2009-07-23 16:43:03 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* e107 website system
|
|
|
|
*
|
2016-12-02 10:33:29 +00:00
|
|
|
* Copyright (C) 2009-2016 e107 Inc (e107.org)
|
2009-07-23 16:43:03 +00:00
|
|
|
* Released under the terms and conditions of the
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
*
|
2009-12-28 21:36:13 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-23 16:43:03 +00:00
|
|
|
|
2009-09-18 22:20:40 +00:00
|
|
|
if (!defined('e107_INIT'))
|
|
|
|
{
|
|
|
|
require_once("../../class2.php");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!e107::isInstalled('banner'))
|
|
|
|
{
|
2016-01-13 19:17:37 -08:00
|
|
|
e107::redirect();
|
2012-08-10 11:37:20 +00:00
|
|
|
exit;
|
2009-09-18 22:20:40 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 14:02:21 +02:00
|
|
|
e107::includeLan(e_PLUGIN."banner/languages/".e_LANGUAGE."_banner.php"); // TODO
|
2016-12-20 10:58:43 +01:00
|
|
|
e107::lan('banner');
|
2015-02-07 22:20:31 -08:00
|
|
|
|
|
|
|
|
2009-09-18 22:20:40 +00:00
|
|
|
|
2016-12-20 10:58:43 +01:00
|
|
|
$sql = e107::getDb();
|
2014-08-13 14:02:21 +02:00
|
|
|
$mes = e107::getMessage();
|
|
|
|
$frm = e107::getForm();
|
|
|
|
|
|
|
|
// When a banner is clicked
|
|
|
|
if(e_QUERY)
|
|
|
|
{
|
2009-07-23 16:43:03 +00:00
|
|
|
$query_string = intval(e_QUERY);
|
2014-08-13 14:02:21 +02:00
|
|
|
$row = $sql->retrieve("banner", "*", "banner_id = '{$query_string}'"); // select the banner
|
2012-01-02 22:06:22 +00:00
|
|
|
$ip = e107::getIPHandler()->getIP(FALSE);
|
2014-08-13 14:02:21 +02:00
|
|
|
$newip = (strpos($row['banner_ip'], "{$ip}^") !== FALSE) ? $row['banner_ip'] : "{$row['banner_ip']}{$ip}^"; // what does this do?
|
|
|
|
$sql->update("banner", "banner_clicks = banner_clicks + 1, `banner_ip` = '{$newip}' WHERE `banner_id` = '{$query_string}'");
|
2016-03-13 00:16:08 -08:00
|
|
|
// header("Location: {$row['banner_clickurl']}");
|
|
|
|
e107::redirect($row['banner_clickurl']);
|
2009-07-23 16:43:03 +00:00
|
|
|
exit;
|
|
|
|
}
|
2015-02-07 22:20:31 -08:00
|
|
|
|
2019-01-17 13:20:56 -08:00
|
|
|
if (empty($BANNER_LOGIN_TABLE) || empty($BANNER_TABLE) || empty($BANNER_TABLE_START) || empty($BANNER_TABLE_END))
|
2015-02-07 22:20:31 -08:00
|
|
|
{
|
2019-01-17 13:20:56 -08:00
|
|
|
$BANNER_TABLE_START = '';
|
|
|
|
$BANNER_TABLE_END = '';
|
|
|
|
$BANNER_TABLE = '';
|
|
|
|
$BANNER_LOGIN_TABLE = '';
|
|
|
|
|
|
|
|
if(file_exists(THEME.'templates/banner/banner_template.php')) // v2.x location.
|
2015-02-07 22:20:31 -08:00
|
|
|
{
|
|
|
|
require_once (THEME.'templates/banner/banner_template.php');
|
|
|
|
}
|
|
|
|
elseif(file_exists(THEME."banner_template.php"))
|
|
|
|
{
|
|
|
|
require_once(THEME."banner_template.php");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
require_once("banner_template.php");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-23 16:43:03 +00:00
|
|
|
|
|
|
|
require_once(HEADERF);
|
|
|
|
|
2015-02-07 22:20:31 -08:00
|
|
|
if (isset($_POST['clientsubmit']))
|
|
|
|
{
|
2009-07-23 16:43:03 +00:00
|
|
|
|
2014-08-13 14:02:21 +02:00
|
|
|
$clean_login = $tp->toDB($_POST['clientlogin']);
|
|
|
|
$clean_password = $tp->toDB($_POST['clientpassword']);
|
2009-07-23 16:43:03 +00:00
|
|
|
|
2014-08-13 14:02:21 +02:00
|
|
|
// check login
|
|
|
|
// TODO: massive clean-up (integrate e107 users, proper login handling, password encryption for new and existing records)
|
|
|
|
if (!$sql->select("banner", "*", "`banner_clientlogin` = '{$clean_login}' AND `banner_clientpassword` = '{$clean_password}'")) {
|
|
|
|
$mes->addError(BANNERLAN_20);
|
|
|
|
$ns->tablerender(PAGE_NAME, $mes->render());
|
2009-07-23 16:43:03 +00:00
|
|
|
require_once(FOOTERF);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-08-13 14:02:21 +02:00
|
|
|
$row = $sql->fetch();
|
|
|
|
$banner_total = $sql->select("banner", "*", "`banner_clientname` = '{$row['banner_clientname']}'");
|
|
|
|
|
|
|
|
// check
|
|
|
|
if(!$banner_total)
|
|
|
|
{
|
2016-12-02 10:33:29 +00:00
|
|
|
$mes->addInfo(LAN_NO_RECORDS_FOUND.": ".LAN_PLUGIN_BANNER_NAME);
|
2014-08-13 14:02:21 +02:00
|
|
|
$ns->tablerender(PAGE_NAME, $mes->render());
|
2009-07-23 16:43:03 +00:00
|
|
|
require_once(FOOTERF);
|
|
|
|
exit;
|
2014-08-13 14:02:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while ($row = $sql->fetch())
|
|
|
|
{
|
2009-07-23 16:43:03 +00:00
|
|
|
$start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
|
2014-08-13 14:02:21 +02:00
|
|
|
$end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
|
2019-01-17 13:20:56 -08:00
|
|
|
|
|
|
|
$scArray = array();
|
|
|
|
$scArray['BANNER_TABLE_CLICKPERCENTAGE'] = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-");
|
|
|
|
$scArray['BANNER_TABLE_IMPRESSIONS_LEFT'] = ($row['banner_impurchased'] ? $row['banner_impurchased'] - $row['banner_impressions'] : BANNERLAN_30);
|
|
|
|
$scArray['BANNER_TABLE_IMPRESSIONS_PURCHASED'] = ($row['banner_impurchased'] ? $row['banner_impurchased'] : BANNERLAN_30);
|
|
|
|
$scArray['BANNER_TABLE_CLIENTNAME'] = $row['banner_clientname'];
|
|
|
|
$scArray['BANNER_TABLE_BANNER_ID'] = $row['banner_id'];
|
|
|
|
$scArray['BANNER_TABLE_BANNER_CLICKS'] = $row['banner_clicks'];
|
|
|
|
$scArray['BANNER_TABLE_BANNER_IMPRESSIONS'] = $row['banner_impressions'];
|
|
|
|
$scArray['BANNER_TABLE_ACTIVE'] = LAN_VISIBILITY." ".($row['banner_active'] != "255" ? LAN_YES : "<b>".LAN_NO."</b>");
|
|
|
|
$scArray['BANNER_TABLE_STARTDATE'] = LAN_START." ".$start_date;
|
|
|
|
$scArray['BANNER_TABLE_ENDDATE'] = LAN_END." ".$end_date;
|
2009-07-23 16:43:03 +00:00
|
|
|
|
|
|
|
if ($row['banner_ip'])
|
|
|
|
{
|
|
|
|
$tmp = explode("^", $row['banner_ip']);
|
2019-01-17 13:20:56 -08:00
|
|
|
$scArray['BANNER_TABLE_IP_LAN'] = (count($tmp)-1);
|
2014-08-13 14:02:21 +02:00
|
|
|
|
2009-07-23 16:43:03 +00:00
|
|
|
for($a = 0; $a <= (count($tmp)-2); $a++) {
|
2019-01-17 13:20:56 -08:00
|
|
|
$scArray['BANNER_TABLE_IP'] .= $tmp[$a]."<br />";
|
2009-07-23 16:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-13 14:02:21 +02:00
|
|
|
|
2019-01-17 13:20:56 -08:00
|
|
|
$textstring .= $tp->parseTemplate($BANNER_TABLE, true, $scArray);
|
2009-07-23 16:43:03 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-13 14:02:21 +02:00
|
|
|
|
|
|
|
|
2019-01-17 13:20:56 -08:00
|
|
|
$textstart = $tp->parseTemplate($BANNER_TABLE_START, true, $scArray);
|
|
|
|
$textend = $tp->parseTemplate($BANNER_TABLE_END, true, $scArray);
|
2009-07-23 16:43:03 +00:00
|
|
|
$text = $textstart.$textstring.$textend;
|
|
|
|
|
2014-08-13 14:02:21 +02:00
|
|
|
$ns->tablerender(PAGE_NAME, $text);
|
2009-07-23 16:43:03 +00:00
|
|
|
|
|
|
|
require_once(FOOTERF);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2019-01-17 13:20:56 -08:00
|
|
|
$scArray = array();
|
2021-01-16 10:02:52 -08:00
|
|
|
$scArray['BANNER_LOGIN_TABLE_LOGIN'] = $frm->text("clientlogin");
|
2019-01-17 13:20:56 -08:00
|
|
|
$scArray['BANNER_LOGIN_TABLE_PASSW'] = $frm->password("clientpassword", '');
|
|
|
|
$scArray['BANNER_LOGIN_TABLE_SUBMIT'] = $frm->button("clientsubmit", LAN_CONTINUE, "submit");
|
2014-08-13 14:02:21 +02:00
|
|
|
|
2019-01-17 13:20:56 -08:00
|
|
|
$text = $tp->parseTemplate($BANNER_LOGIN_TABLE, true, $scArray);
|
2014-08-13 14:02:21 +02:00
|
|
|
|
2009-07-23 16:43:03 +00:00
|
|
|
$ns->tablerender(BANNERLAN_19, $text);
|
|
|
|
|
|
|
|
require_once(FOOTERF);
|
2019-01-17 13:20:56 -08:00
|
|
|
|
|
|
|
|
|
|
|
|