php code stopped working after upgrade to 5.2.9
Posted: Thu Aug 13, 2009 1:28 pm
Hello,
I was handed over code that was working prior to an upgrade. both code files below.
What would have changed?
my ac.php file
My upload.php code:
I was handed over code that was working prior to an upgrade. both code files below.
What would have changed?
my ac.php file
Code: Select all
<?
include "config.php";
session_start();
if ($logout=="true") { $_SESSION = array(); unset($logname); unset($userid); unset($u_level); unset($logout); header ("Location: upload.php");}
if (@mysql_connect($host,$dbusername,$dbpass)) {} else { echo "DB Connection Error:".mysql_errno().": ".mysql_error()."<BR>"; exit; }
if (@mysql_select_db($workingdb)) {} else { echo "Table Connection Error:".mysql_errno().": ".mysql_error()."<BR>"; exit; }
if(!isset($userid))
{
$_SESSION = array();
$u=$REQUEST_URI;
?>
<html><head><title> Please Log In for Access <?php if(!isset($userid)) {echo $_SERVER['PHP_SELF'];}
?></title></head>
<body><form method="POST" action="/ac.php">
<table width="450" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000">
<tr>
<td colspan="2" align="center" bordercolor="#FFFFFF" bgcolor="#663366"><font color="#FFFFFF" size="6" face="Verdana, Arial, Helvetica, sans-serif"><strong>Login Required </strong></font></td>
</tr>
<tr align="center">
<td colspan="2" bordercolor="#FFFFFF"><font size="-1" face="Arial">You must log in to access this server. </font></td>
</tr>
<tr>
<td width="238" align="right" valign="middle" bordercolor="#FFFFFF">
<font face="Arial, Helvetica, sans-serif">User ID: <br>
Password</font>: <br>
</td>
<td width="198" align="left" bordercolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif">
<input type="hidden" name="loginnow" value="65987412">
<input type="text" name="userid" size="20">
<input name="pwd" type="password" size="20" maxlength="20">
</font></td>
</tr>
<tr align="center">
<td colspan="2" valign="middle" bordercolor="#FFFFFF"><input name="submit" type="submit" value="Log in"></td>
</tr>
</table></form>
</body></html>
<? exit;
}
if ($loginnow=="65987412")
{
if ($userid=="") {$userid="Bad Login";}
if ($pwd=="") {$pwd="*B*a*d* *L*o*g*i*n*";}
unset($loginnow);
$ip=$REMOTE_ADDR;
$dns = gethostbyaddr($ip);
$sql = "SELECT id,username,companyname,password,auth_level FROM `authority` WHERE username = '$userid'";
$result = mysql_query($sql);
if (!$result)
{
error("A database error occurred while checking your ".
"login details.\\nIf this error persists, please ".
"contact HardSoft Systems Ltd.");
}
$loginresult=mysql_fetch_array($result);
$co_name=$loginresult["companyname"];
$u_level=$loginresult["auth_level"];
$logname=$loginresult["username"];
$userid=$loginresult["id"];
$dbpwd=$loginresult[password];
#$pwd=md5($pwd);
$pwd='';
if ($dbpwd==$pwd) { $validuser=true; } else { $validuser=false; }
if ($validuser) {
session_register("userid");
session_register("co_name");
session_register("logname");
session_register("u_level");
if ($conf != true) $reload=true;
header("Location: upload.php");
}
else {
$_SESSION = array(); unset($logname); unset($userid); unset($u_level); unset($logout);
$badlogin=true;
?>
<html><head><title> Access Denied </title></head>
<body>
<table width="450" border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td align="center" bgcolor="#663366"><font color="#FFFFFF" size="5" face="Verdana, Arial, Helvetica, sans-serif"><strong>Access Denied </strong></font></td>
</tr>
<tr>
<td align="center"><font face="Arial, Helvetica, sans-serif">Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$PHP_SELF?>?logout=true">here</a>.
</td>
</tr>
</table>
</body></html>
<? exit;
}
} //loginnow
?>
My upload.php code:
Code: Select all
<?
include "ac.php";
if ($del=="yes") {
$fname=base64_decode($file);
$fname=urldecode($fname);
unlink($fname);
header("Location: upload.php");
}
if ($Upload=="Upload"){
if ($file_name=="") { $u_status=1; } else {
$this_file="./$logname/$file_name";
//echo $this_file;
if (!@copy($file, $this_file)) {
$u_status=2; }
else {
chmod($this_file, 0777);
// chgrp($this_file, adm);
$u_status=3;
mail('jpimentel@hoechtgalvin.ca', "The Backup Server Has Received A File From: $logname", "This File: $file_name was added to $logname's folder.", "From: Backup Server"); //Mails to Jennifer
header("Location: upload.php?u_status=$u_status");
}
unlink ($file);
}//file name valid
} // if upload
if ($u_status==1) { $u_status="<span class=\"failed\">You forgot to choose the file you want to upload. Click Browse and choose your file.</span>"; }
if ($u_status==2) { $u_status="<span class=\"failed\">The File failed to upload Correctly, Please Try again!</span>"; }
if ($u_status==3) { $u_status="<span class=\"success\">The File was uploaded Successfully!</span>"; }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function confirm_ex(url,mess){
if (confirm(mess)){
window.location=url; }}
// -->
</script>
</script>
<title>HGBS - hgbs.hoechtgalvin.ca</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.failed {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FF0000;
}
.success {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #00FF00;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
color: #FFFFFF;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.style6 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; }
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; }
.style9 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #66CC66;
}
.style10 {
font-size: 12px;
font-style: italic;
font-weight: bold;
}
.style12 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14; }
.style13 {font-size: 12px}
.style14 {color: #FFCC33}
.style15 {color: #FFCC33; font-size: 12px; }
.style17 {font-size: 14px; font-style: italic; font-weight: bold; }
-->
</style>
</head>
<body>
<table width="780" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr align="left" bordercolor="#FFFFFF" bgcolor="#339966">
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="right" bgcolor="#287E58">
<td width="776"><img src="admin/images/tit2.gif" width="780" height="77"></td>
</tr>r
</table></td>
</tr>
<tr valign="top" bordercolor="#FFFFFF">
<td width="433"><span class="style2"> <strong>Username:</strong> <?=$logname?></span> <span class="style6"> [<a href="<?=$PHP_SELF?>?logout=true" class="style6">LOGOUT</a>] <? if ($u_level==10) { ?> [<a href="add_edit_users.php" class="style6">User Manager</a>] <? } ?></span><br>
<span class="style2"> <strong>Company Name:</strong> <?=$co_name?>
</span></td>
<td width="161" align="right" class="style2">Server Time <br> <? echo date("D M d, Y"); ?> </td>
</tr>
<tr align="center" valign="bottom" bordercolor="#FFFFFF">
<td colspan="2" align="center" valign="top"><span class="style3"><br>
File Manager<br></span> <span class="style6">( /var/www/html/upload/
<?=$logname?>
/ )</span><br> <span class="style6">These are the files you currently have stored on this backup server, you can click the filename to download the file back to your computer, or click the trashcan to delete the file.</span><span class="style6"> </span></td>
</tr>
<tr align="center" bordercolor="#FFFFFF">
<td colspan="2"><table width="95%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr bordercolor="#CCCCCC">
<td bordercolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12%"> </td>
<td width="12%"> </td>
<td width="38%" align="left" class="style2 style10 style13"> FILENAME</td>
<td align="left" class="style12"><span class="style10"> SIZE </span></td>
<td width="19%" align="left" class="style12"><span class="style10"> DATE </span></td>
</tr>
<?
$x="EEEEEE";
$dir1="./$logname";
if ($handle = opendir($dir1)) { //opendir
while (false !== ($file = readdir($handle))) { //while1
if ($file!="." && $file!=".." && $file!="images") {
$current_file="$dir1/$file";
$fsize1=filesize("$dir1/$file");
$fname=urlencode($current_file);
$fname=base64_encode($fname);
?>
<tr bgcolor="<?=$x?>">
<td align="center"> </td>
<td align="center"><a href="#" onClick="confirm_ex('<?=$PHP_SELF?>?del=yes&file=<?=$fname?>','Delete <?=$file?>');return false;"><img src="admin/images/del.gif" width="23" height="21" border="0"></a></td>
<td align="left" class="style9"><a href="<?=$current_file?>" class="style9"><?=$file?></a></td>
<td width="19%" align="left" class="style2"><? echo get_filesize($fsize1);?></td>
<td align="left" class="style2"><? echo visita_ultima($current_file, "E2");?></td>
</tr>
<? if ($x=="EEEEEE") $x="FFFFFF"; else $x="EEEEEE";
}
}
}
?>
</table></td>
</tr>
</table>
<br>
<table width="95%" border="1" cellspacing="0" cellpadding="0"><form action="./upload.php"
name="uploadform" method="POST" enctype="multipart/form-data">
<tr bordercolor="#FFFFFF">
<td></td>
<td height=1 align="center" class="style2"><?=$u_status?></td>
<td></td>
</tr>
<tr bordercolor="#FFFFFF">
<td> </td>
<td align="center" class="style2"><span class="style17">Upload a File</span><strong><br>
<span class="style6"><span class="style15">Step 1</span> - Click Browse and find the file on your computer.<br>
</span><span class="style14">Step 2</span><span class="style6"> - Click upload! </span> </strong></td>
<td> </td>
</tr>
<tr bordercolor="#FFFFFF">
<td> </td>
<td align="center"><input type="file" name="file"> </td>
<td> </td>
</tr>
<tr bordercolor="#FFFFFF">
<td> </td>
<td align="center"><input name="Upload" type="submit" class="style6" id="Upload" value="Upload"></td>
<td> </td>
</tr></form>
</table>
<br>
</td>
</tr>
</table>
</body>
</html>
<?
function get_filesize ($dsize)
{
if (strlen($dsize) <= 9 && strlen($dsize) >= 7) {
$dsize = number_format($dsize / 1048576,1);
return "$dsize MB";
} elseif (strlen($dsize) >= 10) {
$dsize = number_format($dsize / 1073741824,1);
return "$dsize GB";
} else {
$dsize = number_format($dsize / 1024,1);
return "$dsize KB";
}
}
function visita_ultima($conjuto, $precision)
{
// $conjuto ... (no remote) filename
// $precision ... type of output
// - "D" ... days ago
// - "S" ... seconds ago
//
// - "E1" ... return DD MM YYYY [hh:mm:ss]
// - "E2" ... return DD MM YYYY
//---------------------------------------------------------
$lastvisit = filectime($conjuto);
//echo $lastvisit;
$currentdate = date('U');
$difference = $currentdate - $lastvisit;
if ($precision=="D")
$aviso=intval($difference/84600);
elseif ($precision=="S")
$aviso=$difference;
elseif ($precision=="E1")
$aviso=date('d.m Y [G:i:s]',$lastvisit);
elseif ($precision=="E2")
$aviso= date('M d, Y',$lastvisit);
return $aviso;
}
?>