Skip to content

Commit

Permalink
Updating to 1.7.63
Browse files Browse the repository at this point in the history
  • Loading branch information
minimus committed Nov 2, 2013
1 parent 0613657 commit 0344881
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 59 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions simple-ads-manager/ad.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -724,6 +724,7 @@ private function buildBlock($args = null, $crawler = false) {
$lines = (integer) $block['b_lines'];
$cols = (integer) $block['b_cols'];
$blockDiv = "<div style='margin: ".$block['b_margin']."; padding: ".$block['b_padding']."; background: ".$block['b_background']."; border: ".$block['b_border']."'>";
$lineDiv = "<div style='margin: 0px; padding: 0px;'>";
$itemDiv = "<div style='display: inline-block; margin: ".$block['i_margin']."; padding: ".$block['i_padding']."; background: ".$block['i_background']."; border: ".$block['i_border']."'>";

for($i = 1; $i <= $lines; $i++) {
Expand Down Expand Up @@ -752,8 +753,9 @@ private function buildBlock($args = null, $crawler = false) {
}
if(!empty($iDiv)) $lDiv .= $itemDiv.$iDiv."</div>";
}
if(!empty($lDiv)) $output .= $blockDiv.$lDiv."</div>";
if(!empty($lDiv)) $output .= $lineDiv.$lDiv."</div>";
}
$output = $blockDiv.$output."</div>";
}
else $output = '';

Expand Down
8 changes: 5 additions & 3 deletions simple-ads-manager/admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
?>
<input id="<?php echo $id; ?>"
name="<?php echo SAM_OPTIONS_NAME.'['.$id.']'; ?>"
type="text"
value="<?php echo $settings[$id]; ?>"
style="height: 22px; font-size: 11px; <?php if(!empty($width)) echo 'width: '.$width.'px;' ?>" />
style="height: 22px; font-size: 11px; <?php echo "width: {$width}px;" ?>" />
<?php
}

Expand Down Expand Up @@ -828,6 +829,7 @@ public function samAdminPage() {
if(!empty($errors->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);
?>
Expand Down Expand Up @@ -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') {
Expand Down
4 changes: 2 additions & 2 deletions simple-ads-manager/block.list.admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions simple-ads-manager/errorlog.admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion simple-ads-manager/js/sam-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
data: {
action: "sam_click",
sam_ad_id: adId,
_ajax_nonce: samAjax._ajax_nonce
level: samAjax.level
},
async: true
});
Expand Down
12 changes: 7 additions & 5 deletions simple-ads-manager/js/sam-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
8 changes: 4 additions & 4 deletions simple-ads-manager/list.admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 20 additions & 4 deletions simple-ads-manager/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Contributors: minimus
Donate link: https://load.payoneer.com/[email protected]
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 ==

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
75 changes: 75 additions & 0 deletions simple-ads-manager/sam-ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* Author: minimus
* Date: 24.10.13
* Time: 12:14
*/

define('DOING_AJAX', true);

if (!isset( $_POST['action'])) die('-1');
if (isset( $_POST['level'] )) {
$rootLevel = intval($_POST['level']);
$root = dirname( __FILE__ );
for( $i = 0; $i < $rootLevel; $i++ ) $root = dirname( $root );
}
else $root = dirname(dirname(dirname(dirname(__FILE__))));

ini_set('html_errors', 0);

define('SHORTINIT', true);

require_once( $root . '/wp-load.php' );

global $wpdb;

$oTable = $wpdb->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'));
10 changes: 5 additions & 5 deletions simple-ads-manager/sam.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
Expand All @@ -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'));
Expand Down Expand Up @@ -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__ ) ))))
);
}

Expand Down
27 changes: 1 addition & 26 deletions simple-ads-manager/simple-ads-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="http://www.simplelib.com/">SimpleLib blog</a> for more details.
Version: 1.7.57
Version: 1.7.63
Author: minimus
Author URI: http://blogcoding.ru
*/
Expand Down Expand Up @@ -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;
}
}
?>
9 changes: 8 additions & 1 deletion simple-ads-manager/updater.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 0344881

Please sign in to comment.