View file system/inc/basic_settings.php

File size: 12.52Kb
<?
/*
=============================================
 Движок:  SHCMS Engine
=============================================
 Название файла: Системные настройки
=============================================
 Official website: http://shcms.ru
=============================================
 Данный код защищен авторскими правами
=============================================
*/

defined('SHCMS') or die('Переход на данных раздел запрещено');

session_name("SHCMS");
session_start();
// время запуска скрипта
define('TIME_START', microtime(true));
ini_set('magic_quotes_gpc', 0);
ini_set('magic_quotes_runtime', 0);

define("H", $_SERVER["DOCUMENT_ROOT"].'/');
define('URL', urlencode($_SERVER['REQUEST_URI']));
define('IS_MAIN', $_SERVER ['SCRIPT_NAME'] == '/index.php');
version_compare(PHP_VERSION, '5.2','>')or die('Трубуется PHP >= 5.2'); 
define('SESSION_TIME_SHCMS', 600);
ini_set('session.cache_expire', SESSION_TIME_SHCMS);
define('TIME', time());
define('SHCMS',true);
define('TODAY', mktime(0, 0, 0));
define(DIR_SHCMS,'/shcms/',TRUE);

// игнорировать повторяющиеся ошибки
ini_set('ignore_repeated_errors', true);



if (!file_exists(H.'system/inc/config.php'))
{header("Location: /install/");
exit;}



// показываем только фатальные ошибки
ini_set('error_reporting', e_error);

//непосредственно, включаем показ ошибок
ini_set('display_errors', true);

  // Установка кодировки для mb_string  
if (function_exists('mb_internal_encoding')) {  mb_internal_encoding('UTF-8'); }

//Установка кодировки для iconv
if(function_exists('Iconv')) { iconv_set_encoding('internal_encoding','UTF-8'); }
/* ---------------------- */




/* 
------------------------------- 
Соединение  с базой
------------------------------- 
*/
include_once 'config.php';

$user_db = DBUSER;
$user_user = DBNAME;
$user_localhost = DBHOST;
$user_pass = DBPASS;

		
        /*
        Автоматическая загрузка классов
        */
$opendirphp1=opendir(H.'/system/inc/classes/');
while ($open_files1=readdir($opendirphp1))
{if (eregi('\.php$',$open_files1))
{include_once(H.'/system/inc/classes/'.$open_files1);}}
	
	
        /*
        Загрузка файлов с папки /include/
        */
$opendirphp=opendir(H.'system/inc/include/');
while ($open_files=readdir($opendirphp))
{if (eregi('\.php$',$open_files))
{include_once(H.'system/inc/include/'.$open_files);}}



/* ---------------------------------  */
if (substr(PHP_OS, 0, 3) == 'WIN') { define('OS_WINDOWS', true); define('OS_UNIX', false); define('PEAR_OS', 'Windows'); }
else { define('OS_WINDOWS', false); define('OS_UNIX', true); define('PEAR_OS', 'Unix'); }

@ob_start ();
@ob_implicit_flush (0);


	/*
	--------------------------------
	Вывод коэффициента сжатия 
	--------------------------------
	*/
function zipcount() {
    global $set;
    if ($set['gzip']) {
        $Contents = ob_get_contents();
        $gzib_file = strlen($Contents);
        $gzib_file_out = strlen(gzcompress($Contents, 9));
        $gzib_pro = round(100 - (100 / ($gzib_file / $gzib_file_out)), 1);
        echo '<div>Cжатие вкл. (' . $gzib_pro . '%)</div>';
    } else {
        echo '<div>Cжатие выкл.</div>';
    }
}

/*
----------------------------
Проверяем переменные
----------------------------
*/

function shcms_sh_shcms($engine_str) {
    $engine_str = htmlentities(trim($engine_str), ENT_QUOTES, 'UTF-8');
    $engine_str = nl2br($engine_str);
    $engine_str = strtr($engine_str, array (chr(0)=> '',chr(1)=> '',chr(2)=> '',chr(3)=> '',chr(4)=> '',chr(5)=> '',chr(6)=> '',chr(7)=> '',chr(8)=> '',chr(9)=> '',chr(10)=> '',chr(11)=> '',chr(12)=> '',chr(13)=> '',chr(14)=> '',chr(15)=> '',chr(16)=> '',chr(17)=> '',chr(18)=> '',chr(19)=> '',chr(20)=> '',chr(21)=> '',chr(22)=> '',chr(23)=> '',chr(24)=> '',chr(25)=> '',chr(26)=> '',chr(27)=> '',chr(28)=> '',chr(29)=> '',chr(30)=> '',chr(31)=> ''));
    $engine_str = str_replace("\'", "&#39;", $engine_str);
    $engine_str = str_replace('\\', "&#92;", $engine_str);
    $engine_str = mysql_real_escape_string($engine_str);
    return $engine_str;
}

/*
------------------------------
Функция сообщение об ошибках
------------------------------
*/

function error($errors = false, $links = '') {
    if ($errors) {$out = '';if (is_array($errors)) {foreach ($errors as $val)$out .= '<div>' . $val . '</div>';} 
	else {$out .= '<br />' . $errors;}$out .= '<p>' . $links. '</p>';
        return $out;} else {return false;
    }}
function errors($error_)
	{
	echo '<div class="errors">'.$error_.'</div>';
	}
function rus_lat($engine_str) {

    $engine_str= strtr($engine_str, array (
        'а' => 'a','б' => 'b','в' => 'v','г' => 'g','д' => 'd','е' => 'e','ё' => 'e','ж' => 'j','з' => 'z','и' => 'i','й' => 'i','к' => 'k','л' => 'l','м' => 'm',
        'н' => 'n','о' => 'o','п' => 'p','р' => 'r','с' => 's','т' => 't','у' => 'u','ф' => 'f','х' => 'h','ц' => 'c','ч' => 'ch','ш' => 'sh','щ' => 'sch','ъ' => "",
        'ы' => 'y','ь' => "",'э' => 'ye','ю' => 'yu','я' => 'ya'));
    return $engine_str;
}

$method_logs = $_SERVER['REQUEST_METHOD'];
$server_port =$_SERVER['SERVER_PORT'];
/*
-----------------------------------
Авторизуемся  по  SESSION
-----------------------------------
*/
if (isset ($_SESSION['id_address']) && isset ($_SESSION['use_password'])) {
    $user_id = intval($_SESSION['id_address']);
    $user_ps = $_SESSION['use_password'];
}

/*
-----------------------------------
Авторизуемся по  COOKIE  
-----------------------------------
*/
elseif (isset ($_COOKIE['ip_address']) && isset ($_COOKIE['use_password'])) {
    $user_id = intval(base64_decode($_COOKIE['ip_address']));
    $_SESSION['id_address'] = $user_id;
    $user_ps = md5($_COOKIE['use_password']);
    $_SESSION['use_password'] = $user_ps;
    $cookauth = true;
}
/*
-----------------------------------
Запрос в DB 
-----------------------------------
*/
if ($user_id && $user_ps) {
    $req = mysql_query("SELECT * FROM `users` WHERE `id` = '$user_id' LIMIT 1");
    if (mysql_num_rows($req)) {
        $datauser = mysql_fetch_assoc($req);
        if ($user_ps === $datauser['password']) {
            $set_user = array();
            $set_user = unserialize($datauser['set_user']);
            if (empty ($set_user)) {$set_user['avatar'] = 1;$set_user['smileys'] = 1;$set_user['translit'] = 1;$set_user['quick_go'] = 1;$set_user['gzip'] = 1;
                $set_user['online'] = 1;$set_user['movings'] = 1;$set_user['digest'] = 1;$set_user['sdvig'] = 0;$set_user['kmess'] = 10;$set_user['skin'] = 'default';}
            $poster = (int) $set_user['kmess'];
            $login = $datauser['login'];
            $rights = $datauser['rights'];
   }
        else {
            unset ($_SESSION['id_address']);
            unset ($_SESSION['use_password']);
            setcookie('cuid', '');
            setcookie('cups', '');
            $user_id = false;
            $user_ps = false;
        }
    }
    else {
        unset ($_SESSION['id_address']);
        unset ($_SESSION['use_password']);
        setcookie('cuid', '');
        setcookie('cups', '');
        $user_id = false;
        $user_ps = false;
    }
}
$users_nav = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='$user_id'"));
/*
----------------------
Для не авторизованных
----------------------
*/


function registrat($link = NULL) {
global $user_id;
if (!isset($user_id))
{
if ($link==NULL)$link=H.'index.php?'.SID;
header("Location: $link");exit;}}


function unreg($unregi = "") 
{
global $user_id;
if (isset($user_id))
{
if ($unregi=="")$unregi='/';
header("Location: $unregi");
exit;
}
}
function size($size) {
    if ($size >= 1073741824) {
        $size = round($size / 1073741824 * 100) / 100 . ' Gb';
    }  elseif ($size >= 1048576) {
        $size = round($size / 1048576 * 100) / 100 . ' Mb';
    }  elseif ($size >= 1024) {
        $size = round($size / 1024 * 100) / 100 . ' Kb';
    } else {
        $size = $size . ' b';
    }
    return $size;
}

$users_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user_id'"));
/*
-----------------------------------------
Обработка смайлов, тэгов, сcылок, строк
-----------------------------------------
*/
function handling_smileys($pag_smil,
                          $br = true,
						  $bbcode_smiley_smiley = true,
						  $parser = true,
						  $smiles = true){
if ($br==true){
	$pag_smil=br_per($pag_smil);}
	
if ($bbcode_smiley_smiley==true){
	$bb_c_s=$pag_smil;
	$pag_smil=bb_codes($pag_smil);}
	
if ($parser==true){
	$bb_c_s=$pag_smil;
	$BBcodeParser = new BBcodeParser;
	$pag_smil=$BBcodeParser->parserString($pag_smil); }
	
if ($smiles==true){
	$bb_c_s=$pag_smil;
	$smile_class = new Smiles;
	$pag_smil=$smile_class->Smileclass($pag_smil);}
	return $pag_smil;}

	$titles_home = mysql_fetch_array(
	                                 mysql_query("SELECT * FROM `settings_shcms`"));
	$title_homes = $titles_home['title'];


     mysql_query("UPDATE users SET datelast=".time()." WHERE id=$user_id");
 
    include_once 'array_name.php';


function downloads($filename, $name, $onshcms='application/octet-stream') {
     ob_end_clean();
     $unon=0;
     $size=filesize($filename);
     $to=$size;
     header('Content-Length: ' .($to-$unon));
     if (isset($cr))header($cr);
     header('Connection: close');
     header('Content-Type: ' . $onshcms);
     $f=fopen($filename, 'rb');
     header('Content-Disposition: attachment; filename="'.$name.'";');
     
     fseek($f, $$unon, SEEK_SET);
     $size=$to;
     $downloaded=0;
     while(!feof($f) and !connection_status() and ($downloaded<$size)) {
     $block = min(1024*8, $size - $downloaded);
      echo fread($f, $block);
     $downloaded += $block;
     flush();}
      fclose($f);
}
	

$user_them = mysql_query("SELECT * FROM `users`");
$users_them = mysql_fetch_array($user_them);

$h_ua = str_replace('windows ce', '', strtolower($_SERVER['HTTP_USER_AGENT'])); 
if (!$h_ua || 
	strpos($h_ua, 'windows') !== false || 
	strpos($h_ua, 'linux') !== false || 
	strpos($h_ua, 'bsd') !== false || 
	strpos($h_ua, 'x11') !== false || 
	strpos($h_ua, 'unix') !== false || 
	strpos($h_ua, 'macintosh') !== false || 
	strpos($h_ua, 'macos') !== false) 
	{$brodilka = "web"; }
	else{ 
	$brodilka = "wap";}
	
class adminka_list{

function admin(){
	global $user_id;
	$admin_users = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `team`='6'"));
	if($admin_users['id'] != $user_id){
	header("Refresh:1; url=/");
	include_once'../template/foot.php';
	exit;}
	}
	}

	$adminka = new adminka_list;

	$user4 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$user_id'"));

	/*
	------------------------------
	Проверка пользователя на Бан
	------------------------------
	*/
	if (!isset($list_bans) && mysql_result(
	mysql_query("SELECT COUNT(*) FROM `ban_users` WHERE `user_id` = '$user_id' AND (`time_1` > '".(time())."')"), 0)){
   header('Location: '.DIR_SHCMS.'ban.php?');
   exit();}

   
	/*
	-----------------------------------------------
	Гостю будет показана стандартная web wap тема
	-----------------------------------------------
	*/
if(!$user_id){
	$users_nav['wap'] = 'shcms';
	$users_nav['web'] = 'shcms_web';}




	/*
	-----------------------------------------------
	Закидывает гостя в базу 
	-----------------------------------------------
	*/
$sys = mysql_fetch_array(mysql_query("SELECT * FROM `online_guest` WHERE `ip` = '$vi_shcms'"));
if(!$user_id){
if($sys['ip'] == $vi_shcms){
   mysql_query("UPDATE online_guest SET ip='$vi_shcms',time='".time()."',ua='$ua' WHERE ip = $sys[ip]");}
else{
   mysql_query("INSERT INTO online_guest (ip,time,ua) VALUES('$vi_shcms','".time()."',ua='$ua')");}}
   
   mysql_query("DELETE FROM `online_guest` WHERE `time` < '".(time()-600)."' AND ip='$vi_shcms'");
   mysql_query("OPTIMIZE TABLE `online_guest`");

   
   
   
   
   
   

?>