Пример #1
0
 function __GetSEFRealUrl($url)
 {
     $arResult = CUrlRewriter::GetList(array('QUERY' => $url));
     if (is_array($arResult) && count($arResult) > 0) {
         return $arResult[0]['PATH'];
     } else {
         return false;
     }
 }
Пример #2
0
    if (empty($aMsg)) {
        if (strlen($apply) <= 0) {
            LocalRedirect("/bitrix/admin/urlrewrite_list.php?lang=" . LANG . "&filter_site_id=" . UrlEncode($site_id) . "&" . GetFilterParams("filter_", false));
        }
    } else {
        $message = new CAdminMessage(GetMessage("SAE_ERROR"), new CAdminException($aMsg));
        $bVarsFromForm = true;
    }
}
if (StrLen($CONDITION) > 0) {
    $APPLICATION->SetTitle(GetMessage("MURL_EDIT"));
} else {
    $APPLICATION->SetTitle(GetMessage("MURL_ADD"));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$arResultList = CUrlRewriter::GetList(array("SITE_ID" => $site_id, "CONDITION" => $CONDITION));
if (count($arResultList) <= 0) {
    unset($CONDITION);
    $arResult = array();
    $str_CONDITION_OLD = "";
    $str_CONDITION = "";
    $str_ID = "";
    $str_FILE_PATH = "";
    $str_RULE = "";
} else {
    $arResult = $arResultList[0];
    $str_CONDITION_OLD = htmlspecialcharsbx($arResult["CONDITION"]);
    $str_CONDITION = htmlspecialcharsbx($arResult["CONDITION"]);
    $str_ID = htmlspecialcharsbx($arResult["ID"]);
    $str_FILE_PATH = htmlspecialcharsbx($arResult["PATH"]);
    $str_RULE = htmlspecialcharsbx($arResult["RULE"]);
Пример #3
0
             if ($_SERVER["REQUEST_METHOD"] == $method) {
                 return true;
             }
         }
         if (strpos($_SERVER['HTTP_USER_AGENT'], "Microsoft Office") !== false && strpos($_SERVER['HTTP_USER_AGENT'], "Outlook") === false || strpos($_SERVER['HTTP_USER_AGENT'], "MiniRedir") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "WebDAVFS") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "davfs2") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "Sardine") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "gvfs") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "LibreOffice") !== false) {
             return true;
         }
         return false;
     }
 }
 $bNeedInclude = true;
 if ($_SERVER["REQUEST_METHOD"] == "HEAD") {
     $res = strtolower($_SERVER["HTTP_USER_AGENT"]);
     if (strpos($res, "microsoft") === false && strlen($_SERVER["REAL_FILE_PATH"]) <= 0 && substr($_SERVER['REQUEST_URI'], -1, 1) == '/') {
         $bNeedInclude = false;
         $res = CUrlRewriter::GetList(array("QUERY" => $_SERVER['REQUEST_URI']));
         foreach ($res as $res_detail) {
             if (strpos($res_detail["ID"], "webdav") !== false || strpos($res_detail["ID"], "disk") !== false || strpos($res_detail["ID"], "socialnetwork") !== false) {
                 $bNeedInclude = true;
                 break;
             }
         }
     }
 }
 if (__webdavIsDavHeaders() && $bNeedInclude) {
     if (CModule::includeModule('ldap') && CLdapUtil::isBitrixVMAuthSupported()) {
         CLdapUtil::bitrixVMAuthorize();
     }
     if (!$_SERVER['PHP_AUTH_USER'] || !$_SERVER['PHP_AUTH_USER']) {
         $res = !empty($_SERVER['REDIRECT_REMOTE_USER']) ? $_SERVER['REDIRECT_REMOTE_USER'] : $_SERVER['REMOTE_USER'];
         if (!empty($res) && preg_match('/(?<=(basic\\s))(.*)$/is', $res, $matches)) {
Пример #4
0
 /**
  * Sets right search path for comments, likes etc.
  * http://jabber.bx/view.php?id=25340
  * @param int $forumID - forum's ID were comments saving (for example $arParams['FORUM_ID'])
  * @param str $rightPath - wich path must leads to the comment ( for example: "/comment/#MESSAGE_ID#/" )
  * @param str $urlRewriterPath - wich path leads to curent module (complex component) ( for example: "/services/wiki.php" )
  * @return bool true|false
  */
 static function SetCommentPath($forumID, $rightPath, $urlRewriterPath)
 {
     if (!$forumID || !CModule::IncludeModule('forum') || !$rightPath || !$urlRewriterPath) {
         return false;
     }
     $arRewriter = CUrlRewriter::GetList(array("PATH" => $urlRewriterPath));
     //http://jabber.bx/view.php?id=25340
     if (!is_array($arRewriter) || empty($arRewriter)) {
         return false;
     }
     $rewriteCondition = str_replace(array("#", "^"), "", $arRewriter[0]["CONDITION"]);
     $rightCommentsPath = $rewriteCondition . $rightPath;
     $arActualCommentsPath = CWikiUtils::GetCommentPath($forumID);
     if (!is_array($arActualCommentsPath)) {
         return false;
     }
     $arUpdateForum = array();
     foreach ($arActualCommentsPath as $site => $path) {
         if ($path != $rightCommentsPath) {
             $arUpdateForum["SITES"][$site] = $rightCommentsPath;
         }
     }
     if (!empty($arUpdateForum)) {
         CForumNew::Update($forumID, $arUpdateForum);
     }
     return true;
 }
Пример #5
0
    function OnBeforeProlog()
    {
        global $USER, $APPLICATION;
        if (isset($_SERVER["PHP_AUTH_USER"]) && (!defined("NOT_CHECK_PERMISSIONS") || NOT_CHECK_PERMISSIONS !== true) && (CWebDavBase::IsDavHeaders("check_all") || !$USER->IsAuthorized())) {
            if (strlen($_SERVER["PHP_AUTH_USER"]) > 0 and strlen($_SERVER["PHP_AUTH_PW"]) > 0) {
                if (strpos($_SERVER["PHP_AUTH_USER"], $_SERVER['HTTP_HOST'] . "\\") === 0) {
                    $_SERVER["PHP_AUTH_USER"] = str_replace($_SERVER['HTTP_HOST'] . "\\", "", $_SERVER["PHP_AUTH_USER"]);
                } elseif (strpos($_SERVER["PHP_AUTH_USER"], $_SERVER['SERVER_NAME'] . "\\") === 0) {
                    $_SERVER["PHP_AUTH_USER"] = str_replace($_SERVER['SERVER_NAME'] . "\\", "", $_SERVER["PHP_AUTH_USER"]);
                }
                $arAuthResult = $USER->Login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"], "N");
                $APPLICATION->arAuthResult = $arAuthResult;
            }
        }
        if (($_SERVER['REQUEST_METHOD'] == 'OPTIONS' || $_SERVER['REQUEST_METHOD'] == 'PROPFIND') && (strlen($_SERVER["REAL_FILE_PATH"]) <= 0 && substr($_SERVER['REQUEST_URI'], -1, 1) == '/' || strpos($_SERVER['REQUEST_URI'], 'personal') !== false && strlen($_SERVER["REAL_FILE_PATH"]) <= 0 && !file_exists($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI']))) {
            $res = CUrlRewriter::GetList(array("QUERY" => $_SERVER['REQUEST_URI']));
            $good_res = true;
            $file_path = "";
            foreach ($res as $res_detail) {
                if (strpos($res_detail["ID"], "webdav") !== false || strpos($res_detail["ID"], "socialnetwork") !== false) {
                    $good_res = !$USER->IsAuthorized();
                    break;
                }
            }
            if ($good_res) {
                header("MS-Author-Via: DAV");
                if (strpos($_SERVER['HTTP_USER_AGENT'], "Microsoft-WebDAV-MiniRedir") !== false && $_SERVER['REQUEST_METHOD'] == "OPTIONS") {
                    CWebDavBase::base_OPTIONS();
                    die;
                }
                if ($_SERVER['REQUEST_METHOD'] != 'PROPFIND') {
                    if (!$USER->IsAuthorized()) {
                        CWebDavBase::SetAuthHeader();
                        die;
                    }
                    CWebDavBase::base_OPTIONS();
                    die;
                }
                if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') {
                    if (!$USER->IsAuthorized()) {
                        CWebDavBase::SetAuthHeader();
                        die;
                    }
                    CWebDavBase::SetStatus('207 Multi-Status');
                    echo '<?xml version="1.0" encoding="utf-8" ?>
<D:multistatus xmlns:D="DAV:" xmlns:Office="urn:schemas-microsoft-com:office:office" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:Z="urn:schemas-microsoft-com:">
<D:response>
	<D:href>http://' . htmlspecialcharsbx($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '</D:href>
	<D:propstat>
		<D:prop>
			<D:displayname></D:displayname>
			<D:lockdiscovery/><D:supportedlock/>
			<D:isFolder>t</D:isFolder>
			<D:iscollection>1</D:iscollection>
			<D:ishidden>0</D:ishidden>
			<D:getcontenttype>application/octet-stream</D:getcontenttype>
			<D:getcontentlength>0</D:getcontentlength>
			<D:resourcetype><D:collection/></D:resourcetype>
			<Repl:authoritative-directory>t</Repl:authoritative-directory>
			<D:getlastmodified>2008-10-29T13:58:59Z</D:getlastmodified>
			<D:creationdate>2008-10-29T13:58:59Z</D:creationdate>
			<Repl:repl-uid>rid:{D77F5F6A-44A9-4015-AB49-4D3A439808C1}</Repl:repl-uid>
			<Repl:resourcetag>rt:D77F5F6A-44A9-4015-AB49-4D3A439808C1@00000000000</Repl:resourcetag>
			<D:getetag>&quot;{D77F5F6A-44A9-4015-AB49-4D3A439808C1},0&quot;</D:getetag>
		</D:prop>
		<D:status>HTTP/1.1 200 OK</D:status>
	</D:propstat>
</D:response>
</D:multistatus>';
                    die;
                }
            }
        } elseif (CWebDavBase::IsDavHeaders("check_all")) {
            if (!$USER->IsAuthorized()) {
                $res = CUrlRewriter::GetList(array("QUERY" => $_SERVER['REQUEST_URI']));
                $good_res = true;
                $file_path = "";
                foreach ($res as $res_detail) {
                    if (strpos($res_detail["ID"], "webdav") !== false || strpos($res_detail["ID"], "socialnetwork") !== false) {
                        $good_res = !$USER->IsAuthorized();
                        break;
                    }
                }
                if ($good_res) {
                    CWebDavBase::SetAuthHeader();
                    die;
                }
            }
            return true;
        }
    }
Пример #6
0
{
	CUtil::JSPostUnescape();
	CModule::IncludeModule("fileman");

	$f = $io->GetFile($absoluteFilePath);

	$arUndoParams = array(
		'module' => 'fileman',
		'undoType' => 'delete_file',
		'undoHandler' => 'CFileman::UndoFileDelete',
		'arContent' => array(
			'path' => $path,
			'content' => $f->GetContents(),
			'site' => $site,
			'perm' => CFileMan::FetchFileAccessPerm(Array($site, $path)),
			'SEF' => CUrlRewriter::GetList(array("PATH" => $path))
		)
	);

	$success = BXDeleteFromSystem($absoluteFilePath, $path, $site);
	if ($success)
	{
		if ($deleteFromMenu)
			$arUndoParams['arContent']['menu'] = BXDeleteFromMenu($documentRoot, $path, $site);

		if($_GET['subdialog'] == 'Y')
			echo "<script>structReload('".urlencode($_REQUEST["path"])."');</script>";

		$ID = CUndo::Add($arUndoParams);

		CUndo::ShowUndoMessage($ID);
Пример #7
0
        }
    }
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        switch ($_REQUEST['action']) {
            case "delete":
                @set_time_limit(0);
                CUrlRewriter::Delete(array("SITE_ID" => $filter_site_id, "CONDITION" => $ID));
                break;
        }
    }
}
// инициализация списка - выборка данных
$arResultList = CUrlRewriter::GetList($arFilter, array($by => $order));
$dbResultList = new CDBResult();
$dbResultList->InitFromArray($arResultList);
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
// установке параметров списка
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SAA_NAV")));
// заголовок списка
$lAdmin->AddHeaders(array(array("id" => "CONDITION", "content" => GetMessage("MURL_USL"), "sort" => "CONDITION", "default" => true), array("id" => "ID", "content" => GetMessage("MURL_COMPONENT"), "sort" => "ID", "default" => true), array("id" => "PATH", "content" => GetMessage("MURL_FILE"), "sort" => "PATH", "default" => true), array("id" => "RULE", "content" => GetMessage("MURL_RULE"), "sort" => "RULE", "default" => true)));
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
// построение списка
while ($arResult = $dbResultList->NavNext(true, "f_")) {
    $row =& $lAdmin->AddRow($f_CONDITION, $arResult, "urlrewrite_edit.php?CONDITION=" . UrlEncode($arResult["CONDITION"]) . "&lang=" . LANG . "&site_id=" . UrlEncode($filter_site_id), GetMessage("MURL_EDIT"));
    $row->AddField("CONDITION", $f_CONDITION);
    $row->AddField("ID", $f_ID);
    $row->AddField("PATH", $f_PATH);
Пример #8
0
 public static function GetULRsFromIBlockID($IBLOCK_ID, $params = array())
 {
     $IBLOCK_ID = intval($IBLOCK_ID);
     if ($IBLOCK_ID <= 0) {
         return false;
     }
     $params = is_array($params) ? $params : array();
     $params["path"] = trim(!!$params["path"] ? $params["path"] : (!!$params["PATH"] ? $params["PATH"] : ""));
     if (empty($params["path"])) {
         $params["path"] = CIBlock::GetArrayByID($IBLOCK_ID, "DETAIL_PAGE_URL");
     }
     // Params for socialnetwork
     static $arExtranetSite = false;
     static $defSite = false;
     $params["SECTION_ID"] = intval($params["SECTION_ID"]);
     // root section id
     $params["ELEMENT_ID"] = intval($params["ELEMENT_ID"]);
     $arSection = is_array($params["SECTION"]) ? $params["SECTION"] : array();
     // root section
     $arElement = is_array($params["ELEMENT"]) ? $params["ELEMENT"] : array();
     if (empty($arSection)) {
         if ($params["SECTION_ID"] > 0) {
             $arSection = CIBlockSection::GetList(array(), array("ID" => $params["SECTION_ID"], 'CHECK_PERMISSIONS' => 'N'), false, array('ID', 'IBLOCK_ID', 'SOCNET_GROUP_ID', 'CREATED_BY'))->fetch();
         } else {
             if ($params["ELEMENT_ID"] > 0 && empty($arElement)) {
                 $arElement = CIBlockElement::GetList(array(), array('ID' => $params["ELEMENT_ID"]), false, false, array('ID', 'IBLOCK_SECTION_ID', 'IBLOCK_CODE', 'IBLOCK_ID'))->fetch();
             }
             if (!empty($arElement) && $arElement["IBLOCK_SECTION_ID"] > 0) {
                 $res = CWebDavSymlinkHelper::getNavChain($IBLOCK_ID, $arElement["IBLOCK_SECTION_ID"]);
                 if (!!$res) {
                     $arSection = reset($res);
                 }
             }
         }
     }
     if (empty($arSection) || $arSection["IBLOCK_ID"] != $IBLOCK_ID) {
         $arSection = array();
         $arElement = array();
     }
     // Params for socialnetwork /
     if (strpos($params["path"], "#SITE_DIR#") !== false) {
         $params["path"] = str_replace("#SITE_DIR#", SITE_DIR, $params["path"]);
     } else {
         if (array_key_exists("SITE_ID", $params) && CModule::IncludeModule('extranet') && CExtranet::GetExtranetSiteID() == $params["SITE_ID"]) {
             if ($arExtranetSite === false) {
                 $rsSites = CSite::GetByID(SITE_ID);
                 $arExtranetSite = $rsSites->Fetch();
                 unset($rsSites);
             }
             if ($arExtranetSite) {
                 if ($defSite === false) {
                     $defSite = CSite::GetDefSite();
                 }
                 $params["path"] = $arExtranetSite["DIR"] . $params["path"];
             }
         }
     }
     $SEF_FOLDER = "/";
     $SEF_URL_TEMPLATES = array();
     $arUrlRewrite = CUrlRewriter::GetList(!empty($params["path"]) ? array("QUERY" => str_replace("//", "/", $params["path"])) : array());
     $entity = false;
     foreach ($arUrlRewrite as $arRule) {
         if (!in_array($arRule["ID"], array("bitrix:webdav", "bitrix:socialnetwork", "bitrix:socialnetwork_user", "bitrix:socialnetwork_group"))) {
             continue;
         }
         $arComponents = WDGetComponentsOnPage($arRule["PATH"]);
         $firstMet = !empty($params["path"]);
         foreach ($arComponents as $arComponent) {
             if ($arComponent["COMPONENT_NAME"] == $arRule["ID"]) {
                 $SEF_FOLDER = $arComponent["PARAMS"]["SEF_FOLDER"];
                 if (strpos($arRule["ID"], "bitrix:socialnetwork") === 0) {
                     if ($arRule["ID"] == "bitrix:socialnetwork" && $arComponent["PARAMS"]["FILES_GROUP_IBLOCK_ID"] == $arComponent["PARAMS"]["FILES_USER_IBLOCK_ID"] && ($firstMet || $arComponent["PARAMS"]["FILES_USER_IBLOCK_ID"] == $IBLOCK_ID)) {
                         $entity = $arSection["SOCNET_GROUP_ID"] > 0 ? "group" : "user";
                     } else {
                         if (($firstMet || $arComponent["PARAMS"]["FILES_USER_IBLOCK_ID"] == $IBLOCK_ID) && ($arRule["ID"] == "bitrix:socialnetwork_user" || $arRule["ID"] == "bitrix:socialnetwork")) {
                             $entity = "user";
                         } else {
                             if (($firstMet || $arComponent["PARAMS"]["FILES_GROUP_IBLOCK_ID"] == $IBLOCK_ID) && ($arRule["ID"] == "bitrix:socialnetwork_group" || $arRule["ID"] == "bitrix:socialnetwork")) {
                                 $entity = "group";
                             }
                         }
                     }
                     if (!!$entity) {
                         $SEF_URL_TEMPLATES = $entity == "user" ? array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["user_files"], "view" => "user/#user_id#/files/element/view/#element_id#/", "edit" => "user/#user_id#/files/element/edit/#element_id#/#action#/", "history" => "user/#user_id#/files/element/history/#element_id#/", "history_get" => "user/#user_id#/files/element/historyget/#element_id#/#element_name#") : array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["group_files"], "view" => "group/#group_id#/files/element/view/#element_id#/", "edit" => "group/#group_id#/files/element/edit/#element_id#/#action#/", "history" => "group/#group_id#/files/element/history/#element_id#/", "history_get" => "group/#group_id#/files/element/historyget/#element_id#/#element_name#");
                     }
                 } else {
                     if ($arRule["ID"] == "bitrix:webdav" && ($firstMet || $arComponent["PARAMS"]["IBLOCK_ID"] == $IBLOCK_ID)) {
                         $entity = "lib";
                         $SEF_URL_TEMPLATES = array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["sections"], "view" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element"], "edit" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_edit"], "history" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_history"], "history_get" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_history_get"]);
                     }
                 }
                 if (!!$entity) {
                     $SEF_URL_TEMPLATES["component"] = $arRule["ID"];
                     break 2;
                 }
             }
         }
     }
     $repl = array("#id#", "#ELEMENT_ID#", "#element_id#", "#name#", "#ELEMENT_NAME#", "#element_name#", "#action#", "//");
     $patt = array("#ELEMENT_ID#", "#ELEMENT_ID#", "#ELEMENT_ID#", "#ELEMENT_NAME#", "#ELEMENT_NAME#", "#ELEMENT_NAME#", "#ACTION#", "/");
     if ($entity != "lib") {
         $repl[] = "#SOCNET_USER_ID#";
         $patt[] = "#USER_ID#";
         $repl[] = "#socnet_user_id#";
         $patt[] = "#USER_ID#";
         $repl[] = "#user_id#";
         $patt[] = "#USER_ID#";
         $repl[] = "#SOCNET_GROUP_ID#";
         $patt[] = "#GROUP_ID#";
         $repl[] = "#socnet_group_id#";
         $patt[] = "#GROUP_ID#";
         $repl[] = "#group_id#";
         $patt[] = "#GROUP_ID#";
         $repl[] = "#SOCNET_OBJECT_ID#";
         $patt[] = "#SOCNET_OBJECT#";
         $repl[] = "#socnet_object_id#";
         $patt[] = "#SOCNET_OBJECT#";
         $repl[] = "#socnet_object#";
         $patt[] = "#SOCNET_OBJECT#";
         if (!empty($arSection)) {
             $repl[] = "#USER_ID#";
             $patt[] = $arSection["CREATED_BY"];
             $repl[] = "#GROUP_ID#";
             $patt[] = $arSection["SOCNET_GROUP_ID"];
             $patt[] = "#SOCNET_OBJECT#";
             $patt[] = $arSection["SOCNET_GROUP_ID"] > 0 ? "group" : "user";
         }
     }
     if (!empty($arElement)) {
         $repl[] = "#ID#";
         $patt[] = $arElement["ID"];
         $repl[] = "#ELEMENT_ID#";
         $patt[] = $arElement["ID"];
         $repl[] = "#NAME#";
         $patt[] = $arElement["NAME"];
         $repl[] = "#ELEMENT_NAME#";
         $patt[] = $arElement["NAME"];
     }
     foreach ($SEF_URL_TEMPLATES as $key => $val) {
         $SEF_URL_TEMPLATES[$key] = str_replace($repl, $patt, $SEF_FOLDER . "/" . $val);
     }
     $SEF_URL_TEMPLATES["path"] = str_replace(array("#path#", "#PATH#"), "", $SEF_URL_TEMPLATES["path"]);
     $SEF_URL_TEMPLATES["delete_dropped"] = str_replace("#ACTION#", "delete_dropped", $SEF_URL_TEMPLATES["edit"]);
     $SEF_URL_TEMPLATES["edit"] = str_replace("#ACTION#", "edit", $SEF_URL_TEMPLATES["edit"]);
     $SEF_URL_TEMPLATES["entity"] = $entity;
     return $SEF_URL_TEMPLATES;
 }
Пример #9
0
if (!is_array($arParams)) {
    $arParams = array();
}
if (strlen($arParams["site_id"]) <= 0) {
    $arParams["site_id"] = "s1";
}
//Import XML
if ($IBLOCK_ID = CIBlockCMLImport::GetIBlockByXML_ID("content-news")) {
    //Create directory and copy files
    $rsElements = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID), false, array("nTopSize" => 1), array("ID"));
    $arElement = $rsElements->Fetch();
    $search = array("#IBLOCK.ID(XML_ID=content-news)#", "#IBLOCK_ELEMENT.ID(IBLOCK_XML_ID=content-news)#");
    $replace = array($IBLOCK_ID, $arElement["ID"]);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/", $_SERVER["DOCUMENT_ROOT"] . "/examples", false, false);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/custom-registration/", $_SERVER["DOCUMENT_ROOT"] . "/examples/custom-registration", false, true);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/download/", $_SERVER["DOCUMENT_ROOT"] . "/examples/download", false, true);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/menu/", $_SERVER["DOCUMENT_ROOT"] . "/examples/menu", false, true);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/rss/", $_SERVER["DOCUMENT_ROOT"] . "/examples/rss", false, true);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/sef/", $_SERVER["DOCUMENT_ROOT"] . "/examples/sef", false, true);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/examples/feedback/", $_SERVER["DOCUMENT_ROOT"] . "/examples/feedback", false, true);
    CopyDirFiles(dirname(__FILE__) . "/bitrix/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix", false, true);
    DEMO_IBlock_CopyFiles(array(dirname(__FILE__), "/public/language/" . LANGUAGE_ID . "/examples/my-components/"), "/examples/my-components/", false, $search, $replace);
    CopyDirFiles(dirname(__FILE__) . "/public/language/" . LANGUAGE_ID . "/upload/", $_SERVER["DOCUMENT_ROOT"] . "/upload", false, true);
    $CONDITION = "#^/examples/my-components/news/#";
    $arResult = CUrlRewriter::GetList(array("SITE_ID" => $arParams["site_id"], "CONDITION" => $CONDITION));
    if (count($arResult) <= 0) {
        CUrlRewriter::Add(array("SITE_ID" => $arParams["site_id"], "CONDITION" => $CONDITION, "ID" => "demo:news", "PATH" => "/examples/my-components/news_sef.php"));
    }
    //Add menu item
    DEMO_IBlock_AddMenuItem("/.top.menu.php", array(GetMessage("DEMO_EXAMPLES_MENU"), "/examples/", array(), array(), ""));
}
Пример #10
0
    $deleteFromMenu = isset($_REQUEST["delete_from_menu"]) && $_REQUEST["delete_from_menu"] == "Y";
    if (!check_bitrix_sessid()) {
        $strWarning = GetMessage("MAIN_SESSION_EXPIRED");
    }
} else {
    if ($io->ExtractNameFromPath($path) == "index.php") {
        $strNotice = GetMessage("PAGE_DELETE_INDEX_WARNING");
    }
    $deleteFromMenu = true;
}
//Delete File
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST["save"]) && $strWarning == "") {
    CUtil::JSPostUnescape();
    CModule::IncludeModule("fileman");
    $f = $io->GetFile($absoluteFilePath);
    $arUndoParams = array('module' => 'fileman', 'undoType' => 'delete_file', 'undoHandler' => 'CFileman::UndoFileDelete', 'arContent' => array('path' => $path, 'content' => $f->GetContents(), 'site' => $site, 'perm' => CFileMan::FetchFileAccessPerm(array($site, $path)), 'SEF' => CUrlRewriter::GetList(array("PATH" => $path))));
    $success = BXDeleteFromSystem($absoluteFilePath, $path, $site);
    if ($success) {
        if ($deleteFromMenu) {
            $arUndoParams['arContent']['menu'] = BXDeleteFromMenu($documentRoot, $path, $site);
        }
        if ($_GET['subdialog'] == 'Y') {
            echo "<script>structReload('" . urlencode($_REQUEST["path"]) . "');</script>";
        }
        $ID = CUndo::Add($arUndoParams);
        CUndo::ShowUndoMessage($ID);
        //CUndo::Escape($ID);
        $popupWindow->Close($bReload = $_GET['subdialog'] != 'Y', $back_url);
    } else {
        $strWarning = GetMessage("PAGE_DELETE_ERROR_OCCURED");
    }
Пример #11
0
function WDUFGetPathOptions($path, $IBLOCK_ID, $arSection, $arElement = array())
{
    static $arExtranetSite = false;
    static $defSite = false;
    $path = !empty($path) && is_string($path) ? $path : '';
    $IBLOCK_ID = intval($IBLOCK_ID);
    $SEF_FOLDER = "/";
    $SEF_URL_TEMPLATES = array();
    // old version
    $entity = strpos($path, "#user_id#") !== false || strpos($path, "#USER_ID#") !== false ? "user" : (strpos($path, "#group_id#") !== false || strpos($path, "#GROUP_ID#") !== false ? "group" : "lib");
    if (strpos($path, "#SITE_DIR#") !== false) {
        $path = str_replace("#SITE_DIR#", SITE_DIR, $path);
    } else {
        if (CModule::IncludeModule('extranet') && CExtranet::GetExtranetSiteID() == SITE_ID) {
            if ($arExtranetSite === false) {
                $rsSites = CSite::GetByID(SITE_ID);
                $arExtranetSite = $rsSites->Fetch();
                unset($rsSites);
            }
            if ($arExtranetSite && strpos($path, $arExtranetSite["DIR"]) === false) {
                if ($defSite === false) {
                    $defSite = CSite::GetDefSite();
                }
                if ($entity == "user") {
                    $intranet_path = COption::GetOptionString("socialnetwork", "user_page", false, $defSite);
                    $extranet_path = COption::GetOptionString("socialnetwork", "user_page", false, SITE_ID);
                    if (strpos($path, $intranet_path) === 0) {
                        $path = str_replace($intranet_path, $extranet_path, $path);
                    }
                } elseif ($entity == "group") {
                    $intranet_path = COption::GetOptionString("socialnetwork", "workgroups_page", false, $defSite);
                    $extranet_path = COption::GetOptionString("socialnetwork", "workgroups_page", false, SITE_ID);
                    if (strpos($path, $intranet_path) === 0) {
                        $path = str_replace($intranet_path, $extranet_path, $path);
                    }
                } else {
                    $path = $arExtranetSite["DIR"] . $path;
                }
            }
        }
    }
    $path = str_replace(array("///", "//"), "/", $path);
    if ($entity != "lib") {
        $SEF_FOLDER = substr($path, 0, strpos(strtolower($path), $entity == "user" ? "user/#user_id#/files" : "group/#group_id#/files"));
        $SEF_URL_TEMPLATES = $entity == "user" ? array("path" => "user/#user_id#/files/lib/#path#", "view" => "user/#user_id#/files/element/view/#element_id#/", "edit" => "user/#user_id#/files/element/edit/#element_id#/#action#/", "history" => "user/#user_id#/files/element/history/#element_id#/", "history_get" => "user/#user_id#/files/element/historyget/#element_id#/#element_name#") : array("path" => "group/#group_id#/files/#path#", "view" => "group/#group_id#/files/element/view/#element_id#/", "edit" => "group/#group_id#/files/element/edit/#element_id#/#action#/", "history" => "group/#group_id#/files/element/history/#element_id#/", "history_get" => "group/#group_id#/files/element/historyget/#element_id#/#element_name#");
    }
    if ($entity == "lib" && $path !== '' && $IBLOCK_ID > 0) {
        $arUrlRewrite = CUrlRewriter::GetList(array("QUERY" => $path));
        $arRule = array();
        foreach ($arUrlRewrite as $arRule) {
            if ($arRule["ID"] == "bitrix:webdav") {
                $entity = "lib";
                $wdSefPathSettings = COption::GetOptionString('webdav', 'webdav_comp_sef_path_' . $IBLOCK_ID);
                if ($wdSefPathSettings && CheckSerializedData($wdSefPathSettings)) {
                    $wdSefPathSettings = @unserialize($wdSefPathSettings);
                    $SEF_FOLDER = $wdSefPathSettings['SEF_FOLDER'];
                    $wdSefPathSettings = $wdSefPathSettings['SEF_URL_TEMPLATES'];
                    if (is_array($wdSefPathSettings)) {
                        $SEF_URL_TEMPLATES = array("path" => $wdSefPathSettings["sections"], "view" => $wdSefPathSettings["element"], "edit" => $wdSefPathSettings["element_edit"], "history" => $wdSefPathSettings["element_history"], "history_get" => $wdSefPathSettings["element_history_get"]);
                        break;
                    }
                }
            }
            $arComponents = WDUFGetComponentsOnPage($arRule["PATH"]);
            $entity = false;
            foreach ($arComponents as $arComponent) {
                if ($arComponent["COMPONENT_NAME"] == $arRule["ID"]) {
                    $SEF_FOLDER = $arComponent["PARAMS"]["SEF_FOLDER"];
                    if (strpos($arRule["ID"], "bitrix:socialnetwork") === 0) {
                        if ($arRule["ID"] == "bitrix:socialnetwork" && $arComponent["PARAMS"]["FILES_GROUP_IBLOCK_ID"] == $IBLOCK_ID && $arComponent["PARAMS"]["FILES_USER_IBLOCK_ID"] == $IBLOCK_ID) {
                            $entity = $arSection["SOCNET_GROUP_ID"] > 0 ? "group" : "user";
                        } else {
                            if ($arComponent["PARAMS"]["FILES_USER_IBLOCK_ID"] == $IBLOCK_ID && ($arRule["ID"] == "bitrix:socialnetwork_user" || $arRule["ID"] == "bitrix:socialnetwork")) {
                                $entity = "user";
                            } else {
                                if ($arComponent["PARAMS"]["FILES_GROUP_IBLOCK_ID"] == $IBLOCK_ID && ($arRule["ID"] == "bitrix:socialnetwork_group" || $arRule["ID"] == "bitrix:socialnetwork")) {
                                    $entity = "group";
                                }
                            }
                        }
                        if (!!$entity) {
                            $SEF_URL_TEMPLATES = $entity == "user" ? array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["user_files"], "view" => "user/#user_id#/files/element/view/#element_id#/", "edit" => "user/#user_id#/files/element/edit/#element_id#/#action#/", "history" => "user/#user_id#/files/element/history/#element_id#/", "history_get" => "user/#user_id#/files/element/historyget/#element_id#/#element_name#") : array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["group_files"], "view" => "group/#group_id#/files/element/view/#element_id#/", "edit" => "group/#group_id#/files/element/edit/#element_id#/#action#/", "history" => "group/#group_id#/files/element/history/#element_id#/", "history_get" => "group/#group_id#/files/element/historyget/#element_id#/#element_name#");
                        }
                    } else {
                        if ($arRule["ID"] == "bitrix:webdav" && $arComponent["PARAMS"]["IBLOCK_ID"] == $IBLOCK_ID) {
                            $entity = "lib";
                            $SEF_URL_TEMPLATES = array("path" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["sections"], "view" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element"], "edit" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_edit"], "history" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_history"], "history_get" => $arComponent["PARAMS"]["SEF_URL_TEMPLATES"]["element_history_get"]);
                        }
                    }
                    if (!!$entity) {
                        $SEF_URL_TEMPLATES["component"] = $arRule["ID"];
                        break 2;
                    }
                }
            }
        }
        $entity = !$entity ? $SEF_URL_TEMPLATES["entity"] : $entity;
    }
    $repl = array("#id#", "#ELEMENT_ID#", "#element_id#", "#name#", "#ELEMENT_NAME#", "#element_name#", "#action#", "//");
    $patt = array("#ID#", "#ID#", "#ID#", "#NAME#", "#NAME#", "#NAME#", "#ACTION#", "/");
    if ($entity != "lib" && !empty($arSection)) {
        $repl = array_merge(array("#SOCNET_USER_ID#", "#USER_ID#", "#SOCNET_GROUP_ID#", "#GROUP_ID#", "#SOCNET_OBJECT#", "#SOCNET_OBJECT_ID#", "#socnet_user_id#", "#user_id#", "#socnet_group_id#", "#group_id#", "#socnet_object#", "#socnet_object_id#"), $repl);
        $patt = array_merge(array($arSection["CREATED_BY"], $arSection["CREATED_BY"], $arSection["SOCNET_GROUP_ID"], $arSection["SOCNET_GROUP_ID"], $entity, $arSection["SOCNET_GROUP_ID"] > 0 ? $arSection["SOCNET_GROUP_ID"] : $arSection["CREATED_BY"], $arSection["CREATED_BY"], $arSection["CREATED_BY"], $arSection["SOCNET_GROUP_ID"], $arSection["SOCNET_GROUP_ID"], $entity, $arSection["SOCNET_GROUP_ID"] > 0 ? $arSection["SOCNET_GROUP_ID"] : $arSection["CREATED_BY"]), $patt);
    }
    if (!empty($arElement)) {
        $repl[] = "#ID#";
        $patt[] = $arElement["ID"];
        $repl[] = "#NAME#";
        $patt[] = $arElement["NAME"];
    }
    foreach ($SEF_URL_TEMPLATES as $key => $val) {
        $SEF_URL_TEMPLATES[$key] = str_replace($repl, $patt, $SEF_FOLDER . "/" . $val);
    }
    $SEF_URL_TEMPLATES["path"] = str_replace(array("#path#", "#PATH#"), "", $SEF_URL_TEMPLATES["path"]);
    $SEF_URL_TEMPLATES["delete_dropped"] = str_replace("#ACTION#", "delete_dropped", $SEF_URL_TEMPLATES["edit"]);
    $SEF_URL_TEMPLATES["edit"] = str_replace("#ACTION#", "edit", $SEF_URL_TEMPLATES["edit"]);
    $SEF_URL_TEMPLATES["entity"] = $entity;
    return $SEF_URL_TEMPLATES;
}