function __construct() { $this->ipn_status = ''; $this->txn_id = null; $this->ipn_log = true; $this->ipn_response = ''; $this->ipn_debug = false; self::$pieinstance = $this; /***********************/ parent::__construct(); global $pagenow, $wp_version, $profile; $errors = new WP_Error(); add_action('wp_ajax_get_meta_by_field', array($this, 'getMeta')); add_action('wp_ajax_check_username', array($this, 'unique_user')); add_action('wp_ajax_nopriv_check_username', array($this, 'unique_user')); add_action('admin_init', array($this, 'piereg_register_scripts')); #Adding Menus add_action('admin_menu', array($this, 'AddPanel')); #plugin page links add_filter('plugin_action_links', array($this, 'add_action_links'), 10, 2); //Add paypal payment method add_action("check_payment_method_paypal", array($this, "check_payment_method_paypal")); //Adding "embed form" button add_action('media_buttons_context', array($this, 'add_pie_form_button')); if (in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php'))) { add_action('admin_footer', array($this, 'add_pie_form_popup')); } #Adding Short Code Functionality add_shortcode('pie_register_login', array($this, 'showLoginForm')); add_shortcode('pie_register_form', array($this, 'showForm')); add_shortcode('pie_register_profile', array($this, 'showProfile')); add_shortcode('pie_register_forgot_password', array($this, 'showForgotPasswordForm')); add_shortcode('pie_register_renew_account', array($this, 'show_renew_account')); #Genrate Warnings add_action('admin_notices', array($this, 'warnings'), 20); add_action('init', array($this, 'pie_main')); $profile = new Profile_admin(); add_action('show_user_profile', array($profile, "edit_user_profile")); add_action('personal_options_update', array($profile, "updateMyProfile")); add_action('edit_user_profile', array($profile, "edit_user_profile")); add_action('edit_user_profile_update', array($profile, 'updateProfile')); add_action('widgets_init', array($this, 'initPieWidget')); add_action('get_header', array($this, 'add_ob_start')); //It will redirect the User to the home page if the curren tpage is a alternate login page add_filter('get_header', array($this, 'checkLoginPage')); add_action('payment_validation_paypal', array($this, 'payment_validation_paypal')); add_action("Add_payment_option", array($this, "Add_payment_option")); add_action("add_payment_method_script", array($this, "add_payment_method_script")); add_action("add_select_payment_script", array($this, "add_select_payment_script")); add_action("get_payment_content_area", array($this, "get_payment_content_area")); add_action("show_icon_payment_gateway", array($this, "show_icon_payment_gateway")); add_filter("piereg_messages", array($this, "modify_all_notices")); /*update update_invitation_code form ajax*/ add_action('wp_ajax_pireg_update_invitation_code', array($this, 'pireg_update_invitation_code_cb_url')); add_action('wp_ajax_nopriv_pireg_update_invitation_code', array($this, 'pireg_update_invitation_code_cb_url')); //add_action( 'admin_enqueue_scripts' ,array($this,'pie_admin_menu_style_enqueu') ); ////FRONT END SCRIPTS add_action('wp_head', array($this, 'pie_frontend_ajaxurl')); add_action('wp_enqueue_scripts', array($this, 'pie_frontend_enqueu_scripts')); /* * Add sub links in wp plugin's page */ add_filter('plugin_row_meta', array($this, 'piereg_plugin_row_meta'), 10, 2); }
function pieResetFormOutput($piereg_widget = false) { $pie_register_base = new PieReg_Base(); /* * Sanitizing post data */ $pie_register_base->piereg_sanitize_post_data(isset($_POST) && !empty($_POST) ? $_POST : array()); $option = get_option('pie_register_2'); $forgot_pass_form = ''; $forgot_pass_form .= ' <div class="piereg_entry-content pieregForgotPassword"> <div id="piereg_forgotpassword">'; $warning = '<strong>' . ucwords(__("warning", "piereg")) . '</strong>: ' . __("Please enter your username or email address. You will receive a link to create a new password via email.", 'piereg'); $success = ""; if (isset($_POST['user_login']) and trim($_POST['user_login']) == "") { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Invalid Username or Email, try again!', 'piereg'); } elseif (isset($_POST['reset_pass'])) { $error_found = 0; if ($option['capthca_in_forgot_pass'] == 1) { $settings = get_option("pie_register_2"); $privatekey = $settings['captcha_private']; if ($privatekey) { require_once PIEREG_DIR_NAME . '/recaptchalib.php'; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Invalid Security Code', 'piereg'); $error_found++; } } } elseif ($option['capthca_in_forgot_pass'] == 2) { if (isset($_POST['piereg_math_captcha_forgot_pass'])) { $piereg_cookie_array = $_COOKIE['piereg_math_captcha_forgot_password']; /*$piereg_cookie_array = explode(",",$piereg_cookie_array);*/ $piereg_cookie_array = explode("|", $piereg_cookie_array); $cookie_result1 = intval(base64_decode($piereg_cookie_array[0])) - 12; $cookie_result2 = intval(base64_decode($piereg_cookie_array[1])) - 786; $cookie_result3 = intval(base64_decode($piereg_cookie_array[2])) + 5; if ($cookie_result1 == $cookie_result2 && $cookie_result3 == $_POST['piereg_math_captcha_forgot_pass']) { } else { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Invalid Captcha', 'piereg'); $error_found++; } } elseif (isset($_POST['piereg_math_captcha_forgot_pass_widget'])) { $piereg_cookie_array = $_COOKIE['piereg_math_captcha_forgot_password_widget']; /*$piereg_cookie_array = explode(",",$piereg_cookie_array);*/ $piereg_cookie_array = explode("|", $piereg_cookie_array); $cookie_result1 = intval(base64_decode($piereg_cookie_array[0])) - 12; $cookie_result2 = intval(base64_decode($piereg_cookie_array[1])) - 786; $cookie_result3 = intval(base64_decode($piereg_cookie_array[2])) + 5; if ($cookie_result1 == $cookie_result2 && $cookie_result3 == $_POST['piereg_math_captcha_forgot_pass_widget']) { } else { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Invalid Captcha', 'piereg'); $error_found++; } } else { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Invalid Captcha', 'piereg'); $error_found++; } } if ($error_found == 0) { global $wpdb, $wp_hasher; $error = array(); $username = trim($_POST['user_login']); $user_exists = false; // First check by username if (username_exists($username)) { $user_exists = true; $user = get_user_by('login', $username); } elseif (email_exists($username)) { $user_exists = true; $user = get_user_by_email($username); } else { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('Username or Email was not found, try again!', 'piereg'); } /* * If User Exist then */ if ($user_exists) { $user_login = $user->user_login; $user_email = $user->user_email; $allow = apply_filters('allow_password_reset', true, $user->ID); if ($allow) { //$allow = apply_filters( 'allow_password_reset', true, $user_data->ID ); do_action('retrieve_password_key', $user_login); // $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login)); // Generate something random for a key... if (empty($wp_hasher)) { require_once ABSPATH . 'wp-includes/class-phpass.php'; } $wp_hasher = new PasswordHash(8, true); $key = wp_generate_password(20, false); $hashed = $wp_hasher->HashPassword($key); do_action('retrieve_password_key', $user_login, $key); // Now insert the new md5 key into the db $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login)); $message_temp = ""; if ($option['user_formate_email_forgot_password_notification'] == "0") { $message_temp = nl2br(strip_tags($option['user_message_email_forgot_password_notification'])); } else { $message_temp = $option['user_message_email_forgot_password_notification']; } $message = $pie_register_base->filterEmail($message_temp, $user->user_login, '', $key); $from_name = $option['user_from_name_forgot_password_notification']; $from_email = $option['user_from_email_forgot_password_notification']; $reply_email = $option['user_to_email_forgot_password_notification']; $subject = html_entity_decode($option['user_subject_email_forgot_password_notification'], ENT_COMPAT, "UTF-8"); //Headers $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) { //Validating From $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n"; } if ($reply_email) { $headers .= "Reply-To: {$reply_email}\r\n"; $headers .= "Return-Path: {$from_name}\r\n"; } else { $headers .= "Reply-To: {$from_email}\r\n"; $headers .= "Return-Path: {$from_email}\r\n"; } //send email meassage if (FALSE == wp_mail($user_email, $subject, $message, $headers)) { $error[] = '<strong>' . ucwords(__("error", "piereg")) . '</strong>: ' . __('The e-mail could not be sent.', 'piereg') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'piereg'); } unset($key); unset($hashed); unset($_POST['user_login']); } else { $error[] = apply_filters('piereg_password_reset_not_allowed_text', __("Password reset is not allowed for this user", "piereg")); } /*$message = __('Someone has asked to reset the password for the following site and username.','piereg') . "\r\n\r\n"; $message .= get_option('siteurl') . "\r\n\r\n"; $message .= sprintf(__('Username:'******'piereg')." %s ", $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.','piereg') . "\r\n\r\n"; $message .= network_site_url("wp-login.php?action=rp&key=$key&login="******"&redirect_to=".urlencode(get_option('siteurl'))."\r\n";*/ if (count($error) == 0) { $success = '<strong>' . ucwords(__("success", "piereg")) . '</strong>: ' . apply_filters("piereg_message_will_be_sent_to_your_email", __('A message will be sent to your email address.', 'piereg')); } } } } $forgot_pass_form .= '<div id="piereg_login">'; if (isset($error) && is_array($error) && count($error) == 0) { $forgot_pass_form .= '<div class="alert alert-successs"><p class="piereg_message">'; $forgot_pass_form .= $success; $forgot_pass_form .= '</p></div>'; } else { if (isset($error) && is_array($error) && count($error) > 0) { $forgot_pass_form .= '<div class="alert alert-danger"><p class="piereg_login_error">'; $forgot_pass_form .= $error[0]; $forgot_pass_form .= '</p></div>'; } elseif ($warning) { $forgot_pass_form .= '<div class="alert alert-warning"><p class="piereg_warning">' . $warning . '</p></div>'; } } $forgot_pass_form .= ' <form method="post" action="' . $_SERVER['REQUEST_URI'] . '" id="piereg_lostpasswordform"> <p>'; if (isset($option['forgot_pass_username_label']) && !empty($option['forgot_pass_username_label'])) { $forgot_pass_form .= '<label for="user_login">' . (isset($option['forgot_pass_username_label']) && !empty($option['forgot_pass_username_label']) ? __($option['forgot_pass_username_label'], "piereg") : __("Username or E-mail:", "piereg")) . '</label>'; } $forgot_pass_form .= '<input type="text" size="20" value="" class="input validate[required]" id="user_login" name="user_login" style="margin : 10px 0px;" placeholder="' . (isset($option['forgot_pass_username_placeholder']) && !empty($option['forgot_pass_username_placeholder']) ? $option['forgot_pass_username_placeholder'] : "") . '"> </p> <input type="hidden" value="" name="redirect_to">'; global $piereg_math_captcha_forgot_pass, $piereg_math_captcha_forgot_pass_widget; if ($option['capthca_in_forgot_pass'] != 0 && !empty($option['capthca_in_forgot_pass'])) { if ($piereg_math_captcha_forgot_pass == false && $piereg_widget == false) { $forgot_pass_form .= '<p>'; if (!empty($option['capthca_in_forgot_pass_label'])) { $forgot_pass_form .= '<label style="margin-top:0px;">' . $option['capthca_in_forgot_pass_label'] . '</label>'; } $forgot_pass_form .= forgot_pass_captcha($option['capthca_in_forgot_pass'], $piereg_widget); $forgot_pass_form .= '</p>'; $piereg_math_captcha_forgot_pass = true; } elseif ($piereg_math_captcha_forgot_pass_widget == false && $piereg_widget == true) { $forgot_pass_form .= '<p>'; if (!empty($option['capthca_in_forgot_pass_label'])) { $forgot_pass_form .= '<label style="margin-top:0px;">' . $option['capthca_in_forgot_pass_label'] . '</label>'; } $forgot_pass_form .= forgot_pass_captcha($option['capthca_in_forgot_pass'], $piereg_widget); $forgot_pass_form .= '</p>'; $piereg_math_captcha_forgot_pass_widget = true; } } $forgot_pass_form .= '<p class="submit">'; do_action('pieresetpass'); $forgot_pass_form .= ' <input type="submit" value="' . __('Reset my password', "piereg") . '" class="button button-primary button-large" id="wp-submit" name="user-submit"> </p>'; //if(!is_page()) { if (isset($pagenow) && $pagenow == 'wp-login.php') { $forgot_pass_form .= '<p class="forgot_pass_links"> <a href="file://///192.168.14.2/projects/baqar/test_wp_plugin/wp-content/plugins/pie-register/' . wp_login_url() . '">' . __('Log in', "piereg") . '</a> | <a href="file://///192.168.14.2/projects/baqar/test_wp_plugin/wp-content/plugins/pie-register/' . wp_registration_url() . '">' . __('Register', "piereg") . '</a> </p> <p class="forgot_pass_links"><a title="' . __('Are you lost?', "piereg") . '" href="file://///192.168.14.2/projects/baqar/test_wp_plugin/wp-content/plugins/pie-register/' . get_bloginfo("url") . '">← ' . __('Back to', "piereg") . ' ' . get_bloginfo("name") . '</a></p>'; } $forgot_pass_form .= ' <input type="hidden" name="reset_pass" value="1" /> <input type="hidden" name="user-cookie" value="1" /> </form> </div> </div> </div>'; return $forgot_pass_form; }