bostonjim Posted June 24, 2010 Share Posted June 24, 2010 Here is the code I'm using... it is supposed to sort the results in alphabetical order... but it doesn't. <?php $THUMBNAIL_FOLDER = "_thumbnails"; $HIDDEN_FILES[] = "Thumbs.db"; $HIDDEN_FILES[] = "index.php"; $HIDDEN_FILES[] = $THUMBNAIL_FOLDER; $THUMBNAIL_WIDTH = 200; $THUMBNAIL_HEIGHT = 100; // Image Output; HandleImageOutput(); ?> <html> <head> <title>Index Of.</title> <style> body { background-color: #FCFFF0; font-size: 12px;} A:link {text-decoration: none; color: blue} A:visited {text-decoration: none; color: blue} A:active {text-decoration: none; color: blue} A:hover {text-decoration: underline; color: blue} #images, #folders, #files { border: 1px solid #000000; background-color: #fff; margin: 50px; padding: 25px; } DIV.image { width: <?php echo $THUMBNAIL_WIDTH; ?>; height: <?php echo $THUMBNAIL_HEIGHT; ?>; float: left; margin: 10px; text-align: center; border: 0px; } IMG { border: 1px solid #444; background-color: #eee; } </style> </head> <body> <p><br><p><table width=100%><tr width=100%><td width=100%><h2>Title</h2> <font face=tahoma> <?php $Browse = $_GET["b"] ; if ( $Browse ) { $Browse .= "/"; } // Stop them accessing higher level folders if ( substr_count( $Browse, ".." ) > 0 || substr_count( $Browse, $THUMBNAIL_FOLDER ) > 0 ) { echo "You don't have permission to access this folder!"; exit(); } $DIR = "./" . $Browse; $d = dir( $DIR ); while (false !== ($entry = $d->read())) { if ($entry[0] == '.') continue; if ( in_array( $entry, $HIDDEN_FILES) ) continue; // Don't list the folder if it has an index! if ($entry == 'index.html') exit(); if ($entry == 'index.htm') exit(); if ($entry == 'index.php') exit(); if ($entry == 'index.asp') exit(); if ( IsImage($entry) ) $images[] = array( filemtime( $DIR . "/" . $entry ), $entry ); else if ( is_dir( $DIR . "/" . $entry ) ) $folders[] = array( filemtime( $DIR . "/" . $entry ), $entry ); else $files[] = array( filemtime( $DIR . "/" . $entry ), $entry ); } if ( count( $folders ) > 0 ) { echo "<div id=\"folders\">"; arsort($folders); foreach ( $folders as $fn ) { echo "<a href=\"$fn[1]/index.php\">$fn[1]</a><br>"; } echo "</div>"; } if ( count( $files ) > 0 ) { echo "<div id=\"files\">"; arsort($files); foreach ( $files as $fn ) { echo "<a href=\"$Browse$fn[1]\">$fn[1]</a><br>"; } echo "</div>"; } if ( count( $images ) > 0 ) { echo "<div id=\"images\"><div style=\"clear: both;\"></div>"; arsort($images); foreach ( $images as $fn ) { echo GetImageLink( $Browse . $fn[1], $fn[1] ); } echo "<div style=\"clear: both;\"></div></div>"; } ?> </body> </html> <? ////// FUNCTIONS ///// function IsImage( $i ) { $i = strtolower( $i ); if ( substr_count( $i, ".jpg" ) > 0 || substr_count( $i, ".jpeg" ) > 0 || substr_count( $i, ".gif" ) > 0 || substr_count( $i, ".png" ) > 0 ) { return true; } return false; } function GetImageLink( $imgfilename, $img ) { global $THUMBNAIL_WIDTH, $THUMBNAIL_HEIGHT; return "<div class=\"image\"><a href=\"$imgfilename\"><img src=\"?img=$imgfilename\" width=$THUMBNAIL_WIDTH height=$THUMBNAIL_HEIGHT></a><br>$img</div>"; } function HandleImageOutput() { global $THUMBNAIL_FOLDER, $THUMBNAIL_WIDTH, $THUMBNAIL_HEIGHT; $image = $_GET['img']; if (!$image) return; $imagecache = $THUMBNAIL_FOLDER . "/" . md5( $THUMBNAIL_WIDTH . $THUMBNAIL_HEIGHT . $image ) . ".jpg"; $im = @imagecreatefromjpeg( $imagecache ); if ( $im ) { header("Content-type: image/jpg"); imagejpeg($im); imagedestroy($im); exit(); } $imgsize = getimagesize ( $image ); switch ($imgsize[2]) { case 1: // GIF $im = imagecreatefromgif( $image ); break; case 2: // JPG $im = imagecreatefromjpeg( $image ); break; case 3: // PNG $im = imagecreatefrompng( $image ); break; default: // UNKNOWM! echo "Unknown Image!"; exit(); } header("Content-type: image/jpg"); $img_thumb = imagecreatetruecolor( $THUMBNAIL_WIDTH, $THUMBNAIL_HEIGHT ); $dsth = ($THUMBNAIL_WIDTH / ImageSX($im)) * ImageSY($im); imagecopyresampled( $img_thumb, $im, 0,($THUMBNAIL_HEIGHT-$dsth)/2, 0,0, $THUMBNAIL_WIDTH, $dsth, ImageSX($im), ImageSY($im) ); imagejpeg( $img_thumb ); // This will fail if you haven't created and chmodded your thumbnails folder if ( $im && $img_thumb ) { @imagejpeg( $img_thumb, $imagecache, 95 ); } imagedestroy( $img_thumb ); imagedestroy( $im ); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/ Share on other sites More sharing options...
phpchamps Posted June 24, 2010 Share Posted June 24, 2010 If you use the button element in an HTML form, different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. Use the input element to create buttons in an HTML form. Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076547 Share on other sites More sharing options...
bostonjim Posted June 24, 2010 Author Share Posted June 24, 2010 Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076554 Share on other sites More sharing options...
phpchamps Posted June 24, 2010 Share Posted June 24, 2010 oops... sorry thts the answer of the different post.. please ignore my answer.. sorry Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076559 Share on other sites More sharing options...
bostonjim Posted June 24, 2010 Author Share Posted June 24, 2010 I just noticed something that I need to mention. Using the sorting I have in my code, it actually is sorting... but the sorting is broken up into two groups. First it runs through the shorter names alphabetically, then it starts over at "A" and runs through the longer names (longer than 8 or so letters) alphabetically... why would it do this? Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076566 Share on other sites More sharing options...
bostonjim Posted June 24, 2010 Author Share Posted June 24, 2010 I shortened the name of one of the longer entries thinking that it would change position in the sort, since they seem to be grouping into the two separate alphabetical groups based on length (one for shorter entires and one for longer ones of 9+ characters), but it stayed in the same position. So it's not due to length. I really don't get this. I just want the array to sort in alphabetical order. But for some reason, it is separating some of them from the others and then, secondarily, sorting the two groups alphabetically... Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076573 Share on other sites More sharing options...
bostonjim Posted June 24, 2010 Author Share Posted June 24, 2010 Well, I've pretty much narrowed down the problem. When I make some change to a file in the folder, that folder pops to the top of the list in its parent folder (where I have this php code displaying the contents of that folder). So it is actually sorting them by the date of the folder's contents. The partially alphabetical sorting is just due to the fact that they mostly uploaded in that order. ANY help on why it would be doing this would be appreciated... Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076584 Share on other sites More sharing options...
bostonjim Posted June 24, 2010 Author Share Posted June 24, 2010 Well, it's sad to see that I figured out that the use of filemtime in the array was the problem before the "experts" around here did. /thread Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076587 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 Well ... you gave us this big long script which we're not familiar with, but didn't give us an example of the array you were trying to sort (both before & after). Sometimes, you have better luck trying to solve a problem yourself, than waiting for a solution from a forum. Ken Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076594 Share on other sites More sharing options...
salathe Posted June 24, 2010 Share Posted June 24, 2010 I figured out ... filemtime ... was the problem before the "experts" around here did. I figured out the answer last week, but a badger ate it. Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076642 Share on other sites More sharing options...
Mchl Posted June 24, 2010 Share Posted June 24, 2010 Well, it's sad to see that I figured out that the use of filemtime in the array was the problem before the "experts" around here did. /thread Quite to contrary. You should be really proud of yourself. Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076643 Share on other sites More sharing options...
Pikachu2000 Posted June 24, 2010 Share Posted June 24, 2010 Well, it's sad to see that I figured out that the use of filemtime in the array was the problem before the "experts" around here did. /thread With that attitude, I hope you never come here for help with your "scripts" again. Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076648 Share on other sites More sharing options...
premiso Posted June 24, 2010 Share Posted June 24, 2010 Well, it's sad to see that I figured out that the use of filemtime in the array was the problem before the "experts" around here did. /thread There are experts on this board? Since when ??? Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076649 Share on other sites More sharing options...
salathe Posted June 24, 2010 Share Posted June 24, 2010 There are experts on this board? Since when ??? That's why the word was wrapped in double-quotes! Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076655 Share on other sites More sharing options...
premiso Posted June 24, 2010 Share Posted June 24, 2010 There are experts on this board? Since when ??? That's why the word was wrapped in double-quotes! Oh! Well to answer the OP's question, you should really look at the filemtime in that script, I think that is the problem! Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076657 Share on other sites More sharing options...
Maq Posted June 24, 2010 Share Posted June 24, 2010 Well, it's sad to see that I figured out that the use of filemtime in the array was the problem before the "experts" around here did. /thread Sorry bostonjim, I was still sleeping. I'll make sure to get up at the crack of dawn to answer your question. Quote Link to comment https://forums.phpfreaks.com/topic/205730-thing-wont-alphabetize/#findComment-1076722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.