%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.117.105.74
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/mysql/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/mysql/location_group.php
<?php

require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/general/location_group.php");

use Bitrix\Sale\Location;

class CSaleLocationGroup extends CAllSaleLocationGroup
{
	public static function GetList($arOrder = Array("NAME"=>"ASC"), $arFilter=Array(), $strLang = LANGUAGE_ID)
	{
		global $DB;
		$arSqlSearch = Array();
		$arSqlSearchFrom = array();

		if(!is_array($arFilter))
			$filter_keys = Array();
		else
			$filter_keys = array_keys($arFilter);

		$countFilterKey = count($filter_keys);
		for($i=0; $i < $countFilterKey; $i++)
		{
			$val = $DB->ForSql($arFilter[$filter_keys[$i]]);
			if ($val == '') continue;

			$key = $filter_keys[$i];
			if ($key[0]=="!")
			{
				$key = mb_substr($key, 1);
				$bInvert = true;
			}
			else
				$bInvert = false;

			switch(ToUpper($key))
			{
			case "ID":
				$arSqlSearch[] = "LG.ID ".($bInvert?"<>":"=")." ".intval($val)." ";
				break;
			case "LOCATION":

				if(CSaleLocation::isLocationProMigrated())
				{
					try
					{
						$class = self::CONN_ENTITY_NAME.'Table';
						$arSqlSearch[] = "	LG.ID ".($bInvert ? 'not' : '')." in (".$class::getConnectedEntitiesQuery(intval($val), 'id', array('select' => array('ID'))).") ";
					}
					catch(Exception $e)
					{
					}
				}
				else
				{
					$arSqlSearch[] = "LG.ID = L2LG.LOCATION_GROUP_ID AND L2LG.LOCATION_GROUP_ID ".($bInvert?"<>":"=")." ".intval($val)." ";
					$arSqlSearchFrom[] = ", b_sale_location2location_group L2LG ";
				}

				break;
			}
		}

		$strSqlSearch = "";
		$countSqlSearch = count($arSqlSearch);
		for($i=0; $i < $countSqlSearch; $i++)
		{
			$strSqlSearch .= " AND ";
			$strSqlSearch .= " (".$arSqlSearch[$i].") ";
		}

		$strSqlSearchFrom = "";
		$countSqlSearchForm = count($arSqlSearchFrom);
		for($i=0; $i < $countSqlSearchForm; $i++)
		{
			$strSqlSearchFrom .= " ".$arSqlSearchFrom[$i]." ";
		}

		$strSql =
			"SELECT DISTINCT LG.ID, LG.SORT, LGL.NAME, LGL.LID ".
			"FROM (b_sale_location_group LG ".
			"	".$strSqlSearchFrom.") ".
			"	LEFT JOIN b_sale_location_group_lang LGL ON (LG.ID = LGL.LOCATION_GROUP_ID AND LGL.LID = '".$DB->ForSql($strLang, 2)."') ".
			"WHERE 1 = 1 ".
			"	".$strSqlSearch." ";

		$arSqlOrder = Array();
		foreach ($arOrder as $by=>$order)
		{
			$by = ToUpper($by);
			$order = ToUpper($order);
			if ($order!="ASC") $order = "DESC";

			if ($by == "ID") $arSqlOrder[] = " LG.ID ".$order." ";
			elseif ($by == "NAME") $arSqlOrder[] = " LGL.NAME ".$order." ";
			else
			{
				$arSqlOrder[] = " LG.SORT ".$order." ";
				$by = "SORT";
			}
		}

		$strSqlOrder = "";
		DelDuplicateSort($arSqlOrder);
		$countSqlOrder = count($arSqlOrder);
		for ($i=0; $i < $countSqlOrder; $i++)
		{
			if ($i==0)
				$strSqlOrder = " ORDER BY ";
			else
				$strSqlOrder .= ", ";

			$strSqlOrder .= $arSqlOrder[$i];
		}

		$strSql .= $strSqlOrder;
		$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		return $db_res;
	}

	public static function GetByID($ID, $strLang = LANGUAGE_ID)
	{
		global $DB;

		$ID = intval($ID);
		$strSql =
			"SELECT LG.ID, LG.SORT, LGL.NAME, LGL.LID ".
			"FROM b_sale_location_group LG ".
			"	LEFT JOIN b_sale_location_group_lang LGL ON (LG.ID = LGL.LOCATION_GROUP_ID AND LGL.LID = '".$DB->ForSql($strLang, 2)."') ".
			"WHERE LG.ID = ".$ID." ";
		$db_res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);

		if ($res = $db_res->Fetch())
		{
			return $res;
		}
		return False;
	}

	public static function Add($arFields)
	{
		global $DB;

		if (!CSaleLocationGroup::CheckFields("ADD", $arFields))
			return false;

		// make IX_B_SALE_LOC_GROUP_CODE feel happy
		$arFields['CODE'] = 'randstr'.rand(999, 999999);

		$db_events = GetModuleEvents("sale", "OnBeforeLocationGroupAdd");
		while ($arEvent = $db_events->Fetch())
			if (ExecuteModuleEventEx($arEvent, array($arFields))===false)
				return false;

		$arInsert = $DB->PrepareInsert("b_sale_location_group", $arFields);
		$strSql =
			"INSERT INTO b_sale_location_group(".$arInsert[0].") ".
			"VALUES(".$arInsert[1].")";

		$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);

		$ID = intval($DB->LastID());

		// make IX_B_SALE_LOC_CODE feel happy
		Location\GroupTable::update($ID, array('CODE' => $ID));

		$countFieldLang = count($arFields["LANG"]);
		for ($i = 0; $i < $countFieldLang; $i++)
		{
			$arInsert = $DB->PrepareInsert("b_sale_location_group_lang", $arFields["LANG"][$i]);
			$strSql =
				"INSERT INTO b_sale_location_group_lang(LOCATION_GROUP_ID, ".$arInsert[0].") ".
				"VALUES(".$ID.", ".$arInsert[1].")";

			$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}

		if(CSaleLocation::isLocationProMigrated())
		{
			try
			{
				$entityClass = self::CONN_ENTITY_NAME.'Table';
				$entityClass::resetMultipleForOwner($ID, array(
					Location\Connector::DB_LOCATION_FLAG => $entityClass::normalizeLocationList($arFields["LOCATION_ID"])
				));
			}
			catch(Exception $e)
			{
			}
		}
		else
		{
			$strSqlHead ="INSERT INTO b_sale_location2location_group (LOCATION_ID, LOCATION_GROUP_ID) VALUES ";
			$strSqlHeadLength = mb_strlen($strSqlHead);

			$res = $DB->Query('SHOW VARIABLES LIKE \'max_allowed_packet\'');
			$maxPack = $res->Fetch();

			if(isset($maxPack["Value"]))
				$max_allowed_packet = $maxPack["Value"]-$strSqlHeadLength-100;
			else
				$max_allowed_packet = 0;

			$tmpSql = '';
			$strSql = '';
			$countFieldLoc = count($arFields["LOCATION_ID"]);
			for ($i = 0; $i < $countFieldLoc; $i++)
			{
				$tmpSql ="(".$arFields["LOCATION_ID"][$i].", ".$ID.")";
				$strSqlLen = mb_strlen($strSql);

				if($strSqlHeadLength + $strSqlLen + mb_strlen($tmpSql) < $max_allowed_packet || $max_allowed_packet <= 0)
				{
					if($strSqlLen > 0)
						$strSql .=",";

					$strSql .= $tmpSql;
				}
				else
				{
					$DB->Query($strSqlHead.$strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
					$strSql = $tmpSql;
				}
			}

			if($strSql <> '')
				$DB->Query($strSqlHead.$strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		}

		$events = GetModuleEvents("sale", "OnLocationGroupAdd");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID, $arFields));

		return $ID;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit