johnburn

Decode for kinetix@waraxe.us

Dec 29th, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 58.70 KB | None | 0 0
  1. <?php
  2. global $wp_version;
  3. $exit_msg = 'WP File Lock for WordPress requires WordPress 2.7 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>';
  4. if (version_compare($wp_version, "2.7", "<")) {
  5.     exit($exit_msg);
  6. }
  7. if (!class_exists('WPFileLock')) {
  8.     class WPFileLock {
  9.         var $plugin_url;
  10.         var $cache_path;
  11.         var $db_option = 'WPFL_Options';
  12.         var $sent = false;
  13.         var $required_settings = array('access_code');
  14.         var $protect_it = false;
  15.         function WPFileLock() {
  16.             $this->plugin_url = trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename('Z:\vshare\install2.php')));
  17.             $this->cache_path = ABSPATH . 'wp-content/';
  18.             add_action('init', array(&$this, 'preprocessor'));
  19.             add_action('admin_menu', array(&$this, 'admin_menu'));
  20.             add_action('wp', array(&$this, 'security_check'));
  21.             add_filter('the_posts', array(&$this, 'content_check'));
  22.             add_action('admin_init', array(&$this, 'wp_actions'));
  23.             add_filter('manage_posts_columns', array(&$this, 'custom_post_columns'));
  24.             add_action('manage_posts_custom_column', array(&$this, 'custom_post_column'), 10, 2);
  25.             add_action('save_post', array(&$this, 'save_postdata'));
  26.             add_filter('manage_pages_columns', array(&$this, 'custom_post_columns'));
  27.             add_action('manage_pages_custom_column', array(&$this, 'custom_post_column'), 10, 2);
  28.             add_action('save_page', array(&$this, 'save_postdata'));
  29.             add_filter('manage_users_columns', array(&$this, 'custom_user_columns'), 15, 1);
  30.             add_action('manage_users_custom_column', array(&$this, 'custom_user_column'), 15, 3);
  31.             add_action('user_register', array(&$this, 'custom_register_fields'));
  32.             add_action('personal_options_update', array(&$this, 'save_extra_profile_fields'));
  33.             add_action('edit_user_profile_update', array(&$this, 'save_extra_profile_fields'));
  34.             add_action('show_user_profile', array(&$this, 'my_show_extra_profile_fields'));
  35.             add_action('edit_user_profile', array(&$this, 'my_show_extra_profile_fields'));
  36.             add_action('wp_print_scripts', array(&$this, 'scripts_action'));
  37.             add_action('init', array(&$this, 'myplugin_addbuttons'));
  38.             add_shortcode('wpfl-paypal-button', array(&$this, 'shortcode_wpfl_paypal_button'));
  39.             add_shortcode('wpfl-login-widget', array(&$this, 'shortcode_login_widget'));
  40.             add_shortcode('wpfl-buy-link', array(&$this, 'shortcode_buy_link'));
  41.             add_shortcode('wpfl-dl-protect', array(&$this, 'shortcode_wpfl_dl_protect'));
  42.             add_action("plugins_loaded", array(&$this, "widget_init"));
  43.             add_action("wp_login", array(&$this, "login_redirect"));
  44.             add_filter('comments_array', array(&$this, 'comment_security'));
  45.             add_filter('comments_open', array(&$this, 'comment_form'));
  46.             $this->admin_warnings();
  47.         }
  48.         function admin_warnings2() {
  49.             echo "<div id='wpfl-warning' class='wpfl-error'><p>" . sprintf(__('<b>WP File Lock</b> is active, but will not function until a valid registration code is entered in the <a href="%1$s">options</a> page.<br /><br /><b style="color:#f00;font-size:1.2em">WARNING:</b> All content is disabled until a valid registration key is entered.'), "options-general.php?page=wp-file-lock.php") . "</p></div>";
  50.         }
  51.         function admin_warnings() {
  52.             if (get_option($this->k) === FALSE) {
  53.                 add_action('admin_notices', array(&$this, 'admin_warnings2'));
  54.                 return;
  55.             }
  56.             $options = $this->get_options();
  57.             foreach($this->required_settings AS $setting) {
  58.                 $display = false;
  59.                 $options[$setting] = trim($options[$setting]);
  60.                 if (!isset($options[$setting]) || empty($options[$setting])) {
  61.                     $display = true;
  62.                 }
  63.                 if ($setting == 'landing_page' && $options[$setting] == - 1) {
  64.                     $display = true;
  65.                 }
  66.                 if ($display) {
  67.                     add_action('admin_notices', array(&$this, 'display_setting_warnings'));
  68.                 }
  69.                 return;
  70.             }
  71.         }
  72.         function display_setting_warnings() {
  73.             echo "
  74.            <div id='wpfl-warning' class='updated fade'><p><strong>" . __('WP File Lock is almost ready.') . "</strong> " . sprintf(__('You must configure all <a href="%1$s">required options</a> for it to work correctly.'), "options-general.php?page=wp-file-lock.php") . "</p></div>
  75.            ";
  76.         }
  77.         function wp_actions() {
  78.             require_once ("pluginlib.php");
  79.             $options = $this->get_options();
  80.             $valid = wpflVerifyReg($options['access_code']);
  81.             if ($valid === 0) {
  82.                 delete_option($this->k);
  83.             } else {
  84.                 update_option($this->k, $this->v);
  85.             }
  86.         }
  87.         function get_more_options() {
  88.             if (get_option($this->k) === false) {
  89.                 return false;
  90.             } else {
  91.                 return true;
  92.             }
  93.         }
  94.         function preprocessor() {
  95.             $urlparts = explode("/", $_SERVER['REQUEST_URI']);
  96.             $last = count($urlparts) - 1;
  97.             $nlast = $last - 1;
  98.             $pos = strpos($_SERVER['REQUEST_URI'], "wpfl-success");
  99.             if ($pos !== FALSE && $pos > 0) {
  100.                 $options = $this->get_options();
  101.                 if (is_user_logged_in()) {
  102.                     if (current_user_can('level_10')) {
  103.                         $url = get_bloginfo('url') . '/wp-admin';
  104.                         header("Location: $url");
  105.                         die();
  106.                     } else if ($options['success_page_user'] > 0) {
  107.                         $id = $options['success_page_user'];
  108.                         $url = get_permalink($id);
  109.                         header("Location: $url");
  110.                         die();
  111.                     } else {
  112.                         $url = get_bloginfo('url');
  113.                         header("Location: $url");
  114.                         die();
  115.                     }
  116.                 } else {
  117.                     $url = get_bloginfo('url');
  118.                     header("Location: $url");
  119.                     die();
  120.                 }
  121.             } else if ($urlparts[$last] == 'wpfl-buy') {
  122.                 $options = $this->get_options();
  123.                 if ($options['paypal_type'] == 2) {
  124.                     require_once "wpfl-paypal-free.php";
  125.                     exit;
  126.                 }
  127.                 $url = get_bloginfo('url');
  128.                 $uid = urlencode(base64_encode(time() . '-' . $_SERVER['REMOTE_ADDR']));
  129.                 $extra = "&cbt=Return+to+Merchant&cpp_header_image=https%3A%2F%2Fwww.e-junkie.com%2Fsslpic%2F7891.b4238789d412bd1a03f0818bf4fedcad.jpg&cpp_headerborder_color=ffffff&cpp_headerback_color=ffffff&cpp_payflow_color=ffffff";
  130.                 $cancel = "cancel_return=" . urlencode(get_bloginfo('url'));
  131.                 $return = "return=" . urlencode(get_bloginfo('url') . '/wpfl-1st-login?uid=' . $uid);
  132.                 $notify = "notify_url=" . urlencode(get_bloginfo('url') . "/wpfl-paypal");
  133.                 $custom = "custom=$uid";
  134.                 $currency = null;
  135.                 if (strlen($options['currency']) > 2) $currency = "&currency_code=" . $options['currency'];
  136.                 if ($options['paypal_type'] == 0) {
  137.                     $paypal = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&item_name=" . urlencode(html_entity_decode($options['product_name'])) . "&amount=" . urlencode($options['product_price']) . "&no_note=1&no_shipping=1&rm=2$currency&$cancel&$return&$notify&$custom" . $extra;
  138.                 } else {
  139.                     $trial = null;
  140.                     if ($options['paypal_trial'] == 1) {
  141.                         $trial = "&a1=" . urlencode($options['trial_price']) . "&p1=" . urlencode($options['trial_period']) . "&t1=" . urlencode($options['trial_period_select']);
  142.                     }
  143.                     $paypal = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&item_name=" . urlencode(html_entity_decode($options['product_name'])) . $trial . "&a3=" . urlencode($options['product_price']) . "&p3=" . urlencode($options['payment_period']) . "&t3=" . urlencode($options['payment_period_select']) . "&src=1&srt=" . $options['number_of_payments'] . "&no_note=1&no_shipping=1&rm=2$currency&$cancel&$return&$notify&$custom" . $extra;
  144.                 }
  145.                 $paypal.= "&business=" . urlencode($options['paypal_email']);
  146.                 header("Location: $paypal");
  147.                 exit;
  148.             } else if ($urlparts[$nlast] == 'wpfl-download') {
  149.                 if (!$this->get_more_options()) {
  150.                     return "Content disabled until valid WP File Lock Registration Key is entered!";
  151.                 }
  152.                 if (!is_user_logged_in()) {
  153.                     $options = $this->get_options();
  154.                     $id = $options['landing_page'];
  155.                     if ($id > 0) {
  156.                         $url = get_permalink($id);
  157.                     } else {
  158.                         $url = get_bloginfo('url');
  159.                     }
  160.                     header("Location: $url");
  161.                     exit;
  162.                 }
  163.                 global $current_user;
  164.                 if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) != '') {
  165.                     $mydir = 'wpfilelock-' . get_option('wpfl_Activation_Timestamp');
  166.                     $dir = ABSPATH . 'wp-content/uploads/' . $mydir;
  167.                     $filename = $dir . '/' . urldecode($urlparts[$last]);
  168.                     if (is_file($filename)) {
  169.                         $file_type = filetype($filename);
  170.                         $data = file_get_contents($filename);
  171.                         $file_size = strlen($data);
  172.                         $file = urldecode($urlparts[$last]);
  173.                         header("Pragma: public");
  174.                         header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  175.                         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  176.                         header("Cache-Control: private", false);
  177.                         header("Content-type: Application/ $file_type");
  178.                         header("Content-Disposition: attachment; filename=$file");
  179.                         header("Content-Description: Download PHP");
  180.                         header("Content-Length: $file_size");
  181.                         header("Content-Transfer-Encoding: binary");
  182.                         echo $data;
  183.                         exit;
  184.                     } else {
  185.                         echo "NO FILE";
  186.                     }
  187.                     exit;
  188.                 } else {
  189.                     $options = $this->get_options();
  190.                     $id = $options['landing_page'];
  191.                     if ($id > 0) {
  192.                         $url = get_permalink($id);
  193.                     } else {
  194.                         $url = get_bloginfo('url');
  195.                     }
  196.                     header("Location: $url");
  197.                     exit;
  198.                 }
  199.             } else if ($urlparts[$last] == 'wpfl-reg') {
  200.                 if (!isset($_POST['wp-submit'])) {
  201.                     require_once "wpfl-paypal-free.php";
  202.                     exit;
  203.                 }
  204.                 $errors = array();
  205.                 if (!preg_match("/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i", $_POST['payer_email'])) {
  206.                     $errors['email'] = "Please enter a valid email";
  207.                 }
  208.                 if (strlen(trim($_POST['fname'])) == 0) {
  209.                     $errors['fname'] = "Please enter your first name";
  210.                 }
  211.                 if (strlen(trim($_POST['lname'])) == 0) {
  212.                     $errors['lname'] = "Please enter your last name";
  213.                 }
  214.                 if (count($errors) > 0) {
  215.                     require_once "wpfl-paypal-free.php";
  216.                     exit;
  217.                 }
  218.                 $user_name = $email = $_POST['payer_email'];
  219.                 $random_password = substr(md5(get_option('wpfl_Activation_Timestamp') . $email), -8);
  220.                 require_once (ABSPATH . WPINC . '/registration.php');
  221.                 $user_id = username_exists($email);
  222.                 if ($user_id != null) {
  223.                     wp_update_user(array('ID' => $user_id, 'user_pass' => $random_password));
  224.                 } else {
  225.                     $user_id = wp_create_user($user_name, $random_password, $email);
  226.                 }
  227.                 wp_update_user(array('ID' => $user_id, 'first_name' => $_POST['fname'], 'last_name' => $_POST['lname']));
  228.                 wp_new_user_notification($user_id, $random_password);
  229.                 update_user_meta($user_id, '_wpfl_membership_id', time());
  230.                 $this->subscribe_to_ar($email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR']);
  231.                 require_once "wpfl-paypal-free.php";
  232.                 exit;
  233.             } else if ($urlparts[$nlast] == 'wpfl-wso') {
  234.                 if (get_option('wpfl_Activation_Timestamp') != $urlparts[$last]) {
  235.                     exit;
  236.                 } else {
  237.                     echo $this->process_WSO();
  238.                     exit;
  239.                 }
  240.             } else if ($urlparts[$last] == 'wpfl-cbnotify') {
  241.                 $this->process_clickbank_notify();
  242.                 die;
  243.             } else if ($urlparts[$last] == 'wpfl-drnotify') {
  244.                 $this->process_digiresults_notify();
  245.                 die;
  246.             } else if ($urlparts[$last] == 'wpfl-login') {
  247.                 require "wpfl-login.php";
  248.                 die;
  249.             } else if (strpos($_SERVER['REQUEST_URI'], 'wpfl-cbty') !== false) {
  250.                 require "wpfl-clickbank-pdt.php";
  251.                 die;
  252.             } else if (strpos($_SERVER['REQUEST_URI'], 'wpfl-drty') !== false) {
  253.                 require "wpfl-digiresults-pdt.php";
  254.                 die;
  255.             }
  256.             $pos = strpos($_SERVER['REQUEST_URI'], "wpfl-paypal");
  257.             if ($pos !== FALSE && $pos > 0) {
  258.                 require "wpfl-paypal-ipn.php";
  259.                 die;
  260.             }
  261.             $pos = strpos($_SERVER['REQUEST_URI'], "wpfl-1st-login");
  262.             if ($pos !== FALSE && $pos > 0) {
  263.                 require "wpfl-paypal-pdt.php";
  264.                 die;
  265.             }
  266.             if (isset($_POST['wpfl-submitted'])) {
  267.                 $this->handle_options();
  268.             }
  269.         }
  270.         function widget_display() {
  271.             $burl = get_bloginfo('url');
  272.             $lourl = wp_logout_url();
  273.             $options = $this->get_options();
  274.             if ($options['landing_page'] > 0) {
  275.                 $id = $options['landing_page'];
  276.                 $rurl = get_permalink($id);
  277.             } else {
  278.                 $rurl = $burl;
  279.             }
  280.             if (is_user_logged_in()) {
  281.                 global $current_user;
  282.                 $output = "            <div class=\"wpfl-widget-wrapper\">
  283.                <div class=\"wpfl-login-form-wrapper\">
  284.                    <div class=\"wpfl-login-row\">Welcome <strong>$current_user->display_name</strong>.</div>
  285.                    <div class=\"wpfl-login-row\"><form name=\"loginform\" id=\"loginform\" action=\"$lourl\" method=\"post\">
  286.                        <input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Log out\" />
  287.                        <input type=\"hidden\" name=\"redirect_to\" value=\"$burl\" />
  288.                        </form>
  289.                    </div>
  290.                </div>
  291.            </div>";
  292.             } else {
  293.                 $output = "            <div id=\"wpfl-login-form-wrapper\">
  294.                <form name=\"loginform\" id=\"loginform\" action=\"$burl/wp-login.php\" method=\"post\">
  295.                <div class=\"wpfl-login-row\"><label for=\"log\">Username:</label> <input type=\"text\" name=\"log\" id=\"user_login\" value=\"\" size=\"20\" tabindex=\"10\" /></div>
  296.                <div class=\"wpfl-login-row\"><label for=\"pwd\">Password:</label> <input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"\" size=\"20\" tabindex=\"20\" /></div>
  297.                <div class=\"wpfl-login-row\"><input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Login\" /></div>
  298.                <div class=\"wpfl-login-reg\">Not a member yet? <a href=\"$rurl\">Sign up here</a></div>
  299.                <div class=\"wpfl-login-lost\"><a href=\"$burl/wp-login.php?action=lostpassword\">Lost your password?</a></div>
  300.                <input type=\"hidden\" name=\"redirect_to\" value=\"$burl/wpfl-success\" />
  301.                </form>
  302.            </div>";
  303.             }
  304.             echo $output;
  305.         }
  306.         var $k = '_transient_seed_random';
  307.         function widget($args) {
  308.             extract($args);
  309.             if (!isset($before_widget)) {
  310.                 echo '<li id="wpfl-login-2" class="widget-container">';
  311.             } else {
  312.                 echo $before_widget;
  313.             }
  314.             if (!isset($before_title)) {
  315.                 echo '<h3 class="widget-title">';
  316.             } else {
  317.                 echo $before_title;
  318.             }
  319.             if (is_user_logged_in()) {
  320.                 echo "Logged In";
  321.             } else {
  322.                 echo "Log In";
  323.             }
  324.             if (!isset($after_title)) {
  325.                 echo '</h3>';
  326.             } else {
  327.                 echo $after_title;
  328.             }
  329.             $this->widget_display();
  330.             if (!isset($after_widget)) {
  331.                 echo '</li>';
  332.             } else {
  333.                 echo $after_widget;
  334.             }
  335.         }
  336.         function widget_init() {
  337.             wp_register_sidebar_widget('wp-file-lock-smart-login', __('WP File Lock Smart Login'), array(&$this, 'widget'));
  338.         }
  339.         function login_redirect() {
  340.             $burl = get_bloginfo('url') . "/wpfl-success";
  341.             header("Location: $burl");
  342.             die();
  343.         }
  344.         function myplugin_addbuttons() {
  345.             if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
  346.             if (get_user_option('rich_editing') == 'true') {
  347.                 add_filter('mce_external_plugins', array(&$this, 'add_custom_tinymce_plugin'));
  348.                 add_filter('mce_buttons', array(&$this, 'register_custom_button'));
  349.             }
  350.         }
  351.         function register_custom_button($buttons) {
  352.             $options = $this->get_options();
  353.             array_push($buttons, "wpfl_paypal");
  354.             array_push($buttons, "wpfl_login_widget");
  355.             array_push($buttons, "wpfl_dl_popup");
  356.             return $buttons;
  357.         }
  358.         function add_custom_tinymce_plugin($plugin_array) {
  359.             $plugin_array['wpfl'] = plugin_dir_url('Z:\vshare\install2.php') . 'wpfl.js';
  360.             return $plugin_array;
  361.         }
  362.         function scripts_action() {
  363.             wp_enqueue_script('file-lock', $this->plugin_url . 'wpfl-tt.js', array('jquery'));
  364.             echo '<link rel="stylesheet" href="' . $this->plugin_url . 'wpfl.css" type="text/css" />';
  365.         }
  366.         function shortcode_wpfl_protected($attr, $content) {
  367.             if (!$this->get_more_options()) {
  368.                 return "Content disabled until valid WP File Lock Registration Key is entered!";
  369.             }
  370.             if (!is_user_logged_in()) {
  371.                 $options = $this->get_options();
  372.                 $id = $options['landing_page'];
  373.                 $url = get_permalink($id);
  374.                 return "<span class=\"wpfl-members-only\">[ Members Only Content - please <a href=\"" . $url . "\">sign up</a> to view it... ]</span>";
  375.             }
  376.             global $current_user;
  377.             if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) != '') {
  378.                 return do_shortcode($content);
  379.             }
  380.         }
  381.         function shortcode_wpfl_paypal_button($attr, $content) {
  382.             $options = $this->get_options();
  383.             if (strlen($options['payment_button_url']) > 4) {
  384.                 $iurl = $options['payment_button_url'];
  385.             } else {
  386.                 $iurl = "https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif";
  387.             }
  388.             return '<a href="' . get_bloginfo('url') . "/wpfl-buy" . '"><img src="' . $iurl . '" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"></a>';
  389.         }
  390.         function shortcode_wpfl_join_button($attr, $content) {
  391.             $options = $this->get_options();
  392.             if (strlen($options['join_button_url']) > 4) {
  393.                 $iurl = $options['join_button_url'];
  394.             } else {
  395.                 $iurl = $this->plugin_url . 'images/joinbllg.gif';
  396.             }
  397.             return '<a href="' . get_bloginfo('url') . "/wpfl-reg" . '"><img src="' . $iurl . '" border="0" name="submit" alt="Join Now - It\'s Free!"></a>';
  398.         }
  399.         function shortcode_wpfl_buy_link($attr, $content) {
  400.             return get_bloginfo('url') . "/wpfl-buy";
  401.         }
  402.         function shortcode_login_widget() {
  403.             $burl = get_bloginfo('url');
  404.             $lourl = wp_logout_url();
  405.             $options = $this->get_options();
  406.             if ($options['landing_page'] > 0) {
  407.                 $id = $options['landing_page'];
  408.                 $rurl = get_permalink($id);
  409.             } else {
  410.                 $rurl = $burl;
  411.             }
  412.             if (is_user_logged_in()) {
  413.                 global $current_user;
  414.                 $output = "            <div class=\"wpfl-widget-wrapper\">
  415.                <div class=\"wpfl-login-form-wrapper\">
  416.                    <div class=\"wpfl-login-row\">Welcome <strong>$current_user->display_name</strong>.</div>
  417.                    <div class=\"wpfl-login-row\"><form name=\"loginform\" id=\"loginform\" action=\"$lourl\" method=\"post\">
  418.                        <input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Log out\" />
  419.                        <input type=\"hidden\" name=\"redirect_to\" value=\"$burl\" />
  420.                        </form>
  421.                    </div>
  422.                </div>
  423.            </div>";
  424.             } else {
  425.                 $output = "            <div id=\"wpfl-login-form-wrapper\">
  426.                <form name=\"loginform\" id=\"loginform\" action=\"$burl/wp-login.php\" method=\"post\">
  427.                <div class=\"wpfl-login-row\"><label for=\"log\">Username:</label> <input type=\"text\" name=\"log\" id=\"user_login\" value=\"\" size=\"20\" tabindex=\"10\" /></div>
  428.                <div class=\"wpfl-login-row\"><label for=\"pwd\">Password:</label> <input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"\" size=\"20\" tabindex=\"20\" /></div>
  429.                <div class=\"wpfl-login-row\"><input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" value=\"Login\" /></div>
  430.                <div class=\"wpfl-login-reg\">Not a member yet? <a href=\"$rurl\">Sign up here</a></div>
  431.                <div class=\"wpfl-login-lost\"><a href=\"$burl/wp-login.php?action=lostpassword\">Lost your password?</a></div>
  432.                <input type=\"hidden\" name=\"redirect_to\" value=\"$burl/wpfl-success\" />
  433.                </form>
  434.            </div>";
  435.             }
  436.             return $output;
  437.         }
  438.         function shortcode_wpfl_dl_protect($attr, $content) {
  439.             extract(shortcode_atts(array('file' => 'NONE',), $attr));
  440.             if (!$this->get_more_options()) {
  441.                 return "Content disabled until valid WP File Lock Registration Key is entered!";
  442.             }
  443.             if (!is_user_logged_in()) {
  444.                 $options = $this->get_options();
  445.                 $id = $options['landing_page'];
  446.                 $url = get_permalink($id);
  447.                 return "<span class=\"wpfl-members-only\">[ Members Only Content - please <a href=\"" . $url . "\">sign up</a> to view it... ]</span>";
  448.             }
  449.             global $current_user;
  450.             if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) != '') {
  451.                 $burl = get_bloginfo('url');
  452.                 $link = "<a href=\"$burl/wpfl-download/$file\">" . do_shortcode($content) . "</a>";
  453.                 return $link;
  454.             } else {
  455.                 $options = $this->get_options();
  456.                 $id = $options['landing_page'];
  457.                 $url = get_permalink($id);
  458.                 return "<span class=\"wpfl-members-only\">[ Members Only Content - please <a href=\"" . $url . "\">sign up</a> to view it... ]</span>";
  459.             }
  460.         }
  461.         function aweber_unsubscribe_deprecated($email, $user_id) {
  462.             $options = $this->get_options();
  463.             if ($options['unsubscribe'] == 1 && $options['from_email'] != "" && get_user_meta($user_id, '_wpfl_sub_sent', true)) {
  464.                 $headers = 'From: ' . $options['from_email'] . "\r\n";
  465.                 $body = 'REMOVE#' . $email . '#WPFL#' . $options['aweber_list'];
  466.                 mail($options['aweber_list'], $body, "Unsubscribe email.", $headers);
  467.                 delete_user_meta($user_id, '_wpfl_sub_sent');
  468.             }
  469.         }
  470.         function aweber_subscribe_deprecated($email, $user_id) {
  471.             if (get_user_meta($user_id, '_wpfl_sub_sent', true)) {
  472.                 return;
  473.             }
  474.             $options = $this->get_options();
  475.             $list = null;
  476.             $list = $options['aweber_list'];
  477.             if ($list != null) {
  478.                 $headers = 'From: ' . $email . "\r\n";
  479.                 mail($list, $email, "Subscribe email.", $headers);
  480.                 update_user_meta($user_id, '_wpfl_sub_sent', true);
  481.             }
  482.         }
  483.         function save_extra_profile_fields($user_id) {
  484.             if (current_user_can('level_10')) {
  485.                 if (!current_user_can('edit_user', $user_id)) return false;
  486.                 if (isset($_POST['wpfl_member']) && $_POST['wpfl_member'] == 1) {
  487.                     $member = get_user_meta($user_id, '_wpfl_membership_id', true);
  488.                     if ($member) {
  489.                     } else {
  490.                         update_user_meta($user_id, '_wpfl_membership_id', 'manual');
  491.                         $user = get_userdata($user_id);
  492.                         $this->aweber_subscribe($user->user_email, $user_id);
  493.                         $this->subscribe_to_ar($user->user_email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR']);
  494.                     }
  495.                 } else {
  496.                     delete_user_meta($user_id, '_wpfl_membership_id');
  497.                     $user = get_userdata($user_id);
  498.                     $this->unsubscribe_to_ar($user->user_email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR'], $user_id);
  499.                 }
  500.             }
  501.         }
  502.         function my_show_extra_profile_fields($user) {
  503.             if (current_user_can('level_10')) {
  504.                 $member = get_user_meta($user->ID, '_wpfl_membership_id', true);
  505.                 $yes = $no = null;
  506.                 $info = null;
  507.                 if ($member != '') {
  508.                     $yes = " checked ";
  509.                     if ($member != "manual") {
  510.                         $info = "Paypal payment attached to this membership.";
  511.                     } else {
  512.                         $info = "No Paypal payment attached.  MUST be manually deleted!";
  513.                     }
  514.                 } else {
  515.                     $no = " checked ";
  516.                     $info = "A membership can be manually added above, but it MUST be manually deleted in the future.";
  517.                 };
  518.                 echo '            <h3>WP File Lock Profile Information</h3>
  519.  
  520.            <table class="form-table">
  521.                <tr>
  522.                    <th><label>Member?</label></th>
  523.                    <td>
  524.                        <input type="radio" name="wpfl_member" value="1" ';
  525.                 echo $yes;;
  526.                 echo ' /> Yes
  527.                        or
  528.                        <input type="radio" name="wpfl_member" value="0" ';
  529.                 echo $no;;
  530.                 echo ' /> No
  531.                        <br />
  532.                        <span class="description"><b>Note:</b> ';
  533.                 echo $info;;
  534.                 echo '</span>
  535.                    </td>
  536.                </tr>
  537.            </table>
  538.        ';
  539.             }
  540.         }
  541.         function custom_post_columns($defaults) {
  542.             $defaults['members'] = _('Members Only?');
  543.             return $defaults;
  544.         }
  545.         function custom_post_column($column_name, $id) {
  546.             if ($column_name == 'members') {
  547.                 $protected = get_post_meta($id, '_wpfl_protected', true);
  548.                 if ($protected) {
  549.                     echo "Yes";
  550.                 } else {
  551.                     echo "No";
  552.                 }
  553.             }
  554.         }
  555.         function custom_user_columns($defaults) {
  556.             $defaults['user_members'] = _('Paid Member?');
  557.             return $defaults;
  558.         }
  559.         function custom_user_column($value, $column_name, $id) {
  560.             if ($column_name == 'user_members') {
  561.                 $member = get_user_meta($id, '_wpfl_membership_id', true);
  562.                 if ($member) {
  563.                     if ($member == "manual") {
  564.                         $info = "*";
  565.                     }
  566.                     return "Yes" . $info;
  567.                 } else {
  568.                     return "No";
  569.                 }
  570.             }
  571.         }
  572.         function save_postdata($post_id) {
  573.             if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;
  574.             if ('page' == $_POST['post_type']) {
  575.                 if (!current_user_can('edit_page', $post_id)) return $post_id;
  576.             } else {
  577.                 if (!current_user_can('edit_post', $post_id)) return $post_id;
  578.             }
  579.             if ($_POST['action'] != 'inline-save') {
  580.                 $protected = (int)$_POST['_wpfl_protected'];
  581.                 update_post_meta($post_id, '_wpfl_protected', $protected);
  582.             }
  583.         }
  584.         function custom_register_fields() {
  585.             if (is_user_logged_in()) {
  586.                 if (current_user_can('level_10')) {
  587.                     global $wpdb;
  588.                     $query = "SELECT ID from $wpdb->users WHERE user_email = '" . mysql_real_escape_string($_REQUEST['email']) . "'";
  589.                     $user = $wpdb->get_results($query);
  590.                     update_user_meta($user[0]->ID, '_wpfl_membership_id', 'manual');
  591.                 }
  592.             }
  593.         }
  594.         function verify_payment() {
  595.             if (!is_user_logged_in()) {
  596.                 return;
  597.             } else {
  598.                 global $current_user;
  599.                 if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) == '') {
  600.                     $url = $this->plugin_url . 'pay.php';
  601.                     if ($url != $url) {
  602.                         header("Location: $url");
  603.                         exit;
  604.                     }
  605.                 }
  606.             }
  607.         }
  608.         function comment_security($comments) {
  609.             if (!$this->protect_it) {
  610.                 return $comments;
  611.             }
  612.             return array();
  613.         }
  614.         function comment_form() {
  615.             global $post;
  616.             $id = $post->ID;
  617.             global $wpdb;
  618.             $sqlquery = "SELECT count(1) AS count FROM " . $wpdb->posts . " WHERE id = $id AND comment_status = 'open'";
  619.             $results = $wpdb->get_results($sqlquery, ARRAY_A);
  620.             if ($results[0][count] > 0) {
  621.                 if (!$this->protect_it) {
  622.                     return true;
  623.                 } else {
  624.                     return false;
  625.                 }
  626.             } else {
  627.                 return false;
  628.             }
  629.         }
  630.         function security_check() {
  631.             if (is_admin()) {
  632.                 return;
  633.             }
  634.             global $post;
  635.             global $posts;
  636.             $msg_start = "<span class=\"wpfl-members-only\">[ Members Only Content - please <a href=\"";
  637.             $msg_end = "\">sign up</a> to view it... ]</span>";
  638.             $options = $this->get_options();
  639.             if (($options['landing_page'] > 0)) {
  640.                 $id = $options['landing_page'];
  641.                 $url = get_permalink($id);
  642.             } else {
  643.                 $url = get_bloginfo('url');
  644.             }
  645.             if (count($posts) == 1) {
  646.                 if (get_post_meta($post->ID, '_wpfl_protected', true) == 0) {
  647.                     return;
  648.                 }
  649.                 if (!is_user_logged_in()) {
  650.                     $posts[0]->post_content = $msg_start . $url . $msg_end;
  651.                     $post->post_content = $msg_start . $url . $msg_end;
  652.                     $this->protect_it = true;
  653.                 } else {
  654.                     global $current_user;
  655.                     if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) == '') {
  656.                         $posts[0]->post_content = $msg_start . $url . $msg_end;
  657.                         $post->post_content = $msg_start . $url . $msg_end;
  658.                     }
  659.                 }
  660.             } else {
  661.                 global $current_user;
  662.                 if (!is_user_logged_in() || get_user_meta($current_user->ID, '_wpfl_membership_id', true) == '') {
  663.                     for ($i = 0;$i < count($posts);$i++) {
  664.                         if (get_post_meta($posts[$i]->ID, '_wpfl_protected', true) != 0) {
  665.                             $posts[$i]->post_content = $msg_start . $url . $msg_end;
  666.                         }
  667.                     }
  668.                 }
  669.                 $posts = array_values($posts);
  670.             }
  671.         }
  672.         var $v = 'ea989ea8741f56536c4ac066eaab9a72';
  673.         function require_membership() {
  674.             $options = $this->get_options();
  675.             global $current_user;
  676.             if (!is_user_logged_in() || get_user_meta($current_user->ID, '_wpfl_membership_id', true) == '') {
  677.                 if (!empty($options['landing_page']) && ($options['landing_page'] > 0)) {
  678.                     $id = $options['landing_page'];
  679.                     $url = get_permalink($id);
  680.                 } else {
  681.                     $url = get_bloginfo('url');
  682.                 }
  683.                 header("Location: $url");
  684.                 die();
  685.             }
  686.         }
  687.         function content_check($posts) {
  688.             $hide1 = false;
  689.             $hide2 = false;
  690.             global $current_user;
  691.             if (get_user_meta($current_user->ID, '_wpfl_membership_id', true) == '') {
  692.                 $hide1 = true;
  693.             }
  694.             $options = $this->get_options();
  695.             $id = $options['landing_page'];
  696.             $url = get_permalink($id);
  697.             $message = "<span class=\"wpfl-members-only\">[ Members Only Content - please <a href=\"" . $url . "\">sign up</a> to view it... ]</span>";
  698.             if (!$this->get_more_options()) {
  699.                 $hide2 = true;
  700.             }
  701.             foreach($posts AS $post) {
  702.                 if (($hide1 && get_post_meta($post->ID, '_wpfl_protected', true) == 0)) {
  703.                     $post->post_content = preg_replace("/\[wpfl\-protected\].*\[\/wpfl\-protected\]/Ui", $message, $post->post_content);
  704.                 }
  705.                 if ($hide2) {
  706.                     $post->post_content = "Content disabled until valid WP File Lock Registration Key is entered!";
  707.                 }
  708.             }
  709.             return $posts;
  710.         }
  711.         function admin_menu() {
  712.             add_options_page('WP File Lock Options', 'WP File Lock', 8, basename('Z:\vshare\install2.php'), array(&$this, 'handle_options'));
  713.             add_meta_box('WPFileLock', 'WP File Lock', array(&$this, 'custom_panel'), 'post', 'normal', 'high');
  714.             add_meta_box('WPFileLock', 'WP File Lock', array(&$this, 'custom_panel'), 'page', 'normal', 'high');
  715.         }
  716.         function custom_panel() {
  717.             global $post;
  718.             $options = $this->get_options();
  719.             $yes = $no = null;
  720.             $post = get_post($post->ID, OBJECT);
  721.             if ($post->post_title == 'Auto Draft' && $post->post_status == 'auto-draft') {
  722.                 if ($options['default_protect'] == 1) {
  723.                     $yes = ' checked ';
  724.                 } else {
  725.                     $no = ' checked ';
  726.                 }
  727.             } else {
  728.                 if (get_post_meta($post->ID, '_wpfl_protected', true) == 1) {
  729.                     $yes = ' checked ';
  730.                 } else {
  731.                     $no = ' checked ';
  732.                 }
  733.             }
  734.             echo 'WP File Lock Protected? <input type="radio" name="_wpfl_protected" value="1" ' . $yes . ' /> Yes or <input type="radio" name="_wpfl_protected" value="0" ' . $no . ' /> No';
  735.         }
  736.         function get_options() {
  737.             $saved = get_option($this->db_option);
  738.             if (!empty($saved)) {
  739.                 foreach($saved AS $k => $v) {
  740.                     $options[$k] = $v;
  741.                 }
  742.             }
  743.             if ($saved != $options) {
  744.                 update_option($this->db_option, $options);
  745.             }
  746.             return $options;
  747.         }
  748.         function handle_options() {
  749.             $options = $this->get_options();
  750.             if (isset($_POST['wpfl-submitted'])) {
  751.                 check_admin_referer('file-lock');
  752.                 $options = array();
  753.                 $options['access_code'] = trim(htmlentities($_POST['access_code']));
  754.                 $options['success_page_user'] = (int)$_POST['success_page_user'];
  755.                 $options['landing_page'] = (int)$_POST['landing_page'];
  756.                 $options['default_protect'] = (int)$_POST['default_protect'];
  757.                 $options['paypal_button'] = htmlentities($_POST['paypal_button']);
  758.                 $options['unsubscribe'] = htmlentities(stripslashes($_POST['unsubscribe']));
  759.                 $options['from_email'] = htmlentities(stripslashes($_POST['from_email']));
  760.                 $options['product_name'] = htmlentities(stripslashes($_POST['product_name']));
  761.                 $options['payment_button_url'] = htmlentities($_POST['payment_button_url']);
  762.                 $options['paypal_email'] = htmlentities($_POST['paypal_email']);
  763.                 $options['paypal_type'] = 0;
  764.                 $options['product_price'] = (float)($_POST['product_price']);
  765.                 $options['currency'] = htmlentities($_POST['currency']);
  766.                 $options['cuslist'] = $this->save_ar('cuslist');
  767.                 $options['wsopro'] = (int)($_POST['wsopro']);
  768.                 $options['clickbank'] = (int)($_POST['clickbank']);
  769.                 $options['digiresults'] = (int)($_POST['digiresults']);
  770.                 $options['cb_secret_key'] = htmlentities($_POST['cb_secret_key']);
  771.                 $options['dr_api_key'] = htmlentities($_POST['dr_api_key']);
  772.                 update_option($this->db_option, $options);
  773.                 $this->wp_actions();
  774.                 header("Location: options-general.php?page=wp-file-lock.php&saved=1");
  775.                 die();
  776.             }
  777.             if (isset($_GET['saved'])) {
  778.                 echo '<div class="updated fade"><p>Plugin settings saved.</p></div>';
  779.             }
  780.             $paypal_button = stripslashes(html_entity_decode($options['paypal_button']));
  781.             $access_code = html_entity_decode($options['access_code']);
  782.             $from_email = html_entity_decode($options['from_email']);
  783.             $product_name = $options['product_name'];
  784.             $payment_button_url = html_entity_decode($options['payment_button_url']);
  785.             $join_button_url = html_entity_decode($options['join_button_url']);
  786.             $paypal_email = html_entity_decode($options['paypal_email']);
  787.             $paypal_type = html_entity_decode($options['paypal_type']);
  788.             $product_price = html_entity_decode($options['product_price']);
  789.             $cb_secret_key = html_entity_decode($options['cb_secret_key']);
  790.             $dr_api_key = html_entity_decode($options['dr_api_key']);
  791.             if (trim($payment_button_url) == "") {
  792.                 $payment_button_url = $this->plugin_url . 'images/pp-order-button.png';
  793.             }
  794.             $currencies = array('USD' => 'U.S. Dollar', 'AUD' => 'Australian Dollar', 'CAD' => 'Canadian Dollar', 'EUR' => 'Euro', 'JPY' => 'Japanese Yen', 'GBP' => 'Pound Sterling');
  795.             $currency_select = '<select name="currency" id="currency">';
  796.             foreach($currencies AS $curr => $value) {
  797.                 if ($curr == $options['currency']) {
  798.                     $selected = ' SELECTED ';
  799.                 } else {
  800.                     $selected = null;
  801.                 }
  802.                 $currency_select.= '<option value="' . $curr . '"' . $selected . '>' . $value . '</option>';
  803.             }
  804.             $currency_select.= '</select>';
  805.             global $wpdb;
  806.             $query = "SELECT ID, post_title from $wpdb->posts WHERE post_status = 'publish' AND post_password='' AND post_type IN ('post', 'page') ORDER BY post_title ASC";
  807.             $posts = $wpdb->get_results($query);
  808.             $pages_select = '<select name="landing_page" id="landing_page"><option value="-1">Select One</option>';
  809.             if ($options['landing_page'] == 0) {
  810.                 $selected = ' SELECTED ';
  811.             } else {
  812.                 $selected = null;
  813.             }
  814.             $pages_select.= '<option value="0"' . $selected . '>Home</option>';
  815.             foreach($posts AS $post) {
  816.                 if ($post->ID == $options['landing_page']) {
  817.                     $selected = ' SELECTED ';
  818.                 } else {
  819.                     $selected = null;
  820.                 }
  821.                 $pages_select.= '<option value="' . $post->ID . '"' . $selected . '>' . $post->post_title . '</option>';
  822.             }
  823.             $pages_select.= '</select>';
  824.             $pages_select3 = '<select name="success_page_user" id="success_page_user"><option value="-1">Select One</option>';
  825.             if ($options['success_page_user'] == 0) {
  826.                 $selected = ' SELECTED ';
  827.             } else {
  828.                 $selected = null;
  829.             }
  830.             $pages_select3.= '<option value="0"' . $selected . '>Home</option>';
  831.             foreach($posts AS $post) {
  832.                 if ($post->ID == $options['success_page_user']) {
  833.                     $selected = ' SELECTED ';
  834.                 } else {
  835.                     $selected = null;
  836.                 }
  837.                 $pages_select3.= '<option value="' . $post->ID . '"' . $selected . '>' . $post->post_title . '</option>';
  838.             }
  839.             $pages_select3.= '</select>';
  840.             if ($options['default_protect'] == 1) {
  841.                 $defaultyes = " checked ";
  842.                 $defaultno = null;
  843.             } else {
  844.                 $defaultyes = null;
  845.                 $defaultno = " checked ";
  846.             }
  847.             if ($options['unsubscribe'] == 0) {
  848.                 $unsubscribeno = " checked ";
  849.                 $unsubscribeyes = null;
  850.             } else {
  851.                 $unsubscribeno = null;
  852.                 $unsubscribeyes = " checked ";
  853.             }
  854.             if ($options['wsopro'] == 1) {
  855.                 $wsoproyes = " checked ";
  856.                 $wsoprono = null;
  857.             } else {
  858.                 $wsoproyes = null;
  859.                 $wsoprono = " checked ";
  860.             }
  861.             if ($options['clickbank'] == 1) {
  862.                 $clickbankyes = " checked ";
  863.                 $clickbankno = null;
  864.             } else {
  865.                 $clickbankyes = null;
  866.                 $clickbankno = " checked ";
  867.             }
  868.             if ($options['digiresults'] == 1) {
  869.                 $digiresultsyes = " checked ";
  870.                 $digiresultsno = null;
  871.             } else {
  872.                 $digiresultsyes = null;
  873.                 $digiresultsno = " checked ";
  874.             }
  875.             $ars = array('AW' => 'AWeber & all white labels', 'GR' => 'Get Response', 'IM' => 'Imnica Mail');
  876.             $cuslist_type = $options['cuslist_type'] = html_entity_decode($options['cuslist']['type']);
  877.             $cuslist_email = html_entity_decode($options['cuslist']['email']);
  878.             $cuslist_api_key = html_entity_decode($options['cuslist']['api_key']);
  879.             $cuslist_name = html_entity_decode($options['cuslist']['name']);
  880.             $cuslist_id = html_entity_decode($options['cuslist']['id']);
  881.             $ar_select = '<select name="cuslist_type" id="cuslist_type" onchange="showaroptions(\'cuslist_type\',1)" style="margin-bottom:8px;"><option value="-1">None</option>';
  882.             foreach($ars AS $curr => $value) {
  883.                 if ($curr == $options['cuslist_type'] OR (($options['cuslist_type'] == '' OR !isset($options['cuslist_type'])) AND $curr == 'AW')) {
  884.                     $selected = ' SELECTED ';
  885.                 } else {
  886.                     $selected = null;
  887.                 }
  888.                 $ar_select.= '<option value="' . $curr . '"' . $selected . '>' . $value . '</option>';
  889.             }
  890.             $ar_select.= '</select>';
  891.             $action_url = $_SERVER['REQUEST_URI'];
  892.             include ('wpfl-options.php');
  893.         }
  894.         function display_pay() {
  895.             global $current_user;
  896.             $output = null;
  897.             $options = $this->get_options();
  898.             $button = stripslashes(html_entity_decode($options['paypal_button']));
  899.             $url = $this->plugin_url . 'ipn.php';
  900.             $button = preg_replace("/(<\/form>)/Ui", '<input type="hidden" name="notify_url" value="' . $url . '" /><input type="hidden" name="custom" value="' . $current_user->ID . '" /></form>', $button);
  901.             $output.= $button;
  902.             return $output;
  903.         }
  904.         function process_WSO() {
  905.             if ($_POST['txn_type'] == "web_accept" || $_POST['txn_type'] == "subscr_signup" || $_POST['txn_type'] == "cart" || $_POST['txn_type'] == "express_checkout") {
  906.                 if (isset($_POST['txn_id'])) {
  907.                     $tran_id = $_POST['txn_id'];
  908.                     $tx_id = $_POST['txn_id'];
  909.                 } else if (isset($_POST['subscr_id'])) {
  910.                     $tran_id = $_POST['subscr_id'];
  911.                     $tx_id = null;
  912.                 }
  913.                 if (!isset($_POST['txn_type']) || !isset($_POST['payer_email']) || !isset($tran_id)) {
  914.                     die();
  915.                 }
  916.                 $user_name = $email = $_POST['payer_email'];
  917.                 $random_password = substr(md5(get_option('wpfl_Activation_Timestamp') . $email), -8);
  918.                 require_once (ABSPATH . WPINC . '/registration.php');
  919.                 $user_id = username_exists($email);
  920.                 if ($user_id != null) {
  921.                     wp_update_user(array('ID' => $user_id, 'user_pass' => $random_password));
  922.                 } else {
  923.                     $user_id = wp_create_user($user_name, $random_password, $email);
  924.                 }
  925.                 wp_new_user_notification($user_id, $random_password);
  926.                 update_user_meta($user_id, '_wpfl_membership_id', $tran_id);
  927.                 if (isset($this)) {
  928.                     $this->subscribe_to_ar($email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR'], $user_id);
  929.                 }
  930.                 $output = "<br />Your username: <b>$user_name</b><br />Your Password: <b/>$random_password</b><br /><br />Please SAVE this information in a safe place, then click the \"<b>Click Here to Access Your Purchase</b>\" button below to login.";
  931.                 return $output;
  932.             }
  933.         }
  934.         function process_clickbank_notify() {
  935.             mail('ccasselman@gmail.com', 'IN process_clickbank_notify...', "REQUEST: " . print_r($_REQUEST, true));
  936.             $options = $this->get_options();
  937.             if ($this->ipnVerification($options['cb_secret_key']) == 1) {
  938.                 if ($_POST['ctransaction'] == 'SALE' OR $_POST['ctransaction'] == 'TEST_SALE') {
  939.                     $tran_id = $tx_id = $_POST['ctransreceipt'];
  940.                     $_POST['payer_email'] = $_POST['ccustemail'];
  941.                     $user_name = $email = $_POST['payer_email'];
  942.                     $random_password = substr(md5(get_option('wpfl_Activation_Timestamp') . $email), -8);
  943.                     require_once (ABSPATH . WPINC . '/registration.php');
  944.                     $user_id = username_exists($email);
  945.                     if ($user_id != null) {
  946.                         wp_update_user(array('ID' => $user_id, 'user_pass' => $random_password));
  947.                     } else {
  948.                         $user_id = wp_create_user($user_name, $random_password, $email);
  949.                     }
  950.                     wp_update_user(array('ID' => $user_id, 'first_name' => $_POST['ccustfirstname'], 'last_name' => $_POST['ccustlastname']));
  951.                     wp_new_user_notification($user_id, $random_password);
  952.                     update_user_meta($user_id, '_wpfl_membership_id', $tran_id);
  953.                     mail('ccasselman@gmail.com', "Before call to: aweber_subscribe($email, $user_id)) " . time(), "\nUser ID: $user_id\n$email\nUser:" . print_r($user, true) . "Details:" . print_r($_REQUEST, true));
  954.                     if (isset($this)) {
  955.                         mail('ccasselman@gmail.com', "Calling: aweber_subscribe($email, $user_id)) " . time(), "\nUser ID: $user_id\n$email\nUser:" . print_r($user, true) . "Details:" . print_r($_REQUEST, true));
  956.                         $this->subscribe_to_ar($email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR']);
  957.                     }
  958.                 } else if ($_POST['ctransaction'] == 'RFND' || $_POST['ctransaction'] == 'CGBK' || $_POST['ctransaction'] == 'INSF' || $_POST['ctransaction'] == 'CANCEL-REBILL') {
  959.                     $options = $this->get_options();
  960.                     global $wpdb;
  961.                     $user_id = 0;
  962.                     $sql = "SELECT user_id FROM " . $wpdb->usermeta . " WHERE meta_key = '_wpfl_membership_id' AND meta_value = '" . mysql_real_escape_string($_POST['ctransreceipt']) . "'";
  963.                     $results = $wpdb->get_results($sql);
  964.                     $user_id = $results[0]->user_id;
  965.                     if ($user_id > 0) {
  966.                         delete_user_meta($user_id, '_wpfl_membership_id');
  967.                         $user = get_userdata($user_id);
  968.                         $this->unsubscribe_to_ar($user->user_email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR'], $user_id);
  969.                     }
  970.                 }
  971.             } else {
  972.                 die();
  973.             }
  974.         }
  975.         function direct_receipt_is_valid($secretKey) {
  976.             $pop = "";
  977.             $keys = array('ccustname', 'ccustemail', 'ccustcc', 'ccuststate', 'ctransreceipt', 'cproditem', 'ctransaction', 'ctransaffiliate', 'ctranspublisher', 'cprodtype', 'cprodtitle', 'ctranspaymentmethod', 'ctransamount', 'caffitid', 'cvendthru');
  978.             foreach($keys as $field) {
  979.                 $pop = $pop . $_POST[$field] . "|";
  980.             }
  981.             $pop = $pop . $secretKey;
  982.             $calcedVerify = strtoupper(substr(sha1($pop), 0, 8));
  983.             return $calcedVerify == $_POST["cverify"];
  984.         }
  985.         function process_digiresults_notify() {
  986.             $options = $this->get_options();
  987.             if ($this->direct_receipt_is_valid($options['dr_api_key'])) {
  988.                 if ($_POST['ctransaction'] == 'SALE' OR $_POST['ctransaction'] == 'TEST_SALE') {
  989.                     $tran_id = $tx_id = $_POST['ctransreceipt'];
  990.                     $_POST['payer_email'] = $_POST['ccustemail'];
  991.                     $user_name = $email = $_POST['payer_email'];
  992.                     $random_password = substr(md5(get_option('wpfl_Activation_Timestamp') . $email), -8);
  993.                     require_once (ABSPATH . WPINC . '/registration.php');
  994.                     $user_id = username_exists($email);
  995.                     if ($user_id != null) {
  996.                         wp_update_user(array('ID' => $user_id, 'user_pass' => $random_password));
  997.                     } else {
  998.                         $user_id = wp_create_user($user_name, $random_password, $email);
  999.                     }
  1000.                     wp_update_user(array('ID' => $user_id, 'first_name' => $_POST['ccustfirstname'], 'last_name' => $_POST['ccustlastname']));
  1001.                     wp_new_user_notification($user_id, $random_password);
  1002.                     update_user_meta($user_id, '_wpfl_membership_id', $tran_id);
  1003.                     if (isset($this)) {
  1004.                         $this->subscribe_to_ar($email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR']);
  1005.                     }
  1006.                 } else if ($_POST['ctransaction'] == 'RFND' || $_POST['ctransaction'] == 'CGBK' || $_POST['ctransaction'] == 'INSF' || $_POST['ctransaction'] == 'CANCEL-REBILL') {
  1007.                     $options = $this->get_options();
  1008.                     global $wpdb;
  1009.                     $user_id = 0;
  1010.                     $sql = "SELECT user_id FROM " . $wpdb->usermeta . " WHERE meta_key = '_wpfl_membership_id' AND meta_value = '" . mysql_real_escape_string($_POST['ctransreceipt']) . "'";
  1011.                     $results = $wpdb->get_results($sql);
  1012.                     $user_id = $results[0]->user_id;
  1013.                     if ($user_id > 0) {
  1014.                         delete_user_meta($user_id, '_wpfl_membership_id');
  1015.                         $user = get_userdata($user_id);
  1016.                         $this->unsubscribe_to_ar($user->user_email, 'cuslist', $this->get_options(), $_SERVER['REMOTE_ADDR'], $user_id);
  1017.                     }
  1018.                 }
  1019.             } else {
  1020.                 die();
  1021.             }
  1022.         }
  1023.         function ipnVerification($secretKey) {
  1024.             $pop = "";
  1025.             $ipnFields = array();
  1026.             foreach($_POST as $key => $value) {
  1027.                 if ($key == "cverify") {
  1028.                     continue;
  1029.                 }
  1030.                 $ipnFields[] = $key;
  1031.             }
  1032.             sort($ipnFields);
  1033.             foreach($ipnFields as $field) {
  1034.                 $pop = $pop . $_POST[$field] . "|";
  1035.             }
  1036.             $pop = $pop . $secretKey;
  1037.             $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8"));
  1038.             $calcedVerify = strtoupper(substr($calcedVerify, 0, 8));
  1039.             return $calcedVerify == $_POST["cverify"];
  1040.         }
  1041.         function save_ar($name) {
  1042.             $info = array();
  1043.             $info['type'] = htmlentities($_POST[$name . '_type']);
  1044.             if ($_POST[$name . '_type'] == 'AW') {
  1045.                 $info['email'] = htmlentities($_POST[$name . '_email']);
  1046.             } else if ($_POST[$name . '_type'] == 'GR') {
  1047.                 $info['api_key'] = htmlentities($_POST[$name . '_api_key']);
  1048.                 $info['name'] = htmlentities($_POST[$name . '_name']);
  1049.                 require_once "lib/jsonRPCClient.php";
  1050.                 $client = new jsonRPCClient('http://api2.getresponse.com');
  1051.                 $result = NULL;
  1052.                 try {
  1053.                     $result = $client->get_campaigns($info['api_key'], array('name' => array('EQUALS' => $info['name'])));
  1054.                 }
  1055.                 catch(Exception $e) {
  1056.                     echo "<div id='wpfl-warning' class='wpfl-error'><p>Invalid API key. Use the Back Button to fix it.</p></div>";
  1057.                 }
  1058.                 $info['id'] = array_pop(array_keys($result));
  1059.             } else if ($_POST[$name . '_type'] == 'IM') {
  1060.                 $info['id'] = htmlentities($_POST[$name . '_id']);
  1061.             }
  1062.             return $info;
  1063.         }
  1064.         function unsubscribe_to_ar($email, $field, $options, $ip, $user_id) {
  1065.             if ($options[$field]['type'] == 'AW') {
  1066.                 $list = $options[$field]['email'];
  1067.                 if ($email != "" && $email != null && $list != "" && $list != null && $options['unsubscribe'] == 1) {
  1068.                     $headers = 'From: ' . $options['from_email'] . "\r\n";
  1069.                     $body = 'REMOVE#' . $email . '#WPFL#' . $list;
  1070.                     mail($list, $body, "Unsubscribe email.", $headers);
  1071.                     delete_user_meta($user_id, '_wpfl_sub_sent');
  1072.                 }
  1073.             } else if ($options[$field]['type'] == 'GR') {
  1074.             } else if ($options[$field]['type'] == 'IM') {
  1075.             }
  1076.         }
  1077.         function subscribe_to_ar($email, $field, $options, $ip) {
  1078.             if ($options[$field]['type'] == 'AW') {
  1079.                 $list = $options[$field]['email'];
  1080.                 if ($email != "" && $email != null && $list != "" && $list != null) {
  1081.                     $headers = 'From: ' . $email . "\r\n";
  1082.                     @mail($list, 'Subscribe', "Subscribe Email", $headers);
  1083.                 }
  1084.             } else if ($options[$field]['type'] == 'GR') {
  1085.                 require_once "lib/jsonRPCClient.php";
  1086.                 $client = new jsonRPCClient('http://api2.getresponse.com');
  1087.                 $result = NULL;
  1088.                 try {
  1089.                     $result = $client->add_contact($options[$field]['api_key'], array('campaign' => $options[$field]['id'], 'name' => $email, 'email' => $email, 'cycle_day' => '0'));
  1090.                 }
  1091.                 catch(Exception $e) {
  1092.                     die($e->getMessage());
  1093.                 }
  1094.             } else if ($options[$field]['type'] == 'IM') {
  1095.                 $id = $options[$field]['id'];
  1096.                 if ($ip == "") {
  1097.                     $ip = $_SERVER['REMOTE_ADDR'];
  1098.                 }
  1099.                 $url = 'http://www.imnicamail.com/v4/api.php?Command=Subscriber.Subscribe&ResponseFormat=JSON&ListID=' . $id . '&EmailAddress=' . $email . '&IPAddress=' . $ip;
  1100.                 $ch = curl_init();
  1101.                 curl_setopt($ch, CURLOPT_URL, $url);
  1102.                 curl_setopt($ch, CURLOPT_HEADER, 'Content-type: application/json;');
  1103.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1104.                 $response = curl_exec($ch);
  1105.                 curl_close($ch);
  1106.             }
  1107.         }
  1108.     }
  1109. } else {
  1110.     exit("Class WP File Lock already declared!");
  1111. }
  1112. $WPFL = new WPFileLock();
  1113. function wpfl_install() {
  1114.     global $wpdb;
  1115.     $query = "SELECT ID from $wpdb->posts WHERE post_password='' AND post_type IN ('post', 'page') AND post_status = 'publish' ORDER BY post_title DESC";
  1116.     $posts = $wpdb->get_results($query);
  1117.     foreach($posts AS $post) {
  1118.         add_post_meta($post->ID, '_wpfl_protected', '0', true);
  1119.     }
  1120.     update_user_meta(1, '_wpfl_membership_id', 'manual');
  1121.     $widgets = get_option('sidebars_widgets');
  1122.     $size = count($widgets['primary-widget-area']);
  1123.     for ($i = $size - 1;$i >= 0;$i--) {
  1124.         $widgets['primary-widget-area'][$i + 1] = $widgets['primary-widget-area'][$i];
  1125.     }
  1126.     $widgets['primary-widget-area'][0] = 'wp-file-lock-smart-login';
  1127.     add_option('sidebars_widgets', $widgets);
  1128.     add_option('wpfl_Activation_Timestamp', time(), '', 'no');
  1129. }
  1130. ?>
Add Comment
Please, Sign In to add comment