root/trunk/dotnode-dotpage.php

Revision 33, 4.1 kB (checked in by alexx, 3 years ago)
  • Auth: Remove MySQL PASSWORD hashing method to hash password, replace by MD5 hashing, add code to make a smooth transition between hashing method
  • XML engine: Fix a trivial recent bug in dotnode-xml.php
  • Robots: fix a bug in crontab script robots/launch_robots.sh (add cd dirname $0)
  • CSS: Add max_width to image in blog (work on Mozilla/*, Opera but not good on Safari (no proportional resizing), of course, that doesn't work on IE)
  • DB: changing DB structure !!!
    ALTER TABLE `user` ADD `passwd_md5` CHAR( 32 ) NOT NULL AFTER `passwd` ;
    ALTER TABLE `user` CHANGE `passwd` `passwd` VARCHAR( 42 ) NULL ;
    ALTER TABLE `dntp_translator` ADD `passwd_md5` CHAR( 32 ) NOT NULL AFTER `passwd` ;
    ALTER TABLE `dntp_translator` CHANGE `passwd` `passwd` VARCHAR( 42 ) NULL ;
    
Line 
1 <?php
2 /****************************************************** Open .node ***
3  * Description:   
4  * Status:        Stable.
5  * Author:        Alexandre Dath <alexandre@dotnode.com>
6  * $Id$
7  *
8  * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  ******************** http://opensource.ikse.net/projects/dotnode ***/
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     // Determination de la template a afficher
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 // ob_start('ob_gzhandler');
132 $smarty->display('index.tpl', $login.'.'.$lang.'.'.$_SERVER['PHP_SELF']);
133
134 ?>
135
136
Note: See TracBrowser for help on using the browser.