// 05/05 - add global seeder/leecher info to DB
if($lastupdate != date("HdmY")) {
echo "<!-- DEBUG: updated leecher/seeder info in main-db-entry (S:";
echo $seeder_ges."/L:".$leecher_ges.") -->\n";
// 24/05
if(($leecher_ges > 0) || ($seeder_ges > 0)) {
@mysql_query("UPDATE cm_dl_info SET deadsince='' WHERE id = '".$id."' LIMIT 1;");
} else if($info[deadsince] == "") {
@mysql_query("UPDATE cm_dl_info SET deadsince='".date("HdmY")."' WHERE id = '".$id."' LIMIT 1;");
}
@mysql_query("UPDATE cm_dl_info SET lastupdate='".date("HdmY")."' , seeder=".($seeder_ges+0)." , leecher=".($leecher_ges+0)." WHERE id = '".$id."' LIMIT 1;");
}
}
$posts = str_replace("{links}", $links, $posts);
}
}
}elseif(isset($_GET['page']) && !isset($_GET['show'])){
$main = str_replace("{part}", strtolower($part[1]), $main);
$infodb = mysql_query("SELECT * FROM cm_dl_info WHERE gruppeid = '$group' ORDER BY name");
$numinfos = mysql_num_rows($infodb);
if($numinfos < $sumbru * $_GET['page'] - $sumbru){ //Testen ob Daten vorhanden sind
$posts = '<center>Keine Daten vorhanden</center>';
}else{
$posts = "";
$bis = $sumbru * $_GET['page'];
$von = $bis - $sumbru;
$posts .= join('',file("html/seiten.htm"));
$maxs = ceil($numinfos / $sumbru);
$posts = str_replace("{page}", $_GET['page']." von ".$maxs, $posts);
$pages = '';
for($i = 1; $i <=$maxs; $i++){
if ($i == $_GET['page']){
$pages .= $i.' ';
}else{
$pages .= '<a href = "?site=main.php&group='.$group.'&page='.$i.'">'.$i.'</a> ';
}
}
$posts = str_replace("{pages}", $pages, $posts);
if($bis > $numinfos){ $bis = $numinfos; }
for($i=0;$i<$bis;$i++){ //Infos einlesen
$info = mysql_fetch_array($infodb);
if($i >= $von){
$id = $info[0];
$lastupdate = $info[lastupdate];
$rated = checkUserRat($id, $ip);
if ($rated) {
$posts .= join('', file("html/postwor.htm"));
} else {
$posts .= join('', file("html/post.htm"));
}
$name = $info[2];
$lang = $info[3];
$pic = $info[4];
$text = $info[5];
$poster = $info[6];
$downloads = $info[7];
$pswd = $info['pswd'];
if ($info[10] == 0) { $info[10] = 1; }
$rating = round($info[8]/$info[10],0);
$posts = str_replace("{title}", stripslashes($name), $posts);
$posts = str_replace("{lang}", 'gfx/'.$lang.'.gif', $posts);
$posts = str_replace("{pic}", $pic, $posts);
$posts = str_replace("{id}", $id, $posts);
$posts = str_replace("{show}", "", $posts);
$posts = str_replace("{pswd}", $pswd, $posts);
if( $info[11] == "")
$posts = str_replace("{quality}", '<i>Unknown</i>', $posts);
else
$posts = str_replace("{quality}", $info[11], $posts);
if( $info[13] == "")
$posts = str_replace("{genre}", '<i>Unknown</i>', $posts);
else
$posts = str_replace("{genre}", $info[13], $posts);
$posts = str_replace("{info}", stripslashes(nl2br($text)), $posts);
$posts = str_replace("{poster}", $poster, $posts);
$posts = str_replace("{downloads}", $downloads, $posts);
$stars = '';
$a = 0;
while($a < $rating){
if($a + 2 <= $rating){
$a += 2;
$stars .= '<img src="gfx/star.gif">';
}else{
$a += 1;
$stars .= '<img src="gfx/hstar.gif">';
}
}
if ($rating == 0) { $stars = "-"; }
$posts = str_replace("{stars}", $stars, $posts);
$linksdb = mysql_query("SELECT * FROM cm_dl_links WHERE infoid = '$id' ORDER BY name");
$anzlinks = mysql_num_rows($linksdb);
if($anzlinks == 0){ //Testen ob Links vorhanden sind
$links = ' <center>Keine Links vorhanden</center>';
}else{
$links = '';
for($d=0;$d<$anzlinks;$d++){
$getlinks = mysql_fetch_array($linksdb); //Links einlesen und speicherm
// 05/05 - check for valid http link to torrentfile and get seeder/leecher
if(strpos($getlinks[link], "http://") !== FALSE) {
if($getlinks['lastupdate'] != date("HdmY")) {
if(($getlinks['tracker'] == "") || ($getlinks['infohash'] == "") || ($getlinks['tracker'] == "http://")) {
$src = encodeurl($getlinks[link]);
include "t_dectorrent.php";
echo "<!-- DEBUG: added missing tracker/infohash to database! -->\n";
@mysql_query("UPDATE cm_dl_links SET tracker='$tracker' , infohash='$infohash' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
if($getlinks[infohash] != "") { $infohash = $getlinks[infohash]; }
if($getlinks[tracker] != "") { $tracker = $getlinks[tracker]; }
include "t_asktracker.php";
echo "<!-- DEBUG: updated seeder/leecher in database! -->\n";
// 24/05
if(($seeder > 0) || ($leecher > 0)) {
@mysql_query("UPDATE cm_dl_links SET deadsince='' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
@mysql_query("UPDATE cm_dl_links SET lastupdate='".date("HdmY")."' , seeder=$seeder , leecher=$leecher WHERE id = '".$getlinks[id]."' LIMIT 1;");
$getlinks[seeder] = $seeder+0;
$getlinks[leecher] = $leecher+0;
}
} else {
if($getlinks[deadsince] == "") {
@mysql_query("UPDATE cm_dl_links SET deadsince='".date("HdmY")."' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
}
$add = "";
// 05/05 - add up all found seeder/leecher for global seeder/leecher info
$leecher_ges += $getlinks[leecher]+0;
$seeder_ges += $getlinks[seeder]+0;
if($getlinks[5] != ""){ $add = stripslashes(" [$getlinks[5]]"); }
// 05/05 - add seeder/leecher to link
if(($getlinks[seeder] > 0) || ($getlinks[leecher] > 0)) {
$add .= " (S:".$getlinks[seeder]."/L:".$getlinks[leecher].")";
}
if($getlinks[4] == ""){
$links .= '<a onclick = "javascript:window.open(\'main.php?iid='.$id.'&dl='.$getlinks[0].'\',\'Fenster2\',\'width=300,height=200,scrollbars=0,left=0,top=0\');return false" href = "main.php?iid='.$id.'&dl='.$getlinks[0].'" target = "_blanc">'.stripslashes($getlinks[1]).'</a> ('.$getlinks[2].' klicks)'.$add.'<br>'."\n";
}else{
$links .= '<a onclick = "javascript:window.open(\'main.php?iid='.$id.'&dl='.$getlinks[0].'\',\'Fenster2\',\'width=300,height=200,scrollbars=0,left=0,top=0\');return false" href = "main.php?iid='.$id.'&dl='.$getlinks[0].'" target = "_blanc">'.stripslashes($getlinks[4]).'</a> ('.$getlinks[2].' klicks)'.$add.'<br>'."\n";
}
}
// 05/05 - add global seeder/leecher info to DB
if($lastupdate != date("HdmY") || ($info[seeder] <> $seeder_ges) || ($info[leecher] <> $leecher_ges)) {
echo "<!-- DEBUG: updated leecher/seeder info in main-db-entry -->";
// 24/05
if(($leecher_ges > 0) || ($seeder_ges > 0)) {
@mysql_query("UPDATE cm_dl_info SET deadsince='' WHERE id = '".$id."' LIMIT 1;");
} else if($info[deadsince] == "") {
@mysql_query("UPDATE cm_dl_info SET deadsince='".date("HdmY")."' WHERE id = '".$id."' LIMIT 1;");
}
@mysql_query("UPDATE cm_dl_info SET lastupdate='".date("HdmY")."' , seeder=".($seeder_ges+0)." , leecher=".($leecher_ges+0)." WHERE id = '".$id."' LIMIT 1;");
}
}
$posts = str_replace("{links}", $links, $posts);
}
}
}
}else{
$showid = $_GET['show'];
$id = $showid;
$infodb = mysql_query("SELECT * FROM cm_dl_info WHERE id = '$showid'");
$numinfos = mysql_num_rows($infodb);
if($numinfos == 0){ //Testen ob Daten vorhanden sind
$posts = 'Der Download existiert nicht';
}else{
$info = mysql_fetch_array($infodb); //Infos einlesen
$lastupdate = $info[lastupdate];
$main = str_replace("{part}", strtolower(stripslashes($info[2])), $main);
$rated = checkUserRat($id, $ip);
if ($rated) {
$posts .= join('', file("html/postwor.htm"));
} else {
$posts .= join('', file("html/post.htm"));
}
$posts = str_replace("{title}", stripslashes($info[2]), $posts);
$posts = str_replace("{lang}", 'gfx/'.$info[3].'.gif', $posts);
$posts = str_replace("{pic}", $info[4], $posts);
$posts = str_replace("{id}", $id, $posts);
$posts = str_replace("{show}", "show=$id&", $posts);
$posts = str_replace("{pswd}", $info['pswd'], $posts);
if( $info[11] == "")
$posts = str_replace("{quality}", '<i>Unknown</i>', $posts);
else
$posts = str_replace("{quality}", $info[11], $posts);
if( $info[13] == "")
$posts = str_replace("{genre}", '<i>Unknown</i>', $posts);
else
$posts = str_replace("{genre}", $info[13], $posts);
$posts = str_replace("{info}", stripslashes(nl2br($info[5])), $posts);
$posts = str_replace("{poster}", $info[6], $posts);
$posts = str_replace("{downloads}", $info[7], $posts);
$stars = '';
if ($info[10] == 0) { $info[10] = 1; }
$rating = round($info[8]/$info[10],0);
$a = 0;
while($a < $rating){
if($a + 2 <= $rating){
$a += 2; $stars .= '<img src="gfx/star.gif">';
}else{
$a += 1; $stars .= '<img src="gfx/hstar.gif">';
}
}
if ($rating == 0) { $stars = "-"; }
$posts = str_replace("{stars}", $stars, $posts);
$linksdb = mysql_query("SELECT * FROM cm_dl_links WHERE infoid = '$showid' ORDER BY name");
$anzlinks = mysql_num_rows($linksdb);
if($anzlinks == 0){ //Testen ob Links vorhanden sind
$links = ' Keine Links vorhanden';
}else{
$links = '';
$seeder_ges = 0;
$leecher_ges = 0;
for($d=0;$d<$anzlinks;$d++){
$getlinks = mysql_fetch_array($linksdb); //Links einlesen und speicherm
// 05/05 - check for valid http link to torrentfile and get seeder/leecher
if(strpos($getlinks[link], "http://") !== FALSE) {
if($getlinks['lastupdate'] != date("HdmY")) {
if(($getlinks['tracker'] == "") || ($getlinks['infohash'] == "") || ($getlinks['tracker'] == "http://")) {
$src = encodeurl($getlinks[link]);
include "t_dectorrent.php";
echo "<!-- DEBUG: added missing tracker/infohash to database! -->\n";
@mysql_query("UPDATE cm_dl_links SET tracker='$tracker' , infohash='$infohash' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
if($getlinks[infohash] != "") { $infohash = $getlinks[infohash]; }
if($getlinks[tracker] != "") { $tracker = $getlinks[tracker]; }
include "t_asktracker.php";
echo "<!-- DEBUG: updated seeder/leecher in database! -->\n";
// 24/05
if(($seeder > 0) || ($leecher > 0)) {
@mysql_query("UPDATE cm_dl_links SET deadsince='' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
@mysql_query("UPDATE cm_dl_links SET lastupdate='".date("HdmY")."' , seeder=$seeder , leecher=$leecher WHERE id = '".$getlinks[id]."' LIMIT 1;");
$getlinks[seeder] = $seeder+0;
$getlinks[leecher] = $leecher+0;
}
} else {
if($getlinks[deadsince] == "") {
@mysql_query("UPDATE cm_dl_links SET deadsince='".date("HdmY")."' WHERE id = '".$getlinks[id]."' LIMIT 1;");
}
}
$add = "";
// 05/05 - add up all found seeder/leecher for global seeder/leecher info
$leecher_ges += $getlinks[leecher]+0;
$seeder_ges += $getlinks[seeder]+0;
if($getlinks[5] != ""){
$add = stripslashes(" [$getlinks[5]]");
}
// 05/05 - add seeder/leecher to link
if(($getlinks[seeder] > 0) || ($getlinks[leecher] > 0)) {
$add .= " » <font color='orange'><b>".$getlinks[seeder]."/".$getlinks[leecher]."</b></font>";
}
if($getlinks[4] == ""){
$links .= '<a href = "?site=main.php&show='.$id.'&iid='.$id.'&dl='.$getlinks[0].'">'.stripslashes($getlinks[1]).'</a> ('.$getlinks[2].' klicks)'.$add.'<br>'."\n";
}else{
$links .= '<a href = "?site=main.php&show='.$id.'&iid='.$id.'&dl='.$getlinks[0].'">'.stripslashes($getlinks[4]).'</a> ('.$getlinks[2].' klicks)'.$add.'<br>'."\n";
}
}
// 05/05 - add global seeder/leecher info to DB
if($lastupdate != date("HdmY") || ($info[seeder] <> $seeder_ges) || ($info[leecher] <> $leecher_ges)) {
echo "<!-- DEBUG: updated leecher/seeder info in main-db-entry (S:";
echo $seeder_ges."/L:".$leecher_ges.") -->\n";
// 24/05
if(($leecher_ges > 0) || ($seeder_ges > 0)) {
@mysql_query("UPDATE cm_dl_info SET deadsince='' WHERE id = '".$id."' LIMIT 1;");
} else if($info[deadsince] == "") {
@mysql_query("UPDATE cm_dl_info SET deadsince='".date("HdmY")."' WHERE id = '".$id."' LIMIT 1;");
}
?>