コード例 #1
0
ファイル: uninstall.php プロジェクト: fwelections/fwelections
 function removeProcess()
 {
     if (is_admin()) {
         $filename = dirname(__FILE__) . DS . 'uninstall.sql';
         $handle = fopen($filename, 'r');
         $query = fread($handle, filesize($filename));
         fclose($handle);
         $modelObj =& WYSIJA::get('user', 'model');
         $queries = str_replace('DROP TABLE `', 'DROP TABLE `[wysija]', $query);
         $queries = explode('-- QUERY ---', $queries);
         $modelWysija = new WYSIJA_model();
         global $wpdb;
         foreach ($queries as $query) {
             $modelWysija->query($query);
         }
         delete_option('wysija');
         WYSIJA::update_option('wysija_reinstall', 1);
         global $wp_roles;
         foreach ($wp_roles->roles as $rolek => $roled) {
             if ($rolek == 'administrator') {
                 continue;
             }
             $role = get_role($rolek);
             $arr = array('wysija_newsletters', 'wysija_subscribers', 'wysija_subscriwidget', 'wysija_config');
             foreach ($arr as $arrkey) {
                 $role->remove_cap($arrkey);
             }
         }
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: config.php プロジェクト: rotoballer/emily
 function fieldFormHTML_dkim($key, $value, $model, $paramsex)
 {
     $field = '';
     $keypublickey = $key . '_pubk';
     if (!$this->model->getValue($keypublickey)) {
         //refresh the public key private key generation
         $helpersLi =& WYSIJA::get('licence', 'helper');
         $helpersLi->dkim_config();
     } else {
         WYSIJA::update_option('dkim_autosetup', false);
         $formsHelp =& WYSIJA::get("forms", "helper");
         $realkey = $key . '_active';
         $checked = false;
         if ($this->model->getValue($realkey)) {
             $checked = true;
         }
         $field .= '<p>';
         $field .= $formsHelp->checkbox(array('id' => $realkey, 'name' => 'wysija[' . $model . '][' . $realkey . ']', 'style' => 'margin-left:0px;', 'class' => 'activateInput'), 1, $checked);
         $field .= '</p>';
         $field .= '<div id="' . $realkey . '_linkname" >';
         //$titlelink=str_replace(array('[link]','[\link]'), array('<a href="">','</a>'),'');
         $titlelink = __('Configure your DNS by adding a key/value record in TXT as shown below.', WYSIJA) . ' <a href="http://support.wysija.com/knowledgebase/guide-to-dkim-in-wysija/?utm_source=wpadmin&utm_campaign=settings" target="_blank">' . __('Read more', WYSIJA) . '</a>';
         $field .= '<fieldset style=" border: 1px solid #ccc;margin: 0;padding: 10px;"><legend>' . $titlelink . '</legend>';
         $field .= '<label id="drlab" for="domainrecord">' . __('Key', WYSIJA) . ' <input readonly="readonly" id="domainrecord" style="margin-right:10px;" type="text" value="wys._domainkey"/></label><label id="drpub" for="dkimpub">' . __('Value', WYSIJA) . ' <input readonly="readonly" id="dkimpub" type="text" size="70" value="v=DKIM1;k=rsa;g=*;s=email;h=sha1;t=s;p=' . $this->model->getValue($keypublickey) . '"/>';
         $field .= '</fieldset>';
         $realkey = $key . '_domain';
         $field .= '<p><label class="dkim" for="' . $realkey . '">' . __('Domain', WYSIJA) . '</label>';
         $field .= $formsHelp->input(array('id' => $realkey, 'name' => 'wysija[' . $model . '][' . $realkey . ']'), $this->model->getValue($realkey));
         $field .= '</p>';
         $field .= '</div>';
     }
     return $field;
 }
コード例 #3
0
ファイル: BACK.PHP プロジェクト: pauEscarcia/AIMM
    function WYSIJA_control_back(){
        parent::WYSIJA_control();
        global $wysija_msg,$wysija_queries,$wysija_queries_errors;
        $wysija_msgTemp=get_option('wysija_msg');
        if(is_array($wysija_msgTemp) && count($wysija_msgTemp)>0){
            $wysija_msg=$wysija_msgTemp;
        }

        $wysija_qryTemp=get_option('wysija_queries');
        $wysija_qryErrors=get_option('wysija_queries_errors');
        if(is_array($wysija_qryTemp) && count($wysija_qryTemp)>0){
            $wysija_queries=$wysija_qryTemp;
        }

        if(is_array($wysija_qryErrors) && count($wysija_qryErrors)>0){
            $wysija_queries_errors=$wysija_qryErrors;
        }

        WYSIJA::update_option('wysija_queries','');
        WYSIJA::update_option('wysija_queries_errors','');
        WYSIJA::update_option('wysija_msg','');
        global $wysija_installing;
        if($wysija_installing===true) return;
        $this->pref=get_user_meta(WYSIJA::wp_get_userdata('ID'),'wysija_pref',true);

        $prefupdate=false;
        if($this->pref) {
            $prefupdate=true;
            $this->pref=unserialize(base64_decode($this->pref));
        }else{
            $this->pref=array();
        }

        if(!isset($_GET['action'])) $action='default';
        else $action=$_GET['action'];

        if(isset($_REQUEST['limit_pp'])){
            $this->pref[$_REQUEST['page']][$action]['limit_pp']=$_REQUEST['limit_pp'];
        }

        if($this->pref && isset($_REQUEST['page']) && $_REQUEST['page'] && isset($this->pref[$_REQUEST['page']][$action]['limit_pp'])){
            $this->viewObj->limit_pp=$this->pref[$_REQUEST['page']][$action]['limit_pp'];
            $this->modelObj->limit_pp=$this->pref[$_REQUEST['page']][$action]['limit_pp'];
        }

        if($prefupdate){
            update_user_meta(WYSIJA::wp_get_userdata('ID'),'wysija_pref',base64_encode(serialize($this->pref)));
        }else{
            add_user_meta(WYSIJA::wp_get_userdata('ID'),'wysija_pref',base64_encode(serialize($this->pref)));
        }
        add_action('wysija_various_check',array($this,'variousCheck'));
        do_action('wysija_various_check');

        // check if the plugin has an update available
        $updateH=WYSIJA::get('update','helper');
        $updateH->checkForNewVersion();
        $this->target_action_form = $this->data['target_action_form'] = $this->_getTargetActionForm(); // set default value of any form action
    }
コード例 #4
0
ファイル: back.php プロジェクト: fwelections/fwelections
 function WYSIJA_control_back()
 {
     parent::WYSIJA_control();
     global $wysija_msg, $wysija_queries, $wysija_queries_errors;
     $wysija_msgTemp = get_option("wysija_msg");
     if (is_array($wysija_msgTemp) && count($wysija_msgTemp) > 0) {
         $wysija_msg = $wysija_msgTemp;
     }
     $modelEmail =& WYSIJA::get('email', 'model');
     $campaign = $modelEmail->getOne('params', array('email_id' => 12));
     $wysija_qryTemp = get_option("wysija_queries");
     $wysija_qryErrors = get_option("wysija_queries_errors");
     if (is_array($wysija_qryTemp) && count($wysija_qryTemp) > 0) {
         $wysija_queries = $wysija_qryTemp;
     }
     if (is_array($wysija_qryErrors) && count($wysija_qryErrors) > 0) {
         $wysija_queries_errors = $wysija_qryErrors;
     }
     WYSIJA::update_option("wysija_queries", "");
     WYSIJA::update_option("wysija_queries_errors", "");
     WYSIJA::update_option("wysija_msg", "");
     $this->pref = get_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', true);
     $prefupdate = false;
     if ($this->pref) {
         $prefupdate = true;
         $this->pref = unserialize(base64_decode($this->pref));
     } else {
         $this->pref = array();
     }
     if (!isset($_GET['action'])) {
         $action = "default";
     } else {
         $action = $_GET['action'];
     }
     if (isset($_REQUEST['limit_pp'])) {
         $this->pref[$_REQUEST['page']][$action]['limit_pp'] = $_REQUEST['limit_pp'];
     }
     if ($this->pref && isset($_REQUEST['page']) && $_REQUEST['page'] && isset($this->pref[$_REQUEST['page']][$action]['limit_pp'])) {
         $this->viewObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
         $this->modelObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
     }
     if ($prefupdate) {
         update_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     } else {
         add_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     }
     add_action('wysija_various_check', array($this, 'variousCheck'));
     do_action('wysija_various_check');
     /*check if the plugin has an update available */
     $updateH =& WYSIJA::get('update', 'helper');
     $updateH->checkForNewVersion();
 }
コード例 #5
0
ファイル: config.php プロジェクト: fwelections/fwelections
 function form_save()
 {
     /*add modify an element in the wysija_forms option*/
     $arrayData = json_decode(stripslashes($_POST['data']), true);
     $wysija_forms = json_decode(get_option('wysija_forms'), true);
     if (isset($wysija_forms[$_POST['formid']])) {
         unset($wysija_forms[$_POST['formid']]);
     }
     $wysija_forms[$arrayData['id']] = $arrayData;
     WYSIJA::update_option('wysija_forms', json_encode($wysija_forms));
     $this->notice('Form added/modified');
     return json_decode(stripslashes($_POST['data']), true);
 }
コード例 #6
0
ファイル: config.php プロジェクト: rotoballer/emily
 function dkimcheck()
 {
     if (isset($_REQUEST['xtz'])) {
         $dataconf = json_decode(base64_decode($_REQUEST['xtz']));
         if (isset($dataconf->dkim_pubk) && isset($dataconf->dkim_privk)) {
             $modelConf =& WYSIJA::get('config', 'model');
             $dataconfsave = array('dkim_pubk' => $dataconf->dkim_pubk->key, 'dkim_privk' => $dataconf->dkim_privk);
             $modelConf->save($dataconfsave);
             WYSIJA::update_option('dkim_autosetup', false);
         }
     }
     $this->redirect('admin.php?page=wysija_config');
     return true;
 }
コード例 #7
0
ファイル: campaigns.php プロジェクト: rotoballer/emily
 function licok()
 {
     parent::WYSIJA_control_back();
     $dt = get_option("wysijey");
     if (isset($_REQUEST['xtz']) && $dt == $_REQUEST['xtz']) {
         $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
         $this->notice(__("Premium version is valid for your site.", WYSIJA));
     } else {
         $dataconf = array('premium_key' => "", 'premium_val' => "");
         //$datadomain=unserialize(base64_decode($dt));
         $this->error(str_replace(array("[link]", "[/link]"), array('<a href="http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=orders&action=checkout&wysijadomain=' . $dt . '" target="_blank">', '</a>'), __("Premium licence does not exist for your site. Purchase it [link]here[/link].", WYSIJA)), 1);
     }
     WYSIJA::update_option("wysicheck", false);
     $modelConf =& WYSIJA::get("config", "model");
     $modelConf->save($dataconf);
     $this->redirect('admin.php?page=wysija_config#tab-premium');
 }
コード例 #8
0
ファイル: install.php プロジェクト: sontv1003/fashionbeans
 function install()
 {
     $values = array();
     if (!$this->testSystem()) {
         return false;
     }
     if (!$this->createTables()) {
         return false;
     }
     $this->moveData('themes');
     $this->moveData('dividers');
     $this->moveData('bookmarks');
     $this->recordDefaultUserField();
     $this->defaultSettings($values);
     $this->defaultList($values);
     $this->defaultCampaign($values);
     $helper_import =& WYSIJA::get('import', 'helper');
     $values['importwp_list_id'] = $helper_import->importWP();
     $this->createPage($values);
     $this->createWYSIJAdir($values);
     $this->create_default_subscription_form();
     $model_config =& WYSIJA::get('config', 'model');
     $model_config->add_translated_default();
     $model_email =& WYSIJA::get('email', 'model');
     $model_email->blockMe = true;
     $values['confirm_email_id'] = $model_email->insert(array('type' => '0', 'from_email' => $values['from_email'], 'from_name' => $values['from_name'], 'replyto_email' => $values['from_email'], 'replyto_name' => $values['from_name'], 'subject' => $model_config->getValue('confirm_email_title'), 'body' => $model_config->getValue('confirm_email_body'), 'status' => 99));
     $values['installed'] = true;
     $values['manage_subscriptions'] = true;
     $values['installed_time'] = time();
     $values['wysija_db_version'] = WYSIJA::get_version();
     $wptoolboxs =& WYSIJA::get('toolbox', 'helper');
     $values['dkim_domain'] = $wptoolboxs->_make_domain_name();
     if (get_option('wysija_reinstall', 0)) {
         $values['wysija_whats_new'] = WYSIJA::get_version();
     }
     $model_config->save($values);
     $this->testNLplugins();
     $helper_wp_tools =& WYSIJA::get('wp_tools', 'helper');
     $helper_wp_tools->set_default_rolecaps();
     global $wysija_installing;
     $wysija_installing = false;
     WYSIJA::update_option('wysija_reinstall', 0);
     return true;
 }
コード例 #9
0
 function removeProcess()
 {
     // Remove the wysija folder in uploads.
     $helper_file = WYSIJA::get('file', 'helper');
     $upload_dir = $helper_file->getUploadDir();
     $is_writable = is_writable($upload_dir);
     if ($is_writable) {
         $helper_file->rrmdir($upload_dir);
     } elseif ($upload_dir != false) {
         return false;
     }
     $file_name = WYSIJA_DIR . 'sql' . DS . 'uninstall.sql';
     $handle = fopen($file_name, 'r');
     $query = fread($handle, filesize($file_name));
     fclose($handle);
     $queries = str_replace('DROP TABLE `', 'DROP TABLE `[wysija]', $query);
     $queries = explode('-- QUERY ---', $queries);
     $modelWysija = new WYSIJA_model();
     global $wpdb;
     foreach ($queries as $query) {
         $modelWysija->query($query);
     }
     //wysija_last_php_cron_call
     foreach ($this->options_delete as $option_key) {
         delete_option($option_key);
     }
     WYSIJA::update_option('wysija_reinstall', 1);
     global $wp_roles;
     foreach ($wp_roles->roles as $rolek => $roled) {
         if ($rolek == 'administrator') {
             continue;
         }
         $role = get_role($rolek);
         //remove wysija's cap
         $arr = array('wysija_newsletters', 'wysija_subscribers', 'wysija_config');
         foreach ($arr as $arrkey) {
             $role->remove_cap($arrkey);
         }
     }
     return true;
 }
コード例 #10
0
ファイル: base.php プロジェクト: namwoody/curry
 /**
  * check that there is no passed schedules that need to be executed now
  * @return void
  */
 public static function cron_check()
 {
     $cron_schedules = WYSIJA::get_cron_schedule('all');
     if (empty($cron_schedules)) {
         return;
     } else {
         $processes = WYSIJA::get_cron_frequencies();
         $updated_sched = false;
         foreach ($cron_schedules as $schedule => &$params) {
             $running = 0;
             $time_now = time();
             if (isset($params['running'])) {
                 $running = $params['running'];
             }
             //if the process has timedout we reschedule the next execution
             if ($running && $time_now > $running + $processes[$schedule]) {
                 //WYSIJA::setInfo('error','modifying next schedule for '.$proc);
                 $process_frequency = $processes[$schedule];
                 $next_schedule = $running + $process_frequency;
                 // if the next schedule is already behind, we give it 30 seconds before it can trigger again
                 if ($next_schedule < $time_now) {
                     $next_schedule = $time_now + 30;
                 }
                 $params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
                 $updated_sched = true;
             }
         }
         if ($updated_sched) {
             //WYSIJA::setInfo('error','updating scheds');
             WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
         }
     }
     $time_now = time();
     $processesToRun = array();
     foreach ($cron_schedules as $schedule => $scheduled_times) {
         $process_frequency = $processes[$schedule];
         if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + $process_frequency < $time_now) && $scheduled_times['next_schedule'] < $time_now) {
             $processesToRun[] = $schedule;
         }
     }
     $model_config = WYSIJA::get('config', 'model');
     $page_view_trigger = (int) $model_config->getValue('cron_page_hit_trigger');
     if (!empty($processesToRun) && $page_view_trigger === 1) {
         //call the cron url
         $cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
         $cron_request = apply_filters('cron_request', array('url' => $cron_url, 'args' => array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))));
         wp_remote_post($cron_url, $cron_request['args']);
     }
 }
コード例 #11
0
 /**
  * this save a default list of column matching to ease the import process, this is done only the first time when the
  * field is not populated yet
  */
 private function _save_default_import_field_match()
 {
     $import_fields = get_option('wysija_import_fields');
     if (!$import_fields) {
         $import_fields = array('fname' => 'firstname', 'firstname' => 'firstname', 'prenom' => 'firstname', 'nom' => 'lastname', 'name' => 'lastname', 'lastname' => 'lastname', 'lname' => 'lastname', 'ipaddress' => 'ip', 'ip' => 'ip', 'addresseip' => 'ip');
         WYSIJA::update_option('wysija_import_fields', $import_fields);
     }
 }
コード例 #12
0
ファイル: licence.php プロジェクト: fwelections/fwelections
 function dkim_config()
 {
     $helperToolbox =& WYSIJA::get("toolbox", "helper");
     $dkim_domain = $helperToolbox->_make_domain_name(admin_url('admin.php'));
     $res1 = $errorssl = false;
     if (function_exists('openssl_pkey_new')) {
         while ($err = openssl_error_string()) {
         }
         $res1 = openssl_pkey_new(array('private_key_bits' => 512));
         $errorssl = openssl_error_string();
     }
     if (function_exists('openssl_pkey_new') && $res1 && !$errorssl && function_exists('openssl_pkey_get_details')) {
         $rsaKey = array('private' => '', 'public' => '', 'error' => '');
         $res = openssl_pkey_new(array('private_key_bits' => 512));
         if ($res && !openssl_error_string()) {
             $privkey = '';
             openssl_pkey_export($res, $privkey);
             $pubkey = openssl_pkey_get_details($res);
             $dataconf = array('dkim_domain' => $dkim_domain, 'dkim_privk' => $privkey, 'dkim_pubk' => $pubkey['key']);
             $modelConf =& WYSIJA::get('config', 'model');
             $modelConf->save($dataconf);
         }
     } else {
         //fetch them through a request to wysija.com
         $data = $this->getDomainInfo();
         $httpHelp =& WYSIJA::get("http", "helper");
         $jsonResult = $httpHelp->request('http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDkim&data=' . $data);
         if ($jsonResult) {
             $decoded = json_decode($jsonResult);
             $dataconf = array('dkim_domain' => $dkim_domain, 'dkim_privk' => $decoded->dkim_privk, 'dkim_pubk' => $decoded->dkim_pubk->key);
             $modelConf =& WYSIJA::get('config', 'model');
             $modelConf->save($dataconf);
             WYSIJA::update_option('dkim_autosetup', false);
         } else {
             WYSIJA::update_option('dkim_autosetup', true);
         }
     }
 }
コード例 #13
0
 function import_save()
 {
     @ini_set('max_execution_time', 0);
     $this->requireSecurity();
     $this->_resetGlobMsg();
     //to avoid timeout when importing a lot of data apparently.
     global $wpdb;
     $wpdb->query('set session wait_timeout=600');
     //import the contacts
     //1-check that a list is selected and that there is a csv file pasted
     //2-save the list if necessary
     //3-save the contacts and record them for each list selected
     //we need to save a new list in that situation
     if (isset($_REQUEST['wysija']['list'])) {
         $model =& WYSIJA::get('list', 'model');
         $data = array();
         $data['is_enabled'] = 1;
         $data['name'] = $_REQUEST['wysija']['list']['newlistname'];
         $_REQUEST['wysija']['user_list']['list'][] = $model->insert($data);
     }
     if (!isset($_REQUEST['wysija']['user_list']['list']) || !$_REQUEST['wysija']['user_list']['list']) {
         $this->error(__('You need to select at least one list.', WYSIJA), true);
         return $this->importmatch();
     }
     //is it a new list or not
     //try to make a wysija dir
     $csvData = unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
     $csvfilename = $csvData['csv'];
     $fileHelp =& WYSIJA::get('file', 'helper');
     $resultFile = $fileHelp->get($csvfilename, 'import');
     if (!$resultFile) {
         $upload_dir = wp_upload_dir();
         $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"', WYSIJA), $upload_dir['basedir']), true);
         return $this->import();
     }
     //get the temp csv file
     $csvdata = file_get_contents($resultFile);
     $csvArr = $this->_csvToArray($csvdata, 0, $csvData['fsep'], $csvData['fenc']);
     $datatoinsert = array();
     $emailKey = '';
     foreach ($_POST['wysija']['match'] as $key => $val) {
         if ($val != 'nomatch') {
             $datatoinsert[$key] = trim($val);
         }
         if ($val == 'email') {
             $emailKey = $key;
         }
     }
     //dbg($datatoinsert);
     if (!in_array('status', $datatoinsert)) {
         $datatoinsert['status'] = 'status';
     }
     $queryStart = 'INSERT IGNORE INTO [wysija]user (`' . implode('` ,`', $datatoinsert) . '`,`created_at`) VALUES ';
     //$linescount=count($csvArr);
     //detect the emails that are duplicate in the import file
     $emailsCount = array();
     $header_row = $csvArr[0];
     //we process the sql insertion 200 by 200 so that we are safe with the server
     $csvChunks = array_chunk($csvArr, 200);
     $csvArr = null;
     $j = 0;
     $linescount = 0;
     $dataNumbers = array('invalid' => array(), 'inserted' => 0, 'outof' => 0, 'list_added' => 0, 'list_user_ids' => 0, 'list_list_ids' => count($_REQUEST['wysija']['user_list']['list']), 'emails_queued' => 0);
     $ignored_row_count = 0;
     foreach ($csvChunks as $keyChunk => $arra) {
         foreach ($arra as $keyline => $emailline) {
             if (isset($emailline[$emailKey])) {
                 if (isset($emailsCount[$emailline[$emailKey]])) {
                     $emailsCount[$emailline[$emailKey]]++;
                     //$arra[$keyline]
                 } else {
                     $emailsCount[$emailline[$emailKey]] = 1;
                 }
             } else {
                 //if the record doesn't have the attribute email then we just ignore it
                 $ignored_row_count++;
                 unset($arra[$keyline]);
             }
         }
         $result = $this->_importRows($queryStart, $arra, $j, $datatoinsert, $emailKey, $dataNumbers);
         if ($result !== false) {
             $j++;
         } else {
             $try = 0;
             while ($result === false && $try < 3) {
                 $result = $this->_importRows($queryStart, $arra, $j, $datatoinsert, $emailKey, $dataNumbers);
                 $try++;
             }
             if ($result) {
                 $j++;
             } else {
                 $this->error(__('There seems to be an error with the list you\'re trying to import.', WYSIJA), true);
                 $this->redirect('admin.php?page=wysija_subscribers&action=import');
                 return false;
             }
         }
         $linescount = $linescount + $result;
     }
     if (!isset($_POST['firstrowisdata'])) {
         //save the importing fields to be able to match them the next time
         $importfields = get_option('wysija_import_fields');
         foreach ($_POST['wysija']['match'] as $key => $val) {
             if ($val != 'nomatch') {
                 $importfields[$header_row[$key]] = $val;
             }
         }
         WYSIJA::update_option('wysija_import_fields', $importfields);
     }
     //get a list of list name
     $model =& WYSIJA::get('list', 'model');
     $results = $model->get(array('name'), array('list_id' => $_REQUEST['wysija']['user_list']['list']));
     $listnames = array();
     foreach ($results as $k => $v) {
         $listnames[] = $v['name'];
     }
     $helperU =& WYSIJA::get('user', 'helper');
     $helperU->refreshUsers();
     foreach ($emailsCount as $emailkeycount => $countemailfile) {
         if ($countemailfile == 1) {
             unset($emailsCount[$emailkeycount]);
         }
     }
     if ($linescount < 0) {
         $linescount = 0;
     }
     $dataNumbers['ignored'] = $dataNumbers['outof'] - $dataNumbers['inserted'];
     $dataNumbers['ignored_list'] = $dataNumbers['list_user_ids'] * $dataNumbers['list_list_ids'] - $dataNumbers['list_added'];
     // $this->notice(sprintf(__('%1$s subscribers have been added to database. (%2$s were ignored)',WYSIJA),$dataNumbers['inserted'],$dataNumbers['ignored']));
     $ignored_row_count;
     //this contain some ignored row because the email attribute was not detected. I say there should be a message for those
     $this->notice(sprintf(__('%1$s subscribers added to %2$s.', WYSIJA), $dataNumbers['list_user_ids'], '"' . implode('", "', $listnames) . '"'));
     if (count($emailsCount) > 0) {
         $listemails = '';
         $m = 0;
         foreach ($emailsCount as $emailkeyalready => $occurences) {
             if ($m > 0) {
                 $listemails .= ', ';
             }
             $listemails .= $emailkeyalready . ' (' . $occurences . ')';
             $m++;
         }
         //$emailsalreadyinserted=array_keys($emailsCount);
         $this->notice(sprintf(__('%1$s emails appear more than once in your file : %2$s.', WYSIJA), count($emailsCount), $listemails), 0);
     }
     if (count($dataNumbers['invalid']) > 0) {
         $this->notice(sprintf(__('%1$s emails are not valid : %2$s.', WYSIJA), count($dataNumbers['invalid']), implode(', ', $dataNumbers['invalid'])), 0);
     }
     $this->redirect();
 }
コード例 #14
0
ファイル: config.php プロジェクト: duboisGeof/deliciousMeals
 function wysija_dismiss_license_notice()
 {
     WYSIJA::update_option('wysija_dismiss_license_notice', true);
 }
コード例 #15
0
ファイル: LICENCE.PHP プロジェクト: pauEscarcia/AIMM
    function dkim_config(){


        //checkif the open ssl function for priv and ub key are present on that server
        $hToolbox = WYSIJA::get('toolbox','helper');
        $dkim_domain = $hToolbox->_make_domain_name(admin_url('admin.php'));
        $res1=$errorssl=false;
        if(function_exists('openssl_pkey_new')){
            while ($err = openssl_error_string());
            $res1=openssl_pkey_new(array('private_key_bits' => 1024));
            $errorssl=openssl_error_string();
        }

        if(function_exists('openssl_pkey_new') && $res1 && !$errorssl  && function_exists('openssl_pkey_get_details')){

            $rsaKey = array('private' => '', 'public' => '', 'error' => '');
            $res = openssl_pkey_new(array('private_key_bits' => 1024));

            if($res && !openssl_error_string()){
                // Get private key
                $privkey = '';
                openssl_pkey_export($res, $privkey);

                // Get public key
                $pubkey = openssl_pkey_get_details($res);


                $configData=array('dkim_domain'=>$dkim_domain,'dkim_privk'=>$privkey,'dkim_pubk'=>$pubkey['key'],'dkim_1024'=>1);

                $mConfig = WYSIJA::get('config','model');
                $mConfig->save($configData);
            }

        }else{//fetch them through a request to mailpoet.com
            $domainData=$this->getDomainInfo();
            $hHTTP = WYSIJA::get('http','helper');

            $jsonResult = $hHTTP->wp_request('http://www.mailpoet.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDkimNew&data='.$domainData);

            //remotely connect to host
            if($jsonResult!==false){
                $decoded=json_decode($jsonResult);

                $configData=array('dkim_domain'=>$dkim_domain,'dkim_privk'=>$decoded->dkim_privk,'dkim_pubk'=>$decoded->dkim_pubk->key,'dkim_1024'=>1);

                $mConfig = WYSIJA::get('config','model');
                $mConfig->save($configData);
                WYSIJA::update_option('dkim_autosetup',false);

            }else{
                 WYSIJA::update_option('dkim_autosetup',true);
            }

        }

    }
コード例 #16
0
ファイル: config.php プロジェクト: fwelections/fwelections
    function subforms()
    {
        $mUserField =& WYSIJA::get('user_field', 'model');
        $mUserField->orderBy('field_id');
        $customFields = $mUserField->getRows(false);
        ?>
        <a id="wj-create-new-form" class="button-secondary"><?php 
        echo __('New form', WYSIJA);
        ?>
</a>
        <?php 
        $wysija_forms = json_decode(get_option('wysija_forms'), true);
        if (empty($wysija_forms)) {
            $wysija_forms = array();
            $defaultForm = array('id' => 'default-form', 'name' => __('Default form', WYSIJA), 'blocks' => array(0 => array('fields' => array(0 => array('type' => 'email', 'params' => array('label' => __('Email', WYSIJA))))), 1 => array('fields' => array(0 => array('type' => 'submit', 'params' => array('label' => __('Subscribe!', WYSIJA)))))));
            $wysija_forms['default-form'] = $defaultForm;
            WYSIJA::update_option('wysija_forms', json_encode($wysija_forms));
        }
        ?>
        <script type="text/javascript">var wysijaForms=<?php 
        echo json_encode($wysija_forms);
        ?>
;</script>
            <select id="list-forms" name="wysija[profiles][forms]">
                <option value=""><?php 
        echo __('Edit a form...', WYSIJA);
        ?>
</option>
                <?php 
        foreach ($wysija_forms as $wj_form) {
            echo '<option value="' . $wj_form['id'] . '">' . $wj_form['name'] . '</option>';
        }
        ?>
            </select>

        <hr/>
        <div id="wj-forms-editor" class="clearfix">
            <div id="wj-form-edit-drag">
                <div id="wj-form-name">Edit <span id="wj-edit-form-name">
                        <span id="wj-form-name-label"></span>
                        <input type="text" id="wj-form-name-value" name="wysija[profiles][form][name]" value=""/>
                        <input type="hidden" id="wj-form-id-value" name="wysija[profiles][form][id]" value=""/>
                    </span>
                </div>
                <div id="wj-currentform"></div>
                <div id="general-part">
                    <div class="list-selection"><p><?php 
        _e('Add subscribers to these lists:', WYSIJA);
        ?>
</p><?php 
        $fieldHTML = '';
        $modelList =& WYSIJA::get('list', 'model');
        $lists = $modelList->get(array('name', 'list_id'), array('is_enabled' => 1));
        foreach ($lists as $list) {
            $checked = false;
            //if(in_array($list['list_id'], $valuefield)) $checked=true;
            $formObj =& WYSIJA::get('forms', 'helper');
            $fieldHTML .= '<p class="labelcheck listcheck"><label for="listid-' . $list['list_id'] . '">' . $formObj->checkbox(array('id' => 'listid-' . $list['list_id'], 'name' => 'wysija[profiles][form][lists][]', 'class' => ''), $list['list_id'], $checked) . $list['name'] . '</label></p>';
            $fieldHTML .= '<input type="hidden" name="wysija[profiles][form][list_name][' . $list['list_id'] . ']' . '" value="' . $list['name'] . '" />';
        }
        echo $fieldHTML;
        ?>
</div>
                    <p class="submit">
                    <a href="javascript:;" id="forms-save" class="button-primary wysija" ><?php 
        echo esc_attr(__('Save', WYSIJA));
        ?>
</a>
                    <a href="javascript:;" id="form-delete"><?php 
        echo esc_attr(__('Delete', WYSIJA));
        ?>
</a>
                    </p>
                </div>
            </div>
            <div id="wysija_toolbar">
                <ul class="wysija_toolbar_tabs">
                    <li class="wjt-content">
                        <a class="selected" href="javascript:;" rel="#wj_content"><?php 
        _e('Content', WYSIJA);
        ?>
</a>
                    </li>
                </ul>

                <!-- CONTENT BAR -->
                <ul id="wj_content" class="wj-tab-inner" >
                    <?php 
        foreach ($customFields as $cfield) {
            echo '<li class="wj_element"><a class="wysija_item" id="' . $cfield['column_name'] . '" wysija_type="text">' . $cfield['name'] . '</a></li>';
        }
        $extraTypes = array('list-selection' => array('label' => __('List selection', WYSIJA), 'type' => 'lists'), 'text-instructions' => array('label' => __('Random text or instructions', WYSIJA), 'type' => 'instructions'), 'divider' => array('label' => __('Divider', WYSIJA), 'type' => 'divider'));
        foreach ($extraTypes as $key => $data) {
            echo '<li class="wj_element"><a class="wysija_item" id="' . $key . '" wysija_type="' . $data['label'] . '">' . $data['label'] . '</a></li>';
        }
        add_filter('wysija_premium_fields_soon', array($this, 'premiumSoonFields'), 1);
        echo apply_filters('wysija_premium_fields_soon', '');
        ?>
                </ul>

                <div id="wysija_notices" style="display:none;"><span id="wysija_notice_msg"></span><img alt="loader" style="display:none;" id="ajax-loading" src="<?php 
        echo WYSIJA_URL;
        ?>
img/wpspin_light.gif" /></div>
            </div>
        </div>
        <?php 
    }
コード例 #17
0
ファイル: autonews.php プロジェクト: sontv1003/fashionbeans
 function checkPostNotif()
 {
     $current_check = (int) get_option('wysija_check_pn');
     if (microtime(true) < $current_check + 60) {
         WYSIJA::log('already_running_checkPN', $current_check, 'post_notif');
         return false;
     }
     $current_check = microtime(true);
     WYSIJA::update_option('wysija_check_pn', $current_check);
     WYSIJA::log('check_post_notif_starts', $current_check, 'post_notif');
     $model_email =& WYSIJA::get('email', 'model');
     $model_email->reset();
     $all_emails = $model_email->get(false, array('type' => '2', 'status' => array('1', '3', '99')));
     if ($all_emails) {
         $helper_toolbox =& WYSIJA::get('toolbox', 'helper');
         foreach ($all_emails as $email) {
             if ($email['params']['autonl']['event'] == 'new-articles' && $email['params']['autonl']['when-article'] != 'immediate') {
                 if (!isset($email['params']['autonl']['nextSend'])) {
                     WYSIJA::log('check_post_notif_next_send_not_set', $current_check, 'post_notif');
                 } else {
                     $time_now_server = time();
                     if ($time_now_server > $helper_toolbox->localtime_to_servertime($email['params']['autonl']['nextSend'])) {
                         $how_late = $time_now_server - $helper_toolbox->localtime_to_servertime($email['params']['autonl']['nextSend']);
                         if (!$this->cancel_late_post_notification($email, $how_late)) {
                             WYSIJA::log('check_post_notif_before_give_birth', $current_check, 'post_notif');
                             $model_email->give_birth($email);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #18
0
ファイル: autonews.php プロジェクト: crazyyy/octagram
 /**
  * check if there is post notification needing a child email
  */
 function checkPostNotif()
 {
     // flag security to make sure that there can't be two checks of the post notif in the same minute
     $current_check = (double) get_option('wysija_check_pn');
     // there is a check that has been starting to run less than 60 seconds ago
     if (microtime(true) < $current_check + 60) {
         WYSIJA::log('already_running_checkPN', $current_check, 'post_notif');
         return false;
     }
     // flag is down we process our post notification check and set the start time of the current check
     $current_check = microtime(true);
     WYSIJA::update_option('wysija_check_pn', $current_check);
     // let's check when do we come here
     WYSIJA::log('check_post_notif_starts', $current_check, 'post_notif');
     $model_email = WYSIJA::get('email', 'model');
     $model_email->reset();
     $all_emails = $model_email->get(false, array('type' => '2', 'status' => array('1', '3', '99')));
     if ($all_emails) {
         $helper_toolbox = WYSIJA::get('toolbox', 'helper');
         foreach ($all_emails as $email) {
             //post notification make a child newsletter when the timing is immediate otherwise let the cron take care of it
             if ($email['params']['autonl']['event'] == 'new-articles' && $email['params']['autonl']['when-article'] != 'immediate') {
                 //check if the next sending is passed if so then we give birth to one child email
                 //IMPORTANT WE COMPARE TO THE OFFSET TIME (time set by the administrator)
                 //if the nextSend doesn't exist then we set it
                 if (!isset($email['params']['autonl']['nextSend'])) {
                     WYSIJA::log('check_post_notif_next_send_not_set', $current_check, 'post_notif');
                 } else {
                     //if the next send is passed we should trigger it
                     $time_now_server = time();
                     if ($time_now_server > $helper_toolbox->localtime_to_servertime($email['params']['autonl']['nextSend'])) {
                         $how_late = $time_now_server - $helper_toolbox->localtime_to_servertime($email['params']['autonl']['nextSend']);
                         //check how late was the previous notification,
                         //if it has been more than two hours late then cancel it and change it to the next day
                         if (!$this->cancel_late_post_notification($email, $how_late)) {
                             WYSIJA::log('check_post_notif_before_give_birth', $current_check, 'post_notif');
                             //it is not cancel so we can give birth toa a child newsletter
                             $model_email->give_birth($email);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #19
0
ファイル: back.php プロジェクト: rotoballer/emily
 function WYSIJA_control_back()
 {
     parent::WYSIJA_control();
     global $wysija_msg, $wysija_queries;
     $wysija_msgTemp = get_option("wysija_msg");
     if (is_array($wysija_msgTemp) && count($wysija_msgTemp) > 0) {
         $wysija_msg = $wysija_msgTemp;
     }
     $modelEmail =& WYSIJA::get('email', 'model');
     $campaign = $modelEmail->getOne('params', array('email_id' => 12));
     $wysija_qryTemp = get_option("wysija_queries");
     if (is_array($wysija_qryTemp) && count($wysija_qryTemp) > 0) {
         $wysija_queries = $wysija_qryTemp;
     }
     WYSIJA::update_option("wysija_queries", "");
     WYSIJA::update_option("wysija_msg", "");
     $this->pref = get_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', true);
     $prefupdate = false;
     if ($this->pref) {
         $prefupdate = true;
         $this->pref = unserialize(base64_decode($this->pref));
     } else {
         $this->pref = array();
     }
     if (!isset($_GET['action'])) {
         $action = "default";
     } else {
         $action = $_GET['action'];
     }
     if (isset($_REQUEST['limit_pp'])) {
         $this->pref[$_REQUEST['page']][$action]['limit_pp'] = $_REQUEST['limit_pp'];
     }
     if ($this->pref && isset($_REQUEST['page']) && $_REQUEST['page'] && isset($this->pref[$_REQUEST['page']][$action]['limit_pp'])) {
         $this->viewObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
         $this->modelObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
     }
     if ($prefupdate) {
         update_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     } else {
         add_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     }
     /* check the licence if we have a premium user once in a while like every 24hrs*/
     $modelC =& WYSIJA::get('config', 'model');
     if (get_option('wysicheck') || isset($_REQUEST['action']) && $_REQUEST['action'] != 'licok' && $modelC->getValue('premium_key')) {
         //$this->notice('licence check');
         $onedaysec = 7 * 24 * 3600;
         if (get_option('wysicheck') || (!$modelC->getValue('premium_val') || time() > (int) $modelC->getValue('premium_val') + $onedaysec)) {
             $helpLic =& WYSIJA::get('licence', 'helper');
             $res = $helpLic->check(true);
             if ($res['nocontact']) {
                 /* redirect instantly to a page with a javascript file  where we check the domain is ok */
                 $data = get_option('wysijey');
                 /* remotely connect to host */
                 wp_enqueue_script('wysija-verif-licence', 'http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDomain&js=1&data=' . $data, array('jquery'), time());
             }
         }
     }
     if (get_option('dkim_autosetup')) {
         $helpLic =& WYSIJA::get('licence', 'helper');
         $data = $helpLic->getDomainInfo();
         wp_enqueue_script('wysija-setup-dkim', 'http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDkim&js=1&data=' . $data, array('jquery'), time());
     }
     /*check if the plugin has an update available */
     $updateH =& WYSIJA::get('update', 'helper');
     $updateH->checkForNewVersion();
 }
コード例 #20
0
ファイル: stats.php プロジェクト: sontv1003/fashionbeans
 function share()
 {
     $data = $this->getDomainStats();
     if (!$js) {
         WYSIJA::update_option('wysijey', $data);
     }
     $res['domain_name'] = $data;
     $res['nocontact'] = false;
     $httpHelp =& WYSIJA::get('http', 'helper');
     $jsonResult = $httpHelp->request('http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=shareData&data=' . $data);
     if ($jsonResult) {
     }
 }
コード例 #21
0
ファイル: UPDATE.PHP プロジェクト: pauEscarcia/AIMM
    function runUpdate($version){
        //run all the updates missing since the db-version
        //foreach ... $this->updateVersion($version);
        switch($version){
            case '1.1':
                //add column namekey to
                $model_config=WYSIJA::get('config','model');
                if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'namekey';")){
                    $querys[]='ALTER TABLE `[wysija]list` ADD `namekey` VARCHAR( 255 ) NULL;';
                }

                $querys[]="UPDATE `[wysija]list` SET `namekey` = 'users' WHERE `list_id` =".$model_config->getValue('importwp_list_id').";";
                $errors=$this->runUpdateQueries($querys);

                $importHelp=WYSIJA::get('import','helper');
                $importHelp->testPlugins();

                // move data
                $installHelper = WYSIJA::get('install', 'helper');
                $installHelper->moveData('dividers');
                $installHelper->moveData('bookmarks');
                $installHelper->moveData('themes');

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
            case '2.0':
                //add column namekey to
                $model_config=WYSIJA::get('config','model');
                if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]email` LIKE 'modified_at';")){
                    $querys[]="ALTER TABLE `[wysija]email` ADD `modified_at` INT UNSIGNED NOT NULL DEFAULT '0';";
                }
                if(!$model_config->getValue('update_error_20')){
                    $querys[]="UPDATE `[wysija]email` SET `modified_at` = `sent_at`  WHERE `sent_at`>=0;";
                    $querys[]="UPDATE `[wysija]email` SET `modified_at` = `created_at` WHERE `modified_at`='0';";
                    $querys[]="UPDATE `[wysija]email` SET `status` = '99' WHERE `status` ='1';";//change sending status from 1 to 99
                }


                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $model_config->save(array('update_error_20'=>true));
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
            case '2.1':
                $model_config=WYSIJA::get('config','model');
                if(!$model_config->getValue('update_error_21')){
                    $modelEmails=WYSIJA::get('email','model');
                    $modelEmails->reset();
                    $emailsLoaded=$modelEmails->get(array('subject','email_id'),array('status'=>2,'type'=>1));

                    //set the default new role caps for super admin and admin
                    $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
                    $wp_tools_helper->set_default_rolecaps();

                    //based on the config values for role_campaign and role_subscribers
                    //let's give the each core roles the right capability

                    $minimumroles=array('role_campaign'=>'wysija_newsletters','role_subscribers'=>'wysija_subscribers');

                    foreach($minimumroles as $rolename=>$capability){
                        $rolesetting=$model_config->getValue($rolename);
                        switch($rolesetting){
                            case 'switch_themes':
                                $keyrole=1;
                                break;
                            case 'moderate_comments':
                                $keyrole=3;
                                break;
                            case 'upload_files':
                                $keyrole=4;
                                break;
                            case 'edit_posts':
                                $keyrole=5;
                                break;
                            case 'read':
                                $keyrole=6;
                                break;
                            default:
                                $keyrole=false;
                        }

                        if(!$keyrole){
                            //add the setting to a custom role
                            $role = get_role($rolesetting);
                            //added for invalid roles ...
                            if($role){
                                $role->add_cap( $capability );
                            }
                        }else{
                            //get all the minimum roles getting that capability
                            $editable_roles=$wp_tools_helper->wp_get_roles();
                            $startcount=1;
                            if(!isset($editable_roles[$startcount])) $startcount++;
                            for($i = $startcount; $i <= $keyrole; $i++) {
                                $rolename=$editable_roles[$i];
                                //add the setting to a custom role
                                $role = get_role($rolename['key']);
                                $role->add_cap( $capability );
                            }
                        }
                    }
                    $wptoolboxs = WYSIJA::get('toolbox', 'helper');
                    $model_config->save(array('dkim_domain'=>$wptoolboxs->_make_domain_name()));
                }

                if(!$this->modelWysija->query("SHOW COLUMNS FROM `[wysija]list` LIKE 'is_public';")){
                    $querys[]="ALTER TABLE `[wysija]list` ADD `is_public` TINYINT UNSIGNED NOT NULL DEFAULT 0;";
                    $errors=$this->runUpdateQueries($querys);
                    if($errors){
                        $model_config->save(array('update_error_21'=>true));
                        $this->error(implode($errors,"\n"));
                        return false;
                    }
                }
                return true;
            break;
            case '2.1.6':
                $querys[]="UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= B.created_at where A.sub_date=0 and A.unsub_date=0 and B.status>-1;";
                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
            case '2.1.7':
                $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id= B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and B.status>-1;';
                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
           case '2.1.8':
               $mConfig=WYSIJA::get('config','model');

               $querys[]='UPDATE `[wysija]user_list` as A set A.sub_date= '.time().' where A.list_id='.$mConfig->getValue('importwp_list_id').';';
                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
           case '2.2':
               $mConfig=WYSIJA::get('config','model');

               //let's rename the Synched WordPress list into WordPress Users
               $mList=WYSIJA::get('list','model');
               $mList->update(array('name'=>'WordPress Users'),array('list_id'=>$mConfig->getValue('importwp_list_id'), 'namekey'=>'users'));

               //remove subscribers that should not be in the WordPress Users list
               $querys[]='DELETE FROM `[wysija]user_list` WHERE `list_id` = '.$mConfig->getValue('importwp_list_id').' AND `user_id` in ( SELECT user_id FROM `[wysija]user` where wpuser_id=0 );';
                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }

                return true;
               break;
           case '2.2.1':
                $helperU=WYSIJA::get('user','helper');
                $helperU->cleanWordpressUsersList();

                return true;
               break;
           case '2.3.3':
                update_option('wysija_log', $optionlog);

                return true;
               break;


           case '2.3.4':
                $model_config=WYSIJA::get('config','model');

                $dbl_optin=(int)$model_config->getValue('confirm_dbleoptin');
                //count issue for people who went through all of the versions and now are left with some users in a limbo
                $querys[]='UPDATE `[wysija]user_list` as A inner join `[wysija]user` as B on (A.user_id = B.user_id) set A.sub_date= '.time().' where A.sub_date=0 and A.unsub_date=0 and B.status>='.$dbl_optin.';';
                $errors=$this->runUpdateQueries($querys);

                if($errors){
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;

            case '2.4':
                $queries = array();
                $queries[] = 'CREATE TABLE IF NOT EXISTS `[wysija]form` ('.
                    '`form_id` INT unsigned AUTO_INCREMENT NOT NULL,'.
                    '`name` tinytext COLLATE utf8_bin,'.
                    '`data` longtext COLLATE utf8_bin,'.
                    '`styles` longtext COLLATE utf8_bin,'.
                    '`subscribed` int(10) unsigned NOT NULL DEFAULT "0",'.
                    'PRIMARY KEY (`form_id`)'.
                ') ENGINE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci*/';

                $errors = $this->runUpdateQueries($queries);

                if($errors) {
                    $this->error(implode($errors,"\n"));
                    return false;
                } else {
                    // the table should be created now. let's make sure:
                    if((bool)$this->modelWysija->query('SHOW TABLES LIKE "[wysija]form";') === false) {
                        return false;
                    } else {
                        // the form table has been successfully created, let's convert all previously added widgets
                        $widgets_converted = $this->convert_widgets_to_forms();
                        if($widgets_converted === 0) {
                            $helper_install = WYSIJA::get('install', 'helper');
                            $helper_install->create_default_subscription_form();
                        }
                    }
                }

                return true;
                break;

            case '2.4.1':
                $model_email=WYSIJA::get('email','model');
                $model_email->setConditions(array('type'=>'2'));
                $emails = $model_email->getRows(array('email_id','params'));

                // we don't want parent post notification to send emails
                foreach($emails as $email){
                    $model_email->getParams($email);
                    if(isset($email['params']) && $email['params']['autonl']['event']=='new-articles'){
                        $model_queue=WYSIJA::get('queue','model');
                        $model_queue->delete(array('email_id'=>$email['email_id']));
                    }
                }
                return true;

            break;

            case '2.4.3':
                // convert data for previously saved forms
                /*
                * 1. get all forms and loop through each form
                * 2. check data['settings']['success_message'] is base64 valid -> decode it
                * 3. loop through data['body'], if type="text" -> is base64 valid -> decode it
                * 4. save form
                */
                $model_forms = WYSIJA::get('forms', 'model');
                $forms = $model_forms->getRows();
                if(is_array($forms) && count($forms) > 0) {

                    foreach ($forms as $i => $form) {
                        $requires_update = false;

                        // decode form data
                        $data = unserialize(base64_decode($form['data']));

                        // convert success_message if necessary
                        if(strlen($data['settings']['success_message']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data['settings']['success_message'])) {
                            // this is a potential base64 string so decode it
                            $data['settings']['success_message'] = base64_decode($data['settings']['success_message']);

                            $requires_update = true;
                        }

                        // loop through each block
                        foreach ($data['body'] as $j => $block) {
                            // in case we find a text block
                            if($block['type'] === 'text') {
                                // convert text if necessary
                                if(strlen($block['params']['text']) % 4 === 0 && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $block['params']['text'])) {

                                    // this is a potential base64 string so decode it
                                    $data['body'][$j]['params']['text'] = base64_decode($block['params']['text']);
                                    $requires_update = true;
                                }
                            }
                        }

                        // if the form requires update, let's do it
                        if($requires_update === true) {
                            $model_forms->reset();
                            $model_forms->update(array('data' => base64_encode(serialize($data))), array('form_id' => (int)$form['form_id']));
                        }
                    }
                }

                return true;
            break;
            case '2.4.4':
                // we now have steps in the installation process to make sure we don't rerun two processes
                WYSIJA::update_option('installation_step', '16');
                return true;
                break;

            case '2.5':
                // set the default new role caps for super admin and admin
                $wp_tools_helper = WYSIJA::get('wp_tools', 'helper');
                $wp_tools_helper->set_default_rolecaps();

                // get the main site bounce settings and save them to the global ms settings
                if(is_multisite()){
                    $main_blog_id=1;
                    switch_to_blog( $main_blog_id );
                    $main_site_encoded_option = unserialize(base64_decode(get_option( 'wysija' )));
                    restore_current_blog();

                    $data_bounce=array();
                    foreach($main_site_encoded_option as $key => $val){
                        if((strpos($key, 'bounce_')!==false || strpos($key, 'bouncing_')!==false) && !empty($val)) $data_bounce['ms_'.$key]=$val;
                    }

                    $data_saved_ms_before= unserialize(base64_decode(get_site_option('ms_wysija')));

                    // we don't want to run that multiple times
                    if(empty($data_saved_ms_before['ms_bounce_host'])){
                        if(!empty($data_saved_ms_before))   $data_bounce=array_merge($data_saved_ms_before, $data_bounce);
                        update_site_option('ms_wysija',base64_encode(serialize($data_bounce)));
                    }

                }

                // Sending method: remove "once a day" & "twice daily",  fallback on "every 2 hours"
                $model_config = WYSIJA::get('config','model');
                $removed_sending_methods = array('twicedaily','daily');
                $target_sending_method = 'two_hours';
                if(in_array($model_config->getValue('sending_emails_each'), $removed_sending_methods))
                    $model_config->save(array('sending_emails_each'=>$target_sending_method));
                if(in_array($model_config->getValue('ms_sending_emails_each'), $removed_sending_methods))
                    $model_config->save(array('ms_sending_emails_each'=>$target_sending_method));

                return true;
                break;

            case '2.5.2':
                $queries = array();
                $queries[] = 'UPDATE `[wysija]user_list` AS A JOIN `[wysija]user` AS B ON A.user_id = B.user_id SET A.unsub_date = 0, A.sub_date = '.time().' WHERE STATUS = 1 AND sub_date =0';
                $errors = $this->runUpdateQueries($queries);
                if($errors) {
                    $this->error(implode($errors,"\n"));
                    return false;
                }
                return true;
                break;
            case '2.5.5':
                $model_email = WYSIJA::get('email','model',false,'wysija-newsletters',false);
                $model_config = WYSIJA::get('config','model');

                $model_email->update( array('replyto_name'=>$model_config->getValue('replyto_name'),'replyto_email'=>$model_config->getValue('replyto_email')) ,
                        array('email_id'=>$model_config->getValue('confirm_email_id')) );
                return true;
                break;
            default:
                return false;
        }
        return false;
    }
コード例 #22
0
 function importsave()
 {
     $this->requireSecurity();
     $this->_resetGlobMsg();
     /* import the contacts */
     /* 1-check that a list is selected and that there is a csv file pasted*/
     /* 2-save the list if necessary*/
     /* 3-save the contacts and record them for each list selected*/
     /* we need to save a new list in that situation*/
     if (isset($_REQUEST['wysija']['list'])) {
         $model =& WYSIJA::get('list', 'model');
         $data = array();
         $data['is_enabled'] = 1;
         $data['name'] = $_REQUEST['wysija']['list']['newlistname'];
         $_REQUEST['wysija']['user_list']['list'][] = $model->insert($data);
     }
     if (!isset($_REQUEST['wysija']['user_list']['list']) || !$_REQUEST['wysija']['user_list']['list']) {
         $this->error(__('You need to select at least one list.', WYSIJA), true);
         return $this->importmatch();
     }
     /* is it a new list or not */
     /* try to make a wysija dir */
     $csvData = unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
     $csvfilename = $csvData['csv'];
     $fileHelp =& WYSIJA::get("file", "helper");
     $resultFile = $fileHelp->get($csvfilename, "import");
     if (!$resultFile) {
         $upload_dir = wp_upload_dir();
         $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"', WYSIJA), $upload_dir['basedir']), true);
         return $this->import();
     }
     /*get the temp csv file*/
     $csvdata = file_get_contents($resultFile);
     $csvArr = $this->_csvToArray($csvdata, 0, $csvData['fsep'], $csvData['fenc']);
     $datatoinsert = array();
     $emailKey = '';
     foreach ($_POST['wysija']['match'] as $key => $val) {
         if ($val != 'nomatch') {
             $datatoinsert[$key] = trim($val);
         }
         if ($val == 'email') {
             $emailKey = $key;
         }
     }
     //dbg($datatoinsert);
     if (!in_array('status', $datatoinsert)) {
         $datatoinsert['status'] = 'status';
     }
     $queryStart = "INSERT IGNORE INTO [wysija]user (`" . implode("` ,`", $datatoinsert) . "`,`created_at`) VALUES ";
     //$linescount=count($csvArr);
     /* detect the emails that are duplicate in the import file */
     $emailsCount = array();
     /* we process the sql insertion 200 by 200 so that we are safe with the server */
     $csvChunks = array_chunk($csvArr, 200);
     $j = 0;
     $linescount = 0;
     $dataNumbers = array('invalid' => array(), 'inserted' => 0, 'outof' => 0, 'list_added' => 0, 'list_user_ids' => 0, 'list_list_ids' => count($_REQUEST['wysija']['user_list']['list']));
     $allemailsinvalid = array();
     foreach ($csvChunks as $keyChunk => $arra) {
         foreach ($arra as $keyline => $emailline) {
             if (isset($emailsCount[$emailline[$emailKey]])) {
                 $emailsCount[$emailline[$emailKey]]++;
                 //$arra[$keyline]
             } else {
                 $emailsCount[$emailline[$emailKey]] = 1;
             }
         }
         $result = $this->_importRows($queryStart, $arra, $j, $datatoinsert, $emailKey, $dataNumbers);
         if ($result !== false) {
             $j++;
         } else {
             $try = 0;
             while ($result === false && $try < 3) {
                 $result = $this->_importRows($queryStart, $arra, $j, $datatoinsert, $emailKey, $dataNumbers);
                 $try++;
             }
             if ($result) {
                 $j++;
             } else {
                 $this->error(__("There seems to be an error with the list you're trying to import.", WYSIJA), true);
                 $this->redirect('admin.php?page=wysija_subscribers&action=import');
                 return false;
             }
         }
         $linescount = $linescount + $result;
     }
     if (!isset($_POST['firstrowisdata'])) {
         //$linescount--;
         /* save the importing fields to be able to match them the next time */
         $importfields = get_option("wysija_import_fields");
         foreach ($_POST['wysija']['match'] as $key => $val) {
             if ($val != 'nomatch') {
                 $importfields[$csvArr[0][$key]] = $val;
             }
         }
         WYSIJA::update_option('wysija_import_fields', $importfields);
     }
     /* get a list of list name */
     $model =& WYSIJA::get('list', 'model');
     $results = $model->get(array('name'), array('list_id' => $_REQUEST['wysija']['user_list']['list']));
     $listnames = array();
     foreach ($results as $k => $v) {
         $listnames[] = $v['name'];
     }
     $helperU =& WYSIJA::get('user', 'helper');
     $helperU->refreshUsers();
     foreach ($emailsCount as $emailkeycount => $countemailfile) {
         if ($countemailfile == 1) {
             unset($emailsCount[$emailkeycount]);
         }
     }
     if ($linescount < 0) {
         $linescount = 0;
     }
     $dataNumbers['ignored'] = $dataNumbers['outof'] - $dataNumbers['inserted'];
     $dataNumbers['ignored_list'] = $dataNumbers['list_user_ids'] * $dataNumbers['list_list_ids'] - $dataNumbers['list_added'];
     $this->notice(sprintf(__('%1$s subscribers have been added to database. (%2$s were ignored)', WYSIJA), $dataNumbers['inserted'], $dataNumbers['ignored']));
     $this->notice(sprintf(__('%1$s subscribers have been added to %2$s. (%3$s insertions were ignored out of %4$s)', WYSIJA), $dataNumbers['list_user_ids'], '"' . implode('", "', $listnames) . '"', $dataNumbers['ignored_list'], $dataNumbers['list_user_ids'] * $dataNumbers['list_list_ids']));
     if (count($emailsCount) > 0) {
         $listemails = '';
         $m = 0;
         foreach ($emailsCount as $emailkeyalready => $occurences) {
             if ($m > 0) {
                 $listemails .= ', ';
             }
             $listemails .= $emailkeyalready . ' (' . $occurences . ')';
             $m++;
         }
         //$emailsalreadyinserted=array_keys($emailsCount);
         $this->notice(sprintf(__('%1$s emails appear more than once in your file : %2$s.', WYSIJA), count($emailsCount), $listemails), 0);
     }
     if (count($dataNumbers['invalid']) > 0) {
         $this->notice(sprintf(__('%1$s emails are not valid : %2$s.', WYSIJA), count($dataNumbers['invalid']), implode(', ', $dataNumbers['invalid'])), 0);
     }
     $this->redirect();
 }
コード例 #23
0
ファイル: back.php プロジェクト: crazyyy/octagram
 function WYSIJA_control_back()
 {
     parent::WYSIJA_control();
     global $wysija_msg, $wysija_queries, $wysija_queries_errors;
     $wysija_msgTemp = get_option('wysija_msg');
     if (is_array($wysija_msgTemp) && count($wysija_msgTemp) > 0) {
         $wysija_msg = $wysija_msgTemp;
     }
     $wysija_qryTemp = get_option('wysija_queries');
     $wysija_qryErrors = get_option('wysija_queries_errors');
     if (is_array($wysija_qryTemp) && count($wysija_qryTemp) > 0) {
         $wysija_queries = $wysija_qryTemp;
     }
     if (is_array($wysija_qryErrors) && count($wysija_qryErrors) > 0) {
         $wysija_queries_errors = $wysija_qryErrors;
     }
     WYSIJA::update_option('wysija_queries', '');
     WYSIJA::update_option('wysija_queries_errors', '');
     WYSIJA::update_option('wysija_msg', '');
     global $wysija_installing;
     if ($wysija_installing === true) {
         return;
     }
     $this->pref = get_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', true);
     $prefupdate = false;
     if ($this->pref) {
         $prefupdate = true;
         $this->pref = unserialize(base64_decode($this->pref));
     } else {
         $this->pref = array();
     }
     if (!isset($_GET['action'])) {
         $action = 'default';
     } else {
         $action = $_GET['action'];
     }
     if (isset($_REQUEST['limit_pp'])) {
         $this->pref[$_REQUEST['page']][$action]['limit_pp'] = $_REQUEST['limit_pp'];
     }
     if (!empty($_REQUEST['orderby'])) {
         $_REQUEST['orderby'] = preg_replace('|[^a-z0-9#_.-]|i', '', $_REQUEST['orderby']);
     }
     if (!empty($_REQUEST['ordert']) && !in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC'))) {
         $_REQUEST['ordert'] = 'DESC';
     }
     if (!empty($_REQUEST['id'])) {
         $_REQUEST['id'] = (int) $_REQUEST['id'];
     }
     if (!empty($_REQUEST['search'])) {
         $_REQUEST['search'] = esc_attr($_REQUEST['search']);
     }
     if ($this->pref && isset($_REQUEST['page']) && $_REQUEST['page'] && isset($this->pref[$_REQUEST['page']][$action]['limit_pp'])) {
         $this->viewObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
         $this->modelObj->limit_pp = $this->pref[$_REQUEST['page']][$action]['limit_pp'];
     }
     if ($prefupdate) {
         update_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     } else {
         add_user_meta(WYSIJA::wp_get_userdata('ID'), 'wysija_pref', base64_encode(serialize($this->pref)));
     }
     add_action('wysija_various_check', array($this, 'variousCheck'));
     do_action('wysija_various_check');
 }
コード例 #24
0
ファイル: campaigns.php プロジェクト: namwoody/SAAZINDIAN.COM
 function licok()
 {
     parent::WYSIJA_control_back();
     $dt = get_option('wysijey');
     if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
         $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time(), 'premium_expire_at' => (int) $_REQUEST['expire_at']);
         $this->notice(__('Premium version is valid for your site.', WYSIJA));
     } else {
         $dataconf = array('premium_key' => '', 'premium_val' => '');
         if (!empty($_REQUEST['expire_at'])) {
             $dataconf['premium_expire_at'] = (int) $_REQUEST['expire_at'];
         } else {
             $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
             $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
         }
     }
     WYSIJA::update_option('wysicheck', false);
     $modelConf = WYSIJA::get('config', 'model');
     $modelConf->save($dataconf);
     $this->redirect('admin.php?page=wysija_config#tab-premium');
 }
コード例 #25
0
ファイル: INSTALL.PHP プロジェクト: pauEscarcia/AIMM
    function install(){
        $values=array();
        $model_config=WYSIJA::get('config','model');
        // test server against few things to make sure the installation can be done
        $helper_server=WYSIJA::get('server','helper');
        $missing_capabilities=$helper_server->unhealthy();

        // if it returns false it means we're all good
        if($missing_capabilities!==false){
            // it will fail only if we have more than one missing capabilities or if we have just one and that's a required function
            if(count($missing_capabilities) > 1 ||
                    (count($missing_capabilities)==1 && (!isset($missing_capabilities['functions']) || isset($missing_capabilities['functions']['required']))) ){
                // here we need to return unfortunately
                $this->error(__('Your server cannot run Wysija.',WYSIJA),1);

                if(isset($missing_capabilities['functions']['required'])){
                    $this->error(sprintf(__('Your server is missing one or many important PHP functions to run properly :  %1$s',WYSIJA),'<strong>'.implode(', ',  array_keys($missing_capabilities['functions']['required'])).'</strong>').' '.__('Please contact your host or server administrator to fix this.',WYSIJA));

                }
                return false;
            }else{
                // here we're ok
            }
        }

        // create the tables there shouldn't be any issue since we've tested it before
        if((int)get_option('installation_step')<1){
             if(!$this->createTables(WYSIJA_DIR.'sql'.DS.'install.sql')) return false;

            WYSIJA::update_option('installation_step', '1');
        }


        // move data to uploads folder: this needs to be done prior to default campaign creation for dependency reasons
        if((int)get_option('installation_step')<4){
            $this->moveData('themes');
            $this->moveData('dividers');
            $this->moveData('bookmarks');
            WYSIJA::update_option('installation_step', '4');
        }


        // record custom fields lastname firstname in the user_field table
        if((int)get_option('installation_step')<5){
            $this->recordDefaultUserField();
            WYSIJA::update_option('installation_step', '5');
        }

        // save default values for the fields : from_name, from_email replyto_name, replyto_email
        if((int)get_option('installation_step')<6){
            $this->defaultSettings($values);
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '6');
        }


        //create a default list
        if((int)get_option('installation_step')<7){
            $this->defaultList($values);
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '7');
        }


        // create a default campaign
        if((int)get_option('installation_step')<8){
            $this->defaultCampaign($values);
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '8');
        }


        // synchronize our user table with wordpress users
        if((int)get_option('installation_step')<9){
            $helper_import=WYSIJA::get('import','helper');
            $values['importwp_list_id']=$helper_import->importWP();
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '9');
        }

        // create subscription redirection page
        if((int)get_option('installation_step')<10){
            $this->createPage($values);
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '10');
        }


        // create the default dir
        if((int)get_option('installation_step')<11){
            $this->createWYSIJAdir($values);
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '11');
        }


        // create default subscription form
        if((int)get_option('installation_step')<12){
            $this->create_default_subscription_form();
            WYSIJA::update_option('installation_step', '12');
        }


        // save the confirmation email in the table


        if((int)get_option('installation_step')<13){
            // make sure that the activation email is translated
            $model_config->add_translated_default();
            WYSIJA::update_option('installation_step', '13');
        }

        if((int)get_option('installation_step')<14){
            $model_email=WYSIJA::get('email','model');
            $model_email->blockMe=true;
            $values['confirm_email_id']=$model_email->insert(
                    array('type'=>'0',
                        'from_email'=>$values['from_email'],
                        'from_name'=>$values['from_name'],
                        'replyto_email'=>$values['from_email'],
                        'replyto_name'=>$values['from_name'],
                        'subject'=>$model_config->getValue('confirm_email_title'),
                        'body'=>$model_config->getValue('confirm_email_body'),
                        'status'=>99));
            $model_config->save($values);
            WYSIJA::update_option('installation_step', '14');
        }


        // look for existing newsletter plugins to import from
        if((int)get_option('installation_step')<15){
            $this->testNLplugins();

            // administrator caps
            $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
            $helper_wp_tools->set_default_rolecaps();

            WYSIJA::update_option('installation_step', '15');
        }



        // save the config into the db

        if((int)get_option('installation_step')<16){
            $values['installed']=true;
            $values['manage_subscriptions']=true;
            $values['installed_time']=time();

            $values['wysija_db_version']=WYSIJA::get_version();

            $wptoolboxs = WYSIJA::get('toolbox', 'helper');
            $values['dkim_domain']=$wptoolboxs->_make_domain_name();

            if(get_option('wysija_reinstall',0)) $values['wysija_whats_new']=WYSIJA::get_version();
            $model_config->save($values);

            WYSIJA::update_option('installation_step', '16');
        }




        global $wysija_installing;
        $wysija_installing=false;
        WYSIJA::update_option('wysija_reinstall',0);
        return true;
    }
コード例 #26
0
ファイル: base.php プロジェクト: rotoballer/emily
 function create_post_type()
 {
     //$modelC=&WYSIJA::get('config','model');
     //$rewritewysijap=array("slug"=>"wysijap");
     //by default there is url rewriteing on wysijap custom post, though in one client case I had to deactivate it.
     //as this is rare we just need to set this setting to activate it
     //if($modelC->getValue('no_rewrite_wysijap'))$rewritewysijap=false;
     //by default let's deactivate the url rewriting of the wysijap confirmation page because it is breaking in some case.
     $rewritewysijap = false;
     register_post_type('wysijap', array('labels' => array('name' => __('Wysija page'), 'singular_name' => __('Wysija page')), 'public' => true, 'has_archive' => false, 'show_ui' => false, 'show_in_menu' => false, 'rewrite' => $rewritewysijap, 'show_in_nav_menus' => false, 'can_export' => false, 'publicly_queryable' => true, 'exclude_from_search' => true));
     if (!get_option('wysija_post_type_updated')) {
         $modelPosts = new WYSIJA_model();
         $modelPosts->tableWP = true;
         $modelPosts->table_prefix = '';
         $modelPosts->table_name = 'posts';
         $modelPosts->noCheck = true;
         $modelPosts->pk = 'ID';
         if ($modelPosts->exists(array('post_type' => 'wysijapage'))) {
             $modelPosts->update(array('post_type' => 'wysijap'), array('post_type' => 'wysijapage'));
             flush_rewrite_rules(false);
         }
         WYSIJA::update_option('wysija_post_type_updated', time());
     }
     if (!get_option('wysija_post_type_created')) {
         flush_rewrite_rules(false);
         WYSIJA::update_option('wysija_post_type_created', time());
     }
     /*
             $rewritewysija=array('slug'=>'wysija');
             register_post_type( 'wysija',
                 array(
                         'labels' => array(
                                 'name' => 'Wysija Archives',
                                 'singular_name' => 'Wysija archives'
                         ),
                 'public' => true,
                 'has_archive' => false,
                 'show_ui' =>false,
                 'show_in_menu' =>false,
                 'rewrite' => $rewritewysija,
                 'show_in_nav_menus'=>false,
                 'can_export'=>false,
                 'publicly_queryable'=>true,
                 'exclude_from_search'=>true,
                 )
             );
     
             if(!get_option('wysija_post_type2_created')) {
                 flush_rewrite_rules( false );
                 WYSIJA::update_option('wysija_post_type2_created',time());
             }*/
 }
コード例 #27
0
ファイル: base.php プロジェクト: sontv1003/fashionbeans
 /**
  * check that there is no passed schedules that need to be executed now
  * @return void
  */
 public static function cron_check()
 {
     $cron_schedules = WYSIJA::get_cron_schedule('all');
     if (empty($cron_schedules)) {
         return;
     } else {
         $processes = WYSIJA::get_cron_frequencies();
         $updatedsched = false;
         foreach ($cron_schedules as $proc => &$params) {
             $running = 0;
             if (isset($params['running'])) {
                 $running = $params['running'];
             }
             //if the process has timedout we reschedule the next execution
             if ($running && time() > $running + 900) {
                 //WYSIJA::setInfo('error','modifying next schedule for '.$proc);
                 $next_schedule = time() + $processes[$proc];
                 $params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
                 $updatedsched = true;
             }
         }
         if ($updatedsched) {
             //WYSIJA::setInfo('error','updating scheds');
             WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
         }
     }
     $timenow = time();
     $processesToRun = array();
     foreach ($cron_schedules as $process => $scheduled_times) {
         if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + 900 < $timenow) && $scheduled_times['next_schedule'] < $timenow) {
             $processesToRun[] = $process;
         }
     }
     $model_config =& WYSIJA::get('config', 'model');
     if (!empty($processesToRun) && $model_config->getValue('cron_page_hit_trigger')) {
         //call the cron url
         $cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
         //TODO we should use the http class there
         $hHTTP =& WYSIJA::get('http', 'helper');
         $hHTTP->request_timeout($cron_url);
     }
 }
コード例 #28
0
ファイル: bounce.php プロジェクト: selectSIFISO/.comsite
 /**
  * record the bounce into the bounce table on a multisite
  * @return type
  */
 function record_bounce_ms()
 {
     // make sure that the bounce recording is not already being processed on another child site
     if (get_site_option('wysija_bounce_being_recorded')) {
         return;
     }
     // flag the current recording
     WYSIJA::update_option('wysija_bounce_being_recorded', true);
     // set the flag to indicate we are processing the bounce in a multisite manner right now
     $this->record_ms_bounce = true;
     // will record the bounce in the ms table
     $result = $this->process_bounce();
     // lower the flag we can process the bounce again
     WYSIJA::update_option('wysija_bounce_being_recorded', false);
     return $result;
 }
コード例 #29
0
ファイル: config.php プロジェクト: christocmp/bingopaws
    function main($data)
    {
        $is_multisite = is_multisite();
        $is_network_admin = WYSIJA::current_user_can('manage_network');
        //$is_network_admin=$is_multisite=true;//PROD comment that line
        if ($is_multisite && $is_network_admin) {
            add_filter('wysija_extend_settings', array($this, 'ms_tab_name'), 12);
            add_filter('wysija_extend_settings_content', array($this, 'ms_tab_content'), 12, 2);
        }
        // check for debug
        if (isset($_REQUEST['wysija_debug'])) {
            switch ((int) $_REQUEST['wysija_debug']) {
                // turn off debug
                case 0:
                    WYSIJA::update_option('debug_on', false);
                    WYSIJA::update_option('debug_new', false);
                    break;
                    // turn on debug (with debug level as value)
                // turn on debug (with debug level as value)
                case 1:
                case 2:
                case 3:
                case 4:
                case 99:
                    WYSIJA::update_option('debug_on', true);
                    WYSIJA::update_option('debug_new', (int) $_REQUEST['wysija_debug']);
                    break;
            }
        }
        echo $this->messages();
        ?>
		<div id="wysija-config">
					<?php 
        $this->tabs();
        ?>
			<form name="wysija-settings" method="post" id="wysija-settings" action="" class="form-valid" autocomplete="off">
				<div id="basics" class="wysija-panel hidden">
		<?php 
        $this->basics();
        ?>
					<p class="submit">
						<input type="submit" value="<?php 
        echo esc_attr(__('Save settings', WYSIJA));
        ?>
" class="button-primary wysija" />
					</p>
				</div>
				<div id="forms" class="wysija-panel hidden">
					<?php 
        /* if(WYSIJA::is_wysija_admin()) */
        $this->form_list();
        ?>
				</div>

				<div id="signupconfirmation" class="wysija-panel hidden">
		<?php 
        $this->signupconfirmation();
        ?>
					<p class="submit">
						<input type="submit" value="<?php 
        echo esc_attr(__('Save settings', WYSIJA));
        ?>
" class="button-primary wysija" />
					</p>
				</div>
		<?php 
        if ($this->_user_can('change_sending_method')) {
            ?>
					<div id="sendingmethod" class="wysija-panel hidden">
			<?php 
            $this->sendingmethod();
            ?>
						<p class="submit">
							<input type="submit" value="<?php 
            echo esc_attr(__('Save settings', WYSIJA));
            ?>
" class="button-primary wysija" />
						</p>
					</div>
					<?php 
        }
        ?>


				<div id="advanced" class="wysija-panel hidden">
				<?php 
        $this->advanced($data);
        ?>
					<p class="submit">
						<input type="submit" value="<?php 
        echo esc_attr(__('Save settings', WYSIJA));
        ?>
" class="button-primary wysija" />
					</p>
				</div>

				<div id="add-ons" class="wysija-panel hidden">
					<?php 
        $this->add_ons();
        ?>
				</div>

		<?php 
        echo apply_filters('wysija_extend_settings_content', '', array('viewObj' => &$this));
        ?>

		<?php 
        $this->secure(array('action' => "save"));
        ?>
				<input type="hidden" value="save" name="action" />
				<input type="hidden" value="" name="redirecttab" id="redirecttab" />
			</form>
		</div>
		<?php 
    }
コード例 #30
0
ファイル: base.php プロジェクト: duboisGeof/deliciousMeals
 /**
  * check that there is no passed schedules that need to be executed now
  * @return void
  */
 public static function cron_check()
 {
     $cron_schedules = WYSIJA::get_cron_schedule('all');
     if (empty($cron_schedules)) {
         return;
     } else {
         $processes = WYSIJA::get_cron_frequencies();
         $updated_sched = false;
         foreach ($cron_schedules as $schedule => &$params) {
             $running = 0;
             $time_now = time();
             if (isset($params['running'])) {
                 $running = $params['running'];
             }
             //if the process has timedout we reschedule the next execution
             if ($running && $time_now > $running + $processes[$schedule]) {
                 //WYSIJA::setInfo('error','modifying next schedule for '.$proc);
                 $process_frequency = $processes[$schedule];
                 $next_schedule = $running + $process_frequency;
                 // if the next schedule is already behind, we give it 30 seconds before it can trigger again
                 if ($next_schedule < $time_now) {
                     $next_schedule = $time_now + 30;
                 }
                 $params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
                 $updated_sched = true;
             }
         }
         if ($updated_sched) {
             //WYSIJA::setInfo('error','updating scheds');
             WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
         }
     }
     $time_now = time();
     $processesToRun = array();
     foreach ($cron_schedules as $schedule => $scheduled_times) {
         if (strpos($schedule, '(bounce handling not activated)') !== false) {
             continue;
         }
         if (!isset($processes[$schedule])) {
             continue;
         }
         $process_frequency = $processes[$schedule];
         if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + $process_frequency < $time_now) && $scheduled_times['next_schedule'] < $time_now) {
             $processesToRun[] = $schedule;
         }
     }
     $model_config = WYSIJA::get('config', 'model');
     $page_view_trigger = (int) $model_config->getValue('cron_page_hit_trigger');
     if (!empty($processesToRun) && $page_view_trigger === 1) {
         //call the cron url
         // do not call that more than once per 5 minutes attempt at reducing the CPU load for some users
         // http://wordpress.org/support/topic/wysija-newsletters-slowing-down-my-site-1
         $last_cron_time_plus_5min = (int) get_option('wysija_last_php_cron_call') + 5 * 60;
         if ($last_cron_time_plus_5min < time()) {
             $cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
             $cron_request = apply_filters('cron_request', array('url' => $cron_url, 'args' => array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))));
             wp_remote_post($cron_url, $cron_request['args']);
             WYSIJA::update_option('wysija_last_php_cron_call', time());
         }
     }
 }