7 private static $httpStatusCodes =
array(
8 301 =>
"301 Moved Permanently",
18 return self::$arErrors;
23 self::$arErrors[] =
$error;
28 self::$arErrors =
array();
47 $strUpdate =
$DB->PrepareUpdate(
"b_short_uri",
$arFields);
50 "UPDATE b_short_uri SET ".
52 " MODIFIED = ".$DB->CurrentTimeFunction().
" ".
67 return "/".$arResult[
"SHORT_URI"];
72 "SHORT_URI" => self::GenerateShortUri(),
79 return "/".$arFields[
"SHORT_URI"];
84 public static function GetUri($shortUri)
86 $shortUri = trim($shortUri);
88 $ar = @parse_url($shortUri);
89 if (isset(
$ar[
"path"]))
90 $shortUri =
$ar[
"path"];
92 $shortUri = trim($shortUri,
"/");
111 "UPDATE b_short_uri SET ".
112 " NUMBER_USED = NUMBER_USED + 1, ".
113 " LAST_USED = ".$DB->CurrentTimeFunction().
" ".
114 "WHERE ID = ".intval($id);
131 foreach(
GetModuleEvents(
"main",
"OnBeforeShortUriDelete",
true) as $arEvent)
136 $err = $ex->GetString();
144 $fl =
$DB->Query(
"DELETE FROM b_short_uri WHERE ID = ".$id,
true);
159 $c = -(0xFFFFFFFF - $c + 1);
166 $updateMode = ($id > 0 ? true :
false);
167 $addMode = !$updateMode;
191 if (isset(
$ar[
"path"]))
213 elseif (!array_key_exists(
$arFields[
"STATUS"], self::$httpStatusCodes))
234 if (array_key_exists(
$code, self::$httpStatusCodes))
235 return self::$httpStatusCodes[
$code];
242 $s =
'<select name="'.$fieldName.
'" '.$field.
'>'.
"\n";
245 foreach (self::$httpStatusCodes as
$code => $codeText)
247 $found = (
$code == $value);
249 $s1 .=
'<option value="'.$code.
'"'.($found ?
' selected':
'').
'>'.(empty($m) ? htmlspecialcharsex($codeText) : htmlspecialcharsex($m)).
'</option>'.
"\n";
252 $s .=
"<option value='' ".($found ?
"" :
"selected").
">".htmlspecialcharsex(
$defaultValue).
"</option>";
253 return $s.$s1.
'</select>';
260 $uri =
"~".randString(5);
281 if ($arUri = static::GetUri(
Bitrix\Main\Context::getCurrent()->getRequest()->getDecodedUri()))
283 static::SetLastUsed($arUri[
"ID"]);
284 if (CModule::IncludeModule(
"statistic"))
288 LocalRedirect($arUri[
"URI"],
true, static::GetHttpStatusCodeText($arUri[
"STATUS"]));
303 $arInsert =
$DB->PrepareInsert(
"b_short_uri",
$arFields);
306 "INSERT INTO b_short_uri (".$arInsert[0].
", MODIFIED) ".
307 "VALUES(".$arInsert[1].
", ".
$DB->CurrentTimeFunction().
")";
310 $taskId = intval(
$DB->LastID());
314 foreach (
GetModuleEvents(
"main",
"OnAfterShortUriAdd",
true) as $arEvent)
326 $arWherePart =
array();
335 $arWherePart[] =
"U.ID=".intval(
$val);
339 if (!empty($q) && ($q !=
"0"))
343 $arWherePart[] =
"U.URI='".$DB->ForSQL(
$val).
"'";
346 $arWherePart[] =
"U.URI_CRC=".intval(
$val);
349 $arWherePart[] =
"U.SHORT_URI='".$DB->ForSQL(
$val).
"'";
351 case "SHORT_URI_CRC":
352 $arWherePart[] =
"U.SHORT_URI_CRC=".intval(
$val);
355 $arWherePart[] =
"U.STATUS=".intval(
$val);
358 $arWherePart[] =
"U.MODIFIED >= FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y"),
"d.m.Y").
"')";
361 $arWherePart[] =
"U.MODIFIED <= FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y").
" 23:59:59",
"d.m.Y").
"')";
364 $arWherePart[] =
"U.LAST_USED >= FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y"),
"d.m.Y").
"')";
367 $arWherePart[] =
"U.LAST_USED <= FROM_UNIXTIME('".MkDateTime(
FmtDate(
$val,
"D.M.Y").
" 23:59:59",
"d.m.Y").
"')";
370 $arWherePart[] =
"U.NUMBER_USED=".intval(
$val);
377 if (!empty($arWherePart))
379 foreach ($arWherePart as
$val)
381 if ($strWherePart !==
"")
382 $strWherePart .=
" AND ";
383 $strWherePart .=
"(".$val.
")";
386 if ($strWherePart !==
"")
387 $strWherePart =
"WHERE ".$strWherePart;
389 $arOrderByPart =
array();
390 if (is_array($arOrder))
395 if (!in_array(
$key,
array(
"ID",
"URI",
"URI_CRC",
"SHORT_URI",
"SHORT_URI_CRC",
"STATUS",
"MODIFIED",
"LAST_USED",
"NUMBER_USED")))
398 if (!in_array(
$val,
array(
"ASC",
"DESC")))
400 if (
$key ==
"MODIFIED")
402 if (
$key ==
"LAST_USED")
408 $strOrderByPart =
"";
409 if (!empty($arOrderByPart))
411 foreach ($arOrderByPart as
$val)
413 if ($strOrderByPart !==
"")
414 $strOrderByPart .=
", ";
415 $strOrderByPart .=
$val;
418 if ($strOrderByPart !==
"")
419 $strOrderByPart =
"ORDER BY ".$strOrderByPart;
421 $strSql =
"FROM b_short_uri U ".$strWherePart;
423 if ($arNavStartParams)
425 $dbResultCount =
$DB->Query(
"SELECT COUNT(U.ID) as C ".$strSql);
426 $arResultCount = $dbResultCount->Fetch();
427 $strSql =
"SELECT ID, URI, URI_CRC, SHORT_URI, SHORT_URI_CRC, STATUS, ".$DB->DateToCharFunction(
"MODIFIED").
" MODIFIED, MODIFIED MODIFIED1, ".
$DB->DateToCharFunction(
"LAST_USED").
" LAST_USED, LAST_USED LAST_USED1, NUMBER_USED ".$strSql.$strOrderByPart;
429 $dbResult->NavQuery($strSql, $arResultCount[
"C"], $arNavStartParams);
433 $strSql =
"SELECT ID, URI, URI_CRC, SHORT_URI, SHORT_URI_CRC, STATUS, ".$DB->DateToCharFunction(
"MODIFIED").
" MODIFIED, MODIFIED MODIFIED1, ".
$DB->DateToCharFunction(
"LAST_USED").
" LAST_USED, LAST_USED LAST_USED1, NUMBER_USED ".$strSql.$strOrderByPart;
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
static AddCurrent($event1, $event2="", $event3="", $money="", $currency="", $goto="", $chargeback="N", $site_id=false)
static GetHttpStatusCodeText($code)
static GetList($arOrder=array("ID"=> "DESC"), $arFilter=array(), $arNavStartParams=false)
static SelectBox($fieldName, $value, $defaultValue="", $field="class=\"typeselect\"")
static ParseFields(&$arFields, $id=0)
static Update($id, $arFields)
static GenerateShortUri()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
ExecuteModuleEventEx($arEvent, $arParams=[])
FmtDate($str_date, $format=false, $site=false, $bSearchInSitesOnly=false)
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key