View file gb/install.php

File size: 11.96Kb
<?
/*
GB(v1.0) by Viktor
icq:357332321
site: http://yarap.ru
http://xwab.ru/forum/profile656
[install.php]
*/
header('Content-Type: text/html; charset=UTF-8');
session_start();
error_reporting(0);
if (@fopen("viktor_gb_config.php", "r"))
    {
    header("Location: index.php");exit;
    }
if($_POST['lang'])
    $_SESSION['viktor_l']=($_POST['lang']=='ru') ? "ru" : "en";
if(!($_SESSION['viktor_l']))
    {
    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\" xml:lang=\"en\"><head><title>Install</title></head><body>Language:<form enctype=\"multipart/form-data\" action=\"install.php\" method=\"post\">
    <select name=\"lang\">
    <option value=\"ru\">&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;</option>
    <option value=\"en\">English</option>
    </select>
    <input type=\"submit\" value=\"OK\"></form></body></html>";
    exit;
    }
elseif($_POST['ololo']<>'xyi')
    {
    include('lang/'.$_SESSION['viktor_l'].'.php');
    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\" xml:lang=\"".$_SESSION['viktor_lang']."\">
    <head><link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\"/><link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"images/x-icon\"/><meta http-equiv=\"Content-Type\" content=\"application/vnd.wap.xhtml+xml; charset=UTF-8\"/><title>".$l[107]."</title></head><body>";
    if($_GET['error'])
        {
        echo "<font color=\"#FF0000\">";
        if($_GET['polya'])echo $l[116].'<br />';
        if($_GET['pass'])echo $l[117].'<br />';
        if($_GET['m_pass'])echo $l[118].'<br />';
        if($_GET['db'])echo $l[119];
        echo "</font>";
        }
    echo "<div class=\"lastnews\"><span><center><span class=\"zag\">G</span>uestbook by <a href=\"http://yarap.ru\">Viktor</a><br/></center></span></div>
    <div class=\"title2\">".$l[107]."</div>
    <form enctype=\"multipart/form-data\" action=\"install.php\" method=\"post\">
    <div class=\"title\">MySQL</div>
    <div class=\"content2\">
    <table bordel=0>
    <tr><td width=30%>".$l[108]."</td><td valing=\"top\"><input type=\"text\" name=\"m_server\" value=\"".(($_SESSION['m_server']) ? $_SESSION['m_server'] : "localhost")."\"/></td></tr>
    <tr><td width=30%>".$l[109]."</td><td valing=\"top\"><input type=\"text\" name=\"m_user\" value=\"".(($_SESSION['m_user']) ? $_SESSION['m_user'] : "")."\"/></td></tr>
    <tr><td width=30%>".$l[110]."</td><td valing=\"top\"><input type=\"text\" name=\"m_name\" value=\"".(($_SESSION['m_name']) ? $_SESSION['m_name'] : "")."\"/></td></tr>
    <tr><td width=30%>".$l[111]."</td><td valing=\"top\"><input type=\"password\" name=\"m_pass1\" value=\"\"/></td></tr>
    <tr><td width=30%>".$l[114]."</td><td valing=\"top\"><input type=\"password\" name=\"m_pass2\" value=\"\"/></td></tr>
    <tr><td width=30%>".$l[112]."</td><td valing=\"top\"><input type=\"text\" name=\"m_pref\" value=\"".(($_SESSION['m_pref']) ? $_SESSION['m_pref'] : "viktor_")."\"/></td></tr>
    </table>
    </div>
    <div class=\"title\">".$l[19]."</div>
    <div class=\"content2\">
    <table bordel=0>
    <tr><td width=30% valign=\"top\">".$l[20]."</td><td valign=\"top\"><input type=\"text\" name=\"title1\" value=\"".(($_SESSION['title1']) ? $_SESSION['title1'] : "Guestbook by Viktor")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[21]."</td><td valign=\"top\"><input type=\"text\" name=\"title2\" value=\"".(($_SESSION['title2']) ? $_SESSION['title2'] : $_SERVER['SERVER_NAME'])."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[30]."</td><td valign=\"top\"><input type=\"text\" name=\"mail\" value=\"".(($_SESSION['mail']) ? $_SESSION['mail'] : "[email protected]")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[31]."</td><td valign=\"top\"><input type=\"text\" name=\"max_text\" value=\"".(($_SESSION['max_text']) ? $_SESSION['max_text'] : "500")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[32]."</td><td valign=\"top\"><input type=\"text\" name=\"min_text\" value=\"".(($_SESSION['min_text']) ? $_SESSION['min_text'] : "5")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[33]."</td><td valign=\"top\"><input type=\"text\" name=\"max_name\" value=\"".(($_SESSION['max_name']) ? $_SESSION['max_name'] : "30")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[34]."</td><td valign=\"top\"><input type=\"text\" name=\"min_name\" value=\"".(($_SESSION['min_name']) ? $_SESSION['min_name'] : "2")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[60]."</td><td valign=\"top\"><input type=\"text\" name=\"site\" value=\"".(($_SESSION['site']) ? $_SESSION['site'] : 'http://'.$_SERVER['SERVER_NAME'])."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[61]."</td><td valign=\"top\"><input type=\"text\" name=\"gb\" value=\"".(($_SESSION['gb']) ? $_SESSION['gb'] : 'http://'.($_SERVER['SERVER_NAME'].str_replace("/install.php", "", $_SERVER['REQUEST_URI'])))."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[62]."</td><td valign=\"top\"><input type=\"text\" name=\"pagin\" value=\"".(($_SESSION['pagin']) ? $_SESSION['pagin'] : "10")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[120]."</td><td valign=\"top\"><input type=\"text\" name=\"file\" value=\"".(($_SESSION['file']) ? $_SESSION['file'] : "admin.php")."\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[113]."</td><td valign=\"top\"><input type=\"password\" name=\"pass1\" value=\"\"/></td></tr>
    <tr><td width=30% valign=\"top\">".$l[115]."</td><td valign=\"top\"><input type=\"password\" name=\"pass2\" value=\"\"/></td></tr>
    </table>
    <input type=\"checkbox\" name=\"http\"".(($_SESSION['http']) ? "checked=\"checked\"" : "")." /> ".$l[22]."<br />
    <input type=\"checkbox\" name=\"code\"".(($_SESSION['code']) ? "checked=\"checked\"" : "")." /> ".$l[85]."<br />
    <input type=\"checkbox\" name=\"online\"".(($_SESSION['online']) ? "checked=\"checked\"" : "")." /> ".$l[102]."<br />
    <input type=\"hidden\" name=\"ololo\" value=\"xyi\">
    <input type=\"submit\" value=\"OK\"></div></body></html>";
    }
else
    {
    $error='';
    foreach ($_POST as $k => $v)
        {
        $_SESSION[$k]=$v;
        if(!($v) && $k<>'http' && $k<>'code' && $k<>'online')$error='&polya=1';
        }
    $m_server=$_POST['m_server'];
    $m_user=$_POST['m_user'];
    $m_name=$_POST['m_name'];
    $m_pass1=$_POST['m_pass1'];
    $m_pass2=$_POST['m_pass2'];
    $m_pref=$_POST['m_pref'];
    $max_text=intval(abs($_POST['max_text']));
    $min_text=intval(abs($_POST['min_text']));
    $max_name=intval(abs($_POST['max_name']));
    $min_name=intval(abs($_POST['min_name']));
    $pagin=intval(abs($_POST['pagin']));
    $pass1=$_POST['pass1'];
    $pass2=$_POST['pass2'];
    if($_POST['http']) $http=1; else $http=0;
    if($_POST['code']) $code=1; else $code=0;
    if($_POST['online']) $online=1; else $online=0;
    if($pass1<>$pass2)
        $error.='&pass=1';
    if($m_pass1<>$m_pass2)
        $error.='&m_pass=1';
    else
        {
        if($error=='')
            {
            $db=mysql_connect($m_server, $m_user, $m_pass1);
            if(!(mysql_select_db($m_name, $db)))
                $error.='&db=1';
            $site=mysql_real_escape_string($_POST['site']);
            $gb=mysql_real_escape_string($_POST['gb']);
            $title1=mysql_real_escape_string($_POST['title1']);
            $title2=mysql_real_escape_string($_POST['title2']);
            $mail=mysql_real_escape_string($_POST['mail']);
            }
        }
    if($error<>'')
        {
        header("Location: install.php?error=1$error");exit;
        }
    $config="<?php\n\$serv='$m_server';\n\$user='$m_user';\n\$pass='$m_pass1';\n\$pref='$m_pref';\n\$dbname='$m_name';\n\$db=mysql_connect(\$serv, \$user, \$pass);\nif(!(mysql_select_db(\$dbname,\$db)))\ndie('Error. Check your data from database/&#1055;&#1088;&#1086;&#1074;&#1077;&#1088;&#1100;&#1090;&#1077; &#1087;&#1088;&#1072;&#1074;&#1080;&#1083;&#1100;&#1085;&#1086;&#1089;&#1090;&#1100; &#1074;&#1074;&#1086;&#1076;&#1072; &#1076;&#1072;&#1085;&#1085;&#1099;&#1093; &#1086;&#1090; &#1073;&#1072;&#1079;&#1099; &#1076;&#1072;&#1085;&#1085;&#1099;&#1093;');\n\$pass='$pass1';\n\$admin='".$_POST['file']."';\n?>";
    if ($conf = fopen('viktor_gb_config.php', 'x'))
        if (fwrite($conf, $config))
            {
            chmod("viktor_gb_config.php", 0644);
            $sql[1]="
CREATE TABLE IF NOT EXISTS `".$m_pref."baners` (
  `id` int(11) NOT NULL,
  `text` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[2]="
CREATE TABLE IF NOT EXISTS `".$m_pref."bans` (
  `ip` text NOT NULL,
  `pri` text,
  `text` text,
  `name` text,
  `time` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[3]="
CREATE TABLE IF NOT EXISTS `".$m_pref."config` (
  `c` text NOT NULL,
  `o` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[4]="
CREATE TABLE IF NOT EXISTS `".$m_pref."lang` (
  `id` mediumint(9) NOT NULL,
  `file` text NOT NULL,
  `name` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[5]="
CREATE TABLE IF NOT EXISTS `".$m_pref."like` (
  `id` int(11) NOT NULL,
  `ip` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[6]="
CREATE TABLE IF NOT EXISTS `".$m_pref."mes` (
  `id` mediumint(9) NOT NULL,
  `name` text NOT NULL,
  `text` text NOT NULL,
  `mail` text NOT NULL,
  `email` text,
  `site` text,
  `admin` int(11) DEFAULT NULL,
  `ip` text NOT NULL,
  `data` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[7]="
CREATE TABLE IF NOT EXISTS `".$m_pref."online` (
  `ip` text NOT NULL,
  `time` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[8]="
CREATE TABLE IF NOT EXISTS `".$m_pref."reklama` (
  `id` mediumint(9) NOT NULL,
  `text` text NOT NULL,
  `k` int(11) NOT NULL DEFAULT '0',
  `link` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[9]="
CREATE TABLE IF NOT EXISTS `".$m_pref."reklama_ip` (
  `ip` text NOT NULL,
  `id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
            $sql[10]="
INSERT INTO `".$m_pref."reklama` (`id`, `text`, `k`, `link`) VALUES
(1, '<b>yaRap.ru</b>', 1, 'http://yarap.ru');";
            $sql[11]="
INSERT INTO `".$m_pref."mes` (`id`, `name`, `text`, `mail`, `email`, `site`, `admin`, `ip`, `data`) VALUES
(1, '&#1042;&#1080;&#1082;&#1090;&#1086;&#1088;', '&#1055;&#1086;&#1079;&#1076;&#1088;&#1072;&#1074;&#1083;&#1103;&#1102;! &#1042;&#1099; &#1091;&#1089;&#1087;&#1077;&#1096;&#1085;&#1086; &#1091;&#1089;&#1090;&#1072;&#1085;&#1086;&#1074;&#1080;&#1083;&#1080; &#1075;&#1086;&#1089;&#1090;&#1077;&#1074;&#1091;&#1102; &#1082;&#1085;&#1080;&#1075;&#1091;!', '[email protected]', NULL, 'http://yarap.ru', NULL, '127.0.0.1', '1323526663');";
            $sql[12]="
INSERT INTO `".$m_pref."lang` (`id`, `file`, `name`) VALUES
(1, 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
(2, 'en', 'English');";
            $sql[13]="
INSERT INTO `".$m_pref."config` (`c`, `o`) VALUES
('title', '$title1'),
('title2', '$title2'),
('http', '$http'),
('max_name', '$max_name'),
('min_name', '$min_name'),
('max_text', '$max_text'),
('min_text', '$min_text'),
('mail', '$mail'),
('site', '$site'),
('gb', '$gb'),
('pagin', '$pagin'),
('lang', '1'),
('code', '$code'),
('online', '$online'),
('close', '0');";
            for($i=1;$i<=13;$i++)mysql_query($sql[$i]);
            if(!(mysql_error()))
               {
                rename('admin.php', $_POST['file']);
                unlink('install.php');
                header("Location: index.php");
                }
            }
    }
?>