Пример #1
0
 function OnSearchGetURL($arFields)
 {
     global $DB, $BX_NEWS_DETAIL_URL, $BX_NEWS_SECTION_URL;
     static $arIBlockCache = array();
     if ($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=") {
         return $arFields["URL"];
     }
     if (!CModule::IncludeModule('iblock')) {
         return "";
     }
     $IBLOCK_ID = IntVal($arFields["PARAM2"]);
     if (!array_key_exists($IBLOCK_ID, $arIBlockCache)) {
         $res = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tDETAIL_PAGE_URL,\n\t\t\t\t\tSECTION_PAGE_URL,\n\t\t\t\t\tCODE as IBLOCK_CODE,\n\t\t\t\t\tXML_ID as IBLOCK_EXTERNAL_ID,\n\t\t\t\t\tIBLOCK_TYPE_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock\n\t\t\t\tWHERE ID = " . $IBLOCK_ID . "\n\t\t\t");
         $arIBlockCache[$IBLOCK_ID] = $res->Fetch();
     }
     if (!is_array($arIBlockCache[$IBLOCK_ID])) {
         return "";
     }
     $arFields["URL"] = LTrim($arFields["URL"], " =");
     parse_str($arFields["URL"], $arr);
     $arr = $arIBlockCache[$IBLOCK_ID] + $arr;
     $arr["LANG_DIR"] = $arFields["DIR"];
     if (substr($arFields["ITEM_ID"], 0, 1) !== 'S') {
         return CIBlock::ReplaceDetailUrl($BX_NEWS_DETAIL_URL, $arr, true, "E");
     } else {
         return CIBlock::ReplaceDetailUrl($BX_NEWS_SECTION_URL, $arr, true, "S");
     }
 }
Пример #2
0
 static function defineRewriteRules()
 {
     # Add filter permalink structure for post type archive
     $post_type = Get_Post_Type_Object(Post_Type::$post_type_name);
     $archive_url_path = $post_type->rewrite['slug'];
     self::$rewrite_rules[LTrim(SPrintF('%s/filter:([^/]+)/?$', $archive_url_path), '/')] = SPrintF('index.php?post_type=%s&filter=$matches[1]', Post_Type::$post_type_name);
     self::$rewrite_rules[LTrim(SPrintF('%s/filter:([^/]+)/page/([0-9]{1,})/?$', $archive_url_path), '/')] = SPrintF('index.php?post_type=%s&filter=$matches[1]&paged=$matches[2]', Post_Type::$post_type_name);
     # Add filter permalink structure for taxonomy archives
     foreach (Get_Taxonomies(Null, 'objects') as $taxonomy) {
         $taxonomy_slug = $taxonomy->rewrite['slug'];
         if (!In_Array(Post_Type::$post_type_name, $taxonomy->object_type)) {
             continue;
         }
         self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]', $taxonomy->name);
         self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/page/([0-9]{1,})/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]&paged=$matches[3]', $taxonomy->name);
     }
 }
Пример #3
0
 function SetOperations($ID, $arr, $bOpNames = false)
 {
     global $DB;
     $ID = intval($ID);
     //get old operations
     $aPrevOp = array();
     $res = $DB->Query("\n\t\t\tSELECT O.NAME\n\t\t\tFROM b_operation O\n\t\t\tINNER JOIN b_task_operation T_OP ON O.ID = T_OP.OPERATION_ID\n\t\t\tWHERE T_OP.TASK_ID = " . $ID . "\n\t\t\tORDER BY O.ID\n\t\t");
     while ($res_arr = $res->Fetch()) {
         $aPrevOp[] = $res_arr["NAME"];
     }
     $sql_str = 'DELETE FROM b_task_operation WHERE TASK_ID=' . $ID;
     $DB->Query($sql_str, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     if (is_array($arr) && count($arr) > 0) {
         if ($bOpNames) {
             $sID = "";
             foreach ($arr as $op_id) {
                 $sID .= ",'" . $DB->ForSQL($op_id) . "'";
             }
             $sID = LTrim($sID, ",");
             $DB->Query("INSERT INTO b_task_operation (TASK_ID, OPERATION_ID) " . "SELECT '" . $ID . "', O.ID " . "FROM b_operation O, b_task T " . "WHERE O.NAME IN (" . $sID . ") AND T.MODULE_ID=O.MODULE_ID AND T.ID=" . $ID . " ", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         } else {
             $sID = "0";
             foreach ($arr as $op_id) {
                 $sID .= "," . intval($op_id);
             }
             $DB->Query("INSERT INTO b_task_operation (TASK_ID, OPERATION_ID) " . "SELECT '" . $ID . "', ID " . "FROM b_operation " . "WHERE ID IN (" . $sID . ") ", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     }
     if (CACHED_b_task_operation !== false) {
         $GLOBALS["CACHE_MANAGER"]->CleanDir("b_task_operation");
     }
     //get new operations
     $aNewOp = array();
     $res = $DB->Query("\n\t\t\tSELECT O.NAME\n\t\t\tFROM b_operation O\n\t\t\tINNER JOIN b_task_operation T_OP ON O.ID = T_OP.OPERATION_ID\n\t\t\tWHERE T_OP.TASK_ID = " . $ID . "\n\t\t\tORDER BY O.ID\n\t\t");
     while ($res_arr = $res->Fetch()) {
         $aNewOp[] = $res_arr["NAME"];
     }
     //compare with old one
     $aDiff = array_diff($aNewOp, $aPrevOp);
     if (empty($aDiff)) {
         $aDiff = array_diff($aPrevOp, $aNewOp);
     }
     if (!empty($aDiff)) {
         if (COption::GetOptionString("main", "event_log_task", "N") === "Y") {
             CEventLog::Log("SECURITY", "TASK_CHANGED", "main", $ID, "(" . implode(", ", $aPrevOp) . ") => (" . implode(", ", $aNewOp) . ")");
         }
         foreach (GetModuleEvents("main", "OnTaskOperationsChanged", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($ID, $aPrevOp, $aNewOp));
         }
     }
 }
Пример #4
0
	function OnSearchGetURL($arFields)
	{
		/** @global CDatabase $DB */
		global $DB;
		static $arIBlockCache = array();

		if($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=")
			return $arFields["URL"];

		$IBLOCK_ID = IntVal($arFields["PARAM2"]);

		if(!array_key_exists($IBLOCK_ID, $arIBlockCache))
		{
			$res = $DB->Query("
				SELECT
					DETAIL_PAGE_URL,
					SECTION_PAGE_URL,
					CODE as IBLOCK_CODE,
					XML_ID as IBLOCK_EXTERNAL_ID,
					IBLOCK_TYPE_ID
				FROM
					b_iblock
				WHERE ID = ".$IBLOCK_ID."
			");
			$arIBlockCache[$IBLOCK_ID] = $res->Fetch();
		}

		if(!is_array($arIBlockCache[$IBLOCK_ID]))
			return "";

		$arFields["URL"] = LTrim($arFields["URL"], " =");
		parse_str($arFields["URL"], $arr);
		$arr = $arIBlockCache[$IBLOCK_ID] + $arr;
		$arr["LANG_DIR"] = $arFields["DIR"];

		if(substr($arFields["ITEM_ID"], 0, 1) !== 'S')
			return CIBlock::ReplaceDetailUrl($arIBlockCache[$IBLOCK_ID]["DETAIL_PAGE_URL"], $arr, false, "E");
		else
			return CIBlock::ReplaceDetailUrl($arIBlockCache[$IBLOCK_ID]["SECTION_PAGE_URL"], $arr, false, "S");
	}
Пример #5
0
 function GetSiteSwitcherArray()
 {
     $cur_dir = $this->GetCurDir();
     $cur_page = $this->GetCurPage();
     $bAdmin = substr($cur_dir, 0, strlen(BX_ROOT . "/admin/")) == BX_ROOT . "/admin/";
     $path_without_lang = $path_without_lang_tmp = "";
     $db_res = CSite::GetList($by, $order, array("ACTIVE" => "Y", "ID" => LANG));
     if (($ar = $db_res->Fetch()) && strpos($cur_page, $ar["DIR"]) === 0) {
         $path_without_lang = substr($cur_page, strlen($ar["DIR"]) - 1);
         $path_without_lang = LTrim($path_without_lang, "/");
         $path_without_lang_tmp = RTrim($path_without_lang, "/");
     }
     $result = array();
     $db_res = CSite::GetList($by = "SORT", $order = "ASC", array("ACTIVE" => "Y"));
     while ($ar = $db_res->Fetch()) {
         $ar["NAME"] = htmlspecialcharsbx($ar["NAME"]);
         $ar["SELECTED"] = $ar["LID"] == LANG;
         if ($bAdmin) {
             global $QUERY_STRING;
             $p = rtrim(str_replace("&#", "#", preg_replace("/lang=[^&#]*&*/", "", $QUERY_STRING)), "&");
             $ar["PATH"] = $this->GetCurPage() . "?lang=" . $ar["LID"] . ($p != '' ? '&' . $p : '');
         } else {
             $ar["PATH"] = "";
             if (strlen($path_without_lang) > 1 && file_exists($ar["ABS_DOC_ROOT"] . "/" . $ar["DIR"] . "/" . $path_without_lang_tmp)) {
                 $ar["PATH"] = $ar["DIR"] . $path_without_lang;
             }
             if (strlen($ar["PATH"]) <= 0) {
                 $ar["PATH"] = $ar["DIR"];
             }
             if ($ar["ABS_DOC_ROOT"] !== $_SERVER["DOCUMENT_ROOT"]) {
                 $ar["FULL_URL"] = (CMain::IsHTTPS() ? "https://" : "http://") . $ar["SERVER_NAME"] . $ar["PATH"];
             } else {
                 $ar["FULL_URL"] = $ar["PATH"];
             }
         }
         $result[] = $ar;
     }
     return $result;
 }
Пример #6
0
function FindConfigElem(&$cfg_file, $elem_name)
{
    $cfg_info = array();
    $inside = 0;
    for ($i = 0; $i < Count($cfg_file); $i++) {
        $cfg_line = $cfg_file[$i];
        $cfg_line = RTrim($cfg_line);
        $cfg_line = LTrim($cfg_line);
        if (!$cfg_line) {
            // Blank line
            continue;
        } elseif (Preg_Match("/^(\\/\\/|#)/", $cfg_line)) {
            //Comment line
            continue;
        } elseif (Preg_Match("/^(([[:alnum:]]+)\\s+({$elem_name})|{$elem_name})\$/i", $cfg_line, $matches)) {
            $next_line = RTrim($cfg_file[$i + 1]);
            if (!Preg_Match("/\\s*\\{\\s*/i", $next_line)) {
                // Not an elem line - maybe a property line with no spaces infront of it.
                continue;
            }
            //Print("Inside (0){$matches[0]} (1){$matches[1]} (2){$matches[2]} (3){$matches[3]}\n");
            //It is inside the elem that it has been told to read.
            $inside = 1;
        } elseif ($inside) {
            if (Preg_Match("/^{/i", $cfg_line)) {
                //Ignore the { line
                continue;
            } elseif (Preg_Match("/^}/i", $cfg_line)) {
                //It reached the } line, which means it is done reading the elem.
                //Stop going through the rest of the file at this point.
                $inside = 0;
                break;
            } else {
                //It is still inside the elem's brackets.
                //Split the lines up into key value pairs.
                //Tuck the values into the array[key]
                $info = Preg_Split("/\\s+/", $cfg_line, 2, PREG_SPLIT_NO_EMPTY);
                $key = $info[0];
                $value = $info[1];
                if (!Is_Array($cfg_info[$key])) {
                    // If cfg_info[key] is not already an array,
                    // make it one so it can hold multiple values.
                    $cfg_info[$key] = array();
                }
                Array_Push($cfg_info[$key], $value);
            }
        }
    }
    if (Count($cfg_info) < 1) {
        return FALSE;
    } else {
        return $cfg_info;
    }
}
Пример #7
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with VerliAdmin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

======================================================================
*/

$continue = TRUE;

$_POST['command'] = Trim($_POST['command']);
IF(($command = SubStr($_POST['command'], 0, StrPos($_POST['command'], " "))) == FALSE)
	$command = $_POST['command'];
$param = LTrim(StrStr($_POST['command'], " "));

//Print "'".$command."' - '".$param."' - '".$_POST['command']."'";

SWITCH(StrToLower($command)) {
//---------------------------------------------------------------------
//	+passwd
	CASE "+passwd" :
		$password = $param;

		IF(!PasswordChange($password, $password, $nick, 1)) {
			VA_Alert($err_msg_pwd_ch_not_allowed, "error", "index.php?".Change_URL_Query("q", $_GET['return'], "return", ""));
			$continue = FALSE;
			}

		BREAK;