config-1.php 5.23 KB
<?php

	// íàñòðîéêè ñåññèé
	ini_set("session.cookie_lifetime",0);
	ini_set("session.auto_start ",1);
	ini_set("session.use_only_cookies",1);
	ini_set("session.use_trans_sid",0);
	ini_set("session.save_path", $_SERVER['DOCUMENT_ROOT'].'/sessions'); 
	ini_set("error_reporting",0);	
	// ini_set("error_reporting", E_ALL);
    ini_set('display_errors','on');
    ini_set('html_errors', 'on');
    ini_set('xdebug.dump_globals', 'on');  
    ini_set('xdebug.show_local_vars', 'off'); 
    ini_set('xdebug.collect_params', '4'); 
    ini_set("log_errors", 1);
	ini_set("error_log", $_SERVER['DOCUMENT_ROOT']."/errors/error.log");
	ini_set("log_errors_max_len", 1024);

	session_start();

	define("DB_HOST",'localhost');
	define("DB_USER",'accelerate');
	define("DB_PSW",'123123');
    
	define("URL","http://{$_SERVER['HTTP_HOST']}/");
	define("WEB_EMAIL",'pavel_gnida@up-trading.kiev.ua');
	// define("DB_HOST",'db');
	// define("DB_USER",'extrem');
	// define("DB_PSW",'9gvs7AbI'); //extrem5105265
	define("DB_BASE",'extrem');

	mysql_connect(DB_HOST, DB_USER, DB_PSW) or die("Could not connect : " . mysql_error());
	mysql_select_db(DB_BASE) or die("Could not select database");
    mysql_query("SET CHARACTER SET 'cp1251'");
    date_default_timezone_set('Europe/Kiev'); 

	$path=explode("/",$_SERVER['REQUEST_URI']);
    parse_str(substr($path[count($path)-1],1), $GET);
   
    // print_r($_GET);
    //phpinfo();
    
    $_SERVER['QUERY_STRING']='index.php?action=catalogs&rubID=13665';


	$page['id']=0;
    $ok=0;
    for ($e=0;$e<count($path);$e++) {
        if (isset($page['id'])) {
            if(!empty($path[$e])) {

                if ($e==0) { $pid=0; }  else { $pid=$page['id'];}
                $sql="SELECT id FROM catalogs_rubrics WHERE `alias`='".$path[$e]."' AND parent_id='".$pid."' ";
                $result=mysql_query($sql) or die (mysql_error());
                if (mysql_affected_rows()!=0) {
                    $page=mysql_fetch_assoc($result);
                    $ok=1;
                }
                
                    $nav_page=GetNavPage($path[$e]);
            }
        }
    }
    if($ok==1) {
        $_GET['action']='catalogs';
        $_GET['rubID']=$page['id'];
        $_GET['brend']='HEAD';
    }
    
    if ($nav_page!=0){
        $_REQUEST['page']=$nav_page;
        $_GET['page']=$nav_page;
    }
    
    function UpdateAlias ($table) {

        $sql="SELECT id, name FROM $table";
        $result=mysql_query($sql) or die (mysql_error());
        if (mysql_affected_rows()!=0) {
            while($row=mysql_fetch_assoc($result)) {
            
                $sql2="UPDATE $table SET alias='".strtolower(Translit(strtolower(trim($row['name']))))."' WHERE id='".$row['id']."'";
                $result2=mysql_query($sql2) or die (mysql_error());      
                
            }
        }
    }
    
    function GetNavPage($page) {
        $pos = strpos($page, "page");
        if ($pos === false) {
            return 0;
        } else {
            $page=str_replace('page_','',$page);
            $page=str_replace('.html','',$page);
            return (int)$page;            
        }
    }
    
    
    function Translit($string, $lang='en') {

        $converter = array(
        
            'à' => 'a',   'á' => 'b',   'â' => 'v',
            'ã' => 'g',   'ä' => 'd',   'å' => 'e',
            '¸' => 'e',   'æ' => 'zh',  'ç' => 'z',
            'è' => 'i',   'é' => 'y',   'ê' => 'k',
            'ë' => 'l',   'ì' => 'm',   'í' => 'n',
            'î' => 'o',   'ï' => 'p',   'ð' => 'r',
            'ñ' => 's',   'ò' => 't',   'ó' => 'u',
            'ô' => 'f',   'õ' => 'h',   'ö' => 'c',
            '÷' => 'ch',  'ø' => 'sh',  'ù' => 'sch',
            'ü' => "",    'û' => 'y',   'ú' => "",
            'ý' => 'e',   'þ' => 'yu',  'ÿ' => 'ya',
            '¿' => 'yi',  'º' => 'ye',  '³' => 'ee',  
            
            'À' => 'A',   'Á' => 'B',   'Â' => 'V',
            'Ã' => 'G',   'Ä' => 'D',   'Å' => 'E',
            '¨' => 'E',   'Æ' => 'Zh',  'Ç' => 'Z',
            'È' => 'I',   'É' => 'Y',   'Ê' => 'K',
            'Ë' => 'L',   'Ì' => 'M',   'Í' => 'N',
            'Î' => 'O',   'Ï' => 'P',   'Ð' => 'R',
            'Ñ' => 'S',   'Ò' => 'T',   'Ó' => 'U',
            'Ô' => 'F',   'Õ' => 'H',   'Ö' => 'C',
            '×' => 'Ch',  'Ø' => 'Sh',  'Ù' => 'Sch',
            'Ü' => "",    'Û' => 'Y',   'Ú' => "",
            'Ý' => 'E',   'Þ' => 'Yu',  'ß' => 'Ya',
            '¯' => 'Yi',  'ª' => 'Ye',  '²' => 'Ee',
            
            ' ' => '-',   "'" => '',    '"' => '',
            '!' => '',    "@" => '',    '#' => '',
            '$' => '',    "%" => '',    '^' => '',
            ';' => '',    "*" => '',    '(' => '',
            ')' => '',    "+" => '',    '~' => '',
            '.' => '',	  ',' => '',	'?' => '',
            '…' => '',    '¹' => 'N',   '°' => '',
            '`' => '',    '|' => '',    '&' => '-and-',
            '<' => '',    '>' => '',    '/'=>''
            
        );
        
        if ($lang=='en') {
            $url=strtr($string, $converter);
        } else {
            $url=strtr($converter, $string);
        }
        
        $url= str_replace ("---",'-', $url);
        $url= str_replace ("--",'-', $url);  
        
        return $url;
    }
    
    
    // UpdateAlias('catalogs_rubrics');
?>