public function downgrade_license()
 {
     $api = new wfAPI('', wfUtils::getWPVersion());
     $return = array();
     try {
         $keyData = $api->call('get_anon_api_key');
         if ($keyData['ok'] && $keyData['apiKey']) {
             wfConfig::set('apiKey', $keyData['apiKey']);
             wfConfig::set('isPaid', 0);
             $return['apiKey'] = $keyData['apiKey'];
             $return['isPaid'] = 0;
             //When downgrading we must disable all two factor authentication because it can lock an admin out if we don't.
             wfConfig::set_ser('twoFactorUsers', array());
         } else {
             throw new Exception('Could not understand the response we received from the Wordfence servers when applying for a free API key.');
         }
     } catch (Exception $e) {
         $return['errorMsg'] = 'Could not fetch free API key from Wordfence: ' . htmlentities($e->getMessage());
         return $return;
     }
     $return['ok'] = 1;
     return $return;
 }
Esempio n. 2
0
 public static function statusEnd($idx, $haveIssues, $successFailed = false)
 {
     $statusStartMsgs = wfConfig::get_ser('wfStatusStartMsgs', array());
     if ($haveIssues) {
         if ($successFailed) {
             self::status(10, 'info', 'SUM_ENDFAILED:' . $statusStartMsgs[$idx]);
         } else {
             self::status(10, 'info', 'SUM_ENDBAD:' . $statusStartMsgs[$idx]);
         }
     } else {
         if ($successFailed) {
             self::status(10, 'info', 'SUM_ENDSUCCESS:' . $statusStartMsgs[$idx]);
         } else {
             self::status(10, 'info', 'SUM_ENDOK:' . $statusStartMsgs[$idx]);
         }
     }
     $statusStartMsgs[$idx] = '';
     wfConfig::set_ser('wfStatusStartMsgs', $statusStartMsgs);
 }
Esempio n. 3
0
 /**
  * @param int $userID
  */
 public function removeAdmin($userID)
 {
     $loggedAdmins = $this->getLoggedAdmins();
     if (array_key_exists($userID, $loggedAdmins) && !array_key_exists($userID, $this->getCurrentAdmins())) {
         unset($loggedAdmins[$userID]);
         wfConfig::set_ser('adminUserList', $loggedAdmins);
     }
 }
Esempio n. 4
0
 public function fork()
 {
     wordfence::status(4, 'info', "Entered fork()");
     if (wfConfig::set_ser('wfsd_engine', $this, true)) {
         wordfence::status(4, 'info', "Calling startScan(true)");
         self::startScan(true);
     }
     //Otherwise there was an error so don't start another scan.
     exit(0);
 }
Esempio n. 5
0
 private function updateSummaryItems()
 {
     global $wpdb;
     $dat = array();
     $users = $wpdb->get_col("SELECT {$wpdb->users}.ID FROM {$wpdb->users}");
     $dat['totalUsers'] = sizeof($users);
     $res1 = $wpdb->get_col("SELECT count(*) as cnt FROM {$wpdb->posts} where post_type='page' and post_status NOT IN ('auto-draft')");
     $dat['totalPages'] = $res1['0'];
     $res1 = $wpdb->get_col("SELECT count(*) as cnt FROM {$wpdb->posts} where post_type='post' and post_status NOT IN ('auto-draft')");
     $dat['totalPosts'] = $res1['0'];
     $res1 = $wpdb->get_col("SELECT count(*) as cnt FROM {$wpdb->comments}");
     $dat['totalComments'] = $res1['0'];
     $res1 = $wpdb->get_col("SELECT count(*) as cnt FROM {$wpdb->term_taxonomy} where taxonomy='category'");
     $dat['totalCategories'] = $res1['0'];
     $res1 = $wpdb->get_col("show tables");
     $dat['totalTables'] = sizeof($res1);
     $totalRows = 0;
     foreach ($res1 as $table) {
         $res2 = $wpdb->get_col("select count(*) from `{$table}`");
         if (isset($res2[0])) {
             $totalRows += $res2[0];
         }
     }
     $dat['totalRows'] = $totalRows;
     $arr = wfConfig::get_ser('wf_summaryItems', array());
     foreach ($dat as $key => $val) {
         $arr[$key] = $val;
     }
     wfConfig::set_ser('wf_summaryItems', $arr);
 }