本文整理汇总了PHP中bxstrrpos函数的典型用法代码示例。如果您正苦于以下问题:PHP bxstrrpos函数的具体用法?PHP bxstrrpos怎么用?PHP bxstrrpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bxstrrpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckCacheFiles_Rec
function CheckCacheFiles_Rec($strDir)
{
global $iGoodNum, $iOldNum, $iEmptyDirNum, $dLog;
if ($handle = @opendir($strDir))
{
while (($file = readdir($handle)) !== false)
{
if ($file == "." || $file == "..") continue;
if (is_dir($strDir."/".$file))
{
CheckCacheFiles_Rec($strDir."/".$file);
}
elseif (is_file($strDir."/".$file))
{
$ext = "";
$ext_pos = bxstrrpos($file, ".");
if ($ext_pos!==false)
$ext = substr($file, $ext_pos + 1);
$bCacheExp = False;
if ($ext=="html")
$bCacheExp = CPageCache::IsCacheExpired($strDir."/".$file);
elseif ($ext=="php")
$bCacheExp = CPHPCache::IsCacheExpired($strDir."/".$file);
if ($bCacheExp)
{
$iOldNum++;
@unlink($strDir."/".$file);
}
else
{
$iGoodNum++;
}
}
}
@closedir($handle);
}
clearstatcache();
$bEmptyFolder = True;
if ($handle = @opendir($strDir))
{
while (($file = readdir($handle)) !== false)
{
if ($file == "." || $file == "..") continue;
$bEmptyFolder = False;
break;
}
}
if ($bEmptyFolder)
{
$iEmptyDirNum++;
@rmdir($strDir);
}
}
示例2: array
$this->__component->__menu_values = $result;
if ($arParams["SHOW_NAVIGATION"] != "N") {
// text from main
CMain::InitPathVars($site, $path);
$DOC_ROOT = CSite::GetSiteDocRoot($site);
$path = $GLOBALS["APPLICATION"]->GetCurDir();
$arChain = array();
while (true) {
$path = rtrim($path, "/");
$chain_file_name = $DOC_ROOT . $path . "/.section.php";
if (file_exists($chain_file_name)) {
$sSectionName = "";
include $chain_file_name;
if (strlen($sSectionName) > 0) {
$arChain[] = array("TITLE" => $sSectionName, "LINK" => $path . "/");
}
}
if ($path . '/' == SITE_DIR) {
break;
}
if (strlen($path) <= 0) {
break;
}
$pos = bxstrrpos($path, "/");
if ($pos === false) {
break;
}
$path = substr($path, 0, $pos + 1);
}
$GLOBALS["APPLICATION"]->IncludeComponent("bitrix:breadcrumb", "webdav", array("START_FROM" => count($arChain) + $this->__component->__count_chain_item - 1, "PATH" => "", "SITE_ID" => "", "STR_TITLE" => $arParams["STR_TITLE"]), $component, array("HIDE_ICONS" => "Y"));
}
示例3: unpack
/**
* Unpack values from string (something like rsplit).
* Simple example for separator ".":
* <code>
* // Unpack all values:
* unpack('test.all.values', 0) -> ['test', 'all', 'values']
*
* // Unpack 2 values (by default). First element containing the rest of string.
* unpack('test.all.values') -> ['test.all', 'values']
*
* // Exception if separator is missing
* unpack('test.all values', 3) -> throws BadSignatureException
* </code>
*
* @param string $value String for unpacking.
* @param int $limit If $limit === 0 - unpack all values, default - 2.
* @return array
* @throws BadSignatureException
*/
protected function unpack($value, $limit = 2)
{
// Some kind of optimization
if ($limit === 0) {
if (strpos($value, $this->separator) === false) {
throw new BadSignatureException('Separator not found in value');
}
return explode($this->separator, $value);
}
$result = array();
while (--$limit > 0) {
$pos = bxstrrpos($value, $this->separator);
if ($pos === false) {
throw new BadSignatureException('Separator not found in value');
}
$result[] = \CUtil::binSubstr($value, $pos + 1);
$value = \CUtil::binSubstr($value, 0, $pos);
}
$result[] = $value;
return array_reverse($result);
}
示例4: __SearchTemplate
function __SearchTemplate($customTemplatePath = "")
{
$this->__file = "";
$this->__fileAlt = "";
$this->__folder = "";
$this->__hasCSS = null;
$this->__hasJS = null;
$arFolders = array();
$relativePath = $this->__component->GetRelativePath();
$parentRelativePath = "";
$parentTemplateName = "";
$parentComponent =& $this->__component->GetParent();
$defSiteTemplate = $this->__siteTemplate == ".default";
if ($parentComponent && $parentComponent->GetTemplate()) {
$parentRelativePath = $parentComponent->GetRelativePath();
$parentTemplateName = $parentComponent->GetTemplate()->GetName();
if (!$defSiteTemplate) {
$arFolders[] = array("path" => "/local/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true);
}
$arFolders[] = array("path" => "/local/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => ".default");
$arFolders[] = array("path" => "/local/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => "");
}
if (!$defSiteTemplate) {
$arFolders[] = array("path" => "/local/templates/" . $this->__siteTemplate . "/components" . $relativePath);
}
$arFolders[] = array("path" => "/local/templates/.default/components" . $relativePath, "site_template" => ".default");
$arFolders[] = array("path" => "/local/components" . $relativePath . "/templates", "site_template" => "");
if ($parentComponent) {
if (!$defSiteTemplate) {
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true);
}
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => ".default");
$arFolders[] = array("path" => "/bitrix/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath, "in_theme" => true, "site_template" => "");
}
if (!$defSiteTemplate) {
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $relativePath);
}
$arFolders[] = array("path" => BX_PERSONAL_ROOT . "/templates/.default/components" . $relativePath, "site_template" => ".default");
$arFolders[] = array("path" => "/bitrix/components" . $relativePath . "/templates", "site_template" => "");
if (strlen($customTemplatePath) > 0 && ($templatePageFile = $this->__SearchTemplateFile($customTemplatePath, $this->__page))) {
$this->__fileAlt = $customTemplatePath . "/" . $templatePageFile;
foreach ($arFolders as $folder) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $folder["path"] . "/" . $this->__name)) {
$this->__file = $folder["path"] . "/" . $this->__name . "/" . $templatePageFile;
$this->__folder = $folder["path"] . "/" . $this->__name;
}
if (strlen($this->__file) > 0) {
if (isset($folder["site_template"])) {
$this->__siteTemplate = $folder["site_template"];
}
if (isset($folder["in_theme"]) && $folder["in_theme"] === true) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
return strlen($this->__file) > 0;
}
static $cache = array();
$cache_id = $relativePath . "|" . $this->__siteTemplate . "|" . $parentRelativePath . "|" . $parentTemplateName . "|" . $this->__page . "|" . $this->__name;
if (!isset($cache[$cache_id])) {
foreach ($arFolders as $folder) {
$fname = $folder["path"] . "/" . $this->__name;
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if ($templatePageFile = $this->__SearchTemplateFile($fname, $this->__page)) {
$this->__file = $fname . "/" . $templatePageFile;
$this->__folder = $fname;
$this->__hasCSS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/style.css");
$this->__hasJS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/script.js");
}
} elseif (is_file($_SERVER["DOCUMENT_ROOT"] . $fname)) {
$this->__file = $fname;
if (strpos($this->__name, "/") !== false) {
$this->__folder = $folder["path"] . "/" . substr($this->__name, 0, bxstrrpos($this->__name, "/"));
}
}
} else {
if ($templatePageFile = $this->__SearchTemplateFile($folder["path"], $this->__name)) {
$this->__file = $folder["path"] . "/" . $templatePageFile;
}
}
if ($this->__file != "") {
if (isset($folder["site_template"])) {
$this->__siteTemplate = $folder["site_template"];
}
if (isset($folder["in_theme"]) && $folder["in_theme"] === true) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
$cache[$cache_id] = array($this->__folder, $this->__file, $this->__siteTemplate, $this->__templateInTheme, $this->__hasCSS, $this->__hasJS);
} else {
$this->__folder = $cache[$cache_id][0];
$this->__file = $cache[$cache_id][1];
//.........这里部分代码省略.........
示例5: GetContentType
function GetContentType($path, $bPhysicalName = false)
{
$io = CBXVirtualIo::GetInstance();
$pathX = $bPhysicalName ? $path : $io->GetPhysicalName($path);
if (function_exists("mime_content_type")) {
$type = mime_content_type($pathX);
} else {
$type = "";
}
if (strlen($type) <= 0 && function_exists("image_type_to_mime_type")) {
$arTmp = CFile::GetImageSize($pathX, true);
$type = $arTmp["mime"];
}
if (strlen($type) <= 0) {
$arTypes = array("jpeg" => "image/jpeg", "jpe" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "gif" => "image/gif", "bmp" => "image/bmp");
$type = $arTypes[strtolower(substr($pathX, bxstrrpos($pathX, ".") + 1))];
}
return $type;
}
示例6: GetFileName
function GetFileName($path)
{
$path = TrimUnsafe($path);
$path = str_replace("\\", "/", $path);
$path = rtrim($path, "/");
$p = bxstrrpos($path, "/");
if($p !== false)
return substr($path, $p+1);
return $path;
}
示例7: FetchFileAccessPerm
function FetchFileAccessPerm($path)
{
CMain::InitPathVars($site, $path);
$DOC_ROOT = CSite::GetSiteDocRoot($site);
$result = false;
if (($p = bxstrrpos($path, "/")) === false) {
return $result;
}
$path_file = substr($path, $p + 1);
$path_dir = substr($path, 0, $p);
$io = CBXVirtualIo::GetInstance();
if (!$io->FileExists($DOC_ROOT . $path_dir . "/.access.php")) {
return $result;
}
include $io->GetPhysicalName($DOC_ROOT . $path_dir . "/.access.php");
$result = array();
foreach ($PERM as $file => $arPerm) {
if ($file == $path_file) {
foreach ($arPerm as $group => $perm) {
$result[] = array('permFile' => $DOC_ROOT . $path_dir . "/.access.php", 'file' => $file, 'group' => $group, 'perm' => $perm);
}
}
}
return $result;
}
示例8: CopyFileAccessPermission
function CopyFileAccessPermission($path_from, $path_to, $bOverWrite = false)
{
CMain::InitPathVars($site_from, $path_from);
$DOC_ROOT_FROM = CSite::GetSiteDocRoot($site_from);
CMain::InitPathVars($site_to, $path_to);
//upper .access.php
if (($p = bxstrrpos($path_from, "/")) !== false) {
$path_from_file = substr($path_from, $p + 1);
$path_from_dir = substr($path_from, 0, $p);
} else {
return false;
}
$PERM = array();
$io = CBXVirtualIo::GetInstance();
if (!$io->FileExists($DOC_ROOT_FROM . $path_from_dir . "/.access.php")) {
return true;
}
include $io->GetPhysicalName($DOC_ROOT_FROM . $path_from_dir . "/.access.php");
$FILE_PERM = $PERM[$path_from_file];
if (count($FILE_PERM) > 0) {
return $this->SetFileAccessPermission(array($site_to, $path_to), $FILE_PERM, $bOverWrite);
}
return true;
}
示例9: __SearchTemplate
function __SearchTemplate($customTemplatePath = "")
{
$this->__file = "";
$this->__fileAlt = "";
$this->__folder = "";
$arFolders = array();
$relativePath = $this->__component->GetRelativePath();
$parentComponent = & $this->__component->GetParent();
if ($parentComponent)
{
$parentRelativePath = $parentComponent->GetRelativePath();
$parentTemplate = & $parentComponent->GetTemplate();
$parentTemplateName = $parentTemplate->GetName();
$arFolders[] = BX_PERSONAL_ROOT."/templates/".$this->__siteTemplate."/components".$parentRelativePath."/".$parentTemplateName.$relativePath;
$arFolders[] = BX_PERSONAL_ROOT."/templates/.default/components".$parentRelativePath."/".$parentTemplateName.$relativePath;
$arFolders[] = "/bitrix/components".$parentRelativePath."/templates/".$parentTemplateName.$relativePath;
}
$arFolders[] = BX_PERSONAL_ROOT."/templates/".$this->__siteTemplate."/components".$relativePath;
$arFolders[] = BX_PERSONAL_ROOT."/templates/.default/components".$relativePath;
$arFolders[] = "/bitrix/components".$relativePath."/templates";
if (strlen($customTemplatePath) > 0 && $templatePageFile = $this->__SearchTemplateFile($customTemplatePath, $this->__page))
{
$this->__fileAlt = $customTemplatePath."/".$templatePageFile;
for ($i = 0, $cnt = count($arFolders); $i < $cnt; $i++)
{
if (file_exists($_SERVER["DOCUMENT_ROOT"].$arFolders[$i]."/".$this->__name)
&& is_dir($_SERVER["DOCUMENT_ROOT"].$arFolders[$i]."/".$this->__name))
{
$this->__file = $arFolders[$i]."/".$this->__name."/".$templatePageFile;
$this->__folder = $arFolders[$i]."/".$this->__name;
}
if (StrLen($this->__file) > 0)
{
if ($i == 0 || $i == 3)
$this->__siteTemplate = $this->__siteTemplate;
elseif ($i == 1 || $i == 4)
$this->__siteTemplate = ".default";
else
$this->__siteTemplate = "";
if ($parentComponent && $i < 3)
$this->__templateInTheme = True;
else
$this->__templateInTheme = False;
break;
}
}
return (strlen($this->__file) > 0);
}
for ($i = 0, $cnt = count($arFolders); $i < $cnt; $i++)
{
if (file_exists($_SERVER["DOCUMENT_ROOT"].$arFolders[$i]."/".$this->__name))
{
if (is_dir($_SERVER["DOCUMENT_ROOT"].$arFolders[$i]."/".$this->__name))
{
if ($templatePageFile = $this->__SearchTemplateFile($arFolders[$i]."/".$this->__name, $this->__page))
{
$this->__file = $arFolders[$i]."/".$this->__name."/".$templatePageFile;
$this->__folder = $arFolders[$i]."/".$this->__name;
}
}
elseif (is_file($_SERVER["DOCUMENT_ROOT"].$arFolders[$i]."/".$this->__name))
{
$this->__file = $arFolders[$i]."/".$this->__name;
if (StrPos($this->__name, "/") !== False)
$this->__folder = $arFolders[$i]."/".SubStr($this->__name, 0, bxstrrpos($this->__name, "/"));
}
}
else
{
if ($templatePageFile = $this->__SearchTemplateFile($arFolders[$i], $this->__name))
$this->__file = $arFolders[$i]."/".$templatePageFile;
}
if (StrLen($this->__file) > 0)
{
if ($i == 0 || $i == 3)
$this->__siteTemplate = $this->__siteTemplate;
elseif ($i == 1 || $i == 4)
$this->__siteTemplate = ".default";
else
$this->__siteTemplate = "";
if ($parentComponent && $i < 3)
$this->__templateInTheme = True;
else
$this->__templateInTheme = False;
break;
}
}
//.........这里部分代码省略.........
示例10: die
CHTTP::SetStatus("403 Forbidden");
die("Index file is not found.");
}
} else {
CHTTP::SetStatus("404 Not Found");
die("File is not found.");
}
}
if (strtolower(substr($requestUriAbsolute, -4)) == ".php") {
include $io->GetPhysicalName($requestUriAbsolute);
} else {
$f = $io->GetFile($requestUriAbsolute);
$fsize = $f->GetFileSize();
$fModTime = $f->GetModificationTime();
$arTypes = array("jpeg" => "image/jpeg", "jpe" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "gif" => "image/gif", "bmp" => "image/bmp");
$ext = strtolower(substr($requestUriAbsolute, bxstrrpos($requestUriAbsolute, ".") + 1));
if (isset($arTypes[$ext])) {
header("Content-Type: " . $arTypes[$ext]);
} else {
$name = $io->ExtractNameFromPath($requestUri);
header("Content-Type: application/force-download; name=\"" . $name . "\"");
header("Content-Disposition: attachment; filename=\"" . $name . "\"");
}
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $fsize);
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Last-Modified: " . gmdate('D, d M Y H:i:s \\G\\M\\T', $fModTime));
$f->ReadFile();
}
示例11: CopyDirFiles
public static function CopyDirFiles($path_from, $path_to, $ReWrite = True, $Recursive = False)
{
if (strpos($path_to . "/", $path_from . "/") === 0 || realpath($path_to) === realpath($path_from)) {
return false;
}
if (is_dir($path_from)) {
CheckDirPath($path_to . "/");
} elseif (is_file($path_from)) {
$p = bxstrrpos($path_to, "/");
$path_to_dir = substr($path_to, 0, $p);
CheckDirPath($path_to_dir . "/");
if (file_exists($path_to) && !$ReWrite) {
return False;
}
@copy($path_from, $path_to);
if (is_file($path_to)) {
@chmod($path_to, BX_FILE_PERMISSIONS);
}
return True;
} else {
return True;
}
if ($handle = @opendir($path_from)) {
while (($file = readdir($handle)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
// skip files with non-safe names
if (!CLearnHelper::IsBaseFilenameSafe($file)) {
continue;
}
if (is_dir($path_from . "/" . $file) && $Recursive) {
self::CopyDirFiles($path_from . "/" . $file, $path_to . "/" . $file, $ReWrite, $Recursive);
} elseif (is_file($path_from . "/" . $file)) {
if (file_exists($path_to . "/" . $file) && !$ReWrite) {
continue;
}
@copy($path_from . "/" . $file, $path_to . "/" . $file);
@chmod($path_to . "/" . $file, BX_FILE_PERMISSIONS);
}
}
@closedir($handle);
return true;
}
return false;
}
示例12: GetFileAccessPermission
//.........这里部分代码省略.........
if (trim($path, "/") != "") {
$path = Rel2Abs("/", $path);
if ($path == "") {
return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
}
}
if (COption::GetOptionString("main", "controller_member", "N") == "Y" && COption::GetOptionString("main", "~controller_limited_admin", "N") == "Y") {
$bAdminM = is_object($USER) ? $USER->IsAdmin() : false;
} else {
$bAdminM = in_array("G1", $groups);
}
if ($bAdminM) {
return !$task_mode ? 'X' : array(CTask::GetIdByLetter('X', 'main', 'file'));
}
if (substr($path, -12) == "/.access.php" && !$bAdminM) {
return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
}
if (substr($path, -10) == "/.htaccess" && !$bAdminM) {
return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
}
$max_perm = "D";
$arGroupTask = array();
$io = CBXVirtualIo::GetInstance();
//in the group list * === "any group"
$groups[] = "*";
while (true) {
$path = rtrim($path, "");
$path = rtrim($path, "/");
if ($path == '') {
$access_file_name = "/.access.php";
$Dir = "/";
} else {
//file or folder
$pos = bxstrrpos($path, "/");
if ($pos === false) {
break;
}
$Dir = substr($path, $pos + 1);
//security fix: under Windows "my." == "my"
$Dir = TrimUnsafe($Dir);
//parent folder
$path = substr($path, 0, $pos + 1);
$access_file_name = $path . ".access.php";
}
if (array_key_exists($site . "|" . $access_file_name, $this->FILE_PERMISSION_CACHE)) {
$PERM = $this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name];
} else {
$PERM = array();
//file with rights array
if ($io->FileExists($DOC_ROOT . $access_file_name)) {
include $io->GetPhysicalName($DOC_ROOT . $access_file_name);
}
//windows files are case-insensitive
if ($bWin && !empty($PERM)) {
$PERM_TMP = array();
foreach ($PERM as $key => $val) {
$PERM_TMP[strtolower($key)] = $val;
}
$PERM = $PERM_TMP;
}
$this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name] = $PERM;
}
//check wheather the rights are assigned to this file\folder for these groups
if (isset($PERM[$Dir]) && is_array($PERM[$Dir])) {
$dir_perm = $PERM[$Dir];
foreach ($groups as $key => $group_id) {
示例13: GetContentType
function GetContentType($path, $bPhysicalName = false)
{
if ($bPhysicalName) {
$pathX = $path;
} else {
$io = CBXVirtualIo::GetInstance();
$pathX = $io->GetPhysicalName($path);
}
if (function_exists("mime_content_type")) {
$type = mime_content_type($pathX);
} else {
$type = "";
}
if ($type == "" && function_exists("image_type_to_mime_type")) {
$arTmp = CFile::GetImageSize($pathX, true);
$type = $arTmp["mime"];
}
if ($type == "") {
static $arTypes = array("jpeg" => "image/jpeg", "jpe" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "gif" => "image/gif", "bmp" => "image/bmp", "xla" => "application/vnd.ms-excel", "xlb" => "application/vnd.ms-excel", "xlc" => "application/vnd.ms-excel", "xll" => "application/vnd.ms-excel", "xlm" => "application/vnd.ms-excel", "xls" => "application/vnd.ms-excel", "xlsx" => "application/vnd.ms-excel", "xlt" => "application/vnd.ms-excel", "xlw" => "application/vnd.ms-excel", "dbf" => "application/vnd.ms-excel", "csv" => "application/vnd.ms-excel", "doc" => "application/msword", "docx" => "application/msword", "dot" => "application/msword", "rtf" => "application/msword", "rar" => "application/x-rar-compressed", "zip" => "application/zip");
$type = $arTypes[strtolower(substr($pathX, bxstrrpos($pathX, ".") + 1))];
}
if ($type == "") {
$type = "application/octet-stream";
}
return $type;
}
示例14: GetMessage
if($_SERVER["REQUEST_METHOD"]=="POST" && $_POST["action"]=="import" && $isAdmin && check_freetrix_sessid())
{
$ID = $_POST["ID"];
if(!is_uploaded_file($_FILES["tpath_file"]["tmp_name"]))
{
$strError .= GetMessage("MAIN_TEMPLATE_LOAD_ERR_LOAD");
}
else
{
if(strlen($ID)<=0)
{
$ID = basename($_FILES['tpath_file']['name']);
if($p = bxstrrpos($ID, ".gz"))
$ID = substr($ID, 0, $p);
if($p = bxstrrpos($ID, ".tar"))
$ID = substr($ID, 0, $p);
$ID = str_replace("\\", "", $ID);
$ID = str_replace("/", "", $ID);
}
if(strlen($ID)<=0)
{
$strError .= GetMessage("MAIN_TEMPLATE_LOAD_ERR_ID");
}
else
{
if(file_exists($_SERVER["DOCUMENT_ROOT"].FX_PERSONAL_ROOT."/templates/".$ID))
{
$strError .= str_replace("#TEMPLATE_NAME#", $ID, GetMessage("MAIN_TEMPLATE_LOAD_ERR_EX"));
}
示例15: __SearchTemplate
function __SearchTemplate($customTemplatePath = "")
{
$this->__file = "";
$this->__fileAlt = "";
$this->__folder = "";
$this->__hasCSS = null;
$this->__hasJS = null;
$arFolders = array();
$relativePath = $this->__component->GetRelativePath();
$parentComponent =& $this->__component->GetParent();
if ($parentComponent) {
$parentRelativePath = $parentComponent->GetRelativePath();
$parentTemplateName = $parentComponent->GetTemplate()->GetName();
$arFolders[] = BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath;
$arFolders[] = BX_PERSONAL_ROOT . "/templates/.default/components" . $parentRelativePath . "/" . $parentTemplateName . $relativePath;
$arFolders[] = "/bitrix/components" . $parentRelativePath . "/templates/" . $parentTemplateName . $relativePath;
} else {
$parentRelativePath = "";
$parentTemplateName = "";
}
$arFolders[] = BX_PERSONAL_ROOT . "/templates/" . $this->__siteTemplate . "/components" . $relativePath;
$arFolders[] = BX_PERSONAL_ROOT . "/templates/.default/components" . $relativePath;
$arFolders[] = "/bitrix/components" . $relativePath . "/templates";
if (strlen($customTemplatePath) > 0 && ($templatePageFile = $this->__SearchTemplateFile($customTemplatePath, $this->__page))) {
$this->__fileAlt = $customTemplatePath . "/" . $templatePageFile;
for ($i = 0, $cnt = count($arFolders); $i < $cnt; $i++) {
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $arFolders[$i] . "/" . $this->__name) && is_dir($_SERVER["DOCUMENT_ROOT"] . $arFolders[$i] . "/" . $this->__name)) {
$this->__file = $arFolders[$i] . "/" . $this->__name . "/" . $templatePageFile;
$this->__folder = $arFolders[$i] . "/" . $this->__name;
}
if (StrLen($this->__file) > 0) {
if ($i == 0 || $i == 3) {
} elseif ($i == 1 || $i == 4) {
$this->__siteTemplate = ".default";
} else {
$this->__siteTemplate = "";
}
if ($parentComponent && $i < 3) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
}
return strlen($this->__file) > 0;
}
static $cache;
$cache_id = $relativePath . "|" . $this->__siteTemplate . "|" . $parentRelativePath . "|" . $parentTemplateName . "|" . $this->__page . "|" . $this->__name;
if (!isset($cache)) {
$cache = array();
}
if (!isset($cache[$cache_id])) {
$i = 0;
foreach ($arFolders as $folder) {
$fname = $folder . "/" . $this->__name;
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if (is_dir($_SERVER["DOCUMENT_ROOT"] . $fname)) {
if ($templatePageFile = $this->__SearchTemplateFile($fname, $this->__page)) {
$this->__file = $fname . "/" . $templatePageFile;
$this->__folder = $fname;
$this->__hasCSS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/style.css");
$this->__hasJS = file_exists($_SERVER["DOCUMENT_ROOT"] . $fname . "/script.js");
}
} elseif (is_file($_SERVER["DOCUMENT_ROOT"] . $fname)) {
$this->__file = $fname;
if (StrPos($this->__name, "/") !== false) {
$this->__folder = $folder . "/" . SubStr($this->__name, 0, bxstrrpos($this->__name, "/"));
}
}
} else {
if ($templatePageFile = $this->__SearchTemplateFile($folder, $this->__name)) {
$this->__file = $folder . "/" . $templatePageFile;
}
}
if ($this->__file != "") {
if ($i == 0 || $i == 3) {
} elseif ($i == 1 || $i == 4) {
$this->__siteTemplate = ".default";
} else {
$this->__siteTemplate = "";
}
if ($parentComponent && $i < 3) {
$this->__templateInTheme = true;
} else {
$this->__templateInTheme = false;
}
break;
}
$i++;
}
$cache[$cache_id] = array($this->__folder, $this->__file, $this->__siteTemplate, $this->__templateInTheme, $this->__hasCSS, $this->__hasJS);
} else {
$this->__folder = $cache[$cache_id][0];
$this->__file = $cache[$cache_id][1];
$this->__siteTemplate = $cache[$cache_id][2];
$this->__templateInTheme = $cache[$cache_id][3];
$this->__hasCSS = $cache[$cache_id][4];
$this->__hasJS = $cache[$cache_id][5];
}
//.........这里部分代码省略.........