Jump to content

rtil

New Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rtil's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok, thank you. i'll probably come back here with questions
  2. and to be extra safe, you could also write an array of symbols you'd want to be replaced by an underscore, like this: illegal_characters = Array(" ", "%20", ";", "#", "~"); $newname = strtolower(str_replace(illegal_characters,"_",$_FILES['doc_uploaded']['name'])); some file uploaders tend to misbehave if there are strange characters present. at least mine did, haha
  3. i'd love to do that, but as i previously stated, i have no idea how to go about writing a script like that and i need a little guidance.
  4. hello everyone well, i'm going to say straight up i am very much a novice at php and all that i've learned has been gathered mostly by analyzing other people's work. one ongoing project i've been working on is a simple file upload page that lists the files and sorts them alphabetically. my goal is to be able to let people also sort them by filesize and date uploaded. i have been told that this is almost impossible without using mysql - is that true? anyway, here is the page: http://www.thebackalleys.com/ok/public/ WARNING: it takes about a minute for the page to load (therein lies the problem). and here is the script on the page, which is a mixture of code that i wrote along with code that i have found and modified to suit my needs (mostly for the look of the page): <? $colorbar = 0; $path = "."; $dir_handle = opendir($path) or die("Unable to open $path"); $paths = array(); while ($file = readdir($dir_handle)){ if(!is_dir($file)){ $paths[] = "$path$file"; } } closedir($dir_handle); sort($paths); foreach ($paths as $link) { $show = str_replace(" ","%20",substr($link,strrpos($link, '/')+1)); if ($show != ".htaccess" && $show != ".ftpquota" && substr($show,-3) != "php" && $show != "ajax-loader.gif"){ $total_files++; $root = "http://www.thebackalleys.com/ok/public/"; $root .= $show; $root = str_replace(" ","%20",$root); if ($colorbar&1){ echo "</tr><tr><td align='left'><a href=" . $show . ">"; }else{ echo "</tr><tr><td align='left' bgcolor='#343234'><a href=" . $show . ">"; } $show = substr($link,strrpos($link, '/')+1); echo "$show</a></td>\n"; $f = fopen($root, 'r'); if ($colorbar&1){ echo "<td align='right'>"; $colorbar++; }else{ echo "<td align='right' bgcolor='#343234'>"; $colorbar++; } $divsize = sprintf("%01.2f",filesize($show)/1000,-1); $total_filesize = $total_filesize + $divsize; if ($divsize < 1100){ echo " " . $divsize; echo "KB"; }else{ echo " " . sprintf("%01.1f",$divsize/1000,-1); echo "MB"; } echo "</td>"; fclose($f); }else{ } } echo "</table>"; echo "<p>\n"; echo "Total files: <b>$total_files</b> <br>\n"; $average_filesize = sprintf("%01.1f",$total_filesize/$total_files,1); echo "Average file size: <b>$average_filesize</b>KB <br> \n"; $total_filesize = sprintf("%01.1f",$total_filesize/1000,1); echo "Total directory size: <b>$total_filesize</b>MB <br>\n"; echo "</p>"; ?> i know the loops is what is making this slow. i guess i have 3 questions: 1. is this script poorly written, and if so how can i optimize it? however, 2. if it can't be made efficient in any possible way, does it need to be made in mysql? and if that is the case, 3. can anyone point me in the right direction on how to begin writing such a script? thank you for your time, -rtil
  5. hi i am using invision power board and poteto wacintaki bbs board, and i was wondering is it simple to take things like this that have a member database and easily merge the user databases? or is this really messy? is it even perhaps possible to have the two linked so that if you make an account on the forums and you'll also have an account on the bbs board as well? they are on two seperate databases, but they seem to have similar user/pass things. i am really new to this, so sorry if this is really easy or something.
×
×
  • 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.