1 | <?php |
---|
2 | /* |
---|
3 | * phpMyVisites : website statistics and audience measurements |
---|
4 | * Copyright (C) 2002 - 2006 |
---|
5 | * http://www.phpmyvisites.net/ |
---|
6 | * phpMyVisites is free software (license GNU/GPL) |
---|
7 | * Authors : phpMyVisites team |
---|
8 | */ |
---|
9 | |
---|
10 | // $Id: index.php,v 1.49 2005/12/21 00:54:18 matthieu_ Exp $ |
---|
11 | |
---|
12 | /** |
---|
13 | * index de l'application |
---|
14 | * |
---|
15 | * |
---|
16 | * @author xavier Lembo <xav@elix-dev.com> |
---|
17 | * @since Thu Sep 01 21:03:50 CEST 2005 |
---|
18 | * @version $Id: index.php,v 1.49 2005/12/21 00:54:18 matthieu_ Exp $ |
---|
19 | * @package phpmyvisites_v2 |
---|
20 | * |
---|
21 | */ |
---|
22 | |
---|
23 | if (!defined('_DIR_PLUGIN_PHPMV')){ |
---|
24 | $p=explode(basename(_DIR_PLUGINS)."/",str_replace('\\','/',realpath(dirname(dirname(__FILE__))))); |
---|
25 | define('_DIR_PLUGIN_PHPMV',(_DIR_PLUGINS.end($p)).'/'); |
---|
26 | } |
---|
27 | |
---|
28 | function verif_install(){ |
---|
29 | // gestion de l'install et repertoires, selon les versions |
---|
30 | if (defined('_DIR_TMP')){ |
---|
31 | define('_PHPMV_DIR_DATA',realpath(_DIR_TMP . "phpmvdatas")); |
---|
32 | if (!is_dir(_DIR_TMP."phpmvdatas")){ |
---|
33 | sous_repertoire(_DIR_TMP, "phpmvdatas"); |
---|
34 | } |
---|
35 | else { |
---|
36 | define('_PHPMV_DIR_DATA',realpath(_DIR_SESSIONS . "phpmvdatas")); |
---|
37 | if (!is_dir(_DIR_SESSIONS."phpmvdatas")){ |
---|
38 | sous_repertoire(_DIR_SESSIONS, "phpmvdatas"); |
---|
39 | } |
---|
40 | if (defined('_DIR_ETC')){ |
---|
41 | if (!is_dir(_DIR_ETC."phpmvconfig")) |
---|
42 | sous_repertoire(_DIR_ETC, "phpmvconfig"); |
---|
43 | if (is_dir(_DIR_ETC."phpmvconfig")) |
---|
44 | define('_PHPMV_DIR_CONFIG',realpath(_DIR_ETC . "phpmvconfig")); |
---|
45 | } |
---|
46 | if (!defined('_PHPMV_DIR_CONFIG')){ |
---|
47 | define('_PHPMV_DIR_CONFIG',realpath(_DIR_SESSIONS . "phpmvconfig")); |
---|
48 | if (!is_dir(_DIR_SESSIONS."phpmvconfig")){ |
---|
49 | sous_repertoire(_DIR_SESSIONS, "phpmvconfig"); |
---|
50 | } |
---|
51 | |
---|
52 | if (@file_exists(_PHPMV_DIR_CONFIG."config.php")) |
---|
53 | return; |
---|
54 | |
---|
55 | if (!defined('_FILE_CONNECT')){ |
---|
56 | define('_FILE_CONNECT', |
---|
57 | (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
---|
58 | : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php3') ? $f |
---|
59 | : false))); |
---|
60 | } |
---|
61 | if (lire_fichier(_FILE_CONNECT,$connect) && preg_match(',spip_connect_db\(([^\)]*)\),i',$connect,$r)){ |
---|
62 | $pars = explode(',',$r[1]); |
---|
63 | $host = substr($pars[0],1,strlen($pars[0])-2); |
---|
64 | $port = substr($pars[1],1,strlen($pars[1])-2); |
---|
65 | $login = substr($pars[2],1,strlen($pars[2])-2); |
---|
66 | $pass = substr($pars[3],1,strlen($pars[3])-2); |
---|
67 | $db = substr($pars[4],1,strlen($pars[4])-2); |
---|
68 | $url = url_de_base()._DIR_PLUGIN_PHPMV; |
---|
69 | |
---|
70 | define('DB_LOGIN',$login); |
---|
71 | define('DB_PASSWORD',$pass); |
---|
72 | define('DB_HOST',$host); |
---|
73 | define('DB_NAME',$db); |
---|
74 | |
---|
75 | $conf = '<'.'?php |
---|
76 | $siteInfo = array ('." |
---|
77 | 1 => |
---|
78 | array ( |
---|
79 | 'idsite' => '1', |
---|
80 | 'name' => '".$GLOBALS['meta']['nom_site']."', |
---|
81 | 'logo' => 'pixel.gif', |
---|
82 | 'params_choice' => 'all', |
---|
83 | 'params_names' => '', |
---|
84 | ), |
---|
85 | ); |
---|
86 | ?".'>'; |
---|
87 | ecrire_fichier(_PHPMV_DIR_CONFIG."/site_info.php",$conf); |
---|
88 | $conf = '<'.'?php |
---|
89 | $siteUrls = array ('." |
---|
90 | 1 => |
---|
91 | array ( |
---|
92 | 0 => '".$GLOBALS['meta']['adresse_site']."', |
---|
93 | ), |
---|
94 | ); |
---|
95 | ?".'>'; |
---|
96 | ecrire_fichier(_PHPMV_DIR_CONFIG."/site_urls.php",$conf); |
---|
97 | |
---|
98 | return; |
---|
99 | |
---|
100 | /*define('_PHPMV_DIR_CONFIG',realpath(_DIR_SESSIONS . "phpmvconfig")); |
---|
101 | define('_PHPMV_DIR_DATA',realpath(_DIR_SESSIONS . "phpmvdatas")); |
---|
102 | chdir(_DIR_PLUGIN_PHPMV); |
---|
103 | require_once INCLUDE_PATH . '/core/include/PmvConfig.class.php'; |
---|
104 | require_once INCLUDE_PATH . '/core/include/ApplicationController.php'; |
---|
105 | require_once INCLUDE_PATH . '/core/include/Request.class.php'; |
---|
106 | require_once INCLUDE_PATH . '/core/include/Module.class.php'; |
---|
107 | require_once INCLUDE_PATH . '/core/include/global.php'; |
---|
108 | require_once INCLUDE_PATH . '/core/include/Lang.class.php'; |
---|
109 | require_once INCLUDE_PATH . '/core/include/User.class.php'; |
---|
110 | |
---|
111 | $configPhpFileContent = array( |
---|
112 | 'db_login' => $login, |
---|
113 | 'db_password' => $pass, |
---|
114 | 'db_host' => $host, |
---|
115 | 'db_name' => $db, |
---|
116 | 'db_tables_prefix' => 'phpmv_', |
---|
117 | ); |
---|
118 | |
---|
119 | $db =& Db::getInstance(); |
---|
120 | |
---|
121 | // try to connect with new values |
---|
122 | $db->host = $configPhpFileContent['db_host']; |
---|
123 | $db->login = $configPhpFileContent['db_login']; |
---|
124 | $db->password = $configPhpFileContent['db_password']; |
---|
125 | $db->name = $configPhpFileContent['db_name']; |
---|
126 | $db->init(); |
---|
127 | |
---|
128 | if($db->isReady()) |
---|
129 | { |
---|
130 | $c =& PmvConfig::getInstance(); |
---|
131 | $c->update( $configPhpFileContent ); |
---|
132 | |
---|
133 | $c->write(); |
---|
134 | $c->defineAsConstant( $c->content ); |
---|
135 | $c->defineTables(); |
---|
136 | $db->createAllTables(); |
---|
137 | }*/ |
---|
138 | |
---|
139 | //$db->connect(); |
---|
140 | //$db->createAllTables(); |
---|
141 | } |
---|
142 | |
---|
143 | } |
---|
144 | |
---|
145 | |
---|
146 | function exec_phpmv(){ |
---|
147 | global $connect_statut; |
---|
148 | include_spip('inc/presentation'); |
---|
149 | |
---|
150 | if (_request('mod')!='view_graph'){ |
---|
151 | if ($connect_statut != '0minirezo') { |
---|
152 | debut_page(_L("PHPMyVisites"), "statistiques", "phpmv"); |
---|
153 | echo "<strong>"._T('avis_acces_interdit')."</strong>"; |
---|
154 | fin_page(); |
---|
155 | exit; |
---|
156 | } |
---|
157 | else{ |
---|
158 | // TODO : si pas les tampons dispo, afficher l'en tete direct |
---|
159 | // les redirect de phpmv s'afficheront avec un lien a cliquer |
---|
160 | $GLOBALS['spip_debut_page']=""; |
---|
161 | ob_start(); |
---|
162 | debut_page(_L("PHPMyVisites"), "statistiques", "phpmv"); |
---|
163 | $GLOBALS['spip_debut_page']=ob_get_contents(); |
---|
164 | ob_end_clean(); |
---|
165 | } |
---|
166 | } |
---|
167 | else if ($connect_statut != '0minirezo') { |
---|
168 | exit; |
---|
169 | } |
---|
170 | |
---|
171 | define('INCLUDE_PATH', '.'); |
---|
172 | |
---|
173 | verif_install(); |
---|
174 | |
---|
175 | if (!isset($GLOBALS['meta']['PHPMyVisites_no_admin_stat'])){ |
---|
176 | ecrire_meta('PHPMyVisites_no_admin_stat','non'); |
---|
177 | ecrire_metas(); |
---|
178 | } |
---|
179 | $PHPMyVisites_no_admin_stat = $GLOBALS['meta']['PHPMyVisites_no_admin_stat']; |
---|
180 | |
---|
181 | $cwd = getcwd(); |
---|
182 | chdir(_DIR_PLUGIN_PHPMV); |
---|
183 | |
---|
184 | define('PROFILING', false ); |
---|
185 | @set_time_limit(0); |
---|
186 | @error_reporting(E_ALL); |
---|
187 | |
---|
188 | if(PROFILING) |
---|
189 | xdebug_start_profiling(); |
---|
190 | |
---|
191 | require_once INCLUDE_PATH . '/core/include/PmvConfig.class.php'; |
---|
192 | require_once INCLUDE_PATH . '/core/include/ApplicationController.php'; |
---|
193 | |
---|
194 | ApplicationController::init(); |
---|
195 | |
---|
196 | if( Request::moduleIsNotAStrangeModule() ) |
---|
197 | printTime('EOF', true); |
---|
198 | |
---|
199 | if(PROFILING) |
---|
200 | xdebug_dump_function_profile(1); |
---|
201 | |
---|
202 | chdir($cwd); |
---|
203 | fin_page(); |
---|
204 | if ($PHPMyVisites_no_admin_stat != $GLOBALS['meta']['PHPMyVisites_no_admin_stat']){ |
---|
205 | ecrire_meta('PHPMyVisites_no_admin_stat',$GLOBALS['meta']['PHPMyVisites_no_admin_stat']); |
---|
206 | ecrire_metas(); |
---|
207 | } |
---|
208 | |
---|
209 | } |
---|
210 | |
---|
211 | ?> |
---|