1<?php 2################################################# 3# 4# This file is part of VFront. 5# 6# VFront is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# any later version. 10# 11# VFront is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <http://www.gnu.org/licenses/>. 18# 19 20/** 21 * VFront Web Installer - Utility di installazione dell'applicazione VFront 22 * Caratteristiche richieste: PHP5.x , MySQL 5.x, php_mysqli 23 * Oppure: PHP5.x , Postgres 8.x, php_pgsql 24 * @package VFront 25 * @subpackage VFront_Web_Installer 26 * @author M.Marcello Verona 27 * @copyright 2007-2010 M.Marcello Verona 28 * @version 0.96 $Id: index.php 910 2010-12-23 14:39:14Z marciuz $ 29 * @license http://www.gnu.org/licenses/gpl.html GNU Public License 30 * 31 */ 32 33session_start(); 34 35 36// Impostazione della lingua 37if(isset($_GET['install_lang'])){ 38 39 $_SESSION['install_lang']=preg_replace("|[^a-z_]+|i",'',$_GET['install_lang']); 40} 41 42$locale = (isset($_SESSION['install_lang'])) ? $_SESSION['install_lang'] : 'en_US'; 43 44$locale_dir = '../locale'; 45 46$domain = 'messages'; 47 48$encoding='UTF-8'; 49 50// TEST GETTEXT 51if(!function_exists('_')){ 52 53 require_once('../plugins/phpgettext/gettext.inc.php'); 54 55 // gettext setup 56 if(!defined('LC_MESSAGES')){ 57 58 @putenv("LC_ALL=$locale"); 59 @putenv("LC_MESSAGES=$locale"); 60 } 61 62 T_setlocale(LC_MESSAGES, $locale); 63 64 // Set the text domain as 'messages' 65 bindtextdomain($domain, $locale_dir); 66 67 // bind_textdomain_codeset is supported only in PHP 4.2.0+ 68 if (function_exists('bind_textdomain_codeset')) 69 bind_textdomain_codeset($domain, $encoding); 70 71 textdomain($domain); 72} 73else{ 74 75 putenv("LANGUAGE=$locale"); 76 putenv("LC_ALL=$locale"); 77 setlocale(LC_ALL, $locale, "$locale.utf8"); 78 bindtextdomain($domain,$locale_dir); 79 textdomain($domain); 80} 81 82 83 84 85 86 87if(!isset($_GET['p'])){ 88 89 $_GET['p']='0'; 90} 91 92 93 94 95 96 97###################################################################### 98# 99# Procedura installazione 100# 101 102switch($_GET['p']){ 103 104 // Installation language select and license 105 case '0': step0(); break; 106 107 // system test 108 case '1': step1(); break; 109 110 // Form for conf file 111 case '2': step2(); break; 112 113 // SERVER ONLY: create conf file 114 case '2s': step2s(); break; 115 116 // DB connection 117 case '3': step3(); break; 118 119 // SERVER ONLY: DB creation 120 case '3s': step3s(); break; 121 122 // Form crea admin 123 case '4': step4(); break; 124 125 // SERVER ONLY: crea admin 126 case '4s': step4s(); break; 127 128 // SERVER ONLY: DB creation 129 case '5': step5(); break; 130 131 case 'panic': panic_page(); break; 132 133 134} 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160/** 161 * @desc Genera il codice HTML da mostrare a inizio installazione 162 * @return string HTML 163 */ 164function step0(){ 165 166 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 167<html> 168 <head><title>VFront Installer</title> 169 <style type=\"text/css\"> 170 @import \"install.css\"; 171 </style> 172 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\" ></script> 173 <script type=\"text/javascript\" src=\"install.js\" ></script> 174 </head> 175 <body>\n"; 176 177 178 echo "<h1>VFront Installer - Select Language</h1>\n"; 179 180 echo "<div class=\"margin_left\">Welcome to the installer VFront. This procedure will install and configure VFront on your server.</div>"; 181 182 183 $license=htmlspecialchars(join("",file("../license"))); 184 185 echo " 186 <form action=\"".$_SERVER['PHP_SELF']."\" method=\"get\" id=\"form1\"> 187 188 189 <div class=\"installbox\" id=\"ilanguage\"> 190 <h2>Select install language</h2> 191 192 <p> 193 <label for=\"lang\">Language</label> 194 <select name=\"install_lang\" id=\"lang\"> 195 <option value=\"en_US\" selected=\"selected\">English</option> 196 <option value=\"it_IT\" >Italiano</option> 197 </select> 198 </p> 199 200 <p> </p> 201 202 </div> <!-- END ilanguage --> 203 204 <div class=\"installbox\" id=\"ilicense\"> 205 <h2>License</h2> 206 207 <p> 208 <textarea cols=\"82\" rows=\"14\" id=\"license\">$license</textarea> 209 </p> 210 211 <p> 212 <input type=\"checkbox\" id=\"accept\" value=\"1\" /> 213 <label for=\"accept\" style=\"float:none\">Accept license</label> 214 </p> 215 216 </div> <!-- END ilicense --> 217 218 219 <p><input type=\"hidden\" name=\"install0\" value=\"1\" /> 220 <input type=\"hidden\" name=\"p\" value=\"1\" /> 221 <input type=\"button\" id=\"invia\" value=\" Next >>\" onclick=\"lic();\" /></p> 222 223 </form> 224 225 </body> 226 </html>"; 227 228 229} 230 231 232 233 234 235/** 236 * @desc Test del sistema 237 * @return string HTML 238 */ 239function step1(){ 240 241 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 242<html> 243 <head><title>"._('VFront installation')."</title> 244 <style type=\"text/css\"> 245 @import \"install.css\"; 246 </style> 247 248 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\" ></script> 249 </head> 250 <body>\n"; 251 252 253 echo "<h1>"._("VFront installation - System requirements")."</h1>\n"; 254 255 256 $cartella_writable=is_writable("../conf"); 257 258 $fatal=false; 259 $notice=false; 260 261 // prova a cambiare i diritti della directory conf: 262 if(!$cartella_writable && !@chmod('../conf',0777)){ 263 264 echo "<p class=\"install-err\">".sprintf(_("Please set the <em>conf</em> folder as writeable and %s"),"<a href=\"".$_SERVER['PHP_SELF']."?p=1\">"._('try again')."</a>")."</p>"; 265 266 $fatal=true; 267 } 268 else{ 269 echo "<p class=\"install-ok\">"._("The folder <em>conf</em> is writeable")."</p>"; 270 } 271 272 273 274 // controllo PHP 275 $php_version = (substr(phpversion(),0,1)=='5') ? 1:0; 276 277 if($php_version){ 278 279 $classe_php='install-ok'; 280 } 281 else{ 282 $fatal=true; 283 $classe_php='install-err'; 284 } 285 286 echo "<p class=\"$classe_php\">"._("PHP Version").": <strong>".phpversion()."</strong><br />\n"; 287 echo "<small>"._("VFront requires PHP version >= 5.x")."</small></p>\n"; 288 289 290 291 // ESTENSIONI PHP 292 $ext=get_loaded_extensions(); 293 294 // Check Apache Modules 295 if(function_exists('apache_get_modules')){ 296 297 $php_modules = (array) @apache_get_modules(); 298 $l_modrewrite=(in_array('mod_rewrite',$php_modules)) ? 1:0; 299 $class_alert['modrewrite']= ($l_modrewrite) ? 'install-ok' : 'install-alert'; 300 $alert_rewrite_na=''; 301 } 302 // caso CGI 303 else{ 304 305 $php_modules= array(); 306 $l_modrewrite='na'; 307 $class_alert['modrewrite']= 'install-na'; 308 $alert_rewrite_na=_('This information is not available, since it seems to be using PHP as CGI'); 309 } 310 311 $l_mysqli=(in_array('mysqli',$ext)) ? 1:0; 312 $l_mysql_old=(in_array('mysql',$ext)) ? 1:0; 313 $l_pgsql=(in_array('pgsql',$ext)) ? 1:0; 314 315 if(file_exists("../inc/vmsql.oracle.php")){ 316 $l_oci8=(in_array('oci8',$ext)) ? 1:0; 317 } 318 else{ 319 $l_oci8=false; 320 } 321 322 $l_sqlite3 =(in_array('sqlite3', $ext)) ? 1:0; 323 $l_sqlite2 =(in_array('SQLite', $ext)) ? 1:0; 324 325 326 // Check MySQL 327 if($l_mysqli || $l_mysql_old){ 328 329 $classe_mysqli='install-ok'; 330 $txt_mysqli=''; 331 332 // Alt Check for MySQL 333 if(!$l_mysqli){ 334 $classe_mysqli='install-alert'; 335 $txt_mysqli=_('VFront uses the library MySQLi, but may optionally use the old library Mysql. Try to load the new library MySQLi'); 336 } 337 } 338 else{ 339 340 $classe_mysqli='install-alert'; 341 342 } 343 344 345 346 // Check SQLite 347 if($l_sqlite2 || $l_sqlite3){ 348 349 $l_sqlite=1; 350 351 $classe_sqlite='install-ok'; 352 $txt_sqlite=''; 353 $version_sqlite='3.x'; 354 355 // Alt Check for SQLite 356 if(!$l_sqlite3){ 357 $classe_sqlite='install-alert'; 358 $txt_sqlite=_('VFront uses the library SQLite3, but may optionally use the old library SQLite. If is possible, install the new library SQLite3'); 359 $version_sqlite='2.x'; 360 } 361 } 362 else{ 363 364 $l_sqlite=0; 365 $classe_sqlite='install-alert'; 366 $version_sqlite=''; 367 $txt_sqlite=_("If you use this DB <b>the extension should be loaded</b>"); 368 369 } 370 371 372 $classe_pgsql = ($l_pgsql) ? 'install-ok':'install-alert'; 373 374 $classe_oci8 = ($l_oci8) ? "install-ok" : 'install-alert'; 375 376 if(!$l_mysqli && !$l_mysql_old && !$l_pgsql && !$l_oci8 && !$l_sqlite){ 377 378 $fatal=true; 379 } 380 381 382 383 384 echo "<p class=\"$classe_mysqli\">"._("MySQL extension (MySQL Improved):")."<br />\n"; 385 echo "<small>"._("VFront uses the Mysqli library to connect to MySQL. If you use this DB the <b>extension should be loaded</b>")." ".$txt_mysqli."</small></p>\n"; 386 387 echo "<p class=\"$classe_pgsql\">"._("Postgres extension:")."<br />\n"; 388 echo "<small>"._("If you use this DB <b>the extension should be loaded</b>")."</small></p>\n"; 389 390 391 if(file_exists("../inc/vmsql.oracle.php")){ 392 echo "<p class=\"$classe_oci8\">"._("Oracle extension:")."<br />\n"; 393 echo "<small>"._("If you use this DB <b>the extension should be loaded</b>")."</small></p>\n"; 394 } 395 396 echo "<p class=\"$classe_sqlite\">"._("SQlite extension:")." $version_sqlite<br />\n"; 397 echo "<small>".$txt_sqlite."</small></p>\n"; 398 399 400 $class_alert['gd']= (in_array('gd',$ext)) ? 'install-ok':'install-alert'; 401 402 echo "<p class=\"".$class_alert['gd']."\">"._("GD Library:")."<br />\n"; 403 echo "<small>"._("GD library is used by Vfront for the creation of statistics graphs")."</small></p>\n"; 404 405 406 echo "<p class=\"".$class_alert['modrewrite']."\">"._("Apache Module mod_rewrite:")."<br />\n"; 407 echo "<small>"._("VFront uses mod_rewite module")." $alert_rewrite_na</small></p>\n"; 408 409 410 /*$l_xsl=(in_array('xsl',$ext)) ? 1:0; 411 412 echo "<span class=\"grigio\">"._("XSL transformation:")."</span> <strong>$l_xsl</strong>\n"; 413 echo "<div class=\"piccolo\">".sprintf(_("If the module is not loaded, go to the %s menu and cancel the server-side XSLT CONVERSION"), 414 "<a href=\"variabili.php\">"._("variables")."</a>") 415 ."</div><br />\n"; 416 */ 417 418 419 /* 420 421 FROM 0.96beta3 PEAR is not required 422 423 $class_alert['pear']=(@include_once("PEAR.php")) ? "install-ok" : "install-alert"; 424 echo "<p class=\"".$class_alert['pear']."\">"._("PEAR includes:")."<br />\n"; 425 echo "<small>"._("PEAR is used in creating statistical graphs")."</small></p>\n"; 426 427 $class_alert['pear_img_graph_class']=(@include_once("Image/Graph.php")) ? "install-ok" : "install-alert"; 428 echo "<p class=\"".$class_alert['pear_img_graph_class']."\">"._("PEAR Image/Graph module include:")."<br />\n"; 429 echo "<small>"._("PEAR module used for creating graphs")."</small></p>\n"; 430 431 432 $class_alert['pear_img_canvas_class']=(@include_once("Image/Canvas.php")) ? "install-ok" : "install-alert"; 433 echo "<p class=\"".$class_alert['pear_img_canvas_class']."\">"._("PEAR Image/Canvas module include:")."<br />\n"; 434 echo "<small>"._("PEAR module used to create statisctical graphs (dependency Image / Graph.php)")."</small></p>\n"; 435 436 437 $class_alert['pear_img_color_class']=(@include_once("Image/Color.php")) ? "install-ok" : "install-alert"; 438 echo "<p class=\"".$class_alert['pear_img_color_class']."\">"._("PEAR Image/Color module include:")."<br />\n"; 439 echo "<small>"._("PEAR module used to create statisctical graphs (dependency Image / Graph.php)")."</small></p>\n"; 440 441 */ 442 443 444 445 446// CARTELLE SCRIVIBILI O NO ------------------------------------- 447 448 449 450 ########################################### 451 # 452 # OTHER HIDDEN TEST FOR THE CONFIGURATION 453 # 454 455 // test dir 456 if( is_writable('../files/tmp') && 457 is_writable('../files/html') && 458 is_writable('../files/db') && 459 is_writable('../files') && 460 is_writable('../files/docs') && 461 is_writable('../files/docsadmin') && 462 is_writable('../files/xsl_custom') 463 ){ 464 // ok 465 $class_alert['writable_files_dir']="install-ok"; 466 $txt_files_dir=_("Files folder writeable"); 467 } 468 else{ 469 $class_alert['writable_files_dir']="install-err"; 470 $fatal=true; 471 $txt_files_dir=sprintf(_('Please set the files folder as writeable and %s') 472 ,"<a href=\"".$_SERVER['PHP_SELF']."?p=1\">"._('try again')."</a>"); 473 } 474 475 echo "<p class=\"".$class_alert['writable_files_dir']."\">".$txt_files_dir."<br />\n"; 476 echo "<small>"._("The files folder and its subfolders must be writable by the Apache user.")."</small></p>\n"; 477 478 479 480 if(in_array('install-alert',$class_alert)) $notice=true; 481 482 483 484 485 486 487 488 489 // PRINT FEEDBACK 490 491 if(!$fatal){ 492 493 // crea un file conf/.testvfront 494 if($fp=@fopen("../conf/.testvfront",'w')){ 495 fwrite($fp, intval($notice),1); 496 fclose($fp); 497 } 498 499 if($notice){ 500 501 echo "<p>"._("Some VFront configuration settings are not optimal. However these do not prevent installation, you can always adjust them later")."</a> </p>\n"; 502 } 503 else{ 504 505 echo "<p>"._("All seems well configured")."</a> </p>\n"; 506 } 507 508 echo "<p style=\"font-size:1.4em;\" > <a href=\"?p=2\">"._("Next step")."</a> </p>\n"; 509 510 } 511 else{ 512 513 echo "<p>"._("There are some errors in configuration. These must be resolved to allow the installation to proceed")."</a> </p>\n"; 514 } 515 516 517 518 echo "</body>\n</html>\n"; 519} 520 521 522 523 524 525 526/** 527 * @desc Imposta tutti i parametri del file di connessione che viene generato 528 * @return string HTML 529 */ 530function step2(){ 531 532 533 534 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 535<html> 536 <head><title>"._('VFront installation')."</title> 537 <style type=\"text/css\"> 538 @import \"install.css\"; 539 </style> 540 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\" ></script> 541 <script type=\"text/javascript\" src=\"./install.js\" ></script> 542 <script type=\"text/javascript\" > 543 544 545 546 function ut(n){ 547 548 549 $('host').disabled= (n) ? true:false; 550 $('user').disabled= (n) ? true:false; 551 $('passw').disabled= (n) ? true:false; 552 $('port').disabled= (n) ? true:false; 553 554 } 555 556 557 </script> 558 </head> 559 <body>\n"; 560 561 562 echo "<h1>"._("VFront installation")." - ".sprintf(_("Step %d of %d"),1,3)."</h1>\n"; 563 564 565 // Oracle Test 566 if(file_exists("../inc/vmsql.oracle.php") && function_exists('oci_connect')){ 567 568 $add_oci_val="<option value=\"oracle\">Oracle</option>"; 569 } 570 else{ 571 $add_oci_val=''; 572 } 573 574 575 // Mysql test 576 $option_mysql_dis=(function_exists('mysqli_query') || function_exists('mysql_query')) 577 ? '' : 'disabled="disabled"'; 578 579 // Postgres test 580 $option_pgsql_dis=(function_exists('pg_query')) 581 ? '':'disabled="disabled"'; 582 583 // SQLite test 584 $option_sqlite_dis=(class_exists('SQLite3') || class_exists('SQLiteDatabase')) 585 ? '':'disabled="disabled"'; 586 587 588 589 ?> 590 591 592<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?p=2s" id="installform"> 593 594 595 <a name="DBregistrymethod"></a> 596 <div class="installbox" id="idbrules"> 597 598 <h2><?php echo _('VFront registry method');?></h2> 599 600 <div class="method-radio"> 601 <input type="radio" name="var[regmethod]" value="internal" id="regmethod_internal" checked="checked" /> 602 <label for="regmethod_internal"><?php echo _('Create a rules DB for VFront registry');?></label> 603 <span class="desc"><?php echo _('Classic method. This is the default method prior to version 0.96 and use a "frontend" schema (in Postgres) or another DB (in MySQL) for internal rules');?></span> 604 </div> 605 606 <div class="method-radio"> 607 <input type="radio" name="var[regmethod]" value="sqlite" id="regmethod_sqlite" <?php echo $option_sqlite_dis; ?>/> 608 <label for="regmethod_sqlite"><?php echo _('Use SQLite for VFront registry');?></label> 609 <span class="desc"><?php echo _('This is the alternative method since version 0.96. With this method VFront uses a database of internal rules, in a file .sqlite');?></span> 610 </div> 611 612 </div> 613 614 615 <a name="DBconnection"></a> 616 <div class="installbox" id="idb"> 617 618 <h2><?php echo _('DB connection');?></h2> 619 620 <p> 621 <label for="dbtype">DBType</label> 622 <select id="dbtype" name="var[dbtype]" > 623 <option value="mysql" selected="selected" <?php echo $option_mysql_dis;?>>MySQL</option> 624 <option value="postgres" <?php echo $option_pgsql_dis;?>>PostgreSQL</option> 625 <option value="sqlite" <?php echo $option_sqlite_dis;?>>SQLite</option> 626 <?php echo $add_oci_val;?> 627 </select> 628 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 629 <span class="desc" style="display:none"><?php echo _('Database type you want to use with VFront');?></span> 630 </p> 631 632 <div id="conn_mysql"> 633 634 635 <p> 636 <label for="dbhost1">DB host</label> 637 <input type="text" name="var[dbhost1]" id="dbhost1" value="localhost" /> 638 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 639 <span class="desc" style="display:none" ><?php echo _('Database host (default: localhost)');?></span> 640 </p> 641 642 <p> 643 <label for="dbport1">DB port</label> 644 <input type="text" name="var[dbport1]" id="dbport1" value="3306" /> 645 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 646 <span class="desc" style="display:none"><?php echo _('Database port (default: 3306)');?></span> 647 </p> 648 649 <p> 650 <label for="dbname1">DB-data name</label> 651 <input type="text" name="var[dbname1]" id="dbname1" value="" onblur="set_frontend_name(this.value)" /> 652 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 653 <span class="desc" style="display:none"><?php echo _('Name of the existing database on which you want to use VFront');?></span> 654 </p> 655 656 <p class="internal-frontend"> 657 <label for="dbfrontend1">DB-frontend name</label> 658 <input type="text" name="var[dbfrontend1]" id="dbfrontend1" value="" /> 659 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 660 <span class="desc" style="display:none"><?php echo _('Name of the database to be created for the rules of VFront');?></span> 661 </p> 662 663 <p> 664 <label for="dbuser1">DB user</label> 665 <input type="text" name="var[dbuser1]" id="dbuser1" value="" /> 666 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 667 <span class="desc" style="display:none"><?php echo _('Username to connect to database');?></span> 668 </p> 669 670 <p> 671 <label for="dbpassw1">DB password</label> 672 <input type="password" name="var[dbpassw1]" id="dbpassw1" value="" /> 673 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 674 <span class="desc" style="display:none"><?php echo _('Password to connect to database');?></span> 675 </p> 676 677 678 679 </div> 680 681 <div id="conn_postgres" style="display:none"> 682 <p> 683 <label for="dbhost2">DB host</label> 684 <input type="text" name="var[dbhost2]" id="dbhost2" value="localhost" /> 685 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 686 <span class="desc" style="display:none"><?php echo _('Database host (default: localhost)');?></span> 687 </p> 688 689 <p> 690 <label for="dbport2">DB port</label> 691 <input type="text" name="var[dbport2]" id="dbport2" value="5432" /> 692 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 693 <span class="desc" style="display:none"><?php echo _('Database port (default: 5432)');?></span> 694 </p> 695 696 <p> 697 <label for="dbname2">DB name</label> 698 <input type="text" name="var[dbname2]" id="dbname2" value="" /> 699 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 700 <span class="desc" style="display:none"><?php echo _('Name of the existing database on which you want to use VFront');?></span> 701 </p> 702 703 <p> 704 <label for="dbschema2">DB schema</label> 705 <input type="text" name="var[dbschema2]" id="dbschema2" value="public" /> 706 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 707 <span class="desc" style="display:none"><?php echo _('Name of the existing schema on which you want to use VFront');?></span> 708 </p> 709 710 <p class="internal-frontend"> 711 <label for="dbfrontend2">VFront Schema</label> 712 <input type="text" name="var[dbfrontend2]" id="dbfrontend2" value="frontend" /> 713 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 714 <span class="desc" style="display:none"><?php echo _('Name of the new schema for VFront rules');?></span> 715 </p> 716 717 <p> 718 <label for="dbuser2">DB user</label> 719 <input type="text" name="var[dbuser2]" id="dbuser2" value="" /> 720 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 721 <span class="desc" style="display:none"><?php echo _('Username to connect to database');?></span> 722 </p> 723 724 <p> 725 <label for="dbpassw2">DB password</label> 726 <input type="password" name="var[dbpassw2]" id="dbpassw2" value="" /> 727 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 728 <span class="desc" style="display:none"><?php echo _('Password to connect to database');?></span> 729 </p> 730 </div> 731 732 733 <div id="conn_oracle" style="display:none"> 734 <p> 735 <label for="dbhost3">DB host</label> 736 <input type="text" name="var[dbhost3]" id="dbhost3" value="localhost" /> 737 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 738 <span class="desc" style="display:none"><?php echo _('Database host (default: localhost)');?></span> 739 </p> 740 741 <p> 742 <label for="dbport3">DB port</label> 743 <input type="text" name="var[dbport3]" id="dbport3" value="" /> 744 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 745 <span class="desc" style="display:none"><?php echo _('Database port');?></span> 746 </p> 747 748 <p> 749 <label for="dbservice3">DB service</label> 750 <input type="text" name="var[dbservice3]" id="dbservice3" value="" /> 751 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 752 <span class="desc" style="display:none"><?php echo _('Name of the Oracle service on which you want to use VFront');?></span> 753 </p> 754 755 <p> 756 <label for="dbuser3">DB user</label> 757 <input type="text" name="var[dbuser3]" id="dbuser3" value="" /> 758 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 759 <span class="desc" style="display:none"><?php echo _('Username to connect to database');?></span> 760 </p> 761 762 <p> 763 <label for="dbpassw3">DB password</label> 764 <input type="password" name="var[dbpassw3]" id="dbpassw3" value="" /> 765 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 766 <span class="desc" style="display:none"><?php echo _('Password to connect to database');?></span> 767 </p> 768 769 <p class="internal-frontend"> 770 <label for="dbfrontend3">VFront table prefix</label> 771 <input type="text" name="var[dbfrontend3]" id="dbfrontend3" value="VF_" /> 772 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 773 <span class="desc" style="display:none"><?php echo _('Prefix for the VFront registry tables');?></span> 774 </p> 775 </div> 776 777 778 779 <div id="conn_sqlite" style="display:none"> 780 <p> 781 <label for="dbfilename4">SQLite file (*.db or *.sqlite) </label> 782 <input type="text" name="var[dbfilename4]" id="dbfilename4" value="" size="70"/> 783 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 784 <span class="desc" style="display:none"><?php echo _('SQlite database');?></span> 785 </p> 786 787 788 </div> 789 790 <p> 791 <input type="button" onclick="test_db_conn()" id="testdb" value="Test connection" /> <span id="testdb_feedback" > </span> 792 </p> 793 794 </div> <!-- END idb --> 795 <hr /> 796 797 798 799 800 <a name="Authentication"></a> 801 <div class="installbox" id="iauth"> 802 803 <h2><?php echo _('Authentication');?></h2> 804 805 <div id="authtype_box"> 806 807 <p> 808 <label for="dbhost1"><?php echo _('Authentication method');?></label> 809 <select id="authtype" name="var[authtype]" onchange="show_auth_div(this.value); show_ajax_help(this.value);"> 810 <option value="null" selected="selected">VFront Internal</option> 811 <option value="db">Data DB (on same server)</option> 812 <option value="db_ext">External DB</option> 813 <option value="ldap">LDAP/Active Directory</option> 814 <!--<option value="soap">Soap</option> 815 <option value="OpenID">OpenID</option>--> 816 </select> 817 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 818 <span class="desc" style="display:none"><?php echo _('For user management and authentication, VFront can use your database, or use external data sources such as another database or an LDAP server');?></span> 819 <span id="auth_null"> </span> 820 </p> 821 822 </div> 823 824 825 826 <div id="auth_ext_common" class="auth-box" style="display:none;"> 827 828 829 <div id="auth_db" class="auth-box" style="display:none;"> 830 <p> 831 <label for="authdb_dbname">Db name (on same server!)</label> 832 <span id="authdb_dbname_cont"><input type="text" name="var[authdb_dbname]" id="authdb_dbname" value="" /></span> 833 <span id="authdb_dbname_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 834 </p> 835 836 <p> 837 <label for="authdb_usertable">User table name</label> 838 <span id="authdb_usertable_cont"><input type="text" name="var[authdb_usertable]" id="authdb_usertable" value="" /></span> 839 <span id="authdb_usertable_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 840 </p> 841 842 843 </div> 844 845 <div id="auth_db_ext" class="auth-box" style="display:none;"> 846 847 <p> 848 <label for="authdb_ext_type">External DB type</label> 849 <select name="var[authdb_ext_type]" id="authdb_ext_type"> 850 <option value="mysql">MySQL</option> 851 <option value="postgres">PostgreSQL</option> 852 <option value="odbc">ODBC</option> 853 </select> 854 </p> 855 856 <p> 857 <label for="authdb_ext_host">External DB Host</label> 858 <input type="text" name="var[authdb_ext_host]" id="authdb_ext_host" value="" /> 859 </p> 860 861 <p> 862 <label for="authdb_ext_port">External DB Port</label> 863 <input type="text" name="var[authdb_ext_port]" id="authdb_ext_port" value="" /> 864 </p> 865 866 <p> 867 <label for="authdb_ext_user">External DB User</label> 868 <input type="text" name="var[authdb_ext_user]" id="authdb_ext_user" value="" /> 869 </p> 870 871 <p> 872 <label for="authdb_ext_passwd">External DB Password</label> 873 <input type="password" name="var[authdb_ext_passwd]" id="authdb_ext_passwd" value="" /> 874 </p> 875 876 <p> 877 <label for="authdb_ext_dbname">External DB Name</label> 878 <input type="text" name="var[authdb_ext_dbname]" id="authdb_ext_dbname" value="" /> 879 </p> 880 881 <p> 882 <label for="authdb_ext_table">External DB Table</label> 883 <input type="text" name="var[authdb_ext_table]" id="authdb_ext_table" value="" /> 884 </p> 885 886 <p> 887 <label for="authdb_ext_odbcdsn">ODBC DSN (only ODBC)</label> 888 <input type="text" name="var[authdb_ext_odbcdsn]" id="authdb_ext_odbcdsn" value="" /> 889 </p> 890 891 </div> 892 893 894 <?php 895 896 ############################# 897 # 898 # AUTH LDAP 899 900 ?> 901 902 <div id="auth_ldap" class="auth-box" style="display:none;"> 903 <p> 904 <label for="ldap_host">LDAP server</label> 905 <input type="text" name="var[ldap_host]" id="ldap_host" value="" /> 906 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 907 <span class="desc" style="display:none"><?php echo _('The domain name or IP address of your LDAP Server. For example: localhost');?></span> 908 </p> 909 910 <p> 911 <label for="ldap_port">LDAP port</label> 912 <input type="text" name="var[ldap_port]" id="ldap_port" value="389" /> 913 <img class="help-image" src="../img/info_small.gif" alt="help" onclick="$(this).next(0).toggle()" /> 914 <span class="desc" style="display:none"><?php echo _('Default').": 389";?></span> 915 </p> 916 917 <p> 918 <label for="ldap_basedn">LDAP base dn</label> 919 <input type="text" name="var[ldap_basedn]" id="ldap_basedn" value="" /> 920 921 922 </p> 923 924 <p> 925 <label for="ldap_anonymus_bind">LDAP Anonymus bind</label> 926 <input type="checkbox" id="ldap_anonymus_bind" value="1" name="var[ldap_anonymus_bind]" onclick="anon_bind()" /> 927 </p> 928 929 930 <p> 931 <label for="ldap_bind_user">LDAP User for bind</label> 932 <input type="text" id="ldap_bind_user" value="" name="var[ldap_bind_user]" /> 933 </p> 934 935 <p> 936 <label for="ldap_bind_passw">LDAP Password for bind</label> 937 <input type="password" id="ldap_bind_passw" value="" name="var[ldap_bind_passw]" /> 938 </p> 939 940 941 942 </div> 943 944 <!--<div id="auth_soap" class="auth-box" style="display:none;"> 945 auth_soap 946 </div> 947 948 <div id="auth_OpenID" class="auth-box" style="display:none;"> 949 auth_OpenID 950 </div>--> 951 952 <p id="authext_nick_p"> 953 <label for="authext_nick"><?php echo _('User nickname field (or email)');?></label> 954 <span id="authext_nick_cont"><input type="text" name="var[authext_nick]" id="authext_nick" value="" /></span> 955 <span id="authext_nick_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 956 </p> 957 958 <p id="authext_passwd_p"> 959 <label for="authext_passwd"><?php echo _('User password field');?></label> 960 <span id="authext_passwd_cont"><input type="text" name="var[authext_passwd]" id="authext_passwd" value="" /></span> 961 <span id="authext_passwd_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 962 </p> 963 964 <p id="authext_passwd_encode_p"> 965 <label for="authext_passwd_encode"><?php echo _('Password Type');?></label> 966 <select name="var[authext_passwd_encode]" id="authext_passwd_encode"> 967 <option value="" selected="selected">none</option> 968 <option value="md5">md5</option> 969 <option value="sha1">sha1</option> 970 </select> 971 </p> 972 973 <p id="authext_mail_p"> 974 <label for="authext_mail"><?php echo _('User email Field (optional)');?></label> 975 <span id="authext_mail_cont"><input type="text" name="var[authext_mail]" id="authext_mail" value="" /></span> 976 <span id="authext_mail_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 977 </p> 978 979 980 <p id="authext_name_p"> 981 <label for="authext_name"><?php echo _('User name Field (optional)');?></label> 982 <span id="authext_name_cont"><input type="text" name="var[authext_name]" id="authext_name" value="" /></span> 983 <span id="authext_name_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 984 </p> 985 986 987 <p id="authext_surname_p"> 988 <label for="authext_surname"><?php echo _('User surname Field (optional)');?></label> 989 <span id="authext_surname_cont"><input type="text" name="var[authext_surname]" id="authext_surname" value="" /></span> 990 <span id="authext_surname_wait" style="display:none"><img src="../img/refresh1.gif" alt="wait" /></span> 991 </p> 992 993 <p> 994 <input type="button" onclick="test_ext()" id="testext" value="<?php echo _('Test connection');?>" /> <span id="testext_feedback" > </span> 995 </p> 996 997 </div> 998 999 1000 1001 1002 1003 </div> <!-- END iauth --> 1004 1005 <hr /> 1006 1007 1008 <div class="installbox" id="imail"> 1009 1010 <h2>Mail & SMTP</h2> 1011 1012 <p> 1013 <label for="mail_sysamin">Administrator email</label> 1014 <input type="text" name="var[mail_sysamin]" id="mail_sysamin" value="<?php echo $_SERVER['SERVER_ADMIN'];?>" /> 1015 </p> 1016 1017 1018 <p> 1019 <label for="mail_dev">Developer email (optional)</label> 1020 <input type="text" name="var[mail_dev]" id="mail_dev" value="" /> 1021 </p> 1022 1023 <p> 1024 <label for="smtp_sender">Default sender</label> 1025 <input type="text" name="var[smtp_sender]" id="smtp_sender" value="<?php echo $_SERVER['SERVER_ADMIN'];?>" /> 1026 </p> 1027 1028 <p> 1029 <label for="smtp_sendername">Default sender displayed name</label> 1030 <input type="text" name="var[smtp_sendername]" id="smtp_sendername" value="VFront admin" /> 1031 </p> 1032 1033 1034 <p> 1035 <label for="smtp_use">Use SMTP</label> 1036 <select name="var[smtp_use]" id="smtp_use" onchange="display_smtp()" > 1037 <option value="false">No</option> 1038 <option value="true">Yes</option> 1039 </select> 1040 </p> 1041 1042 <div id="use_smtp" style="display:none" > 1043 1044 <p> 1045 <label for="smtp_address">SMTP address</label> 1046 <input type="text" name="var[smtp_address]" id="smtp_address" value="" /> 1047 </p> 1048 1049 <p> 1050 <label for="smtp_user">SMTP user</label> 1051 <input type="text" name="var[smtp_user]" id="smtp_user" value="" /> 1052 </p> 1053 1054 <p> 1055 <label for="smtp_passwd">SMTP password</label> 1056 <input type="password" name="var[smtp_passwd]" id="smtp_passwd" value="" /> 1057 </p> 1058 1059 </div> 1060 1061 </div> 1062 <!-- END idebug --> 1063 1064 <hr /> 1065 1066 <div class="installbox" id="idebug"> 1067 <h2>Debug</h2> 1068 1069 <p> 1070 <label for="debug_sql">Debug SQL</label> 1071 <select name="var[debug_sql]" id="debug_sql"> 1072 <option value="false" selected="selected">false</option> 1073 <option value="true">true</option> 1074 </select> 1075 </p> 1076 <!-- 1077 <p> 1078 <label for="rpc_debug">RPC Debug</label> 1079 <select name="var[rpc_debug]" id="rpc_debug"> 1080 <option value="false" selected="selected">false</option> 1081 <option value="true">true</option> 1082 </select> 1083 </p> 1084 --> 1085 1086 1087 </div> <!-- END idebug --> 1088 1089 1090 1091 <hr /> 1092 1093 <div class="installbox" id="ilang"> 1094 1095 <h2><?php echo _('Language and encoding');?></h2> 1096 1097 <p> 1098 <label for="lang"><?php echo _('Language');?></label> 1099 <select name="var[lang]" id="lang"> 1100 <?php 1101 1102 if ($handle = opendir('../locale')) { 1103 while (false !== ($dirr = readdir($handle))) { 1104 if(preg_match("|[a-z]{2}_[a-z]{2}|i",$dirr)){ 1105 1106 $sel = ($dirr=='en_US') ? " selected=\"selected\"" : ""; 1107 1108 echo "<option value=\"$dirr\"$sel>$dirr</option>\n"; 1109 } 1110 } 1111 1112 closedir($handle); 1113 } 1114 1115 ?> 1116 </select> 1117 </p> 1118 1119 <p> 1120 <label for="encoding"><?php echo _('Encoding');?></label> 1121 <select name="var[encoding]" id="encoding"> 1122 <option value="UTF-8" selected="selected">UTF-8</option> 1123 <option value="iso-8859-1">iso-8859-1</option> 1124 </select> 1125 </p> 1126 1127 </div> <!-- END ilang --> 1128 1129 1130 <hr /> 1131 1132 <div class="installbox" id="idatetime"> 1133 <h2><?php echo _('Date and time');?></h2> 1134 1135 <p> 1136 <label for="dateformat"><?php echo _('Date and time format');?></label> 1137 <select name="var[dateformat]" id="dateformat"> 1138 <option value="iso" selected="selected">ISO (ISO 8601), ex: 2009-01-15</option> 1139 <option value="ita">Latin/Europe (Italy, German, France, etc.), ex: 15/01/2009</option> 1140 <option value="eng">USA, ex: 01/15/2009</option> 1141 </select> 1142 </p> 1143 1144 </div> <!-- END idatetime --> 1145 1146 <hr /> 1147 1148 <div class="installbox" id="ipath"> 1149 1150 <h2><?php echo _('Paths');?></h2> 1151 1152 <?php 1153 1154 // Linux or windows ? 1155 $front_root0= (substr(realpath(__FILE__),0,1)=='/') ? __FILE__ : str_replace("\\","/",__FILE__) ; 1156 $front_root= str_replace("/_install/index.php","",$front_root0); 1157 1158 $doc_root="http://".$_SERVER['HTTP_HOST'].str_replace("/_install/index.php",'',$_SERVER['PHP_SELF']); 1159 1160 ?> 1161 1162 <p> 1163 <label for="front_root">VFront root (realpath)</label> 1164 <input type="text" name="var[front_root]" id="front_root" value="<?php echo $front_root;?>" size="50" /> 1165 </p> 1166 1167 <p> 1168 <label for="document_root">VFront document root (http...)</label> 1169 <input type="text" name="var[document_root]" id="document_root" value="<?php echo $doc_root;?>" size="50" /> 1170 </p> 1171 1172 <p id="sqlite-path" style="display:none;"> 1173 <label for="sqlite_path">VFront SQLite path</label> 1174 <input type="text" name="var[sqlite_path]" id="sqlite_path" value="<?php echo $front_root."/files/db/vfront.sqlite";?>" size="50" /> 1175 </p> 1176 1177 </div> <!-- END ipath --> 1178 1179 <hr /> 1180 1181 <?php 1182 1183 1184 // FOP settings: 1185 1186 if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){ 1187 $FOP_EXEC='fop.bat'; 1188 } 1189 else{ 1190 $FOP_EXEC='fop'; 1191 } 1192 1193 // passphrase 1194 $passph=implode("",array_rand(array_flip(range("a","z")),8)); 1195 1196 1197 ?> 1198 1199 <div class="installbox" id="ifop"> 1200 <h2>Apache FOP</h2> 1201 1202 <p> 1203 <label for="fop_enabled">FOP Enabled</label> 1204 <select name="var[fop_enabled]" id="fop_enabled"> 1205 <option value="false" selected="selected">false</option> 1206 <option value="true" >true</option> 1207 </select> 1208 </p> 1209 1210 <p> 1211 <label for="path_fop">path fop</label> 1212 <input type="text" name="var[path_fop]" id="path_fop" value="<?php // echo $front_root."/plugins/fop/".$FOP_EXEC;?>" size="50" /> 1213 </p> 1214 </div> <!-- END ifop --> 1215 1216 <hr /> 1217 1218 <div class="installbox" id="imisc"> 1219 <h2><?php echo _('Miscellaneous');?></h2> 1220 1221 <p> 1222 <label for="max_tempo_edit">Max tempo edit (default: 240 seconds)</label> 1223 <input type="text" name="var[max_tempo_edit]" id="max_tempo_edit" value="240" size="50" /> 1224 </p> 1225 1226 <p> 1227 <label for="passfrase">Passphrase for base64</label> 1228 <input type="text" name="var[passfrase]" id="passfrase" value="<?php echo $passph;?>" size="50" /> 1229 </p> 1230 1231 <p> 1232 <label for="name_proj">Name of project</label> 1233 <input type="text" name="var[name_proj]" id="name_proj" value="VFront" /> 1234 </p> 1235 1236 </div> <!-- END imisc --> 1237 1238 <p> 1239 <input type="hidden" name="file_connessione" value="" id="file_connessione" /> 1240 <input type="button" value="<< <?php echo _('Previous');?> " onclick="window.location='<?php echo $_SERVER['PHP_SELF'];?>'" id="back_button" /> 1241 <input type="button" value=" <?php echo _('Next');?> >>" onclick="check_installer()" id="submit_button" /> <span id="check_feed" > </span> 1242 </p> 1243 1244 1245 1246 1247 1248</form> 1249 1250 <?php 1251 1252 echo "</body>\n</html>"; 1253 1254 1255 exit; 1256 1257} 1258 1259 1260 1261function step2s(){ 1262 1263 // Create Conf FILE 1264 if(isset($_POST['file_connessione'])){ 1265 1266 $test_include=true; 1267 require_once("./create_conf.php"); 1268 1269 // If the registry is SQLITE based, go to 3s 1270 if($var['regmethod']=='sqlite' || $var['dbtype']=='sqlite'){ 1271 header("Location: ".$_SERVER['PHP_SELF']."?p=3s"); 1272 } 1273 // else go to DB creation 1274 else{ 1275 header("Location: ".$_SERVER['PHP_SELF']."?p=3"); 1276 } 1277 exit; 1278 1279 } 1280 else{ 1281 1282 header("Location: ".$_SERVER['PHP_SELF']."?p=2&error_in=2"); 1283 exit; 1284 } 1285} 1286 1287 1288 1289 1290 1291 1292 1293/** 1294 * @desc Definisci la connessione per generare il DB ed eventualmente crea il DB nel prossimo passo 1295 * @return string HTML 1296 */ 1297function step3(){ 1298 1299 include_once("../conf/conf.vfront.php"); 1300 include_once("./vfront.{$db1['dbtype']}.sql.php"); 1301 include_once("../plugins/highlight/highlight_sql.php"); 1302 1303 1304 1305 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 1306<html> 1307 <head><title>"._('VFront installation')."</title> 1308 <style type=\"text/css\"> 1309 @import \"install.css\"; 1310 </style> 1311 1312 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\"></script> 1313 <script type=\"text/javascript\"> 1314 1315 function ut(n){ 1316 $('host').disabled= (n) ? true:false; 1317 $('user').disabled= (n) ? true:false; 1318 $('passw').disabled= (n) ? true:false; 1319 $('port').disabled= (n) ? true:false; 1320 } 1321 1322 </script> 1323 1324 </head> 1325 <body>\n"; 1326 1327 echo "<h1>"._("VFront installation")." - "._("Step 2 of 3")."</h1>\n"; 1328 1329 // errori di connessione: 1330 1331 if(isset($_GET['err'])){ 1332 1333 switch ($_GET['err']){ 1334 1335 case 1: echo "<span style=\"color:red\"><b>"._("Warning! Procedure interrupted ")."</b>. "._("Open a connection for installation")."</span>\n"; 1336 break; 1337 1338 case 2: echo "<span style=\"color:red\">"._("Could not create tables with privileges for the following user")."</span>\n"; 1339 break; 1340 } 1341 } 1342 1343 1344 1345 1346 1347 echo "<div id=\"createdb\" >\n"; 1348 echo "<h2>"._("VFront DB install")."</h2>\n"; 1349 1350 if($db1['dbtype']=='mysql' || $db1['dbtype']=='postgres'){ 1351 1352 1353 echo "<p> 1354 "._("Tables will be inserted in the database specified in the CONF file")." <strong>".$db1['frontend']."</strong><br /> 1355 "._("Will try to create it if it does not exist (privileges required).")." 1356 </p> 1357 1358 <form action=\"".$_SERVER['PHP_SELF']."?p=3s\" method=\"post\" >\n"; 1359 1360 $PORTA = ($db1['dbtype']=='mysql') ? "3306" : "5432"; 1361 1362 $UT_DEFAULT =($db1['dbtype']=='mysql') ? "root" : "postgres"; 1363 1364 1365 // Mostra il box per la connessione del superutente se non e' root|postgres 1366 if($UT_DEFAULT!=$db1['user']){ 1367 1368 echo " 1369 <input type=\"hidden\" name=\"tipo_link\" id=\"tl1\" value=\"1\" /> 1370 1371 <p> 1372 "._("host").": <input type=\"text\" name=\"host\" id=\"host\" value=\"localhost\" /><br /> 1373 "._("user").": <input type=\"text\" name=\"user\" id=\"user\" value=\"$UT_DEFAULT\" /><br /> 1374 "._("password").": <input type=\"password\" name=\"passw\" id=\"passw\" value=\"\" /><br /> 1375 "._("port").": <input type=\"text\" name=\"port\" id=\"port\" value=\"$PORTA\" /><br /> 1376 </p> 1377 1378 "; 1379 1380 1381 echo " 1382 <p> 1383 <input type=\"radio\" name=\"grant_user\" id=\"g0\" value=\"1\" checked=\"checked\" /> "._("Assign permissions to user")." <b>".$db1['user']."</b> "._("on this DB (GRANT option required)")." <br /> 1384 <input type=\"radio\" name=\"grant_user\" id=\"g1\" value=\"0\" /> "._("Set privileges manually")."<br /> 1385 </p> 1386 "; 1387 } 1388 else{ 1389 1390 // manda un segnale per usare i dati della connessione 1391 echo "<input type=\"hidden\" name=\"user\" id=\"user\" value=\"USER_DEFAULT_CONF\" />\n"; 1392 } 1393 1394 1395 1396 1397 1398 1399 if($UT_DEFAULT!=$db1['user']){ 1400 1401 echo " 1402 <p>"._("If you do not have sufficient rights to perform an unattended installation,<br />if you want to install manually <br />or you simply want to see what the installation on your server is going to do,")."<br /> 1403 "._("open")." <span class=\"fakelink\" onclick=\"$('boxsql').toggle();\">"._("this box")."</span></p>\n"; 1404 1405 } 1406 else{ 1407 1408 echo " 1409 <p>"._("If you wish to install manually <br /> or simply want to see what the installation on your server is going to do,")."<br /> 1410 "._("open")." <span class=\"fakelink\" onclick=\"$('boxsql').toggle();\">"._("this box")."</span></p>\n"; 1411 1412 1413 } 1414 1415 } 1416 1417 else if ($db1['dbtype']=='oracle'){ 1418 1419 1420 echo "<p> 1421 "._("Tables will be inserted in the database specified in the CONF file")." <strong>".$db1['frontend']."</strong><br /> 1422 "._("Will try to create it if it does not exist (privileges required).")." 1423 </p>"; 1424 1425 1426 echo "<p>"._("If you wish to install manually <br /> or simply want to see what the installation on your server is going to do,")."<br /> 1427 "._("open")." <span class=\"fakelink\" onclick=\"$('boxsql').toggle();\">"._("this box")."</span></p>\n"; 1428 1429 1430 echo "<form action=\"".$_SERVER['PHP_SELF']."?install_db\" method=\"post\" >\n"; 1431 } 1432 1433 echo " 1434 1435 <p> 1436 <input type=\"submit\" name=\"Invia\" value=\" "._("Proceed")." \" /> 1437 <input type=\"button\" name=\"esci\" value=\" "._("Exit installation")." \" onclick=\"location.href='?esci'\"/> 1438 </p> 1439 1440 </form>\n"; 1441 1442 1443 echo "<div id=\"boxsql\" style=\"display:none\">\n"; 1444 echo "<code class=\"sql\">\n"; 1445 1446 $create_db = ($db1['dbtype']=='mysql') ? "CREATE DATABASE ".$db1['frontend'].";\n\n" : ''; 1447 1448 echo syntax_highlight(nl2br($create_db.implode(";\n",$SQL_DEFINITION)),"SQL"); 1449 echo "</code>\n"; 1450 echo "</div>\n"; 1451 1452 1453 1454 1455 1456 echo " 1457 </div> 1458 1459 </body> 1460 </html>"; 1461 1462 1463} 1464 1465 1466 1467 1468/** 1469 * @desc Step 3 on server 1470 * Copy the SQLite file or create the vfront schema using SQL templates 1471 * @return void 1472 */ 1473function step3s(){ 1474 1475 require_once("../conf/conf.vfront.php"); 1476 1477 $GLOBALS['db1']=$db1; 1478 1479 if(defined('USE_REG_SQLITE') && USE_REG_SQLITE){ 1480 1481 $feed_op=copy_sqlite(); 1482 $ty='sqlite'; 1483 1484 } 1485 else{ 1486 1487 $feed_op=crea_db_rules(); 1488 $ty='dbrules'; 1489 } 1490 1491 1492 1493 if($feed_op) 1494 header("Location: ".$_SERVER['PHP_SELF']."?p=4"); 1495 else 1496 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&errty=copy_$ty"); 1497 1498 exit; 1499 1500} 1501 1502 1503/** 1504 * @desc Copy the SQLite file in files/db 1505 * @global array $db1 1506 * @return bool 1507 */ 1508function copy_sqlite(){ 1509 1510 global $db1; 1511 1512 $v = (class_exists('SQLite3')) ? 3:2; 1513 1514 $test_copy=copy(FRONT_ROOT."/_install/sqlite/vfront{$v}.dist.sqlite", $db1['filename_reg']); 1515 1516 return $test_copy; 1517} 1518 1519 1520 1521/** 1522 * @desc Crea il DB e le tabelle 1523 * 1524 */ 1525function crea_db_rules(){ 1526 1527 global $db1; 1528 1529 $GLOBALS['DEBUG_SQL']=true; 1530 1531 1532 require_vmsql($db1['dbtype']); 1533 1534 if($db1['dbtype']=='oracle' || (isset($_POST['user']) && $_POST['user']==='USER_DEFAULT_CONF')){ 1535 1536 $vmsql = new vmsql(); 1537 $test_conn =$vmsql->connect($db1); 1538 1539 if(!$test_conn){ 1540 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&err=2&errty=no_db_conn"); 1541 exit; 1542 } 1543 1544 } 1545 else{ 1546 1547 if(!isset($db1['postgres_dbname'])){ 1548 $db1['postgres_dbname']=''; 1549 } 1550 1551 $db2=array("host"=>$_POST['host'], 1552 "user"=>$_POST['user'], 1553 "passw"=>$_POST['passw'], 1554 "dbname"=>$db1['dbname'], 1555 "port"=>$_POST['port'], 1556 "postgres_dbname"=>$db1['postgres_dbname'], 1557 "dbtype"=>$db1['dbtype'], 1558 "frontend"=>$db1['frontend'], 1559 "sep"=>$db1['sep'] 1560 ); 1561 1562 $vmsql = new vmsql(); 1563 $test_conn2=$vmsql->connect($db2); 1564 1565 if(!$test_conn2){ 1566 1567 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&err=2&errty=no_db_conn"); 1568 exit; 1569 } 1570 1571 } 1572 1573 1574 ########################################## 1575 // 1576 // testa la creazione di tabelle 1577 1578 // nome casuale 1579 $nome_tabella="a".substr(md5(time()),0,16); 1580 1581 $sql_test="CREATE TABLE $nome_tabella (test integer)"; 1582 1583 $q_test=$vmsql->query_try($sql_test,false); 1584 1585 if(!$q_test){ 1586 1587 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&errty=no_create_table"); 1588 exit; 1589 } 1590 else{ 1591 1592 // OK! 1593 $q_test2=$vmsql->query("DROP TABLE $nome_tabella"); 1594 1595 } 1596 1597 1598 1599 1600 1601 1602 if($db1['dbtype']=='mysql'){ 1603 1604 if(!is_file("./vfront.mysql.sql.php")){ 1605 1606 die(_("Could not read SQL data from original file. Procedure interrupted .")); 1607 } 1608 1609 require_once("./vfront.mysql.sql.php"); 1610 } 1611 else if($db1['dbtype']=='postgres'){ 1612 1613 if(!is_file("./vfront.postgres.sql.php")){ 1614 1615 die(_("Could not read SQL data from original file. Procedure interrupted .")); 1616 } 1617 1618 require_once("./vfront.postgres.sql.php"); 1619 } 1620 else if($db1['dbtype']=='oracle'){ 1621 1622 if(!is_file("./vfront.oracle.sql.php")){ 1623 1624 die(_("Could not read SQL data from original file. Procedure interrupted .")); 1625 } 1626 1627 require_once("./vfront.oracle.sql.php"); 1628 } 1629 1630 // crea il database 1631 if($db1['dbtype']=='mysql'){ 1632 $sql_creadb= "CREATE DATABASE IF NOT EXISTS ".$db1['frontend']; 1633 1634 $q0=@$vmsql->query($sql_creadb) or die("Impossibile creare il database {$db1['frontend']}"); 1635 1636 } 1637 elseif($db1['dbtype']=='postgres'){ 1638 1639 // Null 1640 } 1641 1642 1643 $errore=0; 1644 1645 for($i=0;$i<count($SQL_DEFINITION);$i++){ 1646 $q_creatabelle= $vmsql->query($SQL_DEFINITION[$i]); 1647 1648 if(!$q_creatabelle){ 1649 $xerr=$vmsql->error($SQL_DEFINITION[$i],_('Error in sql execution')); 1650 $vmsql->query("ROLLBACK"); 1651 die(sprintf("$xerr<br /> "._('Unable to create tables in database %s'),$db1['frontend'])); 1652 } 1653 1654 } 1655 1656 if($db1['dbtype']=='mysql'){ 1657 //$q_use0=$vmsql->query("USE ".$db1['dbname']) or die(_sprintf(_("Cannot use database %s with command USE",$db1['dbname']))); 1658 } 1659 1660 if(isset($_POST['grant_user']) && $_POST['grant_user']==1){ 1661 1662 $esito_grant=grant(false,$vmsql,$db1); 1663 } 1664 1665 1666 return true; 1667 1668 1669} 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686/** 1687 * @desc Funzione per la generazione della pagina di creazione primo utente 1688 * 1689 */ 1690function step4(){ 1691 1692 global $vmsql, $vmreg, $db1, $conf_auth; 1693 1694 1695 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 1696<html> 1697 <head><title>"._("VFront installation")."</title> 1698 <style type=\"text/css\"> 1699 @import \"install.css\"; 1700 </style> 1701 <script type=\"text/javascript\" src=\"../js/yav/yav.js\" ></script> 1702 <script type=\"text/javascript\" src=\"../js/yav/yav-config-it.js\" ></script> 1703 <script type=\"text/javascript\" > 1704 1705 var rules= new Array(); 1706 1707 rules[0]='email|required|"._("Email required")."'; 1708 rules[1]='passw1|minlength|6|"._("Password must be at least 6 characters")."'; 1709 rules[2]='passw1|equal|\$passw2|".addslashes(_("The two password don't match"))."'; 1710 rules[3]='nome|required|"._("Name required")."'; 1711 rules[4]='cognome|required|"._("Family name required")."'; 1712 1713 </script> 1714 </head> 1715 1716 <body>\n"; 1717 1718 echo "<h1>"._("VFront installation")." - "._("Step 3 of 3")."</h1>\n"; 1719 1720 1721 1722 // analizza se il login richiesto anche esternamente 1723 1724 if($conf_auth['tipo_external_auth']!=''){ 1725 1726 echo "<p>"._("Warning! Authentication is required through an external database0")." (" 1727 .$conf_auth['tipo_external_auth']."). "."<br /> 1728 ".sprintf(_("The first user access will be as administrator, then use your normal account for your first login."),$conf_auth['tipo_external_auth'])."</p>"; 1729 1730 echo "<p><a href=\"?p=5\">"._("Next step")."</a></p>\n"; 1731 } 1732 1733 else{ 1734 1735 echo "<form action=\"?p=4s\" method=\"post\" name=\"f1\" onsubmit=\"return performCheck('f1', rules,'classic');\"> 1736 1737 <div class=\"installbox\" id=\"iadmin\"> 1738 1739 <h2>"._("Creation of admin user")."</h2> 1740 1741 <p>"._("Now insert admin user data")."</p> 1742 1743 <p> 1744 <label for=\"email\">"._("Email").":</label><br /> 1745 <input type=\"text\" size=\"42\" value=\"\" name=\"email\" id=\"email\" /> 1746 </p> 1747 1748 <p> 1749 <label for=\"passw1\">"._("Password").":</label><br /> 1750 <input type=\"password\" size=\"42\" value=\"\" name=\"passw1\" id=\"passw1\" /> 1751 </p> 1752 1753 <p> 1754 <label for=\"passw2\">"._("Re-enter the password").":</label><br /> 1755 <input type=\"password\" size=\"42\" value=\"\" name=\"passw2\" id=\"passw2\" /> 1756 </p> 1757 1758 <p> 1759 <label for=\"nome\">"._("Name").":</label><br /> 1760 <input type=\"text\" size=\"42\" value=\"\" name=\"nome\" id=\"nome\" /> 1761 </p> 1762 1763 <p> 1764 <label for=\"cognome\">"._("Surname").":</label><br /> 1765 <input type=\"text\" size=\"42\" value=\"\" name=\"cognome\" id=\"cognome\" /> 1766 </p> 1767 1768 </div> 1769 1770 1771 <p> 1772 <input type=\"submit\" value=\" "._("Save data")."\" name=\"invia\" /> 1773 </p> 1774 1775 </form>\n"; 1776 1777 } 1778 1779 echo "</body>\n</html>\n"; 1780 1781 exit; 1782 1783} 1784 1785 1786 1787 1788 1789 1790 1791/** 1792 * @desc Funzione di creazione primo utente 1793 * 1794 */ 1795function step4s(){ 1796 1797 require_once("../conf/conf.vfront.php"); 1798 1799 $GLOBALS['db1']=$db1; 1800 $GLOBALS['DEBUG_SQL']=true; 1801 1802 1803 if(USE_REG_SQLITE){ 1804 1805 if(VERSION_REG_SQLITE==3){ 1806 require_once("../inc/vmsql.sqlite3.php"); 1807 $vmreg = new sqlite3_vmsql(); 1808 } 1809 else{ 1810 require_once("../inc/vmsql.sqlite2.php"); 1811 $vmreg = new sqlite2_vmsql(); 1812 } 1813 1814 1815 $test_conn =$vmreg->connect($db1['filename_reg']); 1816 1817 if(!$test_conn){ 1818 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&errty=no_insert_admin_sqlite"); 1819 exit; 1820 } 1821 1822 } 1823 else{ 1824 1825 if(isset($db1['dbsqlite_version'])){ 1826 $db_file_version=$db1['dbsqlite_version']; 1827 } 1828 else{ 1829 $db_file_version=''; 1830 } 1831 1832 require_vmsql($db1['dbtype'],$db_file_version); 1833 1834 $vmreg = new vmsql(); 1835 $test_conn =$vmreg->connect($db1); 1836 1837 } 1838 1839 $_dati=$vmreg->recursive_escape($_POST); 1840 1841 $sql=sprintf("INSERT INTO {$db1['frontend']}{$db1['sep']}utente 1842 (nick, passwd, email, livello, gid, data_ins, nome, cognome) VALUES 1843 ('%s', '%s','%s', %d, %d, '%s', '%s', '%s')", 1844 $_dati['email'], 1845 md5($_dati['passw1']), 1846 $_dati['email'], 1847 3, 1848 0, 1849 date("Y-m-d"), 1850 $_dati['nome'], 1851 $_dati['cognome'] 1852 ); 1853 1854 $q=$vmreg->query($sql); 1855 1856 if($vmreg->affected_rows($q)==1){ 1857 1858 // set Oracle theme? 1859 if(file_exists("../inc/vmsql.oracle.php") && $db1['dbtype']=='oracle'){ 1860 1861 $sql2="UPDATE variabili SET valore='oracle_edition' WHERE variabile='layout'"; 1862 $q=$vmreg->query($sql2); 1863 } 1864 1865 1866 header("Location: ".$_SERVER['PHP_SELF']."?p=5"); 1867 exit; 1868 } 1869 else{ 1870 header("Location: ".$_SERVER['PHP_SELF']."?p=panic&errty=no_user_admin"); 1871 exit; 1872 } 1873 1874} 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896/** 1897 * @desc Genera il codice HTML da mostrare a fine installazione 1898 * @param bool $esito 1899 * @return string HTML 1900 */ 1901function step5($esito=true){ 1902 1903 require_once("../conf/conf.vfront.php"); 1904 require_once("../inc/func.ppal.php"); 1905 1906 echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 1907<html> 1908 <head><title>"._('VFront installation')."</title> 1909 <style type=\"text/css\"> 1910 @import \"install.css\"; 1911 </style> 1912 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\" ></script> 1913 </head> 1914 <body>\n"; 1915 1916 if($esito){ 1917 1918 // prendi info: 1919 1920 1921 $INFO_TXT=""; 1922 $INFO_POST=''; 1923 1924 $auth_type= ($conf_auth['tipo_external_auth']=='') ? 'vfront': $conf_auth['tipo_external_auth'].".".$conf_auth['db_ext']['dbtype']; 1925 1926 /*$file_version 1927 $version=*/ 1928 1929 $reg_method=(USE_REG_SQLITE) ? "sqlite":"internal"; 1930 1931 $INFO_TXT.="Date: ".date("Y-m-d H:i")."<br />\n"; 1932 $INFO_TXT.="OS: ".PHP_OS."<br />\n"; 1933 $INFO_TXT.="DB Type: ".$db1['dbtype']."<br />\n"; 1934 $INFO_TXT.="Auth Type: ".$auth_type."<br />\n"; 1935 $INFO_TXT.="Language: ".FRONT_LANG."<br />\n"; 1936 $INFO_TXT.="Encoding: ".FRONT_ENCODING."<br />\n"; 1937 $INFO_TXT.="VFront Registry Method: ".$reg_method."<br />\n"; 1938 $INFO_TXT.="PHP Version: ".phpversion()."<br />\n"; 1939 1940 $INFO_POST.="os=".PHP_OS."&"; 1941 $INFO_POST.="d=".date("YmdHis")."&"; 1942 $INFO_POST.="db=".$db1['dbtype']."&"; 1943 $INFO_POST.="auth=".$auth_type."&"; 1944 $INFO_POST.="l=".FRONT_LANG."&"; 1945 $INFO_POST.="enc=".FRONT_ENCODING."&"; 1946 $INFO_POST.="meth=".$reg_method."&"; 1947 $INFO_POST.="v=".phpversion(); 1948 1949 1950 $START_dev=1187301600; 1951 $now_dev=time()-$START_dev; 1952 $gg_dev=round($now_dev/(3600*24)); 1953 1954 1955 echo "<h1>"._("Installation complete!")."</h1> 1956 1957 <div id=\"ifeedback\"> 1958 <h2>"._("Please send us feedback!")."</h2> 1959 <div id=\"pleasesend\"> 1960 <p>"._('Please help us to know the usage of VFront in the world :-)')."<br /> 1961 "._('You can send information by clicking on the link below.')."</p> 1962 1963 <div id=\"sendinfo\" ><code><strong>Info to send:</strong><br />------------------<br />$INFO_TXT</code></div> 1964 1965 <p><span class=\"fakelink\" onclick=\"window.open('http://www.vfront.org/getinfo.php?".addslashes($INFO_POST)."','infovfront','width=400,height=350,toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes'); $('pleasesend').hide();$('thankyou').show();\">"._("Send info!")."</span></p> 1966 </div> 1967 1968 <div id=\"thankyou\" style=\"display:none\"> 1969 1970 <p>"._('Thank you for the feedback!')."</p> 1971 </div> 1972 1973 </div> 1974 1975 1976 <div id=\"isupport\"> 1977 <h2>"._("Support us!")."</h2> 1978 <div id=\"isupport2\"> 1979 <p><strong>"._('The numbers behind VFront').":</strong></p> 1980 <ul id=\"isupport-ul\"> 1981 <li>".sprintf(_('%s code lines'),'~30.000')."</li> 1982 <li>".sprintf(_('%d days of development and maintenance'),$gg_dev)."</li> 1983 <li>".sprintf(_('%s pages of manuals and documentation'),'~200')."</li> 1984 <li>".sprintf(_('%d cups of coffee'),$gg_dev*3)."</li> 1985 </ul> 1986 1987 <p>"._('Do you want to offer me some coffee?')."</p> 1988 1989 </div> 1990 1991 "; 1992 1993 1994 1995 echo "<div id=\"support_form\" >".ppal()."</div>"; 1996 1997 echo " 1998 </div> 1999 2000 2001 <div id=\"ilogin\"> 2002 <h2>"._("Go to login")."</h2> 2003 <p>"._("Go to login page and enter your email and password you previously specfied.")."</p> 2004 <p><a href=\"../index.php\">"._('Go to login')."</a></p> 2005 </div>\n"; 2006 2007 } 2008 else{ 2009 2010 echo "<h1>"._("Error creating user!")."</h1> 2011 <p>"._("Try to create the user in the table <em>utente</em> manually, specifying level = 3 and group = 0")."</p> 2012 <p><a href=\"../index.php\">"._('Go to login')."</a></p>\n"; 2013 2014 } 2015 2016 echo "</body>\n</html>\n"; 2017} 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028/** 2029 * @desc Genera il codice HTML da mostrare a inizio installazione 2030 * @return string HTML 2031 */ 2032function panic_page(){ 2033 2034 if(file_exists("../conf/conf.vfront.php")){ 2035 require_once("../conf/conf.vfront.php"); 2036 } 2037 2038 $OUT= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> 2039<html> 2040 <head><title>VFront Installer</title> 2041 <style type=\"text/css\"> 2042 @import \"install.css\"; 2043 </style> 2044 <script type=\"text/javascript\" src=\"../js/scriptaculous/lib/prototype.js\" ></script> 2045 <script type=\"text/javascript\" src=\"install.js\" ></script> 2046 </head> 2047 <body>\n"; 2048 2049 2050 $OUT.= "<h1><span class=\"ko\">"._('Oh no!')."</span> "._('Something goes wrong...')."</h1>\n"; 2051 2052 2053 if(defined('FRONT_ERROR_LOG') && file_exists(FRONT_ERROR_LOG) && is_readable(FRONT_ERROR_LOG)){ 2054 2055 $ERROR_LOG = file_get_contents(FRONT_ERROR_LOG); 2056 2057 $ERROR_LOG_HTML="<div id=\"error_log\"><code>" 2058 .str_replace("\n", "<br /><br />\n",htmlentities($ERROR_LOG,ENT_QUOTES)) 2059 ."</code></div>\n"; 2060 } 2061 else{ 2062 $ERROR_LOG_HTML=''; 2063 } 2064 2065 2066 2067 if(!isset($_GET['errty'])) $_GET['errty']=''; 2068 2069 switch($_GET['errty']){ 2070 2071 case 'copy_sqlite': $msg="<p>"; 2072 $msg.=sprintf(_('There is a problem copying the SQLite file in %s.'), 2073 $db1['filename_reg']); 2074 $msg.="</p>\n<p>\n"; 2075 $msg.="<b>"._('Is the directory writable by apache user?')."</b></p>"; 2076 $msg.="<p>".sprintf(_("Try to change the directory permissions and %s go back to step 2 %s"), 2077 "<a href=\"?p=2\">","</a>"); 2078 $msg.="</p>"; 2079 break; 2080 2081 2082 case 'copy_dbrules': $msg="<p>"; 2083 $msg.=_('There is a problem creating the VFront schema/database.'); 2084 $msg.="</p>\n<p>\n"; 2085 $msg.="<b>"._('Is you DB connected? Have the user the correct permissions? Please see you error log:')."</b> "; 2086 $msg.="</p>"; 2087 $msg.=$ERROR_LOG_HTML; 2088 break; 2089 2090 case 'no_insert_admin_sqlite': 2091 $msg="<p>"; 2092 $msg.=_('There is a problem creating the admin user.'); 2093 $msg.="</p>\n<p>\n"; 2094 $msg.="<b>".sprintf(_('The SQLite file %s exists and is writable by apache user?'), 2095 $db1['filename_reg'])."</b></p>"; 2096 $msg.="<p>".sprintf(_("Try to change the directory permissions and %s go back to step 4 %s"), 2097 "<a href=\"?p=4\">","</a>"); 2098 $msg.="</p>"; 2099 break; 2100 2101 2102 case 'no_db_conn': $msg="<p>"; 2103 $msg.=sprintf(_('There is a problem connecting to %s.'), $db1['frontend']); 2104 $msg.="</p>\n<p>\n"; 2105 $msg.=sprintf(_("Please check your DB connection in %s step 1 %s"), 2106 "<a href=\"?p=1\">","</a>"); 2107 $msg.="</p>"; 2108 break; 2109 2110 case 'no_create_table':$msg="<p>"; 2111 $msg.=_('There is a problem creating the VFront tables.'); 2112 $msg.="</p>\n<p>\n"; 2113 $msg.="<b>"._('Is you DB connected? Have the user the CREATE permission?')."<br />"; 2114 $msg.=_('Please see you error log:')."</b> "; 2115 $msg.="</p>"; 2116 $msg.=$ERROR_LOG_HTML; 2117 break; 2118 2119 2120 case 'no_user_admin':$msg="<p>"; 2121 $msg.=_('There is a problem creating the admin user.'); 2122 $msg.="</p>\n<p>\n"; 2123 $msg.="<b>"._('Please see you error log:')."</b> "; 2124 $msg.="</p>"; 2125 $msg.=$ERROR_LOG_HTML; 2126 break; 2127 2128 default: $msg="<p>"._('Unknow error')."</p>\n"; 2129 $msg.=$ERROR_LOG_HTML; 2130 2131 } 2132 2133 $OUT.=$msg; 2134 2135 2136 2137 $OUT.= " 2138 </body> 2139 </html>"; 2140 2141 print $OUT; 2142 2143 exit; 2144} 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169function require_vmsql($dbtype,$dbsqlite_version=''){ 2170 2171 if(file_exists("../inc/vmsql.".$dbtype.$dbsqlite_version.".php")){ 2172 require_once("../inc/vmsql.".$dbtype.$dbsqlite_version.".php"); 2173 } 2174 else{ 2175 die("Errore su ".__LINE__); 2176 } 2177 2178 // Alias Class for DB connection 2179 2180 if (!function_exists('class_alias')) { 2181 function class_alias($original, $alias) { 2182 eval('class ' . $alias . ' extends ' . $original . ' {}'); 2183 } 2184 } 2185 2186 if($dbtype=='mysql' && class_exists('mysqli_vmsql')){ 2187 $cname='mysqli_vmsql'; 2188 } 2189 else if($dbtype=='mysql' && class_exists('mysql_vmsql')){ 2190 $cname='mysql_vmsql'; 2191 } 2192 else if($dbtype=='sqlite'){ 2193 2194 $cname=($dbsqlite_version=='3') ? 'sqlite3_vmsql' : 'sqlite2_vmsql'; 2195 } 2196 else{ 2197 $cname=$dbtype."_vmsql"; 2198 } 2199 2200 if(!class_exists('vmsql')) $make_alias1 = class_alias($cname, 'vmsql'); 2201 if(!class_exists('vmreg')) $make_alias2 = class_alias($cname, 'vmreg'); 2202} 2203 2204 2205 2206/** 2207 * Funzione di test per la generazione di una tabella. 2208 * Serve a testare il diritto CREATE, mediante la creazione di una tabella di nome pseudocasuale 2209 * 2210 * @return bool 2211 */ 2212function test_crea_tabella(){ 2213 2214 global $vmsql, $db1; 2215 2216 // nome casuale 2217 $nome_tabella="a".substr(md5(time()),0,16); 2218 2219 $sql_test="CREATE TABLE $nome_tabella (test integer)"; 2220 2221 $q_test=$vmsql->query_try($sql_test,false); 2222 2223 if(!$q_test){ 2224 2225 return false; 2226 } 2227 else{ 2228 $q_test2=$vmsql->query("DROP TABLE $nome_tabella"); 2229 return true; 2230 } 2231 2232} 2233 2234 2235 2236 2237 2238/** 2239 * @desc Esegue i GRANT necessari per il nuovo utente 2240 * @param bool $return_only_sql 2241 * @return int 2242 */ 2243function grant($return_only_sql, $vmsql, $db1){ 2244 2245 $sql=array(); 2246 2247 2248 if($db1['dbtype']=='mysql'){ 2249 2250 //$sql_user= "CREATE USER {$db1['user']}@{$db1['host']} IDENTIFIED BY '{$db1['passw']}'; "; 2251 2252 $sql[]="GRANT SELECT, INSERT, UPDATE, DELETE ON {$db1['frontend']}{$db1['sep']}* TO " 2253 ."'{$db1['user']}'@{$db1['host']} IDENTIFIED BY '{$db1['passw']}'"; 2254 2255 //$sql[]= "GRANT SELECT, INSERT, UPDATE, DELETE, SHOW VIEW ON {$db1['dbname']}.* TO '{$db1['user']}'@{$db1['host']} IDENTIFIED BY '{$db1['passw']}';"; 2256 } 2257 else if ($db1['dbtype']=='postgres'){ 2258 2259 2260 // crea l'utente 2261 //$sql_user= "CREATE USER {$db1['user']} WITH PASSWORD '{$db1['passw']}'; "; 2262 2263 $sql=array(); 2264 2265 // diritto d'uso dello schema frontend 2266 $sql[]="GRANT USAGE ON SCHEMA {$db1['frontend']} TO {$db1['user']};"; 2267 2268 // diritto d'uso dello schema information_schema 2269 $sql[]="GRANT USAGE ON SCHEMA information_schema TO {$db1['user']};"; 2270 2271 // diritto d'uso dello schema pg_catalog 2272 $sql[]="GRANT USAGE ON SCHEMA pg_catalog TO {$db1['user']};"; 2273 2274 // prendi le tabelle dei due schemi 2275 $q_tab=$vmsql->query("SELECT table_schema || '.' || '\"' || table_name || '\"' FROM information_schema.tables WHERE table_schema IN ('{$db1['dbname']}','{$db1['frontend']}')"); 2276 2277 while($RS_tab=pg_fetch_row($q_tab)){ 2278 2279 $sql[]="GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON ".$RS_tab[0]." TO {$db1['user']};"; 2280 } 2281 2282 // prendi le tabelle dell'information_schema 2283 $q_tab=$vmsql->query("SELECT table_schema || '.' || '\"' || table_name || '\"' FROM information_schema.tables WHERE table_schema='information_schema'; "); 2284 2285 while($RS_tab=pg_fetch_row($q_tab)){ 2286 2287 $sql[]="GRANT SELECT ON ".$RS_tab[0]." TO {$db1['user']};"; 2288 } 2289 2290 // prendi le funzioni dei due schemi 2291 $q_func=$vmsql->query("select 'GRANT EXECUTE ON FUNCTION '||n.nspname||'.'||p.proname||'('||oidvectortypes(p.proargtypes)||') TO {$db1['user']};' from pg_proc p, pg_namespace n where n.oid = p.pronamespace and n.nspname IN ('{$db1['dbname']}','{$db1['frontend']}');"); 2292 2293 while($RS_func=$vmsql->fetch_row($q_func)){ 2294 2295 $sql[]=$RS_func[0]; 2296 } 2297 2298 // prendi le sequenze dei due schemi 2299 $q_seq=$vmsql->query("select 'GRANT ALL ON '||n.nspname||'.'||c.relname||' TO {$db1['user']};' from pg_class c, pg_namespace n where n.oid = c.relnamespace and c.relkind IN ('S') and n.nspname in ('{$db1['dbname']}','{$db1['frontend']}');"); 2300 2301 while($RS_seq=$vmsql->fetch_row($q_seq)){ 2302 2303 $sql[]=$RS_seq[0]; 2304 } 2305 } 2306 2307 if($return_only_sql){ 2308 2309 return $sql_user."\n".implode("\n",$sql); 2310 } 2311 2312 //$q_user=$vmsql->query_try($sql_user,false); 2313 2314 for($i=0;$i<count($sql);$i++){ 2315 2316 $q=$vmsql->query($sql[$i]) or die($vmsql->error()); 2317 } 2318 2319 $aff_rows=$vmsql->affected_rows($q); 2320 2321 if($db1['dbtype']=='mysql') $q_flush=$vmsql->query("FLUSH PRIVILEGES"); 2322 2323 return $aff_rows; 2324} 2325 2326 2327 2328 2329 2330function get_sqlite_file_version($path_sqlite){ 2331 2332 if(!file_exists($path_sqlite)) return false; 2333 2334 $test=0; 2335 2336 if(class_exists('SQLite3')){ 2337 2338 $mylink= new SQLite3($path_sqlite,SQLITE3_OPEN_READONLY); 2339 $test=$mylink->exec("SELECT 1 from sqlite_master"); 2340 2341 if($test) return 3; 2342 } 2343 2344 if($test==0 || class_exists('SQLiteDatabase')){ 2345 2346 $mylink= new SQLiteDatabase($path_sqlite); 2347 $test=$mylink->queryExec("SELECT 1 from sqlite_master"); 2348 2349 if($test) return 2; 2350 } 2351 2352 return 0; 2353}