.
*/
define('INSTALLDIR', dirname(__FILE__));
function main()
{
if (!checkPrereqs())
{
return;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
handlePost();
} else {
showForm();
}
}
function checkPrereqs()
{
$pass = true;
if (file_exists(INSTALLDIR.'/config.php')) {
?>
Config file "config.php" already exists.
Require PHP version 5 or greater.
Cannot load required extension:
Cannot write config file to:
On your server, try this command: chmod a+w
Cannot write avatar directory: /avatar/
On your server, try this command: chmod a+w /avatar/
$pass = false;
}
return $pass;
}
function checkExtension($name)
{
if (!extension_loaded($name)) {
if (!dl($name.'.so')) {
return false;
}
}
return true;
}
function showForm()
{
$config_path = htmlentities(trim(dirname($_SERVER['REQUEST_URI']), '/'));
echo<<
- Page notice
-
Enter your database connection information below to initialize the database.
E_O_T;
}
function updateStatus($status, $error=false)
{
?>
>
- Page notice
-
'SMS carrier',
'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
updateStatus(sprintf("Adding %s data to database...", $name));
$res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
if ($res === false) {
updateStatus(sprintf("Can't run %d script.", $name), true);
showForm();
return;
}
}
updateStatus("Writing config file...");
$sqlUrl = "mysqli://$username:$password@$host/$database";
$res = writeConf($sitename, $sqlUrl, $fancy, $path);
if (!$res) {
updateStatus("Can't write config file.", true);
showForm();
return;
}
updateStatus("Done!");
if ($path) $path .= '/';
updateStatus("You can visit your new Laconica site.");
?>
");
return $res;
}
function runDbScript($filename, $conn)
{
$sql = trim(file_get_contents($filename));
$stmts = explode(';', $sql);
foreach ($stmts as $stmt) {
$stmt = trim($stmt);
if (!mb_strlen($stmt)) {
continue;
}
$res = mysql_query($stmt, $conn);
if ($res === false) {
return $res;
}
}
return true;
}
?>
xml version="1.0" encoding="UTF-8" "; ?>
Install Laconica