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


PHP wfUtils::makeTimeAgo方法代码示例

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


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

示例1: getHits

 public function getHits($hitType, $type, $afterTime, $limit = 50, $IP = false)
 {
     $serverTime = $this->getDB()->querySingle("select unix_timestamp()");
     $IPSQL = "";
     if ($IP) {
         $IPSQL = " and IP=%s ";
         $sqlArgs = array($afterTime, wfUtils::inet_pton($IP), $limit);
     } else {
         $sqlArgs = array($afterTime, $limit);
     }
     if ($hitType == 'hits') {
         if ($type == 'hit') {
             $typeSQL = " ";
         } else {
             if ($type == 'crawler') {
                 $now = time();
                 $typeSQL = " and jsRun = 0 and {$now} - ctime > 30 ";
             } else {
                 if ($type == 'gCrawler') {
                     $typeSQL = " and isGoogle = 1 ";
                 } else {
                     if ($type == '404') {
                         $typeSQL = " and is404 = 1 ";
                     } else {
                         if ($type == 'human') {
                             $typeSQL = " and jsRun = 1 ";
                         } else {
                             if ($type == 'ruser') {
                                 $typeSQL = " and userID > 0 ";
                             } else {
                                 wordfence::status(1, 'error', "Invalid log type to wfLog: {$type}");
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         array_unshift($sqlArgs, "select * from " . $this->hitsTable . " where ctime > %f {$IPSQL} {$typeSQL} order by ctime desc limit %d");
         $results = call_user_func_array(array($this->getDB(), 'querySelect'), $sqlArgs);
     } else {
         if ($hitType == 'logins') {
             array_unshift($sqlArgs, "select * from " . $this->loginsTable . " where ctime > %f {$IPSQL} order by ctime desc limit %d");
             $results = call_user_func_array(array($this->getDB(), 'querySelect'), $sqlArgs);
         } else {
             wordfence::status(1, 'error', "getHits got invalid hitType: {$hitType}");
             return false;
         }
     }
     $this->resolveIPs($results);
     $ourURL = parse_url(site_url());
     $ourHost = strtolower($ourURL['host']);
     $ourHost = preg_replace('/^www\\./i', '', $ourHost);
     $browscap = new wfBrowscap();
     $advanced_blocking_results = $this->getDB()->querySelect('SELECT * FROM ' . $this->ipRangesTable);
     $advanced_blocking = array();
     foreach ($advanced_blocking_results as $advanced_blocking_row) {
         list($blocked_range) = explode('|', $advanced_blocking_row['blockString']);
         $blocked_range = explode('-', $blocked_range);
         if (count($blocked_range) == 2) {
             // Still using v5 32 bit int style format.
             if (!preg_match('/[\\.:]/', $blocked_range[0])) {
                 $blocked_range[0] = long2ip($blocked_range[0]);
                 $blocked_range[1] = long2ip($blocked_range[1]);
             }
             $advanced_blocking[] = array(wfUtils::inet_pton($blocked_range[0]), wfUtils::inet_pton($blocked_range[1]), $advanced_blocking_row['id']);
         }
     }
     foreach ($results as &$res) {
         $res['type'] = $type;
         $res['timeAgo'] = wfUtils::makeTimeAgo($serverTime - $res['ctime']);
         $res['blocked'] = $this->getDB()->querySingle("select blockedTime from " . $this->blocksTable . " where IP=%s and (permanent = 1 OR (blockedTime + %s > unix_timestamp()))", $res['IP'], wfConfig::get('blockedTime'));
         $res['rangeBlocked'] = false;
         $res['ipRangeID'] = -1;
         foreach ($advanced_blocking as $advanced_blocking_row) {
             if (strcmp($res['IP'], $advanced_blocking_row[0]) >= 0 && strcmp($res['IP'], $advanced_blocking_row[1]) <= 0) {
                 $res['rangeBlocked'] = true;
                 $res['ipRangeID'] = $advanced_blocking_row[2];
                 break;
             }
         }
         $res['IP'] = wfUtils::inet_ntop($res['IP']);
         $res['extReferer'] = false;
         if (isset($res['referer']) && $res['referer']) {
             if (wfUtils::hasXSS($res['referer'])) {
                 //filtering out XSS
                 $res['referer'] = '';
             }
         }
         if (isset($res['referer']) && $res['referer']) {
             $refURL = parse_url($res['referer']);
             if (is_array($refURL) && isset($refURL['host']) && $refURL['host']) {
                 $refHost = strtolower(preg_replace('/^www\\./i', '', $refURL['host']));
                 if ($refHost != $ourHost) {
                     $res['extReferer'] = true;
                     //now extract search terms
                     $q = false;
                     if (preg_match('/(?:google|bing|alltheweb|aol|ask)\\./i', $refURL['host'])) {
                         $q = 'q';
                     } else {
//.........这里部分代码省略.........
开发者ID:TomFarrow,项目名称:wordpress-stackable,代码行数:101,代码来源:wfLog.php

示例2: processGetHitsResults

 /**
  * @param string $type
  * @param array $results
  * @throws Exception
  */
 public function processGetHitsResults($type, &$results)
 {
     $serverTime = $this->getDB()->querySingle("select unix_timestamp()");
     $this->resolveIPs($results);
     $ourURL = parse_url(site_url());
     $ourHost = strtolower($ourURL['host']);
     $ourHost = preg_replace('/^www\\./i', '', $ourHost);
     $browscap = new wfBrowscap();
     $advanced_blocking_results = $this->getDB()->querySelect('SELECT * FROM ' . $this->ipRangesTable);
     $advanced_blocking = array();
     foreach ($advanced_blocking_results as $advanced_blocking_row) {
         list($blocked_range) = explode('|', $advanced_blocking_row['blockString']);
         $blocked_range = explode('-', $blocked_range);
         if (count($blocked_range) == 2) {
             // Still using v5 32 bit int style format.
             if (!preg_match('/[\\.:]/', $blocked_range[0])) {
                 $blocked_range[0] = long2ip($blocked_range[0]);
                 $blocked_range[1] = long2ip($blocked_range[1]);
             }
             $advanced_blocking[] = array(wfUtils::inet_pton($blocked_range[0]), wfUtils::inet_pton($blocked_range[1]), $advanced_blocking_row['id']);
         }
     }
     foreach ($results as &$res) {
         $res['type'] = $type;
         $res['timeAgo'] = wfUtils::makeTimeAgo($serverTime - $res['ctime']);
         $res['blocked'] = $this->getDB()->querySingle("select blockedTime from " . $this->blocksTable . " where IP=%s and (permanent = 1 OR (blockedTime + %s > unix_timestamp()))", $res['IP'], wfConfig::get('blockedTime'));
         $res['rangeBlocked'] = false;
         $res['ipRangeID'] = -1;
         foreach ($advanced_blocking as $advanced_blocking_row) {
             if (strcmp($res['IP'], $advanced_blocking_row[0]) >= 0 && strcmp($res['IP'], $advanced_blocking_row[1]) <= 0) {
                 $res['rangeBlocked'] = true;
                 $res['ipRangeID'] = $advanced_blocking_row[2];
                 break;
             }
         }
         $res['IP'] = wfUtils::inet_ntop($res['IP']);
         $res['extReferer'] = false;
         if (isset($res['referer']) && $res['referer']) {
             if (wfUtils::hasXSS($res['referer'])) {
                 //filtering out XSS
                 $res['referer'] = '';
             }
         }
         if (isset($res['referer']) && $res['referer']) {
             $refURL = parse_url($res['referer']);
             if (is_array($refURL) && isset($refURL['host']) && $refURL['host']) {
                 $refHost = strtolower(preg_replace('/^www\\./i', '', $refURL['host']));
                 if ($refHost != $ourHost) {
                     $res['extReferer'] = true;
                     //now extract search terms
                     $q = false;
                     if (preg_match('/(?:google|bing|alltheweb|aol|ask)\\./i', $refURL['host'])) {
                         $q = 'q';
                     } else {
                         if (stristr($refURL['host'], 'yahoo.')) {
                             $q = 'p';
                         } else {
                             if (stristr($refURL['host'], 'baidu.')) {
                                 $q = 'wd';
                             }
                         }
                     }
                     if ($q) {
                         $queryVars = array();
                         if (isset($refURL['query'])) {
                             parse_str($refURL['query'], $queryVars);
                             if (isset($queryVars[$q])) {
                                 $res['searchTerms'] = urlencode($queryVars[$q]);
                             }
                         }
                     }
                 }
             }
             if ($res['extReferer']) {
                 if (isset($referringPage) && stristr($referringPage['host'], 'google.')) {
                     parse_str($referringPage['query'], $queryVars);
                     // echo $queryVars['q']; // This is the search term used
                 }
             }
         }
         $res['browser'] = false;
         if ($res['UA']) {
             $b = $browscap->getBrowser($res['UA']);
             if ($b) {
                 $res['browser'] = array('browser' => !empty($b['Browser']) ? $b['Browser'] : "", 'version' => !empty($b['Version']) ? $b['Version'] : "", 'platform' => !empty($b['Platform']) ? $b['Platform'] : "", 'isMobile' => !empty($b['isMobileDevice']) ? $b['isMobileDevice'] : "", 'isCrawler' => !empty($b['Crawler']) ? $b['Crawler'] : "");
             }
         }
         if ($res['userID']) {
             $ud = get_userdata($res['userID']);
             if ($ud) {
                 $res['user'] = array('editLink' => wfUtils::editUserLink($res['userID']), 'display_name' => $res['display_name'], 'ID' => $res['userID']);
                 $res['user']['avatar'] = get_avatar($res['userID'], 16);
             }
         } else {
             $res['user'] = false;
//.........这里部分代码省略.........
开发者ID:ashenkar,项目名称:sanga,代码行数:101,代码来源:wfLog.php

示例3: getSummaryItems

 public function getSummaryItems()
 {
     if (!$this->updateCalled) {
         $this->updateCalled = true;
         $this->updateSummaryItems();
     }
     $arr = wfConfig::get_ser('wf_summaryItems', array());
     //$arr['scanTimeAgo'] = wfUtils::makeTimeAgo(sprintf('%.0f', time() - $arr['scanTime']));
     $arr['scanRunning'] = wfUtils::isScanRunning() ? '1' : '0';
     $arr['scheduledScansEnabled'] = wfConfig::get('scheduledScansEnabled');
     $secsToGo = wp_next_scheduled('wordfence_scheduled_scan') - time();
     if ($secsToGo < 1) {
         $nextRun = 'now';
     } else {
         $nextRun = wfUtils::makeTimeAgo($secsToGo) . ' from now';
     }
     $arr['nextRun'] = $nextRun;
     $arr['totalCritical'] = $this->getDB()->querySingle("select count(*) as cnt from " . $this->issuesTable . " where status='new' and severity=1");
     $arr['totalWarning'] = $this->getDB()->querySingle("select count(*) as cnt from " . $this->issuesTable . " where status='new' and severity=2");
     return $arr;
 }
开发者ID:ashenkar,项目名称:sanga,代码行数:21,代码来源:wfIssues.php

示例4:

    ?>
7&dir=<?php 
    echo $sortIDX == 7 && $sortDir == 'fwd' ? 'rev' : 'fwd';
    ?>
">Permissions</a></th>
	<th><a href="<?php 
    echo $sortLink;
    ?>
1&dir=<?php 
    echo $sortIDX == 1 && $sortDir == 'fwd' ? 'rev' : 'fwd';
    ?>
">Full file path</a></th>
</tr>
<?php 
    for ($i = 0; $i < sizeof($files); $i++) {
        echo '<tr><td>' . wfUtils::formatBytes($files[$i][2]) . '</td><td>' . wfUtils::makeTimeAgo(time() - $files[$i][3]) . ' ago.</td><td>' . $files[$i][5] . '</td><td>' . $files[$i][6] . '</td><td>' . $files[$i][7] . '</td><td><a href="' . $files[$i][4] . '" target="_blank">' . $files[$i][1] . '</a></td></tr>';
    }
    echo "</table>";
} else {
    ?>
<p style="margin: 40px; font-size: 20px;">
	You either have not completed a scan recently, or there were no files found on your system that are not in the WordPress official repository for Core files, themes and plugins.
</p>
<?php 
}
?>

<div class="diffFooter">&copy;&nbsp;2011 Wordfence &mdash; Visit <a href="http://wordfence.com/">Wordfence.com</a> for help, security updates and more.</a>
</body>
</html>
开发者ID:roycocup,项目名称:enclothed,代码行数:30,代码来源:unknownFiles.php

示例5: getHits

 public function getHits($hitType, $type, $afterTime, $limit = 50, $IP = false)
 {
     $serverTime = $this->getDB()->querySingle("select unix_timestamp()");
     $IPSQL = "";
     if ($IP) {
         $IPSQL = " and IP=INET_ATON(%s) ";
         $sqlArgs = array($afterTime, $IP, $limit);
     } else {
         $sqlArgs = array($afterTime, $limit);
     }
     if ($hitType == 'hits') {
         if ($type == 'hit') {
             $typeSQL = " ";
         } else {
             if ($type == 'crawler') {
                 $now = time();
                 $typeSQL = " and jsRun = 0 and {$now} - ctime > 30 ";
             } else {
                 if ($type == 'gCrawler') {
                     $typeSQL = " and isGoogle = 1 ";
                 } else {
                     if ($type == '404') {
                         $typeSQL = " and is404 = 1 ";
                     } else {
                         if ($type == 'human') {
                             $typeSQL = " and jsRun = 1 ";
                         } else {
                             if ($type == 'ruser') {
                                 $typeSQL = " and userID > 0 ";
                             } else {
                                 wordfence::status(1, 'error', "Invalid log type to wfLog: {$type}");
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
         array_unshift($sqlArgs, "select * from " . $this->hitsTable . " where ctime > %f {$IPSQL} {$typeSQL} order by ctime desc limit %d");
         $results = call_user_func_array(array($this->getDB(), 'querySelect'), $sqlArgs);
     } else {
         if ($hitType == 'logins') {
             array_unshift($sqlArgs, "select * from " . $this->loginsTable . " where ctime > %f {$IPSQL} order by ctime desc limit %d");
             $results = call_user_func_array(array($this->getDB(), 'querySelect'), $sqlArgs);
         } else {
             wordfence::status(1, 'error', "getHits got invalid hitType: {$hitType}");
             return false;
         }
     }
     $this->resolveIPs($results);
     $ourURL = parse_url(site_url());
     $ourHost = strtolower($ourURL['host']);
     $ourHost = preg_replace('/^www\\./i', '', $ourHost);
     $browscap = new wfBrowscap();
     foreach ($results as &$res) {
         $res['type'] = $type;
         $res['timeAgo'] = wfUtils::makeTimeAgo($serverTime - $res['ctime']);
         $res['blocked'] = $this->getDB()->querySingle("select blockedTime from " . $this->blocksTable . " where IP=%s and (permanent = 1 OR (blockedTime + %s > unix_timestamp()))", $res['IP'], wfConfig::get('blockedTime'));
         $res['IP'] = wfUtils::inet_ntoa($res['IP']);
         $res['extReferer'] = false;
         if (isset($res['referer']) && $res['referer']) {
             if (!preg_match('/^https?:\\/\\/[a-z0-9\\.\\-]+\\/[^\':<>\\"\\\\]*$/i', $res['referer'])) {
                 //filtering out XSS
                 $res['referer'] = '';
             }
         }
         if (isset($res['referer']) && $res['referer']) {
             $refURL = parse_url($res['referer']);
             if (is_array($refURL) && isset($refURL['host']) && $refURL['host']) {
                 $refHost = strtolower(preg_replace('/^www\\./i', '', $refURL['host']));
                 if ($refHost != $ourHost) {
                     $res['extReferer'] = true;
                     //now extract search terms
                     $q = false;
                     if (preg_match('/(?:google|bing|alltheweb|aol|ask)\\./i', $refURL['host'])) {
                         $q = 'q';
                     } else {
                         if (stristr($refURL['host'], 'yahoo.')) {
                             $q = 'p';
                         } else {
                             if (stristr($refURL['host'], 'baidu.')) {
                                 $q = 'wd';
                             }
                         }
                     }
                     if ($q) {
                         $queryVars = array();
                         if (isset($refURL['query'])) {
                             parse_str($refURL['query'], $queryVars);
                             if (isset($queryVars[$q])) {
                                 $res['searchTerms'] = $queryVars[$q];
                             }
                         }
                     }
                 }
             }
             if ($res['extReferer']) {
                 if (isset($referringPage) && stristr($referringPage['host'], 'google.')) {
                     parse_str($referringPage['query'], $queryVars);
                     echo $queryVars['q'];
//.........这里部分代码省略.........
开发者ID:christocmp,项目名称:bingopaws,代码行数:101,代码来源:wfLog.php


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