@@ 3289-3344 (lines=56) @@ | ||
3286 | * |
|
3287 | * @return null|string |
|
3288 | */ |
|
3289 | public static function xtubeGetBannerFromBannerId($banner_id) |
|
3290 | { |
|
3291 | ###### Hack by www.stefanosilvestrini.com ###### |
|
3292 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
3293 | $bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id); |
|
3294 | list($numrows) = $db->fetchRow($bresult); |
|
3295 | if ($numrows > 1) { |
|
3296 | --$numrows; |
|
3297 | mt_srand((double)microtime() * 1000000); |
|
3298 | $bannum = mt_rand(0, $numrows); |
|
3299 | } else { |
|
3300 | $bannum = 0; |
|
3301 | } |
|
3302 | if ($numrows > 0) { |
|
3303 | $bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id, 1, $bannum); |
|
3304 | list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
3305 | if ($GLOBALS['xoopsConfig']['my_ip'] === xoops_getenv('REMOTE_ADDR')) { |
|
3306 | // EMPTY |
|
3307 | } else { |
|
3308 | $db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
3309 | } |
|
3310 | /* Check if this impression is the last one and print the banner */ |
|
3311 | if ($imptotal === $impmade) { |
|
3312 | $newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
|
3313 | $sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, |
|
3314 | $date, time()); |
|
3315 | $db->queryF($sql); |
|
3316 | $db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
3317 | } |
|
3318 | if ($htmlbanner) { |
|
3319 | $bannerobject = $htmlcode; |
|
3320 | } else { |
|
3321 | $bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
|
3322 | if (false !== stripos($imageurl, '.swf')) { |
|
3323 | $bannerobject = $bannerobject |
|
3324 | . '<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">' |
|
3325 | . '<param name="movie" value="' |
|
3326 | . $imageurl |
|
3327 | . '"></param>' |
|
3328 | . '<param name="quality" value="high"></param>' |
|
3329 | . '<embed src="' |
|
3330 | . $imageurl |
|
3331 | . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
|
3332 | . '</embed>' |
|
3333 | . '</object>'; |
|
3334 | } else { |
|
3335 | $bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="" />'; |
|
3336 | } |
|
3337 | $bannerobject .= '</a></div>'; |
|
3338 | } |
|
3339 | ||
3340 | return $bannerobject; |
|
3341 | } |
|
3342 | ||
3343 | return null; |
|
3344 | } |
|
3345 | ||
3346 | /** |
|
3347 | * @param $client_id |
|
@@ 3351-3406 (lines=56) @@ | ||
3348 | * |
|
3349 | * @return null|string |
|
3350 | */ |
|
3351 | public static function xtubeGetBannerFromClientId($client_id) |
|
3352 | { |
|
3353 | ###### Hack by www.stefanosilvestrini.com ###### |
|
3354 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
3355 | $bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id); |
|
3356 | list($numrows) = $db->fetchRow($bresult); |
|
3357 | if ($numrows > 1) { |
|
3358 | --$numrows; |
|
3359 | mt_srand((double)microtime() * 1000000); |
|
3360 | $bannum = mt_rand(0, $numrows); |
|
3361 | } else { |
|
3362 | $bannum = 0; |
|
3363 | } |
|
3364 | if ($numrows > 0) { |
|
3365 | $bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id . ' ORDER BY rand()', 1, $bannum); |
|
3366 | list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
3367 | if ($GLOBALS['xoopsConfig']['my_ip'] === xoops_getenv('REMOTE_ADDR')) { |
|
3368 | // EMPTY |
|
3369 | } else { |
|
3370 | $db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
3371 | } |
|
3372 | /* Check if this impression is the last one and print the banner */ |
|
3373 | if ($imptotal === $impmade) { |
|
3374 | $newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
|
3375 | $sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, |
|
3376 | $date, time()); |
|
3377 | $db->queryF($sql); |
|
3378 | $db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
|
3379 | } |
|
3380 | if ($htmlbanner) { |
|
3381 | $bannerobject = $htmlcode; |
|
3382 | } else { |
|
3383 | $bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
|
3384 | if (false !== stripos($imageurl, '.swf')) { |
|
3385 | $bannerobject = $bannerobject |
|
3386 | . '<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">' |
|
3387 | . '<param name="movie" value="' |
|
3388 | . $imageurl |
|
3389 | . '"></param>' |
|
3390 | . '<param name="quality" value="high"></param>' |
|
3391 | . '<embed src="' |
|
3392 | . $imageurl |
|
3393 | . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
|
3394 | . '</embed>' |
|
3395 | . '</object>'; |
|
3396 | } else { |
|
3397 | $bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="" />'; |
|
3398 | } |
|
3399 | $bannerobject .= '</a></div>'; |
|
3400 | } |
|
3401 | ||
3402 | return $bannerobject; |
|
3403 | } |
|
3404 | ||
3405 | return null; |
|
3406 | } |
|
3407 | ||
3408 | /** |
|
3409 | * |