From: <ma...@us...> - 2012-01-05 21:37:52
|
Revision: 8643 http://xoops.svn.sourceforge.net/xoops/?rev=8643&view=rev Author: mageg Date: 2012-01-05 21:37:45 +0000 (Thu, 05 Jan 2012) Log Message: ----------- Final version of the banners module with modification of the xoops core Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php XoopsCore/branches/2.6.x/2.6.0/htdocs/install/include/makedata.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/install.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/main.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/modinfo.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/xoops_version.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/language/english/admin/preferences.php XoopsCore/branches/2.6.x/2.6.0/htdocs/themes/default/theme.html Added Paths: ----------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/index.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/blocks.php XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_id.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_random.html XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/index.html Removed Paths: ------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/functions.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoops.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -1296,21 +1296,36 @@ /** * Function to get banner html tags for use in templates * + * @param int $nb_banner + * @param string $align + * @param array $client + * @param string $ids + * * @return string */ - public function getBanner() + public function getBanner($nb_banner = 1, $align = 'H', $client = array(), $ids = '') { - if ($this->getConfig('banners')) { + if ($this->isActiveModule('banners')) { // Get banners handler $banner_Handler = $this->getHandlerBanner(); // Display banner $criteria = new CriteriaCompo(); $criteria->add(new Criteria('status', 0, '!=')); $criteria->setSort('RAND()'); - $criteria->setStart(0); - $criteria->setLimit(1); + if (!empty($client)) { + if (!in_array(0,$client)) { + $criteria->add(new Criteria('cid', '(' . implode(',', $client) . ')','IN')); + } + } + if ($ids == '') { + $criteria->setLimit($nb_banner); + $criteria->setStart(0); + } else { + $criteria->add(new Criteria('bid', '(' . $ids . ')','IN')); + } $banner_arr = $banner_Handler->getall($criteria); $numrows = count($banner_arr); + $bannerobject = ''; if ($numrows > 0) { foreach (array_keys($banner_arr) as $i) { $imptotal = $banner_arr[$i]->getVar("imptotal"); @@ -1320,33 +1335,36 @@ $imageurl = $banner_arr[$i]->getVar("imageurl"); $bid = $banner_arr[$i]->getVar("bid"); $clickurl = $banner_arr[$i]->getVar("clickurl"); - } - if ($this->getConfig('my_ip') == $this->getEnv('REMOTE_ADDR')) { - // EMPTY - } else { /** - * Check if this impression is the last one + * Print the banner */ - $impmade = $impmade + 1; - if ($imptotal > 0 && $impmade >= $imptotal) { - $this->db->queryF(sprintf('UPDATE %s SET status = %u, dateend = %u WHERE bid = %u', $this->db->prefix('banner'), 0, time(), $bid)); - }else{ - $this->db->queryF(sprintf('UPDATE %s SET impmade = %u WHERE bid = %u', $this->db->prefix('banner'), $impmade, $bid)); + if ($htmlbanner) { + $bannerobject .= $htmlcode; + } else { + if (stristr($imageurl, '.swf')) { + $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"></a>' . '<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl . '" style="z-index:100;">' . '<param name="movie" value="' . $imageurl . '" />' . '<param name="wmode" value="opaque" />' . '</object>'; + } else { + $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"><img src="' . $imageurl . '" alt="' . $clickurl . '" /></a>'; + } } - } - /** - * Print the banner - */ - if ($htmlbanner) { - $bannerobject = $htmlcode; - } else { - $bannerobject = '<div id="xo-bannerfix">'; - if (stristr($imageurl, '.swf')) { - $bannerobject .= '<div id ="xo-fixbanner">' . '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"></a></div>' . '<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl . '" style="z-index:100;">' . '<param name="movie" value="' . $imageurl . '" />' . '<param name="wmode" value="opaque" />' . '</object>'; + if ($align == 'V') { + $bannerobject .= '<br /><br />'; } else { - $bannerobject .= '<a href="' . XOOPS_URL . '/modules/banners/index.php?op=click&bid=' . $bid . '" rel="external" title="' . $clickurl . '"><img src="' . $imageurl . '" alt="' . $clickurl . '" /></a>'; + $bannerobject .= ' '; } - $bannerobject .= '</div>'; + if ($this->getModuleConfig('banners_myip', 'banners') == $this->getEnv('REMOTE_ADDR')) { + // EMPTY + } else { + /** + * Check if this impression is the last one + */ + $impmade = $impmade + 1; + if ($imptotal > 0 && $impmade >= $imptotal) { + $this->db->queryF(sprintf('UPDATE %s SET status = %u, dateend = %u WHERE bid = %u', $this->db->prefix('banner'), 0, time(), $bid)); + }else{ + $this->db->queryF(sprintf('UPDATE %s SET impmade = %u WHERE bid = %u', $this->db->prefix('banner'), $impmade, $bid)); + } + } } return $bannerobject; } Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/install/include/makedata.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/install/include/makedata.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/install/include/makedata.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -163,9 +163,7 @@ $dbm->insert('config', " VALUES (9, 0, 1, 'gzip_compression', '_MD_AM_USEGZIP', '0', '_MD_AM_USEGZIPDSC', 'yesno', 'int', 16)"); $dbm->insert('config', " VALUES (10, 0, 1, 'usercookie', '_MD_AM_USERCOOKIE', 'xoops_user', '_MD_AM_USERCOOKIEDSC', 'textbox', 'text', 18)"); $dbm->insert('config', " VALUES (11, 0, 1, 'session_expire', '_MD_AM_SESSEXPIRE', '15', '_MD_AM_SESSEXPIREDSC', 'textbox', 'int', 22)"); - $dbm->insert('config', " VALUES (12, 0, 1, 'banners', '_MD_AM_BANNERS', '1', '_MD_AM_BANNERSDSC', 'yesno', 'int', 26)"); $dbm->insert('config', " VALUES (13, 0, 1, 'debug_mode', '_MD_AM_DEBUGMODE', '0', '_MD_AM_DEBUGMODEDSC', 'select', 'int', 24)"); - $dbm->insert('config', " VALUES (14, 0, 1, 'my_ip', '_MD_AM_MYIP', '127.0.0.1', '_MD_AM_MYIPDSC', 'textbox', 'text', 29)"); $dbm->insert('config', " VALUES (15, 0, 1, 'use_ssl', '_MD_AM_USESSL', '0', '_MD_AM_USESSLDSC', 'yesno', 'int', 30)"); $dbm->insert('config', " VALUES (16, 0, 1, 'session_name', '_MD_AM_SESSNAME', 'xoops_session', '_MD_AM_SESSNAMEDSC', 'textbox', 'text', 20)"); $dbm->insert('config', " VALUES (17, 0, 2, 'minpass', '_MD_AM_MINPASS', '5', '_MD_AM_MINPASSDSC', 'textbox', 'int', 1)"); Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1,104 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * banners module + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package banners + * @since 2.6.0 + * @author Mage Gr\xE9gory (AKA Mage) + * @version $Id$ + */ +function banners_blocks_show($options) { + $block = array(); + $xoops = Xoops::getInstance(); + //echo $options[3] . ' - ' . $options[3]; + switch ($options[0]) { + case 'random': + $nb_display = $options[1]; + $align = $options[2]; + array_shift($options); + array_shift($options); + array_shift($options); + $client = $options; + $block['banners'] = $xoops->getBanner($nb_display, $align, $client); + break; + + case 'id': + $ids = $options[1]; + $align = $options[2]; + $block['banners'] = $xoops->getBanner(1, $align, 0, $ids); + break; + } + return $block; +} + +function banners_blocks_edit($options) { + $form = ''; + switch ($options[0]) { + + case 'random': + $form .= _MB_BANNERS_DISP . " \n"; + $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n"; + $form .= "<input name=\"options[1]\" size=\"5\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" /> " . _MB_BANNERS . "<br />\n"; + switch ($options[2]){ + case 'H': + $checked_H = 'checked="checked"'; + $checked_V = ''; + break; + + case 'V': + $checked_H = ''; + $checked_V = 'checked="checked"'; + break; + } + $form .= _MB_BANNERS_ALIGNEMENT . " : <input name=\"options[2]\" value=\"H\" type=\"radio\" " . $checked_H . "/>" . _MB_BANNERS_ALIGNEMENT_H . " \n"; + $form .= "<input name=\"options[2]\" value=\"V\" type=\"radio\" " . $checked_V . "/>" . _MB_BANNERS_ALIGNEMENT_V . "<br />\n"; + array_shift($options); + array_shift($options); + array_shift($options); + $form .= _MB_BANNERS_CLIENTSTODISPLAY . "<br /><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n"; + $xoops = Xoops::getInstance(); + $client_Handler = $xoops->getHandlerBannerclient(); + $criteria = new CriteriaCompo(); + $criteria->setSort('name'); + $criteria->setOrder('ASC'); + $client_arr = $client_Handler->getall($criteria); + $form .= "<option value=\"0\" " . (array_search(0, $options) === false ? '' : 'selected="selected"') . ">" . _MB_BANNERS_ALLCLIENTS . "</option>\n"; + foreach (array_keys($client_arr) as $i) { + $form .= "<option value=\"" . $client_arr[$i]->getVar('cid') . "\" " . (array_search($client_arr[$i]->getVar('cid'), $options) === false ? '' : 'selected="selected"') . ">" . $client_arr[$i]->getVar('name')."</option>\n"; + } + $form .= "</select>\n"; + break; + + case 'id': + $form .= _MB_BANNERS_IDDISPLAY . " \n"; + $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n"; + $form .= "<input name=\"options[1]\" size=\"20\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" /> " . _MB_BANNERS_SEP . "<br />\n"; + switch ($options[2]){ + case 'H': + $checked_H = 'checked="checked"'; + $checked_V = ''; + break; + + case 'V': + $checked_H = ''; + $checked_V = 'checked="checked"'; + break; + } + $form .= _MB_BANNERS_ALIGNEMENT . " : <input name=\"options[2]\" value=\"H\" type=\"radio\" " . $checked_H . "/>" . _MB_BANNERS_ALIGNEMENT_H . " \n"; + $form .= "<input name=\"options[2]\" value=\"V\" type=\"radio\" " . $checked_V . "/>" . _MB_BANNERS_ALIGNEMENT_V . "<br />\n"; + break; + } + return $form; +} \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/banners_blocks.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/blocks/index.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Deleted: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/functions.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/functions.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/functions.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -1,26 +0,0 @@ -<?php -/* - You may not change or alter any portion of this comment or credits - of supporting developers from this source code or any supporting source code - which is considered copyrighted (c) material of the original comment or credit authors. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -*/ - -/** - * banners module - * - * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ - * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @package banners - * @since 2.6.0 - * @author Mage Gr\xE9gory (AKA Mage) - * @version $Id$ - */ - -function banner_stats() -{ - echo 'prout'; -} \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/install.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/install.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/include/install.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -62,6 +62,12 @@ } $sql = "DROP TABLE " . $xoops->db->prefix("bannerfinish"); $xoops->db->queryF($sql); - } + } + + // delete banners and my_ip + $sql = "DELETE FROM " . $xoops->db->prefix("config") . " WHERE `conf_name` = 'banners'"; + $xoops->db->queryF($sql); + $sql = "DELETE FROM " . $xoops->db->prefix("config") . " WHERE `conf_name` = 'my_ip'"; + $xoops->db->queryF($sql); return true; } \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/index.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -24,8 +24,6 @@ $xoops = Xoops::getInstance(); XoopsLoad::load('system', 'system'); -$xoops->loadLanguage('admin'); -include dirname(__FILE__) . '/include/functions.php'; // Get main instance $system = System::getInstance(); // Get banners handler @@ -42,19 +40,32 @@ case 'list': default: - $uid = $xoops->user->getVar('uid'); + $access = false; + $admin = false; + if (is_object($xoops->user)) { + $uid = $xoops->user->getVar('uid'); + } else { + $uid = 0; + } if ($uid == 0) { - $xoops->redirect(XOOPS_URL, 2, _NOPERM); + $access = false; } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('uid', $uid)); $client_count = $client_Handler->getCount($criteria); - if ($client_count == 0) { + if ($client_count != 0) { + $access = true; + } + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { + $access = true; + $admin = true; + } + if ($access == false) { $xoops->redirect(XOOPS_URL, 2, _NOPERM); } // Get start pager $start = $system->cleanVars($_REQUEST, 'start', 0, 'int'); - $startF = $system->cleanVars($_REQUEST, 'startF', 0, 'int'); + $startF = $system->cleanVars($_REQUEST, 'startF', 0, 'int'); // Call header $xoops->header('banners_client.html'); // Define Stylesheet @@ -64,17 +75,21 @@ $xoops->theme->addScript($xoops->url('/media/jquery/jquery.js')); $xoops->theme->addScript($xoops->url('/media/jquery/plugins/jquery.ui.js')); $xoops->theme->addScript('modules/system/js/admin.js'); - + // Display banner - $client_arr = $client_Handler->getall($criteria); - foreach (array_keys($client_arr) as $i) { - $cid[] = $client_arr[$i]->getVar("cid"); + if ($admin == false) { + $client_arr = $client_Handler->getall($criteria); + foreach (array_keys($client_arr) as $i) { + $cid[] = $client_arr[$i]->getVar("cid"); + } } - + // Display banner $criteria = new CriteriaCompo(); $criteria->add(new Criteria('status', 0, '!=')); - $criteria->add(new Criteria('cid', '(' . implode(',', $cid) . ')','IN')); + if ($admin == false) { + $criteria->add(new Criteria('cid', '(' . implode(',', $cid) . ')','IN')); + } $criteria->setSort("cid"); $criteria->setOrder("ASC"); $criteria->setStart($start); @@ -93,12 +108,14 @@ $clicks = $banner_arr[$i]->getVar("clicks"); $htmlbanner = $banner_arr[$i]->getVar("htmlbanner"); $htmlcode = $banner_arr[$i]->getVar("htmlcode"); - $name_client = $client_Handler->get($banner_arr[$i]->getVar("cid")); - $name = ''; - if (is_object($name_client)) { - $name = $name_client->getVar("name"); + $client = $client_Handler->get($banner_arr[$i]->getVar("cid")); + if (is_object($client)) { + $client_name = $client->getVar("name"); + $client_uid = $client->getVar("uid"); + } else { + $client_name = ''; + $client_uid = 0; } - if ($impmade == 0) { $percent = 0; } else { @@ -113,13 +130,12 @@ if ($htmlbanner) { $img .= html_entity_decode($htmlcode); } else { - $img = '<div id="xo-bannerfix">'; + $img = ''; if (stristr($imageurl, '.swf')) { $img .= '<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl . '" style="z-index:100;">' . '<param name="movie" value="' . $imageurl . '" />' . '<param name="wmode" value="opaque" />' . '</object>'; } else { $img .= '<img src="' . $imageurl . '" alt="" />'; } - $img .= '</div>'; } $banner['bid'] = $banner_arr[$i]->getVar("bid"); @@ -128,7 +144,8 @@ $banner['left'] = $left; $banner['percent'] = $percent; $banner['imageurl'] = $img; - $banner['name'] = $name; + $banner['name'] = $client_name; + $banner['uid'] = $client_uid; $banner['clickurl'] = $banner_arr[$i]->getVar("clickurl"); $xoops->tpl->append_by_ref('banner', $banner); $xoops->tpl->append_by_ref('popup_banner', $banner); @@ -144,7 +161,9 @@ // Criteria $criteria = new CriteriaCompo(); $criteria->add(new Criteria('status', 0)); - $criteria->add(new Criteria('cid', '(' . implode(',', $cid) . ')','IN')); + if ($admin == false) { + $criteria->add(new Criteria('cid', '(' . implode(',', $cid) . ')','IN')); + } $criteria->setSort("datestart"); $criteria->setOrder("DESC"); $criteria->setStart($startF); @@ -163,6 +182,14 @@ $htmlcode = $banner_finish_arr[$i]->getVar("htmlcode"); $impressions = $banner_finish_arr[$i]->getVar("impmade"); $clicks = $banner_finish_arr[$i]->getVar("clicks"); + $client = $client_Handler->get($banner_finish_arr[$i]->getVar("cid")); + if (is_object($client)) { + $client_name = $client->getVar("name"); + $client_uid = $client->getVar("uid"); + } else { + $client_name = ''; + $client_uid = 0; + } if ($impressions != 0) { $percent = substr(100 * $clicks / $impressions, 0, 5); } else { @@ -189,12 +216,8 @@ $banner_finish['datestart'] = XoopsLocal::formatTimestamp($banner_finish_arr[$i]->getVar("datestart"), "m"); $banner_finish['dateend'] = XoopsLocal::formatTimestamp($banner_finish_arr[$i]->getVar("dateend"), "m"); $banner_finish['clickurl'] = $banner_finish_arr[$i]->getVar("clickurl"); - $name_client = $client_Handler->get($banner_finish_arr[$i]->getVar("cid")); - $name = ''; - if (is_object($name_client)) { - $name = $name_client->getVar("name"); - } - $banner_finish['name'] = $name; + $banner_finish['name'] = $client_name; + $banner_finish['uid'] = $client_uid; $xoops->tpl->append_by_ref('banner_finish', $banner_finish); $xoops->tpl->append_by_ref('popup_banner_finish', $banner_finish); unset($banner_finish); @@ -209,14 +232,27 @@ break; case 'edit': - $uid = $xoops->user->getVar('uid'); + $access = false; + $admin = false; + if (is_object($xoops->user)) { + $uid = $xoops->user->getVar('uid'); + } else { + $uid = 0; + } if ($uid == 0) { - $xoops->redirect(XOOPS_URL, 2, _NOPERM); + $access = false; } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('uid', $uid)); $client_count = $client_Handler->getCount($criteria); - if ($client_count == 0) { + if ($client_count != 0) { + $access = true; + } + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { + $access = true; + $admin = true; + } + if ($access == false) { $xoops->redirect(XOOPS_URL, 2, _NOPERM); } $bid = $system->cleanVars($_REQUEST, 'bid', 0, 'int'); @@ -237,8 +273,21 @@ break; case 'save': - $uid = $xoops->user->getVar('uid'); + $access = true; + $admin = false; + if (is_object($xoops->user)) { + $uid = $xoops->user->getVar('uid'); + } else { + $uid = 0; + } if ($uid == 0) { + $access = false; + } + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { + $access = true; + $admin = true; + } + if ($access == false) { $xoops->redirect(XOOPS_URL, 2, _NOPERM); } if (!$xoops->security->check()) { @@ -251,8 +300,10 @@ $criteria->add(new Criteria('cid', $obj->getVar("cid"))); $client_arr = $client_Handler->getall($criteria); foreach (array_keys($client_arr) as $i) { - if ($client_arr[$i]->getVar("uid") != $uid){ - $xoops->redirect(XOOPS_URL, 2, _NOPERM); + if ($admin == false) { + if ($client_arr[$i]->getVar("uid") != $uid){ + $xoops->redirect(XOOPS_URL, 2, _NOPERM); + } } } $obj->setVar("clickurl", $_POST["clickurl"]); @@ -261,13 +312,26 @@ } $xoops->error($obj->getHtmlErrors()); } else { - $xoops->redirect(XOOPS_URL, 1, _MD_BANNERS_INDEX_DBERROR); + $xoops->redirect(XOOPS_URL, 1, _MD_BANNERS_INDEX_NO_ID); } break; - + case 'EmailStats': - $uid = $xoops->user->getVar('uid'); + $access = true; + $admin = false; + if (is_object($xoops->user)) { + $uid = $xoops->user->getVar('uid'); + } else { + $uid = 0; + } if ($uid == 0) { + $access = false; + } + if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) { + $access = true; + $admin = true; + } + if ($access == false) { $xoops->redirect(XOOPS_URL, 2, _NOPERM); } $bid = $system->cleanVars($_REQUEST, 'bid', 0, 'int'); @@ -277,42 +341,47 @@ $criteria->add(new Criteria('cid', $banner->getVar("cid"))); $client_arr = $client_Handler->getall($criteria); foreach (array_keys($client_arr) as $i) { - if ($client_arr[$i]->getVar("uid") != $uid){ - $xoops->redirect(XOOPS_URL, 2, _NOPERM); + if ($admin == false) { + if ($client_arr[$i]->getVar("uid") != $uid){ + $xoops->redirect(XOOPS_URL, 2, _NOPERM); + } } $client_uid = $client_arr[$i]->getVar("uid"); $client_name = $client_arr[$i]->getVar("name"); } $user = $member_handler->getUser($client_arr[$i]->getVar("uid")); $email = $user->getVar("email", 'n'); - if ($banner->getVar('impmade') == 0) { - $percent = 0; + if ($email != ''){ + if ($banner->getVar('impmade') == 0) { + $percent = 0; + } else { + $percent = substr(100 * $banner->getVar('clicks') / $banner->getVar('impmade'), 0, 5); + } + if ($banner->getVar('imptotal') == 0) { + $left = _AM_BANNERS_BANNERS_UNLIMIT; + $banner->setVar('imptotal', _AM_BANNERS_BANNERS_UNLIMIT); + } else { + $left = $banner->getVar('imptotal') - $banner->getVar('impmade'); + } + $date = date("F jS Y, h:iA."); + $subject = sprintf(_MD_BANNERS_INDEX_MAIL_SUBJECT, $xoops->getConfig('sitename')); + $message = sprintf(_MD_BANNERS_INDEX_MAIL_MESSAGE, $xoops->getConfig('sitename'), $client_name, $bid, $banner->getVar('imageurl'), $banner->getVar('clickurl'), $banner->getVar('imptotal'), $banner->getVar('impmade'), $left, $banner->getVar('clicks'), $percent, $date); + $xoopsMailer = $xoops->getMailer(); + $xoopsMailer->useMail(); + $xoopsMailer->setToEmails($email); + $xoopsMailer->setFromEmail($xoops->getConfig('adminmail')); + $xoopsMailer->setFromName($xoops->getConfig('sitename')); + $xoopsMailer->setSubject($subject); + $xoopsMailer->setBody($message); + if (!$xoopsMailer->send()) { + $xoops->redirect("index.php", 2, sprintf(_MAIL_SENDMAILNG, $email)); + } + $xoops->redirect("index.php", 2, _MD_BANNERS_INDEX_MAIL_OK); } else { - $percent = substr(100 * $banner->getVar('clicks') / $banner->getVar('impmade'), 0, 5); + $xoops->redirect("index.php", 2, _MD_BANNERS_INDEX_NOMAIL); } - if ($banner->getVar('imptotal') == 0) { - $left = _AM_BANNERS_BANNERS_UNLIMIT; - $banner->setVar('imptotal', _AM_BANNERS_BANNERS_UNLIMIT); - } else { - $left = $banner->getVar('imptotal') - $banner->getVar('impmade'); - } - $date = date("F jS Y, h:iA."); - $subject = sprintf(_MD_BANNERS_INDEX_MAIL_SUBJECT, $xoops->getConfig('sitename')); - $message = sprintf(_MD_BANNERS_INDEX_MAIL_MESSAGE, $xoops->getConfig('sitename'), $client_name, $bid, $banner->getVar('imageurl'), $banner->getVar('clickurl'), $banner->getVar('imptotal'), $banner->getVar('impmade'), $left, $banner->getVar('clicks'), $percent, $date); - $xoopsMailer = $xoops->getMailer(); - $xoopsMailer->useMail(); - $xoopsMailer->setToEmails($email); - $xoopsMailer->setFromEmail($xoops->getConfig('adminmail')); - $xoopsMailer->setFromName($xoops->getConfig('sitename')); - $xoopsMailer->setSubject($subject); - $xoopsMailer->setBody($message); - - if (!$xoopsMailer->send()) { - $xoops->redirect("index.php", 2, sprintf(_MAIL_SENDMAILNG, $email)); - } - $xoops->redirect("index.php", 2, _MD_BANNERS_INDEX_MAIL_OK); } else { - $xoops->redirect(XOOPS_URL, 1, _MD_BANNERS_INDEX_DBERROR); + $xoops->redirect(XOOPS_URL, 1, _MD_BANNERS_INDEX_NO_ID); } break; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/blocks.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/blocks.php (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/blocks.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1,30 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * banners module + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @package banners + * @since 2.6.0 + * @author Mage Gr\xE9gory (AKA Mage) + * @version $Id$ + */ +define("_MB_BANNERS_DISP","Display"); +define("_MB_BANNERS","banners"); +define("_MB_BANNERS_ALIGNEMENT","Alignement"); +define("_MB_BANNERS_ALIGNEMENT_H","horizontal"); +define("_MB_BANNERS_ALIGNEMENT_V","vertical"); +define("_MB_BANNERS_ALLCLIENTS","All clients"); +define("_MB_BANNERS_CLIENTSTODISPLAY","Select displayed clients"); +define("_MB_BANNERS_IDDISPLAY","Indicate the id of the banners to be displayed"); +define("_MB_BANNERS_SEP","separated with ','."); \ No newline at end of file Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/blocks.php ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Rev URL Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/main.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/main.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/main.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -38,4 +38,5 @@ Report Generated on: %s"); define("_MD_BANNERS_INDEX_MAIL_OK", "Available Banner statistics for the selected banner have been sent to your account email address."); define("_MD_BANNERS_INDEX_MAIL_SUBJECT", "Your Banner Statistics at %s"); +define("_MD_BANNERS_INDEX_NOMAIL", "Failed to send: E-Mail address does not exist."); include_once('admin.php'); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/modinfo.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/modinfo.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/language/english/modinfo.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -28,6 +28,13 @@ define("_MI_BANNERS_CLIENTS", "Clients"); define("_MI_BANNERS_BANNERS", "Banners manager"); define("_MI_BANNERS_ABOUT", "About"); +// Blocks +define("_MI_BANNERS_BLOCKS_RANDOM", "Random Banners"); +define("_MI_BANNERS_BLOCKS_RANDOMDSC", "Display banners randomly"); +define("_MI_BANNERS_BLOCKS_ID", "Id Banners"); +define("_MI_BANNERS_BLOCKS_IDDSC", "Display banners by id"); // Preferences +define("_MI_BANNERS_PREFERENCE_MYIP", "Your IP address"); +define("_MI_BANNERS_PREFERENCE_MYIPDSC", "This IP will not count as an impression for banners"); define("_MI_BANNERS_PREFERENCE_PAGER", "Number of banners to display per page"); define("_MI_BANNERS_PREFERENCE_CLIENTSPAGER", "Number of clients to display per page"); \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/banners_client.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -28,9 +28,11 @@ <a class="tooltip" href="index.php?op=edit&bid=<{$banner.bid}>" title="<{$smarty.const._AM_BANNERS_EDIT}>"> <img src="<{xoAdminIcons edit.png}>" alt="<{$smarty.const._AM_BANNERS_EDIT}>" /> </a> + <{if $banner.uid != 0}> <a class="tooltip" href="index.php?op=EmailStats&bid=<{$banner.bid}>" title="<{$smarty.const._MD_BANNERS_INDEX_EMAIL}>"> <img src="<{xoAdminIcons mail_send.png}>" alt="<{$smarty.const._MD_BANNERS_INDEX_EMAIL}>" /> </a> + <{/if}> </td> </tr> <{/foreach}> @@ -82,9 +84,11 @@ <a class="tooltip" href="index.php?op=edit&bid=<{$banner_finish.bid}>" title="<{$smarty.const._AM_BANNERS_EDIT}>"> <img src="<{xoAdminIcons edit.png}>" alt="<{$smarty.const._AM_BANNERS_EDIT}>" /> </a> + <{if $banner_finish.uid != 0}> <a class="tooltip" href="index.php?op=EmailStats&bid=<{$banner_finish.bid}>" title="<{$smarty.const._MD_BANNERS_INDEX_EMAIL}>"> <img src="<{xoAdminIcons mail_send.png}>" alt="<{$smarty.const._MD_BANNERS_INDEX_EMAIL}>" /> </a> + <{/if}> </td> </tr> <{/foreach}> Property changes on: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks ___________________________________________________________________ Added: tsvn:autoprops + *.php = svn:executable=*;svn:keywords=Author Date Id Rev URL; Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_id.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_id.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_id.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1 @@ +<{$block.banners}> \ No newline at end of file Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_random.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_random.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/banners_blocks_random.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1 @@ +<{$block.banners}> \ No newline at end of file Added: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/index.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/index.html (rev 0) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/templates/blocks/index.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/xoops_version.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/xoops_version.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/banners/xoops_version.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -64,10 +64,35 @@ // Admin Templates $modversion['templates'][] = array('file' => 'banners_admin_banners.html', 'description' => '', 'type' => 'admin'); -$modversion['templates'][] = array('file' => 'banners_admin_clients.html', 'description' => '', 'type' => 'admin'); +$modversion['templates'][] = array('file' => 'banners_admin_clients.html', 'description' => '', 'type' => 'admin'); +// blocks +$i = 0; +$modversion['blocks'][$i]['file'] = 'banners_blocks.php'; +$modversion['blocks'][$i]['name'] = _MI_BANNERS_BLOCKS_RANDOM; +$modversion['blocks'][$i]['description'] = _MI_BANNERS_BLOCKS_RANDOMDSC; +$modversion['blocks'][$i]['show_func'] = 'banners_blocks_show'; +$modversion['blocks'][$i]['edit_func'] = 'banners_blocks_edit'; +$modversion['blocks'][$i]['options'] = 'random|1|H|0'; +$modversion['blocks'][$i]['template'] = 'banners_blocks_random.html'; +$i++; +$modversion['blocks'][$i]['file'] = 'banners_blocks.php'; +$modversion['blocks'][$i]['name'] = _MI_BANNERS_BLOCKS_ID; +$modversion['blocks'][$i]['description'] = _MI_BANNERS_BLOCKS_IDDSC; +$modversion['blocks'][$i]['show_func'] = 'banners_blocks_show'; +$modversion['blocks'][$i]['edit_func'] = 'banners_blocks_edit'; +$modversion['blocks'][$i]['options'] = 'id||H'; +$modversion['blocks'][$i]['template'] = 'banners_blocks_id.html'; + // Preferences $i = 0; +$modversion['config'][$i]['name'] = 'banners_myip'; +$modversion['config'][$i]['title'] = '_MI_BANNERS_PREFERENCE_MYIP'; +$modversion['config'][$i]['description'] = '_MI_BANNERS_PREFERENCE_MYIPDSC'; +$modversion['config'][$i]['formtype'] = 'textbox'; +$modversion['config'][$i]['valuetype'] = 'text'; +$modversion['config'][$i]['default'] = '127.0.0.1'; +$i++; $modversion['config'][$i]['name'] = 'banners_pager'; $modversion['config'][$i]['title'] = '_MI_BANNERS_PREFERENCE_PAGER'; $modversion['config'][$i]['description'] = ''; @@ -80,4 +105,4 @@ $modversion['config'][$i]['description'] = ''; $modversion['config'][$i]['formtype'] = 'textbox'; $modversion['config'][$i]['valuetype'] = 'int'; -$modversion['config'][$i]['default'] = 10; \ No newline at end of file +$modversion['config'][$i]['default'] = 15; \ No newline at end of file Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/language/english/admin/preferences.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/language/english/admin/preferences.php 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/modules/system/language/english/admin/preferences.php 2012-01-05 21:37:45 UTC (rev 8643) @@ -6,7 +6,7 @@ * _CHARSET UTF-8 * @version $Id$ */ - + // dont change define("_AM_DBUPDATED",_AM_SYSTEM_DBUPDATED); @@ -77,10 +77,6 @@ define("_MD_AM_SESSNAMEDSC", "The name of session (Valid only when 'use custom session' is enabled)"); define("_MD_AM_SESSEXPIRE", "Session expiration"); define("_MD_AM_SESSEXPIREDSC", "Maximum duration of session idle time in minutes (Valid only when 'use custom session' is enabled.)"); -define("_MD_AM_BANNERS", "Activate banner ads?"); -define("_MD_AM_BANNERSDSC", ""); -define("_MD_AM_MYIP", "Your IP address"); -define("_MD_AM_MYIPDSC", "This IP will not count as an impression for banners"); define("_MD_AM_ALWDHTML", "HTML tags allowed in all posts."); define("_MD_AM_INVLDMINPASS", "Invalid value for minimum length of password."); define("_MD_AM_INVLDUCOOK", "Invalid value for usercookie name."); Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/themes/default/theme.html =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/themes/default/theme.html 2012-01-05 19:55:19 UTC (rev 8642) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/themes/default/theme.html 2012-01-05 21:37:45 UTC (rev 8643) @@ -39,7 +39,7 @@ <table cellspacing="0"> <tr id="header"> <td id="headerlogo"><a href="<{xoAppUrl /}>" title="<{$xoops_sitename}>"><img src="<{xoImgUrl xoops-logo.png}>" alt="<{$xoops_sitename}>" /></a></td> - <td id="headerbanner"><{$xoops_banner}></td> + <td id="headerbanner"><div id="xo-bannerfix"><{$xoops_banner}></div></td> </tr> <tr> <td id="headerbar" colspan="2"> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |