Location: PHPKode > projects > OpenSupports > support/install2.php
<?php
//Verification ***************************************************************************************
if(!isset($_GET[title]))
{
    header('Location: index.php');
}
else
{
    $titulo = $_GET[title];
    $direccionsoporte = "/".basename(getcwd())."/";
    $mailprincipal = $_GET[mail];
    $adminuser = $_GET[admin];
    $adminpass = $_GET[adminpass];
    $servidor = $_GET[server];
    $serveruser = $_GET[server_user];
    $serverpass = $_GET[server_pass];
    $bd = $_GET[db];
    $servidor_ftp = $_GET[ftp_server];
    $ftp_usuario = $_GET[ftp_user];
    $ftp_clave = $_GET[ftp_pass];
    $filemax = $_GET[ftp_max] * 1024;
    $connect = @mysql_connect($servidor,$serveruser,$serverpass);
    if(strlen($titulo) < 3 || strlen($mailprincipal) < 8 || strlen($adminuser) < 2 || strlen($adminpass) < 2)
    {
        header('Location: install.php?err=len');
    }
    elseif(!$connect)
    {
        header('Location: install.php?err=mysql');
    }
    elseif(!mysql_select_db($bd))
    {
        header('Location: install.php?err=db');
    }
    else
    {
//Make info.php ***************************************************************************************

$info = fopen("info.php", "w+");

//Edit info.php ***************************************************************************************

$content = "
<?php
//Site Name
$"."titulo = '$titulo';
//Support Direction.
$"."direccionsoporte = '$direccionsoporte';
//No-reply email
$"."mailprincipal = '$mailprincipal';

//Admin user
$"."adminuser = '$adminuser';
//Admin password
$"."adminpass = '$adminpass';

//Database Server
$"."servidor = '$servidor';
//Database User
$"."serveruser = '$serveruser';
//Database Password
$"."serverpass = '$serverpass';
//Database Name
$"."bd = '$bd';

//FTP Server
$"."servidor_ftp = '$servidor_ftp';
//FTP User
$"."ftp_usuario = '$ftp_usuario';
//FTP Password
$"."ftp_clave = '$ftp_clave';
//Maximum Filisize
$"."filemax = $filemax;
?>
";
fwrite($info,$content);
fclose($info);

//Tables Creation ***************************************************************************************

require "config.php";
//Tickets Table
$sql = "CREATE TABLE `" . $bd . "` .`tickets` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`user` TINYTEXT NOT NULL ,
`contenido` TEXT NOT NULL ,
`fecha` TINYTEXT NOT NULL ,
`ultimo` TINYTEXT NOT NULL ,
`departamento` TINYTEXT NOT NULL ,
`asunto` TINYTEXT NOT NULL ,
`leido` INT( 1 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql, $conexion);

//Users table
$sql2 = "CREATE TABLE `" . $bd . "` .`usuarios` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`nombre` TINYTEXT NOT NULL ,
`user` TINYTEXT NOT NULL ,
`pass` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql2, $conexion);

//Captcha table
$sql4 = "CREATE TABLE `" . $bd . "`.`code` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`valor` TINYTEXT NOT NULL ,
`img` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql4, $conexion);

//Departments table
$sql5 = "CREATE TABLE `" . $bd . "`.`departamentos` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`departamento` TINYTEXT NOT NULL ,
`staff` TEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql5, $conexion);

//Articles table
$sql6 = "CREATE TABLE `" . $bd . "`.`guias` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`user` TINYTEXT NOT NULL ,
`file` TINYTEXT NOT NULL ,
`asunto` TINYTEXT NOT NULL ,
`contenido` TEXT NOT NULL ,
`fecha` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql6, $conexion);
//"Comentariostickets" table, a table for the user comments.
$sql7 = "CREATE TABLE `" . $bd . "`.`comentariostickets` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`idticket` INT( 11 ) NOT NULL ,
`fecha` TINYTEXT NOT NULL ,
`autor` TINYTEXT NOT NULL ,
`contenido` TEXT NOT NULL ,
`staff` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql7, $conexion);
//"Comentariosarticulos" table, other table for comments. This is for articles
$sql7 = "CREATE TABLE `" . $bd . "`.`comentariosarticulos` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`idarticulo` INT( 11 ) NOT NULL ,
`fecha` TINYTEXT NOT NULL ,
`autor` TINYTEXT NOT NULL ,
`contenido` TEXT NOT NULL ,
`staff` TINYTEXT NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql7, $conexion);
//Staff table
$sql8 = "CREATE TABLE `" . $bd . "`.`staff` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`name` TINYTEXT NOT NULL ,
`user` TINYTEXT NOT NULL ,
`pass` TINYTEXT NOT NULL ,
`email` TINYTEXT NOT NULL ,
`articulo` binary( 1 ) NOT NULL ,
`ban` binary( 1 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
`ultima` TINYTEXT NOT NULL ,
INDEX ( `id` )
) ENGINE = MYISAM";
mysql_db_query($bd, $sql8, $conexion) or die ("Error database");
echo "*The database tables have been created.";
$crearimgs = mysql_query("INSERT INTO code (`id`, `valor`, `img`) VALUES ('1','A4VT6','1.bmp'),('2','7Q9P4','2.bmp'),('3','3B5X7','3.bmp'),('4','P7SA2','4.bmp'), ('5','G1T8X7','5.bmp'),('6','W6VDS','6.bmp'),('7','L6WED','7.bmp'),('8','H3N57','8.bmp'),('9','P8QL3','9.bmp'),('10','ZQ776','10.bmp')") or die ("Error on the captcha:<br>*Opensupports can't access to the database or can not write information");

//Send email ****************************************************************************
$sendTo = $mailprincipal;
$subject = "Support Center - " . $titulo;
$headers = "From: ";
$headers .= "<" . $mailprincipal . ">\r\n";
$headers .= "Reply-To: " . $mailprincipal; 
$message =   "Hello,\nYour support center of " . $titulo . " has been created.\n \n You admin login is:\n Admin: " . $adminuser . "\n Password: " . $adminuser . "\n \n Plase to login as an admin go to: " . $url . "/admin \n If you want to learn how to use or develop OpenSupports,  please visit: http://www.opensupports.com/wiki \n If you have problems, bugs, questions, etc. Plase visit: http://www.opensupports.com/forum. \n\n Remember visit or suscribe to OpenSupports.com for updates.";
mail($sendTo, $subject, $message, $headers);

//Delete this file ***************************************************************************************
unlink("install.php");  
unlink("install2.php");  
echo "<br><br>The installation has been completed and the install files have been deleted.";
    }
}
?>
Return current item: OpenSupports