本文整理汇总了PHP中EscapePHPString函数的典型用法代码示例。如果您正苦于以下问题:PHP EscapePHPString函数的具体用法?PHP EscapePHPString怎么用?PHP EscapePHPString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EscapePHPString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SaveConfig
function SaveConfig($arServerList)
{
self::$arList = false;
$isOnline = false;
$content = '<' . '?
define("BX_MEMCACHE_CLUSTER", "' . EscapePHPString(CMain::GetServerUniqID()) . '");
$arList = array(
';
$defGroup = 1;
$arGroups = array();
$rsGroups = CClusterGroup::GetList(array("ID" => "DESC"));
while ($arGroup = $rsGroups->Fetch()) {
$defGroup = $arGroups[$arGroup["ID"]] = intval($arGroup["ID"]);
}
foreach ($arServerList as $i => $arServer) {
$isOnline |= $arServer["STATUS"] == "ONLINE";
$GROUP_ID = intval($arServer["GROUP_ID"]);
if (!array_key_exists($arServer["GROUP_ID"], $arGroups)) {
$GROUP_ID = $defGroup;
}
$content .= "\t" . intval($i) . " => array(\n";
$content .= "\t\t'ID' => \"" . EscapePHPString($arServer["ID"]) . "\",\n";
$content .= "\t\t'GROUP_ID' => " . $GROUP_ID . ",\n";
$content .= "\t\t'HOST' => \"" . EscapePHPString($arServer["HOST"]) . "\",\n";
$content .= "\t\t'PORT' => " . intval($arServer["PORT"]) . ",\n";
$content .= "\t\t'WEIGHT' => " . intval($arServer["WEIGHT"]) . ",\n";
if ($arServer["STATUS"] == "ONLINE") {
$content .= "\t\t'STATUS' => \"ONLINE\",\n";
} elseif ($arServer["STATUS"] == "OFFLINE") {
$content .= "\t\t'STATUS' => \"OFFLINE\",\n";
} else {
$content .= "\t\t'STATUS' => \"READY\",\n";
}
$content .= "\t),\n";
}
$content .= ');
?' . '>';
file_put_contents($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/cluster/memcache.php", $content);
bx_accelerator_reset();
self::$systemConfigurationUpdate = null;
$cache = \Bitrix\Main\Config\Configuration::getValue('cache');
if ($isOnline) {
if (!is_array($cache) || !isset($cache['type']) || !is_array($cache['type']) || !isset($cache['type']['class_name']) || !$cache['type']['class_name'] === 'CPHPCacheMemcacheCluster') {
\Bitrix\Main\Config\Configuration::setValue('cache', array('type' => array('class_name' => 'CPHPCacheMemcacheCluster', 'extension' => 'memcache', 'required_file' => 'modules/cluster/classes/general/memcache_cache.php')));
self::$systemConfigurationUpdate = true;
}
} else {
if (is_array($cache) && isset($cache['type']) && is_array($cache['type']) && isset($cache['type']['class_name']) && $cache['type']['class_name'] === 'CPHPCacheMemcacheCluster') {
\Bitrix\Main\Config\Configuration::setValue('cache', null);
self::$systemConfigurationUpdate = false;
}
}
}
示例2: SaveConfig
public static function SaveConfig($arServerList)
{
self::$arList = false;
$content = '<'.'?
// define("BX_MEMCACHE_CLUSTER", "'.EscapePHPString(CMain::GetServerUniqID()).'");
$arList = array(
';
$defGroup = 1;
$arGroups = array();
$rsGroups = CClusterGroup::GetList(array("ID" => "DESC"));
while($arGroup = $rsGroups->Fetch())
$defGroup = $arGroups[$arGroup["ID"]] = intval($arGroup["ID"]);
foreach($arServerList as $i => $arServer)
{
$GROUP_ID = intval($arServer["GROUP_ID"]);
if(!array_key_exists($arServer["GROUP_ID"], $arGroups))
$GROUP_ID = $defGroup;
$content .= "\t".intval($i)." => array(\n";
$content .= "\t\t'ID' => \"".EscapePHPString($arServer["ID"])."\",\n";
$content .= "\t\t'GROUP_ID' => ".$GROUP_ID.",\n";
$content .= "\t\t'HOST' => \"".EscapePHPString($arServer["HOST"])."\",\n";
$content .= "\t\t'PORT' => ".intval($arServer["PORT"]).",\n";
$content .= "\t\t'WEIGHT' => ".intval($arServer["WEIGHT"]).",\n";
if($arServer["STATUS"] == "ONLINE")
$content .= "\t\t'STATUS' => \"ONLINE\",\n";
elseif($arServer["STATUS"] == "OFFLINE")
$content .= "\t\t'STATUS' => \"OFFLINE\",\n";
else
$content .= "\t\t'STATUS' => \"READY\",\n";
$content .= "\t),\n";
}
$content .= ');
?'.'>';
file_put_contents(
$_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/cluster/memcache.php"
,$content
);
}
示例3: add
/**
* @param $feedType
* @param $siteId
* @param $interval
* @param bool|false $once
* @return bool|int
* @throws ArgumentNullException
* @throws ArgumentOutOfRangeException
*/
public static function add($feedType, $siteId, $interval, $once = false)
{
if ($interval <= 0) {
return 0;
}
if (empty($siteId)) {
throw new ArgumentNullException('siteId');
}
$siteId = \EscapePHPString($siteId);
if ($feedType == "ORDER") {
$sort = 50;
} elseif ($feedType == "PRODUCT") {
$sort = 100;
} elseif ($feedType == "INVENTORY" || $feedType == "IMAGE") {
$sort = 150;
} else {
throw new ArgumentOutOfRangeException('feedType');
}
$intervalSeconds = $interval * 60;
$timeToStart = ConvertTimeStamp(strtotime(date('Y-m-d H:i:s', time() + $intervalSeconds)), 'FULL');
$result = \CAgent::AddAgent(self::createAgentNameForAdd($feedType, $siteId, $once), 'sale', "N", $interval * 60, $timeToStart, "Y", $timeToStart, $sort);
Ebay::log(Logger::LOG_LEVEL_DEBUG, "EBAY_AGENT_ADDING_RESULT", $feedType, "Feed: " . $feedType . ", site: " . $siteId . ", interval: " . $interval . " once: " . ($once ? 'true' : 'false') . " agentId: '" . $result . "'", $siteId);
return $result;
}
示例4: EscapePHPString
$strSectionName = "\$sSectionName = \"" . EscapePHPString($pageTitle) . "\";\n";
}
}
//Properties
$strDirProperties = "";
if (isset($_POST["PROPERTY"]) && is_array($_POST["PROPERTY"])) {
$bNeedComma = false;
foreach ($_POST["PROPERTY"] as $arProperty) {
$arProperty["CODE"] = isset($arProperty["CODE"]) ? trim($arProperty["CODE"]) : "";
$arProperty["VALUE"] = isset($arProperty["VALUE"]) ? trim($arProperty["VALUE"]) : "";
if (preg_match("/[a-zA-Z_-~]+/i", $arProperty["CODE"])) {
if ($createNewFolder && strlen($arProperty["VALUE"]) > 0) {
if ($bNeedComma) {
$strDirProperties .= ",\n";
}
$strDirProperties .= " \"" . EscapePHPString($arProperty["CODE"]) . "\" => \"" . EscapePHPString($arProperty["VALUE"]) . "\"";
$bNeedComma = true;
} else {
$fileContent = SetPrologProperty($fileContent, $arProperty["CODE"], $arProperty["VALUE"]);
}
}
}
}
if ($createNewFolder) {
$sectionFileContent = "<" . "?\n" . $strSectionName . "\$arDirProperties = Array(\n" . $strDirProperties . "\n);\n" . "?" . ">";
$sectionPath = substr($path, 1) . $fileName;
$success = BXCreateSection($fileContent, $sectionFileContent, $absoluteFilePath, $sectionPath);
$arUndoParams = array('module' => 'fileman', 'undoType' => 'new_section', 'undoHandler' => 'CFileman::UndoNewSection', 'arContent' => array('absPath' => $absoluteFilePath, 'path' => rtrim($path, "/") . "/" . $fileName, 'site' => $site));
} else {
//Tags only for pages
if ($pageTags !== false && IsModuleInstalled("search")) {
示例5: createStatement
/**
* Returns Php\Statement object with escaped php code repeated for body? prefixed with $prefix and suffixed with $suffix.
*
* @param string $prefix Prefix string for each from body.
* @param array|string $body Strings to be escaped.
* @param string $suffix Suffix string for each from body.
*
* @return \Bitrix\Perfmon\Php\Statement
*/
protected function createStatement($prefix, $body, $suffix)
{
$result = new Php\Statement();
if (is_array($body)) {
foreach ($body as $line) {
$result->addLine($prefix . EscapePHPString($line) . $suffix);
}
} else {
$result->addLine($prefix . EscapePHPString($body) . $suffix);
}
return $result;
}
示例6: GetMessage
array("DIV" => "edit8", "TAB" => GetMessage("MAIN_TAB_8"), "ICON" => "main_settings", "TITLE" => GetMessage("MAIN_OPTION_EVENT_LOG")),
array("DIV" => "edit5", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "main_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")),
);
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$SET_LICENSE_KEY = "";
if($_SERVER["REQUEST_METHOD"]=="POST" && strlen($_POST["Update"])>0 && ($USER->CanDoOperation('edit_other_settings') && $USER->CanDoOperation('edit_groups')) && check_freetrix_sessid())
{
if(LICENSE_KEY !== $_POST["SET_LICENSE_KEY"])
{
$SET_LICENSE_KEY = preg_replace("/[^A-Za-z0-9_.-]/", "", $_POST["SET_LICENSE_KEY"]);
file_put_contents(
$_SERVER["DOCUMENT_ROOT"].FX_ROOT."/license_key.php",
"<"."? $"."LICENSE_KEY = \"".EscapePHPString($SET_LICENSE_KEY)."\"; ?".">"
);
}
foreach($arAllOptions as $aOptGroup)
{
foreach($aOptGroup as $option)
{
__AdmSettingsSaveOption("main", $option);
}
}
COption::SetOptionString("main", "admin_lid", $_POST["admin_lid"]);
COption::SetOptionString("main", "show_panel_for_users", serialize($_POST["show_panel_for_users"]));
$cleanup_days = COption::GetOptionInt("main", "new_user_registration_cleanup_days", 7);
if($cleanup_days > 0 && COption::GetOptionString("main", "new_user_registration_email_confirmation", "N") === "Y")
示例7: str_replace
} else {
$safeKey = str_replace('.', '_', $k . "_" . $lng);
if (isset($_POST[$safeKey])) {
$ms_value = $_POST[$safeKey];
}
}
if (isset($_POST[$k . "_" . $lng . "_PREV"])) {
$ms_value_prev = $_POST[$k . "_" . $lng . "_PREV"];
} else {
$safeKey = str_replace('.', '_', $k . "_" . $lng . "_PREV");
if (isset($_POST[$safeKey])) {
$ms_value_prev = $_POST[$safeKey];
}
}
if ($ms_del != "Y" && strlen($ms_value) > 0) {
$arTEXT[$arLangFiles[$ms_lang]][] = "\$MESS[\"" . EscapePHPString($k) . "\"] = \"" . EscapePHPString(str_replace("\r", "", $ms_value)) . "\"";
} elseif (strlen($ms_value_prev) > 0) {
$arTEXT[$arLangFiles[$ms_lang]][] = "";
}
}
}
}
// collect all the variables and write to files
while (list($fpath, $arM) = each($arTEXT)) {
$strContent = "";
foreach ($arM as $M) {
if (strlen($M) > 0) {
$strContent .= "\n" . $M . ";";
}
}
if (!TR_BACKUP($fpath)) {
示例8: GetOptionPHPCode
public function GetOptionPHPCode($arAllValues)
{
$arValues = $arAllValues[$this->id];
$arOptions = $this->GetOptionArray();
$str = "";
foreach($arOptions as $id=>$arOptionParams)
{
if(isset($arValues[$id]))
$str .= 'CControllerClient::SetOptionString("'.EscapePHPString($this->id).'", "'.EscapePHPString($id).'", "'.EscapePHPString($arValues[$id]).'");'."\r\n";
elseif(substr($id, 0, 2)!='__')
$str .= 'CControllerClient::RestoreOption("'.EscapePHPString($this->id).'", "'.EscapePHPString($id).'");'."\r\n";
}
return $str;
}
示例9: UndoFileDelete
function UndoFileDelete($Params, $type)
{
global $APPLICATION;
$documentRoot = CSite::GetSiteDocRoot($Params['site']);
// Restore file
if (strlen($Params['path']) > 0) {
$APPLICATION->SaveFileContent($documentRoot . $Params['path'], $Params['content']);
}
// Update disk quota
if (COption::GetOptionInt("main", "disk_space") > 0) {
$io = CBXVirtualIo::GetInstance();
$f = $io->GetFile($documentRoot . $Params['path']);
$file_size = $f->GetFileSize();
$quota = new CDiskQuota();
$quota->UpdateDiskQuota("file", $file_size, "delete");
}
// Restore file access permissions
if (is_array($Params['perm']) && count($Params['perm']) > 0) {
for ($i = 0, $l = count($Params['perm']); $i < $l; $i++) {
$permFile = $Params['perm'][$i]['permFile'];
$permContent = $APPLICATION->GetFileContent($permFile);
$permContent = substr($permContent, 0, strpos($permContent, "?" . ">"));
$permContent .= "\$PERM[\"" . EscapePHPString($Params['perm'][$i]['file']) . "\"][\"" . EscapePHPString($Params['perm'][$i]['group']) . "\"]=\"" . EscapePHPString($Params['perm'][$i]['perm']) . "\";\n";
$permContent .= "?" . ">\n";
$APPLICATION->SaveFileContent($permFile, $permContent);
}
}
// Restore menu
if (is_array($Params['menu']) && count($Params['menu']) > 0) {
for ($i = 0, $l = count($Params['menu']); $i < $l; $i++) {
$menuFile = $Params['menu'][$i]['menuFile'];
$menuIndex = $Params['menu'][$i]['menuIndex'];
$menuItem = $Params['menu'][$i]['menuItem'];
$arMenu = CFileman::GetMenuArray($documentRoot . $menuFile);
$arFound = false;
if (count($arMenu["aMenuLinks"]) <= $menuIndex) {
$arMenu["aMenuLinks"][] = $menuItem;
} else {
$arMenu["aMenuLinks"] = array_merge(array_slice($arMenu["aMenuLinks"], 0, $menuIndex), array($menuItem), array_slice($arMenu["aMenuLinks"], $menuIndex));
}
CFileMan::SaveMenu(array($Params['site'], $menuFile), $arMenu["aMenuLinks"], $arMenu["sMenuTemplate"]);
}
}
// Restore UrlRewriter
if (is_array($Params['SEF']) && count($Params['SEF']) > 0) {
for ($i = 0, $l = count($Params['SEF']); $i < $l; $i++) {
CUrlRewriter::Add(array("SITE_ID" => $Params['site'], "CONDITION" => $Params['SEF'][$i]["CONDITION"], "ID" => $Params['SEF'][$i]["ID"], "PATH" => $Params['SEF'][$i]["PATH"], "RULE" => $Params['SEF'][$i]["RULE"]));
}
}
$GLOBALS["CACHE_MANAGER"]->CleanDir("menu");
}
示例10: optimizeAsset
/**
* @param array $arFile
* @param bool $unique
* @param string $prefix
* @param string $setName
* @param string $type
* @return array
*/
private function optimizeAsset($arFile = array(), $unique = false, $prefix = 'default', $setName = '', $type = 'css')
{
if (!is_array($arFile) || empty($arFile)) {
return array('RESULT' => '', 'FILES' => array());
}
$this->setTemplateID();
$res = $assetMD5 = $strFiles = $contents = '';
$prefix = trim($prefix);
$prefix = strlen($prefix) < 1 ? 'default' : $prefix;
$add2End = strncmp($prefix, 'kernel', 6) == 0;
$type = $type == 'js' ? 'js' : 'css';
$arIEContent = array();
/** @var bool $noCheckOnly when we cant frite files */
$noCheckOnly = !defined('BX_HEADFILES_CACHE_CHECK_ONLY');
$prefix = $unique ? $prefix : $prefix . '_' . $this->getAssetChecksum($arFile);
$dbType = ToUpper(\Bitrix\Main\Application::getInstance()->getConnection()->getType());
$documentRoot = Main\Loader::getDocumentRoot();
$optimPath = BX_PERSONAL_ROOT . '/cache/' . $type . '/' . SITE_ID . '/' . $this->siteTemplateID . '/' . $prefix . '/';
$infoFile = $documentRoot . BX_PERSONAL_ROOT . '/managed_cache/' . $dbType . '/' . $type . '/' . SITE_ID . '/' . $this->siteTemplateID . '/' . $prefix . '/info.php';
$optimFile = $optimPath . $prefix . ($type == 'css' ? '.css' : '.js');
$optimFName = $documentRoot . $optimFile;
$cssFNameIE = $optimPath . $prefix . '#CNT#.css';
$cssFPathIE = $documentRoot . $cssFNameIE;
$tmpInfo = $this->isAssetChanged($arFile, $infoFile, $optimFName, $unique);
$arFilesInfo = $tmpInfo['INFO'];
$action = $tmpInfo['ACTION'];
$arFile = $tmpInfo['FILE'];
$optimFileExist = $tmpInfo['FILE_EXIST'];
$writeResult = $action == 'NEW' ? false : true;
if ($action != 'NO') {
if ($type == 'css') {
$this->fileList['CSS'][$setName]['UP_NEW_FILES'] = $tmpInfo['FILE'];
} else {
$this->fileList['JS'][$setName]['UP_NEW_FILES'] = $tmpInfo['FILE'];
}
$arFilesInfo['CUR_IE_CNT'] = intval($arFilesInfo['CUR_IE_CNT']);
$arFilesInfo['CUR_SEL_CNT'] = intval($arFilesInfo['CUR_SEL_CNT']);
if ($action == 'UP') {
if ($noCheckOnly) {
$contents .= file_get_contents($optimFName);
if ($type == 'css') {
if ($arFilesInfo['CUR_SEL_CNT'] < self::MAX_ADD_CSS_SELECTOR) {
$css = str_replace('#CNT#', $arFilesInfo['CUR_IE_CNT'], $cssFPathIE);
if (file_exists($css)) {
$arIEContent[$arFilesInfo['CUR_IE_CNT']] .= file_get_contents($css);
$arFilesInfo['CUR_SEL_CNT'] = $this->getCssSelectCnt($arIEContent[$arFilesInfo['CUR_IE_CNT']]);
}
} else {
$arFilesInfo['CUR_IE_CNT']++;
$arFilesInfo['CUR_SEL_CNT'] = 0;
}
}
} else {
$writeResult = false;
}
}
$needWrite = false;
if ($noCheckOnly) {
$tmpStr = '';
foreach ($arFile as $file) {
$tmpContent = file_get_contents($file['FILE_PATH']);
if ($type == 'css') {
$f_cnt = $this->getCssSelectCnt($tmpContent);
$new_cnt = $f_cnt + $arFilesInfo['CUR_SEL_CNT'];
$strFiles .= "/* " . $file['PATH'] . " */\n";
$tmpContent = $this->fixCSSIncludes($tmpContent, $file['PATH']);
$tmpContent = "\n/* Start:" . $file['PATH'] . "*/\n" . $tmpContent . "\n/* End */\n";
if ($new_cnt < self::MAX_CSS_SELECTOR) {
$arFilesInfo['CUR_SEL_CNT'] = $new_cnt;
$arIEContent[$arFilesInfo['CUR_IE_CNT']] .= $tmpContent;
} else {
$arFilesInfo['CUR_SEL_CNT'] = $f_cnt;
$arFilesInfo['CUR_IE_CNT']++;
$arIEContent[$arFilesInfo['CUR_IE_CNT']] .= $tmpContent;
}
$tmpStr .= "\n\n" . $tmpContent;
} else {
$strFiles .= "; /* " . $file['PATH'] . "*/\n";
$tmpStr .= "\n; /* Start:" . $file['PATH'] . "*/\n" . $tmpContent . "\n/* End */\n;";
}
$arFilesInfo['FILES'][$file['PATH']] = $this->getAssetTime($file['FULL_PATH']);
$needWrite = true;
}
if ($needWrite) {
// Write packed files and meta information
$contents = $add2End ? $strFiles . $contents . $tmpStr : $tmpStr . $contents . $strFiles;
if ($writeResult = $this->write($optimFName, $contents)) {
$cacheInfo = '<? $arFilesInfo = array( \'FILES\' => array(';
foreach ($arFilesInfo['FILES'] as $key => $time) {
$cacheInfo .= '"' . EscapePHPString($key) . '" => "' . $time . '",';
}
$cacheInfo .= "), 'CUR_SEL_CNT' => '" . $arFilesInfo['CUR_SEL_CNT'] . "', 'CUR_IE_CNT' => '" . $arFilesInfo['CUR_IE_CNT'] . "'); ?>";
//.........这里部分代码省略.........
示例11: GetMessage
$errorMessage .= GetMessage("ACCESS_DENIED");
}
$newLicenseKey = $APPLICATION->UnJSEscape($_REQUEST["NEW_LICENSE_KEY"]);
$newLicenseKey = preg_replace("/[^A-Za-z0-9_.-]/", "", $newLicenseKey);
if (strlen($newLicenseKey) <= 0) {
$errorMessage .= "[PULK01] " . GetMessage("SUP_ENTER_KEY") . ". ";
} elseif (strtolower($newLicenseKey) == "demo") {
$errorMessage .= "[PULK02] " . GetMessage("SUP_ENTER_CORRECT_KEY") . ". ";
}
if (strlen($errorMessage) <= 0) {
if (!($fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/license_key.php", "w"))) {
$errorMessage .= "[PULK03] " . GetMessage("SUP_CANT_OPEN_FILE") . ". ";
}
}
if (strlen($errorMessage) <= 0) {
fputs($fp, "<" . "? \$" . "LICENSE_KEY = \"" . EscapePHPString($newLicenseKey) . "\"; ?" . ">");
fclose($fp);
if (function_exists("accelerator_reset")) {
accelerator_reset();
}
echo "Y";
} else {
echo $errorMessage;
}
} elseif ($queryType == "register") {
if (CUpdateClient::RegisterVersion($errorMessage, LANG, $stableVersionsOnly)) {
CUpdateClient::AddMessage2Log("Registered", "UPD_SUCCESS");
echo "Y";
} else {
CUpdateClient::AddMessage2Log("Error: " . $errorMessage, "UPD_ERROR");
echo $errorMessage;
示例12: CreateLicenseFile
function CreateLicenseFile()
{
$wizard =& $this->GetWizard();
$_1048905712 = $wizard->GetVar(___125355289(1336));
if ($GLOBALS['____1308158154'][317]($_1048905712) < min(148, 0, 49.333333333333)) {
$_1048905712 = ___125355289(1337);
}
$_932830850 = $_SERVER[___125355289(1338)] . ___125355289(1339);
if (!($_1318943328 = @$GLOBALS['____1308158154'][318]($_932830850, ___125355289(1340)))) {
return false;
}
$_1583459965 = ___125355289(1341) . ___125355289(1342) . ___125355289(1343) . EscapePHPString($_1048905712) . ___125355289(1344) . ___125355289(1345);
if (!$GLOBALS['____1308158154'][319]($_1318943328, $_1583459965)) {
return false;
}
@$GLOBALS['____1308158154'][320]($_1318943328);
if ($this->filePermission > 1168 / 2 - 584) {
@$GLOBALS['____1308158154'][321]($_932830850, $GLOBALS['____1308158154'][322]($this->filePermission));
}
return true;
}
示例13: configureLicenseKey
/**
* Sets license key Bitrix CMS.
*
* @param InputInterface $input
* @param OutputInterface $output
* @param string $licenseKey
*/
protected function configureLicenseKey(InputInterface $input, OutputInterface $output, $licenseKey)
{
if (!is_string($licenseKey)) {
throw new \InvalidArgumentException('Config "licenseKey" must be string type.');
}
$licenseFileContent = "<" . "? \$" . "LICENSE_KEY = \"" . EscapePHPString($licenseKey) . "\"; ?" . ">";
File::putFileContents(Application::getDocumentRoot() . BX_ROOT . '/license_key.php', $licenseFileContent);
}
示例14: Update
function Update($ID, $arFields)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
if (!$this->CheckFields($arFields, $ID)) {
return false;
}
$path = getLocalPath("templates/" . $ID, BX_PERSONAL_ROOT);
if ($path === false) {
return false;
}
if (isset($arFields["CONTENT"])) {
$p = strpos($arFields["CONTENT"], "#WORK_AREA#");
$header = substr($arFields["CONTENT"], 0, $p);
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/header.php", $header);
$footer = substr($arFields["CONTENT"], $p + strlen("#WORK_AREA#"));
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/footer.php", $footer);
}
if (isset($arFields["STYLES"])) {
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/styles.css", $arFields["STYLES"]);
}
if (isset($arFields["TEMPLATE_STYLES"])) {
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/template_styles.css", $arFields["TEMPLATE_STYLES"]);
}
if (isset($arFields["NAME"]) || isset($arFields["DESCRIPTION"]) || isset($arFields["SORT"])) {
$db_t = CSiteTemplate::GetList(array(), array("ID" => $ID), array("NAME", "DESCRIPTION", "SORT"));
$ar_t = $db_t->Fetch();
if (!isset($arFields["NAME"])) {
$arFields["NAME"] = $ar_t["NAME"];
}
if (!isset($arFields["DESCRIPTION"])) {
$arFields["DESCRIPTION"] = $ar_t["DESCRIPTION"];
}
if (!isset($arFields["SORT"])) {
$arFields["SORT"] = $ar_t["SORT"];
}
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/description.php", '<' . '?' . '$arTemplate = array(' . "\n" . ' "NAME" => "' . EscapePHPString($arFields['NAME']) . '",' . "\n" . ' "DESCRIPTION" => "' . EscapePHPString($arFields['DESCRIPTION']) . '",' . "\n" . ' "SORT" => ' . (intval($arFields['SORT']) > 0 ? intval($arFields['SORT']) : '""') . ',' . "\n" . ');' . "\n" . '?' . '>');
}
if (isset($arFields["STYLES_DESCRIPTION"]) && is_array($arFields["STYLES_DESCRIPTION"])) {
$str = '<' . '?' . "\nreturn array(\n";
foreach ($arFields["STYLES_DESCRIPTION"] as $code => $val) {
$str .= "\t\"" . EscapePHPString($code) . '" => "' . EscapePHPString($val) . "\",\n";
}
$str .= ");\n" . '?' . '>';
$APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"] . $path . "/.styles.php", $str);
}
return true;
}
示例15: UpdateCounters
function UpdateCounters($member_id, $task_id = false)
{
global $DB, $APPLICATION;
$member_id = intval($member_id);
$arMember = CControllerMember::GetMember($member_id);
if (!$arMember) {
$e = new CApplicationException("Member #" . $member_id . " is not found.");
$APPLICATION->ThrowException($e);
return false;
}
$dbr_group = CControllerGroup::GetByID($arMember["CONTROLLER_GROUP_ID"]);
if (!($ar_group = $dbr_group->Fetch())) {
$e = new CApplicationException("Group #" . $arMember["CONTROLLER_GROUP_ID"] . " is not found.");
$APPLICATION->ThrowException($e);
return false;
}
$strCommand = '$arResult = array("DATE_FORMAT" => CSite::GetDateFormat());';
if ($ar_group["CHECK_COUNTER_FREE_SPACE"] == "Y") {
$strCommand .= "\n" . '$quota = new CDiskQuota(); $disk_quota = $quota->GetDiskQuota(); if(is_bool($disk_quota))$arResult["COUNTER_FREE_SPACE"] = -1; else $arResult["COUNTER_FREE_SPACE"] = round($disk_quota/1024, 2);';
}
if ($ar_group["CHECK_COUNTER_SITES"] == "Y") {
$strCommand .= "\n" . '$dbr = CSite::GetList(($by="sort"), ($order="asc"), array("ACTIVE"=>Y)); $arResult["COUNTER_SITES"] = $dbr->SelectedRowsCount();';
}
if ($ar_group["CHECK_COUNTER_USERS"] == "Y") {
$strCommand .= "\n" . '$dbr = $GLOBALS["DB"]->Query("SELECT COUNT(1) as USER_COUNT FROM b_user U WHERE (U.EXTERNAL_AUTH_ID IS NULL OR U.EXTERNAL_AUTH_ID=\'\')"); $ar = $dbr->Fetch(); $arResult["COUNTER_USERS"] = $ar["USER_COUNT"];';
}
if ($ar_group["CHECK_COUNTER_LAST_AUTH"] == "Y") {
$strCommand .= "\n" . '$dbr = $GLOBALS["DB"]->Query("SELECT MAX(U.LAST_LOGIN) as LAST_LOGIN FROM b_user U"); $ar = $dbr->Fetch(); $arResult["COUNTER_LAST_AUTH"] = $ar["LAST_LOGIN"];';
}
$rsCounters = CControllerCounter::GetMemberCounters($member_id);
while ($arCounter = $rsCounters->Fetch()) {
$strCommand .= "\n" . '$arResult[' . $arCounter['ID'] . '] = eval("' . EscapePHPString($arCounter["COMMAND"]) . '");';
}
$strCommand .= "\n" . 'foreach($arResult as $k=>$v) echo urlencode($k),"=",urlencode($v),"&";';
foreach (GetModuleEvents("controller", "OnBeforeUpdateCounters", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($arMember, $ar_group, &$strCommand));
}
$command_result = CControllerMember::RunCommand($member_id, $strCommand, array(), $task_id, 'run_immediate');
if ($command_result === false) {
$e = $APPLICATION->GetException();
if (!is_object($e)) {
$e = new CApplicationException("Command execution error.");
$APPLICATION->ThrowException($e);
}
return false;
}
$ar_command_result = array();
parse_str($command_result, $ar_command_result);
//Try to guess encoding and convert to controller site charset
foreach ($ar_command_result as $k => $v) {
$ar_command_result[$k] = CUtil::ConvertToLangCharset($v);
}
$arFields = array("TIMESTAMP" => $arMember["TIMESTAMP_X"], "~COUNTERS_UPDATED" => $DB->CurrentTimeFunction());
if (array_key_exists('COUNTER_FREE_SPACE', $ar_command_result)) {
$arFields['COUNTER_FREE_SPACE'] = intval($ar_command_result['COUNTER_FREE_SPACE']);
}
if (array_key_exists('COUNTER_SITES', $ar_command_result)) {
$arFields['COUNTER_SITES'] = intval($ar_command_result['COUNTER_SITES']);
}
if (array_key_exists('COUNTER_USERS', $ar_command_result)) {
$arFields['COUNTER_USERS'] = intval($ar_command_result['COUNTER_USERS']);
}
if (array_key_exists('COUNTER_LAST_AUTH', $ar_command_result)) {
$arFields['COUNTER_LAST_AUTH'] = $DB->FormatDate($ar_command_result['COUNTER_LAST_AUTH'], 'YYYY-MM-DD HH:MI:SS', CSite::GetDateFormat());
}
if (!CControllerMember::Update($member_id, $arFields)) {
$e = $APPLICATION->GetException();
$e = new CApplicationException(GetMessage("CTRLR_MEM_COUNTERS_ERR1") . $e->GetString());
$APPLICATION->ThrowException($e);
return false;
}
CControllerCounter::UpdateMemberValues($member_id, $ar_command_result);
return $arFields;
}