当前位置: 首页>>代码示例>>PHP>>正文


PHP wfUtils::makeDuration方法代码示例

本文整理汇总了PHP中wfUtils::makeDuration方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::makeDuration方法的具体用法?PHP wfUtils::makeDuration怎么用?PHP wfUtils::makeDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wfUtils的用法示例。


在下文中一共展示了wfUtils::makeDuration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

?>
"/> 0 or empty means unlimited
						issues will be sent.
					</td>
				</tr>
				<tr>
					<th>Time limit that a scan can run in seconds.<a
							href="http://docs.wordfence.com/en/Wordfence_options#Time_limit_that_a_scan_can_run_in_seconds"
							target="_blank" class="wfhelp"></a></th></th>
					<td>
						<input type="text" name="scan_maxDuration" id="scan_maxDuration"
							   value="<?php 
$w->f('scan_maxDuration');
?>
"/> 0 or empty means the default of <?php 
echo wfUtils::makeDuration(WORDFENCE_DEFAULT_MAX_SCAN_TIME);
?>
 will be used.
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div class="wfMarker" id="wfMarkerFirewallRules"></div>
						<h3 class="wfConfigHeading">Rate Limiting Rules<a
								href="http://docs.wordfence.com/en/Wordfence_options#Rate_Limiting_Rules" target="_blank"
								class="wfhelp"></a></h3>
					</td>
				</tr>
				<tr>
					<th>Immediately block fake Google crawlers:<a
							href="http://docs.wordfence.com/en/Wordfence_options#Immediately_block_fake_Google_crawlers:"
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:31,代码来源:menu_options.php

示例2: processAttackData

    /**
     *
     */
    public static function processAttackData()
    {
        global $wpdb;
        $waf = wfWAF::getInstance();
        if ($waf->getStorageEngine()->getConfig('attackDataKey', false) === false) {
            $waf->getStorageEngine()->setConfig('attackDataKey', mt_rand(0, 0xfff));
        }
        //Send alert email if needed
        if (wfConfig::get('wafAlertOnAttacks')) {
            $alertInterval = wfConfig::get('wafAlertInterval', 0);
            $cutoffTime = max(time() - $alertInterval, wfConfig::get('wafAlertLastSendTime'));
            $wafAlertWhitelist = wfConfig::get('wafAlertWhitelist', '');
            $wafAlertWhitelist = preg_split("/[,\r\n]+/", $wafAlertWhitelist);
            foreach ($wafAlertWhitelist as $index => &$entry) {
                $entry = trim($entry);
                if (!preg_match('/^(?:\\d{1,3}(?:\\.|$)){4}/', $entry) && !preg_match('/^((?:[\\da-f]{1,4}(?::|)){0,8})(::)?((?:[\\da-f]{1,4}(?::|)){0,8})$/i', $entry)) {
                    unset($wafAlertWhitelist[$index]);
                    continue;
                }
                $packed = @wfUtils::inet_pton($entry);
                if ($packed === false) {
                    unset($wafAlertWhitelist[$index]);
                    continue;
                }
                $entry = bin2hex($packed);
            }
            $wafAlertWhitelist = array_filter($wafAlertWhitelist);
            $attackData = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->base_prefix}wfHits\n\tWHERE action = 'blocked:waf' " . (count($wafAlertWhitelist) ? "AND HEX(IP) NOT IN (" . implode(", ", array_fill(0, count($wafAlertWhitelist), '%s')) . ")" : "") . "AND attackLogTime > %.6f\n\tORDER BY attackLogTime DESC\n\tLIMIT 10", array_merge($wafAlertWhitelist, array($cutoffTime))));
            $attackCount = $wpdb->get_var('SELECT FOUND_ROWS()');
            if ($attackCount >= wfConfig::get('wafAlertThreshold')) {
                $durationMessage = wfUtils::makeDuration($alertInterval);
                $message = <<<ALERTMSG
The Wordfence Web Application Firewall has blocked {$attackCount} attacks over the last {$durationMessage}. Below is a sample of these recent attacks:


ALERTMSG;
                $attackTable = array();
                $dateMax = $ipMax = $countryMax = 0;
                foreach ($attackData as $row) {
                    $row->longDescription = "Blocked for " . $row->actionDescription;
                    $actionData = json_decode($row->actionData, true);
                    if (!is_array($actionData) || !isset($actionData['paramKey']) || !isset($actionData['paramValue'])) {
                        continue;
                    }
                    $paramKey = base64_decode($actionData['paramKey']);
                    $paramValue = base64_decode($actionData['paramValue']);
                    if (strlen($paramValue) > 100) {
                        $paramValue = substr($paramValue, 0, 100) . chr(2026);
                    }
                    if (preg_match('/([a-z0-9_]+\\.[a-z0-9_]+)(?:\\[(.+?)\\](.*))?/i', $paramKey, $matches)) {
                        switch ($matches[1]) {
                            case 'request.queryString':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in query string: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.body':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in POST body: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.cookie':
                                $row->longDescription = "Blocked for " . $row->actionDescription . ' in cookie: ' . $matches[2] . '=' . $paramValue;
                                break;
                            case 'request.fileNames':
                                $row->longDescription = "Blocked for a " . $row->actionDescription . ' in file: ' . $matches[2] . '=' . $paramValue;
                                break;
                        }
                    }
                    $date = date_i18n('F j, Y g:ia', floor($row->attackLogTime));
                    $dateMax = max(strlen($date), $dateMax);
                    $ip = wfUtils::inet_ntop($row->IP);
                    $ipMax = max(strlen($ip), $ipMax);
                    $country = wfUtils::countryCode2Name(wfUtils::IP2Country($ip));
                    $country = empty($country) ? 'Unknown' : $country;
                    $countryMax = max(strlen($country), $countryMax);
                    $attackTable[] = array('date' => $date, 'IP' => $ip, 'country' => $country, 'message' => $row->longDescription);
                }
                foreach ($attackTable as $row) {
                    $date = str_pad($row['date'], $dateMax + 2);
                    $ip = str_pad($row['IP'] . " ({$row['country']})", $ipMax + $countryMax + 8);
                    $attackMessage = $row['message'];
                    $message .= $date . $ip . $attackMessage . "\n";
                }
                self::alert('Increased Attack Rate', $message, false);
                wfConfig::set('wafAlertLastSendTime', time());
            }
        }
        //Send attack data
        $limit = 500;
        $lastSendTime = wfConfig::get('lastAttackDataSendTime');
        $attackData = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->base_prefix}wfHits\nWHERE action in ('blocked:waf', 'learned:waf', 'logged:waf', 'blocked:waf-always')\nAND attackLogTime > %.6f\nLIMIT %d", $lastSendTime, $limit));
        $totalRows = $wpdb->get_var('SELECT FOUND_ROWS()');
        if ($attackData && wfConfig::get('other_WFNet', true)) {
            $response = wp_remote_get(sprintf(WFWAF_API_URL_SEC . "waf-rules/%d.txt", $waf->getStorageEngine()->getConfig('attackDataKey')));
            if (!is_wp_error($response)) {
                $okToSendBody = wp_remote_retrieve_body($response);
                if ($okToSendBody === 'ok') {
                    // Build JSON to send
                    $dataToSend = array();
                    $attackDataToUpdate = array();
//.........这里部分代码省略.........
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:101,代码来源:wordfenceClass.php

示例3: doScan

 private function doScan()
 {
     if (wfConfig::get('lowResourceScansEnabled')) {
         $isFork = $_GET['isFork'] == '1' ? true : false;
         wfConfig::set('lowResourceScanWaitStep', !wfConfig::get('lowResourceScanWaitStep'));
         if ($isFork && wfConfig::get('lowResourceScanWaitStep')) {
             sleep($this->maxExecTime / 2);
             $this->fork();
             //exits
         }
     }
     while (sizeof($this->jobList) > 0) {
         self::checkForKill();
         $jobName = $this->jobList[0];
         $callback = array($this, 'scan_' . $jobName);
         if (is_callable($callback)) {
             call_user_func($callback);
         }
         array_shift($this->jobList);
         //only shift once we're done because we may pause halfway through a job and need to pick up where we left off
         self::checkForKill();
         if ($this->forkRequested) {
             $this->fork();
         } else {
             $this->forkIfNeeded();
         }
     }
     $summary = $this->i->getSummaryItems();
     $this->status(1, 'info', '-------------------');
     $this->status(1, 'info', "Scan Complete. Scanned " . $summary['totalFiles'] . " files, " . $summary['totalPlugins'] . " plugins, " . $summary['totalThemes'] . " themes, " . ($summary['totalPages'] + $summary['totalPosts']) . " pages, " . $summary['totalComments'] . " comments and " . $summary['totalRows'] . " records in " . wfUtils::makeDuration(time() - $this->startTime, true) . ".");
     if ($this->i->totalIssues > 0) {
         $this->status(10, 'info', "SUM_FINAL:Scan complete. You have " . $this->i->totalIssues . " new issues to fix. See below.");
     } else {
         $this->status(10, 'info', "SUM_FINAL:Scan complete. Congratulations, no problems found.");
     }
     return;
 }
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:37,代码来源:wfScanEngine.php


注:本文中的wfUtils::makeDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。