- Timestamp:
- Sep 14, 2003, 12:33:59 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/install.php
r91 r94 35 35 'step1_user','step1_user_info','step1_pass','step1_pass_info', 36 36 'step1_database','step1_database_info','step1_prefix', 37 'step1_prefix_info','submit','infos_title' ); 37 'step1_prefix_info','submit','infos_title','step2_title', 38 'conf_general_webmaster','conf_general_webmaster_info', 39 'step2_pwd','step2_pwd_info','step2_pwd_conf', 40 'step2_pwd_conf_info','conf_general_mail', 41 'conf_general_mail_info','install_end_title', 42 'install_end_message'); 38 43 templatize_array( $tpl, 'lang', $handle ); 39 44 $vtp->setGlobalVar( $handle, 'language', $_GET['language'] ); … … 78 83 $file_content.= "\n\$prefix_table = '".$_POST['prefix_table']."';"; 79 84 $file_content.= "\n?>"; 80 // writting the configura iton file85 // writting the configuration file 81 86 if ( $fp = @fopen( '../include/mysql.inc.php', 'a+' ) ) 82 87 { … … 138 143 { 139 144 $vtp->addSession( $handle, 'step1' ); 145 140 146 // host 141 147 if ( !isset( $_POST['cfgHote'] ) ) 142 {143 148 $vtp->setVar( $handle, 'step1.f_host', 'localhost' ); 144 }145 149 else 146 {147 150 $vtp->setVar( $handle, 'step1.f_host', $_POST['cfgHote'] ); 148 }149 151 // user 150 152 $vtp->setVar( $handle, 'step1.f_user', $_POST['cfgUser'] ); … … 153 155 // prefix_table 154 156 if ( !isset( $_POST['prefix_table'] ) ) 155 {156 157 $vtp->setVar( $handle, 'step1.f_prefix_table', 'phpwebgallery_' ); 157 }158 158 else 159 {160 159 $vtp->setVar( $handle, 'step1.f_prefix_table', $_POST['prefix_table'] ); 161 } 162 160 163 161 $vtp->closeSession( $handle, 'step1' ); 164 162 } … … 167 165 else if ( $_GET['step'] == 2 ) 168 166 { 167 $errors = array(); 168 $infos = array(); 169 169 170 include( '../include/mysql.inc.php' ); 170 171 mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) … … 176 177 { 177 178 // tables creation, based on phpwebgallery_structure.sql 179 $sql_lines = file( './phpwebgallery_structure.sql' ); 180 $query = ''; 181 foreach ( $sql_lines as $sql_line ) { 182 $sql_line = trim( $sql_line ); 183 if ( preg_match( '/(^--|^$)/', $sql_line ) ) continue; 184 $query.= ' '.$sql_line; 185 // if we reached the end of query, we execute it and reinitialize the 186 // variable "query" 187 if ( preg_match( '/;$/', $sql_line ) ) 188 { 189 $query = trim( $query ); 190 $query = str_replace( 'phpwebgallery_', $prefix_table, $query ); 191 // we don't execute "DROP TABLE" queries 192 if ( !preg_match( '/^DROP TABLE/i', $query ) ) 193 mysql_query( $query ); 194 $query = ''; 195 } 196 } 178 197 } 179 198 180 199 if ( isset( $_POST['submit'] ) ) 181 200 { 182 $configuration = false; 183 $erreur = ""; 184 $nb_erreur = 0; 185 // le pseudo du webmaster ne doit pas 186 // 1. être vide 187 // 2. commencer ou se terminer par un espace 188 // 3. comporter les caractères ' ou " 189 // Notes sur le pseudo du webmaster : 190 // - lorsque l'on trouve plusieurs occurences 191 // consécutives du caractère espace, on réduit à une seule occurence 192 if ( $_POST['webmaster'] == "" ) 193 { 194 $erreur .= "<li>".$lang['step2_err_login1']."</li>"; 195 $nb_erreur++; 196 } 197 $webmaster = ereg_replace( "[ ]{2,}", " ", $_POST['webmaster'] ); 198 if ( ereg( "^.* $", $webmaster ) or ereg( "^ .*$", $webmaster) ) 199 { 200 $erreur .= "<li>".$lang['step2_err_login2']."</li>"; 201 $nb_erreur++; 202 } 203 if ( ereg( "'",$webmaster ) or ereg( "\"",$webmaster ) ) 204 { 205 $erreur .= "<li>".$lang['step2_err_login3']."</li>"; 206 $nb_erreur++; 207 } 208 // on vérifie que le password rentré correspond bien à la confirmation faite par l'utilisateur 201 // webmaster login must be 202 // 1. non empty 203 // 2. without characters ' or " 204 $webmaster = preg_replace( '/\s{2,}/', ' ', $_POST['webmaster'] ); 205 $webmaster = trim( $webmaster ); 206 if ( $webmaster == '' ) 207 array_push( $errors, $lang['step2_err_login1'] ); 208 if ( preg_match( '/[\'"]/', $webmaster ) ) 209 array_push( $errors, $lang['step2_err_login3'] ); 210 // the webmaster string must be the same as its confirmation 209 211 if ( $_POST['pwdWebmaster'] != $_POST['pwdWebmasterConf'] ) 210 { 211 $erreur .= "<li>".$lang['step2_err_pass']."</li>"; 212 $nb_erreur++; 213 } 214 // le mail doit être conforme à qqch du type : nom@serveur.com 215 if( !ereg("([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", $_POST['mail_webmaster'] ) ) 216 { 217 $erreur .= "<li>".$lang['step2_err_mail']."</li>"; 218 $nb_erreur++; 219 } 220 // on met à jour les paramètres de l'application dans le cas où il n'y aucune erreur 221 if ( $nb_erreur == 0 ) 222 { 223 mysql_query( "delete from PREFIX_TABLE"."config" ); 224 $query = "insert into PREFIX_TABLE"."config (webmaster,mail_webmaster) values ('$webmaster','".$_POST['mail_webmaster']."')"; 212 array_push( $errors, $lang['step2_err_pass'] ); 213 // mail address must have this format : name@server.com 214 $error_mail_address = validate_mail_address( $_POST['mail_webmaster'] ); 215 if ( $error_mail_address != '' ) 216 array_push( $errors, $error_mail_address ); 217 if ( $_POST['mail_webmaster'] == '' ) 218 array_push( $errors, $lang['reg_err_mail_address'] ); 219 220 // if no error found till here : insertion of data in tables 221 if ( count( $errors ) == 0 ) 222 { 223 $query = 'DELETE FROM '.$prefix_table.'config'; 224 mysql_query( $query ); 225 226 $query = 'INSERT INTO '.$prefix_table.'config'; 227 $query.= ' (webmaster,mail_webmaster) VALUES '; 228 $query.= " ('".$webmaster."','".$_POST['mail_webmaster']."')"; 229 $query.= ';'; 230 mysql_query( $query ); 231 232 $query = 'INSERT INTO '.$prefix_table.'sites'; 233 $query.= " (id,galleries_url) VALUES (1, './galleries/')"; 234 $query.= ';'; 235 mysql_query( $query ); 236 237 // webmaster admin user 238 $query = 'INSERT INTO '.$prefix_table.'users'; 239 $query.= ' (id,username,password,status,language) VALUES '; 240 $query.= "(1,'".$webmaster."','".md5( $_POST['pwdWebmaster'] )."'"; 241 $query.= ",'admin','".$_GET['language']."')"; 242 $query.= ';'; 225 243 mysql_query($query); 226 $query = "insert into PREFIX_TABLE"."sites values (1, './galleries/');"; 227 mysql_query($query); 228 $query = "insert into PREFIX_TABLE"."users (pseudo,password,status,language) values ('$webmaster','".md5( $pwdWebmaster )."','admin','".$_GET['language']."')"; 229 mysql_query($query); 230 mysql_query("insert into PREFIX_TABLE"."users (pseudo,password,status,language) values ('visiteur','".md5( "" )."','visiteur','".$_GET['language']."')"); 231 $configuration = true; 232 } 233 } 234 235 echo header_install(); 236 if ( $configuration ) 237 { 238 echo" 239 <table width=\"100%\"> 240 <tr> 241 <th>".$lang['install_end_title']."</th> 242 </tr> 243 <tr> 244 <td> </th> 245 </tr> 246 <tr> 247 <td>".$lang['install_end_message']."</td> 248 </tr> 249 </table>"; 250 } 251 else 252 { 253 if ( $nb_erreur > 0 ) 254 { 255 echo" 256 <table width=100%> 257 <tr> 258 <th>".$lang['install_message']."</th> 259 </tr> 260 <tr> 261 <td> </td> 262 </tr> 263 <tr> 264 <td>$erreur</td> 265 </tr> 266 <tr> 267 <td> </td> 268 </tr> 269 </table>"; 270 } 271 echo" 272 <form method=\"post\" action=\"install.php?step=2&language=".$_GET['language']."\"> 273 <table width=100%> 274 <tr> 275 <th colspan=\"3\">".$lang['step2_title']."</th> 276 </tr> 277 <tr> 278 <td colspan=\"3\"> </td> 279 </tr> 280 <tr> 281 <td>".$lang['conf_general_webmaster']."</td> 282 <td align=\"center\"><input type='text' name='webmaster' value=\"".$_POST['webmaster']."\"></td> 283 <td class=\"row2\">".$lang['conf_general_webmaster_info']."</td> 284 </tr> 285 <tr> 286 <td>".$lang['step2_pwd']."</td> 287 <td align=center><input type='password' name='pwdWebmaster' value=''></td> 288 <td class=\"row2\">".$lang['step2_pwd_info']."</td> 289 </tr> 290 <tr> 291 <td>".$lang['step2_pwd_conf']."</td> 292 <td align=center><input type='password' name='pwdWebmasterConf' value=''></td> 293 <td class=\"row2\">".$lang['step2_pwd_conf_info']."</td> 294 </tr> 295 <tr> 296 <td>".$lang['conf_general_mail']."</td> 297 <td align=center><input type='text' name='mail_webmaster' value=\"".$_POST['mail_webmaster']."\"></td> 298 <td class=\"row2\">".$lang['conf_general_mail_info']."</td> 299 </tr> 300 <tr> 301 <td colspan=\"3\"> </th> 302 </tr> 303 <tr> 304 <td colspan=3 align=center> 305 <input type='submit' name='submit' value='".$lang['submit']."'> 306 </td> 307 </tr> 308 </table> 309 </form>"; 310 } 311 echo footer_install(); 244 245 // guest user 246 $query = 'INSERT INTO '.$prefix_table.'users'; 247 $query.= '(id,username,password,status,language) VALUES '; 248 $query.= "(2,'guest','','guest','francais')"; 249 $query.= ';'; 250 mysql_query( $query ); 251 } 252 } 253 254 // errors display 255 if ( sizeof( $errors ) != 0 ) 256 { 257 $vtp->addSession( $handle, 'errors' ); 258 foreach ( $errors as $error ) { 259 $vtp->addSession( $handle, 'error' ); 260 $vtp->setVar( $handle, 'error.content', $error ); 261 $vtp->closeSession( $handle, 'error' ); 262 } 263 $vtp->closeSession( $handle, 'errors' ); 264 } 265 266 if ( !isset( $_POST['submit'] ) or sizeof( $errors ) > 0 ) 267 { 268 $vtp->addSession( $handle, 'step2' ); 269 $vtp->setVar( $handle, 'step2.f_webmaster', $_POST['webmaster'] ); 270 $vtp->setVar( $handle, 'step2.f_mail_webmaster', $_POST['mail_webmaster']); 271 $vtp->closeSession( $handle, 'step2' ); 272 } 273 274 // end of installation message 275 if ( isset( $_POST['submit'] ) and count( $errors ) == 0 ) 276 { 277 $vtp->addSession( $handle, 'install_end' ); 278 $vtp->closeSession( $handle, 'install_end' ); 279 } 312 280 } 313 281 //---------------------------------------------------- Step 0 : language choice -
trunk/template/default/admin/install.vtp
r91 r94 197 197 </form> 198 198 <!--/VTP_step1--> 199 200 <!--VTP_step2--> 201 <form method="post" action="install.php?step=2&language={#language}"> 202 <table width=100%> 203 <tr> 204 <th colspan="3">{#step2_title}</th> 205 </tr> 206 <tr> 207 <td colspan="3"> </td> 208 </tr> 209 <tr> 210 <td>{#conf_general_webmaster}</td> 211 <td align="center"><input type="text" name="webmaster" value="{#f_webmaster}" /></td> 212 <td class="row2">{#conf_general_webmaster_info}</td> 213 </tr> 214 <tr> 215 <td>{#step2_pwd}</td> 216 <td align="center"><input type="password" name="pwdWebmaster" value="" /></td> 217 <td class="row2">{#step2_pwd_info}</td> 218 </tr> 219 <tr> 220 <td>{#step2_pwd_conf}</td> 221 <td align="center"><input type="password" name="pwdWebmasterConf" value="" /></td> 222 <td class="row2">{#step2_pwd_conf_info}</td> 223 </tr> 224 <tr> 225 <td>{#conf_general_mail}</td> 226 <td align="center"><input type="text" name="mail_webmaster" value="{#f_mail_webmaster}" /></td> 227 <td class="row2">{#conf_general_mail_info}</td> 228 </tr> 229 <tr> 230 <td colspan="3"> </th> 231 </tr> 232 <tr> 233 <td colspan="3" align="center"> 234 <input type="submit" name="submit" value="{#submit}" /> 235 </td> 236 </tr> 237 </table> 238 </form> 239 <!--/VTP_step2--> 240 241 <!--VTP_install_end--> 242 <div class="infos_title">{#install_end_title}</div> 243 <div style="padding:5px;">{#install_end_message}</div> 244 <!--/VTP_install_end--> 245 199 246 </td> 200 247 </tr>
Note: See TracChangeset
for help on using the changeset viewer.