<?php require __DIR__ . '/lib.php'; $c = 0; do { $data = read_queue(); if ($data) { define('SAVE_DIRNAME', $data); $lpath = build_data_path($data, 'input_left'); $rpath = build_data_path($data, 'input_right'); $left = read_as_array($lpath, true); $right = read_as_array($rpath, true); $left = process_array($left); $right = process_array($right); $type_list = array(TYPE_SAME, TYPE_DIFFERENT, TYPE_LEFT_ONLY, TYPE_RIGHT_ONLY); foreach ($type_list as $type) { $result = compare($type, $left, $right); save_result($type, $result); } } else { usleep(100); } } while (++$c < 10000);
EOF; $test_page->results_body = <<<EOF <h3>Personeelstest - Verstuurd</h3> <p>Bedankt voor het invullen van deze test!</p> EOF; $test_page->advice_function = function ($score) { $reverse_questions = [0, 7, 11, 16, 21, 24, 25, 27, 31, 33, 37, 40, 42, 45, 47, 49, 54, 55]; $total_score = 0; for ($i = 0; $i < 56; $i++) { if (in_array($i, $reverse_questions)) { $total_score += 5 - $score[$i]; } else { $total_score += $score[$i]; } } save_result($_GET['organisatie'], $_GET['code'], $score); return ''; }; $test_page->create('personeel'); } else { include '../resources/includes/PageCreator.php'; $page = new PageCreator(); $page->path_to_root = '../'; $page->head = '<link rel="stylesheet" href="resources/css/specific/information.css" type="text/css">'; $page->title = "Personeelstest Burn-out"; $page->body = <<<CONTENT <div class="content"> <div class="menuSpacing"></div> <div class="indexImage">
function Main($depth, $url, $keywords, $site, $time_1, $delay) { global $result_tablename, $site_tablename, $searchRequire, $iterationBool, $searchBool, $user_id, $delta; $count = count($keywords); foreach ($keywords as $value) { // echo $value; // echo "<br/>"; //-------------------определение необходимости поиска("поиск сегодня осуществлялся") $keyword = $value; $seacher = $url; $query = "SELECT keyword_id FROM {$site_tablename} WHERE site = '{$site}' AND user_id = '{$user_id}' AND keyword = '{$keyword}'"; $result = mysql_query($query); if (!$result) { error_message(mysql_error()); } $query_data = mysql_fetch_array($result); $keyword_id = $query_data['keyword_id']; $query = "SELECT accessdate, position, url FROM {$result_tablename} WHERE keyword_id = '{$keyword_id}' AND seacher = '{$seacher}' ORDER BY accessdate DESC"; //$site = iconv('windows-1251', 'utf-8', $site); $result = mysql_query($query); if (!$result) { error_message(mysql_error()); } //Определяем необходимость поиска берем первую запись----------- $query_data = mysql_fetch_array($result); $accessdate = $query_data['accessdate']; $position = $query_data['position']; $urlDB = $query_data['url']; //$urlDB = iconv('windows-1251', 'utf-8', $urlDB); //сайт еще ниразу не искался $firstSeaching = 1 $firstSeaching = $position ? NULL : 1; //отменено зимнее время // $todayU = intval(date("U")) + (!date('I')) * 60 * 60; $todayU = intval(date("U")); $accessU = intval(strtotime($accessdate)); $diff = $todayU - $accessU; $searchBool = 0; //перерыв между поисками 12 часов if ($diff > $delta) { $searchBool = 1; $searchRequire = 1; } //-------------------------------------------------------------- //Определяем последний найденый результат $position_first = $urlDB ? $position : NULL; $urlDB_first = $urlDB; for ($i = 1; $i < mysql_num_rows($result); $i++) { $query_data = mysql_fetch_array($result); $position = $query_data['position']; $urlDB = $query_data['url']; if ($urlDB) { $positionOld = $position; break; } } //--------------------------------------------- if ($searchBool == 1) { //-----------------Определяем переменные------------------- //$str_query = str_replace(" ","+",$value); $str_query = urlencode($value); $url_str = "http://www." . $url . "/search?q=" . $str_query . "&sclient=psy-ab&hl=ru"; //--------------------------------------------------------- $data = iteration($depth, $url, $url_str, $value, $site, $str_query, $delay, $position_first, $positionOld, $urlDB_first, $firstSeaching); unset($positionOld); $iterationBool = 1; //echo $value."</br>"; //print_r($data); save_result($url, $depth, $data); } $time_2 = time(); //time_execution($time_1,$time_2); $time_1 = $time_2; for ($g = 0; $g < 1; $g++) { flush(); } //Задержка для всех keywords, кроме последнего if ($searchBool == 1) { if ($keywords[$count - 1] != $value) { sleep($delay[0] + rand(0, $delay[1])); } } } return $time_2; }
function parser($url, $url_str, $keyword) { global $sites; $response = curl($url_str, $url); //подключаем регулярные выражения поиска сайтов и навигации require 'google_regexp.php'; if (count($matches[0]) == 0) { preg_match_all('/<input type="hidden" name="id" value="([^>]+?)">/i', $response, $matches); //Value of Input.id $id = $matches[1][0]; preg_match_all('/<input type="hidden" name="continue" value="([^>]+?)">/i', $response, $matches); //Value of Input.continue $continue = $matches[1][0]; if ($id && $continue) { // т.е страница с капчей echo 0; exit; } else { $statistic[] = array($keyword, 'Sites not found', null, null, null); save_result($statistic); return 0; } } foreach ($matches_nav[1] as $i => $v) { $href_nav[$page_nav[1][$i]] = "http://www." . $url . $v; } foreach ($matches[1] as $v) { preg_match('/^(www.)?([^\\/]+)/i', $v, $matchesSite); $punycode = $matchesSite[2]; //$idn = new idna_convert(array('idn_version'=>2008)); //$punycode = (stripos($punycode, 'xn--')!==false) ? $idn->decode($punycode) : $idn->encode($punycode); $href[] = $punycode; } //удаляем отпарсеные сайты $href = array_diff($href, $sites); $href = array_unique($href); //Поиск адресов по сайтам foreach ($href as $value) { $statistic[] = searchAdress($value, $keyword); } save_result($statistic); $sites = array_merge((array) $sites, (array) $href); if (is_array($href_nav)) { return $href_nav; } else { $statistic[] = array($keyword, 'Sites not found', null, null, null); save_result($statistic); return 0; } }