root/trunk/dntp/engine.php

Revision 1, 3.1 KB (checked in by anonymous, 7 years ago)

initial import

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
25include ('../includes/includes.inc.php');
26include('../includes/config/dntp.inc.php');
27
28
29$smarty = new Smarty;
30
31$smarty->template_dir = SMARTYPATH.'/templates_dntp/';
32$smarty->compile_dir = SMARTYPATH.'/templates_c/';
33$smarty->config_dir = SMARTYPATH.'/configs/';
34$smarty->debugging_ctrl = true;
35$smarty->register_block('t', 'smarty_translate');
36
37$smarty->compile_id = 'dntp';
38$smarty->caching = false;
39$smarty->use_sub_dirs = 1;
40
41session_start();
42
43if($_SESSION['my_lang'] == 'fa_IR')
44    $_SMARTY['rtl'] = true;
45
46$token = retreive_url_info($_SERVER['PHP_SELF']);
47
48if(!$_SESSION['my_id'] && $token[0] != 'pub')
49{
50    header('Location: /pub');
51    exit();
52}
53
54switch($_SESSION['my_status'])
55{
56    case 'waiting':
57        header('Location: /pub');
58        exit();
59        break;
60}
61
62if($token[0] != 'pub' && (!$_SESSION['my_id'] || $_SESSION['SecID'] != $_COOKIE['SecID']  ))
63{
64    header('Location: /pub?url='.urlencode($_SERVER['PHP_SELF']));
65    exit();
66}
67
68// Determination de la template d'aide a afficher
69for($idx=(count($token)-1); $idx>=0; $idx--)
70{
71    $tpl = '';
72    for($level=0; $level<=$idx; $level++)
73        $tpl .= $token[$level].'/';
74    $tpl = substr($tpl,0,-1).'.tpl';
75    if($smarty->template_exists($tpl))
76        break;
77}
78
79if(!$smarty->template_exists($tpl))
80    $tpl='default.tpl';
81
82for($idx=(count($token)-1); $idx>=0; $idx--)
83{
84    $inc = '';
85    for($level=0; $level<=$idx; $level++)
86        $inc .= $token[$level].'/';
87    $inc = substr($inc,0,-1).'.inc.php';
88    //      error_log($_SERVER['HTTP_HOST'].' | Include:'.$inc);
89    if(file_exists(INCLUDEPATH.'/'.$inc))
90        break;
91}
92
93if(!file_exists(INCLUDEPATH.'/'.$inc))
94    $inc = 'index.inc.php';
95
96$db=&DB::connect($dsn);
97if (DB::isError($db))
98    die($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage());
99
100$db->setFetchMode(DB_FETCHMODE_ASSOC);
101
102include (INCLUDEPATH.'/'.$inc);
103$db->disconnect();
104
105$_SMARTY['status'] = array('ok', 'new', 'must_be_verified');
106$_SMARTY['token'] = $token;
107
108$smarty->assign($_SMARTY);
109
110
111header('Content-type: text/html; charset=UTF-8');
112$smarty->display('index_head.tpl');
113$smarty->display($tpl);
114$smarty->display('index_foot.tpl');
115
116?>
Note: See TracBrowser for help on using the browser.