📄 ladder_install.php
字号:
<?php
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$output = "<HTML><BODY>";
// Ladder installation routine
switch($HTTP_GET_VARS['code'])
{
case '1':
getInfo();
break;
case '2':
install();
break;
default:
firstPage();
break;
}
$output .= "</BODY></HTML>";
print($output);
function firstPage()
{
global $output;
$output .= "Welcome to the ladder installer page.<BR>\n";
$output .= "<A HREF = \".\\ladder_install.php?code=1\">Start installation!</a><BR>\n";
}
function getInfo() {
global $output;
$output .= "Please enter the pertinant information about your database : This will be more descriptive later.<BR>\n";
$output .= "<form action = \"ladder_install.php?code=2\" method = \"post\">";
$output .= "Host : <input type = \"text\" name = \"hostname\"><BR>\n";
$output .= "Login : <input type = \"text\" name = \"login\"><BR>\n";
$output .= "Password : <input type = \"text\" name = \"password\"><BR>\n";
$output .= "Database : <input type = \"text\" name = \"database\"><BR>\n";
$output .= "<input type = \"submit\" name = \"submit\" value = \"Start Installation\">";
}
function install() {
global $output, $HTTP_POST_VARS;
$require = "conf.php";
require($require);
$CONF['host_name'] = $HTTP_POST_VARS['hostname'];
$CONF['login'] = $HTTP_POST_VARS['login'];
$CONF['password'] = $HTTP_POST_VARS['password'];
$CONF['database'] = $HTTP_POST_VARS['database'];
if ( ! $connect_id = mysql_connect( $CONF['host_name'],$CONF['login'],$CONF['password'] ) )
{
$output .= "Could not create a mySQL connection, please check the SQL values entered";
return;
}
if ( ! mysql_select_db($CONF['database'], $connect_id) )
{
$output .= "mySQL could not locate a database called please check the value entered for this";
return;
}
$fileOutput = "<?php\n"; //php start markup
foreach( $CONF as $k => $v )
{
$fileOutput .= '$CONF['."'".$k."'".']'."\t\t\t=\t'".$v."';\n";
}
$fileOutput .= "\n?>"; //php end markup
if ( $file = fopen( $require, 'w' ) )
{
fputs($file, $fileOutput, strlen($fileOutput) );
fclose($file);
}
else
{
$output .= "Could not write to 'conf_global.php'";
return;
}
$query = "CREATE TABLE users (
name varchar(32) NOT NULL,
rung int(6) NOT NULL ,
PRIMARY KEY (name)
);";
if (! mysql_query($query, $connect_id) )
{
$output .= "MYSQL error";
}
sucessOutput();
}
function sucessOutput()
{
global $output, $connect_id;
$output .= "Sucessfully Installed" ;
$output .= "<BR><A HREF = \"index.php\">Go to the ladder main page</a>";
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -