316 lines
7.4 KiB
PHP
316 lines
7.4 KiB
PHP
|
<?php
|
||
|
|
||
|
@ignore_user_abort(TRUE);
|
||
|
|
||
|
@set_magic_quotes_runtime(0);
|
||
|
|
||
|
if (!defined("_FCORE"))
|
||
|
{
|
||
|
die('non autorise');
|
||
|
}
|
||
|
|
||
|
if (is_file(_FCORE."ban.xlist"))
|
||
|
{
|
||
|
$banlist = file(_FCORE."ban.xlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||
|
if(in_array($_SERVER['REMOTE_ADDR'], $banlist))
|
||
|
{
|
||
|
die('banni');
|
||
|
}
|
||
|
}
|
||
|
else die('blacklist introuvable');
|
||
|
|
||
|
$config = array();
|
||
|
|
||
|
function load_conf($file,&$config)
|
||
|
{
|
||
|
if(is_file($file))
|
||
|
{
|
||
|
$fconfig = file($file,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||
|
|
||
|
$exp = '#^(\\w{3,30})(\\[(\\w{0,30})\\])?\\s?\:\\s?"(.{0,500})"$#ui';
|
||
|
foreach ($fconfig as $conf_value)
|
||
|
{
|
||
|
if (preg_match($exp,trim($conf_value)))
|
||
|
{
|
||
|
preg_match_all($exp,trim($conf_value),$m);
|
||
|
|
||
|
if(!empty($m[3][0]) && !empty($m[2][0]))
|
||
|
{
|
||
|
$config[$m[1][0]][$m[3][0]] = $m[4][0];
|
||
|
}
|
||
|
elseif(empty($m[3][0]) && !empty($m[2][0]))
|
||
|
{
|
||
|
$config[$m[1][0]][] = $m[4][0];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$config[$m[1][0]] = $m[4][0];
|
||
|
}
|
||
|
}
|
||
|
else die("Fichier de configuration incorrect!");
|
||
|
}
|
||
|
}
|
||
|
else die("fichier de configuration introuvable!");
|
||
|
}
|
||
|
|
||
|
load_conf(_FCORE."config.xconf",$config);
|
||
|
|
||
|
if(defined('_PROFILE'))
|
||
|
{
|
||
|
load_conf(_FCORE."profiles/"._PROFILE.".xconf",$config);
|
||
|
}
|
||
|
|
||
|
if($config['actif']!='1')
|
||
|
{
|
||
|
die('desactive');
|
||
|
}
|
||
|
|
||
|
if($config['log_error'] == '1')
|
||
|
{
|
||
|
@ini_set('log_errors','on');
|
||
|
@ini_set('error_log',substr(strstr(_FCORE,$config['htdocs']),strlen($config['htdocs'])).'logs/php.log');
|
||
|
}
|
||
|
|
||
|
if($config['hide_error'] == '1')
|
||
|
{
|
||
|
@ini_set('display_errors','off');
|
||
|
@ini_set('track_errors','on');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
@error_reporting(E_ALL);
|
||
|
}
|
||
|
|
||
|
setLocale(LC_TIME, $config['locales'], $config['lang']);
|
||
|
|
||
|
if(!is_writable(_FCORE."logs/")) die('log non accessible en ecriture');
|
||
|
|
||
|
function file_log($message,$level=0)
|
||
|
{
|
||
|
$date = strftime('%d-%m-%Y');
|
||
|
$fichier = fopen(_FCORE."logs/".$date.".xlog",'a+');
|
||
|
|
||
|
switch($level)
|
||
|
{
|
||
|
default:
|
||
|
case 0: $level = 'MESSAGE'; break;
|
||
|
case 1: $level = 'AVERTISSEMENT'; break;
|
||
|
case 2: $level = 'ERREUR'; break;
|
||
|
}
|
||
|
$time = strftime('%H:%M:%S');
|
||
|
$req = array_key_exists('REQUEST_METHOD',$_SERVER) ? $_SERVER['REQUEST_METHOD']: '';
|
||
|
$arg = array_key_exists('REQUEST_URI',$_SERVER) ? $_SERVER['REQUEST_URI']: '';
|
||
|
$remote = array_key_exists('REMOTE_ADDR',$_SERVER) ? $_SERVER['REMOTE_ADDR']: '';
|
||
|
$ua = array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT']: '';
|
||
|
$referer = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER['HTTP_REFERER']: '';
|
||
|
$line = "[$time] $level : $message [$remote] [$req] [$arg] [$ua] [$referer]\n";
|
||
|
fwrite($fichier,$line);
|
||
|
fclose($fichier);
|
||
|
}
|
||
|
|
||
|
|
||
|
function random($l=128)
|
||
|
{
|
||
|
switch ($l)
|
||
|
{
|
||
|
default:
|
||
|
case 128: $n = 1; break;
|
||
|
case 256: $n = 2; break;
|
||
|
case 512: $n = 4; break;
|
||
|
case 1024: $n = 8; break;
|
||
|
case 2048: $n = 16; break;
|
||
|
}
|
||
|
|
||
|
for($i = 1;$i <= $n; $i++)
|
||
|
{
|
||
|
$var = time().microtime().mt_rand().md5(time()).md5(microtime()).md5(mt_rand()).sha1(time()).sha1(microtime()).sha1(mt_rand());
|
||
|
$r[$i] = md5(md5($var)^sha1($var));
|
||
|
}
|
||
|
$var = implode('',$r);
|
||
|
|
||
|
return $var;
|
||
|
}
|
||
|
|
||
|
function hash_var($var,$algo = 'whirlpool')
|
||
|
{
|
||
|
if(function_exists('hash'))
|
||
|
{
|
||
|
if(in_array($algo,hash_algos()))
|
||
|
{
|
||
|
$hash = hash($algo, $var);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$hash = md5($var);
|
||
|
}
|
||
|
}
|
||
|
elseif($algo == 'sha1')
|
||
|
{
|
||
|
$hash = sha1($var);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$hash = md5($var);
|
||
|
}
|
||
|
|
||
|
return $hash;
|
||
|
}
|
||
|
|
||
|
function decode_ip($int_ip)
|
||
|
{
|
||
|
$hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
|
||
|
return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
|
||
|
}
|
||
|
|
||
|
function encode_ip($dotquad_ip=FALSE)
|
||
|
{
|
||
|
if(!$dotquad_ip)
|
||
|
{
|
||
|
$dotquad_ip = $_SERVER['REMOTE_ADDR'];
|
||
|
}
|
||
|
$ip_sep = explode('.', $dotquad_ip);
|
||
|
return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
|
||
|
}
|
||
|
|
||
|
function gpc($name,$method='get')
|
||
|
{
|
||
|
switch($method)
|
||
|
{
|
||
|
default:
|
||
|
case 'get': $var = isset($_GET[$name])?$_GET[$name]:NULL; break;
|
||
|
case 'post': $var = isset($_POST[$name])?$_POST[$name]:NULL; break;
|
||
|
case 'cookie': $var = isset($_COOKIE[$name])?$_COOKIE[$name]:NULL; break;
|
||
|
}
|
||
|
|
||
|
if(!empty($var))
|
||
|
{
|
||
|
$var = get_magic_quotes_gpc()?stripslashes($var):$var;
|
||
|
return $var;
|
||
|
}
|
||
|
else return FALSE;
|
||
|
}
|
||
|
|
||
|
function cookie($name,$value,$time=NULL)
|
||
|
{
|
||
|
global $config;
|
||
|
|
||
|
if(empty($time))
|
||
|
{
|
||
|
$time = time()+$config['session_time'];
|
||
|
}
|
||
|
|
||
|
setcookie($name,$value,$time);
|
||
|
}
|
||
|
|
||
|
function enc($var)
|
||
|
{
|
||
|
$string = preg_replace_callback('#^(.*)((\\?.*)?)$#u',create_function('$matches',' return htmlspecialchars($matches[1].urlencode($matches[2]));'),$var);
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
function url($string,$external=FALSE)
|
||
|
{
|
||
|
global $config;
|
||
|
|
||
|
if($external)
|
||
|
{
|
||
|
return enc($string);
|
||
|
}
|
||
|
|
||
|
if($config['url_rewriting'] != '1')
|
||
|
{
|
||
|
$masque = $config['url_masque'];
|
||
|
$replace = $config['url_replace'];
|
||
|
$var = preg_replace($masque,$replace,$string);
|
||
|
return enc($var);
|
||
|
}
|
||
|
else return enc($string);
|
||
|
}
|
||
|
|
||
|
function bbcode($var,$level=0)
|
||
|
{
|
||
|
global $config;
|
||
|
|
||
|
switch($level)
|
||
|
{
|
||
|
case 1:
|
||
|
$pattern[] = '#\\[code\\](.+?)\\[/code\\]#us';
|
||
|
$replace[] = '<pre>$1</pre>';
|
||
|
|
||
|
$pattern[] = '#\\[size=([1-3][0-9])\\](.+?)\\[/size\\]#us';
|
||
|
$replace[] = '<span style="font-size: $1px;">$2</span>';
|
||
|
|
||
|
$pattern[] = '#\\[color=(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|\\#[0-9A-Fa-f]{6})\\](.+?)\\[/color\\]#us';
|
||
|
$replace[] = '<span style="color: $1;">$2</span>';
|
||
|
|
||
|
$pattern[] = '#\\[img\\]http(s)?://([a-zA-Z0-9_/.%*+~,;:\\#-]+)\\[/img\\]#u';
|
||
|
$replace[] = '<img src="http$1://$2" alt="$2" />';
|
||
|
|
||
|
default:
|
||
|
case 0:
|
||
|
$pattern[] = '#\\[url=(?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\](.+?)\\[/url\\]#u';
|
||
|
$replace[] = '<a href="http$1://$2">$3</a>';
|
||
|
|
||
|
$pattern[] = '#\\[url\\](?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\[/url\\]#u';
|
||
|
$replace[] = '<a href="http$1://$2">$2</a>';
|
||
|
|
||
|
$pattern[] = '#\\[cite\\](.+?)\\[/cite\\]#us';
|
||
|
$replace[] = '<q>$1</q>';
|
||
|
|
||
|
$pattern[] = '#\\[u\\](.+?)\\[/u\\]#us';
|
||
|
$replace[] = '<ins>$1</ins>';
|
||
|
|
||
|
$pattern[] = '#\\[i\\](.+?)\\[/i\\]#us';
|
||
|
$replace[] = '<em>$1</em>';
|
||
|
|
||
|
$pattern[] = '#\\[b\\](.+?)\\[/b\\]#us';
|
||
|
$replace[] = '<strong>$1</strong>';
|
||
|
|
||
|
foreach($config['smiley'] as $keys => $values)
|
||
|
{
|
||
|
$pattern[] = '#'.preg_quote($values).'#u';
|
||
|
$replace[] = '<img src="'.$config['smiley_dir'].'/'.$keys.'.gif" alt="'.$keys.'" />';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$pattern = array_reverse($pattern);
|
||
|
$replace = array_reverse($replace);
|
||
|
|
||
|
$var = preg_replace($pattern,$replace,$var);
|
||
|
return $var;
|
||
|
}
|
||
|
|
||
|
|
||
|
define('SMARTY_DIR',_FCORE.'templates/libs/');
|
||
|
|
||
|
require_once(_FCORE."access.php");
|
||
|
|
||
|
require_once(SMARTY_DIR."Smarty.class.php");
|
||
|
|
||
|
require_once(_FCORE."bdd.class.php");
|
||
|
|
||
|
require_once(_FCORE."session.class.php");
|
||
|
|
||
|
define('_TEMPLATE_DIR',_FCORE.$config['template']['dir']);
|
||
|
define('_TEMPLATE_COMPILE',_FCORE.$config['template']['compile']);
|
||
|
define('_TEMPLATE_CONFIG',_FCORE.$config['template']['config']);
|
||
|
define('_TEMPLATE_CACHE',_FCORE.$config['template']['cache']);
|
||
|
|
||
|
class Template extends Smarty
|
||
|
{
|
||
|
var $template_dir = _TEMPLATE_DIR;
|
||
|
var $compile_dir = _TEMPLATE_COMPILE;
|
||
|
var $config_dir = _TEMPLATE_CONFIG;
|
||
|
var $cache_dir = _TEMPLATE_CACHE;
|
||
|
}
|
||
|
|
||
|
function no_db()
|
||
|
{
|
||
|
global $config;
|
||
|
include_once(_FCORE."hb_game/jeu/secours.php");
|
||
|
//die($config['no_db_message']);
|
||
|
}
|
||
|
|
||
|
header("Content-Type: text/html;charset=utf-8");
|
||
|
|
||
|
?>
|