Jump to content

Php Advert View Counter.


irishpeck

Recommended Posts

**Ads.php**

<?php

require_once("config.inc.php");
require_once("pager.cls.php");


// Pager
$page = $_GET['page'] ? $_GET['page'] : 1;
$offset = ($page-1) * $ads_per_page;

if ($sef_urls && !$xsearchmode)
{
if ($xview == "events")
{
	$urlformat = "{$vbasedir}$xcityid/events/$xdate/page{@PAGE}.html";
}
else
{
	$urlformat = "{$vbasedir}$xcityid/posts/$xcatid/".($xsubcatid?$xsubcatid:0)."/page{@PAGE}.html";
}
}
else
{
$urlformat = "?";
$tmp = $_GET;
unset($tmp['page'], $tmp['msg']);
foreach ($tmp as $k=>$v) $urlformat .= "$k=$v&";
$urlformat .= "page={@PAGE}";
}

// Location condition
if($xcityid > 0)
{
$loc_condn = $city_condn = "AND a.cityid = $xcityid";
}
else
{
$loc_condn = $country_condn = "AND ct.countryid = $xcountryid";
}


if ($xview == "events")
{
$where = "";

if ($xsearch)
{
	$searchsql = mysql_escape_string($xsearch);
	$where = "(a.adtitle LIKE '%$searchsql%' OR a.addesc LIKE '%$searchsql%') AND a.endon >= NOW()";
}
else if ($xdate)
{
	$where = "(starton <= '$xdate' AND endon >= '$xdate')";
}
else
{
	$where = "starton >= NOW()";
}

if($_GET['area']) $where .= "AND a.area = '$_GET[area]'";


if ($xsearchmode)
{
	$sort = "a.starton ASC";
}
else
{
	$sort = "a.starton DESC";
}

            
// Get count
$sql = "SELECT COUNT(*) AS adcount
		FROM $t_events a
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E'
		WHERE $where
			AND $visibility_condn
			AND (feat.adid IS NULL OR feat.featuredtill < NOW())
			$loc_condn";
$tmp = mysql_query($sql) or die($sql.mysql_error());
list($adcount) = mysql_fetch_array($tmp);

// Get results
$sql = "SELECT a.*, COUNT(*) AS piccount, p.picfile,
			UNIX_TIMESTAMP(a.createdon) AS timestamp, ct.cityname,
			UNIX_TIMESTAMP(a.starton) AS starton, UNIX_TIMESTAMP(a.endon) AS endon			
		FROM $t_events a
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '1'
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E'
		WHERE $where
			AND $visibility_condn
			AND (feat.adid IS NULL OR feat.featuredtill < NOW())
			$loc_condn
		GROUP BY a.adid
		ORDER BY $sort
		LIMIT $offset, $ads_per_page";
$res = mysql_query($sql) or die($sql.mysql_error());

// Get featured events
$sql = "SELECT a.*, COUNT(*) AS piccount, p.picfile,
			UNIX_TIMESTAMP(a.createdon) AS timestamp, ct.cityname,
			UNIX_TIMESTAMP(a.starton) AS starton, UNIX_TIMESTAMP(a.endon) AS endon
		FROM $t_events a
			INNER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E' AND feat.featuredtill >= NOW()
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '1'
		WHERE $where
			AND $visibility_condn
			$loc_condn
		GROUP BY a.adid
		ORDER BY $sort";
$featres = mysql_query($sql) or die(mysql_error().$sql);

// Vars
$adtable = $t_events;
$adtype = "E";
$target_view = "showevent";
$target_view_sef = "events";
//$page_title = "Events";
if ($_GET['date']) $link_extra = "&date=$xdate";
else $find_date = TRUE;

}
else
{
// Make up the sql query
$whereA = array();

if ($xsearch)
{
	$searchsql = mysql_escape_string($xsearch);
	$whereA[] = "(a.adtitle LIKE '%$searchsql%' OR a.addesc LIKE '%$searchsql%')";
}

if($_GET['area']) $whereA[] = "a.area = '$_GET[area]'";

if ($xsubcathasprice && $_GET['pricemin'])
{
	$whereA[] = "a.price >= $_GET[pricemin]";
}

if ($xsubcathasprice && $_GET['pricemax'])
{
	$whereA[] = "a.price <= $_GET[pricemax]";
}

if ($xsubcatid)		$whereA[] = "a.subcatid = $xsubcatid";
else if ($xcatid)	$whereA[] = "scat.catid = $xcatid";

if (count($_GET['x']))
{
	foreach ($_GET['x'] as $fldnum=>$val)
	{
		if (!$val) continue;

		if($xsubcatfields[$fldnum]['TYPE'] == "N" && is_array($val))
		{
			if($val['min']) $whereA[] = "axf.f{$fldnum} >= $val[min]";
			if($val['max']) $whereA[] = "axf.f{$fldnum} <= $val[max]";
		}
		elseif($xsubcatfields[$fldnum]['TYPE'] == "D") 
		{
			$whereA[] = "axf.f{$fldnum} = '$val'";
		}
		else
		{
			$whereA[] = "axf.f{$fldnum} LIKE '%$val%'";
		}
	}
}

$where = implode(" AND ", $whereA);
if (!$where) $where = "1";

// Get count
$sql = "SELECT COUNT(*) AS adcount
		FROM $t_ads a
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			INNER JOIN $t_subcats scat ON a.subcatid = scat.subcatid
			INNER JOIN $t_cats cat ON scat.catid = cat.catid
			LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A'
		WHERE $where
			AND $visibility_condn
			AND (feat.adid IS NULL OR feat.featuredtill < NOW())
			$loc_condn";

$tmp = mysql_query($sql) or die(mysql_error());
list($adcount) = mysql_fetch_array($tmp);

// List of extra fields
$xfieldsql = "";
if(count($xsubcatfields)) 
{
	for($i=1; $i<=$xfields_count; $i++)	$xfieldsql .= ", axf.f$i";
}

// Get results
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.createdon) AS timestamp, ct.cityname,
			COUNT(*) AS piccount, p.picfile,
			scat.subcatname, cat.catid, cat.catname $xfieldsql
		FROM $t_ads a
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			INNER JOIN $t_subcats scat ON a.subcatid = scat.subcatid
			INNER JOIN $t_cats cat ON scat.catid = cat.catid
			LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
			LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '0'
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A'
		WHERE $where
			AND $visibility_condn
			AND (feat.adid IS NULL OR feat.featuredtill < NOW())
			$loc_condn
		GROUP BY a.adid
		ORDER BY a.createdon DESC
		LIMIT $offset, $ads_per_page";
$res = mysql_query($sql) or die($sql.mysql_error());

// Get featured ads
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.createdon) AS timestamp, ct.cityname,
			COUNT(*) AS piccount, p.picfile,
			scat.subcatname, cat.catid, cat.catname $xfieldsql
		FROM $t_ads a
			INNER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A' AND feat.featuredtill >= NOW()
			INNER JOIN $t_cities ct ON a.cityid = ct.cityid
			INNER JOIN $t_subcats scat ON a.subcatid = scat.subcatid
			INNER JOIN $t_cats cat ON scat.catid = cat.catid
			LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
			LEFT OUTER JOIN $t_adpics p ON a.adid = p.adid AND p.isevent = '0'
		WHERE $where
			AND $visibility_condn
			$loc_condn
		GROUP BY a.adid
		ORDER BY feat.timestamp DESC";
$featres = mysql_query($sql) or die(mysql_error().$sql);
$featadcount = mysql_num_rows($featres);

// Vars
$adtable = $t_ads;
$adtype = "A";
$target_view = "showad"; 
$target_view_sef = "posts"; 
//$page_title = ($xsubcatname ? $xsubcatname : $xcatname);

}

$pager = new pager($urlformat, $adcount, $ads_per_page, $page);

?>
<table width="600" cellspacing="15" cellpadding="15" border="0"><tr>
<td><h2><?php echo $xsubcatname?$xsubcatname:$xcatname; ?></h2></td>
<td align="right" valign="top">
<a href="<?php echo $rssurl; ?>"><img src="images/rss.gif" border="0" align="absmiddle"></a> 
</td></tr></table>

<?php

if ($xview == "events" && !$xsearchmode)
{
// Calendar navigation
$prevmonth = mktime(0, 0, 0, $xdate_m-1, $xdate_d, $xdate_y);
$nextmonth = mktime(0, 0, 0, $xdate_m+1, $xdate_d, $xdate_y);
$prevday = $xdatestamp - 24*60*60;
$nextday = $xdatestamp + 24*60*60;
?>
<table width="100%" class="eventnav" border="0"><tr>

<td valign="bottom">
<?php 
if($sef_urls)
{
$prevday_url = "{$vbasedir}$xcityid/events/".date("Y-m-d", $prevday)."/";
$nextday_url = "{$vbasedir}$xcityid/events/".date("Y-m-d", $nextday)."/";
}
else
{
$prevday_url = "?view=events&date=".date("Y-m-d", $prevday)."&cityid=$xcityid&lang=$xlang";
$nextday_url = "?view=events&date=".date("Y-m-d", $nextday)."&cityid=$xcityid&lang=$xlang";
}
?>
<a href="<?php echo $prevday_url; ?>">
<?php echo $lang['EVENTS_PREVDAY']; ?></a>
</td>

<td align="center">
<b><?php echo QuickDate($xdatestamp, FALSE, FALSE); ?> </b>
</td>

<td align="right" valign="bottom">
<a href="<?php echo $nextday_url; ?>">
<?php echo $lang['EVENTS_NEXTDAY']; ?></a>
</td>

</tr></table>
<?php
}
?>

<?php 
if(!$show_sidebar_always)
{
?>

<div id="search_top">
<b><?php echo $lang['SEARCH']; ?></b><br>
<?php include("search.inc.php"); ?>
</div>

<?php
}
?>


<?php

if ($adcount || mysql_num_rows($featres)>0)
{

?>


<table border="0" cellspacing="0" cellpadding="0" width="100%" class="adlisting">

<?php

if($xview == "events")
{

?>
<tr class="head">
<td><?php echo $lang['EVENTLIST_EVENTTITLE']; ?></td>
<td align="center" width="15%"><?php echo $lang['EVENTLIST_STARTSON']; ?></td>
<td align="center" width="15%"><?php echo $lang['EVENTLIST_ENDSON']; ?></td>
</tr>

<?php

// Featured events
if (mysql_num_rows($featres)>0)
{

$css_first = "_first";

while($row=mysql_fetch_array($featres))
{
	if ($find_date) 
	{
		$link_extra = "&date=".date("Y-m-d", $row['starton']);
		$urldate = date("Y-m-d", $row['starton']);
	}

	if($sef_urls) $url = "{$vbasedir}$xcityid/$target_view_sef/$urldate/$row[adid]_" . RemoveBadURLChars($row['adtitle']) . ".html";
	else $url = "?view=$target_view&adid=$row[adid]&cityid=$xcityid&lang=$xlang{$link_extra}";

?>

	<tr class="featuredad<?php echo $css_first; ?>">
		<td>
		<a href="<?php echo $url; ?>" class="adtitle">
		<?php 
		if($row['picfile'] && $ad_thumbnails) 
		{ 
			$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $tinythumb_max_width, $tinythumb_max_height);
		?>
			<img src="<?php echo "$datadir[adpics]/$row[picfile]"; ?>" border="0" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>" align="left" style="border:1px solid black;margin-right:5px;"> 
		<?php 
		}
		?>
		<img src="images/featured.gif" align="absmiddle" border="0">

		<?php echo $row['adtitle']; ?></a>

		<?php 
		$loc = "";
		if($row['area']) $loc = $row['area'];
		if($xcityid < 0) $loc .= ($loc ? ", " : "") . $row['cityname'];
		if($loc) echo "($loc)";
		?>

		<?php if($row['picfile']) { ?><img src="images/adwithpic.gif" align="absmiddle" title="This ad has picture(s)"><?php } ?>


		<?php 
		if($ad_preview_chars) 
		{ 
			echo "<span class='adpreview'>";
			$row['addesc'] = preg_replace("/\[\/?URL\]/", "", $row['addesc']);
			echo substr($row['addesc'],0,$ad_preview_chars);
			if (strlen($row['addesc'])>$ad_preview_chars) echo "...";
			echo "</span>";
		} 
		?>


		</td>
		<td align="center"><?php echo $langx['months_short'][date("n", $row['starton'])-1] . " " . date("j", $row['starton']); ?></td>
		<td align="center"><?php if($row['starton'] != $row['endon']) echo $langx['months_short'][date("n", $row['endon'])-1] . " " . date("j", $row['endon']);	?>


		</td>

	</tr>

<?php

	$css_first = "";
}

}

?>


<?php

$i = 0;
while($row=mysql_fetch_array($res))
{
	$css_class = "ad" . (($i%2)+1);
	$i++;

?>

	<tr class="<?php echo $css_class; ?>">

		<td>

			<?php

			if ($find_date) 
			{
				$link_extra = "&date=".date("Y-m-d", $row['starton']);
				$urldate = date("Y-m-d", $row['starton']);
			}

			if($sef_urls) $url = "{$vbasedir}$xcityid/$target_view_sef/$urldate/$row[adid]_" . RemoveBadURLChars($row['adtitle']) . ".html";
			else $url = "?view=$target_view&adid=$row[adid]&cityid=$xcityid&lang=$xlang{$link_extra}";


			?>

			<a href="<?php echo $url; ?>" class="adtitle">


			<?php 
			if($row['picfile'] && $ad_thumbnails) 
			{ 
				$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $tinythumb_max_width, $tinythumb_max_height);
			?>
				<img src="<?php echo "$datadir[adpics]/$row[picfile]"; ?>" border="0" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>" align="left" style="border:1px solid black;margin-right:5px;"> 
			<?php 
			}
			?>


			<?php echo $row['adtitle']; ?></a>

			<?php 
			$loc = "";
			if($row['area']) $loc = $row['area'];
			if($xcityid < 0) $loc .= ($loc ? ", " : "") . $row['cityname'];
			if($loc) echo "($loc)";
			?>


			<?php if($row['picfile']) echo "<img src=\"images/adwithpic.gif\" align=\"absmiddle\" title=\"This ad has picture(s)\"> "; ?>



		<?php 
		if($ad_preview_chars) 
		{ 
			echo "<span class='adpreview'>";
			$row['addesc'] = preg_replace("/\[\/?URL\]/", "", $row['addesc']);
			echo substr($row['addesc'],0,$ad_preview_chars);
			if (strlen($row['addesc'])>$ad_preview_chars) echo "...";
			echo "</span>";
		} 
		?>


		</td>
		<td align="center"><?php echo $langx['months_short'][date("n", $row['starton'])-1] . " " . date("j", $row['starton']); ?></td>
		<td align="center"><?php if($row['starton'] != $row['endon']) echo $langx['months_short'][date("n", $row['endon'])-1] . " " . date("j", $row['endon']);	?>


			</td>

	</tr>

<?php

}
}
else
{

?>
<tr class="head">
<td><?php echo $lang['ADLIST_ADTITLE']; ?></td>
<?php
$colspan = 1;
foreach ($xsubcatfields as $fldnum=>$fld)
{
if (!$fld['SHOWINLIST']) continue;

echo "<td";
//if ($fld['TYPE']=="N") 
echo " align=\"center\"";
echo ">$fld[NAME]</td>";
$colspan++;
}
if ($xsubcathasprice) 
{
echo "<td align=\"right\" width=\"12%\">$xsubcatpricelabel</td>";
$colspan++;
}
?>
</tr>

<?php

// Featured ads
if (mysql_num_rows($featres)>0)
{

echo "<tr><td height=\"1\"></td></tr>";
$css_first = "_first";

while($row=mysql_fetch_array($featres))
{

	$catname_inurl = RemoveBadURLChars($row['catname']);
	$subcatname_inurl = RemoveBadURLChars($row['subcatname']);

	if($sef_urls) $url = "{$vbasedir}$xcityid/$target_view_sef/{$row[catid]}_{$catname_inurl}/{$row[subcatid]}_{$subcatname_inurl}/$row[adid]_" . RemoveBadURLChars($row['adtitle']) . ".html";
	else $url = "?view=$target_view&adid=$row[adid]&cityid=$xcityid&lang=$xlang{$link_extra}";

?>

	<tr class="featuredad<?php echo $css_first; ?>">
		<td>
		<a href="<?php echo $url; ?>" class="adtitle">


		<?php 
		if($row['picfile'] && $ad_thumbnails) 
		{ 
			$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $tinythumb_max_width, $tinythumb_max_height);
		?>
			<img src="<?php echo "$datadir[adpics]/$row[picfile]"; ?>" border="0" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>" align="left" style="border:1px solid black;margin-right:5px;"> 
		<?php 
		}
		?>



		<img src="images/featured.gif" align="absmiddle" style="padding-right:5px;" border="0"><?php echo $row['adtitle']; ?></a>
		<?php 
		$loc = "";
		if($row['area']) $loc = $row['area'];
		if($xcityid < 0) $loc .= ($loc ? ", " : "") . $row['cityname'];
		if($loc) echo "($loc)";
		?>
		<?php if($row['picfile']) { ?><img src="images/adwithpic.gif" align="absmiddle" title="This ad has Picture(s)"><?php } ?>


			<?php 
			if($ad_preview_chars) 
			{ 
				echo "<span class='adpreview'>";
				$row['addesc'] = preg_replace("/\[\/?URL\]/", "", $row['addesc']);
				echo substr($row['addesc'],0,$ad_preview_chars);
				if (strlen($row['addesc'])>$ad_preview_chars) echo "...";
				echo "</span>";
			} 
			?>


		</td>

		<?php

		foreach ($xsubcatfields as $fldnum=>$fld)
		{
			if (!$fld['SHOWINLIST']) continue;

			echo "<td";
			//if ($fld['TYPE']=="N")
			echo " align=\"center\"";
			echo "width=\"10%\"> ".
				((($fld['TYPE']=="N" && ($row["f$fldnum"]==-1 || $row["f$fldnum"]=="0" || $row["f$fldnum"]=="")) || ($fld['TYPE']!="N" && trim($row["f$fldnum"])==""))?"-":$row["f$fldnum"])."</td>";
		}

		if($xsubcathasprice) 
			echo "<td align=\"right\"> ".($row['price'] > 0.00?"$currency".$row['price']:"-")."</td>";

		?>

	</tr>

<?php

	$css_first = "";

}

}

?>

<?php

$i = $j = 0;
$lastdate = "";
while($row=mysql_fetch_array($res))
{
	$date_formatted = date("Ymd", $row['timestamp']);
	if($date_formatted != $lastdate)
	{
		if ($lastdate) 
		{
			//echo "<tr><td height=\"1\"></td></tr>";
			$j = 0;
		}

		echo "<tr><td height=\"1\"></td></tr><tr><td class=\"datehead\" colspan=\"$colspan\">".QuickDate($row['timestamp'], FALSE, FALSE)."</td></tr><tr><td height=\"1\"></td></tr>";

		$lastdate = $date_formatted;
	}

	$css_class = "ad" . (($j%2)+1);
	$i++; $j++;

	$catname_inurl = RemoveBadURLChars($row['catname']);
	$subcatname_inurl = RemoveBadURLChars($row['subcatname']);

	if($sef_urls) $url = "{$vbasedir}$xcityid/$target_view_sef/{$row[catid]}_{$catname_inurl}/{$row[subcatid]}_{$subcatname_inurl}/$row[adid]_" . RemoveBadURLChars($row['adtitle']) . ".html";
	else $url = "?view=$target_view&adid=$row[adid]&cityid=$xcityid&lang=$xlang{$link_extra}";

	if($xsearchmode || !$xsubcatid)
	{
		if($sef_urls) $subcatlink = "{$vbasedir}$xcityid/$target_view_sef/{$row[catid]}_{$catname_inurl}/{$row[subcatid]}_{$subcatname_inurl}/";
		else $subcatlink = "?view=ads&subcatid=$row[subcatid]&cityid=$xcityid&lang=$xlang{$link_extra}";

		$title_extra = " - <a href=\"$subcatlink\" class=\"adcat\">$row[catname] $path_sep $row[subcatname]</a>";
	}


?>

	<tr class="<?php echo $css_class; ?>">

		<td>

			<a href="<?php echo $url; ?>" class="adtitle">

			<?php 
			if($row['picfile'] && $ad_thumbnails) 
			{ 
				$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $tinythumb_max_width, $tinythumb_max_height);
			?>
				<img src="<?php echo "$datadir[adpics]/$row[picfile]"; ?>" border="0" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>" align="left" style="border:1px solid black;margin-right:5px;"> 
			<?php 
			}
			?>


			<?php echo $row['adtitle']; ?></a>
			<?php 
			$loc = "";
			if($row['area']) $loc = $row['area'];
			if($xcityid < 0) $loc .= ($loc ? ", " : "") . $row['cityname'];
			if($loc) echo "($loc)";
			?>

			<?php if($row['picfile']) echo "<img src=\"images/adwithpic.gif\" align=\"absmiddle\" title=\"This ad has picture(s)\"> "; ?>
			<?php echo $title_extra; ?>


			<?php 
			if($ad_preview_chars) 
			{ 
				echo "<span class='adpreview'>";
				$row['addesc'] = preg_replace("/\[\/?URL\]/", "", $row['addesc']);
				echo substr($row['addesc'],0,$ad_preview_chars);
				if (strlen($row['addesc'])>$ad_preview_chars) echo "...";
				echo "</span>";
			} 
			?>


		</td>
		<?php

		foreach ($xsubcatfields as $fldnum=>$fld)
		{
			if (!$fld['SHOWINLIST']) continue;

			echo "<td";
			//if ($fld['TYPE']=="N")
			echo " align=\"center\"";
			echo "width=\"10%\"> ".
				((($fld['TYPE']=="N" && ($row["f$fldnum"]==-1 || $row["f$fldnum"]=="0" || $row["f$fldnum"]=="")) || ($fld['TYPE']!="N" && trim($row["f$fldnum"])==""))?"-":$row["f$fldnum"])."</td>";
		}

		if($xsubcathasprice) 
			echo "<td align=\"right\"> ".($row['price'] > 0.00?"$currency".$row['price']:"-")."</td>";

		?>

	</tr>

<?php

}
}
?>

</table>

<?php

if ($adcount > $ads_per_page)
{

?>

<br>
<div align="right">
<table>
<tr><td><b><?php echo $lang['PAGE']; ?>: </b></td><td><?php echo $pager->outputlinks(); ?></td></tr>
</table>
</div>

<?php

}

?>


<?php

}
else
{

?>


<?php

}

?>

Link to comment
Share on other sites

This code is located at the end of ads.php. (Ads.php is to display all the adverts in a certain category an example can be seen by clicking here)

 

 

<div class="noresults"><?php echo $lang['NO_RESULTS']; ?><br>
<a href="?view=main&cityid=<?php echo $xcityid; ?>"><?php echo $lang['BACK_TO_HOME']; ?></a>
</div>

Link to comment
Share on other sites

**Showad.php** (This is the code that displays an advert when its clicked an example can be seen by clicking here

 

<?php

require_once("config.inc.php");

if($image_verification) 
{
require_once("captcha.cls.php");
$captcha = new captcha();
}

$msg = "";
$err = "";

?>

<?php

if (!$_GET['adid'])
{
header("Location: $script_url/?view=main&cityid=$xcityid&lang=$xlang");
exit;
}


$adtable = ($_GET['view'] == "showevent") ? $t_events : $t_ads;

// Make up search query
$qsA = $_GET; $qs = "";
unset($qsA['do'], $qsA['reported'], $qsA['mailed'], $qsA['mailerr'], $qsA['msg'], $qsA['err']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";

if ($_GET['do'] == "reportabuse")
{
$sql = "UPDATE $adtable SET abused = abused + 1 WHERE adid = $_GET[adid]";
mysql_query($sql) or die($sql);

if(mysql_affected_rows())
{
	echo "<div class=\"msg\">$lang[MESSAGE_ABUSE_REPORT]</div>";

	if($max_abuse_reports)
	{
		$sql = "DELETE FROM $adtable WHERE abused > $max_abuse_reports";
		mysql_query($sql);
	}

	header("Location: $script_url/?{$qs}reported=y");
	exit;
}

unset($_GET['do']);
}


if ($xview == "showevent")
{
// Get the event
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill,
		UNIX_TIMESTAMP(a.starton) AS starton, UNIX_TIMESTAMP(a.endon) AS endon
	FROM $t_events a
		LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E'
	WHERE a.adid = $xadid
		AND $visibility_condn_admin";
$ad = mysql_fetch_array(mysql_query($sql));

$isevent = 1;

if($sef_urls) $thisurl = "{$vbasedir}$xcityid/events/$xdate/$xadid_".RemoveBadURLChars($ad['adtitle']).".html";
else $thisurl = "?$qs";

}
else
{
// List of extra fields
$xfieldsql = "";
if(count($xsubcatfields)) 
{
	for($i=1; $i<=$xfields_count; $i++)	$xfieldsql .= ", axf.f$i";
}

// Get the ad
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill $xfieldsql
		FROM $t_ads a
			INNER JOIN $t_subcats scat ON scat.subcatid = a.subcatid
			LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A'
		WHERE a.adid = $xadid
			AND $visibility_condn_admin";
$ad = mysql_fetch_array(mysql_query($sql));

$isevent = 0;
if($sef_urls) $thisurl = "{$vbasedir}$xcityid/posts/$xcatid/$xsubcatid/$xadid_".RemoveBadURLChars($ad['adtitle']).".html";
else $thisurl = "?$qs";

}


if (!$ad) 
{
header("Location: $script_url/?view=main&cityid=$xcityid&lang=$xlang");
exit;
}


if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
if ($image_verification && !$captcha->verify($_POST['captcha']))
{
	$err = $lang['ERROR_IMAGE_VERIFICATION_FAILED'];
}
else
{

	unset($_GET['mailed'],$_GET['mailerr'],$_GET['reported']);
	$qs = "";
	foreach ($_GET as $k=>$v) $qs .= "$k=$v&";
	$qs = substr($qs, 0, -1);
	$thisurl = "$script_url/?$qs";

	$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
	$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
	$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
	$thismail_header = str_replace("{@ADURL}", $thisurl, $thismail_header);
	$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

	$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
	$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
	$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
	$thismail_footer = str_replace("{@ADURL}", $thisurl, $thismail_footer);
	$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

	$mail = $thismail_header . "\n" .
			stripslashes($_POST['mail']) . "\n" .
			$thismail_footer;


	// Makeup mail headers and compose mime msg

	$mime_boundary = "<<<-=-=-[xzero.clfx.".md5(time())."]-=-=->>>";

	$mailheaders  = "";
	$mailheaders .= "From: $contactmail_from\n";
	$mailheaders .= "Reply-To: $_POST[email]\n";

	if($_FILES['attach']['tmp_name'] && !$_FILES['attach']['error'])
	{
		$filename = $_FILES['attach']['name'];
		$filetmpname = $_FILES['attach']['tmp_name'];
		$filesize = $_FILES['attach']['size'];
		$filecontents = base64_encode(file_get_contents($filetmpname));
		$fileencoding = "base64";

		$dotpos = strrpos($filename, ".");
		if($dotpos !== FALSE) $ext = substr($filename, -$dotpos+1);

		if (in_array($ext, $contactmail_attach_wrongfiles))
		{
			$mailerr = $lang['ERROR_INVALID_ATTACHMENT'];
		}
		elseif($filesize > $contactmail_attach_maxsize*1000)
		{
			$mailerr = "The attachment is too big";
		}
		else
		{
			$mailheaders .= "MIME-Version: 1.0\n";
			$mailheaders .= "Content-Type: multipart/mixed;\n";
			$mailheaders .= " boundary=\"".$mime_boundary."\"";

			$fullmsg  = "";
			$fullmsg .= "This is a multi-part message in MIME format.\n";
			$fullmsg .= "\r\n";
			$fullmsg .= "--".$mime_boundary."\r\n";

			$fullmsg .= "Content-Type: text/plain; charset=\"{$langx[charset]}\"\n";
			$fullmsg .= "Content-Transfer-Encoding: 8bit\n";
			$fullmsg .= "\r\n";
			$fullmsg .= $mail;
			$fullmsg .= "\r\n";
			$fullmsg .= "--".$mime_boundary."\r\n";

			$fullmsg .= "Content-Type: application/octet-stream; name=\"".$filename."\"\n";
			$fullmsg .= "Content-Transfer-Encoding: ".$fileencoding."\n";
			$fullmsg .= "Content-Disposition: attachment; filename=\"".$filename."\"\n";
			$fullmsg .= "\r\n";
			$fullmsg .= $filecontents;
			$fullmsg .= "\r\n";
			$fullmsg .= "--".$mime_boundary."--\r\n";
		}
	}
	else
	{
		$mailheaders .= "Content-Type: text/plain; charset=\"{$langx[charset]}\"\n";
		$mailheaders .= "Content-Transfer-Encoding: 8bit\n";
		$fullmsg = $mail;
	}

	$mailheaders .= "\r\n";

	if ($mailerr)
	{
		$mailresult = "n";
	}
	else
	{
		if (mail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $fullmsg, $mailheaders, "-f{$site_email}"))
			$mailresult = "y";
		else
			$mailresult = "n";
	}

	header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
	exit;
}

}

$sql = "SELECT *
	FROM $t_adpics p
	WHERE p.adid = $xadid
		AND isevent = '$isevent'";
$pres = mysql_query($sql);


?>


<script language="javascript">
function confirmAbuseReport()
{
if (confirm('<?php echo addslashes($lang['REPORT_ABUSE_CONFIRM']); ?>'))
{
	location.href = '?<?php echo $qs; ?>do=reportabuse';
}
}
</script>

<?php

if(!$_POST['mail'])
{
if($_GET['mailed'] == "y")		{ $msg .= $lang['MESSAGE_MAIL_SENT']."<br>"; }
elseif ($_GET['mailed'] == "n")	{ $err .= $lang['ERROR_MAIL_NOT_SENT']."<br>".$_GET['mailerr']."<br>"; }

if($_GET['reported'] == "y")	{ $msg .= $lang['MESSAGE_ABUSE_REPORT']."<br>"; }
}

if($_GET['msg'])				{ $msg .= $_GET['msg']."<br>"; }
if($_GET['err'])				{ $err .= $_GET['err']."<br>"; }

?>

<?php

if($err) echo "<div class=\"err\">$err</div>";
if($msg) echo "<div class=\"msg\">$msg</div>";

?>

<?php if($ad['featuredtill'] && $ad['featuredtill'] > time()) { ?>
<div class="msg">
<img src="images/featured.gif" align="absmiddle">
<b><?php echo $lang['THIS_AD_IS_FEATURED']; ?></b>
</div>
<?php } ?>

<table class="adheader" width="100%">
<tr>
<td>

<div align="right">
<a href="javascript:confirmAbuseReport();"><?php echo $lang['REPORT_ABUSE']; ?></a> |
<a href="?view=mailad&cityid=<?php echo $xcityid; ?>&adid=<?php echo $xadid; ?>&adtype=<?php echo $xadtype; ?>"><?php echo $lang['EMAIL_THIS_AD_LINK']; ?></a>
</div>
<?php echo $lang['POST_ID']; ?> <?php echo ($view=="showevent"?"E":"A"); ?><?php echo $ad['adid']; ?><br><br>
<?php
if ($xview == "showevent")
{
?>
<b><?php echo date("d", $ad['starton'])." ".$langx['months_short'][date("n", $ad['starton'])-1] . ", " . date("y", $ad['starton']); ?>
<?php if($ad['starton'] != $ad['endon']) echo " - " . date("d", $ad['endon']) . " " . $langx['months_short'][date("n", $ad['endon'])-1] . ", " . date("y", $ad['endon']); ?></b>
<br>

<?php
}
?>

<div class="adtitle">
<?php echo $ad['adtitle']; ?>
<?php if($ad['area']) echo " <span class=\"adarea\">($ad[area])</span>"; ?>
</div><br>

<b><?php echo $lang['AD_DATE']; ?></b>: 
<?php echo QuickDate($ad['createdon']); ?>
<br>

<?php if($ad['createdon'] != $ad['timestamp']) { ?>
<b><?php echo $lang['AD_LAST_UPDATE']; ?></b>: 
<?php echo QuickDate($ad['timestamp']); ?>
<br>
<?php } ?>

<b><?php echo $lang['AD_EXPIRES_ON']; ?></b>: 
<?php echo QuickDate($ad['expireson']); ?>
<br>

<b><?php echo $lang['REPLY_TO']; ?></b>: 
<?php if ($ad['showemail'] == EMAIL_SHOW) { ?>
<a href="mailto:<?php echo $ad['email']; ?>"><?php echo $ad['email']; ?></a>

<?php } elseif ($ad['showemail'] == EMAIL_USEFORM) { ?>
<i><?php echo $lang['USE_CONTACT_FORM']; ?></i>

<?php } else { ?>
<i><?php echo $lang['EMAIL_NOT_SHOWN']; ?></i>

<?php } ?>
<br>

</td>
</tr>
</table>

<?php
if(($xsubcathasprice && $ad['price']) || count($xsubcatfields))
{
?>
<div style="border-bottom:1px solid #E0E0E0;">
<table>

<?php if($xsubcathasprice) { ?><tr><td><b><?php echo $xsubcatpricelabel; ?></b></td><td>: <?php if(($xsubcathasprice && $ad['price'] > 0.00)) { ?><?php echo $currency . $ad['price']; ?><?php } else { echo $lang['AD_PRICE_NOT_PROVIDED']; } ?></td></tr><?php } ?>

<?php if(count($xsubcatfields)) { foreach ($xsubcatfields as $fldnum=>$fld) { if(($fld['TYPE'] == "N" && $ad["f$fldnum"] > 0) || ($fld['TYPE'] != "N" && $ad["f$fldnum"])) { ?>
<tr><td><b><?php echo $fld['NAME']; ?></b></td><td>: <?php echo $ad["f$fldnum"]; ?></td></tr>
<?php }}} ?>

<tr><td> </td></tr>
</table></div><br>
<?php
}
?>

<table class="ad" width="100%"><tr><td>

<?php echo nl2br(preg_replace("/\[url\](.*)\[\/URL\]/iU", "<a href=\"\\1\" target=\"_blank\">\\1</a>$link_append", $ad['addesc'])); ?>

</td></tr></table>

<?php

if (@mysql_num_rows($pres))
{
$i = 0;
?>

<table class="adpics" width="100%"><tr><td>

<?php
while ($row = mysql_fetch_array($pres))
{
	$i++;

	$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height);

?>

	<img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>" id="adimg<?php echo $i; ?>" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>"><br><br>

<?php
}
?>

</td></tr></table>

<?php

$imgcnt = $i;

}
?>


<?php if ($ad['showemail'] == EMAIL_USEFORM) { 

/*$qs = ""; $qsA = $_GET; unset($qsA['syndicate']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";*/

?>

<form action="<?php echo "$script_url/?$qs"; ?>" method="post" enctype="multipart/form-data">
<table class="contactform">
<tr>
	<th colspan="2"><?php echo $lang['CONTACT_USER']; ?>:<a name="contactform"> </a>
</th>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
	<td><?php echo $lang['YOUR_EMAIL']; ?>: <span class="marker">*</span></td>
	<td>
	<input type="text" size="65" name="email">
	</td>
</tr>
<tr>
	<td valign="top"><?php echo $lang['YOUR_MESSAGE']; ?>: <span class="marker">*</span></td>
	<td>
	<textarea cols="64" rows="10" name="mail"></textarea>
	</td>
</tr>
<tr>
	<td valign="top"><?php echo $lang['ATTACHMENT']; ?>:</td>
	<td>
	<input type="file" size="55" name="attach"><br>
	<span class="hint"><?php echo $lang['UNSUPPORTED_ATTACHEMNTS']; ?>: <?php echo implode(", ", $contactmail_attach_wrongfiles); ?><br>
	</span>
	</td>
</tr>

<?php
if($image_verification)
{
?>

	<tr>
		<td valign="top"><?php echo $lang['POST_VERIFY_IMAGE']; ?>: <span class="marker">*</span></td>
		<td>
		<img src="captcha.png.php?<?php echo rand(0,999); ?>"><br>
		<span class="hint"><?php echo $lang['POST_VERIFY_IMAGE_HINT']; ?></span><br>
		<input type="text" name="captcha" value="">
		</td>
	</tr>

<?php
}
?>

<tr>
	<td> </td>
	<td><button type="submit"><?php echo $lang['BUTTON_SEND_MAIL']; ?></button></td>
</tr>
</table>
</form>

<?php } ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.