don't show a warning when dl() disabled

This commit is contained in:
Evan Prodromou 2009-08-27 08:45:53 -07:00
parent 03e0f73002
commit 2371fe9092

View File

@ -87,7 +87,7 @@ function checkPrereqs()
function checkExtension($name) function checkExtension($name)
{ {
if (!extension_loaded($name)) { if (!extension_loaded($name)) {
if (!dl($name.'.so')) { if (!@dl($name.'.so')) {
return false; return false;
} }
} }
@ -129,7 +129,7 @@ function showForm()
<p class="form_guide">Database hostname</p> <p class="form_guide">Database hostname</p>
</li> </li>
<li> <li>
<label for="dbtype">Type</label> <label for="dbtype">Type</label>
<input type="radio" name="dbtype" id="fancy-mysql" value="mysql" checked='checked' /> MySQL<br /> <input type="radio" name="dbtype" id="fancy-mysql" value="mysql" checked='checked' /> MySQL<br />
<input type="radio" name="dbtype" id="dbtype-pgsql" value="pgsql" /> PostgreSQL<br /> <input type="radio" name="dbtype" id="dbtype-pgsql" value="pgsql" /> PostgreSQL<br />
@ -181,7 +181,7 @@ function handlePost()
$fancy = !empty($_POST['fancy']); $fancy = !empty($_POST['fancy']);
$server = $_SERVER['HTTP_HOST']; $server = $_SERVER['HTTP_HOST'];
$path = substr(dirname($_SERVER['PHP_SELF']), 1); $path = substr(dirname($_SERVER['PHP_SELF']), 1);
?> ?>
<dl class="system_notice"> <dl class="system_notice">
<dt>Page notice</dt> <dt>Page notice</dt>
@ -219,7 +219,7 @@ function handlePost()
showForm(); showForm();
return; return;
} }
switch($dbtype) { switch($dbtype) {
case 'mysql': case 'mysql':
$db = mysql_db_installer($host, $database, $username, $password); $db = mysql_db_installer($host, $database, $username, $password);
@ -229,26 +229,26 @@ function handlePost()
break; break;
default: default:
} }
if (!$db) { if (!$db) {
// database connection failed, do not move on to create config file. // database connection failed, do not move on to create config file.
return false; return false;
} }
updateStatus("Writing config file..."); updateStatus("Writing config file...");
$res = writeConf($sitename, $server, $path, $fancy, $db); $res = writeConf($sitename, $server, $path, $fancy, $db);
if (!$res) { if (!$res) {
updateStatus("Can't write config file.", true); updateStatus("Can't write config file.", true);
showForm(); showForm();
return; return;
} }
/* /*
TODO https needs to be considered TODO https needs to be considered
*/ */
$link = "http://".$server.'/'.$path; $link = "http://".$server.'/'.$path;
updateStatus("StatusNet has been installed at $link"); updateStatus("StatusNet has been installed at $link");
updateStatus("You can visit your <a href='$link'>new StatusNet site</a>."); updateStatus("You can visit your <a href='$link'>new StatusNet site</a>.");
?> ?>
@ -266,7 +266,7 @@ function pgsql_db_installer($host, $database, $username, $password) {
updateStatus("Starting installation..."); updateStatus("Starting installation...");
updateStatus("Checking database..."); updateStatus("Checking database...");
$conn = pg_connect($connstring); $conn = pg_connect($connstring);
if ($conn ===false) { if ($conn ===false) {
updateStatus("Failed to connect to database: $connstring"); updateStatus("Failed to connect to database: $connstring");
showForm(); showForm();
@ -285,7 +285,7 @@ function pgsql_db_installer($host, $database, $username, $password) {
//wrap in transaction; //wrap in transaction;
pg_query($conn, 'BEGIN'); pg_query($conn, 'BEGIN');
$res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql'); $res = runDbScript(INSTALLDIR.'/db/statusnet_pg.sql', $conn, 'pgsql');
if ($res === false) { if ($res === false) {
updateStatus("Can't run database script.", true); updateStatus("Can't run database script.", true);
showForm(); showForm();
@ -311,9 +311,9 @@ function pgsql_db_installer($host, $database, $username, $password) {
else { else {
$sqlUrl = "pgsql://$username:$password@$host/$database"; $sqlUrl = "pgsql://$username:$password@$host/$database";
} }
$db = array('type' => 'pgsql', 'database' => $sqlUrl); $db = array('type' => 'pgsql', 'database' => $sqlUrl);
return $db; return $db;
} }
@ -353,7 +353,7 @@ function mysql_db_installer($host, $database, $username, $password) {
return false; return false;
} }
} }
$sqlUrl = "mysqli://$username:$password@$host/$database"; $sqlUrl = "mysqli://$username:$password@$host/$database";
$db = array('type' => 'mysql', 'database' => $sqlUrl); $db = array('type' => 'mysql', 'database' => $sqlUrl);
return $db; return $db;
@ -364,22 +364,22 @@ function writeConf($sitename, $server, $path, $fancy, $db)
// assemble configuration file in a string // assemble configuration file in a string
$cfg = "<?php\n". $cfg = "<?php\n".
"if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }\n\n". "if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }\n\n".
// site name // site name
"\$config['site']['name'] = '$sitename';\n\n". "\$config['site']['name'] = '$sitename';\n\n".
// site location // site location
"\$config['site']['server'] = '$server';\n". "\$config['site']['server'] = '$server';\n".
"\$config['site']['path'] = '$path'; \n\n". "\$config['site']['path'] = '$path'; \n\n".
// checks if fancy URLs are enabled // checks if fancy URLs are enabled
($fancy ? "\$config['site']['fancy'] = true;\n\n":''). ($fancy ? "\$config['site']['fancy'] = true;\n\n":'').
// database // database
"\$config['db']['database'] = '{$db['database']}';\n\n". "\$config['db']['database'] = '{$db['database']}';\n\n".
($db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":''). ($db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
"\$config['db']['type'] = '{$db['type']}';\n\n". "\$config['db']['type'] = '{$db['type']}';\n\n".
"?>"; "?>";
// write configuration file out to install directory // write configuration file out to install directory
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg); $res = file_put_contents(INSTALLDIR.'/config.php', $cfg);