4 function install_post(&$a) {
8 $dbhost = notags(trim($_POST['dbhost']));
9 $dbuser = notags(trim($_POST['dbuser']));
10 $dbpass = notags(trim($_POST['dbpass']));
11 $dbdata = notags(trim($_POST['dbdata']));
12 $timezone = notags(trim($_POST['timezone']));
13 $phpath = notags(trim($_POST['phpath']));
15 require_once("dba.php");
17 $db = new dba($dbhost, $dbuser, $dbpass, $dbdata, $true);
20 notice( t('Could not connect to database.') . EOL);
24 notice( t('Connected to database.') . EOL);
26 $tpl = file_get_contents('view/htconfig.tpl');
27 $txt = replace_macros($tpl,array(
32 '$timezone' => $timezone,
35 $result = file_put_contents('.htconfig.php', $txt);
40 $errors = load_database($db);
42 // Our sessions normally are stored in the database. But as we have only managed
43 // to get it bootstrapped milliseconds ago, we have to apply a bit of trickery so
44 // that you'll see the following important notice (which is stored in the session).
46 session_write_close();
47 require_once('session.php');
49 $_SESSION['sysmsg'] = '';
51 notice( t('Database import succeeded.') . EOL
52 . t('IMPORTANT: You will need to (manually) setup a scheduled task for the poller.') . EOL
53 . t('Please see the file INSTALL.') . EOL );
54 goaway($a->get_baseurl());
57 $db = null; // start fresh
58 notice( t('Database import failed.') . EOL
59 . t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL
60 . t('Please see the file INSTALL.') . EOL );
65 function install_content(&$a) {
67 notice( t('Welcome to the Mistpark Social Network.') . EOL);
69 $o .= check_htconfig();
73 if(strlen($a->data)) {
74 $o .= manual_config($a);
78 $o .= check_php($phpath);
80 require_once('datetime.php');
82 $tpl = file_get_contents('view/install_db.tpl');
83 $o .= replace_macros($tpl, array(
84 '$tzselect' => ((x($_POST,'timezone')) ? select_timezone($_POST['timezone']) : select_timezone()),
85 '$submit' => t('Submit'),
86 '$dbhost' => ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'),
87 '$dbuser' => notags(trim($_POST['dbuser'])),
88 '$dbpass' => notags(trim($_POST['dbpass'])),
89 '$dbdata' => notags(trim($_POST['dbdata'])),
96 function check_php(&$phpath) {
97 $phpath = trim(shell_exec('which php'));
98 if(! strlen($phpath)) {
100 Could not find a command line version of PHP in the web server PATH. This is required. Please adjust the configuration file .htconfig.php accordingly.
107 function check_htconfig() {
109 if(((file_exists('.htconfig.php')) && (! is_writable('.htconfig.php')))
110 || (! is_writable('.'))) {
114 The web installer needs to be able to create a file called ".htconfig.php" in the top folder of
115 your web server. It is unable to do so. This is most often a permission setting, as the web server
116 may not be able to write files in your folder (even if you can).
118 Please check with your site documentation or support people to see if this situation can be corrected.
119 If not, you may be required to perform a manual installation. Please see the file "INSTALL" for instructions.
128 function manual_config(&$a) {
130 The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.
132 <textarea rows="24" cols="80" >{$a->data}</textarea>
138 function load_database($db) {
140 $str = file_get_contents('database.sql');
141 $arr = explode(';',$str);
143 foreach($arr as $a) {
144 if(strlen(trim($a))) {
145 $r = @$db->q(trim($a));
147 notice( t('Errors encountered creating database tables.') . $a . EOL);