Advertisement
Guest User

Pie Register php

a guest
Jul 28th, 2013
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 110.00 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Pie Register
  4. Plugin URI: http://genetechsolutions.com.com/pie-register.html
  5. Description: <strong>WordPress 3.5 + ONLY.</strong> Enhance your Registration Page. Add Custom Logo, Password Field, Invitation Codes, Disclaimer, Captcha Validation, Email Validation, User the fork of register-plus, however many things have been changed since.
  6.  
  7.  
  8. Author: Genetech
  9. Version: 1.31
  10. Author URI: http://www.genetechsolutions.com/
  11.  
  12. LOCALIZATION
  13. * Currently This feature is not available. We are working on it to improve.
  14.  
  15. CHANGELOG
  16. See readme.txt
  17. */
  18.  
  19. define('LOG_FILE', '.ipn_results.log');
  20. define('SSL_P_URL', 'https://www.paypal.com/cgi-bin/webscr');
  21. define('SSL_SAND_URL','https://www.sandbox.paypal.com/cgi-bin/webscr');
  22. $rp = get_option( 'pie_register' ); //load options
  23. if( $rp['dash_widget'] ) //if dashboard widget is enabled
  24. include_once('dash_widget.php'); //add the dashboard widget
  25.  
  26. if( !class_exists('PieMemberRegister') ){
  27. class PieMemberRegister{
  28. public static $instance;
  29. protected $retrieve_password_for = '';
  30. public $during_user_creation = false; // hack
  31. private $ipn_status;
  32. public $txn_id;
  33. public $ipn_log;
  34. private $ipn_response;
  35. public $ipn_data = array();
  36. public $postvars;
  37. private $ipn_debug;
  38. var $holdmsg = '';
  39. public $headmsg='';
  40. public $bodymsg='';
  41. /**
  42. * Constructor
  43. */
  44. public function __construct() {
  45. $this->ipn_status = '';
  46. $this->txn_id = null;
  47. $this->ipn_log = true;
  48. $this->ipn_response = '';
  49. $this->ipn_debug = false;
  50. $this->PieMemberRegister();
  51. }
  52.  
  53. private function log_ipn_results($success) {
  54. $hostname = gethostbyaddr ( $_SERVER ['REMOTE_ADDR'] );
  55. // Timestamp
  56. $text = '[' . date ( 'm/d/Y g:i A' ) . '] - ';
  57. // Success or failure being logged?
  58. if ($success)
  59. $this->ipn_status = $text . 'SUCCESS:' . $this->ipn_status . "!\n";
  60. else
  61. $this->ipn_status = $text . 'FAIL: ' . $this->ipn_status . "!\n";
  62. // Log the POST variables
  63. $this->ipn_status .= "[From:" . $hostname . "|" . $_SERVER ['REMOTE_ADDR'] . "]IPN POST Vars Received By Paypal_IPN Response API:\n";
  64. foreach ( $this->ipn_data as $key => $value ) {
  65. $this->ipn_status .= "$key=$value \n";
  66. }
  67. // Log the response from the paypal server
  68. $this->ipn_status .= "IPN Response from Paypal Server:\n" . $this->ipn_response;
  69. $this->write_to_log ();
  70. }
  71. private function write_to_log() {
  72. if (! $this->ipn_log)
  73. return; // is logging turned off?
  74.  
  75. // Write to log
  76. $fp = fopen ( LOG_FILE , 'a' );
  77. fwrite ( $fp, $this->ipn_status . "\n\n" );
  78. fclose ( $fp ); // close file
  79. chmod ( LOG_FILE , 0600 );
  80. }
  81. function PieMemberRegister() { //constructor
  82. global $wp_version;
  83. self::$instance = $this;
  84.  
  85. $this->plugin_dir = dirname(__FILE__);
  86. $this->plugin_url = plugins_url() .'/'. basename(dirname(__FILE__)) .'/';
  87. $this->ref = explode('?',$_SERVER['REQUEST_URI']);
  88. $this->ref = $this->ref[0];
  89. $this->admin_edit_profile_page = '/wp-admin/user-edit.php';
  90. $this->admin_own_profile_page = '/wp-admin/profile.php';
  91. //ACTIONS
  92. if (get_magic_quotes_gpc()) {
  93. array_walk_recursive($_GET, array(&$this,'disable_magic_quotes_gpc'));
  94. array_walk_recursive($_POST, array(&$this,'disable_magic_quotes_gpc'));
  95. array_walk_recursive($_COOKIE, array(&$this,'disable_magic_quotes_gpc'));
  96. array_walk_recursive($_REQUEST, array(&$this,'disable_magic_quotes_gpc'));
  97. }
  98.  
  99. if( ($this->ref == $this->admin_edit_profile_page) || ($this->ref == $this->admin_own_profile_page) ){
  100. add_action( 'admin_head', array($this, 'ProfilesHead') );
  101. }
  102. add_action( 'retrieve_password', array( &$this, 'retrieve_password' ) );
  103. add_filter( 'login_headerurl', array(&$this,'login_headerurl') );
  104. add_filter( 'login_headertitle', array(&$this,'login_headertitle') );
  105.  
  106. add_filter( 'login_redirect', array(&$this, 'loginredirect'),10,3 );
  107.  
  108. add_filter('allow_password_reset', array(&$this,'allow_password_reset'),10,2);
  109.  
  110. #Add Settings Panel
  111.  
  112. add_action( 'admin_menu', array($this, 'AddPanel') );
  113. #Update Settings on Save
  114. if($_POST['pieregister_reset'] && $_POST['action'] == 'pie_reg_update'){
  115. add_action( 'init', array($this, 'DefaultSettings') );
  116. }elseif( isset($_POST['action']) && $_POST['action'] == 'pie_reg_update' )
  117. add_action( 'init', array($this,'SaveSettings') );
  118. #Enable jQuery on Settings panel
  119. if( isset($_GET['page']) && $_GET['page'] == 'pie-register' ){
  120. wp_enqueue_script('jquery');
  121. if ( !is_multisite() ) wp_enqueue_script( 'media-upload' );
  122. if ( !is_multisite() ) wp_enqueue_script( 'thickbox' );
  123. if ( !is_multisite() ) wp_enqueue_style( 'thickbox' );
  124. add_action( 'admin_head', array($this, 'SettingsHead') );
  125. }
  126. add_action( 'login_init', array($this, 'SessionStart'),1 );
  127. add_action( 'login_init', array($this, 'setCookies'),1 );
  128. #Add Register Form Fields
  129. //Julian Fix
  130. add_action( 'register_form', array($this, 'RegForm'),5 );
  131. #Add Register Page Javascript & CSS
  132.  
  133. if(isset($_GET['action']) && $_GET['action'] == 'register')
  134. add_action( 'login_head', array($this, 'PassHead') );
  135. #Add Custom Logo CSS to Login Page
  136. add_action( 'login_head', array($this, 'LogoHead') );
  137. #Hide initial login fields when email verification is enabled
  138. add_action( 'login_head', array($this, 'HideLogin') );
  139. #Save Default Settings
  140. add_action( 'init', array($this, 'DefaultSettings') );
  141. #Profile
  142. add_action( 'show_user_profile', array($this, 'Add2Profile') );
  143. add_filter( 'user_contactmethods' , array($this, 'update_contact_methods') , 10 , 1 );
  144. add_action( 'edit_user_profile', array($this, 'Add2Profile') );
  145. add_action( 'profile_update', array($this, 'SaveProfile') );
  146. #Validate User
  147. //add_action( 'login_form', array($this, 'ValidateUser') );
  148. add_action( 'login_head', array($this, 'ValidateUser') );
  149. #Validate Payment of a User
  150. add_action( 'login_head', array($this, 'ValidPUser') );
  151.  
  152. #Delete Invalid Users
  153. add_action( 'init', array($this, 'DeleteInvalidUsers') );
  154. #Unverified Users Head Scripts
  155. add_action( 'admin_head', array($this, 'UnverifiedHead') );
  156. #Admin Validate Users
  157. if( isset($_POST['verifyit']) )
  158. add_action( 'init', array($this, 'AdminValidate') );
  159. #Admin Send Payment Link
  160. if( isset($_POST['paymentl']) )
  161. add_action( 'init', array($this, 'PaymentLink') );
  162. #Admin Resend VerificatioN Email
  163. if( isset($_POST['emailverifyit']) )
  164. add_action( 'init', array($this, 'AdminEmailValidate') );
  165. #Admin Delete Unverified User
  166. if( isset($_POST['vdeleteit']) )
  167. add_action( 'init', array($this, 'AdminDeleteUnvalidated') );
  168.  
  169. //FILTERS
  170. #Check Register Form for Errors
  171. add_filter( 'registration_errors', array($this, 'RegErrors'),1 );
  172. /* Since 1.2.9 Hack for wp >= 3.0 */
  173. add_filter( 'pre_user_email', array( &$this, 'hack_pre_user_email' ) );
  174. add_filter( 'retrieve_password_message', array( &$this, 'retrieve_password_message' ),10,2 );
  175.  
  176. //LOCALIZATION
  177. #Place your language file in the plugin folder and name it "piereg-{language}.mo"
  178. #replace {language} with your language value from wp-config.php
  179. load_plugin_textdomain( 'piereg', false, dirname(plugin_basename(__FILE__)) . '/lang/');
  180.  
  181. //VERSION CONTROL
  182. if( $wp_version < 3.5 )
  183. add_action('admin_notices', array($this, 'version_warning'));
  184.  
  185. // Load this plugin last to ensure other plugins don't overwrite the settings
  186.  
  187. add_action( 'activated_plugin', array($this, 'load_last') );
  188.  
  189. }
  190.  
  191. function login_headerurl($login_header_url){
  192. return site_url();
  193. }
  194. function login_headertitle($login_header_title){
  195. return get_bloginfo('name');
  196. }
  197. function loginredirect($redirect_to,$request,$user){
  198. $piereg=get_option( 'pie_register' );
  199. $loginredirect = $piereg['loginredirect'];
  200. if(!empty($loginredirect)){
  201. return $loginredirect;
  202. }
  203. return $redirect_to;
  204. }
  205. function allow_password_reset($allow, $userid){
  206. global $wpdb;
  207. $pending_payment = get_user_meta( $userid, 'pending_payment', true );
  208. $email_verify = get_user_meta( $userid, 'email_verify_user', true );
  209. $admin_verify = get_user_meta( $userid, 'admin_verify_user', true );
  210. if($pending_payment || $email_verify || $admin_verify) return false;
  211. return $allow;
  212. }
  213. function Install(){
  214. global $wpdb;
  215. $prefix=$wpdb->prefix."pieregister_";
  216. $codetable=$prefix."code";
  217. $wpdb->query("CREATE TABLE ".$codetable."(`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,`created` DATE NOT NULL ,`modified` DATE NOT NULL ,`name` TEXT NOT NULL ,`count` INT( 5 ) NOT NULL ,`status` INT( 2 ) NOT NULL) ENGINE = MYISAM ;");
  218. $wpdb->flush();
  219. }
  220. function Uninstall(){
  221. global $wpdb;
  222. $prefix=$wpdb->prefix.'pieregister_';
  223. $codetable=$prefix.'code';
  224. $wpdb->query('DROP TABLE `'.$codetable.'`');
  225. $wpdb->flush();
  226. }
  227. function InsertCode($name){
  228. if(empty($name)) return false;
  229.  
  230. global $wpdb;
  231. $piereg=get_option( 'pie_register' );
  232. $prefix=$wpdb->prefix."pieregister_";
  233. $codetable=$prefix."code";
  234. $expiry=$piereg['codeexpiry'];
  235. $users = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key='invite_code' AND meta_value='$name'" );
  236. $counts = count($users);
  237. $wpdb->query("DELETE FROM ".$codetable." WHERE `name`='{$name}'");
  238. $wpdb->flush();
  239. if( ($expiry > 0) && ($counts == $expiry) ){
  240. return true;
  241. }
  242. $name = mysql_real_escape_string(trim(preg_replace("/[^A-Za-z0-9_-]/", '', $name)));
  243. /*$expiry=$piereg['codeexpiry'];
  244. if($expiry == '0')
  245. $expiry = 999999999999999999999999999999;*/
  246. $date=date("Y-m-d");
  247.  
  248. $wpdb->query("INSERT INTO ".$codetable." (`created`,`modified`,`name`,`count`,`status`)VALUES('".$date."','".$date."','".$name."','".$counts."','1')");
  249. $wpdb->flush();
  250. return true;
  251.  
  252. }
  253. /**
  254. * This is a HACK because WP 3.0 introduced a change that made it
  255. * impossible to suppress the unique email check when creating a new user.
  256. *
  257. * For the hack, this filter is invoked just before wp_insert_user() checks
  258. * for the uniqueness of the email address. What this is doing is setting a
  259. * flag so that the get_user_by_email() overridden by this plugin, when
  260. * called in the wp_insert_user() context, knows to return false, making WP
  261. * think the email address isn't in use.
  262. *
  263. * @since 1.2.9
  264. *
  265. * @param string $email Email for the user
  266. * @return string The same value as passed to the function
  267. */
  268. function hack_pre_user_email( $email ) {
  269. $this->during_user_creation = true;
  270. return $email;
  271. }
  272. function UpdateCode($name){
  273. if(empty($name)) return false;
  274.  
  275. global $wpdb;
  276. $prefix=$wpdb->prefix."pieregister_";
  277. $codetable=$prefix."code";
  278. $piereg=get_option( 'pie_register' );
  279. $expiry=$piereg['codeexpiry'];
  280. $date=date("Y-m-d");
  281. $name = trim($name);
  282.  
  283. $counts=$wpdb->get_var( "SELECT `count` FROM ".$codetable." WHERE `name`='".$name."';" );
  284. $new_counts=$counts+1;
  285. if( ($expiry > 0) && ($counts == $expiry || $new_counts == $expiry) ){
  286. $wpdb->query("UPDATE ".$codetable." SET `modified`='".$date."' ,`count`='".$new_counts."',`status`='2' WHERE `name`='".$name."'");
  287.  
  288. /*$pieregcodes=explode("\n", $piereg['codepass']);
  289. $newcodes='';
  290. foreach($pieregcodes as $k=>$v){
  291. if($name !== trim($v)){
  292. $newcodes.=$v."\n";
  293. }
  294. }
  295. $newcodes=trim($newcodes,"\n");
  296. $piereg["codepass"] = $newcodes;
  297. update_option( 'pie_register', $piereg )*/;
  298. if($piereg['code_auto_del']){
  299. $wpdb->query("DELETE FROM ".$codetable." WHERE `name`='".$name."'");
  300. }
  301.  
  302. return 2;
  303. }else{
  304. $wpdb->query("UPDATE ".$codetable." SET `modified`='".$date."' ,`count`='".$new_counts."' WHERE `name`='".$name."'");
  305.  
  306. return true;
  307. }
  308.  
  309. }
  310. function SelectCode($name=''){
  311. global $wpdb;
  312. $prefix=$wpdb->prefix."pieregister_";
  313. $codetable=$prefix."code";
  314. $name = trim($name);
  315. if(empty($name)){
  316. $result='';
  317. $result=$wpdb->get_results( "SELECT * FROM ".$codetable." WHERE `status`='2';" );
  318. return $result;
  319. }else{
  320. $counts=$wpdb->get_var( $wpdb->prepare( "SELECT `count` FROM ".$codetable." WHERE `name`='".$name."';" ) );
  321. return $counts;
  322. }
  323. }
  324. function SessionStart(){
  325. return session_start();
  326. }
  327. function setCookies(){
  328. if(isset($_SESSION['secure_id']))
  329. setcookie("session_secure_id", $_SESSION['secure_id'], time()+172800, "/", COOKIE_DOMAIN);
  330. }
  331. function disable_magic_quotes_gpc(&$value){
  332. /*if (TRUE == function_exists('get_magic_quotes_gpc') && 1 == get_magic_quotes_gpc()){
  333. $mqs = strtolower(ini_get('magic_quotes_sybase'));
  334.  
  335. if (TRUE == empty($mqs) || 'off' == $mqs){
  336. // we need to do stripslashes on $_GET, $_POST and $_COOKIE
  337. $rpg=stripslashes($rpg);
  338. }
  339. else{
  340. // we need to do str_replace("''", "'", ...) on $_GET, $_POST, $_COOKIE
  341. $rpg=str_replace("''","'",$rpg);
  342. }
  343. }*/
  344.  
  345. $value = stripslashes($value);
  346.  
  347. return $value;
  348. }
  349.  
  350. function version_warning(){ //Show warning if plugin is installed on a WordPress lower than 3.2
  351. global $wp_version;
  352. echo "<div id='piereg-warning' class='updated fade-ff0000'><p><strong>".__('Pie-Register is only compatible with WordPress v3.5 and up. You are currently using WordPress v.', 'piereg').$wp_version.". The plugin may not work as expected.</strong> </p></div>
  353. ";
  354.  
  355. }
  356.  
  357. function load_last(){
  358.  
  359. // Get array of active plugins
  360.  
  361. if( !$active_plugins = get_option('active_plugins') ) return;
  362.  
  363. // Set this plugin as variable
  364.  
  365. $my_plugin = 'pie-register/'.basename(__FILE__);
  366.  
  367. // See if my plugin is in the array
  368.  
  369. $key = array_search( $my_plugin, $active_plugins );
  370.  
  371. // If my plugin was found
  372.  
  373. if( $key !== FALSE ){
  374.  
  375. // Remove it from the array
  376.  
  377. unset( $active_plugins[$key] );
  378.  
  379. // Reset keys in the array
  380.  
  381. $active_plugins = array_values( $active_plugins );
  382.  
  383. // Add my plugin to the end
  384.  
  385. array_push( $active_plugins, $my_plugin );
  386.  
  387. // Resave the array of active plugins
  388.  
  389. update_option( 'active_plugins', $active_plugins );
  390.  
  391. }
  392.  
  393. }
  394.  
  395. function AddPanel(){ //Add the Settings and User Panels
  396. add_menu_page( "Pie Register Settings", 'Pie Register', 10, 'pie-register', array($this, 'RegPlusSettings') );
  397. add_submenu_page( 'pie-register', 'Payment Gateway Settings', 'Payment Gateway', 10, 'pie-gateway-settings', array($this, 'PieRegPaymentGateway') );
  398. add_submenu_page( 'pie-register', 'Email Notification Settings', 'Email Notification', 10, 'pie-email-notification', array($this, 'PieRegEmailNotification') );
  399. add_submenu_page( 'pie-register', 'Presentation Settings', 'Presentation Settings', 10, 'pie-presentation', array($this, 'PieRegPresentationSettings') );
  400. add_submenu_page( 'pie-register', 'Customised Site Messages', 'Customise Site Messages', 10, 'pie-custom-messages', array($this, 'PieRegCustomMessages') );
  401. //add_options_page( 'Pie Register', 'Pie Register', 10, 'pie-register', array($this, 'RegPlusSettings') );
  402. $piereg = get_option('pie_register');
  403. if( $piereg['email_verify'] || $piereg['admin_verify'] || $piereg['paypal_option'] )
  404. add_users_page( 'Unverified Users', 'Unverified Users', 10, 'unverified-users', array($this, 'Unverified') );
  405. }
  406.  
  407. function DefaultSettings () {
  408. $default = array(
  409. 'paypal_option' => '0',
  410. 'paypal_butt_id' => '',
  411. 'paypal_sandbox' => 'no',
  412. 'paypal_pdt' => '',
  413. 'loginredirect' => get_option('siteurl'),
  414. 'password' => '0',
  415. 'password_meter' => '0',
  416. 'short' => 'Too Short',
  417. 'bad' => 'Bad Password',
  418. 'good' => 'Good Password',
  419. 'strong' => 'Strong Password',
  420. 'mismatch' => 'Mis Match',
  421. 'code' => '0',
  422. 'codename' => 'Invitation',
  423. 'codepass' => '',
  424. 'codeexpiry' => '0',
  425. 'code_auto_del' => '0',
  426. 'Expcodepass' => '',
  427. 'captcha' => '0',
  428. 'disclaimer' => '0',
  429. 'disclaimer_title' => 'Disclaimer',
  430. 'disclaimer_content' => '',
  431. 'disclaimer_agree' => 'Accept the Disclaimer',
  432. 'license' => '0',
  433. 'license_title' => 'License Agreement',
  434. 'license_content' => '',
  435. 'license_agree' => 'Accept the License Agreement',
  436. 'privacy' => '0',
  437. 'privacy_title' => 'Privacy Policy',
  438. 'privacy_content' => '',
  439. 'privacy_agree' => 'Accept the Privacy Policy',
  440. 'email_exists' => '0',
  441. 'firstname' => '0',
  442. 'lastname' => '0',
  443. 'website' => '0',
  444. 'aim' => '0',
  445. 'yahoo' => '0',
  446. 'jabber' => '0',
  447. 'about' => '0',
  448. 'profile_req' => array('0'),
  449. 'require_style' => 'border:solid 1px #E6DB55;background-color:#FFFFE0;',
  450. 'dash_widget' => '0',
  451. 'email_verify' => '0',
  452. 'admin_verify' => '0',
  453. 'email_delete_grace' => '7',
  454. 'html' => '0',
  455. 'emailvmsghtml' => '0',
  456. 'adminvmsghtml' => '0',
  457. 'adminhtml' => '0',
  458. 'from' => get_option('admin_email'),
  459. 'fromname' => get_option('blogname'),
  460. 'subject' => sprintf(__('[%s] Your username and password', 'piereg'), get_option('blogname')),
  461. 'custom_msg' => '0',
  462. 'adminvmsguser_nl2br' => '0',
  463. 'adminvmsg' => " %blogname% Registration \r\n --------------------------- \r\n\r\n Here are your credentials: \r\n Username: %user_login% \r\n Password: %user_pass% \r\n Confirm Registration: %siteurl% \r\n\r\n Thank you for registering with %blogname%! \r\n",
  464. 'emailvmsguser_nl2br' => '0',
  465. 'emailvmsg' => " %blogname% Registration \r\n --------------------------- \r\n\r\n Here are your credentials: \r\n Username: %user_login% \r\n Password: %user_pass% \r\n Confirm Registration: %siteurl% \r\n\r\n Thank you for registering with %blogname%! \r\n",
  466. 'user_nl2br' => '0',
  467. 'msg' => " %blogname% Registration \r\n --------------------------- \r\n\r\n Here are your credentials: \r\n Username: %user_login% \r\n Password: %user_pass% \r\n Confirm Registration: %siteurl% \r\n\r\n Thank you for registering with %blogname%! \r\n",
  468. 'disable_admin' => '0',
  469. 'adminfrom' => get_option('admin_email'),
  470. 'adminfromname' => get_option('blogname'),
  471. 'adminsubject' => sprintf(__('[%s] New User Register', 'piereg'), get_option('blogname')),
  472. 'custom_adminmsg' => '0',
  473. 'admin_nl2br' => '0',
  474. 'adminmsg' => " New %blogname% Registration \r\n --------------------------- \r\n\r\n Username: %user_login% \r\n E-Mail: %user_email% \r\n",
  475. 'logo' => '',
  476. 'login_redirect' => get_option('siteurl'),
  477. 'register_css' => 'body{height:auto;} #login{width: 370px;} .login #pass-strength-result{width:295;}',
  478. 'login_css' => 'body{height:auto;}',
  479. 'firstday' => 6,
  480. 'dateformat' => 'mm/dd/yyyy',
  481. 'startdate' => '01/01/1901',
  482. 'calyear' => '1999',
  483. 'calmonth' => 'cur',
  484. '_admin_message_1' => 'Please select a user to validate!',
  485. '_admin_message_2' => 'Users Verified',
  486. '_admin_message_3' => 'Dear User,',
  487. '_admin_message_4' => 'You have successfuly registered but your payment has been overdue.',
  488. '_admin_message_5' => 'Please Click or copy this link to browser to finish the registration.',
  489. '_admin_message_6' => 'Thank you.',
  490. '_admin_message_7' => 'Payment Pending',
  491. '_admin_message_8' => 'Please select a user to send link to!',
  492. '_admin_message_9' => 'Payment link has been e-mail to the user(s)',
  493. '_admin_message_10' => 'Please select a user to delete',
  494. '_admin_message_12' => 'Users Deleted',
  495. '_admin_message_13' => 'Verification URL: ',
  496. '_admin_message_14' => 'Verify Account Link',
  497. '_admin_message_15' => 'Verification Emails have been re-sent',
  498. '_admin_message_16' => 'Please select a user to send emails to.',
  499. '_admin_message_17' => 'Your account has now been activated by an administrator.',
  500. '_admin_message_18' => 'User Account Registration',
  501. '_admin_message_19' => 'Please enter your First Name.',
  502. '_admin_message_20' => 'Please enter your Last Name.',
  503. '_admin_message_21' => 'Please enter your Website URL.',
  504. '_admin_message_22' => 'Please enter your AIM username.',
  505. '_admin_message_23' => 'Please enter your Yahoo IM username.',
  506. '_admin_message_24' => 'Please enter your Jabber / Google Talk username.',
  507. '_admin_message_25' => 'Please enter your Phone / Mobile number.',
  508. '_admin_message_26' => 'Please enter your Phone / Mobile number in correct formart No Alphabet No more 13 Variables.',
  509. '_admin_message_27' => 'Please enter some information About Yourself.',
  510. '_admin_message_28' => 'Please enter a Password.',
  511. '_admin_message_29' => 'Your Password does not match.',
  512. '_admin_message_30' => 'Your Password must be at least 6 characters in length.',
  513. '_admin_message_31' => 'Image Validation does not match.',
  514. '_admin_message_32' => 'The reCAPTCHA wasn\'t entered correctly.',
  515. '_admin_message_33' => 'Please accept the ',
  516. '_admin_message_34' => 'Please enter the ',
  517. '_admin_message_35' => 'Code has expired or no longer accepted.',
  518. '_admin_message_36' => 'Code is incorrect.',
  519. '_admin_message_37' => 'Please check your e-mail and click the verification link to activate your account and complete your registration.',
  520. '_admin_message_38' => 'This website is currently closed to public registrations. You will need a [prcodename] code to register.',
  521. '_admin_message_39' => 'Have a [prcodename] code? Enter it here. (This is not required)',
  522. '_admin_message_40' => 'Enter the text from the image.',
  523. '_admin_message_41' => 'Your account will be reviewed by an administrator and you will be notified when it is activated.',
  524. '_admin_message_42' => 'Please activate your account using the verification link sent to your email address.',
  525. '_admin_message_43' => 'Please click below to Continue and finish registration.',
  526. '_admin_message_44' => 'There is One-Time Subscription fee. Click to Complete your account registration.',
  527. '_admin_message_45' => 'your email has been verified. There is One-Time Subscription fee. Please Click below to Complete your account registration.',
  528. '_admin_message_46' => 'for registration, Please login.',
  529. '_admin_message_47' => 'your payment has been recieved. Please login to your account now!',
  530. '_admin_message_48' => 'You have successfully Paid for your membership.',
  531. '_admin_message_49' => 'There\'s an error while verifying your payment.',
  532. '_admin_message_50' => 'Thank you for your payment, we are verifying your payment! Please refresh this page in few seconds.'
  533. );
  534. # Get Previously Saved Items and put into new Settings
  535. if( get_option("paypal_option") )
  536. $default['paypal_option'] = get_option("paypal_option");
  537. if( get_option("paypal_butt_id") )
  538. $default['paypal_butt_id'] = get_option("paypal_butt_id");
  539. if( get_option("paypal_sandbox") )
  540. $default['paypal_sandbox'] = get_option("paypal_sandbox");
  541. if( get_option("paypal_pdt") )
  542. $default['paypal_pdt'] = get_option("paypal_pdt");
  543. if( get_option("loginredirect") )
  544. $default['loginredirect'] = get_option("loginredirect");
  545. if( get_option("piereg_password") )
  546. $default['password'] = get_option("piereg_password");
  547. if( get_option("piereg_code") )
  548. $default['code'] = get_option("piereg_code");
  549. if( get_option("piereg_codename") )
  550. $default['codename'] = get_option("piereg_codename");
  551. if( get_option("piereg_codepass") )
  552. $default['codepass'] = get_option("piereg_codepass");
  553. if( get_option("piereg_code_auto_del") )
  554. $default['code_auto_del'] = get_option("piereg_code_auto_del");
  555. if( get_option("piereg_codeexpiry") )
  556. $default['codeexpiry'] = get_option("piereg_codeexpiry");
  557. if( get_option("piereg_captcha") )
  558. $default['captcha'] = get_option("piereg_captcha");
  559. #Delete Previous Saved Items
  560. delete_option('paypal_option');
  561. delete_option('paypal_sandbox');
  562. delete_option('paypal_butt_id');
  563. delete_option('paypal_pdt');
  564. delete_option('loginredirect');
  565. delete_option('piereg_password');
  566. delete_option('piereg_code');
  567. delete_option('piereg_codename');
  568. delete_option('piereg_codepass');
  569. delete_option('piereg_code_auto_del');
  570. delete_option('piereg_codeexpiry');
  571. delete_option('piereg_captcha');
  572.  
  573. if($_POST['pieregister_reset']){
  574. update_option( 'pie_register', $default );
  575. delete_option( 'pie_register_custom' );
  576. }
  577. #Set Default Settings
  578. if( !get_option('pie_register') ){ #Set Defaults if no values exist
  579. add_option( 'pie_register', $default );
  580. }else{ #Set Defaults if new value does not exist
  581. $piereg = get_option( 'pie_register' );
  582. foreach( $default as $key => $val ){
  583. if( !$piereg[$key] ){
  584. $piereg[$key] = $val;
  585. $new = true;
  586. }
  587. }
  588. if( $new )
  589. update_option( 'pie_register', $piereg );
  590. }
  591. }
  592. function SaveSettings(){
  593. global $wpdb;
  594. check_admin_referer('piereg-update-options');
  595. $update = array();
  596. $update = get_option( 'pie_register' );
  597. $custom = get_option( 'pie_register_custom' );
  598. $update["paypal_option"] = $this->disable_magic_quotes_gpc($_POST['piereg_paypal_option']);
  599. if(isset($_POST['payment_gateway_page'])){
  600. $update["paypal_butt_id"] = $this->disable_magic_quotes_gpc($_POST['piereg_paypal_butt_id']);
  601. $update["paypal_pdt"] = $this->disable_magic_quotes_gpc($_POST['piereg_paypal_pdt']);
  602. $update["paypal_sandbox"] = $this->disable_magic_quotes_gpc($_POST['piereg_paypal_sandbox']);
  603. }
  604. if(isset($_POST['email_notification_page'])){
  605.  
  606. $update['html'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_html'],'HTML-ENTITIES','utf-8'));
  607. $update['from'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_from'],'HTML-ENTITIES','utf-8'));
  608. $update['fromname'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_fromname'],'HTML-ENTITIES','utf-8'));
  609. $update['subject'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_subject'],'HTML-ENTITIES','utf-8')));
  610. $update['custom_msg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_custom_msg'],'HTML-ENTITIES','utf-8')));
  611. $update['user_nl2br'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_user_nl2br']));
  612. $update['user_nl2br'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_emailvmsguser_nl2br']));
  613. $update['user_nl2br'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_adminvmsguser_nl2br']));
  614. $update['msg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_msg'],'HTML-ENTITIES','utf-8')));
  615. $update['adminvmsg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_adminvmsg'],'HTML-ENTITIES','utf-8')));
  616. $update['emailvmsg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_emailvmsg'],'HTML-ENTITIES','utf-8')));
  617. $update['disable_admin'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_disable_admin']));
  618. $update['adminhtml'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_adminhtml']));
  619. $update['adminfrom'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_adminfrom'],'HTML-ENTITIES','utf-8')));
  620. $update['adminfromname'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_adminfromname'],'HTML-ENTITIES','utf-8')));
  621. $update['adminsubject'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_adminsubject'],'HTML-ENTITIES','utf-8')));
  622. $update['custom_adminmsg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_custom_adminmsg'],'HTML-ENTITIES','utf-8')));
  623. $update['admin_nl2br'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_admin_nl2br']));
  624. $update['adminmsg'] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_adminmsg'],'HTML-ENTITIES','utf-8')));
  625. }
  626. if(isset($_POST['presentation_page'])){
  627. $update['register_css'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_register_css']));
  628. $update['login_css'] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_login_css']));
  629. }
  630. if(isset($_POST['pieregister_page'])){
  631. $update['login_redirect'] = $this->disable_magic_quotes_gpc($_POST['piereg_login_redirect']);
  632. $update['loginredirect'] = $this->disable_magic_quotes_gpc($_POST['piereg_loginredirect']);
  633. $update["password"] = $this->disable_magic_quotes_gpc($_POST['piereg_password']);
  634. $update["password_meter"] = $this->disable_magic_quotes_gpc($_POST['piereg_password_meter']);
  635. $update["short"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_short'],'HTML-ENTITIES','utf-8'));
  636. $update["bad"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_bad'],'HTML-ENTITIES','utf-8'));
  637. $update["good"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_good'],'HTML-ENTITIES','utf-8'));
  638. $update["strong"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_strong'],'HTML-ENTITIES','utf-8'));
  639. $update["mismatch"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_mismatch'],'HTML-ENTITIES','utf-8'));
  640. $update["code"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_code'],'HTML-ENTITIES','utf-8'));
  641. $update["custom_logo_url"] = $this->disable_magic_quotes_gpc($_POST['custom_logo_url']);
  642.  
  643. if(isset($_POST['piereg_codeexpiry']) && is_numeric($_POST['piereg_codeexpiry'])){
  644. $update["codeexpiry"] = $_POST['piereg_codeexpiry'];
  645. }
  646. $update["code_auto_del"] = $this->disable_magic_quotes_gpc($_POST['piereg_code_auto_del']);
  647. $update["codename"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($$_POST['piereg_codename'],'HTML-ENTITIES','utf-8'));
  648. if( isset($_POST['piereg_code']) ) {
  649. $update["codepass"] = $_POST['piereg_codepass'];
  650. $codespasses=explode("\n",$update["codepass"]);
  651. $piereg=get_option( 'pie_register' );
  652. $prefix=$wpdb->prefix."pieregister_";
  653. $codetable=$prefix."code";
  654. $wpdb->query("DELETE FROM ".$codetable." WHERE 1=1");
  655. $wpdb->flush();
  656. foreach( $codespasses as $k=>$v ){
  657. $this->InsertCode(trim($v));
  658. }
  659. $update["code_req"] = $this->disable_magic_quotes_gpc($_POST['piereg_code_req']);
  660. }
  661. $update["captcha"] = $this->disable_magic_quotes_gpc($_POST['piereg_captcha']);
  662. $update["disclaimer"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_disclaimer'],'HTML-ENTITIES','utf-8')));
  663. $update["disclaimer_title"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_disclaimer_title'],'HTML-ENTITIES','utf-8'));
  664. $update["disclaimer_content"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_disclaimer_content'],'HTML-ENTITIES','utf-8')));
  665. $update["disclaimer_agree"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_disclaimer_agree'],'HTML-ENTITIES','utf-8')));
  666. $update["license"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_license'],'HTML-ENTITIES','utf-8')));
  667. $update["license_title"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_license_title'],'HTML-ENTITIES','utf-8'));
  668. $update["license_content"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_license_content'],'HTML-ENTITIES','utf-8')));
  669. $update["license_agree"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_license_agree'],'HTML-ENTITIES','utf-8')));
  670. $update["privacy"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_privacy'],'HTML-ENTITIES','utf-8')));
  671. $update["privacy_title"] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg_privacy_title'],'HTML-ENTITIES','utf-8'));
  672. $update["privacy_content"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_privacy_content'],'HTML-ENTITIES','utf-8')));
  673. $update["privacy_agree"] = $this->disable_magic_quotes_gpc(htmlentities(mb_convert_encoding($_POST['piereg_privacy_agree'],'HTML-ENTITIES','utf-8')));
  674. $update["email_exists"] = $this->disable_magic_quotes_gpc($_POST['piereg_email_exists']);
  675. $update["firstname"] = $this->disable_magic_quotes_gpc($_POST['piereg_firstname']);
  676. $update["lastname"] = $this->disable_magic_quotes_gpc($_POST['piereg_lastname']);
  677. $update["website"] = $this->disable_magic_quotes_gpc(htmlentities($_POST['piereg_website']));
  678. $update["aim"] = $this->disable_magic_quotes_gpc($_POST['piereg_aim']);
  679. $update["yahoo"] = $this->disable_magic_quotes_gpc($_POST['piereg_yahoo']);
  680. $update["jabber"] = $this->disable_magic_quotes_gpc($_POST['piereg_jabber']);
  681. $update["phone"] = $this->disable_magic_quotes_gpc($_POST['piereg_phone']);
  682. $update["about"] = $this->disable_magic_quotes_gpc($_POST['piereg_about']);
  683. $update["profile_req"] = $this->disable_magic_quotes_gpc($_POST['piereg_profile_req']);
  684. $update["require_style"] = $this->disable_magic_quotes_gpc(($_POST['piereg_require_style']));
  685. $update["dash_widget"] = $this->disable_magic_quotes_gpc(($_POST['piereg_dash_widget']));
  686. $update["admin_verify"] = $this->disable_magic_quotes_gpc($_POST['piereg_admin_verify']);
  687. $update["email_verify"] = $this->disable_magic_quotes_gpc($_POST['piereg_email_verify']);
  688. $update["email_verify_date"] = $this->disable_magic_quotes_gpc($_POST['piereg_email_verify_date']);
  689. $update["email_delete_grace"] = $this->disable_magic_quotes_gpc($_POST['piereg_email_delete_grace']);
  690. $update["reCAP_public_key"] = $this->disable_magic_quotes_gpc($_POST['piereg_reCAP_public_key']);
  691. $update["reCAP_private_key"] = $this->disable_magic_quotes_gpc($_POST['piereg_reCAP_private_key']);
  692.  
  693.  
  694.  
  695. $update['firstday'] = ($_POST['piereg_firstday']);
  696. $update['dateformat'] = ($_POST['piereg_dateformat']);
  697. $update['startdate'] = ($_POST['piereg_startdate']);
  698. $update['calyear'] = ($_POST['piereg_calyear']);
  699. $update['calmonth'] = $_POST['piereg_calmonth'];
  700. if( $_FILES['piereg_logo']['name'] ) $update['logo'] = $this->UploadLogo();
  701. else if( $_POST['remove_logo'] ) $update['custom_logo_url'] = '';
  702.  
  703. if( $_POST['label'] ){
  704. foreach( $_POST['label'] as $k => $field ){
  705. if( $field )
  706. $custom[$k] = array( 'label' => $field, 'profile' => $_POST['profile'][$k], 'reg' => $_POST['reg'][$k], 'required' => $_POST['required'][$k], 'fieldtype' => $_POST['fieldtype'][$k], 'extraoptions' => $_POST['extraoptions'][$k] );
  707. }
  708. }
  709. }
  710. if(isset($_POST['customised_messages_page'])){
  711. $update['_admin_message_1'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_1'],'HTML-ENTITIES','utf-8'));
  712. $update['_admin_message_2'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_2'],'HTML-ENTITIES','utf-8'));
  713. $update['_admin_message_3'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_3'],'HTML-ENTITIES','utf-8'));
  714. $update['_admin_message_4'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_4'],'HTML-ENTITIES','utf-8'));
  715. $update['_admin_message_5'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_5'],'HTML-ENTITIES','utf-8'));
  716. $update['_admin_message_6'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_6'],'HTML-ENTITIES','utf-8'));
  717. $update['_admin_message_7'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_7'],'HTML-ENTITIES','utf-8'));
  718. $update['_admin_message_8'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_8'],'HTML-ENTITIES','utf-8'));
  719. $update['_admin_message_9'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_9'],'HTML-ENTITIES','utf-8'));
  720. $update['_admin_message_10'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_10'],'HTML-ENTITIES','utf-8'));
  721. $update['_admin_message_12'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_12'],'HTML-ENTITIES','utf-8'));
  722. $update['_admin_message_13'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_13'],'HTML-ENTITIES','utf-8'));
  723. $update['_admin_message_14'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_14'],'HTML-ENTITIES','utf-8'));
  724. $update['_admin_message_15'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_15'],'HTML-ENTITIES','utf-8'));
  725. $update['_admin_message_16'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_16'],'HTML-ENTITIES','utf-8'));
  726. $update['_admin_message_17'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_17'],'HTML-ENTITIES','utf-8'));
  727. $update['_admin_message_18'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_18'],'HTML-ENTITIES','utf-8'));
  728. $update['_admin_message_19'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_19'],'HTML-ENTITIES','utf-8'));
  729. $update['_admin_message_20'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_20'],'HTML-ENTITIES','utf-8'));
  730. $update['_admin_message_21'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_21'],'HTML-ENTITIES','utf-8'));
  731. $update['_admin_message_22'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_22'],'HTML-ENTITIES','utf-8'));
  732. $update['_admin_message_23'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_23'],'HTML-ENTITIES','utf-8'));
  733. $update['_admin_message_24'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_24'],'HTML-ENTITIES','utf-8'));
  734. $update['_admin_message_25'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_25'],'HTML-ENTITIES','utf-8'));
  735. $update['_admin_message_26'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_26'],'HTML-ENTITIES','utf-8'));
  736. $update['_admin_message_27'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_27'],'HTML-ENTITIES','utf-8'));
  737. $update['_admin_message_28'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_28'],'HTML-ENTITIES','utf-8'));
  738. $update['_admin_message_29'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_29'],'HTML-ENTITIES','utf-8'));
  739. $update['_admin_message_30'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_30'],'HTML-ENTITIES','utf-8'));
  740. $update['_admin_message_31'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_31'],'HTML-ENTITIES','utf-8'));
  741. $update['_admin_message_32'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_32'],'HTML-ENTITIES','utf-8'));
  742. $update['_admin_message_33'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_33'],'HTML-ENTITIES','utf-8'));
  743. $update['_admin_message_34'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_34'],'HTML-ENTITIES','utf-8'));
  744. $update['_admin_message_35'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_35'],'HTML-ENTITIES','utf-8'));
  745. $update['_admin_message_36'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_36'],'HTML-ENTITIES','utf-8'));
  746. $update['_admin_message_37'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_37'],'HTML-ENTITIES','utf-8'));
  747. $update['_admin_message_38'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_38'],'HTML-ENTITIES','utf-8'));
  748. $update['_admin_message_39'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_39'],'HTML-ENTITIES','utf-8'));
  749. $update['_admin_message_40'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_40'],'HTML-ENTITIES','utf-8'));
  750. $update['_admin_message_41'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_41'],'HTML-ENTITIES','utf-8'));
  751. $update['_admin_message_42'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_42'],'HTML-ENTITIES','utf-8'));
  752. $update['_admin_message_43'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_43'],'HTML-ENTITIES','utf-8'));
  753. $update['_admin_message_44'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_44'],'HTML-ENTITIES','utf-8'));
  754. $update['_admin_message_45'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_45'],'HTML-ENTITIES','utf-8'));
  755. $update['_admin_message_46'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_46'],'HTML-ENTITIES','utf-8'));
  756. $update['_admin_message_47'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_47'],'HTML-ENTITIES','utf-8'));
  757. $update['_admin_message_48'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_48'],'HTML-ENTITIES','utf-8'));
  758. $update['_admin_message_49'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_49'],'HTML-ENTITIES','utf-8'));
  759. $update['_admin_message_50'] = $this->disable_magic_quotes_gpc(mb_convert_encoding($_POST['piereg__admin_message_50'],'HTML-ENTITIES','utf-8'));
  760. }
  761.  
  762. update_option( 'pie_register_custom', $custom );
  763. update_option( 'pie_register', $update );
  764. $_POST['notice'] = __('Settings Saved', 'piereg');
  765. }
  766. /*Deprecated Function*/
  767. function UploadLogo(){
  768. $upload_dir = ABSPATH . get_option('upload_path');
  769. if(!empty($upload_dir)) $upload_dir=ABSPATH.'wp-content/uploads';
  770. $upload_file = trailingslashit($upload_dir) . basename($_FILES['piereg_logo']['name']);
  771. //echo $upload_file;
  772. if( !is_dir($upload_dir) )
  773. wp_upload_dir();
  774. if( move_uploaded_file($_FILES['piereg_logo']['tmp_name'], $upload_file) ){
  775. chmod($upload_file, 0777);
  776. $logo = $_FILES['piereg_logo']['name'];
  777. return trailingslashit( get_option('siteurl') ) . 'wp-content/uploads/' . $logo;
  778. }else{
  779. return false;
  780. }
  781. }
  782.  
  783. function ProfilesHead(){
  784. $piereg=get_option( 'pie_register' );
  785. ?>
  786. <script type="text/javascript" src="<?php echo $this->plugin_url;?>datepicker/date.js"></script>
  787. <!--[if IE]><script type="text/javascript" src="<?php echo $plugin_url;?>datepicker/jquery.bgiframe.min.js"></script><![endif]-->
  788.  
  789. <!-- jquery.datePicker.js -->
  790. <script type="text/javascript" src="<?php echo $this->plugin_url;?>datepicker/jquery.datePicker.js"></script>
  791. <link href="<?php echo $this->plugin_url;?>datepicker/datePicker.css" rel="stylesheet" type="text/css" />
  792. <script type="text/javascript">
  793. jQuery.dpText = {
  794. TEXT_PREV_YEAR : '<?php _e('Previous year','piereg');?>',
  795. TEXT_PREV_MONTH : '<?php _e('Previous month','piereg');?>',
  796. TEXT_NEXT_YEAR : '<?php _e('Next year','piereg');?>',
  797. TEXT_NEXT_MONTH : '<?php _e('Next Month','piereg');?>',
  798. TEXT_CLOSE : '<?php _e('Close','piereg');?>',
  799. TEXT_CHOOSE_DATE : '<?php _e('Choose Date','piereg');?>'
  800. }
  801.  
  802. Date.dayNames = ['<?php _e('Monday','piereg');?>', '<?php _e('Tuesday','piereg');?>', '<?php _e('Wednesday','piereg');?>', '<?php _e('Thursday','piereg');?>', '<?php _e('Friday','piereg');?>', '<?php _e('Saturday','piereg');?>', '<?php _e('Sunday','piereg');?>'];
  803. Date.abbrDayNames = ['<?php _e('Mon','piereg');?>', '<?php _e('Tue','piereg');?>', '<?php _e('Wed','piereg');?>', '<?php _e('Thu','piereg');?>', '<?php _e('Fri','piereg');?>', '<?php _e('Sat','piereg');?>', '<?php _e('Sun','piereg');?>'];
  804. Date.monthNames = ['<?php _e('January','piereg');?>', '<?php _e('February','piereg');?>', '<?php _e('March','piereg');?>', '<?php _e('April','piereg');?>', '<?php _e('May','piereg');?>', '<?php _e('June','piereg');?>', '<?php _e('July','piereg');?>', '<?php _e('August','piereg');?>', '<?php _e('September','piereg');?>', '<?php _e('October','piereg');?>', '<?php _e('November','piereg');?>', '<?php _e('December','piereg');?>'];
  805. Date.abbrMonthNames = ['<?php _e('Jan','piereg');?>', '<?php _e('Feb','piereg');?>', '<?php _e('Mar','piereg');?>', '<?php _e('Apr','piereg');?>', '<?php _e('May','piereg');?>', '<?php _e('Jun','piereg');?>', '<?php _e('Jul','piereg');?>', '<?php _e('Aug','piereg');?>', '<?php _e('Sep','piereg');?>', '<?php _e('Oct','piereg');?>', '<?php _e('Nov','piereg');?>', '<?php _e('Dec','piereg');?>'];
  806. Date.firstDayOfWeek = <?php echo $piereg['firstday'];?>;
  807. Date.format = '<?php echo $piereg['dateformat'];?>';
  808. jQuery(function() {
  809. jQuery('.date-pick').datePicker({
  810. clickInput:true,
  811. startDate:'<?php echo $piereg['startdate'];?>',
  812. year:<?php if($piereg['calyear']){echo $piereg['calyear'];}else{echo date("Y");}?>,
  813. month:<?php if( $piereg['calmonth'] != 'cur' ) echo $piereg['calmonth']-1; else echo date('n')-1;?>
  814. })
  815. });
  816. </script>
  817. <style type="text/css">
  818. a.dp-choose-date { float: left; width: 16px; height: 16px; padding: 0; margin: 5px 3px 0; display: block; text-indent: -2000px; overflow: hidden; background: url(<?php echo $this->plugin_url;?>datepicker/calendar.png) no-repeat; } a.dp-choose-date.dp-disabled { background-position: 0 -20px; cursor: default; } /* makes the input field shorter once the date picker code * has run (to allow space for the calendar icon */ input.dp-applied { width: 140px; float: left; }
  819. </style>
  820. <?php
  821. }
  822. function SettingsHead(){
  823.  
  824. $piereg = get_option( 'pie_register' );
  825.  
  826. ?>
  827. <script type="text/javascript">
  828. <?php
  829. require_once($this->plugin_dir.'/js/pie-register-main.js');
  830. ?>
  831. </script>
  832.  
  833. <style type="text/css">
  834.  
  835. #pie-register{
  836. line-height:16px;
  837. }
  838. #pie-register .label{
  839. display:inline;
  840. }
  841. .expired_code{
  842. width:240px;
  843. border:1px solid #333333;
  844. background-color:#e1e1e1;
  845. max-height:100px;
  846. overflow:auto;
  847. margin-bottom:10px;
  848. padding:5px 10px;
  849. }
  850. </style>
  851. <?php
  852. }
  853. function UnverifiedHead(){
  854. if( $_GET['page'] == 'unverified-users')
  855. echo "<script type='text/javascript' src='".get_option('siteurl')."/wp-admin/js/forms.js?ver=20080317'></script>";
  856. }
  857. function AdminValidate(){
  858. global $wpdb;
  859. $piereg = get_option('pie_register');
  860. check_admin_referer('piereg-unverified');
  861. $valid = $_POST['vusers'];
  862. if($valid){
  863. foreach( $valid as $user_id ){
  864. if ( $user_id ) {
  865. update_user_meta( $user_id, 'admin_verified_user','yes');
  866. if( $piereg['email_verify'] ){
  867. $login = get_user_meta($user_id, 'email_verify_user',true);
  868. $useremail=get_user_meta($user_id,'email_verify_email',true);
  869. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$useremail' WHERE ID = '$user_id'" );
  870. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" );
  871. delete_user_meta($user_id, 'email_verify_user');
  872. delete_user_meta($user_id, 'email_verify');
  873. delete_user_meta($user_id, 'email_verify_date');
  874. delete_user_meta($user_id, 'email_verify_user_email');
  875.  
  876. }else if( $piereg['admin_verify'] ){
  877. $login = get_user_meta($user_id, 'admin_verify_user',true);
  878. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" );
  879. $useremail=get_user_meta($user_id,'email_verify_email',true);
  880. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$useremail' WHERE ID = '$user_id'" );
  881. delete_user_meta($user_id, 'admin_verify_user');
  882. delete_user_meta($user_id, 'email_verify_user_email');
  883. }else if( $piereg['paypal_option'] ){
  884. $login = get_user_meta($user_id, 'email_verify_user',true);
  885. $useremail=get_user_meta($user_id,'email_verify_email',true);
  886. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$useremail' WHERE ID = '$user_id'" );
  887. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" );
  888. delete_user_meta($user_id, 'email_verify_user_email');
  889. delete_user_meta($user_id, 'email_verify_user');
  890. delete_user_meta($user_id, 'email_verify');
  891. delete_user_meta($user_id, 'email_verify_date');
  892. }
  893.  
  894. $this->VerifyNotification($user_id);
  895. }
  896. }
  897. }else{
  898. $_POST['notice'] = __("<strong>Error:</strong> ".$piereg['_admin_message_1'],"piereg");
  899. return false;
  900. }
  901. $_POST['notice'] = __($piereg['_admin_message_2'],"piereg");
  902.  
  903. }
  904. function PaymentLink(){
  905. global $wpdb;
  906. $piereg = get_option('pie_register');
  907. check_admin_referer('piereg-unverified');
  908. $valid = $_POST['vusers'];
  909. if($valid){
  910. foreach( $valid as $user_id ){
  911. if ( $user_id ) {
  912. if( $piereg['email_verify'] || $piereg['paypal_option']){
  913. $login = get_user_meta($user_id, 'email_verify_user',true);
  914. if(!$login)
  915. $login = get_user_meta($user_id, 'admin_verify_user',true);
  916. $user_email = get_user_meta($user_id, 'email_verify_email',true);
  917. if($piereg['paypal_sandbox'] == "yes") $pp=SSL_SAND_URL."?cmd=_s-xclick&hosted_button_id=".$piereg['paypal_butt_id']."&custom=".$user_id;
  918. else $pp=SSL_P_URL."?cmd=_s-xclick&hosted_button_id=".$piereg['paypal_butt_id']."&custom=".$user_id;
  919.  
  920.  
  921.  
  922. }else if( $piereg['admin_verify'] ){
  923. $login = get_user_meta($user_id, 'admin_verify_user',true);
  924. if(!$login)
  925. $login = get_user_meta($user_id, 'email_verify_user',true);
  926. $user_email = get_user_meta($user_id, 'email_verify_email',true);
  927. if($piereg['paypal_sandbox'] == "yes") $pp=SSL_SAND_URL."?cmd=_s-xclick&hosted_button_id=".$piereg['paypal_butt_id']."&custom=".$user_id;
  928. else $pp=SSL_P_URL."?cmd=_s-xclick&hosted_button_id=".$piereg['paypal_butt_id']."&custom=".$user_id;
  929. }
  930. $message = __($piereg['_admin_message_3']) . "\r\n\r\n";
  931. $message .= __($piereg['_admin_message_4']) . "\r\n";
  932. $message .= sprintf(__('Username: %s', 'piereg'), $login) . "\r\n\r\n";
  933. $message .= __($piereg['_admin_message_5']) . "\r\n\r\n";
  934. $message .= $pp." \r\n ".$piereg['_admin_message_6']." \r\n";
  935. add_filter('wp_mail_from', array($this, 'userfrom'));
  936. add_filter('wp_mail_from_name', array($this, 'userfromname'));
  937. wp_mail($user_email, sprintf(__('[%s] '.$piereg['_admin_message_7'], 'piereg'), get_option('blogname')), $message);
  938. //$this->VerifyNotification($user_id,$pp);
  939. }
  940. }
  941. }else{
  942. $_POST['notice'] = __("<strong>Error:</strong> ".$piereg['_admin_message_8'],"piereg");
  943. return false;
  944. }
  945. $_POST['notice'] = __($piereg['_admin_message_9'],"piereg");
  946.  
  947. }
  948. function AdminDeleteUnvalidated() {
  949. global $wpdb;
  950. $piereg = get_option('pie_register');
  951. check_admin_referer('piereg-unverified');
  952. $delete = $_POST['vusers'];
  953. include_once( ABSPATH . 'wp-admin/includes/user.php' );
  954. if($delete){
  955. foreach( $delete as $user_id ){
  956. if ( $user_id ) {
  957. wp_delete_user($user_id);
  958. }
  959. }
  960. }else{
  961. $_POST['notice'] = __("<strong>Error:</strong> ".$piereg['_admin_message_10'],"piereg");
  962. return false;
  963. }
  964. $_POST['notice'] = __($piereg['_admin_message_12'],"piereg");
  965. }
  966. function AdminEmailValidate(){
  967. global $wpdb;
  968. check_admin_referer('piereg-unverified');
  969. $valid = $_POST['vusers'];
  970. if( is_array($valid) ):
  971. foreach( $valid as $user_id ){
  972. $code = get_user_meta($user_id, 'email_verify',true);
  973. if(empty($code)){
  974. $code = $this->RanPass(25);
  975. update_usermeta( $user_id, 'email_verify', $code );
  976. update_usermeta( $user_id, 'email_verify_date', date('Ymd') );
  977.  
  978. $email_code = '?piereg_verification=' . $code;
  979. }
  980. //$code = get_user_meta($user_id, 'email_verify',true);
  981. $user_login = get_user_meta($user_id, 'email_verify_user',true);
  982. if(empty($user_login)){
  983. $user_login = get_user_meta($user_id, 'admin_verify_user',true);
  984. }
  985. $user_email = get_user_meta($user_id, 'email_verify_email',true);
  986. $email_code = '?piereg_verification=' . $code;
  987.  
  988.  
  989.  
  990.  
  991. $prelink = __($piereg['_admin_message_13'], 'piereg');
  992. $message = sprintf(__('Username: %s', 'piereg'), $user_login) . "\r\n";
  993. //$message .= sprintf(__('Password: %s', 'piereg'), $plaintext_pass) . "\r\n";
  994. $message .= $prelink . get_option('siteurl') . "/wp-login.php" . $email_code . "\r\n";
  995. $message .= $notice;
  996. add_filter('wp_mail_from', array($this, 'userfrom'));
  997. add_filter('wp_mail_from_name', array($this, 'userfromname'));
  998. wp_mail($user_email, sprintf(__('[%s] '.$piereg['_admin_message_14'], 'piereg'), get_option('blogname')), $message);
  999.  
  1000. }
  1001. $_POST['notice'] = __($piereg['_admin_message_15'], "piereg");
  1002. else:
  1003. $_POST['notice'] = __("<strong>Error:</strong> ".$piereg['_admin_message_16'], "piereg");
  1004. endif;
  1005. }
  1006. function VerifyNotification($user_id,$pp=""){
  1007. global $wpdb;
  1008. $piereg = get_option('pie_register');
  1009.  
  1010. //$user = $wpdb->get_row("SELECT user_login, user_email FROM $wpdb->users WHERE ID='$user_id'");
  1011. $user = get_user_by('id', $user_id);
  1012. $message = __($piereg['_admin_message_17']) . "\r\n";
  1013. $message .= sprintf(__('Username: %s', 'piereg'), $user->user_login) . "\r\n";
  1014. $message .= $prelink . get_option('siteurl') . "/wp-login.php" . "\r\n";
  1015. $user_email=get_user_meta($user_id, 'email_verify_email',true);
  1016.  
  1017. add_filter('wp_mail_from', array($this, 'userfrom'));
  1018. add_filter('wp_mail_from_name', array($this, 'userfromname'));
  1019. wp_mail($user_email, sprintf(__('[%s] '.$piereg['_admin_message_18'], 'piereg'), get_option('blogname')), $message);
  1020. }
  1021. function Unverified(){
  1022. global $wpdb;
  1023. if( $_POST['notice'] )
  1024. echo '<div id="message" class="updated fade"><p><strong>' . $_POST['notice'] . '.</strong></p></div>';
  1025.  
  1026. $unverified = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_login LIKE '%unverified__%'");
  1027. $piereg = get_option('pie_register');
  1028. ?>
  1029. <div class="wrap">
  1030. <h2><?php _e('Unverified Users', 'piereg')?></h2>
  1031. <form id="verify-filter" method="post" action="">
  1032. <?php if( function_exists( 'wp_nonce_field' )) wp_nonce_field( 'piereg-unverified'); ?>
  1033. <div class="tablenav">
  1034. <div class="alignleft">
  1035. <input value="<?php _e('Verify Checked Users','piereg');?>" name="verifyit" class="button-secondary" type="submit"> &nbsp;<?php if( $piereg['paypal_option'] ){ ?> <input value="<?php _e('Send Payment Link','piereg');?>" name="paymentl" class="button-secondary" type="submit"><?php } ?> &nbsp; <?php if( $piereg['email_verify'] ){ ?>
  1036. <input value="<?php _e('Resend Verification E-mail','piereg');?>" name="emailverifyit" class="button-secondary" type="submit"> <?php } ?> &nbsp; <input value="<?php _e('Delete','piereg');?>" name="vdeleteit" class="button-secondary delete" type="submit">
  1037. </div>
  1038. <br class="clear">
  1039. </div>
  1040.  
  1041. <br class="clear">
  1042.  
  1043. <table class="widefat">
  1044. <thead>
  1045. <tr class="thead">
  1046. <th scope="col" class="check-column"><input onclick="checkAll(document.getElementById('verify-filter'));" type="checkbox"> </th>
  1047. <th><?php _e('Unverified ID','piereg');?></th>
  1048. <th><?php _e('User Name','piereg');?></th>
  1049. <th><?php _e('E-mail','piereg');?></th>
  1050. <th><?php _e('Role','piereg');?></th>
  1051. </tr>
  1052. </thead>
  1053. <tbody id="users" class="list:user user-list">
  1054. <?php
  1055. foreach( $unverified as $un) {
  1056. if( $alt ) $alt = ''; else $alt = "alternate";
  1057. $user_object = new WP_User($un->ID);
  1058. $roles = $user_object->roles;
  1059. $role = array_shift($roles);
  1060. if( $piereg['email_verify'] )
  1061. $user_login = get_user_meta($un->ID, 'email_verify_user',true);
  1062. else if( $piereg['admin_verify'] )
  1063. $user_login = get_user_meta($un->ID, 'admin_verify_user',true);
  1064. ?>
  1065. <tr id="user-1" class="<?php echo $alt;?>">
  1066. <th scope="row" class="check-column"><input name="vusers[]" id="user_<?php echo $un->ID;?>" class="administrator" value="<?php echo $un->ID;?>" type="checkbox"></th>
  1067. <td><strong><?php echo $un->user_login;?></strong></td>
  1068. <td><strong><?php echo $user_login;?></strong></td>
  1069.  
  1070. <td><a href="mailto:<?php echo $un->user_email;?>" title="<?php _e('e-mail: ', 'piereg'); echo $un->user_email;?>"><?php echo $un->user_email;?></a></td>
  1071. <td><?php echo ucwords($role);?></td>
  1072. </tr>
  1073. <?php } ?>
  1074. </tbody>
  1075. </table>
  1076. </form>
  1077. </div>
  1078.  
  1079.  
  1080. <?php
  1081. }
  1082.  
  1083. function RegPlusSettings(){
  1084. //error_reporting(E_ALL);
  1085.  
  1086. require_once($this->plugin_dir.'/menus/pieregisterSettings.php');
  1087. }
  1088. function PieRegPaymentGateway(){
  1089.  
  1090. require_once($this->plugin_dir.'/menus/PieRegPaymentGateway.php');
  1091.  
  1092. }
  1093. function PieRegPresentationSettings(){
  1094.  
  1095. require_once($this->plugin_dir.'/menus/PieRegPresentationSettings.php');
  1096. }
  1097. function PieRegEmailNotification(){
  1098.  
  1099. require_once($this->plugin_dir.'/menus/PieRegEmailNotification.php');
  1100. }
  1101. function PieRegCustomMessages(){
  1102.  
  1103. require_once($this->plugin_dir.'/menus/PieRegCustomMessages.php');
  1104. }
  1105. function count_multiple_accounts( $email, $user_id = null ) {
  1106. global $wpdb;
  1107. $sql = "SELECT COUNT(*) AS count FROM $wpdb->users WHERE user_email = %s";
  1108. if ( $user_id )
  1109. $sql .= ' AND ID != %d';
  1110. return (int) $wpdb->get_var( $wpdb->prepare( $sql, $email, $user_id ) );
  1111. }
  1112.  
  1113. function get_users_by_email( $email ) {
  1114. return get_users( array( 'search' => $email, 'blog_id' => '' ) );
  1115. }
  1116.  
  1117. function has_multiple_accounts( $email ) {
  1118. return $this->count_multiple_accounts( $email ) > 1 ? true : false;
  1119. }
  1120.  
  1121. function retrieve_password( $user_login ) {
  1122. $this->retrieve_password_for = $user_login;
  1123.  
  1124. return $user_login;
  1125. }
  1126. function retrieve_password_message( $message, $key ) {
  1127. $user = get_user_by( 'login', $this->retrieve_password_for );
  1128. $pending_payment = get_user_meta( $user->ID, 'pending_payment', true );
  1129. $email_verify = get_user_meta( $user->ID, 'email_verify_user', true );
  1130. $admin_verify = get_user_meta( $user->ID, 'admin_verify_user', true );
  1131. if($pending_payment || $email_verify || $admin_verify){
  1132. $message.='Hello,
  1133. You can not reset the password for your primary username.
  1134. ';
  1135. }
  1136. if ( $this->has_multiple_accounts( $user->user_email ) ) {
  1137. $message .= "\r\n\r\n";
  1138. $message .= __( 'For your information, there are multiple accounts associated with your email:', 'piereg' ) . "\r\n\r\n";
  1139. foreach ( $this->get_users_by_email( $user->user_email ) as $user ) {
  1140. $pending_payment = get_user_meta( $user->ID, 'pending_payment', true );
  1141. $email_verify = get_user_meta( $user->ID, 'email_verify_user', true );
  1142. $admin_verify = get_user_meta( $user->ID, 'admin_verify_user', true );
  1143. if($pending_payment || $email_verify || $admin_verify){
  1144. continue;
  1145. }
  1146. $message .= "To reset password for username " . $user->user_login . ", Please follow the link below:\r\n";
  1147. $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
  1148. $cnt+=1;
  1149. }
  1150. if($cnt){
  1151. $message .= "\r\n";
  1152. $message .= __( 'In order to reset the password for any of these (if you aren\'t already successfully in the middle of doing so already), you should specify the login when requesting a password reset rather than using your e-mail.', 'piereg' ) . "\r\n\r\n";
  1153. }
  1154. }
  1155. return $message;
  1156. }
  1157. # Check Required Fields
  1158. function RegErrors($errors){
  1159. $CeRror=0;
  1160. $piereg = get_option( 'pie_register' );
  1161. $piereg_custom = get_option( 'pie_register_custom' );
  1162. $Cexpiry=$piereg['codeexpiry'];
  1163. if( !is_array( $piereg_custom ) ) $piereg_custom = array();
  1164.  
  1165. if( $piereg['email_exists'] ){
  1166.  
  1167. if ( $errors->errors['email_exists'] ){
  1168. unset($errors->errors['email_exists']);
  1169. }
  1170.  
  1171. }else{
  1172. if ( $errors->errors['email_exists'] ){
  1173. $CeRror=1;
  1174. }
  1175. }
  1176.  
  1177. if( $piereg['firstname'] && in_array('firstname', $piereg['profile_req']) ){
  1178. if(empty($_POST['firstname']) || $_POST['firstname'] == ''){
  1179. $errors->add('empty_firstname', __('<strong>ERROR</strong>: '.$piereg['_admin_message_19'], 'piereg'));
  1180. $CeRror=1;
  1181. }
  1182. }
  1183. if( $piereg['lastname'] && in_array('lastname', $piereg['profile_req']) ){
  1184. if(empty($_POST['lastname']) || $_POST['lastname'] == ''){
  1185. $errors->add('empty_lastname', __('<strong>ERROR</strong>: '.$piereg['_admin_message_20'], 'piereg'));
  1186. $CeRror=1;
  1187. }
  1188. }
  1189. if( $piereg['website'] && in_array('website', $piereg['profile_req']) ){
  1190. if(empty($_POST['website']) || $_POST['website'] == ''){
  1191. $errors->add('empty_website', __('<strong>ERROR</strong>: '.$piereg['_admin_message_21'], 'piereg'));
  1192. $CeRror=1;
  1193. }
  1194. }
  1195. if( $piereg['aim'] && in_array('aim', $piereg['profile_req']) ){
  1196. if(empty($_POST['aim']) || $_POST['aim'] == ''){
  1197. $errors->add('empty_aim', __('<strong>ERROR</strong>: '.$piereg['_admin_message_22'], 'piereg'));
  1198. $CeRror=1;
  1199. }
  1200. }
  1201. if( $piereg['yahoo'] && in_array('yahoo', $piereg['profile_req']) ){
  1202. if(empty($_POST['yahoo']) || $_POST['yahoo'] == ''){
  1203. $errors->add('empty_yahoo', __('<strong>ERROR</strong>: '.$piereg['_admin_message_23'], 'piereg'));
  1204. $CeRror=1;
  1205. }
  1206. }
  1207. if( $piereg['jabber'] && in_array('jabber', $piereg['profile_req']) ){
  1208. if(empty($_POST['jabber']) || $_POST['jabber'] == ''){
  1209. $errors->add('empty_jabber', __('<strong>ERROR</strong>: '.$piereg['_admin_message_24'], 'piereg'));
  1210. $CeRror=1;
  1211. }
  1212. }
  1213. if( $piereg['phone'] && in_array('phone', $piereg['profile_req']) ){
  1214. if(empty($_POST['phone']) || $_POST['phone'] == ''){
  1215. $errors->add('empty_phone', __('<strong>ERROR</strong>: '.$piereg['_admin_message_25'], 'piereg'));
  1216. $CeRror=1;
  1217. }else if(preg_match('/\D/ism',$_POST['phone']) || (strlen($_POST['phone'])>13) || (strlen($_POST['phone'])<7)){
  1218. $errors->add('Wrong_Phone', __('<strong>ERROR</strong>: '.$piereg['_admin_message_26'], 'piereg'));
  1219. $CeRror=1;
  1220. }
  1221. }
  1222. if( $piereg['about'] && in_array('about', $piereg['profile_req']) ){
  1223. if(empty($_POST['about']) || $_POST['about'] == ''){
  1224. $errors->add('empty_about', __('<strong>ERROR</strong>: '.$piereg['_admin_message_27'], 'piereg'));
  1225. $CeRror=1;
  1226. }
  1227. }
  1228. if (!empty($piereg_custom)) {
  1229. foreach( $piereg_custom as $k=>$v ){
  1230. if( $v['required'] && $v['reg'] ){
  1231. $id = str_replace('.','_',$this->Label_ID($v['label']));
  1232. if(empty($_POST[$id]) || $_POST[$id] == ''){
  1233. $errors->add('empty_' . $id, __('<strong>ERROR</strong>: Please enter your ' . $v['label'] . '.', 'piereg'));
  1234. $CeRror=1;
  1235. }
  1236. }
  1237. }
  1238. }
  1239.  
  1240. if ( $piereg['password'] ){
  1241. if(empty($_POST['pass1']) || $_POST['pass1'] == '' || empty($_POST['pass2']) || $_POST['pass2'] == ''){
  1242. $errors->add('empty_password', __('<strong>ERROR</strong>: '.$piereg['_admin_message_28'], 'piereg'));
  1243. $CeRror=1;
  1244. }elseif($_POST['pass1'] !== $_POST['pass2']){
  1245. $errors->add('password_mismatch', __('<strong>ERROR</strong>: '.$piereg['_admin_message_29'], 'piereg'));
  1246. $CeRror=1;
  1247. }elseif(strlen($_POST['pass1'])<6){
  1248. $errors->add('password_length', __('<strong>ERROR</strong>: '.$piereg['_admin_message_30'], 'piereg'));
  1249. $CeRror=1;
  1250. }else{
  1251. $_POST['user_pw'] = $_POST['pass1'];
  1252. }
  1253. }
  1254.  
  1255.  
  1256. if ( $piereg['captcha'] == 1 ){
  1257.  
  1258. $key = $_SESSION['1k2j48djh'];
  1259. $number = md5($_POST['captcha']);
  1260. if($number!=$key){
  1261. $errors->add('captcha_mismatch', __("<strong>ERROR</strong>: ".$piereg['_admin_message_31'], 'piereg'));
  1262. $CeRror=1;
  1263. unset($_SESSION['1k2j48djh']);
  1264. }
  1265. } else if ( $piereg['captcha'] == 2){
  1266. require_once('recaptchalib.php');
  1267. $privatekey = $piereg['reCAP_private_key'];
  1268. $resp = recaptcha_check_answer ($privatekey,
  1269.  
  1270. $_SERVER["REMOTE_ADDR"],
  1271. $_POST["recaptcha_challenge_field"],
  1272. $_POST["recaptcha_response_field"]);
  1273.  
  1274. if (!$resp->is_valid) {
  1275. $errors->add('recaptcha_mismatch', __("<strong>ERROR:</strong> ".$piereg['_admin_message_32'], 'piereg'));
  1276. $CeRror=1;
  1277. //$errors->add('recaptcha_error', "(" . __("reCAPTCHA said: ", 'piereg') . $resp->error . ")");
  1278. }
  1279. }
  1280.  
  1281. if ( $piereg['disclaimer'] ){
  1282. if(!$_POST['disclaimer']){
  1283. $errors->add('disclaimer', __('<strong>ERROR</strong>: '.$piereg['_admin_message_33'], 'piereg') . stripslashes( $piereg['disclaimer_title'] ) . '.');
  1284. $CeRror=1;
  1285. }
  1286. }
  1287. if ( $piereg['license'] ){
  1288. if(!$_POST['license']){
  1289. $errors->add('license', __('<strong>ERROR</strong>: '.$piereg['_admin_message_33'], 'piereg') . stripslashes( $piereg['license_title'] ) . '.');
  1290. $CeRror=1;
  1291. }
  1292. }
  1293. if ( $piereg['privacy'] ){
  1294. if(!$_POST['privacy']){
  1295. $errors->add('privacy', __('<strong>ERROR</strong>: '.$piereg['_admin_message_33'], 'piereg') . stripslashes( $piereg['privacy_title'] ) . '.');
  1296. $CeRror=1;
  1297. }
  1298. }
  1299.  
  1300. if ( $piereg['code'] && $piereg['code_req'] ){
  1301. $pieregcodes=explode("\n", $piereg['codepass']);
  1302. foreach($pieregcodes as $key=>$val){
  1303. $Pieregcodes[$key]=trim($val);
  1304. }
  1305. if(empty($_POST['regcode']) || $_POST['regcode'] == ''){
  1306. $errors->add('empty_regcode', __('<strong>ERROR</strong>: '.$piereg['_admin_message_34'].' '.$piereg['codename'].' Code.', 'piereg'));
  1307. $CeRror=1;
  1308. }elseif( ($Cexpiry > 0) && $this->SelectCode($_POST['regcode']) == $Cexpiry ){
  1309. //$this->UpdateCode($_POST['regcode']);
  1310. $errors->add('expired_regcode', __('<strong>ERROR</strong>: Your '.$piereg['codename'].' '.$piereg['_admin_message_35'], 'piereg'));
  1311. $CeRror=1;
  1312. }elseif( !in_array($_POST['regcode'], $Pieregcodes) ){
  1313. $errors->add('regcode_mismatch', __('<strong>ERROR</strong>: Your '.$piereg['codename'].' '.$piereg['_admin_message_36'], 'piereg'));
  1314. $CeRror=1;
  1315. }else{
  1316. if($CeRror != 1){
  1317. $this->UpdateCode($_POST['regcode']);
  1318. }
  1319. }
  1320. }
  1321. /*session_start();*/
  1322. $_SESSION['secure_id']=$_POST['user_login'];
  1323. setcookie("session_secure_id", $_POST['user_login'], time()+172800, "/", COOKIE_DOMAIN);
  1324. //Will be Deprecated Soon
  1325. //session_register($_SESSION['secure_id']);
  1326. return $errors;
  1327. }
  1328.  
  1329. function RegMsg($errors){
  1330. $piereg = get_option( 'pie_register' );
  1331.  
  1332. /*session_start();*/
  1333. if ( $errors->errors['registered'] ){
  1334. unset($errors->errors['registered']);
  1335. unset( $errors->error_data['email_exists'] );
  1336. }
  1337. if ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $errors->add('registeredit', __($piereg['_admin_message_37']), 'message');
  1338. return $errors;
  1339. }
  1340.  
  1341. # Add Fields to Register Form
  1342. function RegForm(){
  1343. $piereg = get_option( 'pie_register' );
  1344. $piereg_custom = get_option( 'pie_register_custom' );
  1345. if( !is_array( $piereg_custom ) ) $piereg_custom = array();
  1346.  
  1347. if ( $piereg['firstname'] ){
  1348. if( isset( $_GET['firstname'] ) ) $_POST['firstname'] = $_GET['firstname'];
  1349. ?>
  1350. <p><label for="firstname"><?php _e('First Name:', 'piereg');?><br />
  1351. <input name="firstname" id="firstname" size="25" value="<?php echo sanitize_text_field($_POST['firstname']);?>" type="text" /></label>
  1352. </p>
  1353. <?php
  1354. }
  1355. if ( $piereg['lastname'] ){
  1356. if( isset( $_GET['lastname'] ) ) $_POST['lastname'] = $_GET['lastname'];
  1357. ?>
  1358. <p><label for="lastname"><?php _e('Last Name:', 'piereg');?><br />
  1359. <input name="lastname" id="lastname" size="25" value="<?php echo sanitize_text_field($_POST['lastname']);?>" type="text" /></label></p>
  1360. <?php
  1361. }
  1362.  
  1363. if ( $piereg['password'] ){
  1364. ?>
  1365. <p><label for="password"><?php _e('Password:', 'piereg');?><br />
  1366. <input autocomplete="off" name="pass1" id="pass1" size="25" value="<?php echo sanitize_text_field($_POST['pass1']);?>" type="password" /></label>
  1367. <br /> <label><?php _e('Confirm Password:', 'piereg');?><br />
  1368. <input autocomplete="off" name="pass2" id="pass2" size="25" value="<?php echo sanitize_text_field($_POST['pass2']);?>" type="password" /></label>
  1369. <?php if( $piereg['password_meter'] ){ ?>
  1370. <br /> <span id="pass-strength-result"><?php echo $piereg['short'];?></span>
  1371. <small><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&amp;( in your password.', 'piereg'); ?> </small>
  1372. <?php } ?>
  1373. </p>
  1374. <?php
  1375. }
  1376. foreach( $piereg_custom as $k=>$v){
  1377. if( $v['reg'] ){
  1378. $id = $this->Label_ID($v['label']);
  1379. if( isset( $_GET[$id] ) ) $_POST[$id] = $_GET[$id];
  1380. ?>
  1381.  
  1382.  
  1383. <?php if( $v['fieldtype'] == 'text' ){ ?>
  1384. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:<br />
  1385. <input class="custom_field" name="<?php echo $id;?>" id="<?php echo $id;?>" size="25" value="<?php echo sanitize_text_field($_POST[$id]);?>" type="text" /></label></p>
  1386.  
  1387. <?php } else if( $v['fieldtype'] == 'date' ){
  1388. /*$test_arr = explode('/', $_POST[$id]);
  1389. if (count($test_arr) == 3) {
  1390. //date is valid
  1391. $sanitized_date=intval($test_arr[0]).'/'.intval($test_arr[1]).'/'.intval($test_arr[2]);
  1392. } else {
  1393. // problem with input ...
  1394. $sanitized_date = '';
  1395. }*/
  1396.  
  1397. ?>
  1398. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:<br />
  1399. <input class="custom_field date-pick" name="<?php echo $id;?>" id="<?php echo $id;?>" size="25" value="<?php echo $_POST[$id];?>" type="text" /></label></p>
  1400.  
  1401. <?php } else if( $v['fieldtype'] == 'select' ){
  1402. $ops = explode(',',$v['extraoptions']);
  1403. $options='';
  1404. foreach( $ops as $op ){
  1405. $options .= '<option value="'.$op.'" ';
  1406. if( $_POST[$id] == $op ) $options .= 'selected="selected" ';
  1407. $options .= '>' . $op . '</option>';
  1408. }
  1409. ?>
  1410. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:<br />
  1411. <select class="custom_select" name="<?php echo $id;?>" id="<?php echo $id;?>">
  1412. <?php echo $options;?>
  1413. </select></label></p>
  1414.  
  1415. <?php } else if( $v['fieldtype'] == 'checkbox' ){
  1416. $ops = explode(',',$v['extraoptions']);
  1417. $check='';
  1418. foreach( $ops as $op ){
  1419. $check .= '<label><input type="checkbox" class="custom_checkbox" name="'.$id.'[]" id="'.$id.'" ';
  1420. //if( in_array($op, $_POST[$id]) ) $check .= 'checked="checked" ';
  1421. if( $_POST[$id] == $op ) $check .= 'checked="checked" ';
  1422. $check .= 'value="'.$op.'" /> '.$op.'</label> ';
  1423. }
  1424. ?>
  1425. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:</label><br /><?php
  1426. echo $check . '</p></p>';
  1427.  
  1428. } else if( $v['fieldtype'] == 'radio' ){
  1429. $ops = explode(',',$v['extraoptions']);
  1430. $radio = '';
  1431. foreach( $ops as $op ){
  1432. $radio .= '<label for="'.$id.'-'.$op.'"><input type="radio" class="custom_radio" name="'.$id.'" id="'.$id.'-'.$op.'" ';
  1433. //if( in_array($op, $_POST[$id]) ) $radio .= 'checked="checked" ';
  1434. if( $_POST[$id] == $op ) $radio .= 'checked="checked" ';
  1435. $radio .= 'value="'.$op.'" /> '.$op.'</label> ';
  1436. }
  1437. ?>
  1438. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:</label><br /><?php
  1439. echo $radio . '</p></p>';
  1440.  
  1441. } else if( $v['fieldtype'] == 'textarea' ){ ?>
  1442. <p><label for="<?php echo $id;?>"><?php echo $v['label'];?>:<br />
  1443. <textarea name="<?php echo $id;?>" cols="25" rows="5" id="<?php echo $id;?>" class="custom_textarea"><?php echo sanitize_text_field($_POST[$id]);?></textarea></label></p>
  1444.  
  1445. <?php } else if( $v['fieldtype'] == 'hidden' ){ ?><p>
  1446. <input class="custom_field" name="<?php echo $id;?>" value="<?php echo sanitize_text_field($_POST[$id]);?>" type="hidden" /> </p>
  1447. <?php } ?>
  1448.  
  1449. <?php }
  1450. }
  1451. if ( $piereg['website'] ){
  1452. if( isset( $_GET['website'] ) ) $_POST['website'] = $_GET['website'];
  1453. ?>
  1454. <p><label for="website"><?php _e('Website:', 'piereg');?><br />
  1455. <input name="website" id="website" size="25" value="<?php echo sanitize_text_field($_POST['website']);?>" type="text" /></label></p>
  1456. <?php
  1457. }
  1458. if ( $piereg['aim'] ){
  1459. if( isset( $_GET['aim'] ) ) $_POST['aim'] = $_GET['aim'];
  1460. ?>
  1461. <p><label for="aim"><?php _e('AIM:', 'piereg');?><br />
  1462. <input name="aim" id="aim" size="25" value="<?php echo sanitize_text_field($_POST['aim']);?>" type="text" /></label></p>
  1463. <?php
  1464. }
  1465. if ( $piereg['yahoo'] ){
  1466. if( isset( $_GET['yahoo'] ) ) $_POST['yahoo'] = $_GET['yahoo'];
  1467. ?>
  1468. <p><label for="yahoo"><?php _e('Yahoo IM:', 'piereg');?><br />
  1469. <input name="yahoo" id="yahoo" size="25" value="<?php echo sanitize_text_field($_POST['yahoo']);?>" type="text" /></label></p>
  1470. <?php
  1471. }
  1472. if ( $piereg['jabber'] ){
  1473. if( isset( $_GET['jabber'] ) ) $_POST['jabber'] = $_GET['jabber'];
  1474. ?>
  1475. <p><label for="jabber"><?php _e('Jabber / Google Talk:', 'piereg');?><br />
  1476. <input name="jabber" id="jabber" size="25" value="<?php echo sanitize_text_field($_POST['jabber']);?>" type="text" /></label></p>
  1477. <?php
  1478. }
  1479. if ( $piereg['phone'] ){
  1480. if( isset( $_GET['phone'] ) ) $_POST['phone'] = $_GET['phone'];
  1481. ?>
  1482. <p><label for="phone"><?php _e('Phone # / Mobile #:', 'piereg');?><br />
  1483. <input name="phone" id="phone" size="25" value="<?php echo sanitize_text_field($_POST['phone']);?>" type="text" /></label></p>
  1484. <?php
  1485. }
  1486. if ( $piereg['about'] ){
  1487. if( isset( $_GET['about'] ) ) $_POST['about'] = $_GET['about'];
  1488. ?>
  1489. <p><label for="about"><?php _e('About Yourself:', 'piereg');?><br />
  1490. <textarea name="about" id="about" cols="25" rows="5"><?php echo stripslashes(sanitize_text_field($_POST['about']));?></textarea></label>
  1491. <small><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.', 'piereg');?></small>
  1492. </p>
  1493. <?php
  1494. }
  1495.  
  1496. if ( $piereg['code'] ){
  1497. $pieregcodes=explode("\n", $piereg['codepass']);
  1498.  
  1499. if( isset( $_GET['regcode'] ) ) $_POST['regcode'] = $_GET['regcode'];
  1500. ?>
  1501. <p><label for="code"><?php _e($piereg['codename'].' Code:', 'piereg');?><br />
  1502. <input name="regcode" id="regcode" size="25" value="<?php echo sanitize_text_field($_POST['regcode']);?>" type="text" /></label>
  1503. <?php if ($piereg['code_req']) {?>
  1504. <p><small><?php _e(str_replace('[prcodename]',$piereg['codename'],$piereg['_admin_message_38']), 'piereg');?></small></p>
  1505. <?php }else{ ?>
  1506. <br /><small><?php _e(str_replace('[prcodename]',$piereg['codename'],$piereg['_admin_message_39']), 'piereg');?></small></p>
  1507. <?php } ?>
  1508. </p>
  1509. <?php
  1510. }
  1511.  
  1512. if ( $piereg['disclaimer'] ){
  1513. ?>
  1514. <p><label for="disclaimer"><?php echo stripslashes( $piereg['disclaimer_title'] );?><br />
  1515. <span id="disclaimer"><?php echo stripslashes(html_entity_decode($piereg['disclaimer_content'])); ?></span>
  1516. <input name="disclaimer" value="1" type="checkbox" <?php if($_POST['disclaimer']) echo ' checked="checked"';?> /> <?php echo $piereg['disclaimer_agree'];?></label></p>
  1517. <?php
  1518. }
  1519. if ( $piereg['license'] ){
  1520. ?>
  1521. <p><label for="license"><?php echo stripslashes( $piereg['license_title'] );?><br />
  1522. <span id="license"><?php echo stripslashes(html_entity_decode($piereg['license_content'])); ?></span>
  1523. <input name="license" value="1" type="checkbox" <?php if($_POST['license']) echo ' checked="checked"';?> /> <?php echo $piereg['license_agree'];?></label></p>
  1524. <?php
  1525. }
  1526. if ( $piereg['privacy'] ){
  1527. ?>
  1528. <p><label for="privacy"><?php echo stripslashes( $piereg['privacy_title'] );?><br />
  1529. <span id="privacy"><?php echo stripslashes(html_entity_decode($piereg['privacy_content'])); ?></span>
  1530. <input name="privacy" value="1" type="checkbox" <?php if($_POST['privacy']) echo ' checked="checked"';?> /> <?php echo $piereg['privacy_agree'];?></label></p>
  1531. <?php
  1532. }
  1533.  
  1534. if ( $piereg['captcha'] == 1 ){
  1535.  
  1536. $_SESSION['OK'] = 1;
  1537. if( !isset( $_SESSION['OK'] ) )
  1538. session_start();
  1539. ?>
  1540. <p><label for="captcha"><?php _e('Validation Image:', 'piereg');?><br />
  1541. <img src="<?php echo $this->plugin_url;?>captcha.php" id="captchaimg" alt="" />
  1542. <input type="text" name="captcha" id="captcha" size="25" value="" /></label>
  1543. <small><?php _e($piereg['_admin_message_40'], 'piereg');?></small></p>
  1544.  
  1545. <?php
  1546.  
  1547. } else if ( $piereg['captcha'] == 2 && $piereg['reCAP_public_key'] && $piereg['reCAP_private_key'] ){
  1548. require_once('recaptchalib.php');
  1549. $publickey = $piereg['reCAP_public_key'];
  1550. echo '<div id="reCAPTCHA">';
  1551. echo recaptcha_get_html($publickey);
  1552. echo '</div>';
  1553. }
  1554.  
  1555. if ($piereg['paypal_option']) {
  1556. ?>
  1557.  
  1558. <div class="submit" style="margin-top:10px;padding-top:10px;">
  1559. <input class="button-primary" id="wp-submit" type="submit" value="Continue" name="wp-submit"/>
  1560. </div>
  1561. <style>
  1562. p.submit{
  1563. display:none;
  1564. }
  1565. </style>
  1566. <?php
  1567. }
  1568. ?>
  1569.  
  1570. <?php
  1571. }
  1572.  
  1573. function Label_ID($label){
  1574. $id = str_replace(' ', '_', $label);
  1575. $id = strtolower($id);
  1576. $id = sanitize_user($id, true);
  1577. return $id;
  1578. }
  1579. # Add Javascript & CSS needed
  1580. function PassHead(){
  1581. $piereg = get_option( 'pie_register' );
  1582. if( isset( $_GET['user_login'] ) ) $user_login = $_GET['user_login'];
  1583. if( isset( $_GET['user_email'] ) ) $user_email = $_GET['user_email'];
  1584. ?>
  1585. <script type='text/javascript' src='<?php echo includes_url("/js/jquery/jquery.js?ver=1.7.1");?>'></script>
  1586. <?php /*?><!--<script type='text/javascript' src='<?php trailingslashit(get_option('siteurl'));?>wp-admin/js/common.js?ver=20080318'></script>--><?php */?>
  1587. <?php
  1588. if ( $piereg['password'] ){
  1589. ?>
  1590.  
  1591.  
  1592.  
  1593. <?php /*?><script type='text/javascript' src='<?php echo includes_url("/js/jquery/jquery.color.js?ver=2.0-4561");?>'></script>
  1594. <?php */?><script type='text/javascript'>
  1595. /* <![CDATA[ */
  1596. pwsL10n = {
  1597. short: "<?php echo $piereg['short'];?>",
  1598. bad: "<?php echo $piereg['bad'];?>",
  1599. good: "<?php echo $piereg['good'];?>",
  1600. strong: "<?php echo $piereg['strong'];?>",
  1601. mismatch: "<?php echo $piereg['mismatch'];?>"
  1602. }
  1603. /* ]]> */
  1604. </script>
  1605. <script type='text/javascript' src='<?php echo admin_url("/js/password-strength-meter.js");?>'></script>
  1606. <script type="text/javascript">
  1607. function check_pass_strength ( ) {
  1608.  
  1609. var pass = jQuery('#pass1').val();
  1610. var pass2 = jQuery('#pass2').val();
  1611. var user = jQuery('#user_login').val();
  1612.  
  1613. // get the result as an object, i'm tired of typing it
  1614. var res = jQuery('#pass-strength-result');
  1615.  
  1616. var strength = passwordStrength(pass, user, pass2);
  1617.  
  1618. jQuery(res).removeClass('short bad good strong mismatch');
  1619.  
  1620. if ( strength == 1 ) {
  1621. // this catches 'Too short' and the off chance anything else comes along
  1622. jQuery(res).addClass('short');
  1623. jQuery(res).html( pwsL10n.short );
  1624. }
  1625. else if ( strength == 2 ) {
  1626. jQuery(res).addClass('bad');
  1627. jQuery(res).html( pwsL10n.bad );
  1628. }
  1629. else if ( strength == 3 ) {
  1630. jQuery(res).addClass('good');
  1631. jQuery(res).html( pwsL10n.good );
  1632. }
  1633. else if ( strength == 4 ) {
  1634. jQuery(res).addClass('strong');
  1635. jQuery(res).html( pwsL10n.strong );
  1636. }
  1637. else if ( strength == 5 ) {
  1638. jQuery(res).addClass('mismatch');
  1639. jQuery(res).html( pwsL10n.mismatch );
  1640. }
  1641. else {
  1642. // this catches 'Too short' and the off chance anything else comes along
  1643. jQuery(res).addClass('short');
  1644. jQuery(res).html( pwsL10n.short );
  1645. }
  1646.  
  1647. }
  1648.  
  1649.  
  1650. jQuery(function($) {
  1651. $('#pass1').keyup( check_pass_strength );
  1652. $('#pass2').keyup( check_pass_strength )
  1653. $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
  1654. } );
  1655.  
  1656. jQuery(document).ready( function() {
  1657. jQuery('#pass1,#pass2').attr('autocomplete','off');
  1658. jQuery('#user_login').val('<?php echo $user_login; ?>');
  1659. jQuery('#user_email').val('<?php echo $user_email; ?>');
  1660. });
  1661. </script>
  1662. <?php } ?>
  1663.  
  1664. <!-- required plugins -->
  1665. <script type="text/javascript" src="<?php echo $this->plugin_url;?>datepicker/date.js"></script>
  1666. <!--[if IE]><script type="text/javascript" src="<?php echo $plugin_url;?>datepicker/jquery.bgiframe.js"></script><![endif]-->
  1667.  
  1668. <!-- jquery.datePicker.js -->
  1669. <script type="text/javascript" src="<?php echo $this->plugin_url;?>datepicker/jquery.datePicker.js"></script>
  1670. <link href="<?php echo $this->plugin_url;?>datepicker/datePicker.css" rel="stylesheet" type="text/css" />
  1671. <script type="text/javascript">
  1672. jQuery.dpText = {
  1673. TEXT_PREV_YEAR : '<?php _e('Previous year','piereg');?>',
  1674. TEXT_PREV_MONTH : '<?php _e('Previous month','piereg');?>',
  1675. TEXT_NEXT_YEAR : '<?php _e('Next year','piereg');?>',
  1676. TEXT_NEXT_MONTH : '<?php _e('Next Month','piereg');?>',
  1677. TEXT_CLOSE : '<?php _e('Close','piereg');?>',
  1678. TEXT_CHOOSE_DATE : '<?php _e('Choose Date','piereg');?>'
  1679. }
  1680.  
  1681. Date.dayNames = ['<?php _e('Monday','piereg');?>', '<?php _e('Tuesday','piereg');?>', '<?php _e('Wednesday','piereg');?>', '<?php _e('Thursday','piereg');?>', '<?php _e('Friday','piereg');?>', '<?php _e('Saturday','piereg');?>', '<?php _e('Sunday','piereg');?>'];
  1682. Date.abbrDayNames = ['<?php _e('Mon','piereg');?>', '<?php _e('Tue','piereg');?>', '<?php _e('Wed','piereg');?>', '<?php _e('Thu','piereg');?>', '<?php _e('Fri','piereg');?>', '<?php _e('Sat','piereg');?>', '<?php _e('Sun','piereg');?>'];
  1683. Date.monthNames = ['<?php _e('January','piereg');?>', '<?php _e('February','piereg');?>', '<?php _e('March','piereg');?>', '<?php _e('April','piereg');?>', '<?php _e('May','piereg');?>', '<?php _e('June','piereg');?>', '<?php _e('July','piereg');?>', '<?php _e('August','piereg');?>', '<?php _e('September','piereg');?>', '<?php _e('October','piereg');?>', '<?php _e('November','piereg');?>', '<?php _e('December','piereg');?>'];
  1684. Date.abbrMonthNames = ['<?php _e('Jan','piereg');?>', '<?php _e('Feb','piereg');?>', '<?php _e('Mar','piereg');?>', '<?php _e('Apr','piereg');?>', '<?php _e('May','piereg');?>', '<?php _e('Jun','piereg');?>', '<?php _e('Jul','piereg');?>', '<?php _e('Aug','piereg');?>', '<?php _e('Sep','piereg');?>', '<?php _e('Oct','piereg');?>', '<?php _e('Nov','piereg');?>', '<?php _e('Dec','piereg');?>'];
  1685. Date.firstDayOfWeek = <?php echo $piereg['firstday'];?>;
  1686. Date.format = '<?php echo $piereg['dateformat'];?>';
  1687. jQuery(function() {
  1688. jQuery('.date-pick').datePicker({
  1689. clickInput:true,
  1690. startDate:'<?php echo $piereg['startdate'];?>',
  1691. year:<?php if($piereg['calyear']){echo $piereg['calyear'];}else{echo date("Y");}?>,
  1692. month:<?php if( $piereg['calmonth'] != 'cur' ) echo $piereg['calmonth']-1; else echo date('n')-1;?>
  1693. })
  1694. });
  1695. </script>
  1696. <style type="text/css">
  1697. a.dp-choose-date { width: 16px; height: 16px; padding: 0; margin: 5px 3px 0; display: inline-block; text-indent: -2000px; overflow: hidden; background: url(<?php echo $this->plugin_url;?>datepicker/calendar.png) no-repeat; } a.dp-choose-date.dp-disabled { background-position: 0 -20px; cursor: default; } /* makes the input field shorter once the date picker code * has run (to allow space for the calendar icon */ input.dp-applied { width: 140px !important;display:inline-block;}
  1698.  
  1699. #phone, #pass1, #pass2, #regcode, #captcha, #firstname, #lastname, #website, #aim, #yahoo, #jabber, #about, .custom_field{
  1700. font-size: 20px;
  1701. width: 99%;
  1702. padding: 3px;
  1703. margin-right: 6px;
  1704. }
  1705. .custom_select, .custom_textarea{
  1706. width: 99%;
  1707. padding: 3px;
  1708. margin-right: 6px;
  1709. }
  1710. #about, .custom_textarea{
  1711. height: 60px;
  1712. }
  1713. #disclaimer, #license, #privacy{
  1714. display:block;
  1715. width: 99%;
  1716. padding: 3px;
  1717. background-color:#fff;
  1718. border:solid 1px #A7A6AA;
  1719. font-weight:normal;
  1720. }
  1721. <?php
  1722. $piereg_custom = get_option( 'pie_register_custom' );
  1723. $custom = array();
  1724. if (!empty($piereg_custom)) {
  1725. foreach( $piereg_custom as $k=>$v ){
  1726. if( $v['required'] && $v['reg'] ){
  1727. $custom[] = ', #' . $this->Label_ID($v['label']);
  1728. }
  1729. }
  1730. }
  1731.  
  1732. if( $piereg['profile_req'][0] ) $profile_req = ', #' . implode(', #', $piereg['profile_req']);
  1733. if( $custom[0] )$profile_req .= implode('', $custom);
  1734. ?>
  1735. #phone, #user_login, #user_email, #pass1, #pass2 <?php echo $profile_req;?>{
  1736.  
  1737. <?php echo $piereg['require_style'];?>
  1738.  
  1739. }
  1740. <?php if( strlen($piereg['disclaimer_content']) > 525){ ?>
  1741. #disclaimer{
  1742. height: 200px;
  1743. overflow:scroll;
  1744. }
  1745. <?php } ?>
  1746. <?php if( strlen($piereg['license_content']) > 525){ ?>
  1747. #license{
  1748. height: 200px;
  1749. overflow:scroll;
  1750. }
  1751. <?php } ?>
  1752. <?php if( strlen($piereg['privacy_content']) > 525){ ?>
  1753. #privacy{
  1754. height: 200px;
  1755. overflow:scroll;
  1756. }
  1757. <?php } ?>
  1758. #captcha {
  1759. width: 48%;
  1760. }
  1761. #captchaimg{
  1762. float:left;
  1763. }
  1764. #reg_passmail{
  1765. display:none;
  1766. }
  1767. small{
  1768. font-weight:normal;
  1769. }
  1770. #pass-strength-result{
  1771. padding-top: 3px;
  1772. padding-right: 5px;
  1773. padding-bottom: 3px;
  1774. padding-left: 5px;
  1775. margin-top: 3px;
  1776. text-align: center;
  1777. border-top-width: 1px;
  1778. border-right-width: 1px;
  1779. border-bottom-width: 1px;
  1780. border-left-width: 1px;
  1781. border-top-style: solid;
  1782. border-right-style: solid;
  1783. border-bottom-style: solid;
  1784. border-left-style: solid;
  1785. display:block;
  1786. }
  1787. #reCAPTCHA{
  1788. position:relative;
  1789. margin-left:0px;
  1790. }
  1791.  
  1792.  
  1793. </style>
  1794. <?php
  1795. }
  1796.  
  1797. function HideLogin(){
  1798. global $wpdb;
  1799. $piereg = get_option( 'pie_register' );
  1800. $username = $_COOKIE['session_secure_id'];
  1801. //$user_id = $wpdb->get_var( "SELECT ID FROM $wpdb->users WHERE `user_login` = '".$username."'");
  1802. $user = get_user_by('login', $username);
  1803. $user_id = $user->ID;
  1804. //var_dump($username,$user_id);
  1805. $admin_verified_user = get_user_meta($user_id,'admin_verified_user',true);
  1806. $email_verified_user = get_user_meta($user_id,'email_verified_user',true);
  1807. //var_dump($admin_verified_user ,$email_verified_user);
  1808. if(($piereg['paypal_option'] && $_GET['checkemail']) || (isset($_GET['piereg_verification']) && $piereg['paypal_option'])){
  1809. if(!$admin_verified_user && !$email_verified_user){
  1810. echo '<style type="text/css">label, #user_login, #user_pass, .forgetmenot, #wp-submit{display:none;}</style>';
  1811. }
  1812. }
  1813. }
  1814.  
  1815. function LogoHead(){
  1816. $piereg = get_option( 'pie_register' );
  1817.  
  1818. if( $piereg['custom_logo_url'] ){
  1819. $logo = $piereg['custom_logo_url'];
  1820. list($width, $height, $type, $attr) = getimagesize($logo);
  1821. ?>
  1822. <?php if( $_GET['action'] != 'register' ) : ?>
  1823. <script type='text/javascript' src='<?php includes_url("/js/jquery/jquery.js");?>'></script>
  1824. <?php endif; ?>
  1825. <script type="text/javascript">
  1826. jQuery(document).ready( function() {
  1827. jQuery('#login h1 a').attr('href', '<?php echo get_option('home'); ?>');
  1828. jQuery('#login h1 a').attr('title', '<?php echo get_option('blogname') . ' - ' . get_option('blogdescription'); ?>');
  1829. });
  1830. </script>
  1831. <style type="text/css">
  1832. #login h1 a {
  1833. background-image: url(<?php echo $logo;?>);
  1834. background-position:center top;
  1835. width: <?php echo $width; ?>px;
  1836. min-width:292px;
  1837. margin:0 auto;
  1838. }
  1839.  
  1840. <?php if( $piereg['register_css'] && $_GET['action'] == 'register') echo html_entity_decode(stripslashes($piereg['register_css']));
  1841. else if( $piereg['login_css'] ) echo html_entity_decode(stripslashes($piereg['login_css'])); ?>
  1842. </style>
  1843. <?php }
  1844.  
  1845. }
  1846.  
  1847.  
  1848.  
  1849. function update_contact_methods( $contactmethods ) {
  1850.  
  1851. // Add new fields
  1852. $contactmethods['phone'] = 'Phone';
  1853. return $contactmethods;
  1854. }
  1855.  
  1856. function Add2Profile() {
  1857. global $user_ID;
  1858. get_currentuserinfo();
  1859. if( $_GET['user_id'] ) $user_ID = $_GET['user_id'];
  1860. $piereg = get_option( 'pie_register' );
  1861. $piereg_custom = get_option( 'pie_register_custom' );
  1862. //codename
  1863. if( !is_array( $piereg_custom ) ) $piereg_custom = array();
  1864. $invite_code = get_user_meta($user_ID, 'invite_code', true);
  1865. if($invite_code != ''){
  1866. echo '<table class="form-table"><tbody>';
  1867. echo '<tr><th><label for="invitation_code">'.$piereg['codename'].'</label></th><td><input type="text" name="invite_code" value="'.$invite_code.'" readonly="readonly" /></td></tr>';
  1868. echo '</tbody></table>';
  1869. }
  1870. if( count($piereg_custom) > 0){
  1871. $top = '<h3>' . __('Additional Information', 'piereg') . '</h3><table class="form-table"><tbody>';
  1872. $bottom = '</tbody></table>';
  1873. }
  1874. echo $top;
  1875.  
  1876. if (!empty($piereg_custom)) {
  1877. foreach( $piereg_custom as $k=>$v ){
  1878.  
  1879. if( $v['profile'] ){
  1880. $id = $this->Label_ID($v['label']);
  1881. $single = true;
  1882. $value = get_user_meta( $user_ID, $id, $single );
  1883. $extraops = explode(',', $v['extraoptions']);
  1884. switch( $v['fieldtype'] ){
  1885. case "text" :
  1886. $outfield = '<input type="text" name="' . $id . '" id="' . $id . '" value="' . $value . '" />';
  1887. break;
  1888. case "hidden" :
  1889. $outfield = '<input type="text" disabled="disabled" name="' . $id . '" id="' . $id . '" value="' . $value . '" />';
  1890. break;
  1891. case "select" :
  1892. $outfield = '<select name="' . $id . '" id="' . $id . '">';
  1893. foreach( $extraops as $op ){
  1894. $outfield .= '<option value="' . $op . '"';
  1895. if( $value == $op ) $outfield .= ' selected="selected"';
  1896. $outfield .= '>' . $op . '</option>';
  1897. }
  1898. $outfield .= '</select>';
  1899. break;
  1900. case "textarea" :
  1901. $outfield = '<textarea name="' . $id . '" id="' . $id . '" cols="25" rows="10">' . stripslashes($value) . '</textarea>';
  1902. break;
  1903. case "checkbox" :
  1904. $outfield = '';
  1905. $valarr = explode(', ', $value);
  1906. foreach( $extraops as $op ){
  1907. $outfield .= '<label><input type="checkbox" name="' . $id . '[]" value="' . $op . '"';
  1908. if( in_array($op, $valarr) ) $outfield .= ' checked="checked"';
  1909. $outfield .= ' /> ' . $op . '</label> &nbsp; ';
  1910. }
  1911. break;
  1912. case "radio" :
  1913. $outfield = '';
  1914. foreach( $extraops as $op ){
  1915. $outfield .= '<label><input type="radio" name="' . $id . '" value="' . $op . '"';
  1916. if( $value == $op ) $outfield .= ' checked="checked"';
  1917. $outfield .= ' /> ' . $op . '</label> &nbsp; ';
  1918. }
  1919. break;
  1920. case "date" :
  1921. $outfield = '<input class="custom_field date-pick" tabindex="36" name="' . $id . '" id="' . $id . '" value="' . $value . '" />';
  1922. break;
  1923. }
  1924. ?>
  1925. <tr>
  1926. <th><label for="<?php echo $id;?>"><?php echo $v['label'];?>:</label></th>
  1927. <td><?php echo $outfield; ?></td>
  1928. </tr>
  1929. <?php
  1930.  
  1931. }
  1932. }
  1933. }
  1934. echo $bottom;
  1935. }
  1936. //With Thanks
  1937. //Fixed by Julian Warren
  1938. function SaveProfile($user_id){
  1939. global $wpdb;
  1940. //get_currentuserinfo();
  1941. //if( $_GET['user_id'] ) $user_ID = $_GET['user_id'];
  1942. $user_ID=$user_id;
  1943. $piereg_custom = get_option( 'pie_register_custom' );
  1944. if( !is_array( $piereg_custom ) ) $piereg_custom = array();
  1945. if (!empty($piereg_custom)) {
  1946. foreach( $piereg_custom as $k=>$v ){
  1947. if( $v['profile'] ){
  1948. $key = $this->Label_ID($v['label']);
  1949.  
  1950. if( is_array($_POST[$key]) ) $_POST[$key] = implode(', ', $_POST[$key]);
  1951. $value = $wpdb->prepare($_POST[$key]);
  1952. update_usermeta($user_ID ,$key ,$value);
  1953. }
  1954. }
  1955. }
  1956. }
  1957. function RanPass($len=7) {
  1958. $chars = "0123456789abcdefghijkl0123456789mnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQ0123456789RSTUVWXYZ0123456789";
  1959. srand((double)microtime()*1000000);
  1960. $i = 0;
  1961. $pass = '' ;
  1962. while ($i <= $len) {
  1963. $num = rand() % 33;
  1964. $tmp = substr($chars, $num, 1);
  1965. $pass = $pass . $tmp;
  1966. $i++;
  1967. }
  1968. return $pass;
  1969. }
  1970.  
  1971. function ValidateUser(){
  1972. //die("MOHSIN");
  1973. global $wpdb;
  1974. $piereg = get_option( 'pie_register' );
  1975. if($_GET['checkemail'] == "registered"){
  1976. $username = ($_SESSION['secure_id'] != '')?$_SESSION['secure_id'] : $_COOKIE['session_secure_id'];
  1977. if($piereg['paypal_option']){
  1978. //die($username);
  1979. $user_id = $wpdb->get_var( "SELECT user_id FROM $wpdb->usermeta WHERE (`meta_key` = 'email_verify_user' OR `meta_key` = 'admin_verify_user') AND `meta_value`='".$username."'");
  1980. if($user_id){
  1981. $login = get_user_meta($user_id, 'email_verify_user',true);
  1982. if(!$login)
  1983. $login = get_user_meta($user_id, 'admin_verify_user',true);
  1984. $paypalcode="<a href='";
  1985. if($piereg['paypal_sandbox'] == "yes"){
  1986. $paypalcode.=SSL_SAND_URL;
  1987. }else{
  1988. $paypalcode.=SSL_P_URL;
  1989. }
  1990. $paypalcode.="?cmd=_s-xclick&custom=".$user_id."&hosted_button_id=".$piereg['paypal_butt_id']."'><img src='https://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif' alt='PayPal - The safer, easier way to pay online' border='0' /></a>";
  1991. $msg = '<p style="margin-bottom:10px;">' . sprintf(__('Hello <strong>%s</strong>, '.$piereg['_admin_message_44'], 'piereg'), $login ) . '</p>'.$paypalcode;
  1992. //$func3 = function() use ($msg){ echo $msg; };
  1993. $this->bodymsg = $msg;
  1994. add_action('login_form', array(&$this,'pie_login_form_body_msg'));
  1995.  
  1996. $message = __($piereg['_admin_message_43'], 'piereg');
  1997. //$func = function($ms) use ($message){ return $message; };
  1998. $this->headmsg = $message;
  1999. add_filter('login_messages', array(&$this,'pie_login_head_message'));
  2000. return true;
  2001. }else{
  2002. ///die($username);
  2003. //$user_id = $wpdb->get_var( "SELECT ID FROM $wpdb->users WHERE `user_login` = '".$username."'");
  2004. $user = get_user_by('login', $username);
  2005. $user_id = $user->ID;
  2006. if($user_id){
  2007. $admin_verified_user = get_user_meta($user_id,'admin_verified_user',true);
  2008. if($admin_verified_user){
  2009. $message = __($piereg['_admin_message_17'], 'piereg');
  2010. //$func = function($ms) use ($message){ return $message; };
  2011. $this->headmsg = $message;
  2012. add_filter('login_messages', array(&$this,'pie_login_head_message'));
  2013. }
  2014. }
  2015. }
  2016. }elseif( $piereg['admin_verify']){
  2017. $message = __($piereg['_admin_message_41'], 'piereg');
  2018. //$func = function() use ($message){ return $message; };
  2019. $this->headmsg = $message;
  2020. add_filter('login_messages', array(&$this,'pie_login_head_message'));
  2021. return true;
  2022. }elseif($piereg['email_verify']){
  2023. $message = __($piereg['_admin_message_42'], 'piereg');
  2024. //$func = function() use ($message){ return $message; };
  2025. //die(__($piereg['_admin_message_42'], 'piereg'));
  2026. $this->headmsg = $message;
  2027. //$session[] = $message;
  2028. add_filter('login_messages', array(&$this,'pie_login_head_message'));
  2029. return true;
  2030. }
  2031. }elseif(isset($_GET['piereg_verification'])){
  2032. $verify_key = $wpdb->escape($_GET['piereg_verification']);
  2033. $user_id = $wpdb->get_var( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'email_verify' AND meta_value='$verify_key'");
  2034. //var_dump($user_id);
  2035. if($user_id > 0){
  2036. $login = get_user_meta($user_id, 'email_verify_user',true);
  2037. if(!$login){
  2038. $user = get_user_by("id",$user_id);
  2039. $login = $user->user_login;
  2040. }
  2041. //var_dump($login);
  2042. update_user_meta( $user_id, 'is_email_verified', 'yes' );
  2043. update_user_meta( $user_id, 'email_verified_user','yes');
  2044. $payment_received = get_user_meta($user_id,'payment_verified',true);
  2045. if($payment_received == 'yes'){
  2046. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" );
  2047. $user_email=get_user_meta($user_id, 'email_verify_email',true);
  2048. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$user_email' WHERE ID = '$user_id' " );
  2049. add_user_meta( $user_id, 'email_verified', 'yes' );
  2050. delete_user_meta($user_id, 'email_verify_user');
  2051. //delete_user_meta($user_id, 'email_verify');
  2052. delete_user_meta($user_id, 'email_verify_date');
  2053.  
  2054. $msg = '<p style="margin-bottom:10px;">' . sprintf(__('Thank you <strong>%s</strong>, '.$piereg['_admin_message_46'], 'piereg'), $login ) . '</p>';
  2055. //$func3 = function() use ($msg){ echo $msg; };
  2056. $this->bodymsg = $msg;
  2057. add_action('login_form', array(&$this,'pie_login_form_body_msg'));
  2058. }
  2059. else{
  2060. if($piereg['paypal_option']){
  2061. $paypalcode="<a href='";
  2062. if($piereg['paypal_sandbox'] == "yes"){
  2063. $paypalcode.=SSL_SAND_URL;
  2064. }else{
  2065. $paypalcode.=SSL_P_URL;
  2066. }
  2067. $paypalcode.="?cmd=_s-xclick&custom=".$user_id."&hosted_button_id=".$piereg['paypal_butt_id']."'><img src='https://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif' alt='PayPal - The safer, easier way to pay online' border='0' /></a>";
  2068. $msg = '<p style="margin-bottom:10px;">' . sprintf(__('Hello <strong>%s</strong>, '.$piereg['_admin_message_45'], 'piereg'), $login ) . '</p>'.$paypalcode;
  2069. //$func3 = function() use ($msg){ echo $msg; };
  2070. $this->bodymsg = $msg;
  2071. add_action('login_form', array(&$this,'pie_login_form_body_msg'));
  2072.  
  2073. }else{
  2074. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$login' WHERE ID = '$user_id'" );
  2075. $user_email=get_user_meta($user_id, 'email_verify_email',true);
  2076. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$user_email' WHERE ID = '$user_id' " );
  2077. delete_user_meta($user_id, 'email_verify_user');
  2078. //delete_user_meta($user_id, 'email_verify');
  2079. delete_user_meta($user_id, 'email_verify_date');
  2080.  
  2081. $msg = '<p style="margin-bottom:10px;">' . sprintf(__('Thank you <strong>%s</strong>, '.$piereg['_admin_message_46'], 'piereg'), $login ) . '</p>';
  2082. //$func3 = function() use ($msg){ echo $msg; };
  2083. $this->bodymsg = $msg;
  2084. add_action('login_form', array(&$this,'pie_login_form_body_msg'));
  2085. }
  2086. }
  2087. //var_dump($func3);
  2088.  
  2089. return true;
  2090. }else{
  2091. //do nothing
  2092. return false;
  2093. }
  2094. }else{
  2095. //do nothing
  2096. return false;
  2097. }
  2098. }
  2099. /**
  2100. * validate the IPN
  2101. *
  2102. * @return bool IPN validation result
  2103. */
  2104. public function validate_ipn() {
  2105. global $wpdb;
  2106. $piereg = get_option( 'pie_register' );
  2107. $hostname = gethostbyaddr ( $_SERVER ['REMOTE_ADDR'] );
  2108. if (! preg_match ( '/paypal\.com$/', $hostname )) {
  2109. $this->ipn_status = 'Validation post isn\'t from PayPal';
  2110. $this->log_ipn_results ( false );
  2111. return false;
  2112. }
  2113.  
  2114. /*if (isset($this->paypal_mail) && strtolower ( $_POST['receiver_email'] ) != strtolower(trim( $this->paypal_mail ))) {
  2115. $this->ipn_status = "Receiver Email Not Match";
  2116. $this->log_ipn_results ( false );
  2117. return false;
  2118. }*/
  2119.  
  2120. if (isset($this->txn_id)&& in_array($_POST['txn_id'],$this->txn_id)) {
  2121. $this->ipn_status = "txn_id have a duplicate";
  2122. $this->log_ipn_results ( false );
  2123. return false;
  2124. }
  2125.  
  2126. // parse the paypal URL
  2127. $paypal_url = ($_POST['test_ipn'] == 1) ? SSL_SAND_URL : SSL_P_URL;
  2128. $url_parsed = parse_url($paypal_url);
  2129.  
  2130. // generate the post string from the _POST vars aswell as load the
  2131. // _POST vars into an arry so we can play with them from the calling
  2132. // script.
  2133. $post_string = '';
  2134.  
  2135. $this->postvars = $_POST;
  2136. foreach ($_POST as $field=>$value) {
  2137. $this->ipn_data["$field"] = $value;
  2138. $post_string .= $field.'='.urlencode(stripslashes($value)).'&';
  2139. }
  2140. $post_string.="cmd=_notify-validate"; // append ipn command
  2141.  
  2142. // open the connection to paypal
  2143. if ($piereg['paypal_sandbox'] == "yes")
  2144. $fp = fsockopen ( 'ssl://www.sandbox.paypal.com', "443", $err_num, $err_str, 60 );
  2145. else
  2146. $fp = fsockopen ( 'ssl://www.paypal.com', "443", $err_num, $err_str, 60 );
  2147.  
  2148. if(!$fp) {
  2149. // could not open the connection. If loggin is on, the error message
  2150. // will be in the log.
  2151. $this->ipn_status = "fsockopen error no. $err_num: $err_str";
  2152. $this->log_ipn_results(false);
  2153. return false;
  2154. } else {
  2155. // Post the data back to paypal
  2156. fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
  2157. fputs($fp, "Host: $url_parsed[host]\r\n");
  2158. fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
  2159. fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
  2160. fputs($fp, "Connection: close\r\n\r\n");
  2161. fputs($fp, $post_string . "\r\n\r\n");
  2162.  
  2163. // loop through the response from the server and append to variable
  2164. while(!feof($fp)) {
  2165. $this->ipn_response .= fgets($fp, 1024);
  2166. }
  2167. fclose($fp); // close connection
  2168. }
  2169.  
  2170. // Invalid IPN transaction. Check the $ipn_status and log for details.
  2171. if (! eregi("VERIFIED",$this->ipn_response)) {
  2172. $this->ipn_status = 'IPN Validation Failed';
  2173. $this->log_ipn_results(false);
  2174. return false;
  2175. } else {
  2176. $this->ipn_status = "IPN VERIFIED";
  2177. $this->userPaymentReceived($this->postvars);
  2178. $this->log_ipn_results(true);
  2179. return true;
  2180. }
  2181. }
  2182. function userPaymentReceived($postvars){
  2183. global $wpdb;
  2184. $piereg = get_option( 'pie_register' );
  2185. $firstname = $postvars['first_name'];
  2186. $lastname = $postvars['last_name'];
  2187. $email = $postvars['payer_email'];
  2188. $itemname = $postvars['item_name'];
  2189. $amount = $postvars['mc_gross'];
  2190. $user_login = $postvars['custom'];
  2191. $user_id = trim($postvars['custom']);
  2192. $useremail = get_user_meta($user_id,'email_verify_email',true);
  2193. if ( $user_id ) {
  2194. $loginE = get_user_meta($user_id, 'email_verify_user',true);
  2195. $loginA = get_user_meta($user_id, 'admin_verify_user',true);
  2196. $admin_verified_user = get_user_meta($user_id,'admin_verified_user',true);
  2197. $email_verified_user = get_user_meta($user_id,'email_verified_user',true);
  2198. //pending_payment
  2199. add_user_meta( $user_id, 'payment_verified', 'yes' );
  2200. if($loginE){
  2201.  
  2202. if($admin_verified_user || $email_verified_user){
  2203. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$loginE' WHERE ID = '$user_id'" );
  2204. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$useremail' WHERE ID = '$user_id'" );
  2205. delete_user_meta($user_id, 'pending_payment');
  2206. delete_user_meta($user_id, 'email_verify_user');
  2207. //delete_user_meta($user_id, 'email_verify');
  2208. //add_user_meta( $user_id, 'email_verified', 'yes' );
  2209. delete_user_meta($user_id, 'email_verify_date');
  2210. delete_user_meta($user_id, 'email_verify_user_pwd');
  2211. delete_user_meta($user_id, 'email_verify_email');
  2212. $this->holdmsg = '<p class="message">' . sprintf(__('Thank you %s, '.$piereg['_admin_message_47'], 'piereg'), $login ) . '</p>';
  2213. }else{
  2214. $this->holdmsg = '<p class="message">' . sprintf(__('Thank you %s, '.$piereg['_admin_message_48'], 'piereg'), $login ) . '</p>';
  2215. }
  2216. }else if($loginA){
  2217. if($admin_verified_user || $email_verified_user){
  2218. $wpdb->query( "UPDATE $wpdb->users SET user_login = '$loginA' WHERE ID = '$user_id'" );
  2219. $wpdb->query( "UPDATE $wpdb->users SET user_email = '$uuseremail' WHERE ID = '$user_id'" );
  2220. add_user_meta( $user_id, 'payment_verified', 'yes' );
  2221. delete_user_meta($user_id, 'pending_payment');
  2222. delete_user_meta($user_id, 'admin_verify_user');
  2223. delete_user_meta($user_id, 'email_verify_user_pwd');
  2224. delete_user_meta($user_id, 'email_verify_email');
  2225. delete_user_meta($user_id, 'admin_verify');
  2226. $this->holdmsg = '<p class="message">' . sprintf(__('Thank you %s, '.$piereg['_admin_message_47'], 'piereg'), $login ) . '</p>';
  2227. }else{
  2228. $this->holdmsg = '<p class="message">' . sprintf(__('Thank you %s, '.$piereg['_admin_message_48'], 'piereg'), $login ) . '</p>';
  2229. }
  2230.  
  2231. }
  2232. //echo $msg;
  2233. return true;
  2234. }
  2235. return false;
  2236. }
  2237. function payment_success_msg($message){
  2238. global $wpdb;
  2239. $piereg = get_option( 'pie_register' );
  2240. $admin_verified_user = get_user_meta($_GET['cm'],'admin_verified_user',true);
  2241. $email_verified_user = get_user_meta($_GET['cm'],'email_verified_user',true);
  2242. if($admin_verified_user || $email_verified_user)
  2243. $newmessage='<p class="message">' . __($piereg['_admin_message_47'], 'piereg') . '</p>';
  2244. else
  2245. $newmessage='<p class="message">' . __($piereg['_admin_message_48'], 'piereg') . '</p>';
  2246. return $newmessage.$message;
  2247. }
  2248. function payment_error_msg($message){
  2249. global $wpdb;
  2250. $piereg = get_option( 'pie_register' );
  2251. if(isset($_GET['tx']) && isset($_GET['cm']))
  2252. $newmessage='<div id="login_error">' . __($piereg['_admin_message_50'], 'piereg') . '</div>';
  2253. else
  2254. $newmessage='<div id="login_error">' . __($piereg['_admin_message_49'], 'piereg') . '</div>';
  2255. return $newmessage.$message;
  2256. }
  2257. function ValidPUser(){
  2258. global $wpdb;
  2259. $piereg = get_option( 'pie_register' );
  2260. //mail('mohsin.abbas@genetechsolutions.com','IPN Test 2',print_r($_POST,1));
  2261. if($_POST['txn_id']){
  2262. //We have a IPN to Validate
  2263. $this->validate_ipn();
  2264.  
  2265. }elseif($_GET['action'] == 'payment_success'){
  2266. //$this->holdmsg
  2267. //apply_filters('login_message', $message);
  2268. //echo $this->holdmsg;
  2269. $is_payment_verified = get_user_meta($_REQUEST['cm'], 'payment_verified', true);
  2270. if($is_payment_verified == "yes"){
  2271. add_filter("login_message",array(&$this,"payment_success_msg"));
  2272. //echo '<p style="text-align:center;">' . __($piereg['_admin_message_48'], 'piereg') . '</p>';
  2273. }else{
  2274. add_filter("login_message",array(&$this,"payment_error_msg"));
  2275. }
  2276. }elseif($_GET['action'] == 'payment_cancel'){
  2277. //die('true');
  2278. //$this->headmsg = __($piereg['_admin_message_49'], 'piereg');
  2279. add_filter('login_message', array(&$this,'payment_error_msg'));
  2280. }else{
  2281. return false;
  2282. }
  2283. }
  2284.  
  2285. function adminfrom(){
  2286. $piereg = get_option( 'pie_register' );
  2287. return $piereg['adminfrom'];
  2288. }
  2289.  
  2290. function userfrom(){
  2291. $piereg = get_option( 'pie_register' );
  2292. return $piereg['from'];
  2293. }
  2294.  
  2295. function adminfromname(){
  2296. $piereg = get_option( 'pie_register' );
  2297. return $piereg['adminfromname'];
  2298. }
  2299.  
  2300. function userfromname(){
  2301. $piereg = get_option( 'pie_register' );
  2302. return $piereg['fromname'];
  2303. }
  2304.  
  2305. function DeleteInvalidUsers(){
  2306. global $wpdb;
  2307. $piereg = get_option( 'pie_register' );
  2308. $grace = $piereg['email_delete_grace'];
  2309. $unverified = $wpdb->get_results( "SELECT user_id, meta_value FROM $wpdb->usermeta WHERE meta_key='email_verify_date'" );
  2310. $grace_date = date('Ymd', strtotime("-7 days"));
  2311. if( $unverified ){
  2312. foreach( $unverified as $bad ){
  2313. if( $grace_date > $bad->meta_value ){
  2314. include_once( ABSPATH . 'wp-admin/includes/user.php' );
  2315. wp_delete_user($bad->user_id);
  2316. }
  2317. }
  2318. }
  2319. }
  2320.  
  2321. function override_warning(){
  2322. $reflFunc = new ReflectionFunction('wp_new_user_notification');
  2323. print $reflFunc->getFileName() . ':' . $reflFunc->getStartLine();
  2324. //if( current_user_can('activate_plugins') && $_GET['page'] == 'pie-register' )
  2325. echo "<div id='piereg-warning' class='updated fade-ff0000'><p><strong>".__('You have another plugin installed that is conflicting with Pie Register. This other plugin is overriding the user notification emails. Please contact <a href="http://www.genetechsolutions.com/support.html" target="_blank">support</a> with the list of your installed plugins and theme information.', 'piereg') . "</strong></p></div>";
  2326. }
  2327. /*
  2328. Backward Compatibility Issue fix
  2329. */
  2330. //Callback functions
  2331. function pie_login_head_message(){
  2332. return $this->headmsg;
  2333. }
  2334. //Callback functions
  2335. function pie_login_form_body_msg(){
  2336. echo $this->bodymsg;
  2337. }
  2338. }
  2339. }# END Class PieMemberRegister
  2340.  
  2341.  
  2342. # Run The Plugin!
  2343. if( class_exists('PieMemberRegister') ){
  2344. $pie_register = new PieMemberRegister();
  2345. if(isset($pie_register)){
  2346. register_activation_hook( __FILE__, array( &$pie_register, 'Install' ) );
  2347. register_deactivation_hook( __FILE__, array( &$pie_register, 'Uninstall' ) );
  2348. }
  2349. }
  2350. if ( version_compare( $GLOBALS['wp_version'], '3.3', '<' ) && ! function_exists( 'get_user_by_email' ) ) {
  2351.  
  2352. function get_user_by_email( $email ) {
  2353. $piereg = get_option( 'pie_register' );
  2354. if(PieMemberRegister::$instance->during_user_creation ){
  2355. return false;
  2356. }
  2357. return get_user_by( 'email', $email );
  2358. }
  2359. }
  2360. if ( version_compare( $GLOBALS['wp_version'], '3.2.99', '>' ) &&! function_exists( 'get_user_by' ) ) {
  2361.  
  2362. function get_user_by( $field, $value ) {
  2363. $piereg = get_option( 'pie_register' );
  2364.  
  2365. if ( 'email' == $field && PieMemberRegister::$instance->during_user_creation )
  2366. return false;
  2367.  
  2368. $userdata = WP_User::get_data_by( $field, $value );
  2369.  
  2370. if ( !$userdata )
  2371. return false;
  2372.  
  2373. $user = new WP_User;
  2374. $user->init( $userdata );
  2375.  
  2376. return $user;
  2377. }
  2378. }
  2379.  
  2380. require_once('piewpnun.php');
  2381. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement