| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
include('../includes/includes.inc.php'); |
|---|
| 26 |
include('../includes/config/global.inc.php'); |
|---|
| 27 |
|
|---|
| 28 |
if(ereg('www', $_SERVER['HTTP_HOST'])) |
|---|
| 29 |
{ |
|---|
| 30 |
header('Location: http://'.$config['domain'].$_SERVER['PHP_SELF']); |
|---|
| 31 |
exit(); |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
$smarty = new Smarty_dotnode; |
|---|
| 35 |
|
|---|
| 36 |
$smarty->compile_id = 'www'; |
|---|
| 37 |
|
|---|
| 38 |
$token = retreive_url_info($_SERVER['PHP_SELF']); |
|---|
| 39 |
|
|---|
| 40 |
$cache_array['/news/blog']['lifetime'] = 7200; |
|---|
| 41 |
$cache_array['/communities/last']['lifetime'] = 900; |
|---|
| 42 |
$cache_array['/communities/create']['lifetime'] = 86400; |
|---|
| 43 |
$cache_array['/communities/category']['lifetime'] = 86400; |
|---|
| 44 |
$cache_array['/news']['lifetime'] = 3600; |
|---|
| 45 |
$cache_array['/help/faq']['lifetime'] = 86400; |
|---|
| 46 |
$cache_array['/help/about']['lifetime'] = 86400; |
|---|
| 47 |
$cache_array['/help/terms']['lifetime'] = 86400; |
|---|
| 48 |
$cache_array['/help/privacy']['lifetime'] = 86400; |
|---|
| 49 |
$cache_array['/news/statistics']['lifetime'] = 21600; |
|---|
| 50 |
$cache_array['/support']['lifetime'] = 86400; |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
if(array_key_exists($_SERVER['PHP_SELF'], $cache_array)) |
|---|
| 54 |
$smarty->caching = 2; |
|---|
| 55 |
|
|---|
| 56 |
session_start(); |
|---|
| 57 |
|
|---|
| 58 |
if($_SESSION['my_login'] == $config['admin_login']) |
|---|
| 59 |
$smarty->debugging_ctrl = true; |
|---|
| 60 |
else |
|---|
| 61 |
$smarty->debugging_ctrl = false; |
|---|
| 62 |
|
|---|
| 63 |
if(is_valid('user_id', $token[1])) |
|---|
| 64 |
list($url_id) = array_splice($token, 1,1); |
|---|
| 65 |
else |
|---|
| 66 |
$url_id = $_SESSION['my_id']; |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
switch($_SESSION['my_status']) |
|---|
| 70 |
{ |
|---|
| 71 |
case 'waiting': |
|---|
| 72 |
header('Location: /new/profile'); |
|---|
| 73 |
exit(); |
|---|
| 74 |
break; |
|---|
| 75 |
case 'jail': |
|---|
| 76 |
header('Location: /pub/join'); |
|---|
| 77 |
exit(); |
|---|
| 78 |
break; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
if(!$_SESSION['my_id'] || $_SESSION['status'] != 'member' || $_SESSION['SecID'] != $_COOKIE['SecID'] ) |
|---|
| 82 |
{ |
|---|
| 83 |
header('Location: /pub?url='.urlencode($_SERVER['PHP_SELF'])); |
|---|
| 84 |
error_log('bye'); |
|---|
| 85 |
exit(); |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 91 |
{ |
|---|
| 92 |
$help_tpl = 'help/'; |
|---|
| 93 |
for($level=0; $level<=$idx; $level++) |
|---|
| 94 |
$help_tpl .= $token[$level].'/'; |
|---|
| 95 |
$help_tpl = substr($help_tpl,0,-1).'.tpl'; |
|---|
| 96 |
if($smarty->template_exists($help_tpl)) |
|---|
| 97 |
break; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
if(!$smarty->template_exists($help_tpl)) |
|---|
| 101 |
unset($help_tpl); |
|---|
| 102 |
else |
|---|
| 103 |
$_SMARTY['help_tpl'] = $help_tpl; |
|---|
| 104 |
|
|---|
| 105 |
for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 106 |
{ |
|---|
| 107 |
$tpl = ''; |
|---|
| 108 |
for($level=0; $level<=$idx; $level++) |
|---|
| 109 |
$tpl .= $token[$level].'/'; |
|---|
| 110 |
$tpl = substr($tpl,0,-1).'.tpl'; |
|---|
| 111 |
if($smarty->template_exists($tpl)) |
|---|
| 112 |
break; |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
if(!$smarty->template_exists($tpl)) |
|---|
| 116 |
$tpl='default.tpl'; |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
if(!$smarty->is_cached($tpl, $lang.'.'.$_SERVER['PHP_SELF']) || isset($_SESSION['error']) || $_POST ) |
|---|
| 122 |
{ |
|---|
| 123 |
for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 124 |
{ |
|---|
| 125 |
$inc = ''; |
|---|
| 126 |
for($level=0; $level<=$idx; $level++) |
|---|
| 127 |
$inc .= $token[$level].'/'; |
|---|
| 128 |
$inc = substr($inc,0,-1).'.inc.php'; |
|---|
| 129 |
|
|---|
| 130 |
if(file_exists(INCLUDEPATH.'/'.$inc)) |
|---|
| 131 |
break; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
if(!file_exists(INCLUDEPATH.'/'.$inc)) |
|---|
| 135 |
$inc = 'index.inc.php'; |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
$db =& DB::connect($dsn); |
|---|
| 139 |
if (DB::isError($db)) |
|---|
| 140 |
error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage()); |
|---|
| 141 |
$db->setFetchMode(DB_FETCHMODE_ASSOC); |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
if($_SESSION['sessionid_timestamp'] < time()-1800 ) |
|---|
| 145 |
{ |
|---|
| 146 |
session_regenerate_id(); |
|---|
| 147 |
$_SESSION['sessionid_timestamp'] = time(); |
|---|
| 148 |
} |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
if($_SESSION['lastaction_timestamp']<time()-300) |
|---|
| 152 |
{ |
|---|
| 153 |
$_SESSION['lastaction_timestamp'] = time(); |
|---|
| 154 |
$tmp_result = $db->query('UPDATE session SET timestamp=?, SecID=? WHERE id=?', array($_SESSION['lastaction_timestamp'], $_COOKIE['SecID'], $_SESSION['my_id']) ); |
|---|
| 155 |
if($db->affectedRows() != 1) |
|---|
| 156 |
$db->query('INSERT INTO session SET id=?, SecID=?, timestamp=?', array($_SESSION['my_id'], $_COOKIE['SecID'], $_SESSION['lastaction_timestamp']) ); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
if($_SESSION['nb_new_messages_timestamp']+300 < time()) |
|---|
| 160 |
{ |
|---|
| 161 |
$_SESSION['nb_new_messages'] = $db->getOne('SELECT COUNT(id_mess) FROM message WHERE id=? AND box=? AND flag=?', array($_SESSION['my_id'], 'inbox', 'new')); |
|---|
| 162 |
$_SESSION['nb_new_messages_timestamp'] = time(); |
|---|
| 163 |
error_log($_SESSION['my_login'].' pop: '.$_SESSION['nb_new_messages'].' ;)'); |
|---|
| 164 |
} |
|---|
| 165 |
include (INCLUDEPATH.'/'.$inc); |
|---|
| 166 |
|
|---|
| 167 |
$db->disconnect(); |
|---|
| 168 |
} |
|---|
| 169 |
else |
|---|
| 170 |
error_log('CACHE_DEBUG: '.$_SERVER['PHP_SELF'].', lifetime: '.$cache_array[$_SERVER['PHP_SELF']]['lifetime'].' CACHED !!!'); |
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
$_SMARTY['token'] = $token; |
|---|
| 174 |
$_SMARTY['full_smenu'] = $smenu; |
|---|
| 175 |
$_SMARTY['full_ssmenu'] = $ssmenu; |
|---|
| 176 |
$_SMARTY['menu'] = $menu['main']; |
|---|
| 177 |
$_SMARTY['smenu'] = $smenu[$token[0]]; |
|---|
| 178 |
$_SMARTY['ssmenu'] = $ssmenu[$token[0]][$token[1]]; |
|---|
| 179 |
$_SMARTY['tpl'] = $tpl; |
|---|
| 180 |
|
|---|
| 181 |
$_SMARTY['url_id'] = $url_id; |
|---|
| 182 |
$_SMARTY['nyrk'] = $nyrk; |
|---|
| 183 |
$_SMARTY['labels'] = $labels; |
|---|
| 184 |
$_SMARTY['access_fields'] = $access_fields; |
|---|
| 185 |
|
|---|
| 186 |
if($_SESSION['my_login'] == $config['admin_login']) |
|---|
| 187 |
{ |
|---|
| 188 |
$debug['session'] = $_SESSION; |
|---|
| 189 |
$_SMARTY['debug'] = $debug; |
|---|
| 190 |
$_SMARTY['lang'] = $lang; |
|---|
| 191 |
$_SMARTY['php_mem']= memory_get_usage()/1024; |
|---|
| 192 |
$_SMARTY['inc'] = $inc; |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
$smarty->assign($_SMARTY); |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
error_log($_SERVER['HTTP_HOST'].' | '.$_SERVER['PHP_SELF'].' | '.$_SESSION['my_login']); |
|---|
| 201 |
|
|---|
| 202 |
header('Content-type: text/html; charset=UTF-8'); |
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
$smarty->caching = false; |
|---|
| 206 |
$smarty->display('index_head.tpl', $lang.'.'.$_SERVER['PHP_SELF']); |
|---|
| 207 |
|
|---|
| 208 |
if(array_key_exists($_SERVER['PHP_SELF'], $cache_array) && !isset($_SESSION['error']) && !$_POST ) |
|---|
| 209 |
{ |
|---|
| 210 |
$smarty->caching=2; |
|---|
| 211 |
$smarty->cache_lifetime = $cache_array[$_SERVER['PHP_SELF']]['lifetime']; |
|---|
| 212 |
$smarty->display($tpl, $lang.'.'.$_SERVER['PHP_SELF']); |
|---|
| 213 |
error_log('CACHE_DEBUG: '.$_SERVER['PHP_SELF'].', lifetime: '.$cache_array[$_SERVER['PHP_SELF']]['lifetime'].' CACHED !!!'); |
|---|
| 214 |
} |
|---|
| 215 |
else |
|---|
| 216 |
$smarty->display($tpl); |
|---|
| 217 |
|
|---|
| 218 |
$smarty->caching = false; |
|---|
| 219 |
$smarty->display('index_foot.tpl', $lang.'.'.$_SERVER['PHP_SELF']); |
|---|
| 220 |
|
|---|
| 221 |
unset($_SESSION['error']); |
|---|
| 222 |
session_unregister('error'); |
|---|
| 223 |
|
|---|
| 224 |
unset($_SESSION['temp']); |
|---|
| 225 |
session_unregister('temp'); |
|---|
| 226 |
|
|---|
| 227 |
?> |
|---|
| 228 |
|
|---|