mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Banner plugin frontend code clean up. Far more work to do at later stage (login handling and templates).
This commit is contained in:
@@ -2,20 +2,12 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2013 e107 Inc (e107.org)
|
* Copyright (C) 2009-2014 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* e107 Banner management plugin
|
|
||||||
*
|
|
||||||
* Handles the display and sequencing of banners on web pages, including counting impressions
|
|
||||||
*
|
|
||||||
* @package e107_plugins
|
|
||||||
* @subpackage banner
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('e107_INIT'))
|
if (!defined('e107_INIT'))
|
||||||
{
|
{
|
||||||
@@ -28,18 +20,19 @@ if (!e107::isInstalled('banner'))
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::includeLan(e_PLUGIN."banner/languages/".e_LANGUAGE."_banner.php");
|
e107::includeLan(e_PLUGIN."banner/languages/".e_LANGUAGE."_banner.php"); // TODO
|
||||||
|
|
||||||
require_once(e_HANDLER."form_handler.php"); // FIXME
|
$mes = e107::getMessage();
|
||||||
$rs = new form; // FIXME
|
$frm = e107::getForm();
|
||||||
|
|
||||||
if (e_QUERY) {
|
// When a banner is clicked
|
||||||
|
if(e_QUERY)
|
||||||
|
{
|
||||||
$query_string = intval(e_QUERY);
|
$query_string = intval(e_QUERY);
|
||||||
$sql->db_Select("banner", "*", "banner_id = '{$query_string}' ");
|
$row = $sql->retrieve("banner", "*", "banner_id = '{$query_string}'"); // select the banner
|
||||||
$row = $sql->db_Fetch();
|
|
||||||
$ip = e107::getIPHandler()->getIP(FALSE);
|
$ip = e107::getIPHandler()->getIP(FALSE);
|
||||||
$newip = (strpos($row['banner_ip'], "{$ip}^") !== FALSE) ? $row['banner_ip'] : "{$row['banner_ip']}{$ip}^";
|
$newip = (strpos($row['banner_ip'], "{$ip}^") !== FALSE) ? $row['banner_ip'] : "{$row['banner_ip']}{$ip}^"; // what does this do?
|
||||||
$sql->db_Update("banner", "banner_clicks = banner_clicks + 1, `banner_ip` = '{$newip}' WHERE `banner_id` = '{$query_string}'");
|
$sql->update("banner", "banner_clicks = banner_clicks + 1, `banner_ip` = '{$newip}' WHERE `banner_id` = '{$query_string}'");
|
||||||
header("Location: {$row['banner_clickurl']}");
|
header("Location: {$row['banner_clickurl']}");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -48,48 +41,58 @@ require_once(HEADERF);
|
|||||||
|
|
||||||
if (isset($_POST['clientsubmit'])) {
|
if (isset($_POST['clientsubmit'])) {
|
||||||
|
|
||||||
$clean_login = $tp -> toDB($_POST['clientlogin']);
|
$clean_login = $tp->toDB($_POST['clientlogin']);
|
||||||
$clean_password = $tp -> toDB($_POST['clientpassword']);
|
$clean_password = $tp->toDB($_POST['clientpassword']);
|
||||||
|
|
||||||
if (!$sql->db_Select("banner", "*", "`banner_clientlogin` = '{$clean_login}' AND `banner_clientpassword` = '{$clean_password}'")) {
|
// check login
|
||||||
$ns->tablerender(LAN_ERROR, "<br /><div style='text-align:center'>".BANNERLAN_20."</div><br />");
|
// 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());
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $sql->db_Fetch();
|
$row = $sql->fetch();
|
||||||
$banner_total = $sql->db_Select("banner", "*", "`banner_clientname` = '{$row['banner_clientname']}'");
|
$banner_total = $sql->select("banner", "*", "`banner_clientname` = '{$row['banner_clientname']}'");
|
||||||
|
|
||||||
if (!$banner_total) {
|
// check
|
||||||
$ns->tablerender(LAN_ERROR, "<br /><div style='text-align:center'>".BANNERLAN_29."</div><br />");
|
if(!$banner_total)
|
||||||
|
{
|
||||||
|
$mes->addInfo(BANNERLAN_29);
|
||||||
|
$ns->tablerender(PAGE_NAME, $mes->render());
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
}
|
||||||
while ($row = $sql->db_Fetch()) {
|
else
|
||||||
|
{
|
||||||
|
while ($row = $sql->fetch())
|
||||||
|
{
|
||||||
$start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
|
$start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
|
||||||
$end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
|
$end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
|
||||||
|
|
||||||
$BANNER_TABLE_CLICKPERCENTAGE = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-");
|
$BANNER_TABLE_CLICKPERCENTAGE = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-");
|
||||||
$BANNER_TABLE_IMPRESSIONS_LEFT = ($row['banner_impurchased'] ? $row['banner_impurchased'] - $row['banner_impressions'] : BANNERLAN_30);
|
$BANNER_TABLE_IMPRESSIONS_LEFT = ($row['banner_impurchased'] ? $row['banner_impurchased'] - $row['banner_impressions'] : BANNERLAN_30);
|
||||||
$BANNER_TABLE_IMPRESSIONS_PURCHASED = ($row['banner_impurchased'] ? $row['banner_impurchased'] : BANNERLAN_30);
|
$BANNER_TABLE_IMPRESSIONS_PURCHASED = ($row['banner_impurchased'] ? $row['banner_impurchased'] : BANNERLAN_30);
|
||||||
$BANNER_TABLE_CLIENTNAME = $row['banner_clientname'];
|
$BANNER_TABLE_CLIENTNAME = $row['banner_clientname'];
|
||||||
$BANNER_TABLE_BANNER_ID = $row['banner_id'];
|
$BANNER_TABLE_BANNER_ID = $row['banner_id'];
|
||||||
$BANNER_TABLE_BANNER_CLICKS = $row['banner_clicks'];
|
$BANNER_TABLE_BANNER_CLICKS = $row['banner_clicks'];
|
||||||
$BANNER_TABLE_BANNER_IMPRESSIONS = $row['banner_impressions'];
|
$BANNER_TABLE_BANNER_IMPRESSIONS = $row['banner_impressions'];
|
||||||
$BANNER_TABLE_ACTIVE = BANNERLAN_36.($row['banner_active'] != "255" ? LAN_YES : "<b>".LAN_NO."</b>");
|
$BANNER_TABLE_ACTIVE = BANNERLAN_36.($row['banner_active'] != "255" ? LAN_YES : "<b>".LAN_NO."</b>");
|
||||||
$BANNER_TABLE_STARTDATE = BANNERLAN_37." ".$start_date;
|
$BANNER_TABLE_STARTDATE = BANNERLAN_37." ".$start_date;
|
||||||
$BANNER_TABLE_ENDDATE = BANNERLAN_34." ".$end_date;
|
$BANNER_TABLE_ENDDATE = BANNERLAN_34." ".$end_date;
|
||||||
|
|
||||||
if ($row['banner_ip'])
|
if ($row['banner_ip'])
|
||||||
{
|
{
|
||||||
$tmp = explode("^", $row['banner_ip']);
|
$tmp = explode("^", $row['banner_ip']);
|
||||||
$BANNER_TABLE_IP_LAN = (count($tmp)-1);
|
$BANNER_TABLE_IP_LAN = (count($tmp)-1);
|
||||||
|
|
||||||
for($a = 0; $a <= (count($tmp)-2); $a++) {
|
for($a = 0; $a <= (count($tmp)-2); $a++) {
|
||||||
$BANNER_TABLE_IP .= $tmp[$a]."<br />";
|
$BANNER_TABLE_IP .= $tmp[$a]."<br />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME template loading
|
||||||
if (!$BANNER_TABLE)
|
if (!$BANNER_TABLE)
|
||||||
{
|
{
|
||||||
if (file_exists(THEME."templates/banner/banner_template.php"))
|
if (file_exists(THEME."templates/banner/banner_template.php"))
|
||||||
@@ -105,10 +108,12 @@ if (isset($_POST['clientsubmit'])) {
|
|||||||
require(e_PLUGIN."banner/banner_template.php");
|
require(e_PLUGIN."banner/banner_template.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$textstring .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE);
|
$textstring .= preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME template loading
|
||||||
if (!$BANNER_TABLE)
|
if (!$BANNER_TABLE)
|
||||||
{
|
{
|
||||||
if (file_exists(THEME."banner_template.php"))
|
if (file_exists(THEME."banner_template.php"))
|
||||||
@@ -120,31 +125,36 @@ if (isset($_POST['clientsubmit'])) {
|
|||||||
require(e_PLUGIN."banner/banner_template.php");
|
require(e_PLUGIN."banner/banner_template.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$textstart = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE_START);
|
$textstart = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE_START);
|
||||||
$textend = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE_END);
|
$textend = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_TABLE_END);
|
||||||
$text = $textstart.$textstring.$textend;
|
$text = $textstart.$textstring.$textend;
|
||||||
|
|
||||||
echo $text;
|
$ns->tablerender(PAGE_NAME, $text);
|
||||||
|
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$BANNER_LOGIN_TABLE_LOGIN = $frm->text("clientlogin", $id);
|
||||||
|
$BANNER_LOGIN_TABLE_PASSW = $frm->password("clientpassword", $pw);
|
||||||
|
$BANNER_LOGIN_TABLE_SUBMIT = $frm->button("clientsubmit", LAN_CONTINUE, "submit");
|
||||||
|
|
||||||
$BANNER_LOGIN_TABLE_LOGIN = $rs->form_text("clientlogin", 30, $id, 20, "tbox");
|
if (!$BANNER_LOGIN_TABLE)
|
||||||
$BANNER_LOGIN_TABLE_PASSW = $rs->form_password("clientpassword", 30, "", 20, "tbox");
|
{
|
||||||
$BANNER_LOGIN_TABLE_SUBMIT = $rs->form_button("submit", "clientsubmit", LAN_CONTINUE);
|
if(file_exists(THEME."banner_template.php"))
|
||||||
|
{
|
||||||
if (!$BANNER_LOGIN_TABLE) {
|
|
||||||
if (file_exists(THEME."banner_template.php")) {
|
|
||||||
require_once(THEME."banner_template.php");
|
require_once(THEME."banner_template.php");
|
||||||
} else {
|
}
|
||||||
require_once(e_BASE.$THEMES_DIRECTORY."templates/banner_template.php");
|
else
|
||||||
|
{
|
||||||
|
require_once("banner_template.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_LOGIN_TABLE);
|
$text = preg_replace("/\{(.*?)\}/e", '$\1', $BANNER_LOGIN_TABLE);
|
||||||
$ns->tablerender(BANNERLAN_19, $text);
|
$ns->tablerender(BANNERLAN_19, $text);
|
||||||
|
|
||||||
|
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
|
?>
|
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
* Copyright (C) 2008-2014 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user