Файл: install/index.php
Строк: 143
<?php
$act = isset($_GET['act']) ? htmlspecialchars($_GET['act']) : '';
echo '
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="http://'.$_SERVER['HTTP_HOST'].'/styles.css" rel="stylesheet" type="text/css">
<link href="http://'.$_SERVER['HTTP_HOST'].'/favicon.ico" rel="shortcut icon">
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>';
echo'<title> Установка '.$_SERVER['HTTP_HOST'].'</title></head>';
echo '<body>';
echo'<div id="content">';
echo'<div id="logo"> <h1><a href="http://megcms.ru" id="metamorph"><span style="font-size:20px"><span style="font-weight: bold"><span style="color:red">Meg</span>CMS.<span style="color:red">Ru</span></span></span></a></h1>
<h2><span style="font-weight: bold"><span style="color:red">Meg</span>CMS</span> - система управления контентом</h2> </div> <div id="main"><div id="main2"> <div id="main3"> ';
echo' <div id="cent"> <div id="st11">';
echo'<div class="st1">';
echo'<h2 class="title"></h2>';
echo'<div class="small_back"><div class="back">';
echo' </div> </div></div>';
echo' </div>';
echo '<div id="st21">';
echo '<div class="st2"><h2 class="title">';
echo '<a href = "#">Добро пожаловать!</a></span></h2> <div class="middle_back">';
switch($act)
{
default:
echo'<big><b>Сейчас мы произведем установку <span style="color:red">Meg</span>Cms v1.0.0</b></big><br /><br /><br />';
echo'Проверяем существуют ли нужные папки и файлы, а так же проверяем атрибуты (chmod) этих файлов:<br /><br />';
$arrfile = array(
'Cache',
'Sys/connect.php',
'imgfile'
);
$error = '';
foreach ($arrfile as $file) {
$realfile = '../'.$file;
if (!file_exists($realfile)) {
$file_status = '<span style="color:red">Не найден!</span>';
$error .= 'Файлы не найдены<br/>';
} elseif (is_writable($realfile)) {
$file_status = '<span style="color:green">ОК</span>';
} else {
@chmod($realfile, 0777);
if (is_writable($realfile)) {
$file_status = '<span style="color:green">ОК</span>';
} else {
@chmod($realfile, 0755);
if (is_writable($realfile)) {
$file_status = '<span style="color:green">Разрешено</span>';
} else {
$file_status = '<span style="color:red">Запрещено</span>';
$error .= 'Выставить атрибуты автоматически не удается<br/> Выставите атрибуты разрешающие производить запись (chmod) на файлы и папки в которые выделены красным.<br /> Обычно для файлов это <b>666</b>, для папок <b>777</b>.<br /><br />';
}
}
}
$value = @decoct(@fileperms($realfile)) % 1000;
echo '<b>'.$file . '</b> <b> - ' . $file_status . '</b> (chmod 0' . $value . ')<br />';
}
if(!empty($error))
{
echo '<br /><br /><b><big>Выявлены ошибки:</big></b><br/>';
echo $error;
echo'<br />Для продолжения исправьте ошибки';
}
else
{ echo'<br /><br /><form action="http://'.$_SERVER['HTTP_HOST'].'/install/index.php?act=1" name="post" method="post"> ';
echo'<input type="submit" class="button" value="Продолжить" />
</form>';
}
break;
case '1':
if(isset($_POST['ok']))
{
if (empty($_POST['dbhost']) OR empty($_POST['dbname']) OR empty($_POST['dbuser'])) {
echo'<span style="color:red">Заполните все данные!</span>';
}
else{
$dbhost = htmlspecialchars(trim($_POST['dbhost']));
$dbname = htmlspecialchars(trim($_POST['dbname']));
$dbuser = htmlspecialchars(trim($_POST['dbuser']));
$dbpass = htmlspecialchars(trim($_POST['dbpass']));
$mysqli = new mysqli(''.$dbhost.'', ''.$dbuser.'', ''.$dbpass.'', ''.$dbname.'');
$mysqli->query("SET NAMES utf8");
if(mysqli_connect_errno())
{
echo "Ошибка соединения: ".mysqli_connect_error();
}
else{
$dbfile = "<?phprnrn" .
'$prefix = ' . "'meg_';rn" .
'$ip_user = ' . '$_SERVER["REMOTE_ADDR"];' . "rn" .
"//MySQL...rn" .
'If ($ip_user!=' ."'127.0.0.1'){rn" .
"//настройки для хостаrn" .
'$mysqli = ' . "new mysqli('$dbhost', '$dbuser', '$dbpass', '$dbname');rn" .
"if(mysqli_connect_errno())rn" .
'{ die("Ошибка соединения: ".mysqli_connect_error());}}' .
"else {rn" .
"//настройки для локалиrn" .
'$mysqli = ' . "new mysqli('$dbhost', '$dbuser', '$dbpass', '$dbname');rn" .
'if(mysqli_connect_errno())' . "{ die('Ошибка соединения: '.mysqli_connect_error()); }}rn" .
'$mysqli->' . "query('SET NAMES utf8');rnrnrnrnrnrn" .
"?>rn";
if (!file_put_contents('../Sys/connect.php', $dbfile)) {
echo 'Ошибка, записать настройки бд неудалось! ';
}
else{
$dump = file_get_contents('./db.sql');
if (!$mysqli->multi_query(trim($dump))) {
echo "Ошибка, импортировать базу данных не удалось: (" . $mysqli->errno . ") " . $mysqli->error;
}
else{ $st = 'ok';
echo'<span style="color:green"><big><b>Поздравляем!</b></big></span><br /><br />
<big>Установка <b><span style="color:red">Meg</span>Cms v1.0.0</b> выполнена успешно.</big><br /><br />
<b>Первый зарегистрированный пользователь становится администратором сайта.</b><br /><br /><a href="http://'.$_SERVER['HTTP_HOST'].'/registration">Регистрация</a>';
if (file_exists('../Sys/connect.php')) {
@chmod($realfile, 0755);
if (is_writable($realfile)) {
$error .= 'Атрибуты выставить не удалось<br/>';
}
} else{
$error .= 'Файл не найден<br/>';
}
if(!empty($error))
{
echo '<br /><br /><b><big>Выставите атрибуты <b>0755</b> на файл <b>Sys/connect.php</b> </big></b><br/>';
}
}
}
} } }
if($st=='ok'){
echo '<br /><br /><span style="color:red"><b><big>Удалите папку install </big></b></span><br/>';
}
else
{
echo'<br /><br /><form action="http://'.$_SERVER['HTTP_HOST'].'/install/index.php?act=1" name="post" method="post"> ';
echo 'Сервер MySQL:<br />';
echo'<input type="text" class="form" name="dbhost" value="localhost"/><br/><br />';
echo 'Имя базы данных:<br />';
echo'<input type="text" class="form" name="dbname" value="megcms"/><br/><br />';
echo 'Имя пользователя базы данных:<br />';
echo'<input type="text" class="form" name="dbuser" value="root"/><br/><br />';
echo 'Пароль пользователя базы данных:<br />';
echo'<input type="text" class="form" name="dbpass" value=""/><br/><br />';
echo'<input name="ok" type="submit" class="button" value="Далее" />
</form>';
}
break;
}
echo '</div></div>';
echo '<br /></div>';
echo' <div id="st31"> ';
echo'
<div class="st3"><h2 class="title"></h2><div class="small_back"><div class="back">
<p></p>
</div></div></div>';
echo'<br />';
echo' </div> <div style="clear: both;">';
echo' </div> </div></div> <div id="main3"> ';
echo' <div align="right">';
echo'</div>';
echo'<br /></div>'; echo'<div id="footer">
<p>Copyright © <a href="http://megcms.ru">MegCms.Ru</a></p>
</div>
</div>
</div>
</body>
</html> ';
?>