Your IP : 172.28.240.42


Current Path : /var/www/html/clients/kampol.e-nk.ru/OLD/components/com_artbanners/
Upload File :
Current File : /var/www/html/clients/kampol.e-nk.ru/OLD/components/com_artbanners/artbanners.other.php

<?php
/**
* Content code
**/

// Don't allow direct access to the file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

// function that showing one banner
function showBanner( &$tids, &$count, &$start, &$end, $banners=NULL ) {
	global $database, $my, $mosConfig_live_site, $mosConfig_absolute_path, $mosConfig_offset;

	// including classes
	require_once( $mosConfig_absolute_path."/components/com_artbanners/artbanners.class.php" );

	$datetime = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 );
	$weekday = date( "w", time()+$mosConfig_offset*60*60 );
	//$oddd

	$now = new mosArtBannersDate ($datetime);

	$date = $now->year."-".$now->month."-".$now->day;
	$time = $now->hour.":".$now->minute.":".$now->second;
	
	$where = array();
	if ($tids) {
		$where[] = "tid IN ($tids)";
	}
	if ($banners) {
		$where[] = "id IN ($banners)";
	}
	$where = "(".implode(' OR ', $where).") AND";
	
	$query = "SELECT * FROM #__artbanners WHERE $where
		  (('$date' <= SUBSTRING(publish_down,1,10)
		   OR publish_down = '0000-00-00 00:00:00' )
		  AND '$date' >= SUBSTRING(publish_up,1,10)
		  AND (
		      (reccurtype = 0)
		   OR (reccurtype = 1 AND reccurweekdays LIKE '%$weekday%')
		  )
		  AND '$time' >= SUBSTRING(publish_up,12)
		  AND ('$time' <= SUBSTRING(publish_down,12) OR SUBSTRING(publish_down,12) = '00:00:00')
		  AND access <= '$my->gid'
                  AND state = '1') ORDER BY last_show ASC, msec ASC";
	$database->setQuery( $query );
	if(!$database->query()) {
		echo $database->stderr();
		return false;
	}
	$rows = $database->loadObjectList();

	$showed = 0;
	$result = "";

	foreach ($rows as $row) {
		// rows for showing
		$database->setQuery( "UPDATE #__artbanners SET imp_made=imp_made+1 WHERE id='$row->id'" );
		$database->query();

		$database->setQuery( "UPDATE #__artbanners SET last_show='".date("Y-m-d H:i:s", time()+$mosConfig_offset*60*60)."'  WHERE id='$row->id'" );
		$database->query();

		$secs = gettimeofday();
		$database->setQuery( "UPDATE #__artbanners SET msec='".$secs["usec"]."'  WHERE id='$row->id'" );
		$database->query();

		$row->imp_made++;
		$result .= $start;
		if ($row->imp_total == $row->imp_made) {
			$database->setQuery( "UPDATE #__artbanners SET state='0' WHERE id='$row->id'" );
			$database->query();
		}
		if( $row->custom_banner_code != "") {
			$result .= $row->custom_banner_code;
		} else if ((eregi(".gif", $row->image_url)) || (eregi(".jpg", $row->image_url)) || (eregi(".png", $row->image_url))){
			$image_url="$mosConfig_live_site/images/banners/$row->image_url";
			$imginfo = @getimagesize( "$mosConfig_absolute_path/images/banners/".$row->image_url );
			$result .= "<a href=\"".sefRelToAbs("index.php?option=com_artbanners&amp;task=clk&amp;id=$row->id")."\" target=\"_blank\"><img src=\"" . $image_url . "\" border=\"0\" vspace=\"0\" alt=\"$row->name\" width=\"$imginfo[0]\" height=\"$imginfo[1]\" /></a>";
		} 
		else if (eregi(".swf", $row->image_url)) {
			$image_url="$mosConfig_live_site/images/banners/".$row->image_url;
			$swfinfo = @getimagesize( "$mosConfig_absolute_path/images/banners/".$row->image_url );
			$result .= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" border=\"0\" width=\"$swfinfo[0]\" height=\"$swfinfo[1]\" vspace=\"0\">
						<param name=\"SRC\" value=\"$image_url\"><embed src=\"$image_url\" loop=\"false\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\">
						</object></a>";
		}

		$result .= $end;

		$showed++;
		if ($showed == $count) {break;}

	}

	return $result;
}

?>