root/trunk/dotnode-new.php

Revision 16, 3.9 KB (checked in by alexx, 6 years ago)
  • cleanup crapy code in dotnode-xml.php
  • include new Smarty_dotnode object to fix #14
  • modify reset_data.sh bash script to fix log problem
  • remove hardcoded ini_set error_log in config (it must bi fixed in vhost, or if not possible: in config_server.inc.php
  • fix impossibility to change language in dotpage (cookie name not set correctly)
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
26include('../includes/includes.inc.php');
27include('../includes/config/global.inc.php');
28
29$smarty = new Smarty_dotnode;
30$smarty->compile_id = 'new';
31
32$token = retreive_url_info($_SERVER['PHP_SELF']);
33
34session_start();
35
36if(strlen($token[1]) == 32)
37    list($url_id) = array_splice($token, 1,1);
38else
39    $url_id = $_SESSION['my_id'];
40
41if(!$_SESSION['my_id'] && $_SESSION['status'] != 'guest')
42{
43    header('Location: /pub');
44    exit();
45}
46
47// Determination de la template d'aide a afficher
48
49for($idx=(count($token)-1); $idx>=0; $idx--)
50{
51        $help_tpl = "help/";
52        for($level=0; $level<=$idx; $level++)
53                $help_tpl .= $token[$level].'/';
54        $help_tpl = substr($help_tpl,0,-1).'.tpl';
55        if($smarty->template_exists($help_tpl))
56                break;
57}
58
59if(!$smarty->template_exists($help_tpl))
60        unset($help_tpl);
61else
62        $_SMARTY['help_tpl'] = $help_tpl;
63
64
65
66// Determination de l'include PHP a inclure
67
68for($idx=(count($token)-1); $idx>=0; $idx--)
69{
70        $inc = "";
71        for($level=0; $level<=$idx; $level++)
72                $inc .= $token[$level].'/';
73        $inc = substr($inc,0,-1).'.inc.php';
74    error_log($_SERVER['HTTP_HOST'].' | Include:'.$inc);
75        if(file_exists(INCLUDEPATH.'/'.$inc))
76                break;
77}
78
79if(!file_exists(INCLUDEPATH.'/'.$inc))
80    $inc = 'index.inc.php';
81
82
83$db =& DB::connect($dsn);
84if (DB::isError($db))
85        error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage());
86$db->setFetchMode(DB_FETCHMODE_ASSOC);
87
88include (INCLUDEPATH.'/'.$inc);
89
90$db->disconnect();
91
92// Determination de la template a afficher
93
94for($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//    error_log($_SERVER['HTTP_HOST'].' | Template:'.$tpl);
101    if($smarty->template_exists($tpl))
102        break;
103}
104
105if(!$smarty->template_exists($tpl))
106    $tpl='default.tpl';
107   
108
109// Exportation des donnees pour Smarty
110
111$_SMARTY['token'] = $token;
112$_SMARTY['menu'] = $menu['main'];
113$_SMARTY['smenu'] = $smenu[$token[0]];
114$_SMARTY['ssmenu'] = $ssmenu[$token[0]][$token[1]];
115
116$_SMARTY['tpl'] = $tpl;
117
118$_SMARTY['url_id'] = $url_id;
119$_SMARTY['nyrk'] = $nyrk;
120$_SMARTY['labels'] = $labels;
121$_SMARTY['access_fields'] = $access_fields;
122$_SMARTY['lang'] = $lang;
123
124if($_SERVER['REMOTE_ADDR'] == $config['admin_ip'])
125{
126    $debug['session'] = $_SESSION;
127    $_SMARTY['debug'] = $debug;
128    $_SMARTY['php_mem'] = memory_get_usage()/1024;
129    $_SMARTY['inc'] = $inc;
130}
131
132$smarty->assign($_SMARTY);
133
134// Affiche du template
135
136error_log($_SERVER['HTTP_HOST'].' | '.$_SERVER['PHP_SELF'].' | '.$_SESSION['my_login']);
137header('Content-type: text/html; charset=UTF-8');
138
139// ob_start('ob_gzhandler');
140
141$smarty->display('index_head.tpl', $lang2.'.'.$_SERVER['PHP_SELF']);
142$smarty->display($tpl, $lang2.'.'.$_SERVER['PHP_SELF']);
143$smarty->display('index_foot.tpl', $lang2.'.'.$_SERVER['PHP_SELF']);
144
145unset($_SESSION['error']);
146unset($_SESSION['temp']);
147?>
Note: See TracBrowser for help on using the browser.