Jump to content

Xianoth

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    Massachusetts

Xianoth's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok this is what I would like the script to do. 1: scan a target directory and save file information into a mysql db. a. filename b. filesize c. last modified timestamp d. file location 2. Display directory and allow the list to be modified via Last modified, filesize or name. ascending or descending. 3: Allow the directory list to be searched and have displayed results also be affected by point 2. 4. Allow the filename displayed to be a clickable download. Any help to point me into the direction of an existing script that can do this would be extremely helpful. Thanks
  2. Ok I have modded a few things in the script and I have gotten along a lil farther. I am now getting a parse error on line 38, which is the end of the script itself. Not quite sure why this error is being flagged at me.. Here is the modified code: #!/usr/bin/php5-cgi -q //Sets working directory $dir = '/var/www/test'; //Scans the working directory and puts all information into an array function select_files ($dir) { if (is_dir($dir)) { if ($handle = opendir($dir)) { $files = array(); while (false !== ($file = readdir($handle))) { if (is_file($dir.$file) && $file != basename ($_server['PHP_SELF"])) $file [] = $file; } closedir ($handle); if (is_array ($files)) sort ($files); return $files; } } } <?php //Connect to database, assumes database and tables exist mysql_connect ("localhost", "root", "root1234") or die(mysql_error()); mysql_select_db ("dbtest") or die(mysql_error()); //Insert directory array into Database function insert_record ($name, $mod_date){ $sql = sprintf ("INSERT INTO dbtest SET filename = '%s', lastdate = '%s', location = '%s', $name, $mod_date, $fdir); if (mysql_query ($sql)) { return true; } else { return false; } } ?> end I placed the php tags around the actual php code I am trying to use to insert the information into the database. Pointers and suggestions appreciated.
  3. can't say that I have.. I will try it and see if that works..
  4. If this is in the wrong spot, I apologize ahead of time.... I wrote a PHP script and I am trying to have it execute in a bash environment. I have verified that the PHP5-CGI is properly installed. However, when I try to execute this script, all it is doing is echoing back the full script to my terminal screen. I know I must be missing something simple. Please help! Code follows: #!/usr/bin/php5-cgi -q //Sets working directory $dir = /var/www/test //Scans the working directory and puts all information into an array function select_files ($dir) { if (is_dir($dir)) { if ($handle = opendir($dir)) { $files = array(); while (false !== ($file = readdir($handle))) { if (is_file($dir.$file) && $file != basename ($_server['PHP_SELF"])) $file [] = $file; } closedir ($handle); if (is_array ($files)) sort ($files); return $files; } } } //Connect to database, assumes database and tables exist mysql_connect ("localhost", "username", "password") or die(mysql_error()); mysql_select_db ("dbtest") or die(mysql_error()); //Insert directory array into Database function insert_record ($name, $mod_date); $sql = sprintf ("INSERT INTO dbtest SET filename = '%s', lastdate = '%s', location = '%s', $name, $mod_date, $fdir); if (mysql_query ($sql)) { return true; } else { return false; } Also, any advice on the code will be appreciated as well.
  5. Ok.. After getting my code working and all, I am going through the refining process after the feedback I am getting.. So, if you check out my previous post: http://www.phpfreaks.com/forums/index.php/topic,156919.msg682259.html#msg682259 You will see the synopsis of my project. Now however I need to tweak the code on the backend of the user interface. Now this works.. What I need to do is to add a character to the $name value. The inputs are extension numbers, and the filenames are saved with a "-" before the number in the filename. So say ext 111 would actually be -111 in the filename. What would I have to do to modify my script to include a simple "-" ? Any help is appreciated! Thanks!
  6. Bingo! I added the following: and it works.. Awesome! *rubs hands with glee* ahem.. :-D Thanks for the pointer!
  7. Ok, I am a noob, but thats why I am here.. So here's the problem I am having. I have a directory of .wav files set. What I want to do is take the .wav file from its location, pass it through lame to create a .mp3 of the file and then initiate a download of that file, the .mp3 does not have to or need to be saved on the server locally. The filename is being passed via the url as ?name=(filename), and I am using _GET to extract it. I have even gone so far as to set the variable: $name = _GET['name']; so that I can use $name in the php (see, i am paying attention.. ) The whole script i have so far is as follows: Which is working, but is giving me a direct output of the .mp3 file to my screen. I know I am missing a simple part of the function.. Thanks for all the help!
  8. Thanks for the tip.. I will add that and check the results. I appreciate the help and advice.
  9. well. it wasnt working for me, however I was able to take the code suggestions and manipulate a solution as follows: Now I know right off that I can mix the </a><br /> together and not have the second echo command, but I am just learning PHP and I am bastardizing several code snippet references together. What this code is doing for me is taking the value from a form, the value coming in is "ext" , based on that the code then does a directory list and uses the strstr command to show only the value that matches "ext", then returns that entry as a clickable url link. My next step is pushing the return to a cgi script, but I think I have that already worked out. Just need to fine tune it. I thank everyone who helped out, and I hope that someone down the road will be able to use this to further their php learning experience.
  10. Ok I tried out this script.. the first snippet is giving me an error code: Parse error: syntax error, unexpected $end in /usr/local/apache/htdocs/dir7.php on line 15 the code is 14 lines.. any suggestions?
  11. its a start. What happens is the clickable output will redirect to a cgi script.. Let me try this out and I will let you know whats going on. Thanks for the help!
  12. I am in need of guidance and help. I am working on a project where I need to take a variable from a form, then match that variable against a directory list and return a modified list of files available that are clickable. I have created the form - (easy part) and I have found coding that pulls the directory list. I am having trouble finding information on how to take that directory list a sort the results based only on the keyword that was typed in. Any help or direction will be appreciated. Thank you for your time.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.