| 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/xml.inc.php'); |
|---|
| 27 | |
|---|
| 28 | $_SERVER['HTTP_HOST'] = ereg_replace(":80$", '', $_SERVER['HTTP_HOST']); |
|---|
| 29 | $requested_site = ereg_replace("^www\.", '', $_SERVER['HTTP_HOST']); |
|---|
| 30 | ereg("(.*)\.${config['domain']}$", $requested_site, $regs); |
|---|
| 31 | |
|---|
| 32 | $login = $regs[1]; |
|---|
| 33 | |
|---|
| 34 | $smarty = new Smarty_dotnode; |
|---|
| 35 | $smarty->template_dir = SMARTYPATH.'/templates_xml/'; |
|---|
| 36 | $smarty->compile_id = 'xml'; |
|---|
| 37 | $smarty->caching = true; |
|---|
| 38 | |
|---|
| 39 | session_start(); |
|---|
| 40 | |
|---|
| 41 | if( !$smarty->is_cached('index.tpl',$login.'.'.$_SERVER['PHP_SELF']) ) |
|---|
| 42 | { |
|---|
| 43 | $token = retreive_url_info($_SERVER['PHP_SELF']); |
|---|
| 44 | array_splice($token, 0, 1); |
|---|
| 45 | |
|---|
| 46 | if(strlen($token[0]) == 32) |
|---|
| 47 | list($url_id) = array_splice($token, 0, 1); |
|---|
| 48 | |
|---|
| 49 | for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 50 | { |
|---|
| 51 | $inc = ""; |
|---|
| 52 | for($level=0; $level<=$idx; $level++) |
|---|
| 53 | $inc .= $token[$level].'/'; |
|---|
| 54 | $inc = substr($inc,0,-1).'.inc.php'; |
|---|
| 55 | error_log($_SERVER['HTTP_HOST'].' | Include:'.$inc); |
|---|
| 56 | if(file_exists(INCLUDEPATH.'/'.$inc)) |
|---|
| 57 | break; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | if(!file_exists(INCLUDEPATH.'/'.$inc) || !ereg("\.inc\.php$", $inc)) |
|---|
| 61 | $inc = 'index.inc.php'; |
|---|
| 62 | |
|---|
| 63 | $db =& DB::connect($dsn); |
|---|
| 64 | if (DB::isError($db)) |
|---|
| 65 | error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage()); |
|---|
| 66 | $db->setFetchMode(DB_FETCHMODE_ASSOC); |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | $user['info'] =& get_cache_user_info($login); |
|---|
| 70 | |
|---|
| 71 | if(!$user['info']) |
|---|
| 72 | { |
|---|
| 73 | header('Location: http://'.$config['domain'].'/pub/no-hp'); |
|---|
| 74 | exit(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | if(get_setting($user['info']['id'], 'publish') == 'no') |
|---|
| 78 | exit; |
|---|
| 79 | |
|---|
| 80 | include (INCLUDEPATH.'/'.$inc); |
|---|
| 81 | |
|---|
| 82 | $db->disconnect(); |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 86 | { |
|---|
| 87 | $tpl = ""; |
|---|
| 88 | for($level=0; $level<=$idx; $level++) |
|---|
| 89 | $tpl .= $token[$level].'/'; |
|---|
| 90 | $tpl = substr($tpl,0,-1).'.tpl'; |
|---|
| 91 | if($smarty->template_exists($tpl)) |
|---|
| 92 | break; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | if(!$smarty->template_exists($tpl)) |
|---|
| 96 | $tpl='default.tpl'; |
|---|
| 97 | |
|---|
| 98 | $_SMARTY['tpl'] = $tpl; |
|---|
| 99 | $_SMARTY['token'] = $token; |
|---|
| 100 | $_SMARTY['url_id'] = $url_id; |
|---|
| 101 | $_SMARTY['profile'] = $user; |
|---|
| 102 | $smarty->assign($_SMARTY); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | if(ereg('\.xul$', $_SERVER['PHP_SELF'])) |
|---|
| 106 | header('Content-type: application/vnd.mozilla.xul+xml; charset=UTF-8'); |
|---|
| 107 | elseif(ereg('\.rdf$', $_SERVER['PHP_SELF'])) |
|---|
| 108 | header('Content-type: text/rdf; charset=UTF-8'); |
|---|
| 109 | else |
|---|
| 110 | header('Content-type: application/rdf+xml; charset=UTF-8'); |
|---|
| 111 | $smarty->display('index.tpl', $login.'.'.$_SERVER['PHP_SELF']); |
|---|
| 112 | |
|---|
| 113 | ?> |
|---|
| 114 | |
|---|