Jump to content

questions concerning 2 things


Recommended Posts

I have 2 things I am about to do, and I don't know how to do either, hopefully someone can point me in the right direction, 3 questions actually.1. On a linux server what do I do about scanning file downloads for viruses before download.2. How do I embed files, I am at that point, I have my entire script, the last thing left for me to do, is get each file upon entry to embed, if it's a music or video, then in windows media player, if it's text, then just displayed on the page, the songs, and videos will have a link also to download, but will by default be embedded in a page, sort of like on youtube.com I guess is what he said, how do I do that. Or atleast someone who can point me in the right general direction.3. I have to do something else on 2 different projects, the end of this one, and a new one, this is the section, I have to display the data, but have them be able to change it, on one of the projects, he has to be able to change the data, by just entering form information. Then it will update the display information in the other page. The other question I now have to ask here is how do I get the information to display and be able to have them delete it. I have a column in my database, it says approve, it starts at 0, if it is approved, it is changed to 1, if declined, it is deleted. I think I know how do display it, but have no idea how to set it up, so he see's the entries that are most recent, then it says all the information about them, and has a place to delete them as well, then if he approves, they work, like a list, I don't know any advice would be appreciated thanks.

Link to comment
Share on other sites

for the embedding, you would have to find out what kind of file each thing is, then display them accordingly. I think you could save the file type into the database, because it does send that in the $_FILES['yourfile']['type] doesn't it?

Link to comment
Share on other sites

I am not sure about that, I have in my database, the following information currently.

Field Type Attributes Null Default type varchar(100)  Yes NULL                nameoffunny varchar(100)  Yes NULL                keywords varchar(100)  Yes NULL                funnyurl varchar(100)  Yes NULL                entrydate int(11)  Yes NULL                approval tinyint(1)  No 0

Ok the form gathers some of this, the type meaning what kind of file, poem, or song, or video, or whatever they choose, out of 6 choices.THe name of the funny, is what they nam eit, the keywords, are what they choose as keywords to help with searching later. The funnyurl, is the website address the file is moved too, and the entry date, records information about the date it was entered, I put it in as a unix time stamp, so I could custom format it whichever way I want when I pull the date out.The approval is what I am goign to use when I start to allow him to approve, or decline, it is set to 0 to start, if he approves it changes to 1, if he declines, it simply removes it completely from the database, all this is what I need guidance on, specifically you said file type, I am accepting the following extension types currently ubt I have no idea if these are good ideas, I had a longer list, but made severe revisions earlier at the advice of multiple people. $_accepted_extensions = array

('.mpeg', '.mpg', '.wav', '.avi', '.mid', '.jpg', '.jpeg', '.jfif', '.pdf', '.txt', '.wav', '.gif', '.mp2', '.mp3', '.bmp');

The mpeg, mpg, wav, avi, mid, mp2, and mp3 I should be able to all put into a windows media player on the page.The jpg, jpeg, jfif, gif, bmp, I should be able to simply display on the page.The txt, pdf, I should be able to just allow to show there, but I have no idea how to get any of this to work, or what functions to look towards, some examples, or other stuff, and i have done extensive checking on this, right now I am also researching what to do about virus scanning file downloads, before entry into the server, but so far have found nothing, no tutorials, no software no nothing.

Link to comment
Share on other sites

so what I would do is add a column to your database called filetype. then you add the filetype with $_FILES['yourfile']['type'] and if it's an image, you print the html code, if it's a text file, you include it, and if it's a movie you embed it.

Link to comment
Share on other sites

The $_FILES[]['type'] entry is set by the browser, so it's not entirely reliable and different browsers set different mime types for the same thing. Firefox calls a jpg image/jpeg and IE calls it image/pjpeg. You might just have to get the extension from the filename and use that to check. If it's an image, you can use getimagesize to find out what type of image it is regardless of the extension, but that only works for images.PHP also doesn't do virus scanning that I'm aware of. You will need to install a virus scanner on the server, and have it monitor the upload directory. You may also want to insert a wait of a few seconds after you receive the upload to give the virus scanner time to scan and delete the file if necessary, and then check for the existence before you move it.Also, make sure you never use include to display anything you receive through upload. If there is PHP code in the text file, it will get executed if you use include. Use file_get_contents to just display the contents.When you pull your list of inactive entries from the database, you can order them by the date to put them in order. You also need an autonumber ID in the database if you don't have one so that each record has a unique ID.

Link to comment
Share on other sites

See I also have to do something recent that he asked for, he wants each and every page to be a url, on the site, like if it's a funny movie about a dog falling off a bed, it would be www.funnyemailforwards.com/dogfallingoffbedor whatever it was, I need to figure out how to set this up, I will keep this in mind but I don't understand how to take the file types and make them do this. I have been stuck on this a few days, I don't know why I am so confused on this, I have learned so much during these recent projects, I just don't understand 2 things.How to work with files and get them to embed and everything, and how to display data from a form, and allow someone to update that, like delete stuff, sort of like creating a mini admin page or something.

Link to comment
Share on other sites

To embed things on a page you use the exact same way that you do it through HTML. The PHP just sends the appropriate HTML. You will probably use both the object and embed tags, and include the appropriate file name in the tag.If you want named folders like that, I guess you can get the file name, strip off the extension, and create a new folder. Make sure to convert spaces to underscores or dashes, and strip out characters that aren't allowed in a directory name. Once you create the directory, you can create an index.php file inside it with something like this:<?phpheader("Location: ../view_file.php?id=72");?>And just put the right ID for the file. That's why each file needs a unique ID. For the data, you will want to get everything you need out the database, and probably just loop through it, include a link to the actual file, and probably radio buttons for approve/deny. There's not much to it, where are you confused?

Link to comment
Share on other sites

I just ran into a wall, it's 3 things here I don't understand, and no matter what I do my understanding isn't clearing up.1. How to get the url's to appear as url's like the files to be able to be accessed through a url, someone told me about htaccess and did some stuff to get me on the right track but it's not helpful yet.2. How to get the files embedded, but what you told me helped, but I don't get how to get the file to pass into the embed, because I need every single file to be embedded based on it's file type, automatically upon download.3. How to get an admin page created so I can update, and delete database information, I have learnt a lot and overcome a lot but more stuff keeps ocming at me.

Link to comment
Share on other sites

I've never used .htaccess for anything, so I wouldn't be helpful there. But you can create your own folder and add an index file to it like I described. It's not very elegant, but it works.All you need to do to embed a movie, for example, is put the filename in the object or embed tag. The filename is stored in the database, so when you are printing the HTML tags, you just substitute the filename from the database into the tag. Since you have a lot of different file types, you will need to do different things for each one, so you have to check which file type it is before you do anything. You will probably only want to make one page that displays all of your files. That's what I was referring to in my example above with view_file.php. The view_file.php page would get the ID of the file you want to view, get the information from the database, determine the type, and either write an image tag, or an embed and object tag, or show the contents of a text file, or whatever the case may be. It's a lot easier to only have one page that does everything instead of having a different page for each file.Making a page to update or delete database information isn't particularly difficult. You would get the information out of the database, create an HTML form with all of the information filled in, and when they submit the form update the database. That's sort of the basic functionality of using PHP to work with a database, what about that part is confusing to you?

Link to comment
Share on other sites

PHP also doesn't do virus scanning that I'm aware of. You will need to install a virus scanner on the server, and have it monitor the upload directory. You may also want to insert a wait of a few seconds after you receive the upload to give the virus scanner time to scan and delete the file if necessary, and then check for the existence before you move it.
Ok maybe I will take a chance and hope someone just doesn't upload a virus, I never saw anyone else going to the trouble of trying to figure out this aspect.Ok what I don't get is how to take the file information from that page to another, I might have the file url, hmm, let me think about this, maybe I can do something.The last question I had, I didn't understand about the data, I thought if I display data from the database, if just shows up, I don't know how to get it set up to be updateable, that is the part I am getting confused about.
Link to comment
Share on other sites

You can use the data however you want, it's just data. If you want to display a form, and have the default values of the form fields be the data from the database, you can do that. Show the data in editable fields, let the user change it and submit the form, and the processing page reads the new values in and validates everything then updates the database. You will need to make sure the record ID is a hidden form field, so the processing page knows which record in the database to update.<input type="hidden" name="file_id" value="{$row['id']}" />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...