| 41 | $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_banner WHERE type='0' AND active='1'")); | <> | 41 | if (!function_exists('viewbanner')) { |
| 42 | /* Get a random banner if exist any. */ | 42 | @include_once('includes/mx_bannerfunctions.php'); | |
| 43 | /* More efficient random stuff, thanks to Cristian Arroyo from http://www.planetalinux.com.ar */ | |||
| 45 | if ($numrows>1) { | <> | ||
| 46 | $numrows = $numrows-1; | |||
| 47 | mt_srand((double)microtime()*1000000); | |||
| 48 | $bannum = mt_rand(0, $numrows); | |||
| 49 | } else { | |||
| 50 | $bannum = 0; | |||
| 51 | } | 43 | } | |
| 52 | $sql = "SELECT bid, imageurl, clickurl, alttext FROM ".$prefix."_banner WHERE type='0' AND active='1' LIMIT $bannum,1"; | 44 | if (function_exists('viewbanner')) { | |
| 53 | $result = $db->sql_query($sql); | |||
| 54 | $row = $db->sql_fetchrow($result); | |||
| 55 | $bid = $row[bid]; | 45 | echo viewbanner(1); | |
| 56 | $imageurl = $row[imageurl]; | |||
| 57 | $clickurl = $row[clickurl]; | |||
| 58 | $alttext = $row[alttext]; | |||
| 59 | 46 | } | ||
| 60 | if (!is_admin($admin)) { | |||
| 61 | $db->sql_query("UPDATE ".$prefix."_banner SET impmade=impmade+1 WHERE bid='$bid'"); | |||
| 63 | if($numrows>0) { | +- | ||
| 64 | $sql2 = "SELECT cid, imptotal, impmade, clicks, date FROM ".$prefix."_banner WHERE bid='$bid'"; | |||
| 65 | $result2 = $db->sql_query($sql2); | |||
| 66 | $row2 = $db->sql_fetchrow($result2); | |||
| 67 | $cid = $row2[cid]; | |||
| 68 | $imptotal = $row2[imptotal]; | |||
| 69 | $impmade = $row2[impmade]; | |||
| 70 | $clicks = $row2[clicks]; | |||
| 71 | $date = $row2[date]; | |||
| 73 | /* Check if this impression is the last one and print the banner */ | +- | ||
| 75 | if (($imptotal <= $impmade) AND ($imptotal != 0)) { | +- | ||
| 76 | $db->sql_query("UPDATE ".$prefix."_banner SET active='0' WHERE bid='$bid'"); | |||
| 77 | $sql3 = "SELECT name, contact, email FROM ".$prefix."_bannerclient WHERE cid='$cid'"; | |||
| 78 | $result3 = $db->sql_query($sql3); | |||
| 79 | $row3 = $db->sql_fetchrow($result3); | |||
| 80 | $c_name = $row3[name]; | |||
| 81 | $c_contact = $row3[contact]; | |||
| 82 | $c_email = $row3[email]; | |||
| 83 | if ($c_email != "") { | |||
| 84 | $from = "$sitename <$adminmail>"; | |||
| 85 | $to = "$c_contact <$c_email>"; | |||
| 86 | $message = ""._HELLO." $c_contact:\n\n"; | |||
| 87 | $message .= ""._THISISAUTOMATED."\n\n"; | |||
| 88 | $message .= ""._THERESULTS."\n\n"; | |||
| 89 | $message .= ""._TOTALIMPRESSIONS." $imptotal\n"; | |||
| 90 | $message .= ""._CLICKSRECEIVED." $clicks\n"; | |||
| 91 | $message .= ""._IMAGEURL." $imageurl\n"; | |||
| 92 | $message .= ""._CLICKURL." $clickurl\n"; | |||
| 93 | $message .= ""._ALTERNATETEXT." $alttext\n\n"; | |||
| 94 | $message .= ""._HOPEYOULIKED."\n\n"; | |||
| 95 | $message .= ""._THANKSUPPORT."\n\n"; | |||
| 96 | $message .= "- $sitename "._TEAM."\n"; | |||
| 97 | $message .= "$nukeurl"; | |||
| 98 | $subject = "$sitename: "._BANNERSFINNISHED.""; | |||
| 99 | mail($to, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion()); | |||
| 100 | } | |||
| 101 | } | |||
| 102 | $showbanners = "<a href=\"banners.php?op=click&bid=$bid\" target=\"_blank\"><img src=\"$imageurl\" border=\"0\" alt='$alttext' title='$alttext'></a> "; | |||
| 103 | } | |||
| 104 | } | |||
| 105 | cookiedecode($user); | |||
| 106 | $username = $cookie[1]; | |||
| 107 | if ($username == "") { | |||
| 108 | $username = "Anonymous"; | |||
| 109 | } | |||
| 111 | +- | |||
| 112 | if ($username == "Anonymous") { | |||
| 113 | $theuser = " <a href=\"modules.php?name=Your_Account\">"._LOGIN."</a> or <a href=\"modules.php?name=Your_Account&op=new_user\">"._BREG."</a>"; | |||
| 114 | } else { | |||
| 115 | $theuser = " "._BWEL." $username!"; | |||
| 116 | } | |||
| 117 | ||||
| 158 | $mtime = microtime(); | <> | 90 | $total_time = mxViewBench(); |
| 159 | $mtime = explode(" ",$mtime); | |||
| 160 | $mtime = $mtime[1] + $mtime[0]; | |||
| 161 | $end_time = $mtime; | |||
| 162 | $total_time = ($end_time - $start_time); | |||
| 163 | $total_time = ""._PAGEGENERATION." ".substr($total_time,0,5)." "._SECONDS.""; | |||
| 177 | //$footer_message = footmsg(); | <> | 104 | $footer_message = footmsg('asVariable'); |
| 178 | $footer_message = "$foot1<br>$foot2<br>$foot3"; | |||
| 213 | $posted .= " "._ON." $time $timezone ($counter "._READS.")"; | <> | 139 | $posted .= " "._ON." $time ($counter "._READS.")"; |
| 230 | global $admin, $sid, $tipath; | <> | 156 | global $admin, $sid, $tipath, $notes; |