[ Index ] |
|
Code source de XOOPS 2.0.17.1 |
1 <?php 2 // $Id: banners.php 506 2006-05-26 23:10:37Z skalpa $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 28 include "mainfile.php"; 29 30 /********************************************/ 31 /* Function to let your client login to see */ 32 /* the stats */ 33 /********************************************/ 34 function clientlogin() 35 { 36 global $xoopsDB, $xoopsLogger, $xoopsConfig; 37 include ("header.php"); 38 echo "<style type='text/css'> 39 body {background-color : #fcfcfc;color: #000000;font-weight: normal;font-size: 12px;font-family: Trebuchet MS,Verdana, Arial, Helvetica, sans-serif;margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;} 40 .redirect {width: 70%;margin: 110px;text-align: center;padding: 15px;text-align:center;border: #e0e0e0 1px solid;color: #666666;background-color: #f6f6f6;text-align: center;} 41 .redirect a:link {color: #666666;text-decoration: none;font-weight: bold;} 42 .redirect a:visited {color: #666666;text-decoration: none;font-weight: bold;} 43 .redirect a:hover {color: #999999;text-decoration: underline;font-weight: bold;} 44 hr {height: 3px;border: 3px #E18A00 solid;filter : Alpha(Opacity=100,FinishOpacity=10,Style=2);width: 95%;} 45 font.bigtext { font-size: 16px; font-weight: bold; } 46 </style> 47 48 <form action='banners.php' method='post'> 49 <table width='100%' class='redirect'> 50 <tr><td colspan='2' align='center'> 51 <b>Advertising Statistics</b><hr /></td></tr> 52 <tr><td align='right'><b>Login: </b></td> 53 <td><input class='textbox' type='text' name='login' size='12' maxlength='10' /></td></tr> 54 <tr><td align='right'><b>Password: </b></td> 55 <td><input class='textbox' type='password' name='pass' size='12' maxlength='10' /></td></tr> 56 <tr><td align='center' colspan='2'><input type='hidden' name='op' value='Ok' />".$GLOBALS['xoopsSecurity']->getTokenHTML()." 57 <input type='submit' value='Login'></td></tr> 58 <tr><td colspan='2' align='center'><hr />Please type your client information</td></tr> 59 </table></form>"; 60 include "footer.php"; 61 } 62 63 /*********************************************/ 64 /* Function to display the banners stats for */ 65 /* each client */ 66 /*********************************************/ 67 function bannerstats($login, $pass) 68 { 69 global $xoopsDB, $xoopsConfig, $xoopsLogger; 70 if ($login == "" || $pass == "") { 71 redirect_header("banners.php",2); 72 exit(); 73 } 74 $result = $xoopsDB->query(sprintf("SELECT cid, name, passwd FROM %s WHERE login=%s", $xoopsDB->prefix("bannerclient"), $xoopsDB->quoteString($login))); 75 list($cid, $name, $passwd) = $xoopsDB->fetchRow($result); 76 if ( $pass==$passwd ) { 77 include "header.php"; 78 echo "<style type='text/css'> 79 .b_td {color: #ffffff; background-color: #2F5376; padding: 3px; text-align: center;} 80 </style> 81 <h4 style='text-align:center;'><b>Current Active Banners for $name</b><br /></h4> 82 <table width='100%' border='0'><tr> 83 <td class='b_td'><b>ID</b></td> 84 <td class='b_td'><b>Imp. Made</b></td> 85 <td class='b_td'><b>Imp. Total</b></td> 86 <td class='b_td'><b>Imp. Left</b></td> 87 <td class='b_td'><b>Clicks</b></td> 88 <td class='b_td'><b>% Clicks</b></td> 89 <td class='b_td'><b>Functions</b></td></tr>"; 90 $result = $xoopsDB->query("select bid, imptotal, impmade, clicks, date from ".$xoopsDB->prefix("banner")." where cid=$cid"); 91 while ( list($bid, $imptotal, $impmade, $clicks, $date) = $xoopsDB->fetchRow($result) ) { 92 if ( $impmade == 0 ) { 93 $percent = 0; 94 } else { 95 $percent = substr(100 * $clicks / $impmade, 0, 5); 96 } 97 if ( $imptotal == 0 ) { 98 $left = "Unlimited"; 99 } else { 100 $left = $imptotal-$impmade; 101 } 102 echo "<tr><td align='center'>$bid</td> 103 <td align='center'>$impmade</td> 104 <td align='center'>$imptotal</td> 105 <td align='center'>$left</td> 106 <td align='center'>$clicks</td> 107 <td align='center'>$percent%</td> 108 <td align='center'><a href='banners.php?op=EmailStats&login=$login&pass=$pass&cid=$cid&bid=$bid&t=".$GLOBALS['xoopsSecurity']->createToken()."'>E-mail Stats</a></td></tr>"; 109 } 110 echo "</table><br /><br /><div>Following are your running Banners in " . htmlspecialchars( $xoopsConfig['sitename'] ). " </div><br /><br />"; 111 $result = $xoopsDB->query("select bid, imageurl, clickurl, htmlbanner, htmlcode from ".$xoopsDB->prefix("banner")." where cid=$cid"); 112 while ( list($bid, $imageurl, $clickurl,$htmlbanner, $htmlcode) = $xoopsDB->fetchRow($result) ) { 113 $numrows = $xoopsDB->getRowsNum($result); 114 if ($numrows>1) { 115 echo "<hr /><br />"; 116 } 117 if (!empty($htmlbanner) && !empty($htmlcode)){ 118 echo $myts->displayTarea($htmlcode); 119 }else{ 120 if(strtolower(substr($imageurl,strrpos($imageurl,".")))==".swf") { 121 echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/ swflash.cab#version=6,0,40,0\"; width=\"468\" height=\"60\">"; 122 echo "<param name=movie value=\"$imageurl\" />"; 123 echo "<param name=quality value='high' />"; 124 echo "<embed src=\"$imageurl\" quality='high' pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"; type=\"application/x-shockwave-flash\" width=\"468\" height=\"60\">"; 125 echo "</embed>"; 126 echo "</object>"; 127 } else { 128 echo "<img src='$imageurl' border='1' alt='' />"; 129 } 130 } 131 echo"Banner ID: $bid<br /> 132 Send <a href='banners.php?op=EmailStats&login=$login&cid=$cid&bid=$bid&pass=$pass&t=".$GLOBALS['xoopsSecurity']->createToken()."'>E-Mail Stats</a> for this Banner<br />"; 133 if (!$htmlbanner){ 134 $clickurl = htmlspecialchars($clickurl, ENT_QUOTES); 135 echo "This Banner points to <a href='$clickurl'>this URL</a><br /> 136 <form action='banners.php' method='post'> 137 Change URL: <input class='textbox' type='text' name='url' size='50' maxlength='200' value='$clickurl' /> 138 <input class='textbox' type='hidden' name='login' value='$login' /> 139 <input class='textbox' type='hidden' name='bid' value='$bid' /> 140 <input class='textbox' type='hidden' name='pass' value='$pass' /> 141 <input class='textbox' type='hidden' name='cid' value='$cid' /> 142 <input type='submit' name='op' value='Change' /></form>"; 143 } 144 } 145 146 /* Finnished Banners */ 147 echo "<br />"; 148 if(!$result = $xoopsDB->query("select bid, impressions, clicks, datestart, dateend from ".$xoopsDB->prefix("bannerfinish")." where cid=$cid")){ 149 echo "<h4 style='text-align:center;'>Banners Finished for $name</h4><br /> 150 <table width='100%' border='0'><tr> 151 <td class='b_td'><b>ID</b></td> 152 <td class='b_td'><b>Impressions</b></td> 153 <td class='b_td'><b>Clicks</b></td> 154 <td class='b_td'><b>% Clicks</b></td> 155 <td class='b_td'><b>Start Date</b></td> 156 <td class='b_td'><b>End Date</b></td></tr>"; 157 while ( list($bid, $impressions, $clicks, $datestart, $dateend) = $xoopsDB->fetchRow($result) ) { 158 $percent = substr(100 * $clicks / $impressions, 0, 5); 159 echo "<tr><td align='center'>$bid</td> 160 <td align='center'>$impressions</td> 161 <td align='center'>$clicks</td> 162 <td align='center'>$percent%</td> 163 <td align='center'>".formatTimestamp($datestart)."</td> 164 <td align='center'>".formatTimestamp($dateend)."</td></tr>"; 165 } 166 echo "</table>"; 167 } 168 include "footer.php"; 169 } else { 170 redirect_header("banners.php",2); 171 exit(); 172 } 173 } 174 175 /*********************************************/ 176 /* Function to let the client E-mail his */ 177 /* banner Stats */ 178 /*********************************************/ 179 function EmailStats($login, $cid, $bid, $pass) 180 { 181 global $xoopsDB, $xoopsConfig; 182 if ($login != "" && $pass != "") { 183 $cid = intval($cid); 184 $bid = intval($bid); 185 if ($result2 = $xoopsDB->query(sprintf("select name, email, passwd from %s where cid=%u AND login=%s", $xoopsDB->prefix("bannerclient"), $cid, $xoopsDB->quoteString($login)))) { 186 list($name, $email, $passwd) = $xoopsDB->fetchRow($result2); 187 if ($pass == $passwd) { 188 if ($email == "") { 189 redirect_header("banners.php",3,"There isn't an email associated with client ".$name.".<br />Please contact the Administrator"); 190 exit(); 191 } else { 192 if ($result = $xoopsDB->query("select bid, imptotal, impmade, clicks, imageurl, clickurl, date from ".$xoopsDB->prefix("banner")." where bid=$bid and cid=$cid")) { 193 list($bid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date) = $xoopsDB->fetchRow($result); 194 if ( $impmade == 0 ) { 195 $percent = 0; 196 } else { 197 $percent = substr(100 * $clicks / $impmade, 0, 5); 198 } 199 if ( $imptotal == 0 ) { 200 $left = "Unlimited"; 201 $imptotal = "Unlimited"; 202 } else { 203 $left = $imptotal-$impmade; 204 } 205 $fecha = date("F jS Y, h:iA."); 206 $subject = "Your Banner Statistics at ".$xoopsConfig['sitename']; 207 $message = "Following are the complete stats for your advertising investment at ". $xoopsConfig['sitename']." :\n\n\nClient Name: $name\nBanner ID: $bid\nBanner Image: $imageurl\nBanner URL: $clickurl\n\nImpressions Purchased: $imptotal\nImpressions Made: $impmade\nImpressions Left: $left\nClicks Received: $clicks\nClicks Percent: $percent%\n\n\nReport Generated on: $fecha"; 208 $xoopsMailer =& getMailer(); 209 $xoopsMailer->useMail(); 210 $xoopsMailer->setToEmails($email); 211 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 212 $xoopsMailer->setFromName($xoopsConfig['sitename']); 213 $xoopsMailer->setSubject($subject); 214 $xoopsMailer->setBody($message); 215 $xoopsMailer->send(); 216 redirect_header("banners.php?op=Ok&login=$login&pass=$pass&t=".$GLOBALS['xoopsSecurity']->createToken(), 3, "Statistics for your banner has been sent to your email address."); 217 exit(); 218 } 219 } 220 } 221 } 222 } 223 redirect_header("banners.php",2); 224 exit(); 225 } 226 227 /*********************************************/ 228 /* Function to let the client to change the */ 229 /* url for his banner */ 230 /*********************************************/ 231 function change_banner_url_by_client($login, $pass, $cid, $bid, $url) 232 { 233 global $xoopsDB; 234 if ($login != "" && $pass != "" && $url != "") { 235 $cid = intval($cid); 236 $bid = intval($bid); 237 $sql = sprintf("select passwd from %s where cid=%u and login=%s", $xoopsDB->prefix("bannerclient"), $cid, $xoopsDB->quoteString($login)); 238 if ($result = $xoopsDB->query($sql)) { 239 list($passwd) = $xoopsDB->fetchRow($result); 240 if ( $pass == $passwd ) { 241 $sql = sprintf("update %s set clickurl=%s where bid=%u AND cid=%u", $xoopsDB->prefix("banner"), $xoopsDB->quoteString($url), $bid, $cid); 242 if ($xoopsDB->query($sql)) { 243 redirect_header("banners.php?op=Ok&login=$login&pass=$pass&t=".$GLOBALS['xoopsSecurity']->createToken(), 3, "URL has been changed."); 244 exit(); 245 } 246 } 247 } 248 } 249 redirect_header("banners.php",2); 250 exit(); 251 } 252 253 function clickbanner($bid) 254 { 255 global $xoopsDB; 256 if (is_int($bid) && $bid > 0) { 257 if (xoops_refcheck()) { 258 if ($bresult = $xoopsDB->query("select clickurl from ".$xoopsDB->prefix("banner")." where bid=$bid")) { 259 list($clickurl) = $xoopsDB->fetchRow($bresult); 260 $xoopsDB->queryF("update ".$xoopsDB->prefix("banner")." set clicks=clicks+1 where bid=$bid"); 261 header ('Location: '.$clickurl); 262 } 263 } 264 } 265 exit(); 266 } 267 $op = ''; 268 if (!empty($_POST['op'])) { 269 $op = $_POST['op']; 270 } elseif (!empty($_GET['op'])) { 271 $op = $_GET['op']; 272 } 273 $myts =& MyTextSanitizer::getInstance(); 274 switch ( $op ) { 275 case "click": 276 $bid = 0; 277 if (!empty($_GET['bid'])) { 278 $bid = intval($_GET['bid']); 279 } 280 clickbanner($bid); 281 break; 282 case "login": 283 clientlogin(); 284 break; 285 case "Ok": 286 if (!$GLOBALS['xoopsSecurity']->check()) { 287 redirect_header("banners.php", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 288 exit(); 289 } 290 $login = $pass = ''; 291 if (!empty($_GET['login'])) { 292 $login = $myts->stripslashesGPC(trim($_GET['login'])); 293 } 294 if (!empty($_GET['pass'])) { 295 $pass = $myts->stripslashesGPC(trim($_GET['pass'])); 296 } 297 if (!empty($_POST['login'])) { 298 $login = $myts->stripslashesGPC(trim($_POST['login'])); 299 } 300 if (!empty($_POST['pass'])) { 301 $pass = $myts->stripslashesGPC(trim($_POST['pass'])); 302 } 303 bannerstats($login, $pass); 304 break; 305 case "Change": 306 if (!$GLOBALS['xoopsSecurity']->check()) { 307 redirect_header("banners.php", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 308 exit(); 309 } 310 $login = $pass = $url = ''; 311 $bid = $cid = 0; 312 if (!empty($_POST['login'])) { 313 $login = $myts->stripslashesGPC(trim($_POST['login'])); 314 } 315 if (!empty($_POST['pass'])) { 316 $pass = $myts->stripslashesGPC(trim($_POST['pass'])); 317 } 318 if (!empty($_POST['url'])) { 319 $url = $myts->stripslashesGPC(trim($_POST['url'])); 320 } 321 if (!empty($_POST['bid'])) { 322 $bid = intval($_POST['bid']); 323 } 324 if (!empty($_POST['cid'])) { 325 $cid = intval($_POST['cid']); 326 } 327 change_banner_url_by_client($login, $pass, $cid, $bid, $url); 328 break; 329 case "EmailStats": 330 if (!$GLOBALS['xoopsSecurity']->check()) { 331 redirect_header("banners.php", 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); 332 exit(); 333 } 334 $login = $pass = ''; 335 $bid = $cid = 0; 336 if (!empty($_GET['login'])) { 337 $login = $myts->stripslashesGPC(trim($_GET['login'])); 338 } 339 if (!empty($_GET['pass'])) { 340 $pass = $myts->stripslashesGPC(trim($_GET['pass'])); 341 } 342 if (!empty($_GET['bid'])) { 343 $bid = intval($_GET['bid']); 344 } 345 if (!empty($_GET['cid'])) { 346 $cid = intval($_GET['cid']); 347 } 348 EmailStats($login, $cid, $bid, $pass); 349 break; 350 default: 351 clientlogin(); 352 break; 353 } 354 355 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 11:44:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |