function save()
 {
     if (isset($_POST['send-date']) && $_POST['send-date'] == 'later') {
         $send_at = $_POST['date-pickit'] . " " . $_POST['send-later-time'];
     } else {
         $send_at = '0000-00-00 00:00:00';
     }
     if (isset($_POST['test-add'])) {
         $csvadd = "email,firstname,lastname\n" . trim($_POST['test-add']);
         $data = SendPress_Data::subscriber_csv_post_to_array($csvadd);
     } else {
         $data = false;
     }
     $listids = isset($_POST['listIDS']) ? $_POST['listIDS'] : array();
     SendPress_Option::set('current_send_' . $_POST['post_ID'], array('listIDS' => $listids, 'testemails' => $data, 'send_at' => $send_at));
     SendPress_Option::set('current_send_subject_' . $_POST['post_ID'], $_POST['post_subject']);
     if (isset($_POST['test_report'])) {
         update_post_meta($_POST['post_ID'], 'istest', true);
     } else {
         update_post_meta($_POST['post_ID'], 'istest', false);
     }
     if (isset($_POST['google-campaign-name'])) {
         update_post_meta($_POST['post_ID'], 'google-campaign-name', $_POST['google-campaign-name']);
     }
     if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') {
         SendPress_Admin::redirect('Emails_Send_Confirm', array('emailID' => $_GET['emailID']));
     } else {
         SendPress_Admin::redirect('Emails_Style', array('emailID' => $_GET['emailID']));
     }
 }
 function save($post, $sp)
 {
     $options = SendPress_Option::get('notification_options');
     $options['email'] = $post['toemail'];
     $options['notifications-enable'] = array_key_exists('notifications-enable', $post) ? true : false;
     if ($options['notifications-enable']) {
         $options['subscribed'] = $post['subscribed'];
         $options['unsubscribed'] = $post['unsubscribed'];
         $options['send-to-admins'] = array_key_exists('send-to-admins', $post) ? true : false;
     }
     $options['enable-hipchat'] = array_key_exists('enable-hipchat', $post) ? true : false;
     $options['hipchat-api'] = $post['hipchat-api'];
     if (strlen($options['hipchat-api']) > 0) {
         $options['hipchat-rooms'] = array();
         if (!array_key_exists('hipchat-rooms', $post)) {
             $post['hipchat-rooms'] = array();
         }
         global $hc;
         $hc = new SendPress_HipChat($options['hipchat-api'], 'https://api.hipchat.com');
         try {
             foreach ($hc->get_rooms() as $room) {
                 $options['hipchat-rooms'][$room->room_id] = array_key_exists($room->room_id, $post['hipchat-rooms']) ? true : false;
             }
         } catch (Exception $e) {
             $options['hipchat-room'] = $post['hipchat-room'];
         }
     }
     $options = apply_filters('sendpress_notification_settings_save', $options, $post, $sp);
     SendPress_Option::set('notification_options', $options);
     SendPress_Admin::redirect('Settings_Notifications');
 }
 function save($data, $sp)
 {
     $saveid = SPNL()->validate->int($_POST['post_ID']);
     if ($saveid > 0) {
         $bodybg = SPNL()->validate->hex($_POST['body_bg']);
         $bodytext = SPNL()->validate->hex($_POST['body_text']);
         $bodylink = SPNL()->validate->hex($_POST['body_link']);
         $contentbg = SPNL()->validate->hex($_POST['content_bg']);
         $contenttext = SPNL()->validate->hex($_POST['content_text']);
         $contentlink = SPNL()->validate->hex($_POST['sp_content_link_color']);
         $contentborder = SPNL()->validate->hex($_POST['content_border']);
         $upload_image = $_POST['upload_image'];
         $headerbg = SPNL()->validate->hex($_POST['header_bg']);
         $headertextcolor = SPNL()->validate->hex($_POST['header_text_color']);
         $headertext = sanitize_text_field($_POST['header_text']);
         $headerlink = esc_url_raw($_POST['header_link']);
         $imageheaderurl = esc_url_raw($_POST['image_header_url']);
         $subheadertext = sanitize_text_field($_POST['sub_header_text']);
         $activeHeader = $_POST['active_header'];
         update_post_meta($saveid, 'upload_image', $upload_image);
         update_post_meta($saveid, 'body_bg', $bodybg);
         update_post_meta($saveid, 'body_text', $bodytext);
         update_post_meta($saveid, 'body_link', $bodylink);
         update_post_meta($saveid, 'content_bg', $contentbg);
         update_post_meta($saveid, 'content_text', $contenttext);
         update_post_meta($saveid, 'sp_content_link_color', $contentlink);
         update_post_meta($saveid, 'content_border', $contentborder);
         update_post_meta($saveid, 'header_bg', $headerbg);
         update_post_meta($saveid, 'header_text_color', $headertextcolor);
         update_post_meta($saveid, 'header_text', $headertext);
         update_post_meta($saveid, 'header_link', $headerlink);
         update_post_meta($saveid, 'image_header_url', $imageheaderurl);
         update_post_meta($saveid, 'sub_header_text', $subheadertext);
         update_post_meta($saveid, 'active_header', $activeHeader);
         $canspam = sanitize_text_field($_POST['can-spam']);
         $linkedin = '';
         if (isset($_POST['linkedin'])) {
             $linkedin = esc_url_raw($_POST['linkedin']);
         }
         $twitter = '';
         if (isset($_POST['twitter'])) {
             $twitter = esc_url_raw($_POST['twitter']);
         }
         $facebook = '';
         if (isset($_POST['facebook'])) {
             $facebook = esc_url_raw($_POST['facebook']);
         }
         if (isset($_POST['fromname'])) {
             $fromname = sanitize_text_field($_POST['fromname']);
         }
         SendPress_Option::set('canspam', $canspam);
         SendPress_Option::set('linkedin', $linkedin);
         SendPress_Option::set('facebook', $facebook);
         SendPress_Option::set('twitter', $twitter);
     }
     // SendPress_Option::set('unsubscribetext', $unsubtext);
     SendPress_Admin::redirect('Settings_Styles');
 }
 function send_test_email()
 {
     $options = array();
     $options['testemail'] = $_POST['testemail'];
     SendPress_Option::set($options);
     SendPress_Manager::send_test();
     // SendPress_Admin::redirect('Settings_Account');
     // $this->send_test();
     // $this->redirect();
 }
 function save($post, $sp)
 {
     if (isset($post['allow_tracking'])) {
         SendPress_Option::set('allow_tracking', 'yes');
         SendPress_Option::set('feedback', 'yes');
     } else {
         SendPress_Option::set('allow_tracking', 'no');
         SendPress_Option::set('feedback', 'no');
     }
     if (isset($post['old_permalink'])) {
         SendPress_Option::set('old_permalink', true);
     } else {
         SendPress_Option::set('old_permalink', false);
     }
     if (isset($post['skip_mailto'])) {
         SendPress_Option::set('skip_mailto', true);
     } else {
         SendPress_Option::set('skip_mailto', false);
     }
     if (isset($post['enable_email_template_edit'])) {
         SendPress_Option::set('enable_email_template_edit', true);
     } else {
         SendPress_Option::set('enable_email_template_edit', false);
     }
     if (isset($post['prerelease_templates'])) {
         SendPress_Option::set('prerelease_templates', 'yes');
     } else {
         SendPress_Option::set('prerelease_templates', 'no');
     }
     SendPress_Option::set('queue-per-call', $post['queue-per-call']);
     SendPress_Option::set('sync-per-call', $post['sync-per-call']);
     SendPress_Option::set('autocron-per-call', $post['autocron-per-call']);
     SendPress_Option::set('wpcron-per-call', $post['wpcron-per-call']);
     SendPress_Option::set('queue-history', $post['queue-history']);
     if (isset($post['sp_widget_shortdoces'])) {
         SendPress_Option::set('sp_widget_shortdoces', $post['sp_widget_shortdoces']);
     }
     $widget_options = array();
     $widget_options['widget_options']['load_css'] = 0;
     $widget_options['widget_options']['load_ajax'] = 0;
     $widget_options['widget_options']['load_scripts_in_footer'] = 0;
     if (isset($_POST['load_css'])) {
         $widget_options['widget_options']['load_css'] = $_POST['load_css'];
     }
     if (isset($_POST['load_ajax'])) {
         $widget_options['widget_options']['load_ajax'] = $_POST['load_ajax'];
     }
     if (isset($_POST['load_scripts_in_footer'])) {
         $widget_options['widget_options']['load_scripts_in_footer'] = $_POST['load_scripts_in_footer'];
     }
     SendPress_Option::set($widget_options);
     SendPress_Admin::redirect('Settings_Advanced');
 }
 function save($post, $sp)
 {
     $icon_list = SendPress_Data::social_icons();
     $links = array();
     foreach ($icon_list as $key => $value) {
         if (isset($_POST["url-" . $key]) && $_POST["url-" . $key] != "") {
             $links[$key] = $_POST["url-" . $key];
         }
     }
     SendPress_Option::set('socialicons', $links);
     SendPress_Option::set('socialsize', $_POST['icon-view']);
     //SendPress_Admin::redirect('Settings_Advanced');
 }
 function module_deactivate_sendpress_pro()
 {
     $path = $_POST['plugin_path'];
     $pro_options = SendPress_Option::get('pro_plugins');
     if (!preg_match('/sendpress-pro.php/i', $path)) {
         if (preg_match('/sendpress-pro/i', $path)) {
             //make sure the plugin loads from sendpress pro
             $pro_options[$path] = false;
             SendPress_Option::set('pro_plugins', $pro_options);
         }
     } else {
         deactivate_plugins($path);
     }
 }
 function save()
 {
     SendPress_Option::set('send_optin_email', $_POST['optin']);
     SendPress_Option::set('optin_subject', $_POST['subject']);
     SendPress_Option::set('confirm-page', $_POST['confirm-page']);
     SendPress_Option::set('confirm-page-id', $_POST['confirm-page-id']);
     SendPress_Option::set('confirm-notification-template', $_POST['confirm-notification-template']);
     SendPress_Option::set('manage-page', $_POST['manage-page']);
     SendPress_Option::set('manage-page-id', $_POST['manage-page-id']);
     SendPress_Option::set('try-theme', $_POST['try-theme']);
     $optin = SendPress_Data::get_template_id_by_slug('double-optin');
     /*
     $dpost = get_post($optin);
     $dpost->post_content = $_POST['body'];
     $dpost->post_title = $_POST['subject'];
     */
     $my_post = array('ID' => $optin, 'post_content' => $_POST['body'], 'post_title' => $_POST['subject']);
     wp_update_post($my_post);
     update_post_meta($optin, '_sendpress_template', $_POST['confirm-notification-template']);
     SendPress_Admin::redirect('Settings_Activation');
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        $testListTable = new SendPress_Queue_Errors_Table();
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        $sp->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        ?>

	<h2><?php 
        _e('Error history for the last 2 Weeks', 'sendpress');
        ?>
.</h2>

	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_Errors');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
<?php 
    }
 /**
  * Enqueue styles and scripts needed for the pointers.
  */
 function enqueue()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     SendPress_Option::set('allow_tracking', '');
     $track = SendPress_Option::get('allow_tracking');
     $tour = false;
     //SendPress_Option::get( 'intro_tour' );
     if (($track == false || $track == '') && !isset($_GET['allow_tracking'])) {
         wp_enqueue_style('wp-pointer');
         wp_enqueue_script('jquery-ui');
         wp_enqueue_script('wp-pointer');
         wp_enqueue_script('utils');
         add_action('admin_print_footer_scripts', array($this, 'tracking_request'));
     } else {
         if ($tour == 'false' || $tour == false) {
             /*
             add_action( 'admin_print_footer_scripts', array( $this, 'intro_tour' ) );
             add_action( 'admin_head', array( $this, 'admin_head' ) );
             */
         }
     }
 }
 function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     $phpmailer = new SendPress_PHPMailer();
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $html = $this->change($html, 'UTF-8', $charset);
         $text = $this->change($text, 'UTF-8', $charset);
         $subject = $this->change($subject, 'UTF-8', $charset);
     }
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     //$subject = str_replace(array('’','“','�','–'),array("'",'"','"','-'),$subject);
     //$html = str_replace(chr(194),chr(32),$html);
     //$text = str_replace(chr(194),chr(32),$text);
     //return $email;
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $content_type = 'text/html';
     $phpmailer->MsgHTML($html);
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     $hosting = SendPress_Option::get('website-hosting-provider');
     if ($hosting == 'godaddy') {
         // We are sending SMTP mail
         $phpmailer->IsSMTP();
         // Set the other options
         $phpmailer->Host = 'relay-hosting.secureserver.net';
     }
     // If we don't have a charset from the input headers
     //if ( !isset( $charset ) )
     //$charset = get_bloginfo( 'charset' );
     // Set the content-type and charset
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     //$phpmailer->Sender = '*****@*****.**';//SendPress_Option::get('fromemail');
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     //$phpmailer->AddCustomHeader( sprintf( 'X-SP-MID: %s',$email->messageID ) );
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: website');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     $phpmailer->AddCustomHeader('X-SP-LIST: ' . $list_id);
     $phpmailer->AddCustomHeader('X-SP-REPORT: ' . $report_id);
     $phpmailer->AddCustomHeader('X-SP-SUBSCRIBER: ' . $sid);
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
         //$this->last_send_smtp_debug = $smtp_debug;
     }
     if ($result != true) {
         $log_message = 'Website <br>';
         $log_message .= $to . "<br>";
         if ($istest == true) {
             $log_message .= "<br><br>";
             $log_message .= $smtp_debug;
         }
         //$phpmailer->ErrorInfo
         SPNL()->log->add($phpmailer->ErrorInfo, $log_message, 0, 'sending');
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
         //$msg .= 'The full debugging output(exported mailer) is shown below:\n';
         //$msg .= var_export($phpmailer,true)."\n";
         //$this->append_log($msg);
     }
     return $result;
 }
    function html($sp)
    {
        ?>
  <?php 
        if (SendPress_Option::get('import_error', false) == true) {
            ?>
	<div class="alert alert-danger">
  <?php 
            _e('We had a problem saving your upload', 'sendpress');
            ?>
.
  </div>
  <?php 
        }
        ?>
  <div id="taskbar" class="lists-dashboard rounded group"> 
	<h2><?php 
        _e('Import CSV to ', 'sendpress');
        echo get_the_title($_GET['listID']);
        ?>
</h2>
	</div>
<div class="boxer">
	<div class="boxer-inner">
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form method="post" enctype="multipart/form-data" accept-charset="utf-8" >
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="listID" value="<?php 
        echo SPNL()->validate->int($_GET['listID']);
        ?>
" />
	   	<table>
	   	<tr>
    <td class="left_label"> <?php 
        echo $label;
        ?>
    </td>
    <td>
        <input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
        <input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Upload"  />
     
    </td>
  </tr> 
 	</table>
   
<?php 
        SendPress_Option::set('import_error', false);
        SendPress_Data::nonce_field();
        ?>
	   </form>
</div>
</div>
<?php 
    }
        $my_post['post_title'] = $_POST['post_title'];
        */
        $my_post['post_status'] = 'publish';
        // Update the post into the database
        wp_update_post($my_post);
        update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
        update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
        update_post_meta($my_post['ID'], '_sendpress_status', 'private');
        SendPress_Email::set_default_style($my_post['ID']);
        //clear the cached file.
        delete_transient('sendpress_email_html_' . $my_post['ID']);
        $this->save_redirect($_POST);
        break;
    case 'temaplte-widget-settings':
        $widget_options = array();
        $widget_options['widget_options']['load_css'] = 0;
        $widget_options['widget_options']['load_ajax'] = 0;
        $widget_options['widget_options']['load_scripts_in_footer'] = 0;
        if (isset($_POST['load_css'])) {
            $widget_options['widget_options']['load_css'] = $_POST['load_css'];
        }
        if (isset($_POST['load_ajax'])) {
            $widget_options['widget_options']['load_ajax'] = $_POST['load_ajax'];
        }
        if (isset($_POST['load_scripts_in_footer'])) {
            $widget_options['widget_options']['load_scripts_in_footer'] = $_POST['load_scripts_in_footer'];
        }
        SendPress_Option::set($widget_options);
        wp_redirect(esc_url_raw(admin_url('admin.php?page=sp-settings&view=widget')));
        break;
}
 static function create_default_form($type = 'signup')
 {
     //SendPress_Option::set('default-signup-widget-settings',null);
     $postid = SendPress_Option::get('default-' . $type . '-widget-settings');
     $hasPost = false;
     if (!empty($postid)) {
         $hasPost = true;
         $query = array();
         /*
         			$query =  get_posts(array(
         				'post_type'=>'sp_settings',
         				'post_status'=>'any',
         				'p'=>$postid
         			));
         */
         if (count($query) === 0) {
             $hasPost = false;
             $xposts = get_posts(array('post_type' => 'sp_settings', 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC'));
             foreach ($xposts as $pchecks) {
                 if ($pchecks->post_title == 'Default Signup Settings') {
                     $hasPost = true;
                     SendPress_Option::set('default-signup-widget-settings', $pchecks->ID);
                 }
                 //Default Signup Settings
             }
         }
     }
     if (!$hasPost) {
         switch ($type) {
             case 'signup':
                 $postid = SendPress_Data::create_settings_post("Default Signup Settings", SendPress_Data::signup_defaults());
                 SendPress_Option::set('default-' . $type . '-widget-settings', $postid);
                 break;
         }
     }
 }
 function save($data, $sp)
 {
     $saveid = $_POST['post_ID'];
     $bodybg = $_POST['body_bg'];
     $bodytext = $_POST['body_text'];
     $bodylink = $_POST['body_link'];
     $contentbg = $_POST['content_bg'];
     $contenttext = $_POST['content_text'];
     $contentlink = $_POST['sp_content_link_color'];
     $contentborder = $_POST['content_border'];
     $upload_image = $_POST['upload_image'];
     $headerbg = $_POST['header_bg'];
     $headertextcolor = $_POST['header_text_color'];
     $headertext = $_POST['header_text'];
     $headerlink = $_POST['header_link'];
     $imageheaderurl = $_POST['image_header_url'];
     $subheadertext = $_POST['sub_header_text'];
     $activeHeader = $_POST['active_header'];
     update_post_meta($saveid, 'upload_image', $upload_image);
     update_post_meta($saveid, 'body_bg', $bodybg);
     update_post_meta($saveid, 'body_text', $bodytext);
     update_post_meta($saveid, 'body_link', $bodylink);
     update_post_meta($saveid, 'content_bg', $contentbg);
     update_post_meta($saveid, 'content_text', $contenttext);
     update_post_meta($saveid, 'sp_content_link_color', $contentlink);
     update_post_meta($saveid, 'content_border', $contentborder);
     update_post_meta($saveid, 'header_bg', $headerbg);
     update_post_meta($saveid, 'header_text_color', $headertextcolor);
     update_post_meta($saveid, 'header_text', $headertext);
     update_post_meta($saveid, 'header_link', $headerlink);
     update_post_meta($saveid, 'image_header_url', $imageheaderurl);
     update_post_meta($saveid, 'sub_header_text', $subheadertext);
     update_post_meta($saveid, 'active_header', $activeHeader);
     $canspam = $_POST['can-spam'];
     $linkedin = '';
     if (isset($_POST['linkedin'])) {
         $linkedin = $_POST['linkedin'];
     }
     $twitter = '';
     if (isset($_POST['twitter'])) {
         $twitter = $_POST['twitter'];
     }
     $facebook = '';
     if (isset($_POST['facebook'])) {
         $facebook = $_POST['facebook'];
     }
     if (isset($_POST['fromname'])) {
         $fromname = $_POST['fromname'];
     }
     // From email and name
     // If we don't have a name from the input headers
     if (!isset($fromname) || $fromname == '') {
         $fromname = get_bloginfo('name');
     }
     if (isset($_POST['fromemail'])) {
         $fromemail = $_POST['fromemail'];
     }
     if (!isset($fromemail) || $fromemail == '') {
         // Get the site domain and get rid of www.
         $sitename = strtolower($_SERVER['SERVER_NAME']);
         if (substr($sitename, 0, 4) == 'www.') {
             $sitename = substr($sitename, 4);
         }
         $fromemail = 'wordpress@' . $sitename;
     }
     SendPress_Option::set('canspam', $canspam);
     SendPress_Option::set('linkedin', $linkedin);
     SendPress_Option::set('facebook', $facebook);
     SendPress_Option::set('twitter', $twitter);
     // SendPress_Option::set('unsubscribetext', $unsubtext);
     SendPress_Admin::redirect('Settings_Styles');
 }
Пример #16
0
 function update_options($array)
 {
     _deprecated_function(__FUNCTION__, '0.8.7', 'SendPress_Option::set()');
     return SendPress_Option::set($array);
 }
Пример #17
0
 public function jaiminho_define_redelivre_default_smtp()
 {
     SendPress_Option::set('sendmethod', 'Jaiminho_Sender_RedeLivre');
 }
 static function activate_key($key, $name)
 {
     $api_params = array('edd_action' => 'activate_license', 'license' => $key, 'item_name' => urlencode($name));
     // Call the custom API.
     $response = wp_remote_post(SENDPRESS_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false));
     // make sure the response came back okay
     if (is_wp_error($response)) {
         return true;
     }
     //return true, site might be down
     // decode the license data
     $license_data = json_decode(wp_remote_retrieve_body($response));
     if ($license_data) {
         if ($license_data->license !== 'invalid') {
             SendPress_Option::set('api_key', $key);
             SendPress_Option::set('api_product', $name);
             SendPress_Pro_Manager::set_pro_state(array('state' => $license_data->license, 'transient_time' => SENDPRESS_TRANSIENT_LENGTH));
             return true;
         }
         return false;
     }
     return false;
 }
 static function old_send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     global $phpmailer, $wpdb;
     // (Re)create it, if it's gone missing
     if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer();
     }
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     //return $email;
     //
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $sender = new SendPress_Sender();
         $html = $sender->change($html, 'UTF-8', $charset);
         $text = $sender->change($text, 'UTF-8', $charset);
         $subject = $sender->change($subject, 'UTF-8', $charset);
     }
     $subject = str_replace(array('’', '“', '�', '–'), array("'", '"', '"', '-'), $subject);
     $html = str_replace(chr(194), chr(32), $html);
     $text = str_replace(chr(194), chr(32), $text);
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $phpmailer->MsgHTML($html);
     $content_type = 'text/html';
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     $phpmailer->Sender = SendPress_Option::get('fromemail');
     $sending_method = SendPress_Option::get('sendmethod');
     $phpmailer = apply_filters('sendpress_sending_method_' . $sending_method, $phpmailer);
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: old');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
     }
     return $result;
 }
 function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     $phpmailer = new SendPress_PHPMailer();
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     // If we don't have a charset from the input headers
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     //return $email;
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $html = $this->change($html, 'UTF-8', $charset);
         $text = $this->change($text, 'UTF-8', $charset);
         $subject = $this->change($subject, 'UTF-8', $charset);
     }
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     //$phpmailer->Sender = '*****@*****.**';
     //$phpmailer->Sender = SendPress_Option::get('fromemail');
     $sending_method = SendPress_Option::get('sendmethod');
     //$subject = str_replace(array('’','“','�','–'),array("'",'"','"','-'),$subject);
     //$html = str_replace(chr(194),chr(32),$html);
     //$text = str_replace(chr(194),chr(32),$text);
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $phpmailer->MsgHTML($html);
     $content_type = 'text/html';
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     $rpath = SendPress_Option::get('bounce_email');
     if ($rpath != false) {
         $phpmailer->ReturnPath = $rpath;
         $phpmailer->AddReplyTo($rpath, SendPress_Option::get('fromname'));
     }
     $phpmailer->Mailer = 'smtp';
     // We are sending SMTP mail
     $phpmailer->IsSMTP();
     // Set the other options
     $phpmailer->Host = 'smtp.gmail.com';
     $phpmailer->SMTPAuth = true;
     // authentication enabled
     $phpmailer->SMTPSecure = 'tls';
     // secure transfer enabled REQUIRED for GMail
     $phpmailer->Port = 587;
     // If we're using smtp auth, set the username & password
     $phpmailer->SMTPAuth = TRUE;
     $phpmailer->Username = SendPress_Option::get('gmailuser');
     $phpmailer->Password = SendPress_Option::get('gmailpass');
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: Gmail');
     $phpmailer->AddCustomHeader('X-SP-LIST: ' . $list_id);
     $phpmailer->AddCustomHeader('X-SP-REPORT: ' . $report_id);
     $phpmailer->AddCustomHeader('X-SP-SUBSCRIBER: ' . $sid);
     $phpmailer->AddCustomHeader('List-Unsubscribe: <mailto:' . $from_email . '>');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
     }
     if ($result == true) {
         SendPress_Option::set('phpmailer_error', __('Nenhum erro encontrado', 'jaiminho'));
     }
     if ($result != true) {
         $log_message = 'Gmail <br>';
         $log_message .= $to . "<br>";
         if ($istest == true) {
             $log_message .= "<br><br>";
             $log_message .= $smtp_debug;
         }
         //$phpmailer->ErrorInfo
         SPNL()->log->add($phpmailer->ErrorInfo, $log_message, 0, 'sending');
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
     }
     return $result;
 }
 function autocron()
 {
     $enable = isset($_POST['enable']) ? $_POST['enable'] : false;
     if ($enable !== false) {
         SendPress_Option::set('autocron', 'yes');
         SendPress_Option::set('allow_tracking', 'yes');
         SendPress_Cron::use_iron_cron();
         $email = get_option('admin_email');
         $url = "http://api.sendpress.com/senddiscountcode/" . md5($_SERVER['SERVER_NAME'] . "|" . $email) . "/" . $email;
         wp_remote_get($url);
     } else {
         SendPress_Option::set('autocron', 'no');
     }
     SendPress::add_cron();
     exit;
 }
Пример #22
0
 static function plugin_install()
 {
     if (version_compare($GLOBALS['wp_version'], SENDPRESS_MINIMUM_WP_VERSION, '<')) {
         deactivate_plugins(__FILE__);
         wp_die(sprintf(__('SendPress requires WordPress version %s or later.', 'sendpress'), SENDPRESS_MINIMUM_WP_VERSION));
     } else {
         SendPress_DB_Tables::install();
         @SPNL()->db->subscribers_tracker->create_table();
         @SPNL()->db->subscribers_url->create_table();
         @SPNL()->db->url->create_table();
     }
     //Make sure we stop the old action from running
     wp_clear_scheduled_hook('sendpress_cron_action_run');
     flush_rewrite_rules();
     SendPress::add_cron();
     SendPress_Option::set('install_date', time());
 }
 function get_button($path, $from_pro = false)
 {
     _deprecated_function(__FUNCTION__, '0.9', 'SendPress_Module::buttons()');
     $button = array('class' => 'btn btn-default module-deactivate-plugin', 'href' => '#', 'target' => '', 'text' => __('Deactivate', 'sendpress'));
     if ($from_pro) {
         $pro_options = SendPress_Option::get('pro_plugins');
         $reg_plugin = substr($path, 14, strlen($path));
         if (file_exists(WP_PLUGIN_DIR . '/' . $reg_plugin) && is_plugin_active($reg_plugin)) {
             deactivate_plugins($reg_plugin);
             //deactivate seperate plugin
             $pro_options[$path] = true;
             //activate the pro version
             SendPress_Option::set($pro_options);
             $pro_options = SendPress_Option::get('pro_plugins');
         }
         if (!array_key_exists($path, $pro_options)) {
             !($pro_options[$path] = false);
         }
         if (!$pro_options[$path]) {
             $button['class'] = 'module-activate-plugin btn-success btn-activate btn';
             //$button['id'] = 'module-activate-plugin';
             $button['text'] = 'Activate';
         } else {
             $button['class'] = ' btn-default btn';
             $button['text'] = __('Deactivate', 'sendpress');
         }
     } else {
         if (!file_exists(WP_PLUGIN_DIR . '/' . $path)) {
             $button['class'] = 'module-deactivate-plugin btn-primary btn-buy btn';
             $button['href'] = 'http://sendpress.com';
             $button['target'] = '_blank';
             $button['text'] = 'Buy Now';
             //$button['id'] = '';
         } elseif (!is_plugin_active($path)) {
             $button['class'] = 'module-activate-plugin btn-success btn-activate btn';
             //$button['id'] = 'module-activate-plugin';
             $button['text'] = 'Activate';
         } else {
             $button['class'] = ' btn-default btn';
             $button['text'] = 'Deactivate';
         }
     }
     return $this->build_button($button);
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        if (isset($_GET['cron'])) {
            $sp->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        //$sp->fetch_mail_from_queue();
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        /*
        		$x = $sp->encrypt_data($open_info);
        
        	echo $x."<br>";
        	$x = $sp->decrypt_data($x);
        
        	print_r($x);
        		echo "<br>";
        
        	$d = $_GET['t'];
        	$x = $sp->decrypt_data($d);
        
        	print_r($x->id);
        		echo "<br>";
        	
        	
        	//echo wp_get_schedule('sendpress_cron_action_run');
        	//
        	$time_delay =  SendPress_Option::get('time-delay');
        	echo $time_delay;
        	echo date('l jS \of F Y H:i:s A',$time_delay );
        	echo "<br>";
        	$time = date('H:i:s');
        
        echo $time;//11:09
        	$time = date('H:i:s', $time_delay);
        
        echo $time;//11:09
        */
        $autocron = SendPress_Option::get('autocron', 'no');
        if ($autocron == 'yes') {
            $api_info = json_decode(SendPress_Cron::get_info());
            if (isset($api_info->active) && $api_info->active === 0) {
                echo "<p class='alert alert-danger'><strong>Oh no!</strong> It looks like AutoCron disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
                delete_transient('sendpress_autocron_cache');
                SendPress_Option::set('autocron', 'no');
            } else {
                if (isset($api_info->lastcheck)) {
                    echo "<p class='alert alert-success'><strong>Looking good!</strong> Autocron is running and last checked your site at:&nbsp;" . $api_info->lastcheck . " UTC</p>";
                }
            }
        } else {
            echo "<p class='alert alert-info'><strong>Howdy.</strong> It looks like AutoCron was not enabled or it disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
        }
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">
	<a class="btn btn-large btn-default " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
        echo $txt;
        ?>
</a>

	<a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
        _e('Send Emails Now', 'sendpress');
        ?>
</a>
	</div>
	</div>
	<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        //print_r(SendPress_Data::emails_stuck_in_queue());
        ?>

		
		<h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
		<h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.</small>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page($_GET['page']);
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
  	<div class="modal-content">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">×</button>
		<h3><?php 
        _e('Really? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', 'sendpress');
        ?>
.</p>
	</div>
	<div class="modal-footer">
	<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('No! I was Joking', 'sendpress');
        ?>
</a><a href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
	<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3><?php 
        _e('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
    function html()
    {
        SendPress_Tracking::event('Queue Tab');
        if (SPNL()->validate->_isset('cron')) {
            SPNL()->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        SPNL()->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        $autocron = SendPress_Option::get('autocron', 'no');
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">

       <?php 
        if (SendPress_Option::get('emails-credits') && SendPress_Option::get('sendmethod') === 'Jaiminho_Sender_NetWork' || SendPress_Option::get('sendmethod') != 'Jaiminho_Sender_NetWork') {
            SendPress_Option::set('pause-sending', 'no');
            ?>
          <a class="btn btn-large btn-default " href="<?php 
            echo SendPress_Admin::link('Queue');
            ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
            echo $txt;
            ?>
</a>
          <a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
            _e('Send Emails Now', 'sendpress');
            ?>
</a>
	</div>
	</div>
	<?php 
        } else {
            SendPress_Option::set('pause-sending', 'yes');
        }
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $credits = SendPress_Option::get('emails-credits');
        //print_r(SendPress_Data::emails_stuck_in_queue());
        global $wpdb;
        $table = SendPress_Data::queue_table();
        $date = getdate();
        // Maurilio TODO: fazer com os créditos sejam contados a partir da 00:00:00 do primeiro dia do mês atual
        $hour_ago = strtotime('-' . $date["mday"] . ' day');
        $time = date('Y-m-d H:i:s', $hour_ago);
        $query = $wpdb->prepare("SELECT COUNT(*) FROM {$table} where last_attempt > %s and success = %d", $time, 1);
        $credits_so_far = $wpdb->get_var($query);
        $result_credits = $credits - $credits_so_far;
        if ($credits <= 0) {
            echo "<p class='alert alert-danger' style='width:70%;'>" . __("Vixe! Você não tem créditos. Para enviar emails em sua fila ou enviar novos emails, você precisa obter mais créditos.", "jaiminho") . "</p>";
        } else {
            ?>
        <h2><?php 
            echo $credits ? __('Você tem', 'jaiminho') : "";
            ?>
        <strong><?php 
            echo $result_credits ? $result_credits : "";
            ?>
</strong> <?php 
            echo $credits ? __('créditos', 'jaiminho') : "";
            ?>
.
        </h2>
        <?php 
        }
        ?>
       
      <h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
      <h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
      <?php 
        if (is_multisite() && is_super_admin() || !is_multisite()) {
            ?>
      <small><?php 
            _e('You can adjust these settings here', 'sendpress');
            ?>
: <a href="<?php 
            echo SendPress_Admin::link('Settings_Account');
            ?>
"><?php 
            _e('Settings', 'sendpress');
            ?>
 > <?php 
            _e('Sending Account', 'sendpress');
            ?>
</a>.</small>
                 <?php 
        }
        ?>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page();
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
	<br>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page();
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
  	<div class="modal-content">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal">×</button>
		<h3><?php 
        _e('Really? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', 'sendpress');
        ?>
.</p>
	</div>
	<div class="modal-footer">
	<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('No! I was Joking', 'sendpress');
        ?>
</a><a href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
	<div class="modal-content">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
    <h3><?php 
        _e('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $emails_per_hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
 function tracking()
 {
     //$this->security_check();
     SendPress_Option::set('allow_tracking', SPNL()->validate->_string('allow_tracking'));
     SendPress_Admin::redirect('Overview');
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_All_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        ?>
<h2><?php 
        _e('Queue history for the last ', 'sendpress');
        ?>
 <strong><?php 
        echo SendPress_Option::get('queue-history', 7);
        ?>
</strong> <?php 
        _e('Days', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Advanced');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Advanced', 'sendpress');
        ?>
</a>.</small>
 		<br><br>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_All');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	       <?php 
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            ?>
	    <input type="hidden" name="listID" value="<?php 
            echo SPNL()->validate->int($_POST['listID']);
            ?>
" />
	    <?php 
        }
        ?>
	    <input type="hidden" name="view" value="<?php 
        echo esc_html($_GET['view']);
        ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page($_GET['page']);
        ?>
" name="page" />
		
		
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>

<?php 
    }
 function tracking($get, $sp)
 {
     SendPress_Option::set('allow_tracking', $get['allow_tracking']);
     SendPress_Admin::redirect('Overview');
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        if (isset($_GET['cron'])) {
            $sp->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_All_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        //$sp->fetch_mail_from_queue();
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        /*
        		$x = $sp->encrypt_data($open_info);
        
        	echo $x."<br>";
        	$x = $sp->decrypt_data($x);
        
        	print_r($x);
        		echo "<br>";
        
        	$d = $_GET['t'];
        	$x = $sp->decrypt_data($d);
        
        	print_r($x->id);
        		echo "<br>";
        	
        	
        	//echo wp_get_schedule('sendpress_cron_action_run');
        	//
        	$time_delay =  SendPress_Option::get('time-delay');
        	echo $time_delay;
        	echo date('l jS \of F Y H:i:s A',$time_delay );
        	echo "<br>";
        	$time = date('H:i:s');
        
        echo $time;//11:09
        	$time = date('H:i:s', $time_delay);
        
        echo $time;//11:09
        */
        ?>
<h2><?php 
        _e('Queue history for the last ', 'sendpress');
        ?>
 <strong><?php 
        echo SendPress_Option::get('queue-history', 7);
        ?>
</strong> <?php 
        _e('Days', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Advanced');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Advanced', 'sendpress');
        ?>
</a>.</small>
 		<br><br>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_All');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" /> 
	       <?php 
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            ?>
	    <input type="hidden" name="listID" value="<?php 
            echo $_GET['listID'];
            ?>
" />
	    <?php 
        }
        ?>
	    <input type="hidden" name="view" value="<?php 
        echo $_GET['view'];
        ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo $_GET['page'];
        ?>
" name="page" />
		
		
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>

<?php 
    }