* Date: 2002-08-20 * Last Update: 2004-08-13 * Copyright: (c) 2001-2004 Thorsten Rinne * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. */ define("VERSION", "1.4.1"); define("COPYRIGHT", "© 2001-2004 phpMyFAQ-Team | All rights reserved."); define("SAFEMODE", @ini_get("safe_mode")); require_once("../inc/constants.php"); function version_check ($ist = "", $soll = "", $err_msg = "") { if (empty($ist) OR empty($soll)) { return FALSE; } $ist = explode(".", $ist); $soll = explode(".", $soll); $num = count($soll); for ($i = 0; $i < $num; $i++) { if ($ist[$i] < $soll[$i]) { return FALSE; } if ($ist[$i] == $soll[$i]) { continue; } if ($ist[$i] >= $soll[$i]) { return TRUE; } } return TRUE; } function mysql_check($version) { return version_check(mysql_get_client_info(), $version); } function php_check($version) { return version_check(phpversion(), $version); } function phpmyfaq_check($file) { if (@include($file)) { include($file); // check for version 1.3.x if ((isset($mysql_server) && $mysql_server != "") || (isset($mysql_user) && $mysql_user != "") || (isset($mysql_passwort) && $mysql_passwort != "") || (isset($mysql_db) && $mysql_db != "")) { return FALSE; } // check for version 1.4.x if ((isset($DB["server"]) && $DB["server"] != "") || (isset($DB["user"]) && $DB["user"] != "") || (isset($DB["password"]) && $DB["password"] != "") || (isset($DB["db"]) && $DB["db"] != "") || (isset($DB["prefix"]) && $DB["prefix"] != "")) { return FALSE; } return TRUE; } return TRUE; } function uninstall() { global $uninst, $db; while ($each_query = each($uninst)) { $result = $db->query($each_query[1]); } } function HTMLFooter() { print "

".COPYRIGHT."

\n\n"; } ?> phpMyFAQ <?php print VERSION; ?> Installation

phpMyFAQ Installation

You need PHP Version 4.1.0 or higher!

\n"; HTMLFooter(); die(); } if (mysql_check("3.23.23") == FALSE) { print "

You need MySQL Version 3.23.23 or higher!

\n"; HTMLFooter(); die(); } if (!phpmyfaq_check("../inc/data.php")) { print "

It seems you already running a version of phpMyFAQ.
Please use the update script.

\n"; HTMLFooter(); die(); } if (!is_dir("../attachments")) { echo realpath('../attachments'); if (!mkdir ("../attachments", 0755)) { print "

The directory ../attachments could not be created.

\n"; HTMLFooter(); die(); } } if (!is_dir("../data")) { if (!mkdir ("../data", 0755)) { print "

The directory ../data could not be created.

\n"; HTMLFooter(); die(); } } if (!is_dir("../pdf")) { if (!mkdir ("../pdf", 0755)) { print "

The directory ../pdf could not be created.

\n"; HTMLFooter(); die(); } } if (!is_writeable("../inc") || !@copy("index.html", "../inc/index.html")) { print "

The directory ../inc is not writeable.

\n"; HTMLFooter(); die(); } if (!is_writeable("../attachments") || !@copy("index.html", "../attachments/index.html")) { print "

The directory ../attachments is not writeable.

\n"; HTMLFooter(); die(); } if (!is_writeable("../data") || !@copy("index.html", "../data/index.html")) { print "

The directory ../data is not writeable.

\n"; HTMLFooter(); die(); } if (!is_writeable("../pdf") || !@copy("index.html", "../pdf/index.html")) { print "

The directory ../pdf is not writeable.

\n"; HTMLFooter(); die(); } if (!is_writeable("../xml") || !@copy("index.html", "../xml/index.html")) { print "

The directory ../xml is not writeable.

\n"; HTMLFooter(); die(); } if (!isset($_POST["database_server"]) AND !isset($_POST["database_user"]) AND !isset($_POST["database_db"])) { ?>

Your PHP version: PHP / Your MySQL client version: MySQL

The PHP safe mode is enabled. Maybe you'll getting problems when phpMyFAQ wants to write in some directories.

\n"; } ?>

You should read the documentation carefully before installing phpMyFAQ.

" method="post">
phpMyFAQ Installation

Database server: ?

Database username: ?

Database password: ?

Database database: ?

Table prefix: ?

Default language: ?

Administrator's real name: ?

Administrator's e-mail address: ?

Administrator's username: admin

Administrator's password: ?

Retype password: ?

Do not use if you're already running a version of phpMyFAQ!

Error: There's no database server input.

\n"; HTMLFooter(); die(); } if (isset($_POST["database_user"]) && $_POST["database_user"] != "") { $database_user = $_POST["database_user"]; } else { print "

Error: There's no database username input.

\n"; HTMLFooter(); die(); } if (isset($_POST["database_passwort"]) && $_POST["database_passwort"] != "") { $database_passwort = $_POST["database_passwort"]; } else { print "

Error: There's no database password input.

\n"; HTMLFooter(); die(); } if (isset($_POST["database_db"]) && $_POST["database_db"] != "") { $database_db = $_POST["database_db"]; } else { print "

Error: There's no database name input.

\n"; HTMLFooter(); die(); } require_once("../inc/mysql.php"); $db = new DB(); if (!($db->connect($database_server, $database_user, $database_passwort, $database_db))) { print "

Error: ".$db->error()."

\n"; HTMLFooter(); $db->close(); die(); } if (isset($_POST["password"]) && $_POST["password"] != "") { $password = $_POST["password"]; } else { print "

Error: There's no password. Please set your password.

\n"; HTMLFooter(); die(); } if (isset($_POST["password_retyped"]) && $_POST["password_retyped"] != "") { $password_retyped = $_POST["password_retyped"]; } else { print "

Error: There's no retyped password. Please set your retyped password.

\n"; HTMLFooter(); die(); } if (strlen($password) <= 5 || strlen($password_retyped) <= 5) { print "

Error: Your password and retyped password are too short. Please set your password and your retyped password with a minimum of 6 characters.

\n"; HTMLFooter(); die(); } if ($password != $password_retyped) { print "

Error: Your password and retyped password are not equal. Please check your password and your retyped password.

\n"; HTMLFooter(); die(); } if (isset($_POST["sqltblpre"]) && $_POST["sqltblpre"] != "") { $sqltblpre = $_POST["sqltblpre"]; } else { $sqltblpre = ""; } if (isset($_POST["language"]) && $_POST["language"] != "") { $language = $_POST["language"]; } else { $language = "en"; } if (isset($_POST["realname"]) && $_POST["realname"] != "") { $realname = $_POST["realname"]; } else { $realname = ""; } if (isset($_POST["email"]) && $_POST["email"] != "") { $email = $_POST["email"]; } else { $email = ""; } /** * Write the DB variables in data.php */ if ($fp = @fopen("../inc/data.php","w")) { @fputs($fp,""); @fclose($fp); } else { print "

Error: Cannot write to data.php.

"; HTMLFooter(); die(); } /** * Create config.php and write the language variables in the file */ if (@file_exists("../inc/config.php")) { print "

A config file was found. Please backup ../inc/config.php and remove the file.

\n"; HTMLFooter(); die(); } if (!@copy("../inc/config.php.original", "../inc/config.php")) { print "

Could not copy the file ../inc/config.php.original to ../inc/config.php.

\n"; HTMLFooter(); die(); } if ($fp = @fopen("../inc/config.php","r")) { $anz = 0; while($dat = fgets($fp,1024)) { $anz++; $inp[$anz] = $dat; } @fclose($fp); for ($h = 1; $h <= $anz; $h++) { if (str_replace("\$PMF_CONF[\"language\"] = \"en\";", "", $inp[$h]) != $inp[$h]) { $inp[$h] = "\$PMF_CONF[\"language\"] = \"".$language."\";\n"; } } if ($fp = @fopen("../inc/config.php","w")) { for ($h = 1; $h <= $anz; $h++) { fputs($fp,$inp[$h]); } @fclose($fp); } else { print "

Cannot write to config.php.

"; HTMLFooter(); die(); } } else { print "

Cannot read config.php.

"; HTMLFooter(); die(); } /** * connect to the database using inc/data.php */ require_once("../inc/data.php"); $db = new DB(); if (!($db->connect($DB["server"], $DB["user"], $DB["password"], $DB["db"]))) { print "

Error: ".$db->error()."

\n"; HTMLFooter(); die(); } $uninst[] = "DROP TABLE ".$sqltblpre."faqadminlog"; $uninst[] = "DROP TABLE ".$sqltblpre."faqadminsessions"; $uninst[] = "DROP TABLE ".$sqltblpre."faqcategories"; $uninst[] = "DROP TABLE ".$sqltblpre."faqchanges"; $uninst[] = "DROP TABLE ".$sqltblpre."faqcomments"; $uninst[] = "DROP TABLE ".$sqltblpre."faqdata"; $uninst[] = "DROP TABLE ".$sqltblpre."faqfragen"; $uninst[] = "DROP TABLE ".$sqltblpre."faqnews"; $uninst[] = "DROP TABLE ".$sqltblpre."faqvoting"; $uninst[] = "DROP TABLE ".$sqltblpre."faqsessions"; $uninst[] = "DROP TABLE ".$sqltblpre."faquser"; $uninst[] = "DROP TABLE ".$sqltblpre."faqvisits"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqadminlog ( id int(11) NOT NULL auto_increment, time int(11) NOT NULL, user int(11) NOT NULL, text text NOT NULL, ip text NOT NULL, PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqadminsessions ( uin varchar(50) BINARY NOT NULL, user tinytext NOT NULL, pass varchar(64) BINARY NOT NULL, ip text NOT NULL, time int(11) NOT NULL)"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqcategories ( id INT(11) NOT NULL AUTO_INCREMENT, lang VARCHAR(5) NOT NULL, parent_id INT(11) NOT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL , PRIMARY KEY (id,lang))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqchanges ( id int(11) NOT NULL auto_increment, beitrag int(11) NOT NULL, lang varchar(5) NOT NULL, user int(11) NOT NULL, datum int(11) NOT NULL, what text NOT NULL, PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqcomments ( id_comment int(11) NOT NULL auto_increment, id int(11) NOT NULL, user varchar(255) NOT NULL, email varchar(255) NOT NULL, comment text NOT NULL, datum int(15) NOT NULL, helped text NOT NULL, PRIMARY KEY (id_comment))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqdata ( id int(11) NOT NULL auto_increment, lang varchar(5) NOT NULL, active char(3) NOT NULL, rubrik text NOT NULL, keywords text NOT NULL, thema text NOT NULL, content text NOT NULL, author varchar(255) NOT NULL, email varchar(255) NOT NULL, comment enum('y','n') NOT NULL default 'y', datum varchar(15) NOT NULL, FULLTEXT (keywords,thema,content), PRIMARY KEY (id, lang))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqfragen ( id int(11) unsigned NOT NULL auto_increment, ask_username varchar(100) NOT NULL, ask_usermail varchar(100) NOT NULL, ask_rubrik varchar(100) NOT NULL, ask_content text NOT NULL, ask_date varchar(20) NOT NULL, PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqnews ( id int(11) NOT NULL auto_increment, header varchar(255) NOT NULL, artikel text NOT NULL, datum varchar(14) NOT NULL, link varchar(255) NOT NULL, linktitel varchar(255) NOT NULL, target varchar(255) NOT NULL, PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqvoting ( id int(11) unsigned NOT NULL auto_increment, artikel int(11) unsigned NOT NULL, vote int(11) unsigned NOT NULL, user int(11) unsigned NOT NULL, datum varchar(20) NOT NULL default '', ip varchar(15) NOT NULL default '', PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqsessions ( sid int(11) NOT NULL auto_increment, ip text NOT NULL, time int(11) NOT NULL, PRIMARY KEY sid (sid))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faquser ( id int(2) NOT NULL auto_increment, name text NOT NULL, pass varchar(64) BINARY NOT NULL, realname varchar(255) NOT NULL default '', email varchar(255) NOT NULL default '', rights varchar(255) NOT NULL, PRIMARY KEY (id))"; $query[] = "CREATE TABLE IF NOT EXISTS ".$sqltblpre."faqvisits ( id int(11) NOT NULL auto_increment, lang varchar(5) NOT NULL, visits int(11) NOT NULL, last_visit int(15) NOT NULL, PRIMARY KEY (id, lang))"; $query[] = "INSERT INTO ".$sqltblpre."faquser (id, name, pass, realname, email, rights) VALUES (1, 'admin', MD5('".$password."'), '".$realname."', '".$email."', '1111111111111111111111')"; print "

"; while ($each_query = each($query)) { $result = $db->query($each_query[1]); print "| "; if (!$result) { print "

Error: Please install your version of phpMyFAQ once again or send us a bug report.
MySQL error: ".$db->error()."

/n"; uninstall(); HTMLFooter(); die(); } usleep(250); } print "

\n"; print "

All tables were created and filled with the data.

\n"; print "

Congratulation! Everything seems to be okay.

\n"; print "

You can visit your version of phpMyFAQ or

\n"; print "

login into your admin section.

\n"; if (@unlink(basename($_SERVER["PHP_SELF"]))) { print "

This file was deleted automatically.

\n"; } else { print "

Please delete this file manually.

\n"; } if (@unlink(dirname($_SERVER["PATH_TRANSLATED"])."/update.php")) { print "

The file 'update.php' was deleted automatically.

\n"; } else { print "

Please delete the file 'update.php' manually.

\n"; } HTMLFooter(); } ?>