Location: PHPKode > projects > ToplistHost > toplisthost/update.php
<?php
include_once("ads.inc.php");
#### TABELLE UPDATEN

if(!$listconfig[1] or !$liste) {
	return;
}

### Reset?
if($listconfig[13]) {
	if($listconfig[13] == 1440) {
		$result=mysql_query("select dayofmonth(lastupdate), dayofmonth(curdate()) from ft_all_liste where liste=$liste");
		print mysql_error();
		list($old, $new)=mysql_fetch_row($result);
		if($old != $new) {
			mysql_query("update ft_k_members set spalte1=0, spalte2=0, angemeldet=now() where liste=$liste");
			mysql_query("update ft_k_voting set ip='' where liste=$liste");
			mysql_query("update ft_all_liste set lastreset=now() where liste=$liste");
		}
	} else {
		$result=mysql_query("select liste from ft_all_liste where liste=$liste and lastreset<DATE_SUB(NOW(), interval $listconfig[13] 	minute)");
		print mysql_error();
		if(mysql_num_rows($result)) {
			mysql_query("update ft_k_members set spalte1=0, spalte2=0, angemeldet=now() where liste=$liste");
			mysql_query("update ft_k_voting set ip='' where liste=$liste");
			mysql_query("update ft_all_liste set lastreset=now() where liste=$liste");
			print mysql_error();
		}
	}
}

### Errechene Spalten
switch($listconfig[5]) {
	case 2:
		$result=mysql_query("select kunde, spalte1, spalte2, unix_timestamp(angemeldet), unix_timestamp(now()) from ft_k_members where liste=$liste");
		while($zeile=mysql_fetch_row($result)) {
			$temp=($zeile[4]-$zeile[3])/86400;
			$temp=floor($zeile[2]/$temp);
			if($temp > $zeile[2]) $temp=$zeile[2];
			mysql_query("update ft_k_members set spalte1=$temp where kunde=$zeile[0]");
		}
		break;
	case 3:
		$result=mysql_query("select kunde, round(avg(note)), count(note) from ft_k_voting where liste=$liste and ip!= '' group by kunde");
		while($zeile=mysql_fetch_row($result)) {
			mysql_query("update ft_k_members set spalte2=$zeile[2], spalte1=$zeile[1] where kunde=$zeile[0]");
		}
		break;
	case 4:
		$result=mysql_query("select kunde, spalte1, spalte2, unix_timestamp(angemeldet), unix_timestamp(now()) from ft_k_members where liste=$liste");
		while($zeile=mysql_fetch_row($result)) {
			$temp=($zeile[4]-$zeile[3])/86400;
			$temp=floor($zeile[2]/$temp);
			if($temp > $zeile[2]) $temp=$zeile[2];
			mysql_query("update ft_k_members set spalte1=$temp where kunde=$zeile[0]");
			print mysql_error();
		}
		break;
	case 5:
		$result=mysql_query("select dayofmonth(lastupdate), dayofmonth(curdate()) from ft_all_liste where liste=$liste");
		print mysql_error();
		list($old, $new)=mysql_fetch_row($result);
		if($old != $new) {
			mysql_query("update ft_k_members set spalte1=0 where liste=$liste");
		}
		break;
	case 6:
		$result=mysql_query("select dayofmonth(lastupdate), dayofmonth(curdate()) from ft_all_liste where liste=$liste");
		list($old, $new)=mysql_fetch_row($result);
		if($old != $new) {
			mysql_query("update ft_k_members set spalte1=0 where liste=$liste");
		}
		break;
}

###Tabellenkopf
$result=mysql_query("select html from ft_all_templates where liste=$liste and welches=3");
list($tkopf)=mysql_fetch_row($result);

### Erstelle File-Text
if($listconfig[5] == 4) {
	$sear='and spalte2>0';
} elseif($listconfig[5] != 1 ) {
	$sear='and spalte1>0';
}
$result=mysql_query("select kunde, url, titel, beschreibung, banner, spalte1, spalte2, (unix_timestamp(now())-unix_timestamp(angemeldet)) from ft_k_members where liste=$liste and status=0 $sear order by spalte1 desc limit $listconfig[7]");


$page=1;
#Tabelle inhalt:
$res=mysql_query("select html from ft_all_templates where liste=$liste and welches=4");
list($ttemp)=mysql_fetch_row($res);
$rang=1;
while($zeile=mysql_fetch_row($result)) {
	$temp=str_replace("{url}", "$config[4]/out.php?liste=$liste&id=$zeile[0]", $ttemp);
	if(($zeile[7] < 86400) and  ($listconfig[11])) {
		$temp=str_replace("{titel}", $zeile[2]." <img src=\"$config[4]/new.gif\" border=0>", $temp);
	} else {
		$temp=str_replace("{titel}", $zeile[2], $temp);
	}
	$temp=str_replace("{desc}", $zeile[3], $temp);
	if(($listconfig[8] >= $rang) and $zeile[4])  {
		if($listconfig[10]) {
			list($_breit, $_hoch)=split("x", $listconfig[10]);
			$temp=str_replace("{banner}", "<img src=\"$zeile[4]\" border=0 width=$_breit height=$_hoch>", $temp);
		} else {
			$temp=str_replace("{banner}", "<img src=\"$zeile[4]\" border=0>", $temp);
		}
    } else
		$temp=preg_replace("/(<br>)?([ ]*){banner}([ ]*)?(<br>)?([ ]*)?(<\/a>)?([ ]*)?(<\/p>)?/", "\\6 ", $temp);
	$temp=str_replace("{spalte1}", $zeile[5], $temp);
	$temp=str_replace("{spalte2}", $zeile[6], $temp);
	$temp=str_replace("{rang}", "$rang", $temp);
	$inhalt.=$temp;
	$res=mysql_query("select html from ft_all_wub where liste=$liste and zeile=$rang");
	if(mysql_num_rows($res)) {
		list($temp)=mysql_fetch_row($res);
		$inhalt.="</table><p align=\"center\"> $temp <br>$tkopf";
	}

	if(($rang % $listconfig[33]) == 0) {
		$table=$tkopf.$inhalt."</table>";
		savepage($page);
		$table='';
		$inhalt='';
		$page++;
	}
	$rang++;
}

$btext="<a href=\"$config[4]/newmember.php?liste=$liste\">".gettext2('update_join')."</a>";
for($rang;$rang<=$listconfig[7];$rang++) {
	$temp=preg_replace("/(<br>)?([ ]*){desc}([ ]*)(<br>)?/", "", $ttemp);
	$temp=str_replace("{url}", "", $temp);
	$temp=preg_replace("/(<br>)?([ ]*){banner}([ ]*)(<br>)?/", "", $temp);
	$temp=str_replace("{spalte1}", "-", $temp);
	$temp=str_replace("{spalte2}", "-", $temp);
	$temp=str_replace("{rang}", "-", $temp);
	$temp=preg_replace("/(<br>)?([ ]*){titel}([ ]*)(<br>)?/", "$btext", $temp);
	$inhalt.=$temp;
	$res=mysql_query("select html from ft_all_wub where liste=$liste and zeile=$rang");
	if(mysql_num_rows($res)) {
		list($temp)=mysql_fetch_row($res);
		$inhalt.="</table><p align=\"center\"> $temp <br>$tkopf";
	}
	if(($rang % $listconfig[33]) == 0) {
		$table=$tkopf.$inhalt."</table>";
		savepage($page);
		$table='';
		$inhalt='';
		$page++;
	}
}

$table=$tkopf.$inhalt."</table>";
savepage($page);

mysql_query("update ft_all_liste set lastupdate=now() where liste=$liste");
print mysql_error();



return;

function savepage($page) {
	global $liste, $config, $listconfig, $table;
	werbung();
	if($page == 1) {
		siteofthemoment();
		$fname="index.html";
	} else {
		$fname="index".$page.".html";
	}
	### Tabelle in Seite einf├╝gen
	$result=mysql_query("select html from ft_all_templates where liste=$liste and welches=2");
	list($ttemp)=mysql_fetch_row($result);
	$file=str_replace("{table}",$table, $ttemp);
	$result=mysql_query("select count(kunde), sum(spalte1), sum(spalte2) from ft_k_members where liste=$liste");
	$zeile=mysql_fetch_row($result);
	$file=str_replace("{mem}",$zeile[0], $file);
	$file=str_replace("{spalte1}",$zeile[1], $file);
	$file=str_replace("{spalte2}",$zeile[2], $file);
	$result=mysql_query("select count(kunde) from ft_k_members where liste=$liste and last>date_sub(curdate(), interval 1 day)");
	print mysql_error();
	$zeile=mysql_fetch_row($result);
	$file=str_replace("{aktiv}",$zeile[0], $file);
	$file.=$config[12];
	if($listconfig[17] and ($config[3] > 7)) {
		$file=getad($listconfig[4], 1).$file;
	}

	## Speichern
	$fp=fopen("$config[5]/$liste/$fname","w");
	if(!$fp) {
		return;
	}
	fwrite($fp, $file);
	fclose($fp);
}

function siteofthemoment() {
	global $liste, $table, $listconfig, $config;
	### Site of the moment
	if($listconfig[16]) {
		$result=mysql_query("select html from ft_all_templates where liste=$liste and welches=6");
		list($ttemp)=mysql_fetch_row($result);
		$result=mysql_query("select kunde, url, titel, beschreibung, banner, spalte1, spalte2, (unix_timestamp(now())-unix_timestamp(angemeldet)) from ft_k_members where liste=$liste order by spalte1 desc limit $listconfig[7]");
		$anz=mysql_num_rows($result);
		if($anz == 0) return;
		if($anz > 1) {
			mt_srand((double)microtime()*1000000); 
			$anz = mt_rand(1,$anz)-1; 
		} else {
			$anz--;
		}
		mysql_data_seek($result,$anz); 
		$zeile=mysql_fetch_row($result);
		$temp=str_replace("{titel}", $zeile[2], $ttemp);
		$temp=str_replace("{url}", "$config[4]/out.php?liste=$liste&id=$zeile[0]", $temp);
		$temp=str_replace("{desc}", $zeile[3], $temp);
		if($zeile[4]) {
			if($listconfig[10]) {
				list($_breit, $_hoch)=split("x", $listconfig[10]);
				$temp=str_replace("{banner}", "<img src=\"$zeile[4]\" border=0 width=$_breit height=$_hoch>", $temp);
			} else {
				$temp=str_replace("{banner}", "<img src=\"$zeile[4]\" border=0>", $temp);
			}
		} else
			$temp=preg_replace("/(<br>)?([ ]*){banner}([ ]*)(<br>)?/", "", $temp);
		if(($zeile[7] < 86400) and  ($listconfig[11])) {
			$temp=str_replace("{new}", "$config[6]/new.gif", $temp);
		} else {
			$temp=str_replace("{new}", "", $temp);
		}
		$table=$temp."<br>".$table;
	}
}

function werbung() {
	global $liste, $table, $listconfig, $config;
	####Werbung
	if($listconfig[17]) {
		switch($config[3]) {
			case 7:
				$zeile=getad($listconfig[4],2);
				$table=$table."<br>".$zeile;
			case 3:
				$zeile=getad($listconfig[4],1);
				$table=$table."<br>".$zeile;
			case 1:
				$zeile=getad($listconfig[4], 1);
				$table=$zeile."<br>".$table;
				break;
			case 6:
				$zeile=getad($listconfig[4],2);
				$table=$table."<br>".$zeile;
			case 2:
				$zeile=getad($listconfig[4],1);
				$table=$table."<br>".$zeile;
				break;
			case 9:
			case 4;
				$zeile=getad($listconfig[4],2);
				$table=$table."<br>".$zeile;
				break;
			case 5:
				$zeile=getad($listconfig[4], 1);
				$table=$zeile."<br>".$table;
				$zeile=getad($listconfig[4],2);
				$table=$table."<br>".$zeile;
				break;
		}
	}
}
?>
Return current item: ToplistHost