예제 #1
0
파일: index.php 프로젝트: Satariall/izurit
 function InstallDB($arParams = array())
 {
     global $DBType, $APPLICATION;
     $node_id = strlen($arParams["DATABASE"]) > 0 ? intval($arParams["DATABASE"]) : false;
     if ($node_id !== false) {
         $DB = $GLOBALS["DB"]->GetDBNodeConnection($node_id);
     } else {
         $DB = $GLOBALS["DB"];
     }
     $this->errors = false;
     $arAllErrors = array();
     // check if module was deinstalled without table save
     $DATE_INSTALL_TABLES = "";
     $no_tables = "N";
     if (!$DB->Query("SELECT count('x') FROM b_stat_day WHERE 1=0", true)) {
         // last installation date have to be current
         $DATE_INSTALL_TABLES = date("d.m.Y H:i:s", time());
         $no_tables = "Y";
     }
     if ($no_tables == "Y") {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/install/db/" . strtolower($DB->type) . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     RegisterModule("statistic");
     RegisterModuleDependences("main", "OnPageStart", "statistic", "CStopList", "Check", "100");
     RegisterModuleDependences("main", "OnBeforeProlog", "statistic", "CStatistics", "Keep", "100");
     RegisterModuleDependences("main", "OnEpilog", "statistic", "CStatistics", "Set404", "100");
     RegisterModuleDependences("main", "OnBeforeProlog", "statistic", "CStatistics", "StartBuffer", "1000");
     RegisterModuleDependences("main", "OnAfterEpilog", "statistic", "CStatistics", "EndBuffer", "10");
     RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "statistic", "CStatistics", "GetAuditTypes", 10);
     RegisterModuleDependences("statistic", "OnCityLookup", "statistic", "CCityLookup_geoip_mod", "OnCityLookup", "100");
     RegisterModuleDependences("statistic", "OnCityLookup", "statistic", "CCityLookup_geoip_extension", "OnCityLookup", "200");
     RegisterModuleDependences("statistic", "OnCityLookup", "statistic", "CCityLookup_geoip_pure", "OnCityLookup", "300");
     RegisterModuleDependences("statistic", "OnCityLookup", "statistic", "CCityLookup_stat_table", "OnCityLookup", "400");
     RegisterModuleDependences("cluster", "OnGetTableList", "statistic", "statistic", "OnGetTableList");
     if (strlen($DATE_INSTALL_TABLES) > 0) {
         COption::SetOptionString("main", "INSTALL_STATISTIC_TABLES", $DATE_INSTALL_TABLES, "Date of installation of statistics module tables");
     }
     if ($node_id !== false) {
         COption::SetOptionString("statistic", "dbnode_id", $node_id);
         if (CModule::IncludeModule('cluster')) {
             CClusterDBNode::SetOnline($node_id);
         }
     } else {
         COption::SetOptionString("statistic", "dbnode_id", "N");
     }
     COption::SetOptionString("statistic", "dbnode_status", "ok");
     // init counters
     if (array_key_exists("allow_initial", $arParams) && $arParams["allow_initial"] == "Y") {
         $strSql = "SELECT ID FROM b_stat_day";
         $e = $DB->Query($strSql, false, $err_mess . __LINE__);
         if (!($er = $e->Fetch())) {
             if (intval($arParams["START_HITS"]) > 0 || intval($arParams["START_HOSTS"]) > 0 || intval($arParams["START_GUESTS"]) > 0) {
                 $arFields = array("DATE_STAT" => $DB->GetNowDate(), "HITS" => intval($arParams["START_HITS"]), "C_HOSTS" => intval($arParams["START_HOSTS"]), "GUESTS" => intval($arParams["START_GUESTS"]), "NEW_GUESTS" => intval($arParams["START_GUESTS"]));
                 $DB->Insert("b_stat_day", $arFields, $err_mess . __LINE__);
             }
         }
     }
     $arr = getdate();
     $ndate = mktime(0, 1, 0, $arr["mon"], $arr["mday"], $arr["year"]);
     CAgent::AddAgent("CStatistics::SetNewDay();", "statistic", "Y", 86400, "", "Y", ConvertTimeStamp($ndate + CTimeZone::GetOffset(), "FULL"), 200);
     $ndate = mktime(3, 0, 0, $arr["mon"], $arr["mday"], $arr["year"]);
     CAgent::AddAgent("CStatistics::CleanUpStatistics_1();", "statistic", "Y", 86400, "", "Y", ConvertTimeStamp($ndate + CTimeZone::GetOffset(), "FULL"), 50);
     $ndate = mktime(4, 0, 0, $arr["mon"], $arr["mday"], $arr["year"]);
     CAgent::AddAgent("CStatistics::CleanUpStatistics_2();", "statistic", "Y", 86400, "", "Y", ConvertTimeStamp($ndate + CTimeZone::GetOffset(), "FULL"), 30);
     CAgent::AddAgent("CStatistics::CleanUpSessionData();", "statistic", "N", 7200);
     CAgent::AddAgent("CStatistics::CleanUpPathCache();", "statistic", "N", 3600);
     CAgent::RemoveAgent("SendDailyStatistics();", "statistic");
     if (strpos($_SERVER["SERVER_SOFTWARE"], "(Win32)") <= 0) {
         $ndate = mktime(9, 0, 0, $arr["mon"], $arr["mday"], $arr["year"]);
         CAgent::AddAgent("SendDailyStatistics();", "statistic", "Y", 86400, "", "Y", ConvertTimeStamp($ndate + CTimeZone::GetOffset(), "FULL"), 25);
     }
     if ($no_tables == "Y") {
         $arAllErrors[] = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/install/db/" . strtolower($DB->type) . "/searchers.sql");
         $arAllErrors[] = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/install/db/" . strtolower($DB->type) . "/browsers.sql");
         $arAllErrors[] = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/install/db/" . strtolower($DB->type) . "/adv.sql");
     }
     // ip-to-country
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/ip_tools.php";
     i2c_load_countries();
     if (!array_key_exists("CREATE_I2C_INDEX", $arParams) || $arParams["CREATE_I2C_INDEX"] == "Y") {
         i2c_create_db($total_reindex, $reindex_success, $step_reindex, $int_prev);
     }
     $fname = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/statistic/install/db/" . strtolower($DB->type) . "/optimize.sql";
     if (file_exists($fname)) {
         $arAllErrors[] = $DB->RunSQLBatch($fname);
     }
     $this->errors = array();
     foreach ($arAllErrors as $ar) {
         if (is_array($ar)) {
             foreach ($ar as $strError) {
                 $this->errors[] = $strError;
             }
         }
     }
     if (count($this->errors) < 1) {
         $this->errors = false;
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     return true;
 }
예제 #2
0
파일: import.php 프로젝트: Satariall/izurit
 switch ($STEP) {
     case 0:
         echo GetMessage('STATWIZ_IMPORT_FILE_LOADING');
         echo "<script>Import(1)</script>";
         break;
     case 1:
         $fp = fopen($ABS_FILE_NAME, "r");
         if ($fp) {
             $file_type = CCity::GetCSVFormatType($fp);
         } else {
             $file_type = false;
         }
         if ($file_type === "IP-TO-COUNTRY") {
             i2c_create_db($total_reindex, $reindex_success, $step_reindex, $_SESSION["STATWIZ_INT_PREV"], 5, $FILE_NAME, "ip-to-country.com");
         } elseif ($file_type === "MAXMIND-IP-COUNTRY") {
             i2c_create_db($total_reindex, $reindex_success, $step_reindex, $_SESSION["STATWIZ_INT_PREV"], 5, $FILE_NAME, "maxmind.com");
         } elseif ($file_type === "MAXMIND-CITY-LOCATION") {
             $reindex_success = "Y";
         } elseif ($file_type === "MAXMIND-IP-LOCATION") {
             $reindex_success = "Y";
         } else {
             $reindex_success = "Y";
         }
         if ($reindex_success === "Y") {
             echo '<script>Import(2)</script>';
         } else {
             $_SESSION["STATWIZ_TOTAL_REINDEX"] = $total_reindex[0];
             echo "<script>Import(1, {file_position:'" . intval($total_reindex[1]) . "',AMOUNT:" . intval(filesize($ABS_FILE_NAME)) . ",POS:" . intval($total_reindex[1]) . "})</script>";
         }
         break;
     case 2: