$geoList = strlen($geo) > 0 ? preg_split("/[^0-9\\-]+\\s*/", $geo) : array(); $phraseHash = md5(implode('|', $phraseList) . '|||' . $geo); if (!isset($_SESSION["SEO_FORECASTS"])) { $_SESSION["SEO_FORECASTS"] = array(); } sortByColumn($_SESSION["SEO_FORECASTS"], "TS"); foreach ($_SESSION["SEO_FORECASTS"] as $k => $report) { $lifeTime = time() - $report["TS"]; if ($lifeTime > Engine\YandexDirect::TTL_FORECAST_REPORT && $lifeTime < Engine\YandexDirect::TTL_FORECAST_REPORT_EXT || count($_SESSION["SEO_FORECASTS"]) >= Engine\YandexDirect::MAX_FORECAST_REPORTS) { $reportId = $report["REPORT_ID"]; $engine->deleteForecastReport($reportId); unset($_SESSION["SEO_FORECASTS"][$k]); } } if (!isset($_SESSION["SEO_FORECASTS"][$phraseHash])) { $reportId = $engine->createForecastReport($phraseList, $geoList); $_SESSION["SEO_FORECASTS"][$phraseHash] = array("REPORT_ID" => intval($reportId), "PHRASE" => $phraseList, "GEO" => $geoList, "TS" => time()); $res = $_SESSION["SEO_FORECASTS"][$phraseHash]; } else { $reportId = $_SESSION["SEO_FORECASTS"][$phraseHash]["REPORT_ID"]; $res = $engine->getForecastReport($reportId); } } break; case 'campaign_update': $campaignId = intval($_REQUEST['campaign']); $res = $engine->updateCampaignManual($campaignId); break; case 'banner_update': $bannerId = intval($_REQUEST['banner']); $campaignId = intval($_REQUEST['campaign']);