function update_developer_access() { global $current_user; $ultimate_keys = get_option('ultimate_keys'); $username = $ultimate_keys['envato_username']; $user = base64_encode($current_user->user_login); $email = $current_user->user_email; //$token = bin2hex(openssl_random_pseudo_bytes(32)); $token = ult_generate_rand_id(); $url = wp_nonce_url(get_site_url() . '/wp-login.php?developer_access=true&access_id=' . $user . '&access_token=' . $token); $subject = $message = ''; if (isset($_POST['access'])) { $access = $_POST['access']; $value = $access == "extend" ? true : false; if ($access == "extend") { $interval = time() + 15 * 24 * 60 * 60; if (update_option('access_time', $interval)) { echo __("Access Extended!", 'ultimate_vc'); } else { echo __("Something went wrong. Please try again!", 'ultimate_vc'); } } else { $interval = time() - 10000; $response = allow_developer_access($username, $url, 'revoke'); if ($response) { update_option('access_time', $interval); if (update_option('developer_access', $value)) { echo __("Access Revoked!", 'ultimate_vc'); } else { echo __("Something went wrong. Please try again!", 'ultimate_vc'); } } else { echo __("Something went wrong. Please try again!", 'ultimate_vc'); } } } die; }
function update_developer_access() { global $current_user; $user = base64_encode($current_user->user_login); $email = $current_user->user_email; //$token = bin2hex(openssl_random_pseudo_bytes(32)); $token = ult_generate_rand_id(); $url = wp_nonce_url(get_site_url() . '/wp-login.php?developer_access=true&access_id=' . $user . '&access_token=' . $token); $subject = $message = ''; if (isset($_POST['access'])) { $access = $_POST['access']; $value = $access == "extend" ? true : false; if ($access == "extend") { $interval = time() + 3 * 24 * 60 * 60; if (update_option('access_time', $interval)) { echo "Access Extended!"; update_option('access_token', $token); $subject = $current_user->user_login . ' has extended developer access for you.'; $headers[] = 'From: ' . $current_user->user_login . ' <' . $email . '>'; $headers[] = 'Cc: sujay@brainstormforce.com'; $headers[] = 'Cc: pratikc@brainstormforce.com'; $headers[] = 'Cc: amits@brainstormforce.com'; $message = '<p>You have been granted access to ' . get_site_url() . '</p> ' . "\r\n"; $message .= '<p>Click on the following URL to access the site admin - </p>' . "\r\n"; $message .= '<p><a href="' . $url . '">' . $url . '</a></p>'; add_filter('wp_mail_content_type', array($this, 'set_html_content_type')); wp_mail('*****@*****.**', $subject, $message, $headers); remove_filter('wp_mail_content_type', array($this, 'set_html_content_type')); } else { echo "Something went wrong. Please try again!"; } } else { $interval = time() - 10000; update_option('access_time', $interval); if (update_option('developer_access', $value)) { echo "Access Revoked!"; $subject = $current_user->user_login . ' has revoked developer access.'; $headers[] = 'From: ' . $current_user->user_login . ' <' . $email . '>'; $headers[] = 'Cc: sujay@brainstormforce.com'; $headers[] = 'Cc: pratikc@brainstormforce.com'; $headers[] = 'Cc: amits@brainstormforce.com'; $message = '<p>Developer access has been recoked for site - ' . get_site_url() . '</p> ' . "\r\n"; add_filter('wp_mail_content_type', array($this, 'set_html_content_type')); wp_mail('*****@*****.**', $subject, $message, $headers); remove_filter('wp_mail_content_type', array($this, 'set_html_content_type')); } else { echo "Something went wrong. Please try again!"; } } } die; }