Example #1
0
         Check::good('[' . date('H:i:s') . '] Connected to database.');
         $res = Database::RunFolder($root . '/protected/install/database/schema/');
         if (true !== $res) {
             throw new Exception('Error loading database schema:<br/><div class="nested-error">' . $res . '</div>');
         }
         // Save the new version
         @file_put_contents($root . '/protected/install/database/version', DATABASE_VERSION);
         Check::good('[' . date('H:i:s') . '] Loaded database schema.');
         $subs = array('username' => $_POST['config_username'], 'userpass' => md5($_POST['config_password']));
         $res = Database::RunFile($root . '/protected/install/database/data/add_user.sql', $subs);
         if (true !== $res) {
             throw new Exception('Error loading database data:<br/><div class="nested-error">' . $res . '</div>');
         }
         Check::good('[' . date('H:i:s') . '] Loaded database data.');
         $substitutions = array('mysql_host' => $_POST['mysql_host'], 'mysql_database' => $_POST['mysql_database'], 'mysql_password' => $_POST['mysql_password'], 'mysql_username' => $_POST['mysql_user'], 'security_cookie' => sha1(time() . $_SERVER['SERVER_NAME']), 'host' => $_SERVER['SERVER_NAME'], 'path' => $_SERVER['REQUEST_URI'], 'user' => $_POST['config_username'], 'flickr_comment' => empty($_POST['config_flickr_api_key']) ? ';' : '', 'flickr_key' => $_POST['config_flickr_api_key'], 'google_map_comment' => empty($_POST['config_google_maps_api_key']) ? ';' : '', 'google_map_key' => $_POST['config_google_maps_api_key']);
         if (Config::SaveFile($root . '/protected/install/config.ini.template', $root . '/protected/config/config.ini', $substitutions)) {
             Check::good('[' . date('H:i:s') . '] Saved config file.');
         } else {
             $_SESSION['config'] = Config::RenderFile($root . '/protected/install/config.ini.template', $substitutions);
             Check::warn("Could not write config.ini.<br/>Please below to download your config file and place it in <tt>protected/config/</tt>.<br/><a href=\"?config\">Download config.ini</a>");
         }
         print "<p>Installation Complete!</p>";
         print "<p>Please remove or rename protected/install/install.php</p>";
         print '<p>Go To: <a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '/admin">Administration</a> or <a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '">Front Page</a></p>';
         return 'Installation';
     } else {
         throw new Exception('Your configuration has errors, please see below.');
     }
 } catch (Exception $e) {
     Check::bad($e->getMessage());
     Check::restart();