Files
Testing/include/analytics/ad_referrals.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

128 lines
3.7 KiB
PHP

<?php
include_once($_SERVER["DOCUMENT_ROOT"] . '/include/dbinclude-mysql.php');
function dbconnect()
{}
$em="";
$conda="";
$searchterm="";
$condb="";
$thefromdate="";
$thetodate="";
$condc="";
if(isset($_POST["fromdate"]))
{
$thefromdate=$_POST["fromdate"];
if($_POST["fromdate"] != "")
{
$condb =" AND `bw_ad_referrer`.`thedate` >= '".$_POST["fromdate"]." 00:00:00'";
}
}
if(isset($_POST["todate"]))
{
$thetodate=$_POST["todate"];
if($_POST["todate"] != "")
{
$condc =" AND `bw_ad_referrer`.`thedate` <= '".$_POST["todate"]." 00:00:00'";
}
}
if(isset($_POST["search"]))
{
$conda=" AND `bw_ad_referrer`.`ad_referrer` like '%".$_POST["search"]."%' ";
$searchterm=$_POST["search"];
}
$sql="SELECT
Count(`bw_ad_referrer`.`ad_ref_domain`) AS `referrals`,
`bw_ad_referrer`.`ad_referrer`,
`bw_ad_referrer`.`ad_ref_domain`,
`bw_ad_referrer`.`thedate`,
Max(`bw_ad_referrer`.`thedate`) AS `maxdate`,
Min(`bw_ad_referrer`.`thedate`) AS `mindate`
FROM
`bw_ad_referrer`
WHERE
`bw_ad_referrer`.`ad_ref_domain` IS NOT NULL ".$conda.$condb.$condc."
GROUP BY
`bw_ad_referrer`.`ad_ref_domain`
ORDER BY
`referrals` DESC";
//echo $sql;
$result= $database->database_query($sql) or $em=$em.$database->database_error();
?>
<!doctype html>
<html lang="en-US" class="no-js">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex, nofollow, noarchive">
<title>Ad Referrals</title>
<link rel='stylesheet' id='myers-reset' href='http://bateworld.com/include/analytics/adrotation/css/reset.css?ver=2.0' type='text/css' media='all' />
<script src="/include/analytics/adrotation/js/modernizr.js"></script>
<style>
table {border-collapse:collapse; table-layout:fixed;width:100%;}
table td {border:solid 1px #fab;}
</style>
</head>
<body>
<div style="padding:5px;">
<header>
<h1>Ad Referrals</h1>
<div>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" name="frmsearch" id="frmsearch" enctype="application/x-www-form-urlencoded">
<input type="search" id="search" name="search" value="<?php echo $searchterm;?>" style="width:300px;" placeholder="Search" pattern="^(?!(?:[a-zA-Z\d]*[_. -]){4})[a-zA-Z\d][\w. -]{2,22}[a-zA-Z\d]$" />
<label for="fromdate">From: </label><input type="date" id="fromdate" name="fromdate" value="<?php echo $thefromdate; ?>" size="20" />
<label for="todate">To: </label><input type="date" id="todate" name="todate" value="<?php echo $thetodate; ?>" size="20" />
<input type="submit" id="frmsub" name="frmsub" value="GO" />
</form
></div>
</header>
<main>
<section>
<div>
<table>
<thead>
<tr>
<th style="white-space: nowrap;width:100px;padding:0 2px 0 2px;">Hits</th>
<th style="word-wrap:break-word;white-space: normal;padding:0 3px 0 3px;" align="left">Referrer</th>
<th style="white-space: nowrap;width:170px;padding:0 2px 0 2px;">From To Date</th>
</tr>
</thead>
<tbody>
<?php
$rownum=0;
while ($row = $database->database_fetch_assoc($result)) {
$rownum=$rownum+1;
if($rownum % 2 != 0){$rc="#ffff99";} else{$rc="#fff";}
if($row["referrals"]==1)
{
$pdpmaxdate="";
}
else
{
$pdpmaxdate=$row["maxdate"];
}
echo '<tr valign="top" style="background:'.$rc.'" onmouseover="this.style.background=\'#ccffcc\'" onmouseout="this.style.background=\''.$rc.'\'">
<td style="white-space: nowrap;width:100px;padding:0 2px 0 2px;">'.$row["referrals"].'</td>
<td style="word-wrap:break-word;white-space: normal;padding:0 2px 0 2px;"><a href="/include/analytics/ad_referrals_domain.php?ad_domain='.$row["ad_ref_domain"].'">'.$row["ad_ref_domain"].'</a></td>
<td align="right" style="white-space: nowrap;width:170px;padding:0 2px 0 2px;">'.$row["mindate"].'<br />'.$pdpmaxdate.'</td>
</tr>';
}
if($rownum==0){echo '<td><p style="text-align:center;font-weight:800;">No Records Returned</div></td>';}
?>
</tbody>
</table>
</div>
</section>
</main>
<footer>
</footer>
</div>
</body>
</html>