Changeset 1878235
- Timestamp:
- 05/21/2018 07:04:00 AM (8 years ago)
- Location:
- prime-ads/trunk
- Files:
-
- 5 edited
-
inc/direct.php (modified) (1 diff)
-
inc/services/AdsHelper.php (modified) (5 diffs)
-
inc/services/Migration.php (modified) (2 diffs)
-
prime-ads.php (modified) (12 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
prime-ads/trunk/inc/direct.php
r1622865 r1878235 1 1 <?php 2 $config = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/wp-config.php');3 preg_match('#define\(.DB_HOST., .(.*).\)#iU', $config, $matches);4 $host = $matches[1];5 preg_match('#define\(.DB_USER., .(.*).\)#iU', $config, $matches);6 $user = $matches[1];7 preg_match('#define\(.DB_PASSWORD., .(.*).\)#iU', $config, $matches);8 $pass = $matches[1];9 preg_match('#define\(.DB_NAME., .(.*).\)#iU', $config, $matches);10 $db = $matches[1];11 preg_match('#table_prefix\s*=\s*[\'\"](.*)[\'\"];#iU', $config, $matches);12 $prefix = $matches[1];13 2 14 $mysqli = new mysqli($host, $user, $pass, $db); 15 if($mysqli->connect_error) die('db error'); 3 if($_POST['action'] == 'prma_counter_tick' || $_POST['action'] == 'prma_regclick'){ 4 $config = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/wp-config.php'); 5 preg_match('#define\(.DB_HOST., .(.*).\)#iU', $config, $matches); 6 $host = $matches[1]; 7 preg_match('#define\(.DB_USER., .(.*).\)#iU', $config, $matches); 8 $user = $matches[1]; 9 preg_match('#define\(.DB_PASSWORD., .(.*).\)#iU', $config, $matches); 10 $pass = $matches[1]; 11 preg_match('#define\(.DB_NAME., .(.*).\)#iU', $config, $matches); 12 $db = $matches[1]; 13 preg_match('#table_prefix\s*=\s*[\'\"](.*)[\'\"];#iU', $config, $matches); 14 $prefix = $matches[1]; 16 15 17 // Увеличиваем счётчики 18 if($_POST['action'] == 'prma_counter_tick'){ 19 if($_POST['type'] == 'post') 20 $mysqli->query("UPDATE " . $prefix . "options SET `option_value`=`option_value`+1 WHERE `option_name`='counter_total' OR `option_name`='counter_current'"); 16 $mysqli = new mysqli($host, $user, $pass, $db); 17 if($mysqli->connect_error) die('db error'); 21 18 22 $mysqli->query("UPDATE " . $prefix . "options SET `option_value`=`option_value`+1 WHERE `option_name`='counter_allpages_total' OR `option_name`='counter_allpages_current'"); 23 } 19 // Увеличиваем счётчики 20 if($_POST['action'] == 'prma_counter_tick'){ 21 if($_POST['type'] == 'post') 22 $mysqli->query("UPDATE " . $prefix . "options SET `option_value`=`option_value`+1 WHERE `option_name`='counter_total' OR `option_name`='counter_current'"); 24 23 25 // Регистрируем клики 26 if($_POST['action'] == 'prma_regclick'){ 27 $rel = explode('_', $_POST['rel']); 28 $field = 'clicks'; 29 switch ($rel[0]) { 30 case 'cb': 31 $table = 'ads_code_block'; 32 break; 33 case 'asb': 34 $table = 'ads_adsense_block'; 35 break; 36 case 'st': 37 $table = 'ads_simple_tizer_stat'; 38 $field = 'clicks_' . $rel[2]; 39 break; 24 $mysqli->query("UPDATE " . $prefix . "options SET `option_value`=`option_value`+1 WHERE `option_name`='counter_allpages_total' OR `option_name`='counter_allpages_current'"); 40 25 } 41 if($table){ 42 $id = $rel[1]; 43 if(strpos($id, '_')){ 44 $arr = explode('_', $id); 45 $id = $arr[0]; 26 27 // Регистрируем клики 28 if($_POST['action'] == 'prma_regclick'){ 29 $rel = explode('_', $_POST['rel']); 30 $field = 'clicks'; 31 switch ($rel[0]) { 32 case 'cb': 33 $table = 'ads_code_block'; 34 break; 35 case 'asb': 36 $table = 'ads_adsense_block'; 37 break; 38 case 'st': 39 $table = 'ads_simple_tizer_stat'; 40 $field = 'clicks_' . $rel[2]; 41 break; 46 42 } 47 $mysqli->query("UPDATE " . $prefix . $table . " SET `$field`=`$field`+1 WHERE id=" . $id); 43 if($table){ 44 $id = $rel[1]; 45 if(strpos($id, '_')){ 46 $arr = explode('_', $id); 47 $id = $arr[0]; 48 } 49 $mysqli->query("UPDATE " . $prefix . $table . " SET `$field`=`$field`+1 WHERE id=" . $id); 50 } 51 } 52 53 echo $mysqli->error; 54 echo 'ok'; 55 $mysqli->close(); 56 }else{ 57 require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); 58 global $primeAds; 59 60 define('DIRECT_AJAX', true); 61 62 if(isset($_POST['action']) && $_POST['action'] == 'prma_load_block'){ 63 $primeAds->loadBlock(); 64 } 65 if(isset($_POST['action']) && $_POST['action'] == 'prma_load_positions'){ 66 $primeAds->loadPositions(); 48 67 } 49 68 } 50 51 echo $mysqli->error;52 echo 'ok';53 $mysqli->close(); -
prime-ads/trunk/inc/services/AdsHelper.php
r1874627 r1878235 50 50 public $region; 51 51 public $city; 52 public $referrerDomain; 52 53 53 54 public $postSlug; … … 163 164 if($i > 0) $sql .= " UNION"; 164 165 165 $sql .= " SELECT id, tags, in_rubrics, ex_rubrics, in_posts, ex_posts, min_lenght, country, region, city, resolutions, devices,adblock_only, by_timetable, days_of_week, from_time, to_time, not_show, is_active, position, position_not_in_timetable, shows*shows_ratio as shows, '" . $this->_functions[$i] . "' as method, ((`from_time`<`to_time` AND `from_time`<=" . $hour . " AND `to_time`>" . $hour . ") OR (`from_time`>`to_time` AND ((`from_time`<=" . $hour . " AND " . $hour . "<=23) OR (`to_time`>" . $hour . " AND " . $hour . ">=0))) OR (`from_time`=`to_time`)) as time_exp FROM " . $wpdb->prefix . $this->_tables[$i];166 $sql .= " SELECT id, tags, in_rubrics, ex_rubrics, in_posts, ex_posts, in_referrers, ex_referrers, min_lenght, country, region, city, resolutions, devices,adblock_only, by_timetable, days_of_week, from_time, to_time, not_show, is_active, position, position_not_in_timetable, shows*shows_ratio as shows, '" . $this->_functions[$i] . "' as method, ((`from_time`<`to_time` AND `from_time`<=" . $hour . " AND `to_time`>" . $hour . ") OR (`from_time`>`to_time` AND ((`from_time`<=" . $hour . " AND " . $hour . "<=23) OR (`to_time`>" . $hour . " AND " . $hour . ">=0))) OR (`from_time`=`to_time`)) as time_exp FROM " . $wpdb->prefix . $this->_tables[$i]; 166 167 } 167 168 … … 198 199 if($this->postId) 199 200 $sql .= ' and (`in_posts`="" OR `in_posts` LIKE "%[' . $this->postId . ']%") and (`ex_posts`="" OR `ex_posts` NOT LIKE "%[' . $this->postId . ']%")'; 201 if($this->referrerDomain) 202 $sql .= ' and (`in_referrers`="" OR `in_referrers` LIKE "%[' . $this->referrerDomain . ']%") and (`ex_referrers`="" OR `ex_referrers` NOT LIKE "%[' . $this->referrerDomain . ']%")'; 200 203 if($this->postLength) 201 204 $sql .= ' and `min_lenght`<=' . $this->postLength; … … 227 230 $sql.= " by_timetable DESC, IF(tags !='',0,1),IF(in_rubrics !='',0,1),IF(in_posts !='',0,1),IF(country !='',0,1),IF(region !='',0,1),IF(city !='',0,1),shows limit 1"; 228 231 $itemProps = $wpdb->get_row($sql); 232 echo $wpdb->last_error; 229 233 if(!$itemProps) return ''; 230 234 … … 739 743 } 740 744 745 public function setReferrerDomain() 746 { 747 $referrer = $_SERVER['HTTP_REFERER']; 748 if($referrer){ 749 preg_match('#https*:\/.*[\.\/]([^\.]+\.[^\.]+)[\/$]#iU', $referrer, $referrerDomain); 750 if(isset($referrerDomain[1])) $this->referrerDomain = $referrerDomain[1]; 751 } 752 } 753 741 754 public function getPostAndCat() 742 755 { -
prime-ads/trunk/inc/services/Migration.php
r1874695 r1878235 2 2 3 3 namespace AdsNS\Services; 4 5 use AdsNs\PrimeAds; 4 6 5 7 class Migration{ … … 270 272 return '2.3.0'; 271 273 } 274 275 if($ver == '2.3.0'){ 276 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_adsense_block` ADD `in_referrers` TEXT NOT NULL AFTER `ex_posts`"); 277 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_adsense_block` ADD `ex_referrers` TEXT NOT NULL AFTER `in_referrers`"); 278 279 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_code_block` ADD `in_referrers` TEXT NOT NULL AFTER `ex_posts`"); 280 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_code_block` ADD `ex_referrers` TEXT NOT NULL AFTER `in_referrers`"); 281 282 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_comment` ADD `in_referrers` TEXT NOT NULL AFTER `ex_posts`"); 283 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_comment` ADD `ex_referrers` TEXT NOT NULL AFTER `in_referrers`"); 284 285 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_simple_tizer_group` ADD `in_referrers` TEXT NOT NULL AFTER `ex_posts`"); 286 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_simple_tizer_group` ADD `ex_referrers` TEXT NOT NULL AFTER `in_referrers`"); 287 288 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_text_block` ADD `in_referrers` TEXT NOT NULL AFTER `ex_posts`"); 289 $wpdb->query("ALTER TABLE `" . $wpdb->prefix . "ads_text_block` ADD `ex_referrers` TEXT NOT NULL AFTER `in_referrers`"); 290 291 PrimeAds::moveFolders(); 292 293 update_option('ads-db-verison', '2.3.3'); 294 return '2.3.3'; 295 } 272 296 } 273 297 } -
prime-ads/trunk/prime-ads.php
r1875228 r1878235 3 3 Plugin Name: Prime Ads 4 4 Description: Вывод рекламы с сервиса Prime Ads 5 Version: 2.3. 25 Version: 2.3.3 6 6 Author: Proffit 7 7 Author URI: http://proffit.guru/ … … 19 19 use AdsNS\SxGeo\SxGeo; 20 20 21 define('ADS_VERSION', '2.3. 2');22 define('ADS_DB_VERSION', '2.3. 0');21 define('ADS_VERSION', '2.3.3'); 22 define('ADS_DB_VERSION', '2.3.3'); 23 23 define('ADS_PATH', realpath(__DIR__)); 24 24 define('ADS_SERVICE_URL', get_option('ads-service-url', 'http://primeads.ru/')); … … 226 226 wp_enqueue_script('prma-iframetracker', $upload_dir['baseurl'] . '/' . $folder . '/jquery.iframetracker.js', array('jquery'), "1.1.0", true); 227 227 228 wp_localize_script('prma-functions', 'prma_ajax_object', array('ajax_url' => admin_url('admin-ajax.php'), 'prma_ajax_url' => $upload_dir['baseurl'] . '/' . $folder . '/direct.php')); 228 //wp_localize_script('prma-functions', 'prma_ajax_object', array('ajax_url' => admin_url('admin-ajax.php'), 'prma_ajax_url' => $upload_dir['baseurl'] . '/' . $folder . '/direct.php')); 229 230 wp_localize_script('prma-functions', 'prma_ajax_object', array('ajax_url' => $upload_dir['baseurl'] . '/' . $folder . '/direct.php', 'prma_ajax_url' => $upload_dir['baseurl'] . '/' . $folder . '/direct.php')); 229 231 230 232 wp_enqueue_style('prma-style', $upload_dir['baseurl'] . '/' . $folder . '/style.css', array(), "1.0.0", false); … … 276 278 public function loadPositions() 277 279 { 280 if(strpos($_SERVER['HTTP_REFERER'], 'iframe-toloka.com')){ 281 wp_die(); 282 } 278 283 $this->_adsHelper->setScreenWidth(intVal($_POST['width'])); 279 284 $this->_adsHelper->setDevice(); … … 281 286 $this->_adsHelper->screenWidthInPx = intVal($_POST['width']); 282 287 $this->_adsHelper->adblockDetected = intVal($_POST['adblockDetected']); 288 $this->_adsHelper->setReferrerDomain(); 283 289 echo json_encode($this->_adsHelper->generatePositionContentByPositionId($_POST['id'])); 284 290 $this->_adsHelper->screenWidth = false; 285 291 $this->_adsHelper->screenWidthInPx = false; 286 wp_die(); 292 293 if(!defined('DIRECT_AJAX')) wp_die(); 287 294 } 288 295 … … 292 299 public function loadBlock() 293 300 { 301 if(strpos($_SERVER['HTTP_REFERER'], 'iframe-toloka.com')){ 302 wp_die(); 303 } 294 304 if(intVal($_POST['id']) > 0){ 295 305 $this->_adsHelper->setScreenWidth(intVal($_POST['width'])); 296 306 $this->_adsHelper->setDevice(); 297 307 $this->_adsHelper->getPostAndCat(); 308 $this->_adsHelper->setReferrerDomain(); 298 309 echo json_encode( 299 310 array( … … 303 314 $this->_adsHelper->screenWidth = false; 304 315 } 305 wp_die(); 316 317 if(!defined('DIRECT_AJAX')) wp_die(); 306 318 } 307 319 … … 336 348 if($onoff_state == 'off') return $content; 337 349 if($post->post_type != 'post') return $content; 350 351 if(strpos($_SERVER['HTTP_REFERER'], 'iframe-toloka.com')) 352 return $content; 338 353 339 354 $this->_adsHelper->postId = get_the_ID(); … … 354 369 355 370 $this->_adsHelper->setDevice(); 371 $this->_adsHelper->setReferrerDomain(); 356 372 357 373 $this->_adsHelper->postLength = mb_strlen(strip_tags($content)); … … 420 436 if($onoff_state == 'off') return; 421 437 if($this->_adsHelper->notIncludeAds) return; 438 if(strpos($_SERVER['HTTP_REFERER'], 'iframe-toloka.com')) return; 422 439 423 440 if(isset($this->_adsHelper->positions[AdsHelper::POSITION_BEFORE_COMMENTS])) … … 480 497 if($onoff_state == 'off') return; 481 498 if($this->_adsHelper->notIncludeAds) return; 499 if(strpos($_SERVER['HTTP_REFERER'], 'iframe-toloka.com')) return; 482 500 483 501 //unset($_SESSION['ads.closed']); … … 639 657 add_action('plugins_loaded', function(){ 640 658 if(function_exists('rocket_clean_domain')) { 641 rocket_clean_domain(); 642 } 659 rocket_clean_domain(); 660 rocket_clean_minify(); 661 rocket_clean_cache_busting(); 662 663 $options = get_option( WP_ROCKET_SLUG ); 664 $options['minify_css_key'] = create_rocket_uniqid(); 665 $options['minify_js_key'] = create_rocket_uniqid(); 666 remove_all_filters( 'update_option_' . WP_ROCKET_SLUG ); 667 update_option( WP_ROCKET_SLUG, $options ); 668 669 rocket_dismiss_box( 'rocket_warning_plugin_modification' ); 670 } 643 671 }, 100); 644 672 delete_option('ads-flush-wp-rocket'); -
prime-ads/trunk/readme.txt
r1875228 r1878235 7 7 Requires at least: 4.0 8 8 Tested up to: 4.7 9 Stable tag: 2.3. 29 Stable tag: 2.3.3 10 10 11 11 Ответная часть сервиса монитизации Prime Ads (http://primeads.ru)
Note: See TracChangeset
for help on using the changeset viewer.