root/trunk/wifidog-auth/wifidog/install.php @ 1294

Revision 1294, 51.9 KB (checked in by benoitg, 6 years ago)
  • SmartyWifidog?: If ANY of the mandatory dependencies (not just smarty) are missing, user will be redirected to the install script
  • Move Smarty detection and install to common framework. Take this opportunity to move to upgrade to latest Smarty since people will have to re-run the install script anyway.
  • Fix #381 by applying patch from leandro@…, mea-culpa, I didn't know I broke the install script.


  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3
4/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5
6// +-------------------------------------------------------------------+
7// | WiFiDog Authentication Server                                     |
8// | =============================                                     |
9// |                                                                   |
10// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
11// | portal suite.                                                     |
12// +-------------------------------------------------------------------+
13// | PHP version 5 required.                                           |
14// +-------------------------------------------------------------------+
15// | Homepage:     http://www.wifidog.org/                             |
16// | Source Forge: http://sourceforge.net/projects/wifidog/            |
17// +-------------------------------------------------------------------+
18// | This program is free software; you can redistribute it and/or     |
19// | modify it under the terms of the GNU General Public License as    |
20// | published by the Free Software Foundation; either version 2 of    |
21// | the License, or (at your option) any later version.               |
22// |                                                                   |
23// | This program is distributed in the hope that it will be useful,   |
24// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
25// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
26// | GNU General Public License for more details.                      |
27// |                                                                   |
28// | You should have received a copy of the GNU General Public License |
29// | along with this program; if not, contact:                         |
30// |                                                                   |
31// | Free Software Foundation           Voice:  +1-617-542-5942        |
32// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
33// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
34// |                                                                   |
35// +-------------------------------------------------------------------+
36
37/**
38 * WiFiDog Authentication Server installation and configuration script
39 *
40 * @package    WiFiDogAuthServer
41 * @author     Pascal Leclerc <isf@plec.ca>
42 * @copyright  2005-2006 Pascal Leclerc
43 * @version    Subversion $Id$
44 * @link       http://www.wifidog.org/
45 */
46
47/**
48 * Load required files
49 */
50require_once ('include/path_defines_base.php');
51empty ($_REQUEST['page']) ? $page = 'Welcome' : $page = $_REQUEST['page']; # The page to be loaded
52empty ($_REQUEST['action']) ? $action = '' : $action = $_REQUEST['action']; # The action to be done (in page)
53empty ($_REQUEST['debug']) ? $debug = 0 : $debug = $_REQUEST['debug']; # Use for MySQL debugging
54empty ($_REQUEST['config']) ? $config = '' : $config = $_REQUEST['config']; # Store data to be saved in config.php
55
56# Security : Minimal access validation is use by asking user to retreive a random password in a local file. This prevent remote user to access unprotected installation script. It's dummy, easy to implement and better than nothing.
57
58# Random password generator
59$password_file = '/tmp/dog_cookie.txt';
60$random_password = null;
61if (!file_exists($password_file)) {
62    srand(date("s"));
63    $possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
64    $password = "";
65    while (strlen($random_password) < 8) {
66        $random_password .= substr($possible_charactors, rand() % (strlen($possible_charactors)), 1);
67    }
68    $fd = fopen($password_file, 'w');
69    fwrite($fd, $random_password."\n");
70    fclose($fd);
71}
72
73# Read password file
74$fd = fopen($password_file, "rb");
75$password = trim(fread($fd, filesize($password_file)));
76fclose($fd);
77
78$auth = false;
79
80if ($page != 'Welcome') {
81    if (isset ($_SERVER['PHP_AUTH_PW'])) {
82        #echo "PHP_AUTH_USER=(" . $_SERVER['PHP_AUTH_USER'] . ") PHP_AUTH_PW=(" . $_SERVER['PHP_AUTH_PW'] . ")"; # DEBUG
83        if ($password == $_SERVER['PHP_AUTH_PW'])
84        $auth = true;
85    }
86}
87else
88$auth = true;
89
90if (!$auth) { # Ask user for the passorwd
91    header('WWW-Authenticate: Basic realm="Private"');
92    header('HTTP/1.0 401 Unauthorized');
93    echo "Authorization Required !";
94    exit;
95}
96# End of Security validation
97
98print<<<EndHTML
99<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
100<HTML>
101<HEAD>
102  <TITLE>$page - Wifidog Auth-server configuration</TITLE>
103
104  <SCRIPT type="text/javascript">
105    // This function add new configuration value to the "config" hidden input
106    // On submit, config will be parsed and value saved to config.php file
107    function newConfig(dataAdd) {
108      // TODO : Validate input data
109      if (document.myform.config.value == '') {
110        document.myform.config.value = dataAdd;
111      }
112      else {
113        document.myform.config.value = document.myform.config.value + '|' + dataAdd;
114      }
115      //alert(document.myform.config.value);  // DEBUG
116    }
117  </SCRIPT>
118
119</HEAD>
120<BODY text="black" bgcolor="#CFCFCF">
121
122<style type="text/css">
123<!--
124.button
125{
126  font-size: 12pt;
127  font-weight: bold;
128  color: black;
129  background: #D4D0C8;
130  text-decoration: none;
131  border-top: 1px solid white;
132  border-right: 2px solid gray;
133  border-bottom: 2px solid gray;
134  border-left: 1px solid white;
135  padding: 3px 5px 3px 5px;
136}
137
138body
139{
140  background-color: white;
141}
142
143td
144{
145  padding: 1px 4px 1px 4px;
146}
147-->
148</style>
149
150<FORM NAME="myform" METHOD="post">
151<INPUT TYPE="HIDDEN" NAME="action">
152<INPUT TYPE="HIDDEN" NAME="debug">
153<INPUT TYPE="HIDDEN" NAME="config">
154
155EndHTML;
156
157//print "<pre>";      # DEBUG
158//print_r($_SERVER);  # DEBUG
159//print_r($_REQUEST); # DEBUG
160//print "</pre>";     # DEBUG
161#exit();
162
163# Needed files/directories with write access
164$dir_array = array (
165'tmp',
166'tmp/simplepie_cache',
167'lib/',
168'tmp/smarty/templates_c',
169'tmp/smarty/cache',
170'tmp/openidserver',
171'lib/simplepie',
172'lib/feedpressreview',
173'config.php'
174    );
175
176$smarty_full_url = 'http://smarty.php.net/do_download.php?download_file=Smarty-2.6.14.tar.gz';
177
178$neededPackages = array (
179'smarty' => array (
180'needed' => 1,
181'available' => 0,
182'message' => '',
183'file' => 'lib/smarty/Smarty.class.php'
184        ),
185'simplepie' => array (
186'needed' => 0,
187'available' => 0,
188'message' => '',
189'file' => 'lib/simplepie/simplepie.inc',
190'svn_source' => 'http://svn.simplepie.org/simplepie/branches/1.0/'
191        ),
192'feedpressreview' => array (
193'needed' => 0,
194'available' => 0,
195'message' => '',
196'file' => 'lib/feedpressreview/FeedPressReview.inc',
197'svn_source' => 'http://projects.coeus.ca/svn/feedpressreview/trunk/'
198        )
199);
200
201$optionsInfo = array (
202/* TODO:  SSL is now configured in the DB, but should still be handled by the install script
203 'SSL_AVAILABLE' => array (
204 'title' => 'SSL Support',
205 'depend' => 'return 1;',
206 'message' => '&nbsp;'
207 ),
208 */
209'CONF_USE_CRON_FOR_DB_CLEANUP' => array (
210'title' => 'Use cron for DB cleanup',
211'depend' => 'return 1;',
212'message' => '&nbsp;'
213        ),
214'GMAPS_HOTSPOTS_MAP_ENABLED' => array (
215'title' => 'Google Maps Support',
216'depend' => 'return 1;',
217'message' => '&nbsp;'
218        )
219);
220
221foreach ($neededPackages as $key => $value) { # Detect installed libraries (smarty, ...)
222    if (file_exists(WIFIDOG_ABS_FILE_PATH . $neededPackages[$key]['file']))
223    $neededPackages[$key]['available'] = 1;
224}
225
226$CONFIG_FILE = 'config.php';
227$LOCAL_CONFIG_FILE = 'local.config.php';
228
229if (!empty ($config)) # If not empty, save javascript 'config' variable to config.php file
230saveConfig($config);
231
232### Read Configuration file. Keys and Values => define('FOO', 'BRAK');
233# Use config.php if local.config.php does not exist
234//if(!file_exists(WIFIDOG_ABS_FILE_PATH."$LOCAL_CONFIG_FILE"))
235$contentArray = file(WIFIDOG_ABS_FILE_PATH . "$CONFIG_FILE");
236//else
237//  $contentArray = file(WIFIDOG_ABS_FILE_PATH."$LOCAL_CONFIG_FILE");
238
239$configArray = array ();
240
241foreach ($contentArray as $line) {
242    #print "$line<BR>"; # Debug
243    if (preg_match("/^define\((.+)\);/", $line, $matchesArray)) {
244        //echo '<pre>';print_r($matchesArray);echo '</pre>';
245        list ($key, $value) = explode(',', $matchesArray[1]);
246        $pattern = array (
247        "/^'/",
248        "/'$/"
249        );
250        $replacement = array (
251        '',
252        ''
253            );
254        $key = preg_replace($pattern, $replacement, trim($key));
255        $value = preg_replace($pattern, $replacement, trim($value));
256        $configArray[$key] = $value;
257    }
258}
259//echo '<pre>';print_r($configArray);echo '</pre>';
260# Database connections variables
261$CONF_DATABASE_HOST = $configArray['CONF_DATABASE_HOST'];
262$CONF_DATABASE_NAME = $configArray['CONF_DATABASE_NAME'];
263$CONF_DATABASE_USER = $configArray['CONF_DATABASE_USER'];
264$CONF_DATABASE_PASSWORD = $configArray['CONF_DATABASE_PASSWORD'];
265
266//foreach($configArray as $key => $value) { print "K=$key V=$value<BR>"; } exit(); # DEBUG
267
268###################################
269# array (array1(name1, page1), array2(name2, page2), ..., arrayN(nameN, pageN));
270# Todo : Supporter HTTP_REFERER (j'me comprends)
271function navigation($dataArray) {
272    $SERVER = $_SERVER['HTTP_HOST'];
273    $SCRIPT = $_SERVER['SCRIPT_NAME'];
274    print "\n<p>";
275    foreach ($dataArray as $num => $navArray) {
276        $title = $navArray['title'];
277        $page = $navArray['page'];
278        empty ($navArray['action']) ? $action = '' : $action = $navArray['action'];
279        print<<<EndHTML
280<A HREF="#" ONCLICK="document.myform.page.value = '$page'; document.myform.action.value = '$action'; document.myform.submit();" CLASS="button">$title</A>
281
282EndHTML;
283if (array_key_exists($num +1, $dataArray))
284        print "&nbsp;-&nbsp;";
285    }
286    print "</p>\n";
287}
288
289###################################
290#
291function refreshButton() {
292    print<<<EndHTML
293
294<p><A HREF="#" ONCLICK="javascript: window.location.reload(true);" CLASS="button">Refresh</A></p>
295EndHTML;
296}
297
298
299    ###################################
300    #
301    /*function debugButton() {
302    print <<<EndHTML
303    <p><INPUT TYPE="button" VALUE="Debug" ONCLICK="javascript: window.location.reload(true);"></p>
304    EndHTML;
305    } */
306
307    ###################################
308    # In development
309    /*function installPackage($pkg_name, $full_url, $copy) {
310    print "<h1>$pkg_name installation</h1>\n";
311    chdir(WIFIDOG_ABS_FILE_PATH."tmp");
312    list($url, $filename) = split ("=", $full_url);
313
314    print "Download source code ($filename) : ";
315    if (!file_exists($filename))
316    Dependency::execVerbose("wget \"$url\"", $output, $return);
317    if (!file_exists($filename)) // wget success if file exists
318    Dependency::execVerbose("wget \"$full_url\" 2>&1", $output_array, $return);
319    if (!file_exists($filename)) {
320    print "<B STYLE=\"color:red\">Error</b><p>Current working directory : <em>$basepath/tmp/smarty</em>";
321    $output = implode("\n", $output_array);
322    print "<pre><em>wget \"$full_url\"</em>\n$output</pre>";
323    exit();
324    } else {
325    print "OK<BR>";
326    }
327
328    print "Uncompressing : ";
329    $dirname = array_shift(split(".tar.gz", $filename));
330
331    if (!file_exists($dirname))
332    Dependency::execVerbose("tar -xzf $dirname.tar.gz", $output, $return);
333    print "OK<BR>";
334    print "Copying : ";
335    if (!file_exists('../../lib/smarty/Smarty.class.php'));
336    Dependency::execVerbose("cp -r $dirname/libs/* ../../lib/smarty", $output, $return);
337    Dependency::execVerbose("cp -r $dirname/libs/* ../../lib/smarty", $output, $return);
338    $copy
339    print "OK<BR>";
340    }*/
341
342    ###################################
343    #
344    function saveConfig($data) {
345        print "<!-- saveConfig DATA=($data) -->\n"; # DEBUG
346
347        global $CONFIG_FILE;
348
349        $contentArray = file(WIFIDOG_ABS_FILE_PATH . "$CONFIG_FILE");
350        $fd = fopen(WIFIDOG_ABS_FILE_PATH . "$CONFIG_FILE", 'w');
351
352        $defineArrayToken = array ();
353        $defineArrayToken = explode('|', $data);
354
355        foreach ($defineArrayToken as $nameValue) {
356            list ($name, $value) = explode('=', $nameValue);
357            $defineArray[$name] = $value; # New define value ($name and value)
358            #print "K=$name V=$value<BR>"; # DEBUG
359        }
360
361        foreach ($contentArray as $line) {
362            #print "L=$line<BR>\n";
363            if (preg_match("/^define\((.+)\);/", $line, $matchesArray)) {
364                list ($key, $value) = explode(',', $matchesArray[1]);
365                $pattern = array (
366                "/^'/",
367                "/'$/"
368                );
369                $replacement = array (
370                '',
371                ''
372                );
373                $key = preg_replace($pattern, $replacement, trim($key));
374                //$value = preg_replace($pattern, $replacement, trim($value));
375
376                if (array_key_exists($key, $defineArray)) { // A new value is defined
377                    #print "$key EXISTS<BR>";
378                    #print "define => (" . $defineArray[$key] . ")<BR>";
379                    $pattern = array (
380                    "/^\\\'/",
381                    "/\\\'$/"
382                    );
383                    $replacement = array (
384                    "'",
385                    "'"
386                    );
387                    $value = preg_replace($pattern, $replacement, trim($defineArray[$key]));
388                    #print "(define('$key', $value);)<BR>";
389                    fwrite($fd, "define('$key', $value);\n"); # Write the new define($name, $value)
390                }
391                else { // The key does not exist (no new value to be saved)
392                    fwrite($fd, $line); # Write the same line in config.php
393                }
394            }
395            else {
396                fwrite($fd, $line); # Write the line (not a define line). Ex: Commented text
397            }
398        }
399    }
400
401    ###################################
402    # MAIN
403    switch ($page) {
404        case 'permission' :
405            print "<h1>Permissions</h1>";
406
407            $process_info_user_id = posix_getpwuid(posix_getuid());
408
409            if($process_info_user_id){
410                $process_username = $process_info_user_id['name'];
411            }
412            else {
413                //Posix functions aren't available on windows
414                $process_username = 'unknown_user';
415            }
416            $process_info_group_id = posix_getgrgid(posix_getegid());
417            if($process_info_group_id){
418                $process_group = $process_info_group_id['name'];
419            }
420            else {
421                //Posix functions aren't available on windows
422                $process_group = 'unknown_group';
423            }
424            $cmd_mkdir = '';
425            $cmd_chown = '';
426            $error = 0;
427
428            print "<p><em>HTTP daemon UNIX username/group</em>: $process_username/$process_group</p>";
429            #    print "<p><em>HTTPD group</em>: $process_group<BR</p>";
430            print "<p><table BORDER=\"1\"><tr><td><em>Directory</em></td></td><td><em>Owner</em></td><td><em>Writable</em></td></tr>\n";
431
432            foreach ($dir_array as $dir) {
433                print "<tr><td>$dir</td>";
434                if (!file_exists(WIFIDOG_ABS_FILE_PATH . "$dir")) {
435                    print "<TD COLSPAN=\"2\" STYLE=\"text-align:center;\">Missing</td></tr>\n";
436                    $cmd_mkdir .= WIFIDOG_ABS_FILE_PATH . "$dir ";
437                    $cmd_chown .= WIFIDOG_ABS_FILE_PATH . "$dir ";
438                    $error = 1;
439                    continue;
440                }
441
442                $dir_info = posix_getpwuid(fileowner(WIFIDOG_ABS_FILE_PATH . "$dir"));
443                if($dir_info) {
444                    $dir_owner_username = $dir_info['name'];
445                }
446                else {
447                    //Posix functions aren't available on windows
448                    $dir_owner_username = fileowner(WIFIDOG_ABS_FILE_PATH . "$dir");
449                }
450                print "<td>$dir_owner_username</td>";
451
452                if (is_writable(WIFIDOG_ABS_FILE_PATH . "$dir")) {
453                    print "<td>YES</td>";
454                }
455                else {
456                    print "<td>NO</td>";
457                    $cmd_chown .= WIFIDOG_ABS_FILE_PATH . "$dir ";
458                    $error = 1;
459                }
460                print "</tr>\n";
461            }
462            print "</table>\n";
463
464            if ($error != 1) {
465                navigation(array (
466                array (
467                "title" => "Next",
468                "page" => "version"
469                    )
470                ));
471            }
472            else {
473                refreshButton();
474                print "<p>You need to allow UNIX user <em>$process_username</em> to write to these directories (mkdir, chown or chmod)</p>";
475                if (!empty ($cmd_mkdir) || !empty ($cmd_mkdir))
476                print "<p><b>For instance, you may want to use the following commands</b> :</p>\n";
477                if (!empty ($cmd_mkdir))
478                print "mkdir $cmd_mkdir <br />";
479                if (!empty ($cmd_chown))
480                print "chgrp -R $process_group $cmd_chown;<br/>chmod g+wx $cmd_chown;<br/>";
481                print "<p>After permissions modification done, hit the REFRESH button to see the NEXT button and continue with the installation";
482            }
483            break;
484            ###################################
485        case 'version' :
486            print "<h1>Checking Dependency</h1>";
487            $error = 0;
488            $userData['error']=&$error;
489            require_once("classes/DependenciesList.php");
490            print DependenciesList::getAdminUIStatic($userData);
491            refreshButton();
492            if ($error != 1) {
493                navigation(array (
494                array (
495                "title" => "Back",
496                "page" => "permission"
497                ),
498                array (
499                "title" => "Next",
500                "page" => "simplepie"
501                )
502                ));
503            }
504
505            break;
506###################################
507        case 'simplepie' : // Download, uncompress and install SimplePie
508            print "<h1>SimplePie installation</h1>\n";
509
510            if ($neededPackages['simplepie']['available']) {
511                print "Already installed !<BR>";
512                navigation(array (
513                array (
514                "title" => "Back",
515                "page" => "smarty"
516                ),
517                array (
518                "title" => "Next",
519                "page" => "feedpressreview"
520                )
521                ));
522            }
523            elseif ($action == 'install') {
524                require_once (dirname(__FILE__) . '/include/common.php');
525                print "Download source code frpm svn($filename) : ";
526                Dependency::execVerbose("svn co ".escapeshellarg($neededPackages['simplepie']['svn_source'])." ".escapeshellarg(WIFIDOG_ABS_FILE_PATH."lib/simplepie"), $output, $return);
527                #Dependency::execVerbose("locale", $output, $return);
528
529                refreshButton();
530                navigation(array (
531                array (
532                "title" => "Back",
533                "page" => "smarty"
534                ),
535                array (
536                "title" => "Next",
537                "page" => "feedpressreview"
538                )
539                ));
540            }
541            else {
542                print<<< EndHTML
543<p><A HREF="http://simplepie.org/">SimplePie</A> is a dependency of provides an RSS parser in PHP. It is required for RssPressReview.  It's is recommended to install it, if you don't, RSS feeds options will be disabled.
544
545<p>Do you want to install SimplePie ?
546EndHTML;
547navigation(array (
548                array (
549                "title" => "Back",
550                "page" => "smarty"
551                ),
552                array (
553                "title" => "Install",
554                "page" => "simplepie",
555                "action" => "install"
556                ),
557                array (
558                "title" => "Next",
559                "page" => "feedpressreview"
560                )
561                ));
562            }
563            break;
564            ###################################
565        case 'feedpressreview' : // Download, uncompress and install feedpressreview
566            print "<h1>Feed press review installation</h1>\n";
567
568            if ($neededPackages['feedpressreview']['available']) {
569                print "Already installed !<BR>";
570                navigation(array (
571                array (
572                "title" => "Back",
573                "page" => "simplepie"
574                ),
575                array (
576                "title" => "Next",
577                "page" => "database"
578                )
579                ));
580            }
581            elseif ($action == 'install') {
582                require_once (dirname(__FILE__) . '/include/common.php');
583                print "Download source code frpm svn($filename) : ";
584                Dependency::execVerbose("svn co ".escapeshellarg($neededPackages['feedpressreview']['svn_source'])." ".escapeshellarg(WIFIDOG_ABS_FILE_PATH."lib/feedpressreview"), $output, $return);
585                #Dependency::execVerbose("locale", $output, $return);
586
587                refreshButton();
588                navigation(array (
589                array (
590                "title" => "Back",
591                "page" => "smarty"
592                ),
593                array (
594                "title" => "Next",
595                "page" => "database"
596                )
597                ));
598            }
599            else {
600                print<<< EndHTML
601<p><A HREF="http://projects.coeus.ca/feedpressreview/">Feed press review</A> is a dependency that provides a Feed aggregator in PHP.  It is recommended to install it.  If you don't, RSS feeds options will be disabled.
602
603<p>Do you want to install FeedPressReview ?
604EndHTML;
605navigation(array (
606                array (
607                "title" => "Back",
608                "page" => "simplepie"
609                ),
610                array (
611                "title" => "Install",
612                "page" => "feedpressreview",
613                "action" => "install"
614                ),
615                array (
616                "title" => "Next",
617                "page" => "database"
618                )
619                ));
620            }
621            break;
622            ###################################
623        case 'jpgraph' : // Download, uncompress and install JpGraph library
624            print "<h1>JpGraph installation</h1>\n";
625
626            if ($neededPackages['jpgraph']['available']) {
627                print "Already installed !<BR>";
628                navigation(array (
629                array (
630                "title" => "Back",
631                "page" => "feedpressreview"
632                ),
633                array (
634                "title" => "Next",
635                "page" => "database"
636                )
637                ));
638            }
639            elseif ($action == 'install') {
640                chdir(WIFIDOG_ABS_FILE_PATH . "tmp");
641                $filename = array_pop(preg_split("/\//", $jpgraph_full_url));
642
643                print "Download source code ($filename) : ";
644                if (!file_exists($filename))
645                Dependency::execVerbose("wget \"$jpgraph_full_url\" 2>&1", $output, $return);
646                if (!file_exists($filename)) { # Error occured, print output of wget
647                    print "<B STYLE=\"color:red\">Error</b><p>Current working directory : <em>$basepath/tmp</em>";
648                    $output = implode("\n", $output);
649                    print "<pre><em>wget \"$jpgraph_full_url\"</em>\n$output</pre>";
650                    exit ();
651                }
652                else {
653                    print "OK<BR>";
654                }
655
656                print "Uncompressing : ";
657                $dirname = array_shift(split(".tar.gz", $filename));
658                if (!file_exists($dirname))
659                Dependency::execVerbose("tar -xzf $dirname.tar.gz", $output, $return);
660                print "OK<BR>";
661
662                print "Copying : ";
663                if (!file_exists(WIFIDOG_ABS_FILE_PATH."lib/jpgraph/jpgraph.php"))
664                Dependency::execVerbose("cp $dirname/src/* ".WIFIDOG_ABS_FILE_PATH."lib/jpgraph", $output, $return); # TODO : Utiliser JPGRAPH_REL_PATH
665
666                print "OK<BR>";
667
668                refreshButton();
669                navigation(array (
670                array (
671                "title" => "Back",
672                "page" => "feedpressreview"
673                ),
674                array (
675                "title" => "Next",
676                "page" => "database"
677                )
678                ));
679            }
680            else {
681                print<<< EndHTML
682<p><A HREF="http://www.aditus.nu/jpgraph/">JpGraph</A> is a Object-Oriented Graph creating library for PHP.
683JpGraph is not currently use by Wifidog (will be use for statistique graph in a later version). You can skip this installation if your not a developper.
684
685<p>Do you want to install JpGraph ?
686EndHTML;
687navigation(array (
688                array (
689                "title" => "Back",
690                "page" => "feedpressreview"
691                ),
692                array (
693                "title" => "Install",
694                "page" => "jpgraph",
695                "action" => "install"
696                ),
697                array (
698                "title" => "Next",
699                "page" => "database"
700                )
701                ));
702            }
703            break;
704            ###################################
705        case 'database' :
706            ### TODO : Valider en javascript que les champs soumit ne sont pas vide
707            #          Pouvoir choisir le port de la DB ???
708            print<<< EndHTML
709<h1>Database access configuration</h1>
710<BR>
711<table border="1">
712  <tr><td>Host</td><td><INPUT type="text" name="CONF_DATABASE_HOST" value="$CONF_DATABASE_HOST"></td></tr>
713  <tr><td>DB Name</td><td><INPUT type="text" name="CONF_DATABASE_NAME" value="$CONF_DATABASE_NAME"></td></tr>
714  <tr><td>Username</td><td><INPUT type="text" name="CONF_DATABASE_USER" value="$CONF_DATABASE_USER"></td></tr>
715  <tr><td>Password</td><td><INPUT type="text" name="CONF_DATABASE_PASSWORD" value="$CONF_DATABASE_PASSWORD"></td></tr>
716</table>
717
718<p>By clicking Next, your configuration will be automaticaly saved
719
720<script type="text/javascript">
721  function submitDatabaseValue() {
722    newConfig("CONF_DATABASE_HOST='" + document.myform.CONF_DATABASE_HOST.value + "'");
723    newConfig("CONF_DATABASE_NAME='" + document.myform.CONF_DATABASE_NAME.value + "'");
724    newConfig("CONF_DATABASE_USER='" + document.myform.CONF_DATABASE_USER.value + "'");
725    newConfig("CONF_DATABASE_PASSWORD='" + document.myform.CONF_DATABASE_PASSWORD.value + "'");
726  }
727</script>
728
729EndHTML;
730
731            navigation(array (
732            array (
733            "title" => "Back",
734            "page" => "simplepie"
735            )
736            )); #, array("title" => "Next", "page" => "testdatabase")));
737            print<<< EndHTML
738<p><A HREF="#" ONCLICK="javascript: document.myform.page.value='testdatabase'; submitDatabaseValue(); document.myform.submit();" CLASS="button">Next</A></p>
739
740EndHTML;
741
742            break;
743            ###################################
744        case 'testdatabase' :
745            print "<h1>Database connection</h1>";
746            /* TODO : Tester la version minimale requise de Postgresql                */
747
748            print "<UL><LI>Postgresql database connection : ";
749
750            $conn_string = "host=$CONF_DATABASE_HOST dbname=$CONF_DATABASE_NAME user=$CONF_DATABASE_USER password=$CONF_DATABASE_PASSWORD";
751            $ptr_connexion = pg_connect($conn_string);
752
753            if ($ptr_connexion == TRUE) {
754                print "Success<BR>";
755            }
756            else {
757                print "Unable to connect to database on $CONF_DATABASE_HOST<BR>The database must be online to continue.<BR>Please go back and retry with correct values";
758                refreshButton();
759                navigation(array(array("title" => "Back", "page" => "database")));
760                die();
761            }
762
763            $postgresql_info = pg_version();
764            #        $postgresql_info['server'];
765            #        if ($postgresql_info['server'] > $requiredPostgeSQLVersion) { Todo : Do something }
766
767            print "</UL>";
768            refreshButton();
769            navigation(array (
770            array (
771            "title" => "Back",
772            "page" => "database"
773                    ),
774            array (
775            "title" => "Next",
776            "page" => "dbinit"
777                    )
778            ));
779            break;
780            ###################################
781        case 'dbinit' :
782            print "<h1>Database initialisation</h1>";
783            # SQL are executed with PHP, some lignes need to be commented.
784            $file_db_version = 'UNKNOW';
785            $patterns[0] = '/CREATE DATABASE wifidog/';
786            $patterns[1] = '/\\\connect/';
787            //The following is strictly for compatibility with postgresql 7.4
788            $patterns[2] = '/COMMENT/';
789            $patterns[3] = '/^SET /m';
790            $patterns[4] = '/CREATE PROCEDURAL LANGUAGE/';
791            $patterns[5] = '/ALTER SEQUENCE/';
792            $patterns[6] = '/::regclass/';//To fix incompatibility of postgres < 8.1 with later nextval() calling convention
793            $replacements[0] = '-- ';
794            $replacements[1] = '-- ';
795            $replacements[2] = '-- ';
796            $replacements[3] = '-- ';
797            $replacements[4] = '-- ';
798            $replacements[5] = '-- ';
799            $replacements[6] = '::text';           
800
801            $content_schema_array = file(WIFIDOG_ABS_FILE_PATH . "../sql/wifidog-postgres-schema.sql") or die("<em>Error</em>: Can not open $basepath/../sql/wifidog-postgres-schema.sql"); # Read SQL schema file
802            $content_schema = implode("", $content_schema_array);
803            $content_data_array = file(WIFIDOG_ABS_FILE_PATH . "../sql/wifidog-postgres-initial-data.sql"); # Read SQL initial data file
804            $content_data = implode("", $content_data_array);
805
806            $db_schema_version = ''; # Schema version query from database
807            $file_schema_version = ''; # Schema version from define(REQUIRED_SCHEMA_VERSION) in schema_validate.php
808
809            $conn_string = "host=$CONF_DATABASE_HOST dbname=$CONF_DATABASE_NAME user=$CONF_DATABASE_USER password=$CONF_DATABASE_PASSWORD";
810            $connection = pg_connect($conn_string) or die(); # or die("Couldn't Connect ==".pg_last_error()."==<BR>");
811
812            if (preg_match("/\('schema_version', '(\d+)'\);/", $content_data, $matchesArray)) # Get schema_version from initial data file
813            $file_db_version = $matchesArray[1];
814
815            $contentArray = file(WIFIDOG_ABS_FILE_PATH . "include/schema_validate.php");
816            foreach ($contentArray as $line) {
817                #print "$line<BR>"; # Debug
818                if (preg_match("/^define\('REQUIRED_SCHEMA_VERSION', (\d+)\);/", $line, $matchesArray)) {
819                    #print "REQUIRED_SCHEMA_VERSION = " . $matchesArray[1] . "<BR>";
820                    $file_schema_version = $matchesArray[1];
821                }
822            }
823
824            # Get current database schema version (if defined)
825            $sql = "SELECT * FROM schema_info WHERE tag='schema_version'";
826            if ($result = @ pg_query($connection, $sql)) { # The @ remove warning display
827                $result_array = pg_fetch_all($result);
828                $db_shema_version = $result_array[0]['value'];
829
830                print "<p>On <em>$CONF_DATABASE_HOST</em>, Database <em>$CONF_DATABASE_NAME</em> exists and is ";
831                if ($db_shema_version == $file_schema_version) {
832                    print "up to date (shema version <em>$db_shema_version</em>).";
833                    navigation(array (
834                    array (
835                    "title" => "Back",
836                    "page" => "database"
837                            ),
838                    array (
839                    "title" => "Next",
840                    "page" => "options"
841                            )
842                    ));
843                }
844                elseif ($db_shema_version < $file_schema_version) {
845                    print "at schema version <em>$db_shema_version</em>. The required schema version is <em>$file_schema_version</em><p>Please upgrade the database";
846                    navigation(array (
847                    array (
848                    "title" => "Back",
849                    "page" => "database"
850                            ),
851                    array (
852                    "title" => "Upgrade",
853                    "page" => "schema_validate"
854                            ),
855                    array (
856                    "title" => "Next",
857                    "page" => "options"
858                            )
859                    ));
860                }
861                else {
862                    print "Error : Unexpected result";
863                }
864                exit ();
865            }
866
867            print "<UL><LI>Creating wifidog database schema : ";
868            $content_schema = preg_replace($patterns, $replacements, $content_schema); # Comment bad SQL lines
869            //echo "<pre>$content_schema</pre>";
870            $result = pg_query($connection, $content_schema) or die("<em>" . pg_last_error() . "</em> <=<BR>");
871            print "OK";
872
873            print "<LI>Creating wifidog database initial data : ";
874            $content_data = preg_replace($patterns, $replacements, $content_data); # Comment bad SQL lines
875
876            $result = pg_query($connection, $content_data) or die("<em>" . pg_last_error() . "</em> <=<BR>");
877            print "OK</UL>";
878
879            navigation(array (
880            array (
881            "title" => "Back",
882            "page" => "database"
883                    ),
884            array (
885            "title" => "Next",
886            "page" => "options"
887                    )
888            ));
889            break;
890
891            ###################################
892        case 'schema_validate' :
893            print "<h1>Database schema upgrade</h1>\n";
894
895            require_once (dirname(__FILE__) . '/include/common.php');
896
897            require_once ('classes/AbstractDb.php');
898            require_once ('classes/Session.php');
899            require_once ('include/schema_validate.php');
900
901            validate_schema();
902
903            navigation(array (
904            array (
905            "title" => "Back",
906            "page" => "dbinit"
907            ),
908            array (
909            "title" => "Next",
910            "page" => "options"
911            )
912            ));
913
914            //navigation(array(array("title" => "Back", "page" => "dbinit")));
915            break;
916
917            ###################################
918        case 'options' :
919            # TODO : Tester que la connection SSL est fonctionnelle
920            #        Options avancees : Supporter les define de [SMARTY|PHLICKR|JPGRAPH]_REL_PATH
921            print<<< EndHTML
922<h1>Available options</h1>
923  <table border="1">
924
925EndHTML;
926
927            //echo '<pre>';print_r($optionsInfo);echo '</pre>';
928            foreach ($optionsInfo as $name => $foo) { # Foreach generate all <table> fields
929                $value = $configArray[$name]; # Value of option in config.php
930                $title = $optionsInfo[$name]['title']; # Field Title
931                $message = $optionsInfo[$name]['message']; # Message why option is disable
932                if(empty($value))
933                $message .= ", ERROR: unable to find the '$name' directive in the config file";
934                $depend = @ eval ($optionsInfo[$name]['depend']); # Evaluate the dependencie
935                $selectedTrue = '';
936                $selectedFalse = ''; # Initialize value
937                $value == 'true' ? $selectedTrue = 'SELECTED' : $selectedFalse = 'SELECTED'; # Use to select the previous saved option
938                $depend == 1 ? $disabled = '' : $disabled = 'DISABLED'; # Disable <SELECT> if dependencie is not satisfied
939                $jscript = "<script type=\"text/javascript\"> newConfig(\"$name=false\"); </script>\n"; # Use to save a failed dependencie (option=false)
940                if ($disabled == '') # Dependencie ok, erase $jscript value
941                $jscript = '';
942
943                print<<< EndHTML
944  <tr>
945    <td>$title</td>
946    <td><SELECT name="$name" $disabled>
947          <OPTION value="true" $selectedTrue>true</OPTION>
948          <OPTION value="false" $selectedFalse>false</OPTION>
949        </SELECT>
950    </td>
951    <td>$message</td>
952  </tr>
953  $jscript
954EndHTML;
955            } # End or foreach
956            print<<< EndHTML
957    </table>
958
959<script type="text/javascript">
960  function submitOptionsValue() {
961
962EndHTML;
963
964            foreach ($optionsInfo as $name => $foo) { # Generate the javascript to save value on submit
965                print<<< EndHTML
966    if (!document.myform.$name.disabled)
967      newConfig("$name=" + document.myform.$name.value);
968
969EndHTML;
970            } # End Foreach
971
972            print<<< EndHTML
973  }
974</script>
975
976EndHTML;
977navigation(array (
978            array (
979            "title" => "Back",
980            "page" => "dbinit"
981            )
982            ));
983
984            print<<< EndHTML
985<p><A HREF="#" ONCLICK="javascript: document.myform.page.value='languages'; submitOptionsValue(); document.myform.submit();" CLASS="button">Next</A></p>
986EndHTML;
987
988            break;
989
990            ###################################
991        case 'languages' :
992            print "<h1>Languages configuration</h1>";
993            print<<< EndHTML
994      <p>Not yet implemented ...</p>
995      <p>Will allow selecting language to use.</p>
996<em>Error message example</em> : <BR>
997<DIV style="border:solid black;">Warning: language.php: Unable to setlocale() to fr, return value: , current locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C; [...]</DIV>
998<p><em>I repeat</em> : This is an example of message you can see in the top of your working auth-server if language are not set correctly. To change these values please edit <em>config.php</em> in auth-server install directory. Look for "Available locales" and "Default language" header in config.php.
999EndHTML;
1000//    Dependency::execVerbose("locale -a 2>&1", $output, $return);
1001
1002            navigation(array (
1003            array (
1004            "title" => "Back",
1005            "page" => "options"
1006            ),
1007            array (
1008            "title" => "Next",
1009            "page" => "radius"
1010            )
1011            ));
1012            break;
1013
1014            ###################################
1015        case 'radius' :
1016            print "<h1>Radius Authenticator configuration</h1>";
1017            print "<p>Not yet implemented ...";
1018
1019            navigation(array (
1020            array (
1021            "title" => "Back",
1022            "page" => "languages"
1023            ),
1024            array (
1025            "title" => "Next",
1026            "page" => "admin"
1027            )
1028            ));
1029            break;
1030
1031            ###################################
1032        case 'admin' :
1033            print "<h1>Administration account</h1>";
1034            # TODO : Allow to create more than one admin account and list the current admin users
1035            #        Allow admin to choose to show or not is username
1036            empty ($_REQUEST['username']) ? $username = 'admin' : $username = $_REQUEST['username'];
1037            empty ($_REQUEST['password']) ? $password = '' : $password = $_REQUEST['password'];
1038            empty ($_REQUEST['password2']) ? $password2 = '' : $password2 = $_REQUEST['password2'];
1039            empty ($_REQUEST['email']) ? $email = $_SERVER['SERVER_ADMIN'] : $email = $_REQUEST['email'];
1040
1041            $conn_string = "host=$CONF_DATABASE_HOST dbname=$CONF_DATABASE_NAME user=$CONF_DATABASE_USER password=$CONF_DATABASE_PASSWORD";
1042            $connection = pg_connect($conn_string) or die();
1043
1044            if ($action == 'create') {
1045                //      require_once(dirname(__FILE__) . '/config.php');
1046                require_once (dirname(__FILE__) . '/include/common.php');
1047                require_once (dirname(__FILE__) . '/classes/User.php');
1048
1049                $created_user = User :: createUser(get_guid(), $username, Network :: getDefaultNetwork(), $email, $password);
1050                $user_id = $created_user->getId();
1051
1052                # Add user to admin table, hide his username and set his account status to 1 (allowed)
1053                $sql = "INSERT INTO server_stakeholders (user_id, role_id, object_id) VALUES ('$user_id', 'SERVER_SYSADMIN', 'SERVER_ID');\n";
1054                $sql .= "INSERT INTO network_stakeholders (user_id, role_id, object_id) VALUES ('$user_id', 'NETWORK_SYSADMIN', 'default-network');\n";
1055                $sql .= "UPDATE users SET account_status='1' WHERE user_id='$user_id'";
1056                $result = pg_query($connection, $sql);
1057            }
1058
1059            $sql = "SELECT * FROM users NATURAL JOIN server_stakeholders WHERE account_origin = 'default-network'";
1060            $result = pg_query($connection, $sql);
1061            $result_array = pg_fetch_all($result);
1062            $username_db = $result_array[0]['username'];
1063
1064            if (!empty ($username_db)) {
1065                print "<p>Your administrator user account is <em>$username_db</em>";
1066                navigation(array (
1067                array (
1068                "title" => "Back",
1069                "page" => "radius"
1070                ),
1071                array (
1072                "title" => "Next",
1073                "page" => "network"
1074                )
1075                ));
1076            }
1077            else {
1078                print<<<EndHTML
1079        <p>
1080        <table BORDER="1">
1081        <tr>
1082          <td>Username</td><td><INPUT type="text" name="username" value="$username"></td>
1083        </tr>
1084        <tr>
1085          <td>Password</td><td><INPUT type="password" name="password"></td>
1086        </tr>
1087        <tr>
1088          <td>Password again</td><td><INPUT type="password" name="password2"></td>
1089        </tr>
1090        <tr>
1091          <td>Email</td><td><INPUT type="text" name="email" value="$email"></td>
1092        </tr>
1093        </table>
1094
1095        <script type="text/javascript">
1096          function submitValue() {
1097            if (document.myform.password.value != document.myform.password2.value) {
1098              alert('Password mismatch, Please retry');
1099              exit();
1100            }
1101            if (document.myform.password.value == '') {
1102              alert('You need to type a password');
1103              exit();
1104            }
1105            if (document.myform.email.value == '') {
1106              alert('You need to type a email');
1107              exit();
1108            }
1109            document.myform.page.value='admin';
1110            document.myform.action.value='create';
1111            document.myform.submit();
1112          }
1113        </script>
1114
1115EndHTML;
1116navigation(array (
1117                array (
1118                "title" => "Back",
1119                "page" => "radius"
1120                )
1121                ));
1122                print "<p><A HREF=\"#\" ONCLICK=\"javascript: submitValue();\" CLASS=\"button\">Next</A></p>\n";
1123            }
1124            break;
1125
1126            ###################################
1127        case 'network' :
1128            print "<h1>Network</h1>";
1129
1130            //$HOTSPOT_NETWORK_NAME          = $configArray['HOTSPOT_NETWORK_NAME'];
1131            //$HOTSPOT_NETWORK_URL           = $configArray['HOTSPOT_NETWORK_URL'];
1132            //$TECH_SUPPORT_EMAIL            = $configArray['TECH_SUPPORT_EMAIL'];
1133            //$VALIDATION_GRACE_TIME         = $configArray['VALIDATION_GRACE_TIME'];
1134            //$VALIDATION_EMAIL_FROM_ADDRESS = $configArray['VALIDATION_EMAIL_FROM_ADDRESS'];
1135
1136            /**
1137             * @deprecated 2005-12-26 Needs to use network abstraction
1138             *
1139             *
1140             * <p>
1141             <table border="1">
1142             <tr>
1143             <td>Network Name</td><td><INPUT type="text" name="HOTSPOT_NETWORK_NAME" value="" size="30"></td>
1144             </tr>
1145             <tr>
1146             <td>Network URL</td><td><INPUT type="text" name="HOTSPOT_NETWORK_URL" value="" size="30"></td>
1147             </tr>
1148             <tr>
1149             <td>Tech Support Email</td><td><INPUT type="text" name="TECH_SUPPORT_EMAIL" value="" size="30"></td>
1150             </tr>
1151             <tr>
1152             <td>Validation Grace Time (min)</td><td><INPUT type="text" name="VALIDATION_GRACE_TIME" value="" size="30"></td>
1153             </tr>
1154             <tr>
1155             <td>Validation Email (send from)</td><td><INPUT type="text" name="VALIDATION_EMAIL_FROM_ADDRESS" value="" size="30"></td>
1156             </tr>
1157             </table>
1158             */
1159            print "Need to reimplement this... Until then connect to the administration pages and modify it by yourself.";
1160
1161            print<<< EndHTML
1162
1163
1164<script type="text/javascript">
1165  function submitOptionsValue() {
1166    //newConfig("HOTSPOT_NETWORK_NAME='" + document.myform.HOTSPOT_NETWORK_NAME.value + "'");
1167    //newConfig("HOTSPOT_NETWORK_URL='" + document.myform.HOTSPOT_NETWORK_URL.value + "'");
1168    //newConfig("TECH_SUPPORT_EMAIL='" + document.myform.TECH_SUPPORT_EMAIL.value + "'");
1169    //newConfig("VALIDATION_GRACE_TIME=" + document.myform.VALIDATION_GRACE_TIME.value);
1170    //newConfig("VALIDATION_EMAIL_FROM_ADDRESS='" + document.myform.VALIDATION_EMAIL_FROM_ADDRESS.value + "'");
1171  }
1172</script>
1173
1174EndHTML;
1175
1176            navigation(array (
1177            array (
1178            "title" => "Back",
1179            "page" => "admin"
1180            )
1181            ));
1182
1183            print<<< EndHTML
1184<p><A HREF="#" ONCLICK="javascript: document.myform.page.value='hotspot'; submitOptionsValue(); document.myform.submit();" CLASS="button">Next</A></p>
1185EndHTML;
1186#navigation(array(array("title" => "Back", "page" => "admin"), array("title" => "Next", "page" => "hotspot")));
1187            break;
1188
1189            ###################################
1190        case 'hotspot' :
1191            print "<h1>Hotspot</h1>";
1192            print "<p>A default hotspot has already been created<p>Use administration interface to add more hotspots.";
1193            navigation(array (
1194            array (
1195            "title" => "Back",
1196            "page" => "network"
1197            ),
1198            array (
1199            "title" => "Next",
1200            "page" => "end"
1201            )
1202            ));
1203            break;
1204
1205            ###################################
1206        case 'delete' :
1207            print<<<EndHTML
1208  <h1>Delete temporary files</h1>
1209  ...
1210EndHTML;
1211#navigation(array(array("title" => "Back", "page" => "hotspot")));
1212            break;
1213
1214            ###################################
1215        case 'end' :
1216            $url = 'http://' . $_SERVER['HTTP_HOST'] . SYSTEM_PATH;
1217            print<<<EndHTML
1218  <h1>Thanks for using Wifidog</h1>
1219  Redirection to your new WifiDog Authentification Server in 3 seconds
1220  <meta http-equiv="REFRESH" content="3;url=$url">
1221  <pre>
1222
1223               |\   /|              _
1224               |A\_/A|            z   z
1225            ___|     |           ( (o) )
1226           o    6     \           z _ z
1227           |___        \           /|
1228               |        \         / |
1229                \        \_______/  |
1230                |                   |
1231                |      WIFIDOG      |
1232                |   Captive Portal  |
1233                |   _____________   |
1234                |  /             \  |
1235                |  |             |  |
1236                |  |             |  |
1237              _/   |           _/   |
1238             ?_____|          ?_____|
1239</pre>
1240EndHTML;
1241#navigation(array(array("title" => "Back", "page" => "hotspot")));
1242            break;
1243
1244            ###################################
1245        case 'toc' :
1246            print "<h1>Table of content</h1>";
1247            $contentArray = file(__file__); # Read myself
1248            print "<UL>\n";
1249            foreach ($contentArray as $line) {
1250                if (preg_match("/^  case '(\w+)':/", $line, $matchesArray)) { # Parse for "case" regex
1251                    if ($matchesArray[1] == 'toc')
1252                    continue;
1253                    print "<LI><A HREF=\"" . $_SERVER['SCRIPT_NAME'] . "?page=" . $matchesArray[1] . "\">" . $matchesArray[1] . "</A>\n"; # Display a Table of Content
1254                }
1255            }
1256            print "</UL>\n";
1257            break;
1258            ###################################
1259        case 'notes' :
1260            print<<<EndHTML
1261<!-- /* Editor highlighting trick -->
1262<pre>
1263<em>TODO</em>
1264  -Support des define de Google Maps dans config.php
1265  -Faire une fonction d'execution avec gestion de retour d'erreur et d'affichage de l'exection pour chaque "exec"
1266  -Ajouter une veritable validation (user/password admin provenant de la DB)
1267     Pour une meilleur securite du script d'installation.
1268       Au chargement, valider que la connection DB est fonctionnel, que la DB existe et que l'usager admin existe
1269         Si oui, on demande l'authentification
1270         Si non, on creer l'usager admin
1271  -Faire un vrai menu pour acceder directement aux pages desirees (pas une TOC poche)
1272  -Ameliorer le javascript et arreter de faire des document.myform.submit();
1273  -Generate valid HTML code
1274  -Integrate this script with the portal skin
1275  -Tester que les donnees de AVAIL_LOCALE_ARRAY dans config.php sont valides (fonctionnelles)
1276     Regarder le code dans include/language.php
1277  -Support pour l'option CUSTOM_SIGNUP_URL
1278  -Effacer repertoires/fichiers temporaires des installations
1279
1280  -Nice2Have : Si test d'integrite et de fonctionnement existent, les integrer pour assurer le bon fonctionnement
1281  -Nice2Have : Si donnees de tests exitent (pour les developpeurs) Permettre d'en ajouter a la DB
1282  -Nice2Have : Creer un wifidog.conf (client) selon config + questions si necessaires
1283
1284<em>Change Log</em>
1285  15-08-2005 : Bugs correction + comments added
1286  11-08-2005 : Options rewrite with foreach and Dependency
1287  09-08-2005 : Admin user creation + network configuration
1288  27-07-2005 : Added jpgraph install
1289  26-07-2005 : Added minimal security password validation
1290  14-07-2005 : saveConfig and all javascript code
1291  09-07-2005 : Added Phlickr installation
1292  05-07-2005 : Better PHP extention validation process
1293  17-06-2005 : MySQL schema and data submission
1294  17-06-2005 : Postgresql schema and data submission
1295  24-04-2005 : CSS button
1296
1297</pre>
1298<!-- Editor highlighting trick */ -->
1299EndHTML;
1300break;
1301            ###################################
1302            /*  case 'phpinfo': // Use for debugging, to be removed
1303            print "<pre>";
1304            print_r(get_loaded_extensions());
1305            print "</pre><BR><BR>";
1306            phpinfo();
1307            break;*/
1308
1309        default :
1310            $WIFIDOG_VERSION = $configArray['WIFIDOG_VERSION'];
1311            # TODO : Add links to auth-server web documents
1312            print<<<EndHTML
1313<h1>Welcome to WifiDog Auth-Server installation and configuration script.</h1>
1314<p>This installation still needs improvement, so please any report bug to the mailing list for better support.<BR/>
1315The current auth-server version is <em>$WIFIDOG_VERSION</em>.</p>
1316
1317<p><strong>Before going any further</strong> with this installation you need to do the following:\n
1318<h2>1-Make sure you created a valid user and database.</h2>
1319<p>If you haven't, here is a command line example for PostgreSQL (or use the way you like) :</p>
1320<em>Create the PostgreSQL databaser user for WifiDog</em> (createuser and createdb need to be in you PATH) :
1321<pre>  <I>postgres@yourserver $></I> createuser wifidog --pwprompt
1322  Enter password for new user:
1323  Enter it again:
1324  Shall the new user be allowed to create databases? (y/n) n
1325  Shall the new user be allowed to create more new users? (y/n) n
1326  CREATE USER
1327</pre>
1328<em>Create the WifiDog database</em>
1329<pre>  <I>postgres@yourserver $></I> createdb wifidog --encoding=UTF-8 --owner=wifidog
1330  CREATE DATABASE
1331</pre>
1332<h2>2-Check that the paths were autodected properly</h2>
1333EndHTML;
1334echo "<table>\n";
1335            echo "<tr><td>Absolute path to the /wifidog directory (WIFIDOG_ABS_FILE_PATH):</td><td>" . WIFIDOG_ABS_FILE_PATH . "</td></tr>\n";
1336            echo "<tr><td>URL path to reach the /wifidog directory with a web browser (SYSTEM_PATH): </td><td>" . SYSTEM_PATH . "</td></tr>\n";
1337            echo "<tr><td colspan=2><em>Please verify the two values above.</em> They should be autodectected correctly by wifidog in path_defines_base.php.  If there is a bug and they are not, you need to override them in config.php (or find the bug), or your auth server will not work properly.  </td></tr></table>\n";
1338            print<<<EndHTML
1339<h2>3-Retrieve the install password</h2>
1340A password is needed to continue with the installation. You need to read the random password in <em>$password_file</em> file. No username needed, only the password. This password is only usefull for the installation, you will never use it in Auth-Server administration pages.
1341</pre>
1342
1343<p>When you are ready click next</p>
1344
1345EndHTML;
1346
1347            navigation(array (
1348            array (
1349            "title" => "Next",
1350            "page" => "permission"
1351            )
1352            ));
1353    }
1354    echo "<input type='hidden' name='page' value='$_REQUEST[page]'/>\n" ;
1355    ?>
1356
1357</form>
1358</body>
1359</html>
1360
Note: See TracBrowser for help on using the browser.