Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: WPlockz
- Plugin URI: http://WPlockz.com
- Description: WPlockz
- Version: 1.2
- Author: WPLockz
- Author URI: http://wplockz.com
- */
- if ( version_compare ( PHP_VERSION, '5.0.0', '<' ) ) {
- die('WPlockz requires at least PHP 5.0.0 to function properly, you appear to have PHP '.PHP_VERSION.'. Please contact your host about upgrading.');
- }
- function wp_wplockz_credit_insert() {
- echo '<div id="akismet-credit-insert" style="text-align: center; clear: both;"><p>Content Protection powered by <a href="http://WPLockz.com">WPLockz</a></p></div>';
- }
- add_action('wp_footer', 'wp_wplockz_credit_insert'); /* automatically insert the text in the footer of every blog */
- $__wplockz = new wplockz();
- /* error_reporting(E_ALL); */
- add_action('admin_menu', array($__wplockz,'menu'));
- add_action('wp_head', array($__wplockz,'should_lock'));
- add_action('wp_head',array($__wplockz,'has_more'));
- register_activation_hook( __FILE__,array($__wplockz,'install_wplockz'));
- register_deactivation_hook( __FILE__,array($__wplockz,'uninstall_wplockz'));
- final class wplockz {
- private $db = null;
- private $wplockz_main_table = null;
- private $wplockz_post_table = null;
- private $wplockz_directory = null;
- public function __construct ( ) {
- $this->db = $GLOBALS['wpdb'];
- $this->wplockz_main_table = "`".$this->db->prefix. "wplockz`";
- $this->wplockz_post_table = "`".$this->db->prefix. "wplockz_posts`";
- $this->wplockz_geo_table = "`".$this->db->prefix. "wplockz_geo`";
- $this->wplockz_directory = $this->get_option('directory');
- wp_enqueue_script('jquery');
- wp_enqueue_script('jquery-cookies', $this->wplockz_directory.'js/jquery.cookies.2.1.0.min.js', array('jquery'), '2.1.0');
- wp_enqueue_script('jqModal', $this->wplockz_directory.'js/jqModal.js', array('jquery'), 'r14');
- wp_enqueue_style('jqModal',$this->wplockz_directory.'css/jqModal.css');
- if(is_admin()){
- wp_enqueue_script('jquery-ui-core');
- wp_enqueue_script('jquery-slider', $this->wplockz_directory.'js/ui.slider.js', array('jquery', 'jquery-ui-core'), '1.7.2');
- wp_enqueue_script('jquery-farbtastic', $this->wplockz_directory.'js/farbtastic/farbtastic.js', array('jquery'), '1.2');
- wp_enqueue_script('jquery-iphone', $this->wplockz_directory.'js/iphone-style-checkboxes.js', array('jquery'),'1.0');
- wp_enqueue_script('jquery-asmselect', $this->wplockz_directory.'js/jquery.asmselect.js', array('jquery'),'1.0');
- wp_enqueue_script('jqModal', $this->wplockz_directory.'js/jqModal.js', array('jquery'), 'r14');
- wp_enqueue_style('jquery-iphone',$this->wplockz_directory.'css/iphone-style-checkboxes.css');
- wp_enqueue_style('farbtastic',$this->wplockz_directory.'css/farbtastic/farbtastic.css');
- wp_enqueue_style('slider',$this->wplockz_directory.'css/ui.slider.css');
- wp_enqueue_style('jquery-asmselect',$this->wplockz_directory.'css/jquery.asmselect.css');
- wp_enqueue_style('jqModal',$this->wplockz_directory.'css/jqModal.css');
- }
- if (ob_get_level() == 0) {
- ob_start();
- }
- }
- function install_wplockz() {
- global $wpdb;
- $this->db->query("CREATE TABLE ".$this->wplockz_main_table." (
- `id` INT( 11 ) NOT NULL AUTO_INCREMENT,
- `ad_enabled` TINYINT( 1 ) NOT NULL,
- `ad_name` CHAR( 200 ) NOT NULL,
- `ad_title` CHAR( 200 ) NOT NULL,
- `ad_p1` MEDIUMTEXT NOT NULL,
- `ad_p2` MEDIUMTEXT NOT NULL,
- `ad_footer` MEDIUMTEXT NOT NULL,
- `ad_anchor` CHAR( 200 ) NOT NULL,
- `ad_anchor1` CHAR( 200 ) NOT NULL,
- `ad_anchor2` CHAR( 200 ) NOT NULL,
- `ad_anchor3` CHAR( 200 ) NOT NULL,
- `ad_url` CHAR( 200 ) NOT NULL,
- `ad_url1` CHAR( 200 ) NOT NULL,
- `ad_url2` CHAR( 200 ) NOT NULL,
- `ad_url3` CHAR( 200 ) NOT NULL,
- `ad_anchor1_status` TINYINT( 1 ) NOT NULL,
- `ad_anchor2_status` TINYINT( 1 ) NOT NULL,
- `ad_anchor3_status` TINYINT( 1 ) NOT NULL,
- `ad_color` VARCHAR( 11 ) NOT NULL,
- `ad_color2` VARCHAR( 11 ) NOT NULL,
- `ad_opacity` VARCHAR( 11 ) NOT NULL,
- `ad_block_delay` VARCHAR( 11 ) NOT NULL,
- `ad_rc_lock` TINYINT( 1 ) NOT NULL,
- `ad_scroll_lock` TINYINT( 1 ) NOT NULL,
- `ad_vposition` VARCHAR( 10 ) NOT NULL,
- `ad_unlock_delay` INT( 11 ) NOT NULL,
- `ad_unlock_for` INT( 11 ) NOT NULL,
- PRIMARY KEY ( `id` )
- ) ENGINE = MYISAM PACK_KEYS=1 CHECKSUM=1 CHARACTER SET utf8 COLLATE utf8_bin");
- $this->db->query("CREATE TABLE ".$this->wplockz_post_table." (
- `post_id` INT(11) NOT NULL,
- `ad_id` INT(11) NOT NULL
- ) ENGINE = MYISAM PACK_KEYS=1 CHECKSUM=1 CHARACTER SET utf8 COLLATE utf8_bin");
- $this->db->query("CREATE TABLE ".$this->wplockz_geo_table." (
- `ad_id` INT(11) NOT NULL,
- `cc` VARCHAR(11) NOT NULL
- ) ENGINE = MYISAM PACK_KEYS=1 CHECKSUM=1 CHARACTER SET utf8 COLLATE utf8_bin");
- $this->update_option('directory', WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)));
- $this->update_option('enabled',true);
- $this->update_option('installed',true);
- $this->update_option('block_index', false);
- $this->update_option('block_category', false);
- $this->update_option('block_page', false);
- $this->update_option('block_archive', false);
- $this->update_option('block_search', false);
- $default["ad_enabled"] = '1';
- $default["ad_name"] = '"Default"';
- $default['ad_title'] = '"This Content Is Protected!"';
- $default['ad_p1'] = '"To protect our site from internet bots and spam, we\'ve enabled a post protection system. We apologize for the inconvenience."';
- $default['ad_p2'] = '"To Unlock and Access the Content, Please complete a FREE offer Below. Please Click on any one offer below. Verify any email that is sent to you after the offer has been completed. The protected content will be revealed after our system verifies Completion."';
- $default['ad_footer'] = '"PLEASE CHOOSE BELOW"';
- $default['ad_anchor'] = '"Click Here to Unlock !"';
- $default['ad_url'] = '"http://www.your-test-url.com/"';
- $default['ad_anchor1'] = '"United States and Canada Click Here!"';
- $default['ad_url1'] = '"http://www.USandCanada-test-url.com/"';
- $default["ad_anchor1_status"] = '0';
- $default["ad_anchor2_status"] = '0';
- $default["ad_anchor3_status"] = '0';
- $default['ad_anchor2'] = '"United Kingdom Users Click Here!"';
- $default['ad_url2'] = '"http://www.UK-test-url.com/"';
- $default['ad_anchor3'] = '"International Users Click Here"';
- $default['ad_url3'] = '"http://www.International-test-url.com/"';
- $default["ad_color"] = '"#ccff66"';
- $default["ad_opacity"] = '.80';
- $default["ad_color2"] = '"#ffffcc"';
- $default["ad_block_delay"] = '0';
- $default["ad_rc_lock"] = '0';
- $default["ad_scroll_lock"] = '0';
- $default["ad_vposition"] = '"10%"';
- $default["ad_unlock_delay"] = '6000';
- $default["ad_unlock_for"] = '1';
- $this->db->query('INSERT INTO '.$this->wplockz_main_table.' ('.implode(",",array_keys($default)).") VALUES (".implode(",",array_values($default)).")");
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table. ' (`ad_id`,`cc`) VALUES (1,"all")');
- wp_register_script('jquery-slider', $this->wplockz_directory.'js/ui.slider.js', array('jquery'), '1.7.2');
- wp_register_script('jqModal', $this->wplockz_directory.'js/jqModal.js', array('jquery'), 'r14');
- wp_register_script('jquery-farbtastic', $this->wplockz_directory.'js/farbtastic/farbtastic.js', array('jquery', 'jquery-ui-core'), '1.2');
- wp_register_script('jquery-iphone', $this->wplockz_directory.'js/iphone-style-checkboxes.js', array('jquery'),'1.0');
- wp_register_script('jquery-cookies', $this->wplockz_directory.'js/jquery.cookies.2.1.0.min.js', array('jquery'), '2.1.0');
- wp_register_style('jquery-iphone',$this->wplockz_directory.'css/iphone-style-checkboxes.css');
- wp_register_style('farbtastic',$this->wplockz_directory.'css/farbtastic/farbtastic.css');
- wp_register_style('slider',$this->wplockz_directory.'css/ui.slider.css');
- wp_register_style('jqModal',$this->wplockz_directory.'css/jqModal.css');
- }
- function uninstall_wplockz() {
- $this->db->query('DROP TABLE '.$this->wplockz_main_table);
- $this->db->query('DROP TABLE '.$this->wplockz_post_table);
- $this->db->query('DROP TABLE '.$this->wplockz_geo_table);
- $this->db->query("DELETE FROM " .$this->db->prefix."options where `option_name` LIKE '%wplockz_%'");
- }
- private function update_option($name,$value) {
- return update_option('wplockz_'.$name,$value);
- }
- private function get_option($name) {
- return get_option('wplockz_'.$name);
- }
- private function add_ad($data) {
- $this->db->query('INSERT INTO '.$this->wplockz_main_table.' ('.implode(",",array_keys($data)).") VALUES (".implode(",",array_values($data)).")");
- }
- private function update_ad($ad_id,$data) {
- $data['id'] = (int) $ad_id;
- $sql = '';
- foreach ( $data as $key=>$val ) {
- $sql .= '`'.$key."`='".$this->db->escape($val)."', ";
- }
- $this->db->query('REPLACE INTO '.$this->wplockz_main_table.' SET '.substr($sql, 0, -2));
- }
- private function delete_ad($ad_id) {
- $this->db->query('DELETE FROM '.$this->wplockz_main_table.' WHERE id='.(int)$ad_id);
- }
- private function get_cookie() {
- if(isset ( $_COOKIE['cbwpg'])){
- return true;
- } else {
- return false;
- }
- }
- private function geo_lookup ( $ip ) {
- // use the native pecl geoip module when available
- if ( function_exists ( 'geoip_country_code_by_name') && geoip_db_avail(GEOIP_COUNTRY_EDITION) ) {
- $country = geoip_country_code_by_name($ip);
- if ( ! $country ) {
- $country = 'ZZ';
- }
- } else {
- // fallback to pear geoip module
- // check no other plugins have it already included first
- if ( ! class_exists ( 'Net_GeoIP' ) ) {
- // use from the system pear install if it exists there
- // fallback to our own copy
- include ( $this->findFile ( 'includes'.DIRECTORY_SEPARATOR.'GeoIP.php' ) );
- }
- $geoip = Net_GeoIP::getInstance ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . "GeoIP.dat" );
- try {
- $country = $geoip->lookupCountryCode($ip);
- } catch ( Exception $e ) {
- $country = 'ZZ';
- }
- }
- // will return ZZ on failure to lookup
- return $country;
- }
- private function geo_list(){
- include ($this->findFile ( 'includes'.DIRECTORY_SEPARATOR.'GeoIP.php'));
- $country_codes = Net_GeoIP::$COUNTRY_CODES;
- $country_names = Net_GeoIP::$COUNTRY_NAMES;
- $index = 0;
- foreach($country_codes as $country){
- $country_array[$country] = $country_names[$index];
- $index++;
- }
- return $country_array;
- }
- private function findFile ( $file ) {
- $include_path = get_include_path();
- foreach ( explode ( PATH_SEPARATOR, $include_path ) as $path ) {
- // we are trying to find a system version first
- if ( $path == '.' ) {
- continue;
- }
- if ( file_exists ( $path . DIRECTORY_SEPARATOR . $file ) ) {
- return $path . DIRECTORY_SEPARATOR . $file;
- }
- }
- if ( file_exists ( $file ) ) {
- return realpath($file);
- }
- if ( file_exists ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . $file ) ) {
- return dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . $file;
- }
- return null;
- }
- public function menu () {
- add_menu_page('WPlockz Global Options', 'WPlockz', 8, basename(__FILE__), array($this,'menu_global_options'));
- add_submenu_page(basename(__FILE__), 'WPlockz Protection Manager', 'ProtectionManager', 8, 'ProtectionManager', array($this,'menu_ad_manager'));
- add_submenu_page(basename(__FILE__), 'WPlockz Post Manager', 'PostManager', 8, 'PostManager', array($this,'menu_post_manager'));
- }
- public function menu_global_options() {
- global $wpdb;
- global $posts;
- if (isset($_POST['wplockz_save_settings'])) {
- if($_POST['enabled'] == 'on') { $this->update_option('enabled','1'); } else { $this->update_option('enabled','0'); }
- if($_POST['block_index'] == 'on') { $this->update_option('block_index','1'); } else { $this->update_option('block_index','0'); }
- if($_POST['block_category'] == 'on') { $this->update_option('block_category','1'); } else { $this->update_option('block_category','0'); }
- if($_POST['block_archive'] == 'on') { $this->update_option('block_archive','1'); } else { $this->update_option('block_archive','0'); }
- if($_POST['block_page'] == 'on') { $this->update_option('block_page','1'); } else { $this->update_option('block_page','0'); }
- if($_POST['block_search'] == 'on') { $this->update_option('block_search','1'); } else { $this->update_option('block_search','0'); }
- echo '<script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery(".fade").fadeIn("fast");
- jQuery(".fade").fadeOut(5000);
- })
- </script>';
- echo '';
- }
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery(':checkbox').iphoneStyle();
- });
- </script>
- <div class="wrap">
- <div id="icon-options-general" class="icon32"><br /></div>
- <h2>WPlockz Options</h2>
- <h3>Global Options</h3>
- <p>These options are only applied to global lockz. They do not apply to individual post lockz.</p>
- <form action="" method="post">
- <input type="hidden" name="wplockz_save_settings" value="true" />
- <table class="form-table" style="width:825px;align:center;">
- <tr valign="top">
- <th scope="col">
- <label for="enabled" style="font-weight:bold"><?php _e("Lockz Status","mt_trans_domain") ?></label>
- </th>
- <th scope="col">
- <label for="block_index" style="font-weight:bold"><?php _e("Lockz Index","mt_trans_domain") ?></label>
- </th>
- <th scope="col">
- <label for="block_page" style="font-weight:bold"><?php _e("Lockz Pages","mt_trans_domain") ?></label>
- </th>
- <th scope="col">
- <label for="block_category" style="font-weight:bold"><?php _e("Lockz Category","mt_trans_domain") ?></label>
- </th>
- <th scope="col">
- <label for="block_archive" style="font-weight:bold"><?php _e("Lockz Archives","mt_trans_domain") ?></label>
- </th>
- <th scope="col">
- <label for="block_search" style="font-weight:bold"><?php _e("Lockz Search","mt_trans_domain") ?></label>
- </th>
- </tr>
- <tr valign="top">
- <td>
- <input type="checkbox" class="enabled" name="enabled" <?php if($this->get_option('enabled') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- <td>
- <input type="checkbox" class="block_index" name="block_index" <?php if($this->get_option('block_index') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- <td>
- <input type="checkbox" class="block_page" name="block_page" <?php if($this->get_option('block_page') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- <td>
- <input type="checkbox" class="block_category" name="block_category" <?php if($this->get_option('block_category') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- <td>
- <input type="checkbox" class="block_archive" name="block_archive" <?php if($this->get_option('block_archive') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- <td>
- <input type="checkbox" class="block_search" name="block_search" <?php if($this->get_option('block_search') == true ) { echo 'checked="checked"'; } ?> />
- </td>
- </tr>
- </table>
- <table class="form-table" style="align:center;">
- <tr>
- <td>
- <input type="submit" name="Submit" style="float:left;" class="button-primary" value="<?php _e('Update WPLockz Global Options', 'mt_trans_domain' ) ?>" />
- <div id="message" style="float:left;margin-left:10px;display:none;" class="fade">Options saved.</div>
- </td>
- </tr>
- </table>
- </form>
- </div>
- <p> </p>
- <table width="600" border="3" cellpadding="10" cellspacing="10" bordercolor="#0000FF">
- <tr>
- <th align="left" scope="row">Lockz Status</th>
- <td bordercolor="#0000FF"><font size="-1">This is the Status of the Plugin (default is <strong><font color="#33FF00">ON</strong></font> )</td>
- </tr>
- <tr>
- <th align="left" scope="row">Lockz Index</th>
- <td bordercolor="#0000FF"><font size="-1">This will lock your Main Page (default is <strong><font color="#FF0000">OFF )</strong></font></td>
- </tr>
- <tr>
- <th align="left" scope="row">Lockz Pages</th>
- <td bordercolor="#0000FF"><font size="-1">This will lock All your Pages (default is <strong><font color="#FF0000">OFF </strong></font>)</td>
- </tr>
- <tr>
- <th align="left" scope="row">Lockz Category</th>
- <td bordercolor="#0000FF"><font size="-1">This will lock your Categories (default is <strong><font color="#FF0000">OFF</strong></font> )</td>
- </tr>
- <tr>
- <th align="left" scope="row">Lockz Archives</th>
- <td bordercolor="#0000FF"><font size="-1">This will lock your Archives (default is <strong><font color="#FF0000">OFF </strong></font>)</td>
- </tr>
- <tr>
- <th align="left" scope="row">Lockz Search</th>
- <td bordercolor="#0000FF"><font size="-1">This will lock your Blogs Search Function (default is <strong><font color="#FF0000">OFF </strong></font>)</td>
- </tr>
- </table>
- <?php
- }
- public function menu_ad_manager() {
- global $wpdb, $posts;
- if(isset($_POST['ad_select']) && $_POST['ad_select'] != 'new' ) {
- $ad_id = $_POST['ad_select'];
- } elseif(isset($_POST['ad_id'])) {
- $ad_id = $_POST['ad_id'];
- } else {
- $ad_id = '1';
- }
- if (isset($_POST['wplockz_save_settings']) && $_POST['wplockz_save_settings'] == 'true' && $_POST['ad_id'] != 'new' ) {
- if($_POST['ad_enabled'] == 'on') {
- $update_ad['ad_enabled'] = 1;
- } else {
- $update_ad['ad_enabled'] = 0;
- }
- if($_POST['ad_rc_lock'] == 'on') {
- $update_ad["ad_rc_lock"] = 1;
- } else {
- $update_ad["ad_rc_lock"] = 0;
- }
- if($_POST['ad_scroll_lock'] == 'on') {
- $update_ad["ad_scroll_lock"] = 1;
- } else {
- $update_ad["ad_scroll_lock"] = 0;
- }
- if($_POST['ad_anchor1_status'] == 'on') {
- $update_ad["ad_anchor1_status"] = 1;
- } else {
- $update_ad["ad_anchor1_status"] = 0;
- }
- if($_POST['ad_anchor2_status'] == 'on') {
- $update_ad["ad_anchor2_status"] = 1;
- } else {
- $update_ad["ad_anchor2_status"] = 0;
- }
- if($_POST['ad_anchor3_status'] == 'on') {
- $update_ad["ad_anchor3_status"] = 1;
- } else {
- $update_ad["ad_anchor3_status"] = 0;
- }
- $update_ad['ad_name'] = stripslashes($_POST['ad_name']);
- $update_ad['ad_title'] = stripslashes($_POST['ad_title']);
- $update_ad['ad_p1'] = stripslashes(htmlspecialchars($_POST['ad_p1']));
- $update_ad['ad_p2'] = stripslashes(htmlspecialchars($_POST['ad_p2']));
- $update_ad['ad_footer'] = stripslashes(htmlspecialchars($_POST['ad_footer']));
- $update_ad['ad_anchor'] = stripslashes($_POST['ad_anchor']);
- $update_ad['ad_url'] = stripslashes($_POST['ad_url']);
- $update_ad['ad_anchor1'] = stripslashes($_POST['ad_anchor1']);
- $update_ad['ad_url1'] = stripslashes($_POST['ad_url1']);
- $update_ad['ad_anchor2'] = stripslashes($_POST['ad_anchor2']);
- $update_ad['ad_url2'] = stripslashes($_POST['ad_url2']);
- $update_ad['ad_anchor3'] = stripslashes($_POST['ad_anchor3']);
- $update_ad['ad_url3'] = stripslashes($_POST['ad_url3']);
- $update_ad['ad_color'] = stripslashes($_POST['ad_color']);
- $update_ad['ad_color2'] = stripslashes($_POST['ad_color2']);
- $update_ad['ad_opacity'] = (intval($_POST['ad_opacity'])/100);
- $update_ad['ad_block_delay'] = (intval($_POST['ad_block_delay'])*1000);
- $update_ad["ad_vposition"] = intval($_POST['ad_vposition_number']).$_POST['ad_vposition_unit'];
- $update_ad["ad_unlock_delay"] = (intval($_POST['ad_unlock_delay'])*1000);
- $update_ad["ad_unlock_for"] = intval($_POST['ad_unlock_for']);
- $ad_id = $_POST['ad_id'];
- $ad_geo = $_POST['ad_geo'];
- $this->db->query("DELETE FROM " .$this->wplockz_geo_table. " where `ad_id` = '$ad_id'");
- if(empty($ad_geo)) {
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.' (`ad_id`,`cc`) VALUES ("'.$ad_id.'","all")');
- } else {
- if(!in_array('all',$ad_geo)){
- foreach($ad_geo as $geo_cc){
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.'(`ad_id`,`cc`) VALUES ("'.$ad_id.'","'.$geo_cc.'")');
- }
- } else {
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.' (`ad_id`,`cc`) VALUES ("'.$ad_id.'","all")');
- }
- }
- $this->update_ad($ad_id,$update_ad);
- }
- if (isset($_POST['wplockz_save_settings']) && $_POST['wplockz_save_settings'] == 'true' && $_POST['ad_id'] == 'new' ) {
- if(!empty($_POST['ad_name'])) {
- $add_ad['ad_name'] = '"'. stripslashes($_POST['ad_name']). '"';
- } else {
- $add_ad['ad_name'] = '"Unnamed #'. mt_rand(0,100). '"';
- }
- if($_POST['ad_enabled'] == 'on') {
- $add_ad['ad_enabled'] = 1;
- } else {
- $add_ad['ad_enabled'] = 0;
- }
- if($_POST['ad_rc_lock'] == 'on') {
- $add_ad["ad_rc_lock"] = 1;
- } else {
- $add_ad["ad_rc_lock"] = 0;
- }
- if($_POST['ad_scroll_lock'] == 'on') {
- $add_ad["ad_scroll_lock"] = 1;
- } else {
- $add_ad["ad_scroll_lock"] = 0;
- }
- if($_POST['ad_anchor1_status'] == 'on') {
- $add_ad["ad_anchor1_status"] = 1;
- } else {
- $add_ad["ad_anchor1_status"] = 0;
- }
- if($_POST['ad_anchor2_status'] == 'on') {
- $add_ad["ad_anchor2_status"] = 1;
- } else {
- $add_ad["ad_anchor2_status"] = 0;
- }
- if($_POST['ad_anchor3_status'] == 'on') {
- $add_ad["ad_anchor3_status"] = 1;
- } else {
- $add_ad["ad_anchor3_status"] = 0;
- }
- $add_ad['ad_title'] = '"' .stripslashes($_POST['ad_title']). '"';
- $add_ad['ad_p1'] = '"' .stripslashes(htmlspecialchars($_POST['ad_p1'])). '"';
- $add_ad['ad_p2'] = '"' .stripslashes(htmlspecialchars($_POST['ad_p2'])). '"';
- $add_ad['ad_footer'] = '"' .stripslashes(htmlspecialchars($_POST['ad_footer'])). '"';
- $add_ad['ad_anchor'] = '"' .stripslashes($_POST['ad_anchor']). '"';
- $add_ad['ad_url'] = '"' .stripslashes($_POST['ad_url']). '"';
- $add_ad['ad_anchor1'] = '"' .stripslashes($_POST['ad_anchor1']). '"';
- $add_ad['ad_url1'] = '"' .stripslashes($_POST['ad_url1']). '"';
- $add_ad['ad_anchor2'] = '"' .stripslashes($_POST['ad_anchor2']). '"';
- $add_ad['ad_url2'] = '"' .stripslashes($_POST['ad_url2']). '"';
- $add_ad['ad_anchor3'] = '"' .stripslashes($_POST['ad_anchor3']). '"';
- $add_ad['ad_url3'] = '"' .stripslashes($_POST['ad_url3']). '"';
- $add_ad['ad_color'] = '"' .stripslashes($_POST['ad_color']). '"';
- $add_ad['ad_color2'] = '"' .stripslashes($_POST['ad_color2']). '"';
- $add_ad['ad_opacity'] = (intval($_POST['ad_opacity'])/100);
- $add_ad['ad_block_delay'] = (intval($_POST['ad_block_delay'])*1000);
- $add_ad["ad_vposition"] = "'". intval($_POST['ad_vposition_number']).$_POST['ad_vposition_unit']. "'";
- $add_ad["ad_unlock_delay"] = (intval($_POST['ad_unlock_delay'])*1000);
- $add_ad["ad_unlock_for"] = intval($_POST['ad_unlock_for']);
- $this->add_ad($add_ad);
- $ad_id = mysql_insert_id();
- $ad_geo = $_POST['ad_geo'];
- $this->db->query("DELETE FROM " .$this->wplockz_geo_table. " where `ad_id` = '$ad_id'");
- if(empty($ad_geo)) {
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.' (`ad_id`,`cc`) VALUES ("'.$ad_id.'","all")');
- } else {
- if(!in_array('all',$ad_geo)){
- foreach($ad_geo as $geo_cc){
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.'(`ad_id`,`cc`) VALUES ("'.$ad_id.'","'.$geo_cc.'")');
- }
- } else {
- $this->db->query('INSERT INTO '.$this->wplockz_geo_table.' (`ad_id`,`cc`) VALUES ("'.$ad_id.'","all")');
- }
- }
- }
- if (isset($_POST['wplockz_save_settings']) && $_POST['wplockz_save_settings'] == 'delete' ) {
- $this->delete_ad($_POST['ad_id']);
- $ad_id = '1';
- }
- $ads = $this->db->get_results("SELECT * FROM $this->wplockz_main_table WHERE `id`=$ad_id");
- $current_geo_list = $this->db->get_results("SELECT `cc` FROM $this->wplockz_geo_table WHERE `ad_id`=$ad_id");
- if(isset($_POST)){
- if($_POST['ad_select'] == 'new') {
- $ad_id = 'new';
- unset($curent_geo_list);
- }
- }
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery("select[multiple]").asmSelect({
- addItemTarget: 'bottom',
- animate: true,
- highlight: true,
- sortable: false
- });
- jQuery(':checkbox').iphoneStyle();
- jQuery('#colorpicker').farbtastic('#ad_color');
- jQuery('#colorpicker2').farbtastic('#ad_color2');
- jQuery("#ad_opacity_slider").slider({
- min: 0,
- max: 100,
- value: <?php echo ($ads[0]->ad_opacity*100); ?>,
- slide: function(event, ui) {
- jQuery("#ad_opacity").val(ui.value + '%');
- }
- });
- jQuery("#ad_opacity").val(jQuery("#ad_opacity_slider").slider("value") + '%');
- jQuery("#ad_block_delay_slider").slider({
- min: 0,
- max: 600,
- value: <?php echo ($ads[0]->ad_block_delay/1000); ?>,
- slide: function(event, ui) {
- jQuery("#ad_block_delay").val(ui.value + ' s');
- }
- });
- jQuery("#ad_block_delay").val(jQuery("#ad_block_delay_slider").slider("value") + ' s');
- jQuery("#ad_unlock_delay_slider").slider({
- min: 0,
- max: 3600,
- value: <?php echo ($ads[0]->ad_unlock_delay/1000); ?>,
- slide: function(event, ui) {
- jQuery("#ad_unlock_delay").val(ui.value + ' s');
- }
- });
- jQuery("#ad_unlock_delay").val(jQuery("#ad_unlock_delay_slider").slider("value") + ' s');
- jQuery("#ad_unlock_for_slider").slider({
- min: 0,
- max: 600,
- value: <?php echo $ads[0]->ad_unlock_for; ?>,
- slide: function(event, ui) {
- jQuery("#ad_unlock_for").val(ui.value + ' hrs');
- }
- });
- jQuery("#ad_unlock_for").val(jQuery("#ad_unlock_for_slider").slider("value") + ' hrs');
- jQuery('#delete').click(function() {
- jQuery("#wplockz_save_settings").val('delete');
- });
- jQuery("a.showColor").click(function() {
- jQuery("#colorpicker").slideToggle("normal");
- jQuery("span.showHide").toggle();
- return false;
- });
- jQuery("a.showColor2").click(function() {
- jQuery("#colorpicker2").slideToggle("normal");
- jQuery("span.showHide2").toggle();
- return false;
- });
- });
- </script>
- <div class="wrap">
- <div id="icon-options-general" class="icon32"><br /></div>
- <h2>WPlockz Content Protection Manager</h2>
- <form action="" method="post">
- <input type="hidden" name="wplockz_save_settings" value="select" />
- <table class="form-table">
- <tr valign="top">
- <th scope="row"><label for="ad_select" style="float:left;width:200px;font-weight:bold"><?php _e("Select Content Protector: ", "mt_trans_domain") ?></label></th>
- <td>
- <select name="ad_select" id="ad_select">
- <?php
- $ad_list = $this->db->get_results("SELECT `id`,`ad_name` FROM $this->wplockz_main_table");
- foreach($ad_list as $ad ){
- echo '<option value="'.$ad->id.'"';
- if($ad->id == $ad_id){ echo ' selected=SELECTED'; };
- echo '>'.$ad->ad_name.'</option>';
- }
- echo '<option value="new"';
- if($ad_id == 'new') { echo 'selected=SELECTED'; };
- echo '>Create New</option>';
- ?>
- </select>
- <input type="submit" name="Select" style="margin-left:10px" class="button-primary" value="<?php _e('Select Lockz Protector', 'mt_trans_domain' ) ?>" />
- </td>
- </tr>
- </table>
- </form>
- <hr>
- <form action="" method="post">
- <table class="form-table">
- <input type="hidden" name="wplockz_save_settings" id="wplockz_save_settings" class="wplockz_save_settings" value="true" />
- <input type="hidden" name="ad_id" id="ad_id" class="ad_id" value="<?php echo $ad_id; ?>">
- <tr valign="top">
- <th scope="row"><label for="ad_name" style="float:left;width:120px;font-weight:bold"><?php _e("Protector Name: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:200px" id="ad_name" name="ad_name" value="<?php if($ad_id != 'new') { echo $ads[0]->ad_name; } ?>"<?php if($ad_id == '1'){ echo ' disabled="disabled"';} ?>>
- <?php if($ad_id == '1'){ echo '<input type="hidden" name="ad_name" value="Default">'; } ?>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_geo" style="font-weight:bold"><?php _e("Block Certain Location: ","mt_trans_domain") ?></label></th>
- <td>
- <?php
- if(!empty($current_geo_list)){
- foreach($current_geo_list as $geo) {
- $geo_listing[] = $geo->cc;
- }
- } else {
- $geo_listing[] = 'all';
- }
- ?>
- <select id="ad_geo" name="ad_geo[]" multiple="multiple" title="Click to Select a Country">
- <option value="all" <?php if(in_array('all',$geo_listing)){ echo ' selected="selected"';} ?>>All</option>
- <?php
- $country_array = $this->geo_list();
- array_shift($country_array);
- foreach($country_array as $country_code => $country_name){
- echo '<option value="'.$country_code.'"';
- if(in_array($country_code, $geo_listing)) {echo ' selected="selected"'; }
- echo '>'.$country_name.'</option>';
- }
- ?>
- </select>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_enabled" style="font-weight:bold"><?php _e("Protector Enabled: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_enabled" name="ad_enabled" <?php if($ads[0]->ad_enabled == true ) { echo 'checked="checked"'; } ?>>
- This will enable the Content protector</td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_rc_lock" style="font-weight:bold"><?php _e("Lockz Right Click: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_rc_lock" name="ad_rc_lock" <?php if($ads[0]->ad_rc_lock == true ) { echo 'checked="checked"'; } ?>>
- This will disable the visitors browser right click function</td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_scroll_lock" style="font-weight:bold"><?php _e("Lockz Scrolling: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_scroll_lock" name="ad_scroll_lock" <?php if($ads[0]->ad_scroll_lock == true ) { echo 'checked="checked"'; } ?>>
- This will disable the visitors browser scrolling function</td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_title" style="float:left;width:120px;font-weight:bold"><?php _e("WPLockz Title: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:200px" id="ad_title" name="ad_title" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_title)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_p1" style="float:left;width:120px;font-weight:bold"><?php _e("WPlockz First Paragraph: ","mt_trans_domain") ?></label></th>
- <td colspan="2">
- <textarea rows="4" cols="55" id="ad_p1" name="ad_p1"><?php echo htmlspecialchars_decode(($ads[0]->ad_p1)); ?></textarea>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_p2" style="float:left;width:130px;font-weight:bold"><?php _e("WPlockz Visitor Instructions: ","mt_trans_domain") ?></label></th>
- <td colspan="2">
- <textarea rows="4" cols="55" id="ad_p2" name="ad_p2"><?php echo htmlspecialchars_decode(($ads[0]->ad_p2)); ?></textarea>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_footer" style="float:left;width:130px;font-weight:bold"><?php _e("WPlockz Footer Message: ","mt_trans_domain") ?></label></th>
- <td colspan="2">
- <textarea rows="1" cols="55" id="ad_footer" name="ad_footer"><?php echo htmlspecialchars_decode(($ads[0]->ad_footer)); ?></textarea>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Text 1: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_anchor" name="ad_anchor" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_anchor)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_url" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Link URL 1: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_url" name="ad_url" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_url)); ?>">
- </td>
- </tr>
- <!-- start new ads-->
- <tr valign="top">
- <th scope="row"><label for="ad_anchor1_status" style="font-weight:bold"><?php _e("Enable Offer 2: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_anchor1_status" name="ad_anchor1_status" <?php if($ads[0]->ad_anchor1_status == true ) { echo 'checked="checked"'; } ?>> This will enable or disable the offer below
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor1" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Text 2: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_anchor1" name="ad_anchor1" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_anchor1)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_url1" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Link URL 2: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_url1" name="ad_url1" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_url1)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor2_status" style="font-weight:bold"><?php _e("Enable Offer 3: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_anchor2_status" name="ad_anchor2_status" <?php if($ads[0]->ad_anchor2_status == true ) { echo 'checked="checked"'; } ?>>This will enable or disable the offer below
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor2" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Text 3: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_anchor2" name="ad_anchor2" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_anchor2)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_url2" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Link URL 3:","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_url2" name="ad_url2" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_url2)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor3_status" style="font-weight:bold"><?php _e("Enable Offer 4: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="checkbox" id="ad_anchor3_status" name="ad_anchor3_status" <?php if($ads[0]->ad_anchor3_status == true ) { echo 'checked="checked"'; } ?>>This will enable or disable the offer below
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_anchor3" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Text 4:","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_anchor3" name="ad_anchor3" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_anchor3)); ?>">
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_url3" style="float:left;width:120px;font-weight:bold"><?php _e("Offer Link URL 4:","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:400px" id="ad_url3" name="ad_url3" value="<?php echo htmlspecialchars_decode(($ads[0]->ad_url3)); ?>">
- </td>
- </tr>
- <!-- end new ads-->
- <tr valign="top">
- <th scope="row">
- <label for="ad_vposition_number" style="float:left;width:135px;font-weight:bold"><?php _e("Protector Distance From Top: ","mt_trans_domain") ?></label>
- </th>
- <td>
- <input type="text" style="float: left; width: 50px; margin-right: 10px; text-align: right;" id="ad_vposition_number" name="ad_vposition_number" value="<?php echo intval($ads[0]->ad_vposition); ?>" />
- <select name="ad_vposition_unit" style="float: left; width: 50px; margin-right: 10px; text-align: center;" id="ad_vposition_unit">
- <option value="%"<?php if(substr($ads[0]->ad_vposition, -1, 1) == '%'){ echo ' SELECTED=SELECTED'; } ?>>%</option>
- <option value="px"<?php if(substr($ads[0]->ad_vposition, -1, 1) == 'x'){ echo ' SELECTED=SELECTED'; } ?>>px</option>
- </select>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_color" style="float:left;width:120px;font-weight:bold"><?php _e("Background Overlay Color: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:65px;margin-right:10px;" id="ad_color" name="ad_color" value="<?php if($ads[0]->ad_color != NULL) { echo $ads[0]->ad_color; } else { echo '#ccff66'; } ?>" />
- (<a class="showColor" href="#"><span class="showHide">Show</span><span style="display:none;" class="showHide">Hide</span> Color Chart</a>)
- <div style="display:none" id="colorpicker"></div>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_opacity" style="float:left;width:130px;font-weight:bold"><?php _e("Overlay Opacity: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="float:left;text-align:center;width:40px;margin-right:10px;" id="ad_opacity" name="ad_opacity" value="" />
- <div style="float:left;" id="ad_opacity_slider"></div>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_color2" style="float:left;width:120px;font-weight:bold"><?php _e("Protector Background Color: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="width:65px;margin-right:10px;" id="ad_color2" name="ad_color2" value="<?php if($ads[0]->ad_color2 != NULL) { echo $ads[0]->ad_color2; } else { echo '#ffffcc'; } ?>" />
- (<a class="showColor2" href="#"><span class="showHide2">Show</span><span style="display:none;" class="showHide2">Hide</span> Color Chart</a>)
- <div style="display:none" id="colorpicker2"></div>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_block_delay" style="float:left;width:130px;font-weight:bold"><?php _e("Delay Lockz: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="float:left;text-align:center;width:75px;margin-right:10px;" id="ad_block_delay" name="ad_block_delay" value="" />
- <div style="float:left;" id="ad_block_delay_slider"></div><font size="-1"> (in seconds)</font>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_unlock_delay" style="float:left;width:130px;font-weight:bold"><?php _e("Delay UnLockz: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="float:left;text-align:center;width:75px;margin-right:10px;" id="ad_unlock_delay" name="ad_unlock_delay" value="" />
- <div style="float:left;" id="ad_unlock_delay_slider"></div><font size="-1"> (in seconds)</font>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row"><label for="ad_unlock_for" style="float:left;width:130px;font-weight:bold"><?php _e("UnLockz Post For: ","mt_trans_domain") ?></label></th>
- <td>
- <input type="text" style="float:left;text-align:center;width:75px;margin-right:10px;" id="ad_unlock_for" name="ad_unlock_for" value="" />
- <div style="float:left;" id="ad_unlock_for_slider"></div><font size="-1"> (in hours)</font>
- </td>
- </tr>
- </table>
- <table>
- <tr valign="top">
- <td valign="top">
- <p><p>
- <input type="submit" name="Submit" style="float:left;" class="button-primary" value="<?php if($ad_id != 'new') { _e('Update this Protector Lockz', 'mt_trans_domain' ); } else { _e('Create this Lockz Protector', 'mt_trans_domain' ); } ?>" />
- </td>
- <?php
- if($ad_id != 1 && $ad_id != 'new' ) {
- ?>
- <td valign="top">
- <p><p>
- <input type="submit" id="delete" name="delete" style="margin-left: 20px;" class="button-primary" value="<?php _e('Delete this Lockz Protector', 'my_trans_domain' ); ?>" />
- </td>
- <?php
- }
- ?>
- </tr>
- </table>
- </form>
- </div>
- <?php
- }
- public function menu_post_manager() {
- global $wpdb, $post, $post_ID, $_POST;
- if($_POST['wplockz_ad_selection']) {
- $post_to_assign_ads = $_POST['post_select'];
- } elseif ($_POST['wplockz_save_settings']) {
- $post_to_assign_ads = $_POST['post_id'];
- } else {
- $post_query = get_posts('numberposts=1');
- $post_to_assign_ads = $post_query[0]->ID;
- }
- if($_POST['wplockz_save_settings'] && isset($_POST['assign_ad'])) {
- $this->db->query("DELETE FROM " .$this->wplockz_post_table. " where `post_id` = $post_to_assign_ads");
- foreach($_POST['assign_ad'] as $assigned_ad){
- $this->db->query('INSERT INTO '.$this->wplockz_post_table.' (`post_id`,`ad_id`) VALUES ("'.$post_to_assign_ads.'","'.$assigned_ad.'")');
- }
- } elseif($_POST['wplockz_save_settings'] && !isset($_POST['assign_ad'])) {
- $this->db->query("DELETE FROM " .$this->wplockz_post_table. " where `post_id` = $post_to_assign_ads");
- }
- $get_posts_args = array('numberposts' => -1);
- $post_list = get_posts($get_posts_args);
- $ad_list = $this->db->get_results("SELECT `id`,`ad_name` FROM $this->wplockz_main_table");
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery("select[multiple]").asmSelect({
- addItemTarget: 'bottom',
- animate: true,
- highlight: true,
- sortable: false
- });
- });
- </script>
- <div class="wrap">
- <div id="icon-options-general" class="icon32"><br /></div>
- <h2>WPlockz Post Manager</h2>
- <form action="" method="post">
- <input type="hidden" name="wplockz_ad_selection" value="select" />
- <table class="form-table">
- <tr valign="top">
- <th scope="row"><label for="post_select" style="float:left;width:100px;font-weight:bold"><?php _e("Select Post: ", "mt_trans_domain") ?></label></th>
- <td>
- <select name="post_select" id="post_select">
- <?php
- foreach($post_list as $single_post ){
- echo '<option value="'.$single_post->ID.'"';
- if($single_post->ID == $post_to_assign_ads) { echo ' selected="selected"';}
- echo '>'.$single_post->post_title;
- echo '</option>';
- }
- ?>
- </select>
- <input type="submit" name="Select" style="margin-left:10px" class="button-primary" value="<?php _e('Select Post to Lockz', 'mt_trans_domain' ) ?>" />
- </td>
- </tr>
- </table>
- </form>
- <hr>
- <form action="" method="post">
- <table class="form-table">
- <input type="hidden" name="wplockz_save_settings" id="wplockz_save_settings" class="wplockz_save_settings" value="true" />
- <input type="hidden" name="post_id" id="post_id" class="post_id" value="<?php echo $post_to_assign_ads; ?>">
- <tr valign="top">
- <th scope="row">
- <label for="post_name" style="font-weight:bold">
- <?php _e("Post Name: ","mt_trans_domain") ?>
- </label>
- </th>
- <td>
- <?php
- $this_post = query_posts('p='.$post_to_assign_ads);
- echo $this_post[0]->post_title;
- $current_ads_assigned = $this->db->get_results("SELECT `ad_id` FROM $this->wplockz_post_table WHERE `post_id` = $post_to_assign_ads");
- foreach($current_ads_assigned as $ads_assigned){
- $ad_array[] = $ads_assigned->ad_id;
- }
- ?>
- </td>
- </tr>
- <tr valign="top">
- <th scope="row">
- <label for="assign_ad" style="font-weight:bold">
- <?php _e("Protector(s) To Assign: ","mt_trans_domain") ?>
- </label>
- </th>
- <td>
- <select id="assign_ad" name="assign_ad[]" multiple="multiple" title="Click to Select Protector">
- <?php
- foreach($ad_list as $ad_to_assign){
- echo '<option value="'.$ad_to_assign->id.'"';
- if(!empty($ad_array)){
- if(in_array($ad_to_assign->id, $ad_array)) {echo ' selected="selected"'; }
- }
- echo '>'.$ad_to_assign->ad_name.'</option>';
- }
- ?>
- </select>
- </td>
- </tr>
- </table>
- <table>
- <tr valign="top">
- <td valign="top">
- <input type="submit" name="Submit" style="float:left;" class="button-primary" value="<?php _e('Assign Lockz Content Protector', 'mt_trans_domain' ); ?>" />
- </td>
- </tr>
- </table>
- </form>
- </div>
- <?php
- }
- public function has_more($postContent = NULL) {
- return (bool) ( empty( $postContent ) || preg_match( '/<!--more(.*?)?-->/', $postContent) );
- }
- public function should_lock() {
- global $posts, $post;
- if ($this->get_option('enabled') == false ) {
- return false;
- }
- if($this->get_cookie()){
- return false;
- }
- if($this->get_option('enabled') == true && !is_single()) {
- if( (is_home() == true && $this->get_option('block_index') == true ) ||
- (is_category() == true && $this->get_option('block_category') == true )) {
- $this->lock_action(0);
- return true;
- }
- if(is_page() == true && $this->get_option('block_page') == true ) {
- $this->lock_action(0);
- return true;
- }
- if(is_archive() == true && $this->get_option('block_archive') == true ) {
- $this->lock_action(0);
- return true;
- }
- if(is_search() == true && $this->get_option('block_search') == true ) {
- $this->lock_action(0);
- return true;
- }
- } else {
- $should_block_ad = $this->db->get_results("SELECT `ad_id` FROM $this->wplockz_post_table WHERE `post_id`=$post->ID");
- if(!empty($should_block_ad)){
- $this->lock_action(1);
- } else {
- return;
- }
- }
- }
- public function lock_action($is_post) {
- global $post,$wpdb;
- if($is_post == 0){
- $block_method = $this->db->get_results("SELECT * FROM $this->wplockz_main_table WHERE $this->wplockz_main_table.`id` = 1");
- $block_method = $block_method[0];
- } else {
- $your_cc = $this->geo_lookup($_SERVER['REMOTE_ADDR']);
- $block_method = $this->db->get_results("SELECT * FROM ($this->wplockz_post_table LEFT JOIN $this->wplockz_main_table ON $this->wplockz_post_table.`ad_id` = $this->wplockz_main_table.`id`) LEFT JOIN $this->wplockz_geo_table ON $this->wplockz_post_table.`ad_id` = $this->wplockz_geo_table.`ad_id` WHERE $this->wplockz_post_table.`post_id` = '$post->ID' AND $this->wplockz_geo_table.`cc`='$your_cc'");
- if($this->db->num_rows == 1){
- $block_method = $block_method[0];
- } elseif($this->db->num_rows > 1) {
- $block_method = $block_method[mt_rand(0,(count($block_method)-1))];
- } elseif($this->db->num_rows == 0) {
- $block_method = $this->db->get_results("SELECT * FROM ($this->wplockz_post_table LEFT JOIN $this->wplockz_main_table ON $this->wplockz_post_table.`ad_id` = $this->wplockz_main_table.`id`) LEFT JOIN $this->wplockz_geo_table ON $this->wplockz_post_table.`ad_id` = $this->wplockz_geo_table.`ad_id` WHERE $this->wplockz_post_table.`post_id` = '$post->ID' AND $this->wplockz_geo_table.`cc`='all'");
- if($this->db->num_rows == 1){
- $block_method = $block_method[0];
- } elseif($this->db->num_rows > 1) {
- $block_method = $block_method[mt_rand(0,(count($block_method)-1))];
- }
- }
- }
- ?>
- <script type='text/javascript'>
- jQuery(document).ready(function() {
- jQuery('#blocking-message').jqm({
- toTop: true,
- modal: true,
- onHide: function(h) {
- h.o.remove();
- h.w.fadeOut(888);
- jQuery.cookies.set('cbwpg', '<?php echo md5($page->ID.$your_cc.mt_rand(0,$page->ID)); ?>', {hoursToLive: <?php echo $block_method->ad_unlock_for; ?>});
- jQuery('html').unbind('contextmenu');
- jQuery('html').css('overflow', 'scroll');
- }
- });
- setTimeout(function() {
- <?php
- if($block_method->ad_rc_lock === '1') {
- echo "jQuery('html').bind('contextmenu',function(e){ return false; });";
- }
- ?>
- <?php
- if ($block_method ->ad_scroll_lock === '1') {
- echo "jQuery('html').css('overflow', 'hidden');";
- }
- ?>
- jQuery('#blocking-message').jqmShow();
- jQuery('.jqmOverlay').css('background-color','<?php echo $block_method->ad_color; ?>').css('opacity','<?php echo $block_method->ad_opacity; ?>');
- jQuery('.jqmWindow').css('background-color','<?php echo $block_method->ad_color2; ?>');
- jQuery('#blocking-message').css('top','<?php echo $block_method->ad_vposition; ?>');
- jQuery("#blocking-message a").attr("target","_blank")
- jQuery("#blocking-message a").click(function () {
- setTimeout(function() { jQuery('#blocking-message').jqmHide();}, <?php echo $block_method->ad_unlock_delay; ?>);
- });
- },<?php echo $block_method->ad_block_delay; ?>);
- });
- </script>
- <div id="blocking-message" class="jqmWindow">
- <div class="container">
- <div id="left">
- <img src="<?php echo $lock_pic = $this->get_option('directory')."lock.gif"; ?>">
- </div>
- <div id="right">
- <h1><?php echo $block_method->ad_title; ?></h1>
- <p> </p>
- <div id="text">
- <p><?php echo $block_method->ad_p1; ?></p>
- <p></p>
- <p><?php echo $block_method->ad_p2; ?></p>
- </div>
- <div id="center">
- <p> </p>
- <p><?php echo $block_method->ad_footer; ?></p>
- </div>
- </div>
- <div id="links">
- <a class="link" href="<?php echo $block_method->ad_url; ?>"><?php echo $block_method->ad_anchor; ?></a><p>
- <?php
- if ($block_method ->ad_anchor1_status === '1') {
- ?><a class="link" href="<?php echo $block_method->ad_url1; ?>"><?php echo $block_method->ad_anchor1; ?></a><p><?php
- } else {
- ?><?php echo $ad_anchor1_status; ?><p><?php
- }
- ?>
- <?php
- if ($block_method ->ad_anchor2_status === '1') {
- ?><a class="link" href="<?php echo $block_method->ad_url2; ?>"><?php echo $block_method->ad_anchor2; ?></a><p><?php
- } else {
- ?><?php echo $ad_anchor2_status; ?><p><?php
- }
- ?>
- <?php
- if ($block_method ->ad_anchor3_status === '1') {
- ?><a class="link" href="<?php echo $block_method->ad_url3; ?>"><?php echo $block_method->ad_anchor3; ?></a><p><?php
- } else {
- ?><?php echo $ad_anchor3_status; ?><p><?php
- }
- ?>
- </div>
- </div>
- </div>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment