예제 #1
2
function snp_ml_get_aw_lists()
{
    require_once SNP_DIR_PATH . '/include/aweber/aweber_api.php';
    $list = array();
    if (get_option('snp_ml_aw_auth_info')) {
        $aw = get_option('snp_ml_aw_auth_info');
        try {
            $aweber = new AWeberAPI($aw['consumer_key'], $aw['consumer_secret']);
            $account = $aweber->getAccount($aw['access_key'], $aw['access_secret']);
            $res = $account->lists;
            if ($res) {
                foreach ((array) $res->data['entries'] as $v) {
                    $list[$v['id']] = array('name' => $v['name']);
                }
            }
        } catch (AWeberException $e) {
            //echo $e;
        }
    }
    if (count($list) == 0) {
        $list[0] = array('name' => 'Nothing Found...');
    }
    return $list;
}
function eMember_aweber_new_signup_user($full_target_list_name, $fname, $lname, $email_to_subscribe)
{
    eMember_log_debug("Attempting to signup the user via AWeber API", true);
    $emember_config = Emember_Config::getInstance();
    $eMember_aweber_access_keys = $emember_config->getValue('eMember_aweber_access_keys');
    if (empty($eMember_aweber_access_keys['consumer_key'])) {
        eMember_log_debug("Missing AWeber access keys! You need to first make a conntect before you can use this API", false);
        return;
    }
    if (!class_exists('AWeberAPI')) {
        //TODO - change the class name to "eMember_AWeberAPI" to avoid conflict with others
        include_once 'lib/auto-responder/aweber_api/aweber_api.php';
        eMember_log_debug("AWeber API library inclusion succeeded.", true);
    } else {
        eMember_log_debug("AWeber API library is already included from another plugin.", true);
    }
    try {
        $aweber = new AWeberAPI($eMember_aweber_access_keys['consumer_key'], $eMember_aweber_access_keys['consumer_secret']);
        $account = $aweber->getAccount($eMember_aweber_access_keys['access_key'], $eMember_aweber_access_keys['access_secret']);
        //Get Aweber account
        $account_id = $account->id;
        $mylists = $account->lists;
    } catch (Exception $e) {
        eMember_log_debug($e->getMessage(), false);
        return;
    }
    eMember_log_debug("AWeber account retrieved. Account ID: " . $account_id, true);
    $target_list_name = str_replace("@aweber.com", "", $full_target_list_name);
    eMember_log_debug("Attempting to signup the user to the AWeber list: " . $target_list_name, true);
    $list_name_found = false;
    foreach ($mylists as $list) {
        if ($list->name == $target_list_name || $list->unique_list_id == $target_list_name) {
            $list_name_found = true;
            try {
                //Create a subscriber
                $params = array('email' => $email_to_subscribe, 'name' => $fname . ' ' . $lname);
                $subscribers = $list->subscribers;
                $new_subscriber = $subscribers->create($params);
                eMember_log_debug("User with email address " . $email_to_subscribe . " was added to the AWeber list: " . $target_list_name, true);
            } catch (Exception $exc) {
                eMember_log_debug("Failed to complete the AWeber signup! Error Details Below.", false);
                eMember_log_debug_array($exc, true);
            }
        }
    }
    if (!$list_name_found) {
        eMember_log_debug("Error! Could not find the AWeber list (" . $full_target_list_name . ") in your AWeber Account! Please double check your list name value for typo.", false);
    }
}
예제 #3
1
function pmproaw_getAccount($force = false)
{
    global $pmproaw_aweber_api, $pmproaw_aweber_account;
    if (empty($force) && empty($pmproaw_aweber_account)) {
        $options = get_option("pmproaw_options");
        if (empty($options['access_key']) || empty($options['access_secret'])) {
            return false;
        }
        try {
            $pmproaw_aweber_api = new AWeberAPI(PMPROAW_CONSUMER_KEY, PMPROAW_CONSUMER_SECRET);
            $pmproaw_aweber_account = $pmproaw_aweber_api->getAccount($options['access_key'], $options['access_secret']);
        } catch (AWeberAPIException $exc) {
            global $pmproaw_exception;
            $pmproaw_exception = $exc;
            return false;
        }
    }
    return $pmproaw_aweber_account;
}
        setcookie('requestTokenSecret', $requestTokenSecret);
        setcookie('callbackUrl', $callbackUrl);
        header("Location: {$aweber->getAuthorizeUrl()}");
        exit;
    }
    $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
    $aweber->user->requestToken = $_GET['oauth_token'];
    $aweber->user->verifier = $_GET['oauth_verifier'];
    list($accessToken, $accessTokenSecret) = $aweber->getAccessToken();
    setcookie('accessToken', $accessToken);
    setcookie('accessTokenSecret', $accessTokenSecret);
    header('Location: ' . $_COOKIE['callbackUrl']);
    exit;
}
$aweber->adapter->debug = true;
$account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);
$account->loadFromUrl('/accounts/326084?ws.op=getWebForms');
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>AWeber Test Application</title>
  <link type="text/css" rel="stylesheet" href="styles.css" />
<body>
<?php 
foreach ($account->lists as $offset => $list) {
    ?>
<h1>List: <?php 
    echo $list->name;
    ?>
</h1>
예제 #5
0
파일: premise.php 프로젝트: juslee/e27
 function get_aweber_account()
 {
     $this->initialize_aweber();
     $settings = $this->get_settings();
     $info = $settings['optin']['aweber-account-info'];
     $aweber = new AWeberAPI($info['consumer_key'], $info['consumer_secret']);
     try {
         $account = $aweber->getAccount($info['access_key'], $info['access_secret']);
     } catch (AWeberException $e) {
         $account = null;
     }
     return $account;
 }
예제 #6
0
 function validateAweberAuthorizationCode($code)
 {
     $this->initializeAweberApi();
     try {
         list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($code);
     } catch (AWeberException $e) {
         list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
     }
     if (!$access_secret) {
         return array('error' => __('Invalid Aweber authorization code.  Please make sure you entered it correctly.', 'premise'));
     }
     $aweber = new AWeberAPI($consumer_key, $consumer_secret);
     try {
         $account = $aweber->getAccount($access_key, $access_secret);
     } catch (AWeberResponseError $e) {
         $account = null;
     }
     if (!$account) {
         return array('error' => __('Unable to connect to Aweber account.  Please try again.', 'premise'));
     }
     return compact('consumer_key', 'consumer_secret', 'access_key', 'access_secret');
 }
 /**
  * Creates Aweber account using the data saved to plugin's database.
  * @return object or false
  */
 function get_aweber_account($name)
 {
     if (!class_exists('AWeberAPI')) {
         require_once get_template_directory() . '/includes/subscription/aweber/aweber_api.php';
     }
     $options_array = RAD_Rapidology::get_rapidology_options();
     $account = false;
     if (isset($options_array['accounts']['aweber'][$name])) {
         $consumer_key = $options_array['accounts']['aweber'][$name]['consumer_key'];
         $consumer_secret = $options_array['accounts']['aweber'][$name]['consumer_secret'];
         $access_key = $options_array['accounts']['aweber'][$name]['access_key'];
         $access_secret = $options_array['accounts']['aweber'][$name]['access_secret'];
         try {
             // Aweber requires curl extension to be enabled
             if (!function_exists('curl_init')) {
                 return false;
             }
             $aweber = new AWeberAPI($consumer_key, $consumer_secret);
             if (!$aweber) {
                 return false;
             }
             $account = $aweber->getAccount($access_key, $access_secret);
         } catch (Exception $exc) {
             return false;
         }
     }
     return $account;
 }
예제 #8
0
 public function makeAweberSubscribeEntry($user_id)
 {
     include userpro_path . 'lib/aweber_api/aweber_api.php';
     $email = userpro_profile_data('user_email', $user_id);
     $fname = userpro_profile_data('first_name', $user_id);
     $credentials = array();
     if (get_option('userpro_aweber_credentials') === false) {
         $credentials = AWeberAPI::getDataFromAweberID(userpro_get_option('aweber_api'));
         if (!$credentials) {
             echo 'Incorrect aweber authorization code';
         } else {
             update_option('userpro_aweber_credentials', $credentials);
         }
     } else {
         $credentials = get_option('userpro_aweber_credentials');
     }
     list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $credentials;
     $aweber = new AWeberAPI($consumerKey, $consumerSecret);
     $account = $aweber->getAccount($accessKey, $accessSecret);
     $account_id = $account->id;
     $mylists = $account->lists;
     $list_name_found = false;
     foreach ($mylists as $list) {
         if ($list->id == userpro_get_option('aweber_listname')) {
             $list_name_found = true;
             try {
                 //Create a subscriber
                 $params = array('email' => $email, 'name' => $fname);
                 $subscribers = $list->subscribers;
                 $new_subscriber = $subscribers->create($params);
             } catch (Exception $exc) {
             }
         }
     }
 }
예제 #9
0
function seed_cspv4_emaillist_aweber_add_subscriber($args)
{
    global $seed_cspv4, $seed_cspv4_post_result;
    extract($seed_cspv4);
    require_once SEED_CSPV4_PLUGIN_PATH . 'lib/nameparse.php';
    require_once SEED_CSPV4_PLUGIN_PATH . 'extentions/aweber/aweber_api/aweber_api.php';
    // If tracking enabled
    if (!empty($enable_reflink)) {
        seed_cspv4_emaillist_database_add_subscriber();
    }
    $aweber_auth = get_option('seed_cspv4_aweber_auth');
    extract($aweber_auth);
    if (!empty($consumer_key)) {
        $consumerKey = $consumer_key;
        $consumerSecret = $consumer_secret;
        $aweber = new AWeberAPI($consumerKey, $consumerSecret);
        $list_id = $aweber_listid;
        $name = '';
        if (!empty($_REQUEST['name'])) {
            $name = $_REQUEST['name'];
        }
        $email = $_REQUEST['email'];
        $fname = '';
        $lname = '';
        if (!empty($name)) {
            $name = seed_cspv4_parse_name($name);
            $fname = $name['first'];
            $lname = $name['last'];
        }
        $fullname = $fname . ' ' . $lname;
    }
    try {
        $account = $aweber->getAccount($access_key, $access_secret);
        $account_id = $account->id;
        $listURL = "/accounts/{$account_id}/lists/{$list_id}";
        $list = $account->loadFromUrl($listURL);
        # create a subscriber
        $params = array('email' => $email, 'name' => $fullname, 'ip_address' => seed_cspv4_get_ip());
        $subscribers = $list->subscribers;
        $new_subscriber = $subscribers->create($params);
        # success!
        //$this->add_subscriber($email,$fname,$lname);
        if (empty($seed_cspv4_post_result['status'])) {
            $seed_cspv4_post_result['status'] = '200';
        }
    } catch (AWeberAPIException $exc) {
        if ($exc->status == '400') {
            $seed_cspv4_post_result['status'] = '600';
            $seed_cspv4_post_result['msg'] = $txt_already_subscribed_msg;
            $seed_cspv4_post_result['msg_class'] = 'alert-danger';
        } else {
            $seed_cspv4_post_result['status'] = '500';
        }
        // var_dump($exc);
        // print "<h3>AWeberAPIException:</h3>";
        // print " <li> Type: $exc->type              <br>";
        // print " <li> Msg : $exc->message           <br>";
        // print " <li> Docs: $exc->documentation_url <br>";
        // print "<hr>";
    }
}
예제 #10
0
             }
             $mailchimp_lists_serialized = serialize($mailchimp_lists);
             update_option('wpcb_mailchimp_api_key',$api_key);
             update_option('wpcb_mailchimp_lists',$mailchimp_lists_serialized);
             $showresponse_2 = "<div class='wpcb_success' style='margin: 0px 10px 10px 10px;'><p>". __('Connected to API successfully.', 'wp-conversion-boxes') ."<a href='' style='float:right;' onclick='jQuery(this).parent().parent().fadeOut(300).hide();'>Close</a></p></div>";
         }
         break;
         
 // Aweber                
 case 3: if (!class_exists('AWeberAPI')) {
             include_once(plugin_dir_path(dirname(__FILE__)).'mailers/aweber_api/aweber_api.php');
         }
         try {
                 $aweber_data = AWeberAPI::getDataFromAweberID($api_key);
                 $aweber = new AWeberAPI($aweber_data[0], $aweber_data[1]);
                 $account = $aweber->getAccount($aweber_data[2], $aweber_data[3]);
                 $allaweberlists = $account->lists;
                 foreach($allaweberlists as $aweberlist){
                     $aweber_lists[$aweberlist->id] = $aweberlist->name;
                 }
                 $aweber_data_serialized = serialize($aweber_data);
                 $aweber_lists_serialized = serialize($aweber_lists);
                 update_option('wpcb_aweber_api_key',$aweber_data_serialized);
                 update_option('wpcb_aweber_lists',$aweber_lists_serialized);
                 $showresponse_3 = "<div class='wpcb_success' style='margin: 0px 10px 10px 10px;'><p>". __('Connected to Aweber successfully.', 'wp-conversion-boxes') ."<a href='' style='float:right;' onclick='jQuery(this).parent().parent().fadeOut(300).hide();'>Close</a></p></div>";
         }
         catch (Exception $ex) {
                 $showresponse_3 = "<div id='wpcb_error' style='margin: 0px 10px 10px 10px;'><p>". __('Invalid authorization Key. Please try again.', 'wp-conversion-boxes') ."<a href='' style='float:right;' onclick='jQuery(this).parent().parent().fadeOut(300).hide();'>Close</a></p></div>";
         }
         break;
         
 /**
  * Processes integration with 3rd party APIs.
  * @param cf_Contest $contest
  * @param cf_Participant $participant
  */
 static function process_integration($contest, $participant)
 {
     // mailing lists
     $email = $participant->email;
     $name = '';
     $first_name = '';
     $last_name = '';
     if ($contest->cf_name_field == '1') {
         $name = $participant->first_name . ' ' . $participant->last_name;
         $first_name = $participant->first_name;
         $last_name = $participant->last_name;
     }
     if ($contest->cf_participants_export == 'campaignmonitor') {
         if (!class_exists(CS_REST_Subscribers)) {
             require cf_Manager::$plugin_dir . 'lib/campaign_monitor/csrest_subscribers.php';
         }
         $wrap = new CS_REST_Subscribers($contest->cf_campaignmonitor_list, $contest->cf_campaignmonitor_key);
         $res = $wrap->add(array('EmailAddress' => $email, 'Name' => $name, 'Resubscribe' => true));
         // $res->was_successful()
         // $res->http_status_code
         // $res->response
     } else {
         if ($contest->cf_participants_export == 'mailchimp') {
             if (!class_exists(MCAPI)) {
                 require cf_Manager::$plugin_dir . 'lib/MCAPI.class.php';
             }
             $double_optin = true;
             if ($contest->cf_double_optin == '1') {
                 $double_optin = false;
             }
             $api = new MCAPI($contest->cf_mailchimp_key);
             $api->listSubscribe($contest->cf_mailchimp_list, $email, array('FNAME' => $first_name, 'LNAME' => $last_name), 'html', $double_optin);
             // double optin;
             // if($api->errorCode)
             // $api->errorCode
             // $api->errorMessage
         } else {
             if ($contest->cf_participants_export == 'getresponse') {
                 require cf_Manager::$plugin_dir . 'lib/GetResponseAPI.class.php';
                 $api = new GetResponseAPI($contest->cf_getresponse_key);
                 $response = $api->addContact($contest->cf_getresponse_list, $name, $email);
                 // var_dump($response);
             } else {
                 if ($contest->cf_participants_export == 'aweber') {
                     require cf_Manager::$plugin_dir . 'lib/aweber/aweber_api.php';
                     $aweber_auth = $contest->cf_aweber_auth;
                     if (!empty($aweber_auth) && is_array($aweber_auth)) {
                         $api = new AWeberAPI($aweber_auth['consumer_key'], $aweber_auth['consumer_secret']);
                         try {
                             $account = $api->getAccount($aweber_auth['access_key'], $aweber_auth['access_secret']);
                             $listURL = "/accounts/{$account->id}/lists/{$contest->cf_aweber_list}";
                             $list = $account->loadFromUrl($listURL);
                             // create a subscriber
                             $params = array('email' => $email, 'ip_address' => $_SERVER['REMOTE_ADDR'], 'name' => $name);
                             $subscribers = $list->subscribers;
                             $new_subscriber = $subscribers->create($params);
                         } catch (AWeberAPIException $exc) {
                             // TODO log (post comments?)
                         }
                     }
                 }
             }
         }
     }
     do_action('cf_process_integration', $contest, $participant);
 }
function sendAWeber($mailSubscribe, $merge_vars = NULL)
{
    if (defined('AW_AUTHCODE') && defined('AW_LISTNAME') && $merge_vars) {
        $token = 'api_aweber/' . substr(AW_AUTHCODE, 0, 10);
        if (!file_exists($token)) {
            try {
                $auth = AWeberAPI::getDataFromAweberID(AW_AUTHCODE);
                file_put_contents($token, json_encode($auth));
            } catch (AWeberAPIException $exc) {
                errorLog("AWeber", "[" . $exc->type . "] " . $exc->message . " Docs: " . $exc->documentation_url);
                throw new Exception("Authorization error", 5);
            }
        }
        if (file_exists($token)) {
            $key = file_get_contents($token);
        }
        list($consumerKey, $consumerSecret, $accessToken, $accessSecret) = json_decode($key);
        $aweber = new AWeberAPI($consumerKey, $consumerSecret);
        try {
            $account = $aweber->getAccount($accessToken, $accessSecret);
            $foundLists = $account->lists->find(array('name' => AW_LISTNAME));
            $lists = $foundLists[0];
            if (!isset($merge_vars['name'])) {
                $pix_extra['name'] = getName($mailSubscribe);
            }
            $custom_arr = array();
            foreach ($merge_vars as $variable => $v) {
                if ($variable != 'name') {
                    $custom_arr[filter_var($variable, FILTER_SANITIZE_STRING)] = filter_var($v, FILTER_SANITIZE_STRING);
                }
            }
            $params = array('email' => $mailSubscribe, 'name' => $merge_vars['name'], 'custom_fields' => $custom_arr);
            if (isset($lists)) {
                $lists->subscribers->create($params);
                $output = json_encode(array('type' => 'message', 'text' => 'Thank you for your Subscription.'));
                die($output);
            } else {
                //errorLog("AWeber","List is not found");
                $output = json_encode(array('type' => 'error', 'text' => 'Error: List is not found'));
                die($output);
                //throw new Exception("Error found Lists",4);
            }
        } catch (AWeberAPIException $exc) {
            if ($exc->status == 400) {
                //throw new Exception("Email exist",2);
                $output = json_encode(array('type' => 'error', 'text' => 'Error: Email Already Exists'));
                die($output);
            } else {
                //errorLog("AWeber","[".$exc->type."] ". $exc->message ." Docs: ". $exc->documentation_url);
                $output = json_encode(array('type' => 'error', 'text' => 'Error: ' . "[" . $exc->type . "] " . $exc->message . " Docs: " . $exc->documentation_url));
                die($output);
            }
        }
    } else {
        $output = json_encode(array('type' => 'error', 'text' => 'Error: AWeber configuration Error, please check config.php settings!'));
        die($output);
    }
}
예제 #13
0
 if (!file_exists($auth_f)) {
     try {
         $authorization_code = $AW_AUTH_CODE;
         $auth = AWeberAPI::getDataFromAweberID($authorization_code);
         list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
         file_put_contents($auth_f, json_encode($auth));
     } catch (AWeberAPIException $exc) {
         echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later."));
         errorlog("aweber", $exc->message);
     }
 } else {
     $auth_f_data = file_get_contents($auth_f);
     list($consumerKey, $consumerSecret, $accessToken, $accessSecret) = json_decode($auth_f_data);
     $aweber = new AWeberAPI($consumerKey, $consumerSecret);
     try {
         $account = $aweber->getAccount($accessToken, $accessSecret);
         $list_data = $account->lists->find(array('name' => $AW_LIST_NAME));
         if (isset($list_data[0])) {
             $list = $list_data[0];
             $params = array('email' => $email, 'name' => $firstname);
             $subscribers = $list->subscribers->create($params);
             # success!
             echo json_encode(array("status" => "success"));
         } else {
             echo json_encode(array("status" => "error", "type" => "List name not found."));
         }
     } catch (AWeberAPIException $exc) {
         echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later."));
         errorlog("aweber", $exc->message);
     }
 }
function registrationForm()
{
    ?>
	
	<script type="text/javascript">
	$().ready(function() {
		
		// validate signup form on keyup and submit
		$("#RegisterForm").validate({
			rules: {
				username: {
					required: true,
					minlength: 2,
					maxlength: 20,
				},
				password: {
					required: true,
					minlength: 6,
					maxlength: 30,
				},
				email: {
					required: true,
					email: true,
					maxlength: 60,
				},
				terms: {
					required: true,
				},
			},
			messages: {
				username: {
					required: "Required",
					minlength: "Required atleast 2 letters",
					maxlength:"Max 20 Character allowed"
				},
				password: {
					required: "Required",
					minlength: "Required atleast 6 letters",
					maxlength:"Max 30 Character allowed"
				},
				email: {
					email: "Not a valid email",
					maxlength:"Max 60 Character allowed"
				},
				terms: {
					required: "Required",
				},
			}
		});
		
		
		
	});
	function message(msg){
		var obj = JSON.parse(msg);
		
		toastr.options.showMethod = 'slideDown'; 
		toastr.options.closeButton = true;
		toastr.options.positionClass = 'toast-bottom-left';
		toastr.options.timeOut= '10000';
		
		for(i=0;i<obj.length;i++){
			toastr.error(obj[i]);
		}
			
	}
	</script>	
<?php 
    require_once ABSPATH . WPINC . '/registration.php';
    global $wpdb, $user_ID;
    //Check whether the user is already logged in
    if ($user_ID) {
        // They're already logged in, so we bounce them back to the homepage.
        header('Location:' . home_url() . '/home');
    } else {
        $errors = array();
        if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['signup'])) {
            // Check username is present and not already in use
            $username = $wpdb->escape($_REQUEST['username']);
            if (strpos($username, ' ') !== false) {
                $errors[] = "Sorry, no spaces allowed in usernames";
            }
            if (empty($username)) {
                $errors[] = "Please enter a username";
            } elseif (username_exists($username)) {
                $errors[] = "Username already exists, please try another";
            }
            // Check email address is present and valid
            $email = $wpdb->escape($_REQUEST['email']);
            if (!is_email($email)) {
                $errors[] = "Please enter a valid email";
            } elseif (email_exists($email)) {
                $errors[] = "This email address is already in use";
            }
            // Check password is valid
            if (0 === preg_match("/.{6,}/", $_POST['password'])) {
                $errors[] = "Password must be at least six characters";
            }
            // Check password confirmation_matches
            //if(0 !== strcmp($_POST['password'], $_POST['password_confirmation'])){
            //  $errors['password_confirmation'] = "Passwords do not match";
            //}
            // Check terms of service is agreed to
            //if($_POST['terms'] != "Yes"){
            //    $errors['terms'] = "You must agree to Terms of Service";
            //}
            if (0 === count($errors)) {
                $password = $_POST['password'];
                $new_user_id = wp_create_user($username, $password, $email);
                // email verifaction code
                global $wpdb;
                $verification_code = md5(rand(8842, 100000));
                $wpdb->query("INSERT INTO " . $wpdb->prefix . "user_email_veryfy(`user_name`,`verified_code`) VALUES ('{$username}','{$verification_code}')");
                $to = $email;
                $subject = "E-pray New Account Verification";
                $from = 'E-pray Team';
                $headers = "MIME-version: 1.0\n";
                $headers .= "Content-type: text/html; charset=utf-8\r\n";
                $headers .= "From: ePray Team <*****@*****.**>";
                $message = "<html>\n\t\t\t\t\t\t\t\t\t\t    <head>\n\t\t\t\t\t\t\t\t\t\t      <title>e-pray New Account Verification</title>\n\t\t\t\t\t\t\t\t\t\t    </head>\n\t\t\t\t\t\t\t\t\t\t    <body>\n\t\t\t\t\t\t\t\t\t\t      <table>\n\t\t\t\t\t\t\t\t\t\t      <tr><td> <b>Dear {$username}, Thank you for registering on epray!</td></tr></b>\n\t\t\t\t\t\t\t\t\t\t       <tr><td><b>Email : {$email}</b></td></tr><br />\n\t\t\t\t\t\t\t\t\t\t      <tr><td> But before we can activate your account, one last step must be taken to complete your registration.\n\t\t\t\t\tPlease note, you must complete this last step to become a registered member. You will only need to visit this URL once to activate your account.\n\t\t\t\t\tTo complete your registration, please visit this URL:</td></tr> <br />\n\t\t\t\t\t\t\t\t\t\t     <tr><td>Verification Link : <a href='http://www.brilliantclips.com/bridge/?username={$username}&code={$verification_code}'>http://www.brilliantclips.com/bridge/?username={$username}&code={$verification_code}</a></td></tr>\n\t\t\t\t\t\t\t\t\t\t     <tr><td>After verification : <a href='http://www.brilliantclips.com/'>Sign in</a></td></tr>  <br /><br />\n\t\t\t\t\t\t\t\t\t\t      <b>Best Regards,<br />\n\t\t\t\t\t  \t\t\t\t\t\t  e-pray Team</b>\n\t\t\t\t\t\t\t\t\t\t      </table>\n\t\t\t\t\t\t\t\t\t\t      </body>\n\t\t\t\t\t\t\t\t\t\t      </html>";
                $res = mail($to, $subject, $message, $headers);
                // email verifaction code end
                // You could do all manner of other things here like send an email to the user, etc. I leave that to you.
                $success = 1;
                //header( 'Location:' . get_bloginfo('url') . '/?success=1&u=' . $username );
                //$errors[] = "Registered successfully please confirm your email address.";
                ?>
						<script  type="text/javascript">
							toastr.options.showMethod = 'slideDown'; 
							toastr.options.closeButton = true;
							toastr.options.positionClass = 'toast-top-center';
							toastr.options.timeOut= '5000';
							toastr.success('Registered successfully please confirm your email address.');
						</script>
						<?php 
                /*aWeber subscription logic start*/
                require_once ABSPATH . '/aweber_api/aweber_api.php';
                // Step 1: assign these values from https://labs.aweber.com/apps
                $consumerKey = 'AkPfYOK609eWdTkRPw4SYdlQ';
                $consumerSecret = '9KUawCIEMii5kbS5dS6rGyyL1Rn7Dz7Sp5gDzxoI';
                // Step 2: load this PHP file in a web browser, and follow the instructions to set
                // the following variables:
                $accessKey = 'Agx2SUcHvqVPvt3BWb22gRIh';
                $accessSecret = 'EuiQTyMbCxMo2iOD5w84hk0VdWQ0pxtn3NVoUlWX';
                $list_id = '3386025';
                //wppagespeed list
                $aweber = new AWeberAPI($consumerKey, $consumerSecret);
                if (!$accessKey || !$accessSecret) {
                    //display_access_tokens($aweber);
                }
                try {
                    $account = $aweber->getAccount($accessKey, $accessSecret);
                    $account_id = $account->id;
                    if (!$list_id) {
                        //display_available_lists($account);
                        //exit;
                    }
                    //print "Your script is configured properly! " .
                    //    "You can now start to develop your API calls, see the example in this script.<br><br>" .
                    //    "Be sure to set \$test_email if you are going to use the example<p>";
                    //example: create a subscriber
                    $test_email = $email;
                    if (!$test_email) {
                        //print "Assign a valid email address to \$test_email and retry";
                        //exit;
                    }
                    $listURL = "/accounts/{$account_id}/lists/{$list_id}";
                    $list = $account->loadFromUrl($listURL);
                    $params = array('email' => $test_email, 'misc_notes' => 'ePray app', 'name' => $username);
                    $subscribers = $list->subscribers;
                    $new_subscriber = $subscribers->create($params);
                    //print "{$test_email} was added to the {$list->name} list!";
                } catch (AWeberAPIException $exc) {
                    //print "<h3>AWeberAPIException:<h3>";
                    //print " <li> Type: $exc->type <br>";
                    //print " <li> Msg : $exc->message <br>";
                    //print " <li> Docs: $exc->documentation_url <br>";
                    //print "<hr>";
                    //exit(1);
                }
                function get_self()
                {
                    return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                }
                function display_available_lists($account)
                {
                    //print "Please add one of the lines of PHP Code below to the top of your script for the proper list<br>" .
                    //        "then click <a href=\"" . get_self() . "\">here</a> to continue<p>";
                    $listURL = "/accounts/{$account->id}/lists/";
                    $lists = $account->loadFromUrl($listURL);
                    foreach ($lists->data['entries'] as $list) {
                        //print "\$list_id = '{$list['id']}'; // list name:{$list['name']}\n</br>";
                    }
                }
                function display_access_tokens($aweber)
                {
                    if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
                        $aweber->user->requestToken = $_GET['oauth_token'];
                        $aweber->user->verifier = $_GET['oauth_verifier'];
                        $aweber->user->tokenSecret = $_COOKIE['secret'];
                        list($accessTokenKey, $accessTokenSecret) = $aweber->getAccessToken();
                        //print "Please add these lines of code to the top of your script:<br><br>" .
                        //        "\$accessKey = '{$accessTokenKey}';\n<br>" .
                        //        "\$accessSecret = '{$accessTokenSecret}';\n<br>" .
                        //        "<br><br>" .
                        //        "Then click <a href=\"" . get_self() . "\">here</a> to continue";
                        //exit;
                    }
                    if (!isset($_SERVER['HTTP_USER_AGENT'])) {
                        //print "This request must be made from a web browser\n";
                        //exit;
                    }
                    $callbackURL = get_self();
                    list($key, $secret) = $aweber->getRequestToken($callbackURL);
                    $authorizationURL = $aweber->getAuthorizeUrl();
                    setcookie('secret', $secret);
                    header("Location: {$authorizationURL}");
                    exit;
                }
                ?>
<!-- <script type="text/javascript">
							setTimeout(function () {
						    window.location.href= '<?php 
                echo home_url();
                ?>
/bridge'; 
							},2500); // 3 seconds
							</script> -->
						<?php 
                ?>
							<script>
								message('<?php 
                echo json_encode($errors);
                ?>
');
							</script>
						<?php 
            } else {
                ?>
							<script>
								message('<?php 
                echo json_encode($errors);
                ?>
');
							</script>
						<?php 
            }
        }
    }
    ?>
		
        <div class="signup-form">
                	<form method="post" action="" id="RegisterForm"> 
                    	<ul>
                        	<li>
                            	<div class="top-head">
                                	<h2>New to ePray? <span>Sign Up</span></h2>
                                </div>
                            </li>
                        	<li>
                            	<input type="text" value="" class="text-bx" placeholder="Username" name="username" maxlength="20" autocomplete="off" />
                            </li>
                        	<li>
                            	<input type="email" value="" class="text-bx" placeholder="Email" name="email" maxlength="60" autocomplete="off" />
                            </li>
                        	<li>
                            	<input type="password" value="" class="text-bx" placeholder="Password" name="password" maxlength="30" autocomplete="off" />
                            </li>
                            <li>
                            	<input type="checkbox" name="terms" id="terms" class="check" /><a href="#terms-content" class="fancybox accpt_te">Accept terms & conditions</a>
                            </li>
                            <li>
                                   <?php 
    do_action('wordpress_social_login');
    ?>
 <input type="submit" name="signup" value="Sign-up for ePray" class="sgn-up" />
                            </li>
                        </ul>
                    </form>
                </div>
	    	
        
<?php 
}
function snp_popup_submit()
{
    global $wpdb;
    $result = array();
    $errors = array();
    $_POST['email'] = trim($_POST['email']);
    if (isset($_POST['name'])) {
        $_POST['name'] = trim($_POST['name']);
    }
    if (!snp_is_valid_email($_POST['email'])) {
        $errors['email'] = 1;
    }
    if (isset($_POST['name']) && !$_POST['name']) {
        $errors['name'] = 1;
    }
    $post_id = intval($_POST['popup_ID']);
    if ($post_id) {
        $POPUP_META = get_post_meta($post_id);
    }
    $cf_data = array();
    if (isset($POPUP_META['snp_cf']) && $post_id) {
        $cf = unserialize($POPUP_META['snp_cf'][0]);
        if (isset($cf) && is_array($cf)) {
            foreach ($cf as $f) {
                if (isset($f['name'])) {
                    if (strpos($f['name'], '[')) {
                        $f['name'] = substr($f['name'], 0, strpos($f['name'], '['));
                    }
                    if (!empty($_POST[$f['name']])) {
                        $cf_data[$f['name']] = $_POST[$f['name']];
                    }
                }
                if (isset($f['required']) && $f['required'] == 'Yes' && !$cf_data[$f['name']]) {
                    $errors[$f['name']] = 1;
                }
            }
        }
    }
    if (count($errors) > 0) {
        $result['Errors'] = $errors;
        $result['Ok'] = false;
    } else {
        $Done = 0;
        if (!empty($_POST['name'])) {
            $names = snp_detect_names($_POST['name']);
        } else {
            $names = array('first' => '', 'last' => '');
        }
        $api_error_msg = '';
        if (snp_get_option('ml_manager') == 'directmail') {
            require_once SNP_DIR_PATH . '/include/directmail/class.directmail.php';
            $form_id = snp_get_option('ml_dm_form_id');
            if ($form_id) {
                $api = new DMSubscribe();
                $retval = $api->submitSubscribeForm($form_id, $_POST['email'], $error_message);
                if ($retval) {
                    $Done = 1;
                } else {
                    // Error... Send by email?
                    $api_error_msg = $error_message;
                }
            }
        } elseif (snp_get_option('ml_manager') == 'sendy') {
            $list_id = $POPUP_META['snp_ml_sendy_list'][0];
            if (!$list_id) {
                $list_id = snp_get_option('ml_sendy_list');
            }
            if ($list_id) {
                $options = array('list' => $list_id, 'boolean' => 'true');
                $args['email'] = $_POST['email'];
                if (!empty($_POST['name'])) {
                    $args['name'] = $_POST['name'];
                }
                if (count($cf_data) > 0) {
                    $args = array_merge($args, (array) $cf_data);
                }
                $content = array_merge($args, $options);
                $postdata = http_build_query($content);
                $ch = curl_init(snp_get_option('ml_sendy_url') . '/subscribe');
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
                $api_result = curl_exec($ch);
                curl_close($ch);
                if (strval($api_result) == 'true' || strval($api_result) == '1' || strval($api_result) == 'Already subscribed.') {
                    $Done = 1;
                } else {
                    $api_error_msg = $api_result;
                }
            }
        } elseif (snp_get_option('ml_manager') == 'mailchimp') {
            require_once SNP_DIR_PATH . '/include/mailchimp/Mailchimp.php';
            $ml_mc_list = $POPUP_META['snp_ml_mc_list'][0];
            if (!$ml_mc_list) {
                $ml_mc_list = snp_get_option('ml_mc_list');
            }
            if (snp_get_option('ml_mc_apikey') && $ml_mc_list) {
                $api = new Mailchimp(snp_get_option('ml_mc_apikey'));
                $args = array();
                if (!empty($_POST['name'])) {
                    $args = array('FNAME' => $names['first'], 'LNAME' => $names['last']);
                }
                if (count($cf_data) > 0) {
                    $args = array_merge($args, (array) $cf_data);
                }
                try {
                    $double_optin = snp_get_option('ml_mc_double_optin');
                    if ($double_optin == 1) {
                        $double_optin = true;
                    } else {
                        $double_optin = false;
                    }
                    $double_optin = snp_get_option('ml_mc_double_optin');
                    if ($double_optin == 1) {
                        $double_optin = true;
                    } else {
                        $double_optin = false;
                    }
                    $send_welcome = snp_get_option('ml_mc_send_welcome');
                    if ($send_welcome == 1) {
                        $send_welcome = true;
                    } else {
                        $send_welcome = false;
                    }
                    $retval = $api->lists->subscribe($ml_mc_list, array('email' => $_POST['email']), $args, 'html', $double_optin, false, true, $send_welcome);
                    $Done = 1;
                } catch (Exception $e) {
                    if ($e->getCode() == 214) {
                        $Done = 1;
                    } else {
                        $api_error_msg = $e->getMessage();
                    }
                }
            }
        } elseif (snp_get_option('ml_manager') == 'egoi') {
            $ml_egoi_apikey = snp_get_option('ml_egoi_apikey');
            $client = new SoapClient('http://api.e-goi.com/v2/soap.php?wsdl');
            try {
                $ml_egoi_list = $POPUP_META['snp_ml_egoi_list'][0];
                if (!$ml_egoi_list) {
                    $ml_egoi_list = snp_get_option('ml_egoi_list');
                }
                $args = array('apikey' => $ml_egoi_apikey, 'listID' => $ml_egoi_list, 'email' => $_POST['email']);
                if (!empty($_POST['name'])) {
                    $args['first_name'] = $names['first'];
                    $args['last_name'] = $names['last'];
                }
                if (count($cf_data) > 0) {
                    $CustomFields = array();
                    foreach ($cf_data as $k => $v) {
                        $args[$k] = $v;
                    }
                }
                $res = $client->addSubscriber($args);
                if (isset($res['UID'])) {
                    $Done = 1;
                }
            } catch (Exception $e) {
                // Error...
                // We'll send this by email.
            }
        } elseif (snp_get_option('ml_manager') == 'getresponse') {
            $ml_gr_apikey = snp_get_option('ml_gr_apikey');
            require_once SNP_DIR_PATH . '/include/getresponse/jsonRPCClient.php';
            $api = new jsonRPCClient('http://api2.getresponse.com');
            try {
                $ml_gr_list = $POPUP_META['snp_ml_gr_list'][0];
                if (!$ml_gr_list) {
                    $ml_gr_list = snp_get_option('ml_gr_list');
                }
                $args = array('campaign' => $ml_gr_list, 'email' => $_POST['email']);
                if (!empty($_POST['name'])) {
                    $args['name'] = $_POST['name'];
                }
                if (count($cf_data) > 0) {
                    $CustomFields = array();
                    foreach ($cf_data as $k => $v) {
                        $CustomFields[] = array('name' => $k, 'content' => $v);
                    }
                    $args['customs'] = $CustomFields;
                }
                $res = $api->add_contact($ml_gr_apikey, $args);
                $Done = 1;
            } catch (Exception $e) {
                // Error...
                // We'll send this by email.
                $api_error_msg = $e->getMessage();
            }
        } elseif (snp_get_option('ml_manager') == 'campaignmonitor') {
            require_once SNP_DIR_PATH . '/include/campaignmonitor/csrest_subscribers.php';
            $ml_cm_list = $POPUP_META['snp_ml_cm_list'][0];
            if (!$ml_cm_list) {
                $ml_cm_list = snp_get_option('ml_cm_list');
            }
            $wrap = new CS_REST_Subscribers($ml_cm_list, snp_get_option('ml_cm_apikey'));
            $args = array('EmailAddress' => $_POST['email'], 'Resubscribe' => true);
            if (!empty($_POST['name'])) {
                $args['Name'] = $_POST['name'];
            }
            if (count($cf_data) > 0) {
                $CustomFields = array();
                foreach ($cf_data as $k => $v) {
                    $CustomFields[] = array('Key' => $k, 'Value' => $v);
                }
                $args['CustomFields'] = $CustomFields;
            }
            $res = $wrap->add($args);
            if ($res->was_successful()) {
                $Done = 1;
            } else {
                // Error...
                // We'll send this by email.
                $api_error_msg = 'Failed with code ' . $res->http_status_code;
            }
        } elseif (snp_get_option('ml_manager') == 'icontact') {
            require_once SNP_DIR_PATH . '/include/icontact/iContactApi.php';
            iContactApi::getInstance()->setConfig(array('appId' => snp_get_option('ml_ic_addid'), 'apiPassword' => snp_get_option('ml_ic_apppass'), 'apiUsername' => snp_get_option('ml_ic_username')));
            $oiContact = iContactApi::getInstance();
            $res1 = $oiContact->addContact($_POST['email'], null, null, isset($names['first']) ? $names['first'] : '', isset($names['last']) ? $names['last'] : '', null, null, null, null, null, null, null, null, null);
            if ($res1->contactId) {
                $ml_ic_list = $POPUP_META['snp_ml_ic_list'][0];
                if (!$ml_ic_list) {
                    $ml_ic_list = snp_get_option('ml_ic_list');
                }
                if ($oiContact->subscribeContactToList($res1->contactId, $ml_ic_list, 'normal')) {
                    $Done = 1;
                }
            } else {
                // Error...
                // We'll send this by email.
                $api_error_msg = 'iContact Problem!';
            }
        } elseif (snp_get_option('ml_manager') == 'constantcontact') {
            require_once SNP_DIR_PATH . '/include/constantcontact/class.cc.php';
            $cc = new cc(snp_get_option('ml_cc_username'), snp_get_option('ml_cc_pass'));
            $send_welcome = snp_get_option('ml_cc_send_welcome');
            if ($send_welcome == 1) {
                $cc->set_action_type('contact');
            }
            $email = $_POST['email'];
            $contact_list = $POPUP_META['snp_ml_cc_list'][0];
            if (!$contact_list) {
                $contact_list = snp_get_option('ml_cc_list');
            }
            $extra_fields = array();
            if (!empty($names['first'])) {
                $extra_fields['FirstName'] = $names['first'];
            }
            if (!empty($names['last'])) {
                $extra_fields['LastName'] = $names['last'];
            }
            if (count($cf_data) > 0) {
                $extra_fields = array_merge($extra_fields, (array) $cf_data);
            }
            $contact = $cc->query_contacts($email);
            if ($contact) {
                $status = $cc->update_contact($contact['id'], $email, $contact_list, $extra_fields);
                if ($status) {
                    $Done = 1;
                } else {
                    $api_error_msg = "Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code);
                }
            } else {
                $new_id = $cc->create_contact($email, $contact_list, $extra_fields);
                if ($new_id) {
                    $Done = 1;
                } else {
                    $api_error_msg = "Contact Operation failed: " . $cc->http_get_response_code_error($cc->http_response_code);
                }
            }
        } elseif (snp_get_option('ml_manager') == 'madmimi') {
            require_once SNP_DIR_PATH . '/include/madmimi/MadMimi.class.php';
            if (snp_get_option('ml_madm_username') && snp_get_option('ml_madm_apikey')) {
                $mailer = new MadMimi(snp_get_option('ml_madm_username'), snp_get_option('ml_madm_apikey'));
                $user = array('email' => $_POST['email']);
                if (!empty($names['first'])) {
                    $user['FirstName'] = $names['first'];
                }
                if (!empty($names['last'])) {
                    $user['LastName'] = $names['last'];
                }
                if (count($cf_data) > 0) {
                    $user = array_merge($user, (array) $cf_data);
                }
                $ml_madm_list = $POPUP_META['snp_ml_madm_list'][0];
                if (!$ml_madm_list) {
                    $ml_madm_list = snp_get_option('ml_madm_list');
                }
                $user['add_list'] = $ml_madm_list;
                $res = $mailer->AddUser($user);
                $Done = 1;
            }
        } elseif (snp_get_option('ml_manager') == 'infusionsoft') {
            require_once SNP_DIR_PATH . '/include/infusionsoft/infusionsoft.php';
            if (snp_get_option('ml_inf_subdomain') && snp_get_option('ml_inf_apikey')) {
                $infusionsoft = new Infusionsoft(snp_get_option('ml_inf_subdomain'), snp_get_option('ml_inf_apikey'));
                $user = array('Email' => $_POST['email']);
                if (!empty($names['first'])) {
                    $user['FirstName'] = $names['first'];
                }
                if (!empty($names['last'])) {
                    $user['LastName'] = $names['last'];
                }
                if (count($cf_data) > 0) {
                    $user = array_merge($user, (array) $cf_data);
                }
                $ml_inf_list = $POPUP_META['snp_ml_inf_list'][0];
                if (!$ml_inf_list) {
                    $ml_inf_list = snp_get_option('ml_inf_list');
                }
                $contact_id = $infusionsoft->contact('add', $user);
                $r = $infusionsoft->APIEmail('optIn', $_POST['email'], "Ninja Popups on " . get_bloginfo());
                if ($contact_id && $ml_inf_list) {
                    $infusionsoft->contact('addToGroup', $contact_id, $ml_inf_list);
                }
                if ($contact_id) {
                    $Done = 1;
                }
            }
        } elseif (snp_get_option('ml_manager') == 'aweber') {
            require_once SNP_DIR_PATH . '/include/aweber/aweber_api.php';
            if (get_option('snp_ml_aw_auth_info')) {
                $aw = get_option('snp_ml_aw_auth_info');
                try {
                    $aweber = new AWeberAPI($aw['consumer_key'], $aw['consumer_secret']);
                    $account = $aweber->getAccount($aw['access_key'], $aw['access_secret']);
                    $aw_list = $POPUP_META['snp_ml_aw_lists'][0];
                    if (!$aw_list) {
                        $aw_list = snp_get_option('ml_aw_lists');
                    }
                    $list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $aw_list);
                    $subscriber = array('email' => $_POST['email'], 'ip' => $_SERVER['REMOTE_ADDR']);
                    if (!empty($_POST['name'])) {
                        $subscriber['name'] = $_POST['name'];
                    }
                    if (count($cf_data) > 0) {
                        $subscriber['custom_fields'] = $cf_data;
                    }
                    $r = $list->subscribers->create($subscriber);
                    $Done = 1;
                } catch (AWeberException $e) {
                    $api_error_msg = $e->getMessage();
                }
            }
        } elseif (snp_get_option('ml_manager') == 'wysija' && class_exists('WYSIJA')) {
            $ml_wy_list = $POPUP_META['snp_ml_wy_list'][0];
            if (!$ml_wy_list) {
                $ml_wy_list = snp_get_option('ml_wy_list');
            }
            $userData = array('email' => $_POST['email'], 'firstname' => $names['first'], 'lastname' => $names['last']);
            $data = array('user' => $userData, 'user_list' => array('list_ids' => array($ml_wy_list)));
            $userHelper =& WYSIJA::get('user', 'helper');
            if ($userHelper->addSubscriber($data)) {
                $Done = 1;
            } else {
                $api_error_msg = 'MailPoet Problem!';
            }
        } elseif (snp_get_option('ml_manager') == 'sendpress') {
            $ml_sp_list = $POPUP_META['snp_ml_sp_list'][0];
            if (!$ml_sp_list) {
                $ml_sp_list = snp_get_option('ml_sp_list');
            }
            try {
                SendPress_Data::subscribe_user($ml_sp_list, $_POST['email'], $names['first'], $names['last'], 2);
                $Done = 1;
            } catch (Exception $e) {
                $api_error_msg = 'SendPress Problem!';
            }
        } elseif (snp_get_option('ml_manager') == 'mymail') {
            $userdata = array('firstname' => $names['first'], 'lastname' => $names['last']);
            $ml_mm_list = $POPUP_META['snp_ml_mm_list'][0];
            if (!$ml_mm_list) {
                $ml_mm_list = snp_get_option('ml_mm_list');
            }
            $lists = array($ml_mm_list);
            if (function_exists('mymail')) {
                $entry = $userdata;
                $entry['email'] = $_POST['email'];
                $double_optin = snp_get_option('ml_mm_double_optin');
                if ($double_optin == 1) {
                    $entry['status'] = 0;
                } else {
                    $entry['status'] = 1;
                }
                if (count($cf_data) > 0) {
                    foreach ($cf_data as $k => $v) {
                        $entry[$k] = $v;
                    }
                }
                $subscriber_id = mymail('subscribers')->add($entry, true);
                if (!is_wp_error($subscriber_id)) {
                    $success = mymail('subscribers')->assign_lists($subscriber_id, $lists, false);
                }
                if ($success) {
                    $Done = 1;
                } else {
                    $api_error_msg = 'MyMail Problem!';
                }
            } else {
                $return = mymail_subscribe($_POST['email'], $userdata, $lists);
                if (!is_wp_error($return)) {
                    $Done = 1;
                } else {
                    $api_error_msg = 'MyMail Problem!';
                }
            }
        } elseif (snp_get_option('ml_manager') == 'csv' && snp_get_option('ml_csv_file') && is_writable(SNP_DIR_PATH . 'csv/')) {
            if (!isset($_POST['name'])) {
                $_POST['name'] = '';
            }
            if (count($cf_data) > 0) {
                $CustomFields = '';
                foreach ($cf_data as $k => $v) {
                    $CustomFields .= $k . ' = ' . $v . ';';
                }
            }
            $data = $_POST['email'] . ";" . $_POST['name'] . ";" . $CustomFields . get_the_title($_POST['popup_ID']) . " (" . $_POST['popup_ID'] . ");" . date('Y-m-d H:i') . ";" . $_SERVER['REMOTE_ADDR'] . ";\n";
            if (file_put_contents(SNP_DIR_PATH . 'csv/' . snp_get_option('ml_csv_file'), $data, FILE_APPEND | LOCK_EX) !== FALSE) {
                $Done = 1;
            } else {
                $api_error_msg = 'CSV Problem!';
            }
        }
        if (snp_get_option('ml_manager') == 'email' || !$Done) {
            $Email = snp_get_option('ml_email');
            if (!$Email) {
                $Email = get_bloginfo('admin_email');
            }
            if (!isset($_POST['name'])) {
                $_POST['name'] = '--';
            }
            $error_mgs = '';
            if ($api_error_msg != '') {
                $error_mgs .= "IMPORTANT! You have received this message because connection to your e-mail marketing software failed. Please check connection setting in the plugin configuration.\n";
                $error_mgs .= $api_error_msg . "\n";
            }
            $cf_msg = '';
            if (count($cf_data) > 0) {
                foreach ($cf_data as $k => $v) {
                    $cf_msg .= $k . ": " . $v . "\n";
                }
            }
            $msg = "New subscription on " . get_bloginfo() . "\n" . $error_mgs . "\n" . "E-mail: " . $_POST['email'] . "\n" . "Name: " . $_POST['name'] . "\n" . $cf_msg . "\n" . "Form: " . get_the_title($_POST['popup_ID']) . " (" . $_POST['popup_ID'] . ")\n" . "\n" . "Date: " . date('Y-m-d H:i') . "\n" . "IP: " . $_SERVER['REMOTE_ADDR'] . "";
            wp_mail($Email, "New subscription on " . get_bloginfo(), $msg);
        }
        $result['Ok'] = true;
    }
    echo json_encode($result);
    die('');
}
 public function indeed_aWebberSubscribe($consumer_key, $consumer_secret, $access_key, $access_secret, $aw_list, $e_mail, $full_name = '')
 {
     require_once $this->dir_path . '/email_services/aweber/aweber_api.php';
     try {
         $aweber = new AWeberAPI($consumer_key, $consumer_secret);
         $account = $aweber->getAccount($access_key, $access_secret);
         $list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $aw_list);
         $subscriber = array('email' => $e_mail, 'ip' => $_SERVER['REMOTE_ADDR']);
         if (!empty($full_name)) {
             $subscriber['name'] = $full_name;
         }
         $list->subscribers->create($subscriber);
         return 1;
     } catch (AWeberException $e) {
         return 0;
     }
 }
function emember_auto_responder_settings()
{
    $emember_config = Emember_Config::getInstance();
    echo '<div class="wrap">';
    echo '<div id="poststuff"><div id="post-body">';
    if (isset($_POST['info_update'])) {
        $errors = "";
        if (isset($_POST['aweber_make_connection'])) {
            if ($emember_config->getValue('eMember_aweber_authorize_status') != 'authorized') {
                $authorization_code = trim($_POST['aweber_auth_code']);
                if (!class_exists('AWeberAPI')) {
                    include_once 'lib/auto-responder/aweber_api/aweber_api.php';
                }
                $auth = AWeberAPI::getDataFromAweberID($authorization_code);
                list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
                $eMember_aweber_access_keys = array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'access_key' => $accessKey, 'access_secret' => $accessSecret);
                $emember_config->setValue('eMember_aweber_access_keys', $eMember_aweber_access_keys);
                if ($eMember_aweber_access_keys['access_key']) {
                    try {
                        $aweber = new AWeberAPI($consumerKey, $consumerSecret);
                        $account = $aweber->getAccount($accessKey, $accessSecret);
                    } catch (AWeberException $e) {
                        $account = null;
                    }
                    if (!$account) {
                        //$this->deauthorize();//TODO - remove the keys
                        $errors = 'AWeber authentication failed! Please try connecting again.';
                    } else {
                        $emember_config->setValue('eMember_aweber_authorize_status', 'authorized');
                        $_POST['eMember_use_new_aweber_integration'] = '1';
                        //Set the eMember_use_new_aweber_integration flag to enabled
                        echo '<div id="message" class="updated fade"><p><strong>';
                        echo 'AWeber authorization success!';
                        echo '</strong></p></div>';
                    }
                } else {
                    $errors = 'You need to specify a valid authorization code to establish an AWeber API connection';
                }
            } else {
                //Remove existing connection
                $eMember_aweber_access_keys = array('consumer_key' => '', 'consumer_secret' => '', 'access_key' => '', 'access_secret' => '');
                $emember_config->setValue('eMember_aweber_access_keys', $eMember_aweber_access_keys);
                $emember_config->setValue('eMember_aweber_authorize_status', '');
                $_POST['eMember_use_new_aweber_integration'] = '';
                //Set the eMember_use_new_aweber_integration flag to disabled
                echo '<div id="message" class="updated fade"><p><strong>';
                echo 'AWeber connection removed!';
                echo '</strong></p></div>';
            }
        }
        $emember_config->setValue('eMember_enable_aweber_int', $_POST['eMember_enable_aweber_int'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_aweber_list_name', (string) $_POST["eMember_aweber_list_name"]);
        $emember_config->setValue('eMember_use_new_aweber_integration', $_POST['eMember_use_new_aweber_integration'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_use_mailchimp', $_POST['eMember_use_mailchimp'] == '1' ? '1' : '');
        //$emember_config->setValue('eMember_enable_global_chimp_int', ($_POST['eMember_enable_global_chimp_int']=='1') ? '1':'' );
        $emember_config->setValue('eMember_chimp_list_name', trim($_POST["eMember_chimp_list_name"]));
        $emember_config->setValue('eMember_chimp_api_key', trim($_POST["eMember_chimp_api_key"]));
        $emember_config->setValue('eMember_mailchimp_disable_double_optin', $_POST['eMember_mailchimp_disable_double_optin'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_mailchimp_disable_final_welcome_email', $_POST['eMember_mailchimp_disable_final_welcome_email'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_mailchimp_signup_date_field_name', trim($_POST["eMember_mailchimp_signup_date_field_name"]));
        $emember_config->setValue('eMember_use_getresponse', $_POST['eMember_use_getresponse'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_getResponse_campaign_name', (string) $_POST["eMember_getResponse_campaign_name"]);
        $emember_config->setValue('eMember_getResponse_api_key', (string) $_POST["eMember_getResponse_api_key"]);
        $emember_config->setValue('eMember_use_generic_autoresponder_integration', $_POST['eMember_use_generic_autoresponder_integration'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_use_global_generic_autoresponder_integration', $_POST['eMember_use_global_generic_autoresponder_integration'] == '1' ? '1' : '');
        $emember_config->setValue('eMember_generic_autoresponder_target_list_email', trim($_POST["eMember_generic_autoresponder_target_list_email"]));
        $emember_config->saveConfig();
        if (!empty($errors)) {
            echo '<div id="message" class="error"><p>';
            echo $errors;
            echo '</p></div>';
        } else {
            echo '<div id="message" class="updated fade"><p><strong>';
            echo 'Autoresponder Options Updated!';
            echo '</strong></p></div>';
        }
    }
    ?>

    <form method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
        <input type="hidden" name="info_update" id="info_update" value="true" />

        <div class="postbox">
            <h3><label for="title">AWeber Settings (<a href="http://www.tipsandtricks-hq.com/wordpress-membership/?p=151" target="_blank">AWeber Integration Instructions</a>)</label></h3>
            <div class="inside">

                <table width="100%" border="0" cellspacing="0" cellpadding="6">

                    <tr valign="top"><td width="25%" align="left">
                            <strong>Enable AWeber Signup:</strong>
                        </td><td align="left">
                            <input name="eMember_enable_aweber_int" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_enable_aweber_int') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><i>When checked the plugin will automatically sign up the members at registration time to your AWeber List specified below. For membership level specific signup see the "Autoresponder List/Campaign Name" section of the membership level.</i><br /><br />
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>AWeber List Name:</strong>
                        </td><td align="left">
                            <input name="eMember_aweber_list_name" type="text" size="40" value="<?php 
    echo $emember_config->getValue('eMember_aweber_list_name');
    ?>
"/>
                            <br /><i>The name of the AWeber list where the members will be signed up to (eg. listname@aweber.com)</i><br /><br />
                        </td></tr>
                </table>

                <div style="border-bottom: 1px solid #dedede; height: 10px"></div>
                <table class="form-table">

                    <tr valign="top"><td width="25%" align="left">
                            Use the New AWeber Integration Option:
                        </td><td align="left">
                            <input name="eMember_use_new_aweber_integration" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_use_new_aweber_integration') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><i>When checked the plugin will use the new AWeber integration method which uses the AWeber API (this method is recommended over the old method that uses the email parser).</i>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            Step 1: Get Your AWeber Authorization Code:
                        </td><td align="left">
                            <a href="https://auth.aweber.com/1.0/oauth/authorize_app/999d6172" target="_blank">Click here to get your authorization code</a>
                            <br /><i>Clicking on the above link will take you to the AWeber site where you will need to log in using your AWeber username and password. Then give access to the Tips and Tricks HQ AWeber app.</i>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            Step 2: Paste in Your Authorization Code:
                        </td><td align="left">
                            <input name="aweber_auth_code" type="text" size="140" value=""/>
                            <br /><i>Paste the long authorization code that you got from AWeber in the above field.</i>
                        </td></tr>

                    <tr valign="top"><td colspan="2" align="left">
                            <?php 
    if ($emember_config->getValue('eMember_aweber_authorize_status') == 'authorized') {
        echo '<input type="submit" name="aweber_make_connection" value="Remove Connection" class= "button button" />';
    } else {
        echo '<input type="submit" name="aweber_make_connection" value="Make Connection" class= "button-primary" />';
    }
    ?>
                        </td></tr>

                </table>
            </div></div>

        <div class="postbox">
            <h3><label for="title">MailChimp Settings (<a href="http://www.tipsandtricks-hq.com/wordpress-membership/?p=236" target="_blank">MailChimp Integration Instructions</a>)</label></h3>
            <div class="inside">

                <table width="100%" border="0" cellspacing="0" cellpadding="6">

                    <tr valign="top"><td width="25%" align="left">
                            <strong>Use MailChimp AutoResponder:</strong>
                        </td><td align="left">
                            <input name="eMember_use_mailchimp" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_use_mailchimp') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><i>Check this if you want to use MailChimp Autoresponder service. For membership level specific signup see the "Autoresponder List/Campaign Name" section of the membership level.</i><br /><br />
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>MailChimp List Name:</strong>
                        </td><td align="left">
                            <input name="eMember_chimp_list_name" type="text" size="30" value="<?php 
    echo $emember_config->getValue('eMember_chimp_list_name');
    ?>
"/>
                            <br /><i>The name of the MailChimp list where the customers will be signed up to (e.g. Customer List)</i><br /><br />
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>MailChimp API Key:</strong>
                        </td><td align="left">
                            <input name="eMember_chimp_api_key" type="text" size="50" value="<?php 
    echo $emember_config->getValue('eMember_chimp_api_key');
    ?>
"/>
                            <br /><i>The API Key of your MailChimp account (can be found under the "Account" tab). By default the API Key is not active so make sure you activate it in your Mailchimp account. If you do not have the API Key then you can use the username and password option below but it is better to use the API key.</i>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>Disable Double Opt-In:</strong>
                        </td><td align="left">
                            <input name="eMember_mailchimp_disable_double_optin" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_mailchimp_disable_double_optin') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            Do not send double opt-in confirmation email
                            <br /><i>Use this checkbox if you do not wish to use the double opt-in option. Please note that abusing this option may cause your MailChimp account to be suspended.</i><br />

                            <input name="eMember_mailchimp_disable_final_welcome_email" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_mailchimp_disable_final_welcome_email') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            Do not send welcome email
                            <br /><i>Use this checkbox if you do not wish to send the welcome email sent by MailChimp when a user subscribes to your list. This will only work if you disable the double opt-in option above.</i>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>Signup Date Field Name (optional):</strong>
                        </td><td align="left">
                            <input name="eMember_mailchimp_signup_date_field_name" type="text" size="30" value="<?php 
    echo $emember_config->getValue('eMember_mailchimp_signup_date_field_name');
    ?>
"/>
                            <br /><i>If you have configured a signup date field for your mailchimp list then specify the name of the field here (example: SIGNUPDATE). <a href="http://kb.mailchimp.com/article/how-do-i-create-a-date-field-in-my-signup-form" target="_blank">More Info</a></i><br /><br />
                        </td></tr>

                </table>
            </div></div>

        <div class="postbox">
            <h3><label for="title">GetResponse Settings (<a href="http://www.tipsandtricks-hq.com/wordpress-membership/?p=283" target="_blank">GetResponse Integration Instructions</a>)</label></h3>
            <div class="inside">

                <table width="100%" border="0" cellspacing="0" cellpadding="6">

                    <tr valign="top"><td width="25%" align="left">
                            <strong>Use GetResponse AutoResponder:</strong>
                        </td><td align="left">
                            <input name="eMember_use_getresponse" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_use_getresponse') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><i>Check this if you want to use GetResponse Autoresponder service.</i><br /><br />
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>GetResponse Campaign Name:</strong>
                        </td><td align="left">
                            <input name="eMember_getResponse_campaign_name" type="text" size="30" value="<?php 
    echo $emember_config->getValue('eMember_getResponse_campaign_name');
    ?>
"/>
                            <br /><i>The name of the GetResponse campaign where the customers will be signed up to (e.g. marketing)</i><br /><br />
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            <strong>GetResponse API Key:</strong>
                        </td><td align="left">
                            <input name="eMember_getResponse_api_key" type="text" size="50" value="<?php 
    echo $emember_config->getValue('eMember_getResponse_api_key');
    ?>
"/>
                            <br /><i>The API Key of your GetResponse account (can be found inside your GetResponse Account).</i><br /><br />
                        </td></tr>

                </table>
            </div></div>

        <div class="postbox">
            <h3><label for="title">Generic Autoresponder Integration Settings</label></h3>
            <div class="inside">

                <br /><strong>&nbsp; &nbsp; If your autoresponder provider allows you to signup users just by sending an email to the list email address with the user's email as the from address then you can use this method of integration</strong>

                <table class="form-table" width="100%" border="0" cellspacing="0" cellpadding="6">

                    <tr valign="top"><td width="25%" align="left">
                            Enable Generic Autoresponder Integration:
                        </td><td align="left">
                            <input name="eMember_use_generic_autoresponder_integration" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_use_generic_autoresponder_integration') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><p class="description">Use this option if you want to use the generic auotoresponder integration option.</p>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            Enable Global Integration:
                        </td><td align="left">
                            <input name="eMember_use_global_generic_autoresponder_integration" type="checkbox"<?php 
    if ($emember_config->getValue('eMember_use_global_generic_autoresponder_integration') != '') {
        echo ' checked="checked"';
    }
    ?>
 value="1"/>
                            <br /><p class="description">When checked the plugin will automatically sign up every member to your list/campaign specified below. If you want to selectively signup members on a per membership level basis then use the Autoresponder settings of that level.</p>
                        </td></tr>

                    <tr valign="top"><td width="25%" align="left">
                            Global List/Campaign Email Address:
                        </td><td align="left">
                            <input name="eMember_generic_autoresponder_target_list_email" type="text" size="40" value="<?php 
    echo $emember_config->getValue('eMember_generic_autoresponder_target_list_email');
    ?>
"/>
                            <br /><p class="description">The email address of the list where the member will be signed up to. The plugin will send the autoresponder signup request email to this address.</p>
                        </td></tr>

                </table>
            </div></div>

        <div class="submit">
            <input type="submit" name="info_update" class="button-primary" value="<?php 
    _e('Update options');
    ?>
 &raquo;" />
        </div>
    </form>

    <?php 
    echo '</div></div>';
    echo '</div>';
}
예제 #18
0
 function getAweberLists($forceUpdate = false)
 {
     if (!$forceUpdate) {
         //check from cache
         $aweberLists = get_transient($this->_optin_AweberListsTransient);
         if ($aweberLists !== false) {
             return $aweberLists;
         }
     }
     $this->initializeAweberApi();
     $settings = $this->getSettings();
     $info = $settings['optin']['aweber-account-info'];
     $aweber = new AWeberAPI($info['consumer_key'], $info['consumer_secret']);
     try {
         $account = $aweber->getAccount($info['access_key'], $info['access_secret']);
     } catch (AWeberException $e) {
         $account = null;
     }
     $lists = array();
     $list_web_forms = array();
     if ($account) {
         foreach ($account->getWebForms() as $this_webform) {
             $link_parts = explode('/', $this_webform->url);
             $list_id = $link_parts[4];
             if (!array_key_exists($list_id, $list_web_forms)) {
                 $list_web_forms[$list_id] = array('web_forms' => array(), 'split_tests' => array());
             }
             $list_web_forms[$list_id]['web_forms'][] = $this_webform;
         }
         foreach ($account->getWebFormSplitTests() as $this_webform) {
             $link_parts = explode('/', $this_webform->url);
             $list_id = $link_parts[4];
             if (!array_key_exists($list_id, $list_web_forms)) {
                 $list_web_forms[$list_id] = array('web_forms' => array(), 'split_tests' => array());
             }
             $list_web_forms[$list_id]['split_tests'][] = $this_webform;
         }
         $lists = $account->lists;
         foreach ($lists as $this_list) {
             if (array_key_exists($this_list->id, $list_web_forms)) {
                 $list_web_forms[$this_list->id]['list'] = $this_list;
             }
         }
     }
     $return = array();
     /* still need to figure out why we need the block of code below.
     		foreach($list_web_forms as $id => $data) {
     			//$item = array('id' => $id, 'name' => $data['list']->name, 'forms' => array()); //original from premise
     			$item = array('id' => $data['list']->name, 'name' => $data['list']->name, 'forms' => array());
     			foreach($data['web_forms'] as $web_form) {
     				$item['forms'][] = array('id' => $web_form->id, 'url' => $web_form->url, 'name' => $web_form->name);
     			}
     			foreach($data['split_tests'] as $split_test) {
     				$item['forms'][] = array('id' => $split_test->id, 'url' => $split_test->url, 'name' => sprintf(__('Split Test: %s', 'mab' ), $web_form->name));
     			}
     			$return[] = $item;
     		}
     		//*/
     foreach ($lists as $this_list) {
         $return[] = array('id' => $this_list->unique_list_id, 'name' => $this_list->name);
     }
     set_transient($this->_optin_AweberListsTransient, $return, 24 * 60 * 60);
     //set for one day.
     return $return;
 }
 /**
  * Returns id of the subscriber
  */
 function subscribe($list_id, $sub)
 {
     $key = $this->auth_key;
     $auth = $this->parse_authkey($key);
     if (empty($auth)) {
         throw new Exception("Invalid Auth");
     }
     $access_tokens = $this->get_access_tokens();
     if (empty($access_tokens)) {
         throw new Exception("Auth keys have already expired");
     }
     list($access_token, $access_token_secret) = $access_tokens;
     $api = new AWeberAPI($auth['api_key'], $auth['api_secret']);
     $api->adapter->debug = $this->debug;
     $api->user->tokenSecret = $auth['token_secret'];
     $api->user->requestToken = $auth['request_token'];
     $api->user->verifier = $auth['auth_verifier'];
     try {
         $account = $api->getAccount($access_token, $access_token_secret);
         $list = $account->lists->getById($list_id);
         $subs = $list->subscribers;
         // now create a new subscriber
         $sub = $subs->create($sub);
         $attr = $sub->attrs();
         return $attr['id'];
     } catch (Exception $e) {
         error_log("An error occured while subscribing: " . $e->getMessage());
         return false;
     }
 }
예제 #20
0
 /**
  * API instance.
  *
  * @since 141004
  * @package s2Member\List_Servers
  *
  * @return AWeberAPI|null AWeber API instance.
  */
 public static function aw_api()
 {
     if (!$GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key']) {
         return NULL;
     }
     // Not possible.
     if (!class_exists('AWeberAPI')) {
         // Include the AWeber API class here.
         include_once dirname(dirname(__FILE__)) . '/externals/aweber/aweber_api.php';
     }
     if (count($key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_api_key'])) < 5) {
         return NULL;
     }
     // It's an invalid API key; i.e., authorization code.
     list($consumerKey, $consumerSecret, $requestToken, $tokenSecret, $verifier) = $key_parts;
     $internal_api_key_checksum = md5($consumerKey . $consumerSecret . $requestToken . $tokenSecret . $verifier);
     if (count($internal_key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'])) >= 5) {
         list(, , , , $checksum) = $internal_key_parts;
     }
     // Only need checksum for now.
     if (empty($checksum) || $checksum !== $internal_api_key_checksum) {
         try {
             $aw_api = new AWeberAPI($consumerKey, $consumerSecret);
             $aw_api->user->requestToken = $requestToken;
             $aw_api->user->tokenSecret = $tokenSecret;
             $aw_api->user->verifier = $verifier;
             if (!is_array($accessToken = $aw_api->getAccessToken()) || count($accessToken) < 2) {
                 return NULL;
             }
             // Not possible.
             list($accessTokenKey, $accessTokenSecret) = $accessToken;
             if (!$accessTokenKey || !$accessTokenSecret) {
                 return NULL;
             }
             // Not possible.
             $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'] = $internal_api_key = $consumerKey . '|' . $consumerSecret . '|' . $accessTokenKey . '|' . $accessTokenSecret . '|' . $internal_api_key_checksum;
             c_ws_plugin__s2member_menu_pages::update_all_options(array('ws_plugin__s2member_aweber_internal_api_key' => $internal_api_key), TRUE, FALSE, FALSE, FALSE, FALSE);
         } catch (Exception $exception) {
             return NULL;
             // API initialization failure.
         }
     }
     if (count($internal_key_parts = explode('|', $GLOBALS['WS_PLUGIN__']['s2member']['o']['aweber_internal_api_key'])) < 5) {
         return NULL;
     }
     // It's an invalid internal API key. Cannot continue.
     list($consumerKey, $consumerSecret, $accessTokenKey, $accessTokenSecret, $checksum) = $internal_key_parts;
     try {
         $aw_api = new AWeberAPI($consumerKey, $consumerSecret);
         $aw_api->___account = $aw_api->getAccount($accessTokenKey, $accessTokenSecret);
         return $aw_api;
         // AWeberAPI instance.
     } catch (Exception $exception) {
         return NULL;
         // API initialization failure.
     }
 }
예제 #21
0
 }
 $redirect_url = $contactform_obj->cfg['form_redirecturl'] ? $contactform_obj->cfg['form_redirecturl'] : '';
 // VALIDATION MESSAGE
 $json_response = array('status' => 'ok', 'message' => $contactform_obj->cfg['form_validationmessage'], 'redirect_url' => $redirect_url);
 /**************************************************************************************
  * AWEBER API
  **************************************************************************************/
 if (!empty($cfg['aweber']['consumerkey']) && !empty($cfg['aweber']['consumersecret']) && !empty($cfg['aweber']['accesstokenkey']) && !empty($cfg['aweber']['accesstokensecret']) && !empty($cfg['aweber']['lists'])) {
     $service_id = 'aweber';
     debugServiceSeparator($service_id, true);
     $service_requirements_status = $cfgenwpapi_obj->checkServiceRequirements($service_id);
     if ($service_requirements_status['status']) {
         include '../api/aweber/aweber_api.php';
         try {
             $aweber_api = new AWeberAPI($cfg[$service_id]['consumerkey'], $cfg[$service_id]['consumersecret']);
             $aweber_account = $aweber_api->getAccount($cfg[$service_id]['accesstokenkey'], $cfg[$service_id]['accesstokensecret']);
             //print_r($aweber_account);
             $aweber_account_id = $aweber_account->id;
             foreach ($cfg[$service_id]['lists'] as $list_v) {
                 $list_id = $list_v['list_id'];
                 $aweber_contact = array();
                 $aweber_contact['email'] = '';
                 $aweber_contact['name'] = '';
                 $aweber_contact['ipaddress'] = $_SERVER['REMOTE_ADDR'];
                 // FIELDS
                 if (!empty($list_v['fields'])) {
                     foreach ($list_v['fields'] as $field_v) {
                         if ($field_v['list_field_id'] == 'email' || $field_v['list_field_id'] == 'name') {
                             $aweber_contact[$field_v['list_field_id']] = getElementValue($field_v['element_id']);
                         }
                         if ($field_v['list_field_id'] != 'email' && $field_v['list_field_id'] != 'name') {
예제 #22
0
function aweber_form()
{
    $keys = get_option(THEME_NAME . "_aweber_keys");
    if (isset($_POST["email"])) {
        $email = is_email($_POST["email"]);
    }
    if (isset($_POST["u_name"])) {
        $u_name = esc_textarea($_POST["u_name"]);
    }
    if (isset($_POST["listID"])) {
        $listID = remove_html_slashes($_POST["listID"]);
    }
    $ip = $_SERVER['REMOTE_ADDR'];
    extract($keys);
    if ($email && $u_name && $listID) {
        try {
            $aweber = new AWeberAPI($consumer_key, $consumer_secret);
            $account = $aweber->getAccount($access_key, $access_secret);
            $account_id = $account->id;
            $listURL = "/accounts/{$account_id}/lists/{$listID}";
            $list = $account->loadFromUrl($listURL);
            # create a subscriber
            $params = array('email' => $email, 'ip_address' => $ip, 'name' => $u_name);
            $subscribers = $list->subscribers;
            $new_subscriber = $subscribers->create($params);
        } catch (AWeberAPIException $exc) {
            print 'Error: ' . $exc->message . '';
            exit(1);
        }
    }
    die;
}
예제 #23
0
 function et_pb_get_aweber_account()
 {
     if (!class_exists('AWeberAPI')) {
         require_once ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php';
     }
     $consumer_key = et_get_option('divi_aweber_consumer_key');
     $consumer_secret = et_get_option('divi_aweber_consumer_secret');
     $access_key = et_get_option('divi_aweber_access_key');
     $access_secret = et_get_option('divi_aweber_access_secret');
     if (!empty($consumer_key) && !empty($consumer_secret) && !empty($access_key) && !empty($access_secret)) {
         try {
             // Aweber requires curl extension to be enabled
             if (!function_exists('curl_init')) {
                 return false;
             }
             $aweber = new AWeberAPI($consumer_key, $consumer_secret);
             if (!$aweber) {
                 return false;
             }
             $account = $aweber->getAccount($access_key, $access_secret);
         } catch (Exception $exc) {
             return false;
         }
     } else {
         return false;
     }
     return $account;
 }
예제 #24
0
function pmproaw_options_page()
{
    global $pmproaw_lists;
    //check for a valid API key and get lists
    $options = get_option("pmproaw_options");
    $authorization_code = $options['authorization_code'];
    $access_key = $options['access_key'];
    $access_secret = $options['access_secret'];
    //get token if needed
    if (!empty($authorization_code) && (empty($access_key) || empty($access_secret))) {
        try {
            # set $authorization_code to the code that is given to you from
            # https://auth.aweber.com/1.0/oauth/authorize_app/YOUR_APP_ID
            $auth = AWeberAPI::getDataFromAweberID($authorization_code);
            list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
            # Store the Consumer key/secret, as well as the AccessToken key/secret
            # in your app, these are the credentials you need to access the API.
            $access_key = $accessKey;
            $options['access_key'] = $access_key;
            $access_secret = $accessSecret;
            $options['access_secret'] = $access_secret;
            update_option('pmproaw_options', $options);
        } catch (AWeberAPIException $exc) {
            print "<h3>AWeberAPIException:</h3>";
            print " <li> Type: {$exc->type}              <br>";
            print " <li> Msg : {$exc->message}           <br>";
            print " <li> Docs: {$exc->documentation_url} <br>";
            print "<hr>";
        }
    }
    //get lists
    if (!empty($access_key) && !empty($access_secret)) {
        $aweber = new AWeberAPI(PMPROAW_CONSUMER_KEY, PMPROAW_CONSUMER_SECRET);
        try {
            $account = $aweber->getAccount($access_key, $access_secret);
            $pmproaw_lists = $account->lists->data['entries'];
            $all_lists = array();
            //save all lists in an option
            $i = 0;
            foreach ($pmproaw_lists as $list) {
                $all_lists[$i]['id'] = $list['id'];
                $all_lists[$i]['account_id'] = $account->id;
                $all_lists[$i]['name'] = $list['name'];
                $i++;
            }
            /** Save all of our new data */
            update_option("pmproaw_all_lists", $all_lists);
        } catch (AWeberAPIException $exc) {
            print "<h3>AWeberAPIException:</h3>";
            print " <li> Type: {$exc->type}              <br>";
            print " <li> Msg : {$exc->message}           <br>";
            print " <li> Docs: {$exc->documentation_url} <br>";
            print "<hr>";
        }
    }
    ?>
<div class="wrap">
	<div id="icon-options-general" class="icon32"><br></div>
	<h2>PMPro AWeber Integration Options</h2>		
	
	<?php 
    if (!empty($msg)) {
        ?>
		<div class="message <?php 
        echo $msgt;
        ?>
"><p><?php 
        echo $msg;
        ?>
</p></div>
	<?php 
    }
    ?>
	
	<form action="options.php" method="post">
		
		<p>This plugin will integrate your site with AWeber. You can choose one or more AWeber lists to have users subscribed to when they signup for your site.</p>
		<p>If you have <a href="http://www.paidmembershipspro.com">Paid Memberships Pro</a> installed, you can also choose one or more AWeber lists to have members subscribed to for each membership level.</p>
		<p>Don't have a AWeber account? <a href="http://www.aweber.com/?422729" target="_blank">Get one here</a>.</p>
		
		<?php 
    if (empty($authorization_code)) {
        ?>
			<div class="updated"><p>To get started, you must authorize this website to access your AWeber account. <a target="_blank" href="?page=pmproaw_options&oauth=1">Click here to authorize this site to access your AWeber account</a>. Then copy the "authorization code" given into the field below and click "Save Settings" to continue.</p></div>
			<?php 
    }
    settings_fields('pmproaw_options');
    do_settings_sections('pmproaw_options');
    ?>
		
		<p><br /></p>
						
		<div class="bottom-buttons">
			<input type="hidden" name="pmprot_options[set]" value="1" />
			<input type="submit" name="submit" class="button-primary" value="<?php 
    esc_attr_e('Save Settings');
    ?>
">				
		</div>
		
	</form>
</div>
<?php 
}
function sendAWeber($mailSubscribe)
{
    if (defined('AW_AUTHCODE') && defined('AW_LISTNAME')) {
        $token = 'api_aweber/' . substr(AW_AUTHCODE, 0, 10);
        if (!file_exists($token)) {
            try {
                $auth = AWeberAPI::getDataFromAweberID(AW_AUTHCODE);
                file_put_contents($token, json_encode($auth));
            } catch (AWeberAPIException $exc) {
                errorLog("AWeber", "[" . $exc->type . "] " . $exc->message . " Docs: " . $exc->documentation_url);
                throw new Exception("Authorization error", 5);
            }
        }
        if (file_exists($token)) {
            $key = file_get_contents($token);
        }
        list($consumerKey, $consumerSecret, $accessToken, $accessSecret) = json_decode($key);
        $aweber = new AWeberAPI($consumerKey, $consumerSecret);
        try {
            $account = $aweber->getAccount($accessToken, $accessSecret);
            $foundLists = $account->lists->find(array('name' => AW_LISTNAME));
            $lists = $foundLists[0];
            $params = array('email' => $mailSubscribe, 'name' => getName($mailSubscribe));
            if (isset($lists)) {
                $lists->subscribers->create($params);
            } else {
                errorLog("AWeber", "List is not found");
                throw new Exception("Error found Lists", 4);
            }
        } catch (AWeberAPIException $exc) {
            if ($exc->status == 400) {
                throw new Exception("Email exist", 2);
            } else {
                errorLog("AWeber", "[" . $exc->type . "] " . $exc->message . " Docs: " . $exc->documentation_url);
            }
        }
    }
}
예제 #26
0
	/**
	 * Get the Aweber lists for an account
	 *
	 */
	public function get_aweber_lists() {

		$options = '';
		$consumerKey = '';
		$consumerSecret = '';
		$accessKey = '';
		$accessSecret = '';

		if (isset($_POST['code']) && $_POST['code'] != '') {

			require_once( 'includes/aweber/aweber_api.php');

			try {
				$credentials = AWeberAPI::getDataFromAweberID(sanitize_text_field( $_POST['code'] ));
				list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $credentials;


				$consumerKey = isset($consumerKey) && !empty($consumerKey) ? $consumerKey : '';
				$consumerSecret = isset($consumerSecret) && !empty($consumerSecret) ? $consumerSecret : '';
				$accessKey = isset($accessKey) && !empty($accessKey) ? $accessKey : '';
				$accessSecret = isset($accessSecret) && !empty($accessSecret) ? $accessSecret : '';
			} catch (AWeberAPIException $exc) {
				error_log($exc);
			}

			try {

				$aweber = new AWeberAPI($consumerKey, $consumerSecret);
				$account = $aweber->getAccount($accessKey, $accessSecret);
				$lists = $account->loadFromUrl('/accounts/' . $account->id . '/lists/');

				foreach ($lists as $list) {
					$options .= '<option value="' . $list->id . '">' .  $list->name . '</option>';
				}

			} catch (AWeberAPIException $exc) { error_log($exc); }
		}

		if (isset($_POST['list']) && $_POST['list'] != '') {

			$consumerKey     = sanitize_text_field( $_POST['consumer_key'] );
			$consumerSecret  = sanitize_text_field( $_POST['consumer_secret'] );
			$accessKey       = sanitize_text_field( $_POST['access_key'] );
			$accessSecret    = sanitize_text_field( $_POST['access_secret'] );

			require_once( 'includes/aweber/aweber_api.php');

			try {

				$aweber = new AWeberAPI($consumerKey, $consumerSecret);
				$account = $aweber->getAccount($accessKey, $accessSecret);
				$lists = $account->loadFromUrl('/accounts/' . $account->id . '/lists/');

				$options = '';
				foreach ($lists as $list) {
					if ($_POST['list'] == $list->id) {
						$options .= '<option value="' . $list->id . '" selected="selected">' .  $list->name . '</option>';
					} else {
						$options .= '<option value="' . $list->id . '">' .  $list->name . '</option>';
					}
				}

			} catch (AWeberAPIException $exc) { error_log($exc); }
		}

		echo json_encode(array(
			'html'               => $options,
			'consumer_key'       => $consumerKey,
			'consumer_secret'    => $consumerSecret,
			'access_key'         => $accessKey,
			'access_secret'      => $accessSecret,
		));

		die(); // this is required to terminate immediately and return a proper response
	}
예제 #27
0
 function et_pb_get_aweber_account()
 {
     if (!class_exists('AWeberAPI')) {
         require_once get_template_directory() . '/includes/subscription/aweber/aweber_api.php';
     }
     $consumer_key = et_get_option('divi_aweber_consumer_key');
     $consumer_secret = et_get_option('divi_aweber_consumer_secret');
     $access_key = et_get_option('divi_aweber_access_key');
     $access_secret = et_get_option('divi_aweber_access_secret');
     try {
         // Aweber requires curl extension to be enabled
         if (!function_exists('curl_init')) {
             return false;
         }
         $aweber = new AWeberAPI($consumer_key, $consumer_secret);
         if (!$aweber) {
             return false;
         }
         $account = $aweber->getAccount($access_key, $access_secret);
     } catch (Exception $exc) {
         return false;
     }
     return $account;
 }
    function form($instance)
    {
        /* Set up some default widget settings. */
        $defaults = array('title' => '', 'text' => '', 'code' => '', 'list' => '');
        $instance = wp_parse_args((array) $instance, $defaults);
        if (get_option(THEME_NAME . "_footer_subscribe_code")) {
            /* Set up some default widget settings. */
            $defaults = array('code' => get_option(THEME_NAME . "_footer_subscribe_code"));
        }
        $instance = wp_parse_args((array) $instance, $defaults);
        $title = esc_attr($instance['title']);
        $text = esc_attr($instance['text']);
        if (get_option(THEME_NAME . "_footer_subscribe_code")) {
            $code = get_option(THEME_NAME . "_footer_subscribe_code");
        } else {
            $code = esc_attr($instance['code']);
        }
        $list = esc_attr($instance['list']);
        $keys = get_option(THEME_NAME . "_aweber_keys");
        if ($keys['access_key']) {
            extract($keys);
            $error_ = null;
            try {
                $aweber = new AWeberAPI($consumer_key, $consumer_secret);
                $account = $aweber->getAccount($access_key, $access_secret);
            } catch (AWeberException $e) {
                $error_ = get_class($e);
                $account = null;
            }
            if (!$account) {
                if ($error_ != 'AWeberOAuthException' && $error_ != 'AWeberOAuthDataMissing') {
                    echo "Unable to connect to AWeber's API.  Please refresh the page, or attempt to reauthorize.";
                    $temp_error = True;
                } else {
                    $this->deauthorize();
                    echo "AWeber Web Form authentication failed";
                }
            } else {
                $authorize_success = True;
                $button_value = 'Remove Connection';
            }
        }
        ?>
            <p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        printf(__('Title:', THEME_NAME));
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" /></label></p>
          

			<p><label for="<?php 
        echo $this->get_field_id('text');
        ?>
"><?php 
        printf(__('Text:', THEME_NAME));
        ?>
 <textarea style="height:200px;" class="widefat" id="<?php 
        echo $this->get_field_id('text');
        ?>
" name="<?php 
        echo $this->get_field_name('text');
        ?>
"><?php 
        echo $text;
        ?>
</textarea></label></p>

			<p><strong>Step 1:</strong>	<a href="https://auth.aweber.com/1.0/oauth/authorize_app/0046e0e1" target="_blank"><?php 
        printf(__('Click here to get your authorization code.', THEME_NAME));
        ?>
</a></p>
            <p><label for="<?php 
        echo $this->get_field_id('code');
        ?>
"><?php 
        printf(__('<strong>Step 2:</strong>	Paste in your authorization code:', THEME_NAME));
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('code');
        ?>
" name="<?php 
        echo $this->get_field_name('code');
        ?>
" type="text" value="<?php 
        echo $code;
        ?>
" /></label></p>
		<?php 
        if (isset($account)) {
            $lists = $account->lists;
        }
        if (!empty($lists)) {
            ?>
		    <p><label for="<?php 
            echo $this->get_field_id('list');
            ?>
"><?php 
            printf(__('Select the list you\'d like people to subscribe to:', THEME_NAME));
            ?>
</label>
                <select class="widefat " name="<?php 
            echo $this->get_field_name('list');
            ?>
" id="<?php 
            echo $this->get_field_id('list');
            ?>
">
					<option value="FALSE"><?php 
            printf(__('Select A List', THEME_NAME));
            ?>
</option>
					<?php 
            foreach ($lists as $this_list) {
                ?>
						<option value="<?php 
                echo $this_list->id;
                ?>
"<?php 
                echo $this_list->id == $list ? ' selected="selected"' : "";
                ?>
><?php 
                echo $this_list->name;
                ?>
</option>
					<?php 
            }
            ?>
				</select>
			</p>
            <?php 
        } else {
            ?>
				<?php 
            printf(__('This AWeber account does not currently have any lists or your authorization code is incorrect!', THEME_NAME));
            ?>
            <?php 
        }
        ?>
        <?php 
    }
예제 #29
0
 /**
  * Processes aweber list field. Called by AJAX script.
  */
 public static function field_aweber_list_ajax()
 {
     require CH_Manager::$plugin_dir . 'lib/aweber/aweber_api.php';
     $contest = new CH_Contest($_POST['contest_id']);
     if (!$contest->_valid) {
         die;
     }
     $aweber_auth = $contest->ch_aweber_auth;
     if (empty($aweber_auth)) {
         die;
     }
     if (empty($aweber_auth['consumer_key']) || empty($aweber_auth['consumer_secret']) || empty($aweber_auth['access_key']) || empty($aweber_auth['access_secret'])) {
         die;
     }
     $consumerKey = $aweber_auth['consumer_key'];
     $consumerSecret = $aweber_auth['consumer_secret'];
     $access_key = $aweber_auth['access_key'];
     $access_secret = $aweber_auth['access_secret'];
     $aweber = new AWeberAPI($consumerKey, $consumerSecret);
     $account = $aweber->getAccount($access_key, $access_secret);
     $value = '';
     if (!empty($_POST['value'])) {
         $value = $_POST['value'];
     }
     $output = '';
     foreach ($account->lists as $list) {
         $selected = '';
         if ($list->id == $value) {
             $selected = ' selected="selected"';
         }
         $output .= '<option value="' . $list->id . '"' . $selected . '>' . $list->name . '</option>';
     }
     echo $output;
     die;
 }
예제 #30
-1
 public function syncPlayerAweber()
 {
     $accessKeys = explode('|', $this->meta['aweber']['accessKeys']);
     $consumerKey = $accessKeys[0];
     $consumerSecret = $accessKeys[1];
     $accessKey = $accessKeys[2];
     $accessSecret = $accessKeys[3];
     $listId = str_replace('awlist', '', $this->meta['aweber']['listId']);
     $application = new AWeberAPI($consumerKey, $consumerSecret);
     $account = $application->getAccount($accessKey, $accessSecret);
     try {
         $listUrl = "/accounts/{$account->id}/lists/{$listId}";
         $list = $account->loadFromUrl($listUrl);
         $subscriber = array('email' => $this->playerData['email'], 'name' => $this->playerData['nickname']);
         // Custom field RESULT ?
         if (isset($this->meta['aweber']['resultField']) && $this->meta['aweber']['resultField'] != '') {
             $subscriber['custom_fields'][$this->meta['aweber']['resultField']] = $this->playerData['result'];
         }
         $newSubscriber = $list->subscribers->create($subscriber);
         echo "<pre>";
         echo "— DEBUG —";
         print_r($newSubscriber);
         echo "</pre>";
         die;
     } catch (Exception $exc) {
         print $exc;
         die;
     }
 }