2008-11-04 11:00:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
@ignore_user_abort(TRUE);
|
|
|
|
|
|
|
|
@set_magic_quotes_runtime(0);
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
header("Content-Type: text/html;charset=utf-8");
|
|
|
|
|
|
|
|
if (!defined("_FCORE")) die('non autorise');
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
if (is_file(_FCORE."ban.xlist"))
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
$banlist = file(_FCORE."ban.xlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
|
|
if(in_array($_SERVER['REMOTE_ADDR'], $banlist)) die('banni');
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
else die('blacklist introuvable');
|
|
|
|
|
|
|
|
$config = array();
|
|
|
|
|
|
|
|
function load_conf($file,&$config)
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
if(is_file($file))
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$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)))
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
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];
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
else die("Fichier de configuration incorrect!");
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
else die("fichier de configuration introuvable!");
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
load_conf(_FCORE."config.xconf",$config);
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if(defined('_PROFILE')) load_conf(_FCORE."profiles/"._PROFILE.".xconf",$config);
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if($config['actif']!='1') die('desactive');
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
if($config['log_error'] == '1')
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
@ini_set('log_errors','on');
|
|
|
|
@ini_set('error_log',_FCORE.'/logs/php/');
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
if($config['hide_error'] == '1')
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
@ini_set('display_errors','off');
|
|
|
|
@ini_set('track_errors','on');
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
else
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
@error_reporting(E_ALL);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
setLocale(LC_TIME, $config['locales'], $config['lang']);
|
|
|
|
|
|
|
|
if(!is_writable(_FCORE."logs/")) die('log non accessible en ecriture');
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
function file_log($message,$level = 0,$dir = NULL,$file = NULL)
|
|
|
|
{
|
|
|
|
$dir = empty($dir) ? _FCORE."logs" : $dir;
|
|
|
|
$file = empty($file) ? strftime('%d-%m-%Y').".xlog" : $file;
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if($fichier = @fopen("$dir/$file",'a+'))
|
|
|
|
{
|
2008-11-04 11:00:00 +00:00
|
|
|
switch($level)
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: $level = 'MESSAGE'; break;
|
|
|
|
case 1: $level = 'AVERTISSEMENT'; break;
|
|
|
|
case 2: $level = 'ERREUR'; break;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
$time = strftime('%H:%M:%S');
|
2008-09-20 10:00:00 +00:00
|
|
|
$req = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD']: '';
|
|
|
|
$arg = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI']: '';
|
|
|
|
$remote = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR']: '';
|
|
|
|
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT']: '';
|
|
|
|
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER']: '';
|
|
|
|
$line = "[$time] $level : $message [$remote] [$req] [$arg] [$ua] [$referer]\r\n";
|
2008-11-04 11:00:00 +00:00
|
|
|
fwrite($fichier,$line);
|
|
|
|
fclose($fichier);
|
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
else die('log non accessible en ecriture');
|
|
|
|
}
|
|
|
|
|
|
|
|
function hexstr($var)
|
|
|
|
{
|
|
|
|
$var = pack('H*',$var);
|
|
|
|
return $var;
|
|
|
|
}
|
|
|
|
|
|
|
|
function strhex($var)
|
|
|
|
{
|
|
|
|
$var = array_shift(unpack('H*',$var));
|
|
|
|
return $var;
|
|
|
|
}
|
|
|
|
|
|
|
|
function bitstr($var)
|
|
|
|
{
|
|
|
|
$r = NULL;
|
|
|
|
|
|
|
|
for($i = 0; $i < strlen($var); $i += 8)
|
|
|
|
{
|
|
|
|
$r .= chr(bindec(substr($var,$i,8)));
|
|
|
|
}
|
|
|
|
return $r;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
function bithex($var)
|
|
|
|
{
|
|
|
|
$r = NULL;
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
for($i = 0; $i < strlen($var); $i += 4)
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$r .= base_convert(substr($var,$i,4),2,16);
|
|
|
|
}
|
|
|
|
return $r;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
function cxor($msg,$cle)
|
|
|
|
{
|
|
|
|
$xor = NULL;
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
for($i = 0; $i < strlen($msg);$i++)
|
|
|
|
{
|
|
|
|
$xor .= substr($msg,$i,1) ^ substr($cle,$i % strlen($cle),1);
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
return $xor;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
function random($l=128)
|
|
|
|
{
|
|
|
|
$r = NULL;
|
|
|
|
for($i = 1;$i <= $l/128 && $l/128 <= 32; $i++)
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$var = time().microtime().mt_rand().md5(time()).md5(microtime()).md5(mt_rand()).sha1(time()).sha1(microtime()).sha1(mt_rand());
|
|
|
|
$r .= md5(cxor(hexstr(md5($var)),hexstr(sha1($var))));
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
function hash_var($var,$algo = NULL)
|
|
|
|
{
|
|
|
|
if(function_exists('hash'))
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$algo = empty($algo) ? 'whirlpool' : $algo;
|
|
|
|
|
|
|
|
if(in_array($algo,hash_algos()))
|
|
|
|
{
|
|
|
|
$hash = hash($algo, $var);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$hash = md5($var);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
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]);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
function encode_ip($dotquad_ip=FALSE)
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
if(!$dotquad_ip)
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$dotquad_ip = $_SERVER['REMOTE_ADDR'];
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
$ip_sep = explode('.', $dotquad_ip);
|
|
|
|
return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
function gpc($name,$method='get')
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
switch($method)
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
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;
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if(isset($var) && $var!=='')
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$var = get_magic_quotes_gpc()?stripslashes($var):$var;
|
|
|
|
return $var;
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
else return FALSE;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
function cookie($name,$value,$time=NULL)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
if(empty($time))
|
2008-11-04 11:00:00 +00:00
|
|
|
{
|
2008-09-20 10:00:00 +00:00
|
|
|
$time = time()+$config['session_time'];
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
setcookie($name,$value,$time);
|
|
|
|
}
|
|
|
|
|
2008-11-04 11:00:00 +00:00
|
|
|
function url($string,$external=FALSE)
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
global $config;
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if($external) return htmlspecialchars($string);
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if($config['url_rewriting'] != '1')
|
|
|
|
{
|
|
|
|
$masque = $config['url_masque'];
|
|
|
|
$replace = $config['url_replace'];
|
|
|
|
$var = preg_replace($masque,$replace,$string);
|
|
|
|
return htmlspecialchars($var);
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
2008-09-20 10:00:00 +00:00
|
|
|
else return htmlspecialchars($string);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
function bbcode($var,$level=0)
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
global $config;
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
switch($level)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
$pattern[] = '#\\[code\\](.+?)\\[/code\\]#us';
|
|
|
|
$replace[] = '<pre>$1</pre>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[size=([1-3][0-9])\\](.+?)\\[/size\\]#us';
|
|
|
|
$replace[] = '<span style="font-size: $1px;">$2</span>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$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>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[img\\]http(s)?://([a-zA-Z0-9_/.%*+~,;:\\#-]+)\\[/img\\]#u';
|
|
|
|
$replace[] = '<img src="http$1://$2" alt="$2" />';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
$pattern[] = '#\\[url=(?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\](.+?)\\[/url\\]#u';
|
|
|
|
$replace[] = '<a href="http$1://$2">$3</a>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[url\\](?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\[/url\\]#u';
|
|
|
|
$replace[] = '<a href="http$1://$2">$2</a>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[cite\\](.+?)\\[/cite\\]#us';
|
|
|
|
$replace[] = '<q>$1</q>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[u\\](.+?)\\[/u\\]#us';
|
|
|
|
$replace[] = '<ins>$1</ins>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[i\\](.+?)\\[/i\\]#us';
|
|
|
|
$replace[] = '<em>$1</em>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern[] = '#\\[b\\](.+?)\\[/b\\]#us';
|
|
|
|
$replace[] = '<strong>$1</strong>';
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
foreach($config['smiley'] as $keys => $values)
|
|
|
|
{
|
|
|
|
$pattern[] = '#'.preg_quote($values).'#u';
|
|
|
|
$replace[] = '<img src="'.$config['smiley_dir'].'/'.$keys.'.gif" alt="'.$keys.'" />';
|
2008-11-04 11:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$pattern = array_reverse($pattern);
|
|
|
|
$replace = array_reverse($replace);
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$var = preg_replace($pattern,$replace,$var);
|
|
|
|
return $var;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
require_once(_FCORE."access.php");
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
if($config['db_crypt'] == '1')
|
|
|
|
{
|
|
|
|
foreach($var___db as $key => $value)
|
|
|
|
{
|
|
|
|
$var___db[$key]['password'] = cxor(base64_decode($value['password']),hash_var($config['db_cle']));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define('SMARTY_DIR',_FCORE.'smarty/');
|
|
|
|
|
2008-11-04 11:00:00 +00:00
|
|
|
require_once(SMARTY_DIR."Smarty.class.php");
|
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
switch($config['db_type'])
|
|
|
|
{
|
|
|
|
case 'mysql' :
|
|
|
|
case 'postgresql' :
|
2008-11-04 11:00:00 +00:00
|
|
|
|
2008-09-20 10:00:00 +00:00
|
|
|
$db = $config['db_type'];
|
|
|
|
require_once(_FCORE."bdd.$db.class.php");
|
|
|
|
require_once(_FCORE."session.$db.class.php");
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
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
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
var $template_dir = _TEMPLATE_DIR;
|
|
|
|
var $compile_dir = _TEMPLATE_COMPILE;
|
|
|
|
var $config_dir = _TEMPLATE_CONFIG;
|
|
|
|
var $cache_dir = _TEMPLATE_CACHE;
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
function no_db()
|
2008-09-20 10:00:00 +00:00
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
die($config['no_db_message']);
|
|
|
|
}
|
2008-11-04 11:00:00 +00:00
|
|
|
|
|
|
|
?>
|