Ejemplo n.º 1
0
         $geoList = strlen($geo) > 0 ? preg_split("/[^0-9\\-]+\\s*/", $geo) : array();
         $phraseHash = md5(implode('|', $phraseList) . '|||' . $geo);
         if (!isset($_SESSION["SEO_REPORTS"])) {
             $_SESSION["SEO_REPORTS"] = array();
         }
         sortByColumn($_SESSION["SEO_REPORTS"], "TS");
         foreach ($_SESSION["SEO_REPORTS"] as $k => $report) {
             $lifeTime = time() - $report["TS"];
             if ($lifeTime > Engine\YandexDirect::TTL_WORDSTAT_REPORT && $lifeTime < Engine\YandexDirect::TTL_WORDSTAT_REPORT_EXT || count($_SESSION["SEO_REPORTS"]) >= Engine\YandexDirect::MAX_WORDSTAT_REPORTS) {
                 $reportId = $report["REPORT_ID"];
                 $engine->deleteWordstatReport($reportId);
                 unset($_SESSION["SEO_REPORTS"][$k]);
             }
         }
         if (!isset($_SESSION["SEO_REPORTS"][$phraseHash])) {
             $reportId = $engine->createWordstatReport($phraseList, $geoList);
             $_SESSION["SEO_REPORTS"][$phraseHash] = array("REPORT_ID" => intval($reportId), "PHRASE" => $phraseList, "GEO" => $geoList, "TS" => time());
             $res = $_SESSION["SEO_REPORTS"][$phraseHash];
         } else {
             $reportId = $_SESSION["SEO_REPORTS"][$phraseHash]["REPORT_ID"];
             $res = $engine->getWordstatReport($reportId);
         }
     }
     break;
 case 'forecast_report_clear':
 case 'forecast_report':
     if ($_REQUEST['action'] == 'forecast_report_clear') {
         $reportList = $engine->getForecastReportList();
         if (count($reportList) >= Engine\YandexDirect::MAX_FORECAST_REPORTS) {
             foreach ($reportList as $firstReport) {
                 $engine->deleteForecastReport($firstReport["ForecastID"]);