<?php
/**
* STRESS WEB
* @author Aleksey Khalyapov
* @copyright 2008 - 2010 STRESS WEB
* @version 9.0.1
* @web http://stress-web.ru
*/
define("SW", "9.0.1");
/**
* =========================
* Template
* =========================
*/
function parse_template($action, $description, $content, $button1, $button2, $status = "")
{
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Мастер установки продукта STRESS WEB</title>
<link rel="stylesheet" type="text/css" href="install/css.css" />
<script type="text/javascript">
function checK(f)
{
if (!f.license_true.checked)
{
alert("Вы должны принять пользовательское Соглашение перед началом установки!");
return false;
}
return true;
}
</script>
</head>
<body>
<center>
<p> </p>
<p> </p>
<form action="" method="post" name="install" onsubmit="return checK(this)">
<table width="620" cellpadding="0" cellspacing="0" class="ins_tab">
<tr>
<td class="header"><center>Установщик продукта STRESS WEB</center></td>
</tr>
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0" class="cont_tab">
<tr>
<td width="160" valign="top"><div style="text-align: center; color: white;"><br><br><b>' . $action . '</b><div></td>
<td width="450" valign="top">
<div class="content1"><img src="install/images/sw.png" align="left"> <h1>Установка <a href="http://stress-web.ru" target="_blank" style="text-decoration:none; color: green;">STRESS WEB</a> ' . SW . '</h1><hr><br></div>
<div class="content2"><center><font color=blue><b>' . $description . '</b></font></center><br>
<div class="content3">' . $content . '</div>' . $status . '
</div>
</td>
</tr>
<tr>
<td valign="top">' . $button1 . '</td>
<td align="right" valign="top">' . $button2 . '<br><br> <span style="font-size: 9px;">© 2008-2010 STRESS WEB</span></td>
</tr>
</table>
</td>
</tr>
</table></form>
</center>
</body>
</html>';
}
/**
* =========================
* Already Installed???
* =========================
*/
if (file_exists("ajax/lock.php"))
die('<div>Внимание, на сервере обнаружена уже установленная копия продукта STRESS WEB. Если вы хотите еще раз произвести установку системы, то вам необходимо вручную удалить файл <b>ajax/lock.php</b>, используя FTP протокол.<br /><br /><a href="install.php">Обновить</a></div>');
/**
* =========================
* License
* =========================
*/
if ($_POST['action'] == "license")
{
$_action = "Шаг - 2<br><br>Лицензия";
$_description = "Пожалуйста прочитайте и примите пользовательское соглашение.";
ob_start();
echo "<div style='background: #999999;'>" . file_get_contents("install/license.lic") . "</div><input type='hidden' value='chmod_check' name='action'>";
$_content = ob_get_contents();
ob_end_clean();
$_status = "<input type='checkbox' name='license_true'> <b>Я принимаю соглашение</b>";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = '<input type="submit" value="Дальше >" style="background: transparent; border: 1px solid; color: white;">';
parse_template($_action, $_description, $_content, $_button1, $_button2, $_status);
}
/**
* =========================
* CHMOD
* =========================
*/ elseif ($_POST['action'] == "chmod_check")
{
$important_files = array(
'./ajax/',
'./ajax/data.php'
);
$_action = "Шаг - 3<br><br>Директории";
$_description = "Проверка CHMOD файлов";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = '<input type="submit" value="Дальше >" style="background: transparent; border: 1px solid; color: white;">';
$_content = "<table width='100%'>
<tr>
<td height='25'> <b>Папка/Файл</b></td>
<td width='60' height='25'> <b>CHMOD</b></td>
<td width='100' height='25'> <b>Статус</b></td>
</tr>";
$chmod_errors = 0;
$not_found_errors = 0;
foreach ($important_files as $file)
{
if (!file_exists($file))
{
$file_status = "<font color=red>не найден!</font>";
$not_found_errors++;
} elseif (is_writable($file))
{
$file_status = "<font color=green>разрешено</font>";
}
else
{
@chmod($file, 0777);
if (is_writable($file))
{
$file_status = "<font color=green>разрешено</font>";
}
else
{
@chmod("$file", 0755);
if (is_writable($file))
{
$file_status = "<font color=green>разрешено</font>";
}
else
{
$file_status = "<font color=red>запрещено</font>";
$chmod_errors++;
}
}
}
$chmod_value = @decoct(@fileperms($file)) % 1000;
$_content .= "
<tr>
<td height='22'> $file</td>
<td> $chmod_value</td>
<td> $file_status</td>
</tr>";
}
if ($chmod_errors == 0 and $not_found_errors == 0)
{
$status_report = '<span style="color: green;">Проверка успешно завершена! Можете продолжить установку!</span>';
}
else
{
if ($chmod_errors > 0)
{
$status_report = "<font color=red>Внимание!!!</font><br /><br />Во время проверки обнаружены ошибки: <b>$chmod_errors</b>. Запрещена запись в файл.<br />Вы должны выставить для папок CHMOD 777, для файлов CHMOD 666, используя ФТП-клиент.<br /><br /><font color=red><b>Настоятельно не рекомендуется</b></font> продолжать установку, пока не будут произведены изменения.<br />";
}
if ($not_found_errors > 0)
{
$status_report .= "<font color=red>Внимание!!!</font><br />Во время проверки обнаружены ошибки: <b>$not_found_errors</b>. Файлы не найдены!<br /><br /><font color=red><b>Не рекомендуется</b></font> продолжать установку, пока не будут произведены изменения.<br />";
}
}
$_content .= "
<tr>
<td height='25' colspan=3> Состояние проверки</td>
</tr>
<tr>
<td style='padding: 5px' colspan='3'>$status_report</td>
</tr>
</table><input type=hidden name='action' value='doconfig'></form>";
parse_template($_action, $_description, $_content, $_button1, $_button2);
}
/**
* =========================
* Config Form
* =========================
*/ elseif ($_POST['action'] == "doconfig")
{
$_action = "Шаг - 4<br><br>База данных";
$_description = "Если вы не уверены или не знаете данных, необходимых для данного шага, уточните у вашего хостинг провайдера...";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = '<input type="submit" value="Дальше >" style="background: transparent; border: 1px solid; color: white;">';
$_content = '
<table>
<tr><td colspan="2" height="25" width="430"> <b>Сервер Базы Данных хостинга (БД)</b></td></tr>
<tr><td style="padding: 5px;" width="200">Адрес сервера:</td><td style="padding: 5px;"><input type=text size="28" name="dbhost" value="localhost" id="dbhost"></td></tr>
<tr><td style="padding: 5px;">Имя базы данных:</td><td style="padding: 5px;"><input type=text size="28" name="dbname" value="" id="dbname"></td></tr>
<tr><td style="padding: 5px;">Пользователь БД:</td><td style="padding: 5px;"><input type=text size="28" name="dbuser" value="" id="dbuser"></td></tr>
<tr><td style="padding: 5px;">Пароль БД:</td><td style="padding: 5px;"><input type=password size="28" name="dbpass" id="dbpass"></td></tr>
<tr><td style="padding: 5px;">Кодировка MySQL:<br><span style="font-size: 9px; color: red;">Не изменяйте параметр, если не знаете для чего он предназначен</span></td><td style="padding: 5px;"><input type=text size="28" name="dbcollate" value="cp1251"></td></tr>
</table><input type=hidden name="action" value="doadmin">
<script type="text/javascript" src="install/mysql.test.js"></script>
<div id="mysql_mess"></div>
<input type="button" name="mysql_test" value="Проверить соединение" onclick="javascript: mysqltest();">';
parse_template($_action, $_description, $_content, $_button1, $_button2);
}
/**
* =========================
* Administrator
* =========================
*/ elseif ($_POST['action'] == "doadmin")
{
$_action = "Шаг - 5<br><br>Учетная запись";
$_description = "Учетная запись Администратора";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = '<input type="submit" value="Дальше >" style="background: transparent; border: 1px solid; color: white;">';
$_content = '
<table>
<tr><td colspan="2" height="40" width="430"> <b>Учетная запись Администратора</b></td></tr>
<tr><td style="padding: 5px;" width="200">Имя пользователя:</td><td style="padding: 5px;"><input type=text size="28" name="admlogin" ></td></tr>
<tr><td style="padding: 5px;" width="200">Пароль:</td><td style="padding: 5px;"><input type=password size="28" name="admpass" ></td></tr>
</table>
<input type=hidden name="action" value="doinstall">
<input type=hidden name="dbhost" value="' . $_POST['dbhost'] . '">
<input type=hidden name="dbuser" value="' . $_POST['dbuser'] . '">
<input type=hidden name="dbpass" value="' . $_POST['dbpass'] . '">
<input type=hidden name="dbname" value="' . $_POST['dbname'] . '">
<input type=hidden name="dbcollate" value="'.$_POST['dbcollate'].'">';
parse_template($_action, $_description, $_content, $_button1, $_button2);
}
/**
* =========================
* Install
* =========================
*/ elseif ($_POST['action'] == "doinstall")
{
define("DBHOST", $_POST['dbhost']);
define("DBUSER", $_POST['dbuser']);
define("DBPASS", $_POST['dbpass']);
define("DBNAME", $_POST['dbname']);
define("COLLATE", $_POST['dbcollate']);
$_admlogin = $_POST['admlogin'];
$_admpass = md5($_POST['admpass']);
$database_config = "<" . "?php
/**
* STRESS WEB
* @author Aleksey Khalyapov (Monaxxx)
* @copyright 2008 - 2010 STRESS WEB
* @version " . SW . "
* @web http://stress-web.ru
*/
defined('SOLT') or die('Сюда нельзя!');
define(\"DBHOST\",\"" . DBHOST . "\");
define(\"DBUSER\",\"" . DBUSER . "\");
define(\"DBPASS\",\"" . DBPASS . "\");
define(\"DBNAME\",\"" . DBNAME . "\");
define(\"COLLATE\",\"" . COLLATE . "\");
?" . ">";
$con_file = fopen("./ajax/data.php", "w+");
if (!$con_file)
{
$_action = "Шаг - 6<br><br>Установка";
$_description = "Ошибка установки";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = "";
$_content = '<font color=red><b>Извините, но невозможно создать файл <b>.inc/congig/data.php</b>.<br />Проверьте правильность проставленного CHMOD</b></font>';
parse_template($_action, $_description, $_content, $_button1, $_button2);
exit;
}
fwrite($con_file, $database_config);
fclose($con_file);
@chmod("./ajax/data.php", 0666);
$lock = fopen("./ajax/lock.php", "w+");
fwrite($lock,"LOCKED");
fclose($lock);
@chmod("./ajax/lock.php", 0666);
$table = array();
$table[] = "INSERT INTO `l2_adminlist` SET user='{$_admlogin}' , pass='{$_admpass}', status='unlock' ";
$link = @mysql_connect(DBHOST, DBUSER, DBPASS);
$db = @mysql_select_db(DBNAME, $link);
if (!$link || !$db)
{
$_action = "Шаг - 6<br><br>Установка";
$_description = "Ошибка установки";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = "";
$_content = '<font color=red><b>Невозможно подключиться к MySQL серверу или выбрать базу данных MySQL.</b></font>';
parse_template($_action, $_description, $_content, $_button1, $_button2);
exit;
}
@mysql_query("/*!40101 SET NAMES '" . COLLATE . "' */");
foreach ($table as $dbtable)
{
@mysql_query($dbtable);
}
$_action = "Шаг - 6<br><br>Установка";
$_description = "Завершение установки";
$_button1 = "";
$_button2 = "";
$_content = '<font color=green><b>Поздравляем! Установка завершена.</b></font><br><br>Пройдите в <a href="./admin">Панель Администратора</a> для дальнейшей настройки сайта.<br><br><b><font color=red>Для безопасности рекомендуем удалить файл <font color=blue>install.php</font>, а также папку</font> <font color=blue>./install</font></b>';
parse_template($_action, $_description, $_content, $_button1, $_button2);
}
/**
* =========================
* Start Page
* =========================
*/
else
{
$_action = "Шаг - 1<br><br>Требования";
$_description = "Вас приветствует установщик STRESS WEB. Данный мастер поможет вам установить новую версию продукта.";
$_content = "<br><br><b>Системные требования:</b><br /><b>Zend Optimizer:</b> v3.3.0<br><b>PHP:</b> v5.0.0 или выше<br><b>SQL:</b> mySQL v5.0.0 или выше<br><b>Библиотека:</b> GD 2.0 или выше<input type='hidden' value='license' name='action'>";
$_button1 = '<input type="button" value="Прекратить" onclick="location.href=\'install.php\'" style="background: transparent; border: 1px solid; color: white;">';
$_button2 = '<input type="submit" value="Начать установку" style="background: transparent; border: 1px solid; color: white;">';
parse_template($_action, $_description, $_content, $_button1, $_button2);
}
?>