function snp_ml_get_aw_auth($ml_aw_auth_code)
{
    $return = array();
    require_once SNP_DIR_PATH . '/include/aweber/aweber_api.php';
    $descr = '';
    try {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($ml_aw_auth_code);
    } catch (AWeberAPIException $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
        if (isset($exc->message)) {
            $descr = $exc->message;
            $descr = preg_replace('/http.*$/i', '', $descr);
            # strip labs.aweber.com documentation url from error message
            $descr = preg_replace('/[\\.\\!:]+.*$/i', '', $descr);
            # strip anything following a . : or ! character
            $descr = '(' . $descr . ')';
        }
    } catch (AWeberOAuthDataMissing $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
    } catch (AWeberException $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
    }
    if (!$access_secret) {
        $return['Error'] = 'Unable to connect to your AWeber Account ' . $descr;
        $return['Ok'] = false;
    } else {
        $ml_aw_auth_info = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'access_key' => $access_key, 'access_secret' => $access_secret);
        update_option('snp_ml_aw_auth_info', $ml_aw_auth_info);
        $return['Ok'] = true;
    }
    return $return;
}
/**
 *  Callback for Aweber Authorization
 */
function cspv4_aweber_auth()
{
    if (check_ajax_referer('seed_cspv4_aweber_auth')) {
        require_once SEED_CSPV4_PLUGIN_PATH . 'extentions/aweber/aweber_api/aweber_api.php';
        $authorization_code = urldecode($_GET['auth_code']);
        try {
            $auth = AWeberAPI::getDataFromAweberID($authorization_code);
            list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
            update_option('seed_cspv4_aweber_auth', array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'access_key' => $accessKey, 'access_secret' => $accessSecret));
            echo '200';
        } catch (AWeberAPIException $exc) {
            echo '500';
        }
        exit;
    }
}
 public function verify_auth_data($verify_code = null)
 {
     if ($this->consumer_key == null) {
         if ($verify_code != null && !empty($verify_code)) {
             try {
                 ////error_log( $verify_code );
                 $auth = AWeberAPI::getDataFromAweberID($verify_code);
                 list($this->consumer_key, $this->consumer_secret, $this->access_key, $this->access_secret) = $auth;
                 update_option('stepify_aw_consumer_key', $this->consumer_key);
                 update_option('stepify_aw_consumer_secret', $this->consumer_secret);
                 update_option('stepify_aw_access_key', $this->access_key);
                 update_option('stepify_aw_access_secret', $this->access_secret);
                 return true;
             } catch (Exception $e) {
                 var_dump($e->getMessage());
             }
         }
         return false;
     } else {
         return true;
     }
 }
Exemple #4
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) {
             }
         }
     }
 }
        $options['create_subscriber_signup_text'] = get_option('aweber_signup_text_value');
    }
    update_option($this->widgetOptionsName, $options);
}
if ($authorization_removed) {
    $this->deauthorize();
    $pluginAdminOptions = get_option($this->adminOptionsName);
    $options = get_option($this->widgetOptionsName);
    echo '<div id="message" class="updated"><p>Your connection to your AWeber account has been closed.</p></div>';
    $error = $temp_error = null;
} elseif ($oauth_id and !$pluginAdminOptions['access_secret']) {
    // Then they just saved a key and didn't remove anything
    // Check it's validity then save it for later use
    $error_code = "";
    try {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($oauth_id);
    } catch (AWeberAPIException $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
        # make error messages customer friendly.
        $descr = $exc->description;
        $descr = preg_replace('/http.*$/i', '', $descr);
        # strip labs.aweber.com documentation url from error message
        $descr = preg_replace('/[\\.\\!:]+.*$/i', '', $descr);
        # strip anything following a . : or ! character
        $error_code = " ({$descr})";
    } catch (AWeberOAuthDataMissing $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
    } catch (AWeberException $exc) {
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
    }
    if (!$access_secret) {
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)) {
        //get aweber account or fail
        $account = pmproaw_getAccount();
        if (!empty($account)) {
            try {
                $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>";
            }
        } else {
            global $pmproaw_exception;
            if (!empty($pmproaw_exception)) {
                print "<h3>AWeberAPIException:</h3>";
                print " <li> Type: {$pmproaw_exception->type}              <br>";
                print " <li> Msg : {$pmproaw_exception->message}           <br>";
                print " <li> Docs: {$pmproaw_exception->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 update($new_instance, $old_instance)
 {
     $instance = $old_instance;
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['text'] = strip_tags($new_instance['text']);
     $instance['list'] = strip_tags($new_instance['list']);
     $instance['color'] = strip_tags($new_instance['color']);
     if ($instance['code'] != $new_instance['code'] && $new_instance['code'] != get_option(THEME_NAME . "_footer_subscribe_code")) {
         $instance['code'] = strip_tags($new_instance['code']);
         update_option(THEME_NAME . "_footer_subscribe_code", $instance['code']);
         $oauth_id = $new_instance['code'];
         if ($oauth_id) {
             try {
                 list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = AWeberAPI::getDataFromAweberID($oauth_id);
             } catch (AWeberAPIException $exc) {
                 list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
                 # make error messages customer friendly.
                 $descr = $exc->description;
                 $descr = preg_replace('/http.*$/i', '', $descr);
                 # strip labs.aweber.com documentation url from error message
                 $descr = preg_replace('/[\\.\\!:]+.*$/i', '', $descr);
                 # strip anything following a . : or ! character
                 $error_code = " ({$descr})";
             } catch (AWeberOAuthDataMissing $exc) {
                 list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
             } catch (AWeberException $exc) {
                 list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
             }
         }
         $keys = array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'access_key' => $accessKey, 'access_secret' => $accessSecret);
         update_option(THEME_NAME . "_aweber_keys", $keys);
     }
     return $instance;
 }
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>';
}
Exemple #9
0
function ihc_update_aweber()
{
    include_once IHC_PATH . 'classes/email_services/aweber/aweber_api.php';
    list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($_REQUEST['auth_code']);
    update_option('ihc_aweber_consumer_key', $consumer_key);
    update_option('ihc_aweber_consumer_secret', $consumer_secret);
    update_option('ihc_aweber_acces_key', $access_key);
    update_option('ihc_aweber_acces_secret', $access_secret);
    echo 1;
    die;
}
 public function get_authenticated_instance()
 {
     global $edd_options;
     $authorization_code = isset($edd_options['edd_aweb_api']) ? trim($edd_options['edd_aweb_api']) : '';
     $msg = '';
     if (!empty($authorization_code)) {
         if (!class_exists('AWeberAPI')) {
             require_once EDD_AWEBER_PATH . '/aweber/aweber_api.php';
         }
         $error_code = "";
         if (false !== get_option('aweber_secrets')) {
             $options = get_option('aweber_secrets');
             $msg = $options;
             try {
                 $api = new AWeberAPI($options['consumer_key'], $options['consumer_secret']);
             } catch (AWeberAPIException $exc) {
                 $api = false;
             }
             return $api;
         } else {
             try {
                 list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($authorization_code);
             } catch (AWeberAPIException $exc) {
                 list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
                 # make error messages customer friendly.
                 $descr = $exc->message;
                 $descr = preg_replace('/http.*$/i', '', $descr);
                 # strip labs.aweber.com documentation url from error message
                 $descr = preg_replace('/[\\.\\!:]+.*$/i', '', $descr);
                 # strip anything following a . : or ! character
                 $error_code = " ({$descr})";
             } catch (AWeberOAuthDataMissing $exc) {
                 list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
             } catch (AWeberException $exc) {
                 list($consumer_key, $consumer_secret, $access_key, $access_secret) = null;
             }
             if (!$access_secret) {
                 $msg = '<div id="aweber_access_token_failed" class="error">';
                 $msg .= "Unable to connect to your AWeber Account{$error_code}:<br />";
                 # show oauth_id if it failed and an api exception was not raised
                 if (empty($error_code)) {
                     $msg .= "Authorization code entered was: {$authorization_code} <br />";
                 }
                 $msg .= "Please make sure you entered the complete authorization code and try again.</div>";
             } else {
                 $secrets = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'access_key' => $access_key, 'access_secret' => $access_secret);
                 update_option('aweber_secrets', $secrets);
             }
         }
     } else {
         delete_option('aweber_secrets');
     }
     $msg = isset($msg) ? $msg : $pluginAdminOptions;
     update_option('aweber_response', $msg);
 }
    /**
     * Retrieves the tokens from AWeber
     * @return string
     */
    function aweber_authorization($api_key)
    {
        if (!class_exists('AWeberAPI')) {
            require_once ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php';
        }
        try {
            $auth = AWeberAPI::getDataFromAweberID($api_key);
            if (!(is_array($auth) && 4 === count($auth))) {
                $error_message = esc_html__('Authorization code is invalid. Try regenerating it and paste in the new code.', 'et_builder_plugin');
            } else {
                $error_message = 'success';
                list($consumer_key, $consumer_secret, $access_key, $access_secret) = $auth;
                self::update_option(array('newsletter_main_aweber_key' => sanitize_text_field($api_key), 'aweber_consumer_key' => sanitize_text_field($consumer_key), 'aweber_consumer_secret' => sanitize_text_field($consumer_secret), 'aweber_access_key' => sanitize_text_field($access_key), 'aweber_access_secret' => sanitize_text_field($access_secret)));
            }
        } catch (AWeberAPIException $exc) {
            $error_message = sprintf('<p>%4$s</p>
				<ul>
					<li>%5$s: %1$s</li>
					<li>%6$s: %2$s</li>
					<li>%7$s: %3$s</li>
				</ul>', esc_html($exc->type), esc_html($exc->message), esc_html($exc->documentation_url), esc_html__('AWeberAPIException.', 'et_builder_plugin'), esc_html__('Type', 'et_builder_plugin'), esc_html__('Message', 'et_builder_plugin'), esc_html__('Documentation', 'et_builder_plugin'));
        }
        return $error_message;
    }
Exemple #12
0
function et_aweber_submit_authorization_code()
{
    if (!wp_verify_nonce($_POST['et_load_nonce'], 'et_load_nonce')) {
        die(__('Nonce failed.', 'Divi'));
    }
    $et_authorization_code = $_POST['et_authorization_code'];
    if ('' === $et_authorization_code) {
        die(__('Authorization code is empty.', 'Divi'));
    }
    if (!class_exists('AWeberAPI')) {
        require_once get_template_directory() . '/includes/subscription/aweber/aweber_api.php';
    }
    try {
        $auth = AWeberAPI::getDataFromAweberID($et_authorization_code);
        if (!(is_array($auth) && 4 === count($auth))) {
            die(__('Authorization code is invalid. Try regenerating it and paste in the new code.', 'Divi'));
        }
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = $auth;
        et_update_option('divi_aweber_consumer_key', $consumer_key);
        et_update_option('divi_aweber_consumer_secret', $consumer_secret);
        et_update_option('divi_aweber_access_key', $access_key);
        et_update_option('divi_aweber_access_secret', $access_secret);
        die('success');
    } catch (AWeberAPIException $exc) {
        printf('<p>AWeberAPIException.</p>
			<ul>
				<li>Type: %1$s</li>
				<li>Message: %2$s</li>
				<li>Documentation: %3$s</li>
			</ul>', esc_html($exc->type), esc_html($exc->message), esc_html($exc->documentation_url));
    }
    die;
}
 /**
  * Get the Aweber lists for an account
  *
  * @access public
  * @return void
  */
 function nnr_new_int_get_aweber_lists_v1()
 {
     do_action('nnr_news_int_before_get_aweber_lists_v1');
     $options = '';
     $consumerKey = '';
     $consumerSecret = '';
     $accessKey = '';
     $accessSecret = '';
     if (isset($_POST['code']) && $_POST['code'] != '') {
         require_once dirname(dirname(__FILE__)) . '/services/aweber/aweber_api.php';
         try {
             $credentials = AWeberAPI::getDataFromAweberID($_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 = $_POST['consumer_key'];
         $consumerSecret = $_POST['consumer_secret'];
         $accessKey = $_POST['access_key'];
         $accessSecret = $_POST['access_secret'];
         require_once dirname(dirname(__FILE__)) . '/services/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);
         }
     }
     do_action('nnr_news_int_after_get_aweber_lists_v1');
     echo json_encode(apply_filters('nnr_news_int_get_aweber_lists_v1', 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
 }
    /**
     * Retrieves the tokens from AWeber
     * @return string
     */
    function aweber_authorization($api_key, $name)
    {
        if (!class_exists('AWeberAPI')) {
            require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/aweber/aweber_api.php';
        }
        try {
            $auth = AWeberAPI::getDataFromAweberID($api_key);
            if (!(is_array($auth) && 4 === count($auth))) {
                $error_message = __('Authorization code is invalid. Try regenerating it and paste in the new code.', 'rapidology');
            } else {
                $error_message = 'success';
                list($consumer_key, $consumer_secret, $access_key, $access_secret) = $auth;
                $this->update_account('aweber', $name, array('api_key' => esc_html($api_key), 'consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'access_key' => $access_key, 'access_secret' => $access_secret, 'is_authorized' => esc_html('true')));
            }
        } catch (AWeberAPIException $exc) {
            $error_message = sprintf('<p>%4$s</p>
				<ul>
					<li>%5$s: %1$s</li>
					<li>%6$s: %2$s</li>
					<li>%7$s: %3$s</li>
				</ul>', esc_html($exc->type), esc_html($exc->message), esc_html($exc->documentation_url), esc_html__('AWeberAPIException.', 'rapidology'), esc_html__('Type', 'rapidology'), esc_html__('Message', 'rapidology'), esc_html__('Documentation', 'rapidology'));
        }
        return $error_message;
    }
Exemple #15
0
             foreach($allmclists['data'] as $mclist){
                 $mailchimp_lists[$mclist['id']] = $mclist['name'];
             }
             $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>";
         }
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);
    }
}
Exemple #17
0
         echo json_encode(array("status" => "success"));
         // ERROR SENDING
     } else {
         /*echo json_encode(array(
         			"status" => "error",
         			"type" => $result->message
         		));*/
         echo json_encode(array("status" => "error", "type" => "Looks like something went wrong. Please try again later."));
         errorlog("getresponse", $result->message);
     }
 } elseif ($STORE_MODE == "aweber") {
     $auth_f = substr($AW_AUTH_CODE, 0, 8) . '_auth.rgen';
     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];
Exemple #18
0
function theme_menu()
{
    global $themename, $themeslug, $options, $wpdb;
    $nonsavable_types = array('navigation', 'tab', 'sub_navigation', 'sub_tab', 'homepage_set_test', 'save', 'closesubtab', 'closetab', 'row', 'close');
    // wp-admin custom form settings
    // table name
    $table_name = $wpdb->prefix . THEME_NAME . "_reservation";
    //the single entry id
    if (isset($_GET['ot-single-entry'])) {
        $id = (int) esc_sql($_GET['ot-single-entry']);
    }
    //the single entry id
    if (isset($_GET['action'])) {
        $action = esc_sql($_GET['action']);
    }
    //delete a entry
    if (isset($action) && $action == "delete" && isset($id)) {
        $wpdb->delete($table_name, array('id' => $id));
        wp_redirect("admin.php?page=theme-configuration");
        exit;
    }
    //insert the default values if the fields are empty
    foreach ($options as $value) {
        if (isset($value['id']) && get_option($value['id']) == '' && isset($value['std']) && !in_array($value['type'], $nonsavable_types)) {
            update_option($value['id'], $value['std']);
        }
    }
    //save the field's values if the Save action is present
    if (isset($_GET['page']) && $_GET['page'] == 'theme-configuration') {
        if (isset($_REQUEST['action']) && 'save' == $_REQUEST['action']) {
            //verify the nonce
            if (empty($_POST) || !wp_verify_nonce($_POST['orange-theme-options'], 'orange-theme-update-options')) {
                print 'Sorry, your nonce did not verify.';
                exit;
            } else {
                if (get_option('orange_themes_first_save') == '') {
                    update_option('orange_themes_first_save', 'saved');
                }
                foreach ($options as $value) {
                    if (isset($value['id']) && isset($_REQUEST[$value['id']]) && !in_array($value['type'], $nonsavable_types)) {
                        if ($value['type'] == "checkbox" && $_REQUEST[$value['id']] == "on") {
                            update_option($value['id'], $_REQUEST[$value['id']]);
                        }
                        if ($value['type'] == "aweber_input") {
                            $arrayAweber = get_option(THEME_NAME . "_aweber_keys");
                            if (empty($arrayAweber) || $_REQUEST[$value['id']] != get_option($value['id'])) {
                                $oauth_id = $_REQUEST[$value['id']];
                                if ($oauth_id) {
                                    try {
                                        list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = AWeberAPI::getDataFromAweberID($oauth_id);
                                    } catch (AWeberAPIException $exc) {
                                        list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
                                        # make error messages customer friendly.
                                        $descr = $exc->description;
                                        $descr = preg_replace('/http.*$/i', '', $descr);
                                        # strip labs.aweber.com documentation url from error message
                                        $descr = preg_replace('/[\\.\\!:]+.*$/i', '', $descr);
                                        # strip anything following a . : or ! character
                                        $error_code = " ({$descr})";
                                    } catch (AWeberOAuthDataMissing $exc) {
                                        list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
                                    } catch (AWeberException $exc) {
                                        list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = null;
                                    }
                                }
                                $keys = array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'access_key' => $accessKey, 'access_secret' => $accessSecret);
                                update_option(THEME_NAME . "_aweber_keys", $keys);
                                update_option($value['id'], $_REQUEST[$value['id']]);
                            }
                        }
                        if ($value['type'] != "checkbox" && $value['type'] != "aweber_input") {
                            update_option($value['id'], $_REQUEST[$value['id']]);
                        }
                    } elseif ($value['type'] == "checkboxes") {
                        foreach ($value['checkboxes'] as $checkbox) {
                            if ($_REQUEST[$checkbox['id']] == "on") {
                                update_option($checkbox['id'], $_REQUEST[$checkbox['id']]);
                            } else {
                                update_option($checkbox['id'], "off");
                            }
                        }
                    } elseif ($value['type'] == "homepage_blocks") {
                        $fieldID = get_option(THEME_NAME . "_homepage_layout_order");
                        if (is_array($fieldID)) {
                            $a = 0;
                            foreach ($fieldID as $sssss) {
                                foreach ($value['blocks'] as $block) {
                                    foreach ($block['options'] as $blockOption) {
                                        update_option($blockOption['id'] . "_" . $fieldID[$a]['id'], $_REQUEST[$blockOption['id'] . "_" . $fieldID[$a]['id']]);
                                    }
                                }
                                $a++;
                            }
                        }
                    } elseif (!in_array($value['type'], $nonsavable_types) && isset($value['id'])) {
                        if ($value['type'] != "aweber_input") {
                            delete_option($value['id']);
                        }
                    }
                    if ($value['type'] == 'add_text') {
                        $old_val = $_REQUEST[$value['id'] . 's'];
                        $old_val = explode("|*|", $old_val);
                        if (!in_array($_REQUEST[$value['id']], $old_val) && $_REQUEST[$value['id']]) {
                            update_option($value['id'] . 's', $_REQUEST[$value['id'] . 's'] . sanitize_title($_REQUEST[$value['id']]) . "|*|");
                        }
                    }
                    if ($value['type'] == 'add_text_datepicker') {
                        $old_val = $_REQUEST[$value['id'] . 's'];
                        $old_val = explode("|*|", $old_val);
                        if (!in_array($_REQUEST[$value['id']], $old_val) && $_REQUEST[$value['id']]) {
                            update_option($value['id'] . 's', $_REQUEST[$value['id'] . 's'] . $_REQUEST[$value['id']] . "|*|");
                        }
                    }
                }
                header("Location: admin.php?page=theme-configuration&saved=true");
                die;
            }
        }
    }
    add_menu_page(THEME_FULL_NAME . ' Management', THEME_FULL_NAME . ' Management', 'administrator', 'theme-configuration', 'theme_configuration', get_template_directory_uri() . '/images/control-panel-images/logo-orangethemes-2.png');
    add_submenu_page("edit.php?post_type=" . OT_POST_MENU, __('Category Order', THEME_NAME), __('Category Order', THEME_NAME), 'administrator', THEME_NAME . "-category-order", THEME_NAME . '_category_order');
}
Exemple #19
0
 function _check_services_settings($service, $on_update = false)
 {
     $service_name = $service;
     $service = 'hc_' . $service;
     $appid = $service . '_appid';
     $appkey = $service . '_appkey';
     $appurl = $service . '_appurl';
     require_once 'includes/apis/hc_services_helper.php';
     if ($service_name == 'aweber') {
         if ($on_update === false) {
             $aweber_settings = get_option('hc_aweber_api_settings');
             if (is_array($aweber_settings)) {
                 extract($aweber_settings);
             } else {
                 return false;
             }
             try {
                 $aweber = $this->_get_aweber_api($consumer_key, $consumer_secret);
                 $account = $aweber->getAccount($access_key, $access_secret);
                 return true;
             } catch (AWeberException $e) {
                 $account = null;
                 return false;
             }
             if (!$account) {
                 return false;
             }
             return false;
         }
         require_once 'includes/apis/aweber_api/aweber_api.php';
         $auth_code = get_option($appid);
         try {
             list($consumer_key, $consumer_secret, $access_key, $access_secret) = AWeberAPI::getDataFromAweberID($auth_code);
             $aweber_settings = array('consumer_key' => $consumer_key, 'consumer_secret' => $consumer_secret, 'access_key' => $access_key, 'access_secret' => $access_secret);
             update_option('hc_aweber_api_settings', $aweber_settings);
             return true;
         } catch (AWeberException $e) {
             $aweber_settings = array('consumer_key' => null, 'consumer_secret' => null, 'access_key' => null, 'access_secret' => null);
             update_option('hc_aweber_api_settings', $aweber_settings);
             return false;
         } catch (AWeberOAuthException $e) {
             $aweber_settings = array('consumer_key' => null, 'consumer_secret' => null, 'access_key' => null, 'access_secret' => null);
             update_option('hc_aweber_api_settings', $aweber_settings);
             return false;
         }
         return false;
     }
     if ($service_name == 'mailchimp') {
         $result = mailchimp_getLists(get_option('hc_mailchimp_appkey'));
         if (!$result) {
             return false;
         }
         return true;
     }
     if ($service_name == 'infusionsoft') {
         $client = $this->_get_infusionsoft_client();
         $apikey = get_option('hc_infusionsoft_appkey');
         $result = infusionsoft_getCampaigns($client, $apikey);
         if (isset($result->errno) && $result->errno > 0) {
             return false;
         }
         return true;
     }
     if ($service_name == 'icontact') {
         $appkey = get_option('hc_icontact_appkey');
         $appid = get_option('hc_icontact_appid');
         $appurl = get_option('hc_icontact_appurl');
         if ($appkey != '' && $appid != '' && $appurl != '') {
             $result = icontact_getLists($appid, $appkey, $appurl);
             if (!$result) {
                 return false;
             }
             return true;
         } else {
             return false;
         }
     }
     if ($service_name == 'officeautopilot') {
         $appkey = get_option('hc_officeautopilot_appkey');
         $appid = get_option('hc_officeautopilot_appid');
         if ($appkey == '' || $appid == '') {
             return false;
         }
         $result = officeautopilot_getLists(get_option('hc_officeautopilot_appkey'), get_option('hc_officeautopilot_appid'));
         if (isset($result[0]) && strpos($result[0], "error") > 0) {
             return false;
         }
         if (!isset($result[0])) {
             return false;
         }
         return true;
     }
     if ($service_name == 'getresponse') {
         $result = getresponse_getList(get_option('hc_getresponse_appkey'));
         if (!$result) {
             return false;
         }
         return true;
     }
     if ($service_name == 'constantcontact') {
         $appkey = get_option('hc_constantcontact_appkey');
         $appusername = get_option('hc_constant_contact_username');
         $apptoken = get_option('hc_constant_contact_token');
         if ($appkey != '' && $appid != '' && $appurl != '') {
             $result = constantcontact_getList($appkey, $appusername, $apptoken);
             if (!$result) {
                 return false;
             }
         } else {
             return false;
         }
         return true;
     }
     return false;
 }
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);
            }
        }
    }
}
Exemple #21
0
function et_aweber_submit_authorization_code()
{
    if (!wp_verify_nonce($_POST['et_admin_load_nonce'], 'et_admin_load_nonce')) {
        die(esc_html__('Nonce failed.', 'et_builder'));
    }
    if (!current_user_can('manage_options')) {
        die(-1);
    }
    $et_authorization_code = sanitize_text_field($_POST['et_authorization_code']);
    if ('' === $et_authorization_code) {
        die(esc_html__('Authorization code is empty.', 'et_builder'));
    }
    if (!class_exists('AWeberAPI')) {
        require_once ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php';
    }
    try {
        $auth = AWeberAPI::getDataFromAweberID($et_authorization_code);
        if (!(is_array($auth) && 4 === count($auth))) {
            die(esc_html__('Authorization code is invalid. Try regenerating it and paste in the new code.', 'et_builder'));
        }
        list($consumer_key, $consumer_secret, $access_key, $access_secret) = $auth;
        et_update_option('divi_aweber_consumer_key', $consumer_key);
        et_update_option('divi_aweber_consumer_secret', $consumer_secret);
        et_update_option('divi_aweber_access_key', $access_key);
        et_update_option('divi_aweber_access_secret', $access_secret);
        die('success');
    } catch (AWeberAPIException $exc) {
        printf('<p>%4$s.</p>
			<ul>
				<li>%5$s: %1$s</li>
				<li>%6$s: %2$s</li>
				<li>%7$s: %3$s</li>
			</ul>', esc_html($exc->type), esc_html($exc->message), esc_html($exc->documentation_url), esc_html__('Aweber API Exception', 'et_builder'), esc_html__('Type', 'et_builder'), esc_html__('Message', 'et_builder'), esc_html__('Documentation', 'et_builder'));
    }
    die;
}
Exemple #22
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');
 }
	/**
	 * 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
	}
 /**
  * Processes aweber application link. Called by AJAX script.
  */
 public static function field_aweber_code_ajax()
 {
     require CH_Manager::$plugin_dir . 'lib/aweber/aweber_api.php';
     $contest = new CH_Contest($_POST['contest_id']);
     if (!$contest->_valid) {
         echo __('Error connecting application, unknown contest.', 'contesthopper');
         die;
     }
     if (empty($_POST['auth_key'])) {
         echo __('Empty auth code. Application disconnected.', 'contesthopper');
         die;
     }
     $authorization_code = urldecode($_POST['auth_key']);
     try {
         $auth = AWeberAPI::getDataFromAweberID($authorization_code);
         list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
         $data = array('consumer_key' => $consumerKey, 'consumer_secret' => $consumerSecret, 'access_key' => $accessKey, 'access_secret' => $accessSecret);
         update_post_meta($contest->ID, 'ch_aweber_auth', $data);
         echo __('App connected.', 'contesthopper');
     } catch (AWeberAPIException $exc) {
         echo __('Error connecting app.', 'contesthopper');
     }
     die;
 }
 /**
  * Generate Aweber Creds via Ajax
  * @return json with status=OK or FAIL
  */
 public static function generateAweberCreds()
 {
     require_once 'vendor/aweber/aweber/aweber_api/aweber_api.php';
     $authCode = htmlspecialchars(isset($_POST['authCode']) ? $_POST['authCode'] : '');
     $values = array('status' => 'FAIL', 'code' => $authCode);
     $credentials = AWeberAPI::getDataFromAweberID($authCode);
     $values['consumerKey'] = $credentials[0];
     $values['consumerSecret'] = $credentials[1];
     $values['accessKey'] = $credentials[2];
     $values['accessSecret'] = $credentials[3];
     if ($values['consumerKey'] != NULL) {
         $values['status'] = 'OK';
     }
     die(json_encode($values));
 }