From 0344881e87fc112e0affb7c6fdb264ee954b2206 Mon Sep 17 00:00:00 2001 From: minimus Date: Sat, 2 Nov 2013 18:38:31 +0300 Subject: [PATCH] Updating to 1.7.63 --- README.md | 12 +++ simple-ads-manager/ad.class.php | 6 +- simple-ads-manager/admin.class.php | 8 +- simple-ads-manager/block.list.admin.class.php | 4 +- simple-ads-manager/errorlog.admin.class.php | 4 +- simple-ads-manager/js/sam-layout.js | 2 +- simple-ads-manager/js/sam-settings.js | 12 +-- simple-ads-manager/list.admin.class.php | 8 +- simple-ads-manager/readme.txt | 24 +++++- simple-ads-manager/sam-ajax.php | 75 +++++++++++++++++++ simple-ads-manager/sam.class.php | 10 +-- simple-ads-manager/simple-ads-manager.php | 27 +------ simple-ads-manager/updater.class.php | 9 ++- .../zone.editor.admin.class.php | 4 +- simple-ads-manager/zone.list.admin.class.php | 6 +- 15 files changed, 152 insertions(+), 59 deletions(-) create mode 100644 simple-ads-manager/sam-ajax.php diff --git a/README.md b/README.md index c246f79..2553bf3 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,18 @@ Do not upgrade this plugin from Update page! Upgrade it from Plugins page! Change log ========== +1.7.63 +* Some bugs (Ads Block style, Click Tracker) are resolved. + +1.7.61 +* Some bugs are resolved. + +1.7.60 +* Minor bug is resolved (Ads Places List) + +1.7.58 +* Major bug is resolved (bug of database creating, not database updating) + 1.7.57 * Data updating bugs of editors are fixed. Thanks to **Latibro**. * Control of Error Log is added. diff --git a/simple-ads-manager/ad.class.php b/simple-ads-manager/ad.class.php index 0a48471..db61c60 100644 --- a/simple-ads-manager/ad.class.php +++ b/simple-ads-manager/ad.class.php @@ -637,7 +637,7 @@ private function buildZone($args = null, $useCodes = false, $crawler = false) { } } } - if(is_page()) $id = $zone['z_page']; + if(is_page() && !is_front_page()) $id = $zone['z_page']; if(is_attachment()) $id = $zone['z_attachment']; } if(is_search()) $id = $zone['z_search']; @@ -724,6 +724,7 @@ private function buildBlock($args = null, $crawler = false) { $lines = (integer) $block['b_lines']; $cols = (integer) $block['b_cols']; $blockDiv = "
"; + $lineDiv = "
"; $itemDiv = "
"; for($i = 1; $i <= $lines; $i++) { @@ -752,8 +753,9 @@ private function buildBlock($args = null, $crawler = false) { } if(!empty($iDiv)) $lDiv .= $itemDiv.$iDiv."
"; } - if(!empty($lDiv)) $output .= $blockDiv.$lDiv."
"; + if(!empty($lDiv)) $output .= $lineDiv.$lDiv."
"; } + $output = $blockDiv.$output.""; } else $output = ''; diff --git a/simple-ads-manager/admin.class.php b/simple-ads-manager/admin.class.php index af1bc68..ba4a46b 100644 --- a/simple-ads-manager/admin.class.php +++ b/simple-ads-manager/admin.class.php @@ -716,13 +716,14 @@ public function drawDeactivateSection() { public function drawTextOption( $id, $args ) { $settings = parent::getSettings(); - $width = $args['width']; + if(isset($args['width'])) $width = $args['width']; + else $width = 55; ?> + style="height: 22px; font-size: 11px; " /> errorString)) echo $errors->errorString; if(isset($_GET['settings-updated'])) $updated = $_GET['settings-updated']; elseif(isset($_GET['updated'])) $updated = $_GET['updated']; + else $updated = false; if($updated === 'true') { parent::getSettings(true); ?> @@ -940,7 +942,7 @@ public function samAdminPage() { } public function addButtons() { - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') && ! current_user_can(SAM_ACCESS) ) return; if ( get_user_option('rich_editing') == 'true') { diff --git a/simple-ads-manager/block.list.admin.class.php b/simple-ads-manager/block.list.admin.class.php index e785b60..3a98ea1 100644 --- a/simple-ads-manager/block.list.admin.class.php +++ b/simple-ads-manager/block.list.admin.class.php @@ -34,8 +34,8 @@ public function page() { elseif($iaction === 'kill') $wpdb->query("DELETE FROM $bTable WHERE id=$item"); } if($iaction === 'kill-em-all') $wpdb->query("DELETE FROM $bTable WHERE trash=true"); - $trash_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $bTable WHERE trash = TRUE")); - $active_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $bTable WHERE trash = FALSE")); + $trash_num = $wpdb->get_var("SELECT COUNT(*) FROM $bTable WHERE trash = TRUE"); + $active_num = $wpdb->get_var("SELECT COUNT(*) FROM $bTable WHERE trash = FALSE"); if(is_null($active_num)) $active_num = 0; if(is_null($trash_num)) $trash_num = 0; $all_num = $trash_num + $active_num; diff --git a/simple-ads-manager/errorlog.admin.class.php b/simple-ads-manager/errorlog.admin.class.php index e6adb87..cc2a295 100644 --- a/simple-ads-manager/errorlog.admin.class.php +++ b/simple-ads-manager/errorlog.admin.class.php @@ -35,8 +35,8 @@ public function page() { } if($iaction === 'kill-em-all') $wpdb->query("DELETE FROM $eTable"); if($iaction === 'kill-resolved') $wpdb->query("DELETE FROM $eTable WHERE resolved = TRUE;"); - $resolved_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $eTable WHERE resolved = TRUE")); - $active_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $eTable WHERE resolved = FALSE")); + $resolved_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM %s WHERE resolved = TRUE", $eTable)); + $active_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM %s WHERE resolved = FALSE", $eTable)); if(is_null($active_num)) $active_num = 0; if(is_null($resolved_num)) $resolved_num = 0; $all_num = $resolved_num + $active_num; diff --git a/simple-ads-manager/js/sam-layout.js b/simple-ads-manager/js/sam-layout.js index dd40b4e..3005c0a 100644 --- a/simple-ads-manager/js/sam-layout.js +++ b/simple-ads-manager/js/sam-layout.js @@ -11,7 +11,7 @@ data: { action: "sam_click", sam_ad_id: adId, - _ajax_nonce: samAjax._ajax_nonce + level: samAjax.level }, async: true }); diff --git a/simple-ads-manager/js/sam-settings.js b/simple-ads-manager/js/sam-settings.js index 907158c..fe42699 100644 --- a/simple-ads-manager/js/sam-settings.js +++ b/simple-ads-manager/js/sam-settings.js @@ -16,14 +16,16 @@ $('#access').val(options.values[values[1]]); } }); + + var el = $('#errorlog'), elfs = $('#errorlogFS'); - $('#errorlog').click(function() { - if($('#errorlog').is(':checked')) $('#errorlogFS').attr('checked', true); - if(!$('#errorlog').is(':checked')) $('#errorlogFS').attr('checked', false); + el.click(function() { + if(el.is(':checked')) elfs.attr('checked', true); + if(!el.is(':checked')) elfs.attr('checked', false); }); - $('#errorlogFS').click(function() { - if(!$('errorlogFS').is(':checked')) $('#errorlog').attr('checked', true); + elfs.click(function() { + if(!elfs.is(':checked')) el.attr('checked', true); }); }); })(jQuery); \ No newline at end of file diff --git a/simple-ads-manager/list.admin.class.php b/simple-ads-manager/list.admin.class.php index d5e1e28..63d12bf 100644 --- a/simple-ads-manager/list.admin.class.php +++ b/simple-ads-manager/list.admin.class.php @@ -115,8 +115,8 @@ public function page() { $wpdb->query("UPDATE $pTable SET $pTable.patch_hits = 0;"); $wpdb->query("UPDATE $aTable SET $aTable.ad_hits = 0, $aTable.ad_clicks = 0;"); } - $trash_num = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM '.$pTable.' WHERE trash = TRUE')); - $active_num = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM '.$pTable.' WHERE trash = FALSE')); + $trash_num = $wpdb->get_var("SELECT COUNT(*) FROM $pTable WHERE trash = TRUE"); + $active_num = $wpdb->get_var("SELECT COUNT(*) FROM $pTable WHERE trash = FALSE"); if(is_null($active_num)) $active_num = 0; if(is_null($trash_num)) $trash_num = 0; $all_num = $trash_num + $active_num; @@ -296,8 +296,8 @@ public function page() { elseif($iaction === 'kill') $wpdb->query("DELETE FROM $aTable WHERE id = $iitem"); } if($iaction === 'kill-em-all') $wpdb->query("DELETE FROM $aTable WHERE trash=true"); - $trash_num = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM '.$aTable.' WHERE (trash = TRUE) AND (pid = '.$item.')')); - $active_num = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM '.$aTable.' WHERE (trash = FALSE) AND (pid = '.$item.')')); + $trash_num = $wpdb->get_var("SELECT COUNT(*) FROM $aTable WHERE (trash = TRUE) AND (pid = $item)"); + $active_num = $wpdb->get_var("SELECT COUNT(*) FROM $aTable WHERE (trash = FALSE) AND (pid = $item)"); if(is_null($active_num)) $active_num = 0; if(is_null($trash_num)) $trash_num = 0; $all_num = $trash_num + $active_num; diff --git a/simple-ads-manager/readme.txt b/simple-ads-manager/readme.txt index fd3a985..cf9aa82 100644 --- a/simple-ads-manager/readme.txt +++ b/simple-ads-manager/readme.txt @@ -2,11 +2,11 @@ Contributors: minimus Donate link: https://load.payoneer.com/LoadToPage.aspx?email=minimus@simplelib.com Tags: ad, adbrite, adgridwork, adify, admin, adpinion, adroll, ads, adsense, adserver, advertisement, advertising, affiliate, banner, banners, chitika, cj, commercial, commission, crispads, dfp, google, income, junction, link, manager, media, money, plugin, random, referral, revenue, rotator, seo, server, shoppingads, widget, widgetbucks, yahoo, ypn -Requires at least: 3.3 -Tested up to: 3.4.1 -Stable tag: 1.7.57 +Requires at least: 3.5 +Tested up to: 3.7 +Stable tag: 1.7.63 -Advertisment rotation system with a flexible logic of displaying advertisements. +Advertisement rotation system with a flexible logic of displaying advertisements. == Description == @@ -82,6 +82,14 @@ No questions now... == Changelog == += 1.7.63 = +* Some bugs (Ads Block style, Click Tracker) are resolved. += 1.7.61 = +* Some bugs are resolved. += 1.7.60 = +* Minor bug is resolved (Ads Places List) += 1.7.58 = +* Major bug is resolved (bug of database creating, not database updating) = 1.7.57 = * Data updating bugs of editors are fixed. Thanks to **Latibro** * Control of Error Log is added @@ -159,6 +167,14 @@ No questions now... == Upgrade Notice == += 1.7.63 = +Some bugs (Ads Block style, Click Tracker) are resolved. += 1.7.61 = +Some bugs are resolved. += 1.7.60 = +Minor bug is resolved (Ads Places List) += 1.7.58 = +Major bug is resolved (bug of database creating, not database updating) = 1.7.57 = Data updating bugs of editors are fixed. Thanks to **Latibro**. Control of Error Log is added. diff --git a/simple-ads-manager/sam-ajax.php b/simple-ads-manager/sam-ajax.php new file mode 100644 index 0000000..3c3faf7 --- /dev/null +++ b/simple-ads-manager/sam-ajax.php @@ -0,0 +1,75 @@ +prefix . 'options'; +$oSql = "SELECT $oTable.option_value FROM $oTable WHERE $oTable.option_name = 'blog_charset'"; +$charset = $wpdb->get_var($oSql); + +//Typical headers +@header("Content-Type: application/json; charset=$charset"); +@header( 'X-Robots-Tag: noindex' ); + +send_nosniff_header(); +nocache_headers(); + +$action = !empty($_POST['action']) ? 'sam_ajax_' . stripslashes($_POST['action']) : false; + +//A bit of security +$allowed_actions = array( + 'sam_ajax_sam_click', + 'sam_ajax_sam_show' +); + +if(in_array($action, $allowed_actions)){ + switch($action) { + case 'sam_ajax_sam_click': + $out = null; + if(isset($_POST['sam_ad_id'])) { + $adId = $_POST['sam_ad_id']; + $aId = explode('_', $adId); + $id = (integer) $aId[1]; + } + else $id = -100; + + if($id > 0) { + $aTable = $wpdb->prefix . "sam_ads"; + + $aSql = "UPDATE $aTable SET $aTable.ad_clicks = $aTable.ad_clicks+1 WHERE $aTable.id = %d;"; + $result = $wpdb->query($wpdb->prepare($aSql, $id)); + if($result === 1) { + $out = array('id' => $id, 'result' => $result, 'charset' => $charset); + wp_send_json_success( $out ); + } + else wp_send_json_error(array('id' => $id, 'sql' => $wpdb->last_query, 'error' => $wpdb->last_error)); + } + else wp_send_json_error(array('id' => $id)); + break; + + case 'sam_ajax_sam_show': + + break; + } +} +else wp_send_json_error(array('error' => 'Not allowed action')); \ No newline at end of file diff --git a/simple-ads-manager/sam.class.php b/simple-ads-manager/sam.class.php index 3d4b842..030f0cf 100644 --- a/simple-ads-manager/sam.class.php +++ b/simple-ads-manager/sam.class.php @@ -37,8 +37,8 @@ class SimpleAdsManager { ); public function __construct() { - define('SAM_VERSION', '1.7.57'); - define('SAM_DB_VERSION', '2.1'); + define('SAM_VERSION', '1.7.63'); + define('SAM_DB_VERSION', '2.2'); define('SAM_PATH', dirname( __FILE__ )); define('SAM_URL', plugins_url('/' . str_replace( basename( __FILE__), "", plugin_basename( __FILE__ ) )) ); define('SAM_IMG_URL', SAM_URL.'images/'); @@ -64,7 +64,7 @@ public function __construct() { define('SAM_IS_POST_TYPE_ARCHIVE', 16384); if(!is_admin()) { - add_action('template_redirect', array(&$this, 'headerScripts')); + add_action('wp_enqueue_scripts', array(&$this, 'headerScripts')); add_action('wp_head', array(&$this, 'headerCodes')); add_shortcode('sam', array(&$this, 'doShortcode')); @@ -117,8 +117,8 @@ public function headerScripts() { if($options['useSWF']) wp_enqueue_script('swfobject'); wp_enqueue_script('samLayout', SAM_URL.'js/sam-layout.js', array('jquery'), SAM_VERSION); wp_localize_script('samLayout', 'samAjax', array( - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - '_ajax_nonce' => $this->samNonce) + 'ajaxurl' => SAM_URL . 'sam-ajax.php', + 'level' => count(explode('/', str_replace( ABSPATH, '', dirname( __FILE__ ) )))) ); } diff --git a/simple-ads-manager/simple-ads-manager.php b/simple-ads-manager/simple-ads-manager.php index 44da296..d279dbe 100644 --- a/simple-ads-manager/simple-ads-manager.php +++ b/simple-ads-manager/simple-ads-manager.php @@ -3,7 +3,7 @@ Plugin Name: Simple Ads Manager Plugin URI: http://www.simplelib.com/?p=480 Description: "Simple Ads Manager" is easy to use plugin providing a flexible logic of displaying advertisements. Visit SimpleLib blog for more details. -Version: 1.7.57 +Version: 1.7.63 Author: minimus Author URI: http://blogcoding.ru */ @@ -83,30 +83,5 @@ function drawAdsBlock($args = null) { if(is_object($samObject)) echo $samObject->buildAdBlock($args); else echo ''; } - - add_action('wp_ajax_nopriv_sam_click', 'samClickHandler'); - add_action('wp_ajax_sam_click', 'samClickHandler'); - function samClickHandler() { - $error = null; - if(isset($_POST['sam_ad_id'])) { - $adId = $_POST['sam_ad_id']; - $aId = explode('_', $adId); - $id = (integer) $aId[1]; - } - else $id = -100; - - if(check_ajax_referer('samNonce') && ($id > 0)) { - global $wpdb; - $aTable = $wpdb->prefix . "sam_ads"; - - $result = $wpdb->query("UPDATE $aTable SET $aTable.ad_clicks = $aTable.ad_clicks+1 WHERE $aTable.id = $id;"); - if($result) $error = $id; - else $error = 'error'; - } - else $error = 'error'; - - if($error) exit($error); - else exit; - } } ?> diff --git a/simple-ads-manager/updater.class.php b/simple-ads-manager/updater.class.php index e4c8f63..b1fe069 100644 --- a/simple-ads-manager/updater.class.php +++ b/simple-ads-manager/updater.class.php @@ -146,7 +146,7 @@ public function update() { x_view_users varchar(255) DEFAULT NULL, ad_users_adv tinyint(1) DEFAULT 0, view_type INT(11) DEFAULT 1, - view_pages SET('isHome', 'isSingular', 'isSingle', 'isPage', 'isAttachment', 'isSearch', 'is404', 'isArchive', 'isTax', 'isCategory', 'isTag', 'isAuthor', 'isDate') DEFAULT NULL, + view_pages SET('isHome','isSingular','isSingle','isPage','isAttachment','isSearch','is404','isArchive','isTax','isCategory','isTag','isAuthor','isDate','isPostType','isPostTypeArchive') DEFAULT NULL, view_id VARCHAR(255) DEFAULT NULL, ad_cats TINYINT(1) DEFAULT 0, view_cats VARCHAR(255) DEFAULT NULL, @@ -352,6 +352,7 @@ public function update() { elseif($vData['major'] < 2) { $aSql = "ALTER TABLE $aTable CONVERT TO $charset_collate, + MODIFY view_pages set('isHome','isSingular','isSingle','isPage','isAttachment','isSearch','is404','isArchive','isTax','isCategory','isTag','isAuthor','isDate','isPostType','isPostTypeArchive') default NULL, ADD COLUMN ad_swf tinyint(1) DEFAULT 0, ADD COLUMN ad_swf_flashvars text, ADD COLUMN ad_swf_params text, @@ -370,6 +371,7 @@ public function update() { } elseif($vData['major'] == 2 && $vData['minor'] == 0) { $aSql = "ALTER TABLE $aTable + MODIFY view_pages set('isHome','isSingular','isSingle','isPage','isAttachment','isSearch','is404','isArchive','isTax','isCategory','isTag','isAuthor','isDate','isPostType','isPostTypeArchive') default NULL, ADD COLUMN ad_title varchar(255) DEFAULT NULL, ADD COLUMN ad_swf tinyint(1) DEFAULT 0, ADD COLUMN ad_swf_flashvars text, @@ -386,6 +388,11 @@ public function update() { ADD COLUMN adv_mail varchar(50) DEFAULT NULL;"; $dbResult = $wpdb->query($aSql); } + elseif($vData['major'] == 2 && $vData['minor'] == 1) { + $aSql = "ALTER TABLE $aTable + MODIFY view_pages set('isHome','isSingular','isSingle','isPage','isAttachment','isSearch','is404','isArchive','isTax','isCategory','isTag','isAuthor','isDate','isPostType','isPostTypeArchive') default NULL;"; + $dbResult = $wpdb->query($aSql); + } if($el) { self::errorWrite($eTable, $aTable, $aSql, $dbResult); diff --git a/simple-ads-manager/zone.editor.admin.class.php b/simple-ads-manager/zone.editor.admin.class.php index c2362d9..91bfcb4 100644 --- a/simple-ads-manager/zone.editor.admin.class.php +++ b/simple-ads-manager/zone.editor.admin.class.php @@ -154,7 +154,7 @@ public function page() { 'trash' => ($_POST['trash'] === 'true' ? 1 : 0) ); //FIXED $formatRow = array( '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d'); - $formatRow = array( '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d'); + $formatRow = array( '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d'); if($zoneId === __('Undefined', SAM_DOMAIN)) { $wpdb->insert($zTable, $updateRow); $updated = true; @@ -231,6 +231,8 @@ public function page() { $row = $wpdb->get_row($zSql, ARRAY_A); $zCats = unserialize($row['z_cats']); $zAuthors = unserialize($row['z_authors']); + $zSingleCT = unserialize($row['z_single_ct']); + $zArchiveCT = unserialize($row['z_archive_ct']); foreach($cats as $cat) { $val = (!is_null($zCats[$cat['slug']])) ? $zCats[$cat['slug']] : -1; array_push($sCats, array('name' => $cat['name'], 'slug' => $cat['slug'], 'val' => $val)); diff --git a/simple-ads-manager/zone.list.admin.class.php b/simple-ads-manager/zone.list.admin.class.php index 034dafd..a38e11f 100644 --- a/simple-ads-manager/zone.list.admin.class.php +++ b/simple-ads-manager/zone.list.admin.class.php @@ -34,8 +34,8 @@ function page() { elseif($iaction === 'kill') $wpdb->query("DELETE FROM $zTable WHERE id=$item"); } if($iaction === 'kill-em-all') $wpdb->query("DELETE FROM $zTable WHERE trash=true"); - $trash_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $zTable WHERE trash = TRUE")); - $active_num = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $zTable WHERE trash = FALSE")); + $trash_num = $wpdb->get_var("SELECT COUNT(*) FROM $zTable WHERE trash = TRUE"); + $active_num = $wpdb->get_var("SELECT COUNT(*) FROM $zTable WHERE trash = FALSE"); if(is_null($active_num)) $active_num = 0; if(is_null($trash_num)) $trash_num = 0; $all_num = $trash_num + $active_num; @@ -110,7 +110,7 @@ function page() { if(!is_array($zones) || empty ($zones)) { ?> - +