Народ! Прошу помощи! Есть файл: PHP: <?php /*********************/ /* */ /* Version : 5.1.0 */ /* Author : RM */ /* Comment : 071223 */ /* */ /*********************/ function CheckLoggedInAdm( ) { include_once( SITE_PATH."inc/admin.inc.php" ); if ( !isadmin( ) ) { header( "Location: index.php?page=login&ref_url=".urlencode( $_SERVER['REQUEST_URI'] ) ); exit( ); } } function IsBanned( $id, $UNBAN_MIN, $type = "" ) { global $db; if ( !$id || !$UNBAN_MIN ) { return 0; } $esc_ip = $db->esc( $_SERVER['REMOTE_ADDR'] ); $ts = $db->one_data( "SELECT UNIX_TIMESTAMP(bdate) FROM ".TBL_IP." WHERE ip=INET_ATON(".$esc_ip.") AND link_id='{$id}' AND type='{$type}'" ); if ( !$ts ) { $db->query( "INSERT IGNORE INTO ".TBL_IP." (ip,link_id,bdate,type) VALUES (INET_ATON(".$esc_ip."),'{$id}',".SQL_NOW.",'{$type}')" ); } else { if ( HW_TIME - $UNBAN_MIN * 60 < $ts ) { return 1; } $db->query( "UPDATE ".TBL_IP." SET bdate=".SQL_NOW." WHERE ip=INET_ATON(".$esc_ip.") AND link_id='{$id}' AND type='{$type}'"." AND bdate<DATE_SUB(".SQL_NOW.", INTERVAL {$UNBAN_MIN} MINUTE)" ); if ( $db->affected_rows( ) < 1 ) { return 1; } } return 0; } function get_daughter_cats( $catid, $tbl = TBL_CAT ) { global $db; static $A_RES = NULL; if ( is_array( $catid ) ) { $cnt = count( $catid ); $i = 0; for ( ; $i < $cnt; ++$i ) { if ( !ctype_digit( ( boolean )$catid[$i] ) ) { unset( $catid[$i] ); } } $catid = implode( ",", $catid ); } else if ( !ctype_digit( ( boolean )$catid ) ) { $catid = preg_replace( "/[^\\d,]/", "", $catid ); } if ( !isset( $A_RES[$tbl][$catid] ) ) { $id_arr_tmp = explode( ",", $catid ); $id_arr = array( ); while ( 0 < count( $id_arr_tmp ) ) { $id_arr = array_merge( $id_arr, $id_arr_tmp ); $id_arr_tmp = $db->one_col_array( "SELECT id FROM ".$tbl." WHERE pid IN(\"".implode( "\",\"", $id_arr_tmp )."\")" ); } $A_RES[$tbl][$catid] = $id_arr; } return "\"".implode( "\",\"", $A_RES[$tbl][$catid] )."\""; } function EvalBuffer( $buf, $vars = "", $show = 0 ) { $buf = HawkTpl::evalbuffer( $buf, $vars ); if ( $show ) { echo $buf; return ""; } else { return $buf; } } function EvalAdvTpl( $tf, $vars = "", $show = 0 ) { return evalbuffer( hwreadtpl( $tf ), $vars, $show ); } function hwReadTpl( $f ) { return file_get_contents( hwlnggetpath( $f ) ); } function hwLngGetPath( $f, $lang = "" ) { if ( !$lang ) { $lang = $HW_LANG; } if ( $lang == "en" ) { return $f; } $ext = substr( ( $_s = strrchr( $f, "." ) ) !== false ? $_s : "", 1 ); if ( $ext == "txt" && basename( $f ) != "config_sel.txt" ) { return $f; } $f_new = hwlngcalcpath( $f, $lang ); if ( $f_new != $f && file_exists( $f_new ) ) { $f = $f_new; } return $f; }
PHP: function hwLngCalcPath( $f, $lang ) { if ( $lang == "en" || strpos( $f, "/Multi_Lang/" ) !== false ) { return $f; } $f_path = ""; $f_dir = dirname( $f ); $lang_dir = MOD_DIR."Multi_Lang/language/"; if ( strpos( $f, "modules/" ) ) { if ( substr( $f_dir, -4 ) == "/tpl" ) { $mod = explode( "/", $f ); $mod = $mod[count( $mod ) - 3]; $f_path = $lang_dir.$lang."/modules/".$mod; } } else if ( strpos( $f, FS_DIR."/" ) ) { $fs = explode( "/", $f ); $fs = $fs[count( $fs ) - 2]; $f_path = $lang_dir.$lang."/".FS_DIR."/".$fs; } else if ( $f_dir."/" == TPL_PATH ) { $fn = array_pop( explode( "/", $f ) ); $f_path = $lang_dir.$lang; } if ( $f_path ) { $fn = array_pop( explode( "/", $f ) ); $f = $f_path."/".$fn; } return $f; } function DoNotCache( ) { header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); header( "Cache-Control: post-check=0,pre-check=0", false ); header( "Cache-Control: max-age=0", false ); header( "Pragma: no-cache" ); } function JSRedirect( $url ) { echo "<html><script>document.location=\"".$url."\";</script></html>"; } function GetNavigation( $href, $max_rows, $max_cols, $numrows, $off, $ex_p = "" ) { if ( $numrows <= $max_rows ) { return ""; } if ( is_array( $ex_p ) ) { $a_v = $ex_p; $ex_p = ""; foreach ( $a_v as $k => $v ) { if ( $v != "" && !is_array( $v ) ) { $ex_p .= "&{$k}=".urlencode( $v ); } } unset( $a_v ); } $a_nav = explode( "|", hwlng( "page_nav" ) ); $var_off = "off"; if ( strpos( $off, "=" ) ) { list( $var_off, $off ) = explode( "=", $off ); } if ( $ex_p && strpos( $ex_p, "&".$var_off."=" ) !== false ) { $ex_p = preg_replace( "/&".$var_off."=\\d*/", "", $ex_p ); } $off = abs( ( integer )$off ); $pg = intval( $off / $max_cols ); if ( substr( $href, -1 ) == "&" ) { $f_ch = ""; } else if ( strpos( $href, "?" ) ) { $f_ch = "&"; } else { $f_ch = "?"; } if ( $ex_p ) { $ex_p = $f_ch.substr( $ex_p, 1 )."&".$var_off."="; } else { $ex_p = $f_ch.$var_off."="; } $nav = ""; if ( $pg != 0 ) { $nav .= "<a href=\"".$href.$ex_p.( $max_cols * $pg - 1 )."\">".sprintf( $a_nav[0], $max_cols )."</a> "; } if ( 0 < $off ) { $nav .= "<a href=\"".$href.$ex_p.( $off - 1 )."\">".$a_nav[1]."</a> "; } $i = 1; for ( ; $i <= $max_cols; ++$i ) { $cur_i = $i + $pg * $max_cols; if ( $numrows <= ( $cur_i - 1 ) * $max_rows ) { break; } if ( $cur_i != $off + 1 ) { $nav .= "<a href=\"".$href.$ex_p.( $cur_i - 1 )."\">".$cur_i."</a> "; } else { $nav .= $cur_i." "; } } if ( $off + 1 < ceil( $numrows / $max_rows ) ) { $nav .= "<a href=\"".$href.$ex_p.( $off + 1 )."\">".$a_nav[2]."</a>  "; } if ( $max_rows * $max_cols * ( $pg + 1 ) < $numrows ) { $nav .= "<a href=\"".$href.$ex_p.$max_cols * ( $pg + 1 )."\">".sprintf( $a_nav[3], $max_cols )."</a>  "; } return "<b>".$nav."</b>"; } function hwGetCatSQL( $cat_f, $sql_extra = "", $tbl_cat = TBL_CAT ) { global $HW_LANG; static $A_TBL_LNG = NULL; if ( !isset( $A_TBL_LNG ) ) { $A_TBL_LNG = array( ); if ( hwmodgetstate( "Multi_Lang" ) == "A" ) { $A_TBL_LNG[TBL_CAT] = hwmodtable( "Multi_Lang", "category" ); $_tbl = hwmodtable( "Regions", "category" ); $A_TBL_LNG[$_tbl] = hwmodtable( "Multi_Lang", "region" ); $_tbl = TBL_DEP_MENU_TREE; $A_TBL_LNG[$_tbl] = hwmodtable( "Multi_Lang", "depmenu" ); unset( $_tbl ); } } $cat_f = substr( preg_replace( "/,(?!c\\.)/", ",c.", ",".$cat_f ), 1 ); if ( $HW_LANG != "en" && isset( $A_TBL_LNG[$tbl_cat] ) ) { $a_f = array( "name" ); if ( $tbl_cat == TBL_CAT ) { $a_f[] = "descr"; } $temp_tbl = "_func_cat_sql_".$tbl_cat."_".$HW_LANG; static $A_TBL_OK = NULL; if ( !isset( $A_TBL_OK[$temp_tbl] ) ) { $A_TBL_OK[$temp_tbl] = 1; global $db; $db->query( "DROP TEMPORARY TABLE IF EXISTS ".$temp_tbl ); $db->query( "CREATE TEMPORARY TABLE ".$temp_tbl." SELECT id,".implode( ",", $a_f )." FROM ".$A_TBL_LNG[$tbl_cat]." WHERE lang_id=\"".$HW_LANG."\"" ); } foreach ( $a_f as $f ) { $cat_f = str_replace( "c.{$f}", "IF(m.{$f}<>'',m.{$f},c.{$f}) AS {$f}", $cat_f ); } $sql = "SELECT ".$cat_f." FROM ".$tbl_cat." c LEFT JOIN ".$temp_tbl." m ON c.id=m.id"; } else { $sql = "SELECT ".$cat_f." FROM ".$tbl_cat." c"; } $sql .= " WHERE 1 "; if ( $sql_extra ) { $sql .= " ".$sql_extra; } return $sql; } function ShowDropDownMultiCategoryList( $cat, $fset = "_ALL_", $hide_id = 0 ) { global $db; include_once( SITE_PATH."inc/class.categ_tree.php" ); $o_cat =& new HawkCategTree( TBL_CAT ); $o_cat->CAT_ORDER = "c.weight DESC,name"; $o_cat->CAT_F = "fset"; if ( EN_FSETS && $fset != "_ALL_" ) { $A_PID = array( ); if ( $cat && ctype_digit( ( boolean )$cat ) ) { $pid = $cat; while ( $pid = $db->one_data( "SELECT pid FROM ".TBL_CAT." WHERE id=\"".$pid."\"" ) ) { $A_PID[] = $pid; } } $o_cat['SQL_CAT'] .= $A_PID ? " AND (c.fset='{$fset}' OR c.id IN(".implode( ",", $A_PID )."))" : " AND c.fset='{$fset}'"; } if ( $hide_id ) { if ( !is_array( $hide_id ) ) { $hide_id = array( $hide_id ); } $hide_id = array_map( "intval", $hide_id ); $hide_id = $db->one_col_array( "SELECT id FROM ".TBL_CAT." WHERE id IN(".implode( ",", $hide_id ).")" ); if ( $hide_id ) { $o_cat['SQL_CAT'] .= " AND c.id NOT IN(".get_daughter_cats( $hide_id ).")"; } } $page = ( boolean )$_GET['page']; if ( defined( "TBL_CAT_EXTRA" ) && !defined( "ADMIN_AREA" ) && ( $page == "add" || $page == "modify" ) && PHP_SELF_BASE == "index.php" ) { $no_ids = $db->one_col_array( "SELECT cid FROM ".TBL_CAT_EXTRA." WHERE type=\"H\"" ); if ( $no_ids ) { $o_cat['SQL_CAT'] .= " AND c.id NOT IN(".implode( ",", $no_ids ).")"; } unset( $no_ids ); } $o_cat->TPL_SHOW = FALSE; return $o_cat->GetMenuPage( TPL_PATH."cat_menu_multi.htm", $cat ); }
PHP: function hwGetCatURL( $id ) { static $code = NULL; if ( !isset( $code ) ) { if ( EN_SE_URLS ) { $url = defined( "EN_SE_ADV" ) ? "page-b\$id-".$HW_LANG.".html" : "category-\$id.html"; $code = explode( "\$id", $url ); } else { $code = "D"; } } if ( is_array( $code ) ) { $url = $code[0].$id.$code[1]; } else { static $ex_p = NULL; if ( !isset( $ex_p ) ) { $ex_p = ""; if ( hwmodgetstate( "Multi_Lang" ) == "A" ) { $ex_p .= "&lang=".$HW_LANG; } } $url = "index.php?page=browse&cid=".$id.$ex_p; } return $url; } function hwGetBrowseURL( $id, $off = 0 ) { static $code = NULL; $off = ( integer )$off; if ( !isset( $code ) ) { if ( EN_SE_URLS ) { $url = defined( "EN_SE_ADV" ) ? "page-b\$id_\$id-".$HW_LANG.".html" : "browse-\$id-\$id.html"; $code = explode( "\$id", $url ); } else { $code = "D"; } } if ( is_array( $code ) ) { $url = $code[0].$id.$code[1].$off.$code[2]; } else { static $ex_p = NULL; if ( !isset( $ex_p ) ) { $ex_p = ""; if ( hwmodgetstate( "Multi_Lang" ) == "A" ) { $ex_p .= "&lang=".$HW_LANG; } } $url = "index.php?page=search&s_res=AND&cid={$id}"; if ( $off ) { $url .= "&off=".$off; } if ( $ex_p ) { $url .= $ex_p; } } return $url; }
Вот здесь у меня проблема PHP: $url = defined( "EN_SE_ADV" ) ? "page-b\$id_\$id-".$HW_LANG.".html" : "browse-\$id-\$id.html";
пишу в скрипте echo $HW_LANG; в браузере ничего не выводится! Как тут затрассировать, чтобы понять почему у $HW_LANG когда оно собирается в урлу значение = 0
Призрак Коммунизма, какой ты интеллектуал! Нет чтоб помоч человеку. Я думаю, что надо в начале каждой функции, где используется $HW_LANG, прописать Code: global $HW_LANG;
Такое вроде бы есть PHP: global $HW_LANG; PHP: function Multi_Lang_Redirect( $sql ) { global $db; global $HW_LANG; $_lang = $db->one_data( $sql ); if ( !$_lang ) { $_lang = "en"; } if ( $_lang != $HW_LANG && !isset( $_GET['lang'] ) && ctype_print( $_SERVER['REQUEST_URI'] ) ) { $ch_amt = $db->one_data( "SELECT COUNT(DISTINCT(charset)) FROM ".hwmodtable( "Multi_Lang", "language" )." WHERE id IN(?,?)", array( $_lang, $HW_LANG ) ); if ( $ch_amt == 2 ) { $redir = $_SERVER['REQUEST_URI']."&lang=".$_lang; if ( HW_IS_WINDOWS ) { $redir = "http".( $_SERVER['HTTPS'] == "on" ? "s" : "" )."://".$_SERVER['HTTP_HOST'].$redir; } header( "Location: ".$redir ); exit( ); } } }
PHP: function hwLngGetPath( $f, $lang = "" ) { if ( !$lang ) { $lang = $HW_LANG; } if ( $lang == "en" ) { return $f; } $ext = substr( ( $_s = strrchr( $f, "." ) ) !== false ? $_s : "", 1 ); if ( $ext == "txt" && basename( $f ) != "config_sel.txt" ) { return $f; } $f_new = hwlngcalcpath( $f, $lang ); if ( $f_new != $f && file_exists( $f_new ) ) { $f = $f_new; } return $f; }