Location: PHPKode > projects > PhpScribe Documentation Generator > install.php
<?php
//------------------------------------------------------------------
// save the user's settings
//------------------------------------------------------------------
function saveSettings() {
     $out = "<?\n";
     while(list($key,$value)=each($_POST)) {
          if (!ereg("btn",$key)) {
               $value = ($value == "1" ? "TRUE" : ($value == "0" ? "FALSE" : "\"".str_replace("\\\\","/",$value)."\""));
               $out .= "\$PS_USER_CFG['".$key."']=".$value.";\n";
               $GLOBALS['PS_USER_CFG'][$key] = str_replace("\\\\","/",$_POST[$key]);
          }
     }
     $out .= "\$PS_USER_CFG['CAPTURE_ERRORS']=TRUE;\n";
     $out .= "\$PS_USER_CFG['LOG_ERRORS']=TRUE;\n";
     $out .= "\$PS_USER_CFG['SHOW_ERRORS']=TRUE;\n";
     $out .= "?>\n";
     if (!$fp = @fopen("config/user.cfg","wb")) {
          echo "<TR HEIGHT='40'><TD WIDTH='15'>&nbsp;</TD><TD COLSPAN='3' CLASS='bignormal'><FONT COLOR='#ff0000'><B>Couldn't open settings file to write! ('config/user.cfg') Check file permissions!</B></FONT></TD></TR>";
     } else {
          fputs($fp,$out);
          fclose($fp);
          echo "<TR HEIGHT='40'><TD WIDTH='15'>&nbsp;</TD><TD COLSPAN='3' CLASS='bignormal'><FONT COLOR='#ff0000'><B>Settings successfully updated...</B></FONT></TD>";
     }
}

//------------------------------------------------------------------
// normal execution of the page
//------------------------------------------------------------------
@include_once("config/user.cfg");
@include_once("errorHandler.inc");
@include_once("dbinstall.php");
@set_time_limit(0);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>:::: p h p S c r i b e ::::</TITLE><META NAME="TITLE" CONTENT=":::: p h p S c r i b e ::::">
<META NAME="AUTHOR" CONTENT="Marcos Pont">
<META NAME="DESCRIPTION" CONTENT="">
<META NAME="KEYWORDS" CONTENT="">
<META NAME="GENERATOR" CONTENT="PHP2Go Web Development Framework">
<META NAME="IDENTIFIER-URL" CONTENT="http://mpont.homedns.org/phpscribe">
<META NAME="DATE-CREATION-ddmmyyyy" CONTENT="11/06/2002">
<META NAME="CATEGORY" CONTENT="Outros">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<LINK REL='stylesheet' type='text/css' HREF='resources/stylesheet/phpscribe.css'>
<SCRIPT LANGUAGE='JavaScript' SRC='resources/javascript/empty.js'></SCRIPT>
<SCRIPT>
function checkFormInstall()
{
     var msg = "";
     if (isEmpty("install","GLOBAL_PATH")) {
          msg = msg + "The field named GLOBAL_PATH is mandatory!\n";
     }
     if (isEmpty("install","ABSOLUTE_PATH")) {
          msg = msg + "The field named ABSOLUTE_PATH is mandatory!\n";
     }
     if (isEmpty("install","DATABASE_HOST")) {
          msg = msg + "The field named DATABASE_HOST is mandatory!\n";
     }
     if (isEmpty("install","DATABASE_USER")) {
          msg = msg + "The field named DATABASE_USER is mandatory!\n";
     }
     if (isEmpty("install","DATABASE_BASE")) {
          msg = msg + "The field named DATABASE_BASE is mandatory!\n";
     }
     if (msg != "") {
          alert(msg);
          return false;
     } else {
          document.install.submit();
     }
}
</SCRIPT>
</HEAD>
<BODY LEFTMARGIN='0' TOPMARGIN='0' MARGINWIDTH='0' MARGINHEIGHT='0' bgColor='#d6d6d6'>
<A NAME='top'></A>
<BR>
<TABLE WIDTH='604' ALIGN='center' CELLPADDING='0' CELLSPACING='0' BORDER='1' BORDERCOLOR='#006699'>
<TR BGCOLOR='#006699'>
 <TD CLASS='whiteheading'>&nbsp;phpScribe Installer</TD>
 <TD CLASS='whiteheadingminor' ALIGN='right'><A HREF='#step1' CLASS='whiteheadingminor'>Step 1</A>&nbsp;&nbsp;|&nbsp;&nbsp;<A HREF='#step2' CLASS='whiteheadingminor'>Step 2</A>&nbsp;</TD>
</TR>
</TABLE>
<TABLE WIDTH='600' ALIGN='center' CELLPADDING='0' CELLSPACING='0' BORDER='1' BORDERCOLOR='#006699'>
<TR><TD ALIGN='center'><A NAME='step1'>
<TABLE WIDTH='600' CELLPADDING='3' CELLSPACING='0' BORDER='0'>
<FORM NAME='install' ACTION='install.php' METHOD='post'>
<?
// Salva alterações se elas existem
if (isset($_POST['GLOBAL_PATH'])) {
     saveSettings();
}
// Verificação do banco
if ($_GET['test'] == "db") {
     verifyDB();
}
// Atualização de versão do banco
if (isset($_POST['update'])) {
	$updateValues = explode("|", $_POST['update']);
	updateDB($updateValues[0], $updateValues[1]);
}
?>
<TR>
<TD WIDTH='15'></A></TD>
<TD CLASS='bignormal'><BR>Step 1: phpScribe Settings</TD>
<TD ALIGN='right'><BR><A HREF='index.php' CLASS='normalblue'>Home</A> | <A HREF='#top' CLASS='normalblue'>Top</A></TD>
<TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR>
<TD WIDTH='15'>&nbsp;</TD>
<TD COLSPAN='2'>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Type in the path of phpScribe in the web server:<BR>(e.g.: /home/httpd/html/, /var/www/html/)</SPAN><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><INPUT TYPE='text' NAME='GLOBAL_PATH' <?if (isset($PS_USER_CFG['GLOBAL_PATH'])) echo "VALUE='".$PS_USER_CFG['GLOBAL_PATH']."'";?> SIZE='60' MAXLENGTH='60'><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Type in the path of phpScribe to use as the url location:<BR>(e.g.: http://www.mydomain.com/myproject)</SPAN><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><INPUT TYPE='text' NAME='ABSOLUTE_PATH' SIZE='60' MAXLENGTH='60' <?if (isset($PS_USER_CFG['ABSOLUTE_PATH'])) echo "VALUE='".$PS_USER_CFG['ABSOLUTE_PATH']."'";?>><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Type your mySQL access information:</SPAN><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Host</SPAN><BR><INPUT TYPE='text' NAME='DATABASE_HOST' SIZE='60' MAXLENGTH='60' <?if (isset($PS_USER_CFG['DATABASE_HOST'])) echo "VALUE='".$PS_USER_CFG['DATABASE_HOST']."'";?>><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Username</SPAN><BR><INPUT TYPE='text' NAME='DATABASE_USER' SIZE='20' MAXLENGTH='20' <?if (isset($PS_USER_CFG['DATABASE_USER'])) echo "VALUE='".$PS_USER_CFG['DATABASE_USER']."'";?>><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Password</SPAN><BR><INPUT TYPE='password' NAME='DATABASE_PASS' SIZE='16' MAXLENGTH='16' <?if (isset($PS_USER_CFG['DATABASE_PASS'])) echo "VALUE='".$PS_USER_CFG['DATABASE_PASS']."'";?>><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>Database</SPAN><BR><INPUT TYPE='text' NAME='DATABASE_BASE' SIZE='20' MAXLENGTH='20' <?if (isset($PS_USER_CFG['DATABASE_BASE'])) echo "VALUE='".$PS_USER_CFG['DATABASE_BASE']."'";?>><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><SPAN CLASS='normal'>DB Type (default mySQL)</SPAN><BR><INPUT TYPE='text' NAME='DATABASE_TYPE' SIZE='10' MAXLENGTH='10' <?if (isset($PS_USER_CFG['DATABASE_TYPE'])) echo "VALUE='".$PS_USER_CFG['DATABASE_TYPE']."'"; else echo "VALUE='mysql'"?> READONLY><BR><BR>
<IMG SRC='resources/image/spacer.gif' WIDTH='1' HEIGHT='25'><INPUT TYPE='button' NAME='btn_install' VALUE='Save Settings' onClick='checkFormInstall();'>
<?
?>
</TD>
<TD WIDTH='15'>&nbsp;</TD>
</FORM>
</TR>
<TR>
 <TD COLSPAN='4' HEIGHT='40' VALIGN='bottom'><HR NOSHADE COLOR='#006699' SIZE='2'><A NAME='step2'></A></TD>
</TR>
<TR>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD CLASS='bignormal'><BR>Step 2: Database Creation</TD>
 <TD ALIGN='right'><BR><A HREF='index.php' CLASS='normalblue'>Home</A> | <A HREF='#top' CLASS='normalblue'>Top</A></TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='40'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2' CLASS='bignormal' VALIGN='bottom'><B>»</B> First Installation</TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='30'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2'>&nbsp;&nbsp;&nbsp;<A HREF='sql/phpscribe.zip' CLASS='normal'>Click here to download phpScribe's database creation script</A></TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='30'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2' CLASS='bignormal' VALIGN='bottom'><B>»</B> Update from older versions</TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='60'>
 <FORM NAME='dbinstall' ACTION='install.php' METHOD='POST'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2'>
  &nbsp;&nbsp;&nbsp;<SPAN CLASS='normal'>If you had already installed phpScribe on this server,<BR>&nbsp;&nbsp;&nbsp;please choose the version in the list below and click 'Update Database'</SPAN><BR><BR>
  &nbsp;&nbsp;&nbsp;<SELECT NAME='update'>
   <OPTION VALUE='0.3|0.9'>phpScribe 0.1</OPTION>
   <OPTION VALUE='0.3|0.9'>phpScribe 0.2</OPTION>
   <OPTION VALUE='0.3|0.9'>phpScribe 0.3</OPTION>
   <OPTION VALUE='0.5|0.9'>phpScribe 0.5</OPTION>
   <OPTION VALUE='0.6|0.9'>phpScribe 0.6</OPTION>
   <OPTION VALUE='0.8|0.9'>phpScribe 0.8</OPTION>
  </SELECT>&nbsp;
  <INPUT TYPE='submit' NAME='btn_db' VALUE='Update Database'>
 </TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='30'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2' CLASS='bignormal' VALIGN='bottom'><B>»</B> Verify Database</TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
<TR HEIGHT='30'>
 <TD WIDTH='15'>&nbsp;</TD>
 <TD COLSPAN='2'>&nbsp;&nbsp;&nbsp;<A HREF='install.php?test=db' CLASS='normal'>Click here to verify if your phpScribe's database is ready to use</A></TD>
 <TD WIDTH='15'>&nbsp;</TD>
</TR>
</TABLE>
</TD></TR>
</TABLE>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
</BODY>
</HTML>
Return current item: PhpScribe Documentation Generator