View file install.php

File size: 11.7Kb
<?
if(!isset($_GET['shurik'])){
echo "<div align='right'><small>Шаг 1</small></div>
Создайте в phpmyadmin базу данных для cms (название любое)<br/>
<form action=\"install.php?shurik=2\" method=\"post\"><input name=\"\" type=\"submit\" value=\"Далее\"></form>";}

else 
{
if($_GET['shurik'] ==2){
echo "<div align='right'><small>Шаг 2</small></div>";
echo '<form action="install.php?shurik=3" method="post">
Название базы данной(которую создали в прошлом шаге)<br/>
<input name="db_name" type="text"><br/>
Имя пользователя базы<br/>
<input name="db_user" type="text"><br/>
Пароль пользователя базы<br/>
<input name="db_pass" type="text"><br/>
Mysql хост<br/>
<input name="db_host" type="text" value="localhost"><br/>
<input name="" type="submit" value="Далее"></form>';}

if($_GET['shurik'] ==3)
{if(!isset($_POST['db_name']))exit();

$db_name=$_POST['db_name']; $db_host=$_POST['db_host']; $db_user=$_POST['db_user']; $db_pass=$_POST['db_pass'];

echo "<div align='right'><small>Шаг 3</small></div>";
$db=mysql_connect("$db_host", "$db_user", "$db_pass");
if(!$db)die("Не установлено соединение с Mysql");
mysql_select_db("$db_name", $db);

$q=0;
if(mysql_query("CREATE TABLE `shurik_ava` (
  `id` int(5) NOT NULL auto_increment,
  `url` varchar(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=1;"))$q=1;
if(mysql_query("CREATE TABLE `shurik_ban` (
  `id` int(10) NOT NULL auto_increment,
  `user` int(10) NOT NULL,
  `ban` varchar(255) NOT NULL,
  `razban` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=9;"))$q++;
if(mysql_query("CREATE TABLE `shurik_chat` (
  `id` int(5) NOT NULL auto_increment,
  `avtor` varchar(30) NOT NULL,
  `date` varchar(15) NOT NULL,
  `time` varchar(15) NOT NULL,
  `text` text NOT NULL,
  `time2` varchar(20) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=23 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_com` (
  `id` int(5) NOT NULL auto_increment,
  `for` int(1) NOT NULL,
  `new` int(10) NOT NULL,
  `avtor` varchar(35) NOT NULL,
  `date` varchar(20) NOT NULL,
  `text` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=8 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_f_cat` (
  `id` int(2) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `post` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=5 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_f_post` (
  `id` int(8) NOT NULL auto_increment,
  `avtor` varchar(30) NOT NULL,
  `date` varchar(30) NOT NULL,
  `text` text NOT NULL,
  `tema` int(8) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=42 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_f_tem` (
  `id` int(5) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `cat` int(3) NOT NULL,
  `avtor` varchar(30) NOT NULL,
  `time` varchar(20) NOT NULL,
  `close` int(1) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=16 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_gobook` (
  `id` int(5) NOT NULL auto_increment,
  `avtor` varchar(30) NOT NULL,
  `date` varchar(20) NOT NULL,
  `text` text NOT NULL,
  `ip` varchar(20) NOT NULL,
  `otvet` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=15 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_ls` (
  `id` int(10) NOT NULL auto_increment,
  `from` varchar(35) NOT NULL,
  `to` varchar(35) NOT NULL,
  `date` varchar(20) NOT NULL,
  `text` text NOT NULL,
  `chit` int(1) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=21 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_news` (
  `id` int(5) NOT NULL auto_increment,
  `avtor` varchar(30) NOT NULL,
  `date` varchar(20) NOT NULL,
  `name` varchar(50) NOT NULL,
  `text` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=12 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_pages` (
  `id` int(5) NOT NULL auto_increment,
  `url` varchar(25) NOT NULL,
  `text` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=7 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_reklama` (
  `id` int(5) NOT NULL auto_increment,
  `color` varchar(10) NOT NULL,
  `url` varchar(100) NOT NULL,
  `name` varchar(100) NOT NULL,
  `poz` int(1) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=6 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_setting` (
  `id` int(5) NOT NULL auto_increment,
  `value` text NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=2 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_smile` (
  `id` int(5) NOT NULL auto_increment,
  `text` varchar(10) NOT NULL,
  `url` varchar(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=10 ;"))$q++;
if(mysql_query("CREATE TABLE `shurik_users` (
  `id` int(10) NOT NULL auto_increment,
  `login` varchar(30) NOT NULL,
  `echologin` varchar(30) NOT NULL,
  `email` varchar(50) NOT NULL,
  `pass` varchar(30) NOT NULL,
  `forum` int(10) NOT NULL,
  `chat` int(10) NOT NULL,
  `gost` int(10) NOT NULL,
  `ball` int(10) NOT NULL,
  `admin` int(1) NOT NULL,
  `ava` varchar(10) NOT NULL,
  `online` varchar(20) NOT NULL,
  `sh` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=13;"))$q++;

  @$file = fopen ("include/bd.php","r+");
  $text = '<?
@$db = mysql_connect ("'.$db_host.'","'.$db_user.'","'.$db_pass.'");
if(!$db)die("Не установлено соединение с базой");
mysql_select_db("'.$db_name.'",$db);
$pstr["users"]=10; #Кол-во пользователей на странице в списке юзеров
$pstr["ava"]=10; #Аватаров на странице настроек
$pstr["new"]=10; #Новостей
$pstr["mail"]=10; #Личных сообщений
$pstr["comment"]=5; #Коментариев
?>';
@fputs ( $file, $text);
@fclose ($file); 
if ($file){echo '<br/>Настройки базы сохранены<br>';}
else{echo '<br/>Настройки базы не сохранены!! Попробуйте поставить chmod 777 файлу include/bd.php';}


if($q != 15)echo "База не заполнена до конца!<br/>";
echo "Таблиц создано $q из 15<br/>
<form action=\"install.php?shurik=4\" method=\"post\"><input name=\"\" type=\"submit\" value=\"Далее\"></form>";
}




if($_GET['shurik'] ==4)
{echo "<div align='right'><small>Шаг 4</small></div>";
include("include/bd.php");
$q_q=0;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (1, '1.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (2, '2.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (3, '3.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (4, '4.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (5, '5.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (6, '6.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (7, '7.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (8, '8.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (9, '9.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (10, '10.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (11, '11.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (12, '12.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (13, '13.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (14, '14.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (15, '15.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (16, '16.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (17, '17.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (18, '18.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (19, '19.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (20, '20.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (21, '21.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (22, '22.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (23, '23.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (24, '24.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (25, '25.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (26, '26.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (27, '27.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (28, '28.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (29, '29.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (30, '30.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (31, '31.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_ava` VALUES (33, '32.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_pages` VALUES (1, 'tag.html', '[b]TEXT[/b] = <b>TEXT</b><br/>\r\n[big]TEXT[/big] = <big>TEXT</big><br/>\r\n[i]TEXT[/i] = <i>TEXT</i><br/>\r\n[u]TEXT[/u] = <u>TEXT</u><br/>\r\n[small]TEXT[/small] = <small>TEXT</small><br/>\r\n[color:red]TEXT[/color] = <font color=red>TEXT</font><br/>\r\n[color:blue]TEXT[/color] = <font color=blue>TEXT</font><br/>\r\n[color:green]TEXT[/color] = <font color=green>TEXT</font><br/>\r\n[color:yellow]TEXT[/color] = <font color=yellow>TEXT</font><br/>\r\n[url=http://site.ru]Сайт[/url] = <a href=http://site.ru>Сайт</a>')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_pages` VALUES (2, 'smile.html', ':) = <img src=../images/smile/1.gif><br/>\r\n:( = <img src=../images/smile/2.gif><br/>\r\n;) = <img src=../images/smile/3.gif><br/>\r\n:P = <img src=../images/smile/4.gif><br/>\r\n8) = <img src=../images/smile/5.gif><br/>\r\n:D = <img src=../images/smile/6.gif><br/>\r\n:0 = <img src=../images/smile/7.gif><br/>\r\n:(P = <img src=../images/smile/8.gif><br/>')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_setting` VALUES (1, 'CMS by SHuRiK')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (1, ':)', '1.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (2, ':(', '2.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (3, ';)', '3.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (4, ':P', '4.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (5, '8)', '5.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (6, ':D', '6.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (7, ':0', '7.gif')"))$q_q++;
if(mysql_query("INSERT INTO `shurik_smile` VALUES (9, ':bebe', '8.gif')"))$q_q++;

if($q_q != 43)echo "Записаны не все данные!<br/>";
echo "Записано данных $q_q из 43<br/><form action=\"install.php?shurik=5\" method=\"post\"><input name=\"\" type=\"submit\" value=\"Далее\"></form>";
if($q_q != 43)echo mysql_error();
}

if($_GET['shurik'] ==5)
{echo "<div align='right'><small>Шаг 5</small></div>";
echo '<form action="install.php?shurik=6" method="post"><b>Настройка данных администратора</b><br/>Логин<br/><input name="login" type="text" /><br/>Пароль<br/><input name="pass" type="password" /><br/>E-Mail<br/><input name="email" type="text" /><br/><input name="" type="submit" value="Создать" /></form>';
}

if($_GET['shurik'] ==6)
{include("include/bd.php");
echo "<div align='right'><small>Шаг 6</small></div>";
$login=$_POST['login'];$pass=$_POST['pass'];$email=$_POST['email'];
$new_admin=mysql_query("INSERT INTO `shurik_users` SET `login`='$login', `echologin`='$login', `pass`='$pass', `email`='$email', admin='3', `ava`='1.gif'");
if($new_admin)echo "Администратор создан<br/><a href='index.php'>Установка завершена!</a><br/><big>УДАЛИТЕ ФАЙЛ INSTALL.PHP!! ЕСЛИ ЕГО НЕ УДАЛИТЬ ВАШ САЙТ МОГУТ ВЗЛОМАТЬ!!</big>";
else echo "Ошибка, повторите попытку!<br/>".mysql_error();
}





}





?>