Jump to content

switched from php4 to 5, broke part of my script


frigate

Recommended Posts

Hey guys,

A few years ago my friend wrote a small script for a page on my site where my friends and I can upload pictures or whatever to share with each other. My server switched from PHP4 to 5 and it broke the function that allows you to sort the uploaded files by year: if you click on a previous year, it just shows the current one. It's kind of lame since I've had my site for over 4 years and I can only see a tiny fraction of the files without FTPing.

 

Anyway, this is some of the code for the page that allows you to browse files, browse.php (if needed I can post the rest of the code):

 

<? //List the possible years
function ArrayToURL($Arr) //Takes in an array and prepares its variables to be outputed as parameters in a URL
{
$RetArray=Array();
foreach($Arr as $Key =>$Val)
	$RetArray[]=urlencode($Key)."=".urlencode($Val);
return implode("&",$RetArray);
}

$StartYear=2006; //First year to list
$Dates=array_merge(Array("All"), range($StartYear, date("Y"))); //Possible Years
$Year=(!isset($Year) || !in_array($Year, $Dates) ? date("Y") : $Year); //Set the current year to this year if not set or invalid
foreach($Dates as $Date) //Print out the possibilities
print ($Year!=$Date ? "<a href=browse.php?".ArrayToURL(array_merge($_GET, Array('Year'=>$Date))).">" : "").$Date.($Year!=$Date ? "</a>" : "")." ";
?>
| Sort:
<? //List possible sorts
$Sorts=Array("Date Up", "Date Down", "Name Up", "Name Down"); //Possible Sorts
$Sort=(!isset($Sort) || !in_array($Sort, $Sorts) ? "Date Up" : $Sort); //Set the current sort to "Date Up" if not set or invalid
foreach($Sorts as $CurSort) //Print out the possibilities
print ($Sort!=$CurSort ? "<a href=browse.php?".ArrayToURL(array_merge($_GET, Array('Sort'=>$CurSort))).">" : "").$CurSort.($Sort!=$CurSort ? "</a>" : "")." ";
?>

 

If it's not too much trouble I'd be really really grateful if someone could help :) I tried searching the site but I couldn't find anything, maybe I'm just not familiar enough with PHP to search for the right terms though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.