webForumDet fria alternativet

Ännu mer tid problem x(

1 svar · 96 visningar · startad av Alpha II

Alpha IIMedlem sedan maj 20002 993 inlägg
#1

Varför blir det inte rätt tid när jag spar variabeln $lmodified_mysql i databasen?

<?php
 include("config.inc.php");
 mysql_connect("$db_host","$db_username","$db_password") or die("Can't connect database!");
 mysql_select_db("$db") or die("Can't connect database");

function showfiles() {
 $Days = 30;
 $sec = $Days*24*60*60;
 $DateLine = Time()-$sec;
 $DateLine = date("Ymdhis", $DateLine);

 echo("<table border=\"0\" width=\"370\" cellpadding=\"0\" cellspacing=\"2\">");
 echo("
   <tr>\n
     <td width=\"150\" bgcolor=\"#c0c0c0\" class=\"text2\">&nbsp;<b>Namn</b></td>\n
     <td bgcolor=\"#c0c0c0\" class=\"text2\">&nbsp;<b>Senast uppdaterad</b></td>\n
     <td width=\"50\" bgcolor=\"#c0c0c0\" class=\"text2\">&nbsp;<b>Admin</b></td>\n
   </tr>\n");

 $drvs = mysql_query("SELECT * FROM FileList WHERE DrvLastModified > '$DateLine' ORDER BY DrvLastModified desc");
 $i = 0;

 while($drv = mysql_fetch_array($drvs)) {
  $New = "";
  $exists = "";
  $lmodified = GetLastModified($drv["DrvFilename"]);
  $lmodified_mysql = date("Ymdhis", $lmodified);
  if($lmodified==0)
  	$exists = " <img src=\"img/delete.gif\" border=\"0\"><img src=\"img/delete.gif\" border=\"0\"><img src=\"img/delete.gif\" border=\"0\">";

  if($lmodified_mysql > $drv["DrvLastModified"]) {
    mysql_query("UPDATE FileList SET DrvLastModified='$lmodified_mysql' WHERE ID='$drv[0]'");
    $New = "<img src=\"img/new.gif\" border=\"0\">";    
  }
  $bgColor = (++$i & 1) ? '#F5F5F5' : '#E0E0E0';
  echo("
   <tr>\n
     <td width=\"150\" bgcolor=\"$bgColor\" class=\"text2\">&nbsp;$New<a href=\"ShowFile.php?fileid=".$drv["ID"]."\">".$drv["DrvName"]."</a>$exists</td>\n
     <td bgcolor=\"$bgColor\" class=\"text2\">&nbsp;".strftime("%Y.%m.%d %H:%M",$lmodified)."</td>\n
     <td bgcolor=\"$bgColor\" class=\"text2\">&nbsp;<a href=\"EditFile.php?fileid=".$drv["ID"]."\"><img src=\"img/edit.gif\" border=\"0\"></a> <a href=\"DeleteFile.php?fileid=".$drv["ID"]."\"><img src=\"img/delete.gif\" border=\"0\"></a></td>\n
  </tr>\n");
 }
 echo("</table>");
}

function GetLastModified($filename) {
	if(file_exists($filename)) {
		if(filetype($filename) == "dir") {
			$dir = $filename;	
			$open_dir = opendir ($dir);
			$time = 0;
			while ($file = readdir($open_dir)) {
				$file = basename ($file);
				$file = $dir."/".$file;
				if (filetype($file) != "dir") {
					$mtime = filemtime ($file);
					if ($mtime > $time) {
						$time = $mtime;
						$thatfile = $file;
					}
				}
			}
		closedir($open_dir);
	
		return($time);
	
		} else {

			return(filemtime($filename));

		}
	} else return(0);
}

?>

När man tar ut tiden från databsen så är det inte den tid jag det ska vara... :(

------------------
I have not failed. I´ve just found 10.000 ways that won´t work. // Thomas Edison

Alpha IIMedlem sedan maj 20002 993 inlägg
#2

Ingen som vet? :q

------------------
I have not failed. I´ve just found 10.000 ways that won´t work. // Thomas Edison

135 ms totalt · 3 externa anrop · v20260731065814-full.86db40fa
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
132 ms — hämta tråd, inlägg och bilagor (db)