1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
stoplist.php
См. документацию.
1<?php
3
5{
6 public static function GetByID($STOPLIST_ID)
7 {
8 $STOPLIST_ID = intval($STOPLIST_ID);
9 if($STOPLIST_ID <= 0)
10 return false;
11
13 "ID" => $STOPLIST_ID,
14 "ID_EXACT_MATCH" => "Y",
15 );
16 $rs = CStopList::GetList('', '', $arFilter);
17
18 return $rs;
19 }
20
22 {
23 $DB = CDatabase::GetModuleConnection('statistic');
24
25 $aMsg = array();
26
27 $arFields["TEST"] = "N";
28
29 unset($arFields["ID"]);
30
31 unset($arFields["TIMESTAMP_X"]);
32 $arFields["~TIMESTAMP_X"] = $DB->GetNowFunction();
33
34 if($arFields["SITE_ID"] == '' || $arFields["SITE_ID"] == "NOT_REF")
35 $arFields["SITE_ID"] = false;
36
37 if($arFields["ACTIVE"] != "N")
38 $arFields["ACTIVE"] = "Y";
39
40 if($arFields["SAVE_STATISTIC"] != "Y")
41 $arFields["SAVE_STATISTIC"] = "N";
42
43 $arIPFields = array("IP_1", "IP_2", "IP_3", "IP_4", "MASK_1", "MASK_2", "MASK_3", "MASK_4");
44 foreach($arIPFields as $FIELD_ID)
45 {
46 if(trim($arFields[$FIELD_ID]) <> '')
47 {
48 $arFields[$FIELD_ID] = intval($arFields[$FIELD_ID]);
49 if($arFields[$FIELD_ID] < 0)
50 $arFields[$FIELD_ID] = 0;
51 elseif($arFields[$FIELD_ID] > 255)
52 $arFields[$FIELD_ID] = 255;
53 }
54 else
55 {
56 $arFields[$FIELD_ID] = false;
57 }
58 }
59
60 if($arFields["USER_AGENT_IS_NULL"] != "Y")
61 $arFields["USER_AGENT_IS_NULL"] = "N";
62
63 if($arFields["DATE_END"] <> '' && !CheckDateTime($arFields["DATE_END"]))
64 $aMsg[] = array("id"=>"DATE_END", "text"=> GetMessage("STAT_WRONG_END_DATE"));
65
66 if($arFields["DATE_START"] <> '' && !CheckDateTime($arFields["DATE_START"]))
67 $aMsg[] = array("id"=>"DATE_START", "text"=> GetMessage("STAT_WRONG_START_DATE"));
68
69 $arTestFields = $arFields;
70 $arTestFields["TEST"] = "Y";
71
72 $TEST_ID = $DB->Add("b_stop_list", $arTestFields);
73 $TEST_ID = intval($TEST_ID);
74
75 $TEST_STOP_ID = $this->Check("Y");
76 $TEST_STOP_ID = intval($TEST_STOP_ID);
77
78
79 if($TEST_ID==$TEST_STOP_ID && $TEST_STOP_ID > 0 && $TEST_ID > 0)
80 $aMsg[] = array("id"=>"WRONG_PARAMS", "text"=> GetMessage("STAT_WRONG_STOPLIST_PARAMS"));
81
82 $DB->Query("DELETE FROM b_stop_list WHERE ID='".$TEST_ID."'");
83
84
85 if(!empty($aMsg))
86 {
87 $e = new CAdminException($aMsg);
88 $GLOBALS["APPLICATION"]->ThrowException($e);
89 return false;
90 }
91 return true;
92 }
93
94 function Add($arFields)
95 {
96 $DB = CDatabase::GetModuleConnection('statistic');
97
98 if(!$this->CheckFields(false, $arFields))
99 return false;
100
101 $ID = $DB->Add("b_stop_list", $arFields);
102 CStopList::CleanCache();
103
104 return $ID;
105 }
106
108 {
109 $DB = CDatabase::GetModuleConnection('statistic');
110 $ID = intval($ID);
111
112 if(!$this->CheckFields($ID, $arFields))
113 return false;
114
115 $strUpdate = $DB->PrepareUpdate("b_stop_list", $arFields);
116 if($strUpdate != "")
117 {
118 $res = $DB->Query("UPDATE b_stop_list SET ".$strUpdate." WHERE ID = ".$ID);
119 CStopList::CleanCache();
120
121 if(!$res)
122 return false;
123 }
124 return true;
125 }
126
127 function SetActive($ID, $active = "N")
128 {
129 $DB = CDatabase::GetModuleConnection('statistic');
130 $ID = intval($ID);
131 if($ID)
132 {
133 if($active == "N")
134 {
135 $DB->Query("
136 UPDATE b_stop_list
137 SET ACTIVE='N',
138 TIMESTAMP_X=".$DB->GetNowFunction()."
139 WHERE ID = ".$ID
140 );
141 }
142 else
143 {
144 $rs = $this->GetByID($ID);
145 $ar = $rs->Fetch();
146 if($ar && $ar["ACTIVE"] == "N")
147 {
148 $ar["ACTIVE"] = "Y";
149 if(!$this->CheckFields($ID, $ar))
150 return false;
151 $DB->Query("
152 UPDATE b_stop_list
153 SET ACTIVE='Y',
154 TIMESTAMP_X=".$DB->GetNowFunction()."
155 WHERE ID = ".$ID
156 );
157 }
158 }
159 CStopList::CleanCache();
160 }
161 return true;
162 }
163
164 function Delete($ID)
165 {
166 $DB = CDatabase::GetModuleConnection('statistic');
167 $ID = intval($ID);
168 CStopList::CleanCache();
169 return $DB->Query("DELETE FROM b_stop_list WHERE ID = ".$ID);
170 }
171
172 public static function CleanCache()
173 {
174 $DB = CDatabase::GetModuleConnection('statistic');
175 $file = $_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/managed_cache/".$DB->type."/b_stop_list";
176 if(file_exists($file))
177 unlink($file);
178 }
179}
Определения stoplist.php:5
Delete($ID)
Определения stoplist.php:164
SetActive($ID, $active="N")
Определения stoplist.php:127
CheckFields($ID, &$arFields)
Определения stoplist.php:21
static GetByID($STOPLIST_ID)
Определения stoplist.php:6
static CleanCache()
Определения stoplist.php:172
Add($arFields)
Определения stoplist.php:94
Update($ID, $arFields)
Определения stoplist.php:107
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
if($ajaxMode) $ID
Определения get_user.php:27
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
CheckDateTime($datetime, $format=false)
Определения tools.php:398
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
$rs
Определения action.php:82
$GLOBALS['_____370096793']
Определения update_client.php:1
$arFilter
Определения user_search.php:106