| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
/* |
| 5 |
* Defaine PR Global option's name |
| 6 |
*/ |
| 7 |
if(!defined('OPTION_PIE_REGISTER')) |
| 8 |
define('OPTION_PIE_REGISTER','pie_register'); |
| 9 |
|
| 10 |
/* |
| 11 |
* Define PR DB Version Name |
| 12 |
*/ |
| 13 |
if(!defined('PIEREG_DB_VERSION')) |
| 14 |
define('PIEREG_DB_VERSION','3.7.3.2'); |
| 15 |
|
| 16 |
/* |
| 17 |
* Define Restrict Widgets Option Name |
| 18 |
*/ |
| 19 |
if(!defined("PIEREGISTER_RW_OPTIONS")) |
| 20 |
define("PIEREGISTER_RW_OPTIONS","pieregister_restrict_widgets"); |
| 21 |
|
| 22 |
|
| 23 |
/* |
| 24 |
* Define name of Pie Register's Stats |
| 25 |
*/ |
| 26 |
if(!defined("PIEREG_STATS_OPTION")) |
| 27 |
define("PIEREG_STATS_OPTION","pieregister_stats_option"); |
| 28 |
|
| 29 |
/* |
| 30 |
* Define name of Currency Name with Code |
| 31 |
*/ |
| 32 |
if(!defined("PIEREG_CURRENCY_OPTION")) |
| 33 |
define("PIEREG_CURRENCY_OPTION","piereg_currency"); |
| 34 |
|
| 35 |
/* |
| 36 |
* Define name of Currency Name with Code |
| 37 |
*/ |
| 38 |
if(!defined("PIEREG_DIR_NAME")) |
| 39 |
define("PIEREG_DIR_NAME",plugin_dir_path(__FILE__)); |
| 40 |
|
| 41 |
/* |
| 42 |
* Define Plugin Base name |
| 43 |
*/ |
| 44 |
if(!defined("PIEREG_PLUGIN_BASENAME")) |
| 45 |
define( 'PIEREG_PLUGIN_BASENAME', "pie-register/pie-register.php" ); |
| 46 |
|
| 47 |
/* |
| 48 |
* Define License Key opeion's name |
| 49 |
*/ |
| 50 |
if(!defined("PIEREG_LICENSE_KEY_OPTION")) |
| 51 |
define( 'PIEREG_LICENSE_KEY_OPTION', 'api_manager_example' ); |
| 52 |
|
| 53 |
/* |
| 54 |
* Define PayPal Live Account URL |
| 55 |
*/ |
| 56 |
if(!defined("PIE_SSL_P_URL")) |
| 57 |
define('PIE_SSL_P_URL', 'https://www.paypal.com/cgi-bin/webscr'); |
| 58 |
|
| 59 |
/* |
| 60 |
* Define PayPal Sandbox Account URL |
| 61 |
*/ |
| 62 |
if(!defined("PIE_SSL_SAND_URL")) |
| 63 |
define('PIE_SSL_SAND_URL','https://www.sandbox.paypal.com/cgi-bin/webscr'); |
| 64 |
|
| 65 |
/* |
| 66 |
* Define Log File Name |
| 67 |
*/ |
| 68 |
// $upload_dir = wp_upload_dir(); |
| 69 |
// $temp_dir = realpath($upload_dir['basedir'])."/pie-logs"; |
| 70 |
// if(!defined("PIE_LOG_FILE")) |
| 71 |
// define( 'PIE_LOG_FILE', $temp_dir ); |
| 72 |
|
| 73 |
|
| 74 |
// delete payment logs file - temperorly |
| 75 |
$upload_dir = wp_upload_dir(); |
| 76 |
$temp_dir = $upload_dir['basedir'] . "/pie-logs/payment-log.log"; |
| 77 |
|
| 78 |
if ( file_exists($temp_dir) ) { // Check if file exists |
| 79 |
global $wp_filesystem; |
| 80 |
if ( empty( $wp_filesystem ) ) { |
| 81 |
require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
| 82 |
WP_Filesystem(); |
| 83 |
} |
| 84 |
if ( $wp_filesystem ) { |
| 85 |
$wp_filesystem->delete( $temp_dir ); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
$secure_log_dir = WP_CONTENT_DIR . "/pie-logs"; // Secure directory |
| 91 |
|
| 92 |
// Ensure the directory exists |
| 93 |
if (!file_exists($secure_log_dir)) { |
| 94 |
wp_mkdir_p($secure_log_dir); |
| 95 |
} |
| 96 |
|
| 97 |
// Create .htaccess file to block access |
| 98 |
$htaccess_file = $secure_log_dir . '/.htaccess'; |
| 99 |
if (!file_exists($htaccess_file)) { |
| 100 |
global $wp_filesystem; |
| 101 |
if ( empty( $wp_filesystem ) ) { |
| 102 |
require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
| 103 |
WP_Filesystem(); |
| 104 |
} |
| 105 |
$htaccess_content = "<IfModule mod_authz_core.c>\nRequire all denied\n</IfModule>\n"; |
| 106 |
$htaccess_content .= "<IfModule !mod_authz_core.c>\nOrder allow,deny\nDeny from all\n</IfModule>\n"; |
| 107 |
if ( $wp_filesystem ) { |
| 108 |
$wp_filesystem->put_contents($htaccess_file, $htaccess_content, FS_CHMOD_FILE); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
// Add an index.php file for extra security |
| 113 |
$index_file = $secure_log_dir . '/index.php'; |
| 114 |
if (!file_exists($index_file)) { |
| 115 |
global $wp_filesystem; |
| 116 |
if ( empty( $wp_filesystem ) ) { |
| 117 |
require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
| 118 |
WP_Filesystem(); |
| 119 |
} |
| 120 |
if ( $wp_filesystem ) { |
| 121 |
$wp_filesystem->put_contents($index_file, "<?php\n// Silence is golden.", FS_CHMOD_FILE); |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
// Define log directory constant |
| 126 |
if (!defined("PIE_LOG_FILE")) { |
| 127 |
define('PIE_LOG_FILE', $secure_log_dir); |
| 128 |
} |
| 129 |
|
| 130 |
if( !class_exists('PieRegisterBaseVariables') ){ |
| 131 |
class PieRegisterBaseVariables |
| 132 |
{ |
| 133 |
|
| 134 |
// Deprecated Dynamic Properties - Fixed |
| 135 |
var $admin_path ; |
| 136 |
var $slug ; |
| 137 |
var $read_only ; |
| 138 |
var $not_visible ; |
| 139 |
var $readibility ; |
| 140 |
var $default_fields; |
| 141 |
var $visibility_check; |
| 142 |
var $user_table; |
| 143 |
var $user_meta_table; |
| 144 |
var $plugin_dir; |
| 145 |
var $plugin_url; |
| 146 |
var $pie_success; |
| 147 |
var $pie_error; |
| 148 |
var $pie_error_msg; |
| 149 |
var $pie_success_msg; |
| 150 |
var $piereg_global_options;// deprecated |
| 151 |
var $PR_GLOBAL_OPTIONS; |
| 152 |
var $pr_wp_db_prefix; |
| 153 |
var $pie_post_array; |
| 154 |
|
| 155 |
public $upgrade_url = 'http://store.genetech.co/'; |
| 156 |
public $version = '1.0'; |
| 157 |
|
| 158 |
public $piereg_api_manager_version_name = 'pie-register'; //plugin_api_manager_example_version |
| 159 |
public $piereg_plugin_url; |
| 160 |
|
| 161 |
public $piereg_text_domain = 'pie-register'; |
| 162 |
|
| 163 |
var $piereg_pro_is_activate = false; |
| 164 |
var $no_addon_activated = false; |
| 165 |
var $show_notice_premium_users = false; |
| 166 |
|
| 167 |
//pie-register-woocommerce addon |
| 168 |
var $woocommerce_and_piereg_wc_addon_active = false; |
| 169 |
//pie-register-field-visibility addon |
| 170 |
var $piereg_field_visbility_addon_active = false; |
| 171 |
|
| 172 |
//pie-register-bbpress |
| 173 |
var $piereg_bbpress_addon_active = false; |
| 174 |
|
| 175 |
function __construct(){ |
| 176 |
|
| 177 |
/* |
| 178 |
* Get PR Options from DB |
| 179 |
*/ |
| 180 |
global $piereg_global_options;// deprecated |
| 181 |
global $PR_GLOBAL_OPTIONS; |
| 182 |
global $PR_Bot_List; |
| 183 |
|
| 184 |
$PR_GLOBAL_OPTIONS = get_option(OPTION_PIE_REGISTER); |
| 185 |
$piereg_global_options = $PR_GLOBAL_OPTIONS; |
| 186 |
$PR_Bot_List = "bot\r\nia_archiver\r\ngooglebot\r\nbingbot\r\nslurp\r\nduckduckbot\r\nbaiduspider\r\nyandexbot\r\nsogou\r\nexabot\r\nfacebot"; |
| 187 |
|
| 188 |
/* |
| 189 |
* Get Wp DB Prefix |
| 190 |
*/ |
| 191 |
global $wpdb,$pr_wp_db_prefix; |
| 192 |
$pr_wp_db_prefix = $wpdb->prefix; |
| 193 |
|
| 194 |
|
| 195 |
$this->pie_post_array = array(); |
| 196 |
|
| 197 |
|
| 198 |
/* |
| 199 |
* check is activate plugins |
| 200 |
*/ |
| 201 |
$options = get_option( PIEREG_LICENSE_KEY_OPTION ); |
| 202 |
$activated = get_option( 'piereg_api_manager_activated' ); |
| 203 |
$instance = get_option( 'piereg_api_manager_instance' ); |
| 204 |
|
| 205 |
if (isset($options['api_key'], $options['activation_email']) && !empty($options['api_key']) && !empty($options['activation_email']) && $activated == "Activated" && !empty($instance)) { |
| 206 |
$this->show_notice_premium_users = true; |
| 207 |
} else { |
| 208 |
$this->show_notice_premium_users = false; |
| 209 |
} |
| 210 |
|
| 211 |
if(!defined("PIEREG_IS_ACTIVE")) |
| 212 |
define( 'PIEREG_IS_ACTIVE', false ); |
| 213 |
|
| 214 |
|
| 215 |
if ( ! function_exists( 'is_plugin_active' ) ) |
| 216 |
{ |
| 217 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 218 |
} |
| 219 |
//pie-register-woocommerce addon |
| 220 |
if( is_plugin_active( 'woocommerce/woocommerce.php') && is_plugin_active('pie-register-woocommerce/pie-register-woocommerce.php') && get_option('piereg_api_manager_addon_WooCommerce_activated') == "Activated" ) { |
| 221 |
$this->woocommerce_and_piereg_wc_addon_active = true; |
| 222 |
} |
| 223 |
|
| 224 |
//pie-register-bbpress addon |
| 225 |
if( is_plugin_active('bbpress/bbpress.php') && is_plugin_active('pie-register-bbpress/pie-register-bbpress.php') && get_option('piereg_api_manager_addon_Bbpress_activated') == "Activated" ) { |
| 226 |
$this->piereg_bbpress_addon_active = true; |
| 227 |
} |
| 228 |
|
| 229 |
//pie-register-field-visibility addon |
| 230 |
if( is_plugin_active('pie-register-field-visibility/pie-register-field-visibility.php') && get_option('piereg_api_manager_addon_Field_Visibility_activated') == "Activated" ) { |
| 231 |
$this->piereg_field_visbility_addon_active = true; |
| 232 |
} |
| 233 |
} |
| 234 |
public function pie_get_admin_path() |
| 235 |
{ |
| 236 |
// Replace the site base URL with the absolute path to its installation directory. |
| 237 |
$admin_path = str_replace( get_bloginfo( 'wpurl' ) . '/', ABSPATH, get_admin_url() ); |
| 238 |
|
| 239 |
if( $admin_path == get_admin_url() ) |
| 240 |
{ |
| 241 |
return ABSPATH . 'wp-admin/'; |
| 242 |
} |
| 243 |
|
| 244 |
// Make it filterable, so other plugins can hook into it. |
| 245 |
$admin_path = apply_filters( 'pie_get_admin_path', $admin_path ); |
| 246 |
return $admin_path; |
| 247 |
} |
| 248 |
function piereg_pro_is_activate(){ |
| 249 |
return false; |
| 250 |
} |
| 251 |
|
| 252 |
} |
| 253 |
} |