| 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/hp.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 | $login = $regs[1]; |
|---|
| 32 | |
|---|
| 33 | $smarty = new Smarty_dotnode; |
|---|
| 34 | $smarty->template_dir = SMARTYPATH.'/templates_hp/'; |
|---|
| 35 | $smarty->compile_id = 'hp'; |
|---|
| 36 | $smarty->cache_lifetime = 600; |
|---|
| 37 | $smarty->caching = true; |
|---|
| 38 | |
|---|
| 39 | if(!$smarty->is_cached('index.tpl', $login.'.'.$lang.'.'.$_SERVER['PHP_SELF'] )) |
|---|
| 40 | { |
|---|
| 41 | $token = retreive_url_info($_SERVER["PHP_SELF"]); |
|---|
| 42 | |
|---|
| 43 | for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 44 | { |
|---|
| 45 | $inc = ''; |
|---|
| 46 | for($level=0; $level<=$idx; $level++) |
|---|
| 47 | $inc .= $token[$level].'/'; |
|---|
| 48 | $inc = substr($inc,0,-1).'.inc.php'; |
|---|
| 49 | error_log($_SERVER['HTTP_HOST'].' | Include:'.$inc); |
|---|
| 50 | if(file_exists(INCLUDEPATH.'/'.$inc)) |
|---|
| 51 | break; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | if(!file_exists(INCLUDEPATH.'/'.$inc)) |
|---|
| 55 | $inc = 'index.inc.php'; |
|---|
| 56 | |
|---|
| 57 | $db =& DB::connect($dsn); |
|---|
| 58 | if (DB::isError($db)) |
|---|
| 59 | die($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage()); |
|---|
| 60 | $db->setFetchMode(DB_FETCHMODE_ASSOC); |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | $user['info'] =& get_cache_user_info($login); |
|---|
| 64 | $user['info']['6nergies_url'] = $db->getOne('SELECT 6nergies_url FROM user_professional WHERE id=?', array($user['info']['id'])); |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | if(!$user['info']['gender']) |
|---|
| 68 | { |
|---|
| 69 | header('Location: http://'.$config['domain'].'/pub/no-hp'); |
|---|
| 70 | exit(); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | if(get_setting($user['info']['id'], 'publish') == 'no') |
|---|
| 74 | { |
|---|
| 75 | if (!isset($_SERVER['PHP_AUTH_USER']) || |
|---|
| 76 | $_SERVER['PHP_AUTH_USER'] != $user['info']['login'] || |
|---|
| 77 | !$db->getRow('SELECT login, status FROM user WHERE login=? AND passwd_md5=?',array($_SERVER['PHP_AUTH_USER'], md5($_SERVER['PHP_AUTH_PW'])) ) |
|---|
| 78 | ) |
|---|
| 79 | { |
|---|
| 80 | header('WWW-Authenticate: Basic realm=".Page not published"'); |
|---|
| 81 | header('HTTP/1.0 401 Unauthorized'); |
|---|
| 82 | echo "<h1>Unauthorized</h1>"; |
|---|
| 83 | echo "Your are not authorized to view this .page ... <a href='http://".$config['domain']."'>Go to <b>.node</b></a>"; |
|---|
| 84 | exit; |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | include (INCLUDEPATH.'/'.$inc); |
|---|
| 89 | $dotpage_css = get_setting($user['info']['id'], 'dotpage_css'); |
|---|
| 90 | $db->disconnect(); |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | for($idx=(count($token)-1); $idx>=0; $idx--) |
|---|
| 95 | { |
|---|
| 96 | $tpl = ''; |
|---|
| 97 | for($level=0; $level<=$idx; $level++) |
|---|
| 98 | $tpl .= $token[$level].'/'; |
|---|
| 99 | $tpl = substr($tpl,0,-1).'.tpl'; |
|---|
| 100 | if($smarty->template_exists($tpl)) |
|---|
| 101 | break; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | if(!$smarty->template_exists($tpl)) |
|---|
| 105 | $tpl='default.tpl'; |
|---|
| 106 | |
|---|
| 107 | $_SMARTY['tpl'] = $tpl; |
|---|
| 108 | $_SMARTY['token'] = $token; |
|---|
| 109 | |
|---|
| 110 | $_SMARTY['profile'] = $user; |
|---|
| 111 | $_SMARTY['dotpage_css'] = $dotpage_css; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | $dir = glob(ROOTDIR.'/hp/styles/*', GLOB_ONLYDIR); |
|---|
| 115 | |
|---|
| 116 | $css['default'] = 'default'; |
|---|
| 117 | |
|---|
| 118 | foreach($dir as $style) |
|---|
| 119 | { |
|---|
| 120 | if(basename($style) == 'default') |
|---|
| 121 | continue; |
|---|
| 122 | $css[basename($style)] = basename($style); |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | $_SMARTY['css'] = $css; |
|---|
| 126 | $_SMARTY['lang'] = $lang; |
|---|
| 127 | |
|---|
| 128 | $smarty->assign($_SMARTY); |
|---|
| 129 | |
|---|
| 130 | header('Content-type: text/html; charset=UTF-8'); |
|---|
| 131 | |
|---|
| 132 | $smarty->display('index.tpl', $login.'.'.$lang.'.'.$_SERVER['PHP_SELF']); |
|---|
| 133 | |
|---|
| 134 | ?> |
|---|
| 135 | |
|---|