Файл: install/base.php
Строк: 79
<?php
if (is_file('../system/db.php')) {
    if (isset($_POST['continue'])) {
        unlink('../system/db.php');
        header('Location: index.php');
    }
    echo '<head>
    <link rel="shortcut icon" href="/design/style/favicon.png">
    <link rel="stylesheet" href="/design/style/wap.css" type="text/css" />
    <title>Установка PeasCMS</title>
    </head>
    <body>';
    echo '<div class="base">
    <center><div class="sel">Мастер установки PeasCMS</div></center>';
    echo '<form method="post">
    <b>Ошибка! Файл конфигурации уже создан!</b><br>
    Это означает, что движок уже установлен и продолжение произведёт к потере всей информации, которая находится в базе данных на даный момент!<br>
    <input type="submit" name="continue" value="Продолжить">
    </form>';
    include 'foot.php';
}
include 'head.php';
define('H', $_SERVER['DOCUMENT_ROOT'] .'/');
if (isset($_GET['go'])) {
    $host = htmlspecialchars(trim($_POST['host']));
    $user = htmlspecialchars(trim($_POST['user']));
    $pass = htmlspecialchars(trim($_POST['pass']));
    $base = htmlspecialchars(trim($_POST['base']));
    mysql_connect($host, $user, $pass);
    $data = mysql_select_db($base);
    $datab = true;
    if (!$data) {
        $datab = false;
        echo '<div class="err">Такой базы данных не существует!</div>';
    }
    if ($datab == true) {
$db = "<?php
define ('DBHOST', '$host');
define ('DBNAME', '$base');
define ('DBPASS', '$pass');
define ('DBUSER', '$user');
?>";
        file_put_contents('../system/db.php', $db);
        $dump = file_get_contents('./sql.sql');
        $queryes = explode('-- --------------------------------------------------------', $dump);
        foreach($queryes as $query) {
            mysql_query(trim($query));
        }
        chmod('/files/avatars', 0777);
        chmod('/files/diaries', 0777);
        chmod('/files/user.files', 0777);
        chmod('/files/user.files.screen', 0777);
        chmod('/design/smiles', 0777);
        chmod('/design/imgs', 0777);
        chmod('/design/fonts', 0777);
        chmod('/system', 0777);
        echo '<div class="info">Подключение к Базе Данных, успешно выполнено!</div>
        <form method="post" action="reg.php">
        <input type="submit" name="next" value="Продолжить" />
        </form>';
        include 'foot.php';
    }
}
function permissions($filez)
{
    return decoct(@fileperms("$filez")) % 1000;
}
function test_chmod($df,$chmod)
{
    global $err,$user;
    
    if (isset($user) && $user['level'] == 10)
    $show_df = preg_replace('#^'.preg_quote(H).'#', '/', $df);
    else $show_df = $df;
    @list($f_chmod1, $f_chmod2, $f_chmod3) = str_split(permissions($df));
    list($n_chmod1,$n_chmod2,$n_chmod3) = str_split($chmod);
    if ($f_chmod1<$n_chmod1 || $f_chmod2<$n_chmod2 || $f_chmod3<$n_chmod3)
    {
        $err = 'Установите CHMOD ' . $n_chmod1 . $n_chmod2 . $n_chmod3 . ' на ' . $show_df;
        echo '<div class="err">'. $err .' : ' . $show_df . ' : [' . $f_chmod1 . $f_chmod2 . $f_chmod3 . '] - > ' . $n_chmod1 . $n_chmod2 . $n_chmod3 . '</div>';
    }
    else
    {
        echo '<div class="post">' . $show_df . ' (' . $n_chmod1 . $n_chmod2 . $n_chmod3 . ') : ' . 
        $f_chmod1 . $f_chmod2 . $f_chmod3 . ' <b>(ok)</b></div>';
    }
}
test_chmod(H.'files/',777);
test_chmod(H.'files/avatars/',777);
test_chmod(H.'files/diaries/',777);
test_chmod(H.'files/user.files/',777);
test_chmod(H.'files/user.files.screen/',777);
echo '<div class="title">Введите данные от вашей Базы Данных:</div>
<form method="post" action="?go">
Сервер:<br>
<input type="text" name="host" value="localhost" /><br>
Пользователь:<br>
<input type="text" name="user" /><br>
Пароль:<br>
<input type="password" name="pass" /><br>
База данных:<br>
<input type="text" name="base" /><br>
<input type="submit" name="go" value="Продолжить" />
</form>';
include 'foot.php';
?>