Advertisement
Guest User

pie-register.php

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