function getCalendarSource($src)
 {
     if (strposu($src, '@') === false) {
         $src .= "@group.v.calendar.google.com";
     }
     return $src;
 }
Example #2
0
 function getLocation()
 {
     $uri = $_SERVER["REQUEST_URI"];
     return rawurldecode(($pos = strposu($uri, '?')) ? substru($uri, 0, $pos) : $uri);
 }
Example #3
0
 function analyseRequests($days, $path, $fileNames)
 {
     $this->yellow->toolbox->timerStart($time);
     $this->views = 0;
     if (!empty($fileNames)) {
         $statusCode = 200;
         $sites = $content = $errors = $visitors = array();
         $timeStop = time() - 60 * 60 * 24 * $days;
         $locationSelf = $this->yellow->config->get("serverBase");
         $locationIgnore = $this->yellow->config->get("statsLocationIgnore");
         $spamFilter = $this->yellow->config->get("statsSpamFilter");
         foreach ($fileNames as $fileName) {
             if (defined("DEBUG") && DEBUG >= 1) {
                 echo "YellowStats::analyseRequests file:{$fileName}\n";
             }
             $fileHandle = @fopen($fileName, "r");
             if ($fileHandle) {
                 $filePos = filesize($fileName) - 1;
                 $fileTop = -1;
                 while (($line = $this->getFileLinePrevious($fileHandle, $filePos, $fileTop, $dataBuffer)) !== false) {
                     if (preg_match("/^(\\S+) (\\S+) (\\S+) \\[(.+)\\] \"(\\S+) (.*?) (\\S+)\" (\\S+) (\\S+) \"(.*?)\" \"(.*?)\"\$/", $line, $matches)) {
                         list($line, $ip, $dummy1, $dummy2, $timestamp, $method, $location, $protocol, $status, $size, $referer, $userAgent) = $matches;
                         if (strtotime($timestamp) < $timeStop) {
                             break;
                         }
                         $location = rawurldecode(($pos = strposu($location, '?')) ? substru($location, 0, $pos) : $location);
                         $visitorRequestThrottle = substru($timestamp, 0, 17) . $method . $location;
                         if ($visitors[$ip] == $visitorRequestThrottle) {
                             continue;
                         }
                         $visitors[$ip] = $visitorRequestThrottle;
                         if ($this->checkRequestArguments($location, $referer)) {
                             if (!preg_match("#^{$locationSelf}#", $location)) {
                                 continue;
                             }
                             if (preg_match("#^{$locationSelf}(.*)/({$locationIgnore})/#", $location)) {
                                 continue;
                             }
                             if (preg_match("#^{$locationSelf}(.*)/robots.txt\$#", $location)) {
                                 continue;
                             }
                             if (preg_match("#(bot|spider)#", $userAgent)) {
                                 continue;
                             }
                             if (preg_match("#{$spamFilter}#", $line)) {
                                 continue;
                             }
                             if ($status >= 301 && $status <= 303) {
                                 continue;
                             }
                             if ($status < 400) {
                                 ++$content[$this->getUrl($location)];
                                 ++$sites[$this->getReferer($referer)];
                                 ++$this->views;
                             } else {
                                 ++$errors[$this->getUrl($location) . " - " . $this->getErrorFormatted($status)];
                             }
                         }
                     }
                 }
                 fclose($fileHandle);
             } else {
                 $statusCode = 500;
                 echo "ERROR reading logfiles: Can't read file '{$fileName}'!\n";
             }
         }
         if ($statusCode == 200) {
             unset($sites["-"]);
             $this->showRequests($sites, "Referring sites");
             $this->showRequests($content, "Popular content");
             $this->showRequests($errors, "Error pages");
         }
     } else {
         $statusCode = 500;
         echo "ERROR reading logfiles: Can't find files in directory '{$path}'!\n";
     }
     $this->yellow->toolbox->timerStop($time);
     if (defined("DEBUG") && DEBUG >= 1) {
         echo "YellowStats::analyseRequests time:{$time} ms\n";
     }
     return $statusCode;
 }
Example #4
0
 function getLocation($uri)
 {
     $uri = preg_replace_callback("#(\\\\x[0-9a-f]{2})#", function ($matches) {
         return chr(hexdec($matches[1]));
     }, $uri);
     return rawurldecode(($pos = strposu($uri, '?')) ? substru($uri, 0, $pos) : $uri);
 }