Exemple #1
0
 public function webpageTextChecker()
 {
     $this->deleteOldFiles();
     $site = Files::fileToArray('sites.txt')[0];
     Curl::cookieCreation($site);
     $pageNumber = -1;
     $pages = self::clearPages();
     $pagesUnique = array_unique($pages);
     foreach ($pagesUnique as $page) {
         self::setTextForSearch($page);
         /* check if page does not start with
            slash then add it */
         if ($page[0] !== "/") {
             if (in_array("/{$page}", $pages)) {
                 continue;
             }
             $page = "/{$page}";
         }
         $textForSearch = self::getTextForSearch();
         $pageNumber++;
         $sitePage = $site . $page;
         echo count($pagesUnique) - $pageNumber . ".", $sitePage . "\n";
         $this->pageTextChecker($page, $pages, $site, $sitePage, $textForSearch);
     }
     $logFileName = 'ptc_log_';
     $log = $this->getLog();
     LogCreation::logFileCreator($log, $logFileName);
 }
Exemple #2
0
<?php

require_once '../helpers/Helpers.php';
use helpers\Helpers;
$dbLog = Files::csvToArray('logged_time.csv');
$heroLabels = Files::fileToArray('hero_labels.txt');
$groupByPerson = array();
//group by  person and sum log
foreach ($dbLog as $dbLogRow) {
    if (!array_key_exists($dbLogRow[1], $groupByPerson)) {
        $item = ['name' => $dbLogRow[1], 'time' => $dbLogRow[2]];
        $groupByPerson[$dbLogRow[1]] = $item;
    } else {
        $groupByPerson[$dbLogRow[1]]['time'] += $dbLogRow[2];
    }
}
//add percent to log from database
$dbLogPercent = $dbLog;
foreach ($dbLogPercent as &$dbLogPercRow) {
    foreach ($groupByPerson as $groupByPersonRow) {
        if ($dbLogPercRow[1] == $groupByPersonRow['name']) {
            $dbLogPercRow['%'] = round($dbLogPercRow[2] * 100 / $groupByPersonRow['time'], 2) . '%';
        } elseif (!in_array($dbLogPercRow[0], $heroLabels)) {
            $dbLogPercRow[0] = 'Else';
        }
    }
}
unset($dbLogPercRow);
//create array with people from dbLog
$people = array();
foreach ($dbLogPercent as $dbLogPercKey => $dbLogPercRow) {
Exemple #3
0
 public function websiteTextChecker()
 {
     self::deleteOldFiles();
     $sites = Files::fileToArray('sites.txt');
     $pagesFromFile = Files::fileToArray('pages.txt');
     $siteNumber = -1;
     $textForSearch = Files::fileToArray('text_for_search.txt');
     foreach ($sites as $site) {
         $site = InputInfoValidator::siteNameValidator($site);
         if (!is_null(GetAllHrefs::getOptsForPages())) {
             options:
             GetAllHrefs::setOptsForPages();
         }
         if (in_array(GetAllHrefs::getOptsForPages(), array(1, 3))) {
             if (!isset($checkBlog)) {
                 $checkBlog = GetAllHrefs::setCheckBlog();
             }
             Curl::cookieCreation($site);
             $sitePage = $site;
             $curlForLinks = Curl::getCurlResult($sitePage)[0];
             $pages = GetAllHrefs::getHrefs($site, $curlForLinks);
             if (GetAllHrefs::getOptsForPages() == 3) {
                 $pagesCurl = $pages;
                 $pages = array_merge($pagesCurl, $pagesFromFile);
             }
         } elseif (GetAllHrefs::getOptsForPages() == 2) {
             Curl::cookieCreation($site);
             $pages = $pagesFromFile;
         } else {
             goto options;
         }
         $pageNumber = -1;
         $siteNumber++;
         foreach ($pages as $key => &$page) {
             $pageNumber++;
             if (strpos($page, $site) == TRUE) {
                 $sitePage = $page;
             } else {
                 /* check if page does not start with
                    slash then add it */
                 if ($page[0] !== "/") {
                     if (in_array("/{$page}", $pages)) {
                         continue;
                     }
                     $page = "/{$page}";
                 }
                 $sitePage = "{$site}{$page}";
             }
             #counter for pages, which are being checker
             echo count($sites) - $siteNumber . ".", count($pages) - $pageNumber . ".", $sitePage . "\n";
             self::pageTextChecker($page, $pages, $site, $sitePage, $textForSearch);
         }
     }
     $logFileName = 'wtc_log_';
     $log = $this->log;
     LogCreation::logFileCreator($log, $logFileName);
 }