prefix."AWM_EZ_CL_options"); register_activation_hook( __FILE__, "install_AWM_EZ_CL"); error_reporting(0); $VERSION=1.5; function install_AWM_EZ_CL() { //mysql_query("DROP TABLE ".AWM_TABLE); mysql_query("CREATE TABLE IF NOT EXISTS ".AWM_TABLE." ( `ID` int(8) NOT NULL AUTO_INCREMENT, `locker_code` text NOT NULL, `status` int(1) NOT NULL, `posts` text NOT NULL, `pages` text NOT NULL, `display` int(1) NOT NULL, `hideShow` int(1) NOT NULL, `totalLoads` int(10) NOT NULL, `name` varchar(270) NOT NULL, PRIMARY KEY (`ID`), KEY `status` (`status`), KEY `hideShow` (`hideShow`) ) ENGINE=MyISAM AUTO_INCREMENT=1") or die(mysql_error()); } function AWM_EZ_CL_LOAD_CSS() { echo ''; } function AWM_EZ_CL_plugin_menu() { add_submenu_page('options-general.php', 'AdWork Media EZ Content Locker Settings', 'AWM EZ Locker', 10, __FILE__, 'AWM_EZ_CL_plugin_options'); } function AWM_EZ_CL_plugin_options() { include('AWM-admin-settings.php'); } function updateDatabase () { //index update $countIndex=mysql_num_rows(mysql_query("SHOW INDEX FROM ".AWM_TABLE." WHERE Key_name='status'")); if($countIndex==0) { mysql_query("ALTER TABLE ".AWM_TABLE." ADD INDEX (status)"); } $countIndex=mysql_num_rows(mysql_query("SHOW INDEX FROM ".AWM_TABLE." WHERE Key_name='hideShow'")); if($countIndex==0) { mysql_query("ALTER TABLE ".AWM_TABLE." ADD INDEX (hideShow)"); } $findColumn=mysql_query("SHOW COLUMNS FROM ".AWM_TABLE); $totalLeads=false; $hideShow=false; while($rowColumn=mysql_fetch_array($findColumn)) { if($rowColumn['Field']=='totalLeads') { $totalLeads=true; } if($rowColumn['Field']=='hideShow') { $hideShow=true; } } if($totalLeads==false) { mysql_query("ALTER TABLE ".AWM_TABLE." ADD `hideShow` INT( 1 ) NOT NULL"); } if($hideShow==false) { mysql_query("ALTER TABLE ".AWM_TABLE." ADD `totalLoads` INT( 10 ) NOT NULL"); } // ----------- } /** * Add Settings link to plugins - code from GD Star Ratings */ function AWM_add_settings_link($links, $file) { static $this_plugin; if (!$this_plugin) $this_plugin = plugin_basename(__FILE__); if ($file == $this_plugin){ $settings_link = ''.__("Settings", "AWM-Locker-Settings").''; array_unshift($links, $settings_link); } return $links; } function AWM_LOCK_PAGE() { updateDatabase(); $searchProfiles=mysql_query("SELECT * FROM ".AWM_TABLE." WHERE status=1"); if(mysql_num_rows($searchProfiles)>0) { $lockPage=false; $trigger=false; while($row=mysql_fetch_array($searchProfiles)) { $pages=explode(',', $row['pages']); $posts=explode(',', $row['posts']); if($lockPage==true) { break; } if(in_array('HP', $pages) && is_home()) { $trigger=true; } else { foreach($pages as $pg) { if(is_page($pg)) { $trigger=true; break; } } } if($trigger==false) { foreach($posts as $pg) { if(is_single($pg)) { $trigger=true; break; } } } if($row['hideShow']==1) { if(is_user_logged_in()) { $trigger=false; } } if($row['hideShow']==2) { if (current_user_can('administrator')) { $trigger=false; } } if($row['hideShow']==3) { if (current_user_can('administrator') || is_user_logged_in()) { $trigger=false; } } if($row['display']==0) { if($trigger==true) { if(!empty($row['locker_code'])) { mysql_query("UPDATE ".AWM_TABLE." SET totalLoads=totalLoads+1 WHERE ID=".$row['ID']." LIMIT 1"); echo stripslashes($row['locker_code']); $lockPage=true; } } } else { if($trigger==false) { if(!empty($row['locker_code'])) { mysql_query("UPDATE ".AWM_TABLE." SET totalLoads=totalLoads+1 WHERE ID=".$row['ID']." LIMIT 1"); echo stripslashes($row['locker_code']); $lockPage=true; } } } } } } function createLocker($name, $code, $pages, $posts, $display, $hideShow) { mysql_query("INSERT INTO ".AWM_TABLE." SET name='".mysql_real_escape_string($name)."', locker_code='".mysql_real_escape_string($code)."', status=1, pages='".mysql_real_escape_string($pages)."', posts='".mysql_real_escape_string($posts)."', display='".mysql_real_escape_string($display)."', hideShow='".mysql_real_escape_string($hideShow)."'") or die(mysql_error()); echo '
Success, your profile has been created.
Success, your profile has been updated.
Success, your profile has been deleted.