Просмотр файла install.php

Размер файла: 10.33Kb
<?php
// by mides, wmclub.mobi

require_once 'system/db.php';

function tp($title){
	echo '<div class="s1">'.$title.'</div><div class="s2">';
    return;
}
function nav_main(){
    echo '</div><div class="nav"><a href="../">На главную</a></div>';
    return;
}
function nav($link){
    echo '</div><div class="nav"><a href="'.$link.'">Назад</a><br /><a href="../">На главную</a></div>';
    return;
}
function check($check){
	$check = htmlspecialchars(mysql_real_escape_string($check));
	
	$search = array('|', '\'', '$', '\\', '^', '%', '`', "\0", "\x00", "\x1A", "‮⁄∩");
	$replace = array('&#124;', '&#39;', '&#36;', '&#92;', '&#94;', '&#37;', '&#96;', '', '', '', '');
	$msg = str_replace($search, $replace, $msg);
	
	$msg = stripslashes(trim($msg));
	return $check;
}
function generate($number){
	$arr = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S','T','U','V','X','Y','Z','1','2','3','4','5','6','7','8','9','0');  
    // Генерируем пароль  
    $pass = '';  
    for($i = 0; $i < $number; $i++){
		// Вычисляем случайный индекс массива
		$index = rand(0, count($arr) - 1);
		$pass .= $arr[$index];  
    }
	return $pass;  
}

$config['copy'] = $_SERVER['HTTP_HOST'];
header('Cache-control: no-cache');
$v = '2.0';
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 rel="shortcut icon" href="favicon.ico"/>
<link rel="stylesheet" href="inc/styles/default/style.css" type="text/css"/>
<title>Установка CoolCMS v'.$v.'</title>
</head>
<body>';

switch ($_GET['act']) {
    default:
		tp('Установка CoolCMS v'.$v);
		echo '<form action="?act=do" method="post">
		Логин(min3, max12, a-z, 0-9):<br /><input name="login" type="text" maxlength="8" /><br />
		E-mail(max50):<br /><input name="email" type="text" maxlength="50" /><br />
		<input type="submit" value="Установка"/>
		</form>';
		nav_main();
	break;
	
	case 'do':
		if ($_POST['login'] and $_POST['email']) {
			$login = check($_POST['login']);
			$email = check($_POST['email']);
			$pass = generate(8);
				
			mysql_query("CREATE TABLE IF NOT EXISTS `ad` (`id` int(3) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL,`link` varchar(100) NOT NULL,`type` int(1) NOT NULL,`time` int(10) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `adminchat` (`id` int(11) NOT NULL AUTO_INCREMENT,`id_user` int(11) NOT NULL,`msg` varchar(250) NOT NULL,`time` int(10) NOT NULL,`edit_by` int(11) NOT NULL,`edit_time` int(10) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `book` (`id` int(11) NOT NULL AUTO_INCREMENT,`id_user` int(11) NOT NULL,`msg` varchar(250) NOT NULL,`time` int(10) NOT NULL,`edit_by` int(11) NOT NULL,`edit_time` int(10) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `config` (`id` int(1) NOT NULL AUTO_INCREMENT,`onpage` int(2) NOT NULL,`antispam` int(3) NOT NULL,`edit_time` int(4) NOT NULL,`kick` int(3) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2");
			mysql_query("INSERT INTO `config` (`id`, `onpage`, `antispam`, `edit_time`, `kick`) VALUES(1, 10, 20, 300, 20)");
			mysql_query("CREATE TABLE IF NOT EXISTS `forum_cats` (`id` int(3) NOT NULL AUTO_INCREMENT,`name` varchar(50) NOT NULL,`order` int(11) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `forum_msg` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cat` int(11) NOT NULL,
  `id_subcat` int(11) NOT NULL,
  `id_topic` int(5) NOT NULL,
  `id_user` int(11) NOT NULL,
  `text` text NOT NULL,
  `time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `forum_subcats` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cat` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `order` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
			mysql_query("CREATE TABLE IF NOT EXISTS `forum_topics` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `id_cat` int(3) NOT NULL,
  `id_subcat` int(11) NOT NULL,
  `title` varchar(50) DEFAULT NULL,
  `id_user` int(11) NOT NULL,
  `last_time` int(10) NOT NULL,
  `stuck` int(1) NOT NULL,
  `closed` int(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `loads_cats` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `loads_comm` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_load` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `msg` varchar(250) NOT NULL,
  `time` int(10) NOT NULL,
  `edit_by` int(11) NOT NULL,
  `edit_time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `loads_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cat` int(11) NOT NULL,
  `id_subcat` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `desc` text NOT NULL,
  `author` varchar(20) NOT NULL,
  `site` varchar(20) NOT NULL,
  `file` varchar(50) NOT NULL,
  `time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `loads_subcats` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_cat` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `news` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(50) NOT NULL,
  `text` text,
  `time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `news_comm` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_news` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  `msg` varchar(250) NOT NULL,
  `time` int(10) NOT NULL,
  `edit_by` int(11) NOT NULL,
  `edit_time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `online` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_user` int(11) NOT NULL,
  `place` varchar(50) NOT NULL,
  `time` int(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("CREATE TABLE IF NOT EXISTS `smiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(50) NOT NULL,
  `path` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=38");
			mysql_query("INSERT INTO `smiles` (`id`, `code`, `path`) VALUES
(1, ':)', 'inc/smiles/1.gif'),
(2, ':-)', 'inc/smiles/2.gif'),
(3, ';))', 'inc/smiles/4.gif'),
(4, ':sad', 'inc/smiles/4.gif'),
(5, ';)', 'inc/smiles/5.gif'),
(6, '%0', 'inc/smiles/6.gif'),
(7, ':(', 'inc/smiles/7.gif'),
(8, ':-(', 'inc/smiles/8.gif'),
(9, ':yy', 'inc/smiles/9.gif'),
(10, ':sho', 'inc/smiles/10.gif'),
(11, ':o_o', 'inc/smiles/11.gif'),
(12, ':crazy', 'inc/smiles/12.gif'),
(13, ':d', 'inc/smiles/13.gif'),
(14, ':-d', 'inc/smiles/14.gif'),
(15, ':peace', 'inc/smiles/15.gif'),
(16, ':flud', 'inc/smiles/16.gif'),
(17, ':closed', 'inc/smiles/17.gif'),
(18, ':angry', 'inc/smiles/18.gif'),
(19, ':bravo', 'inc/smiles/19.gif'),
(20, ':ban', 'inc/smiles/20.gif'),
(21, ':f', 'inc/smiles/21.gif'),
(22, ':welcome', 'inc/smiles/22.gif'),
(23, ':good', 'inc/smiles/23.gif'),
(24, ':ubanned', 'inc/smiles/24.gif'),
(25, ':spam', 'inc/smiles/25.gif'),
(26, ':shut', 'inc/smiles/26.gif'),
(27, ':shock', 'inc/smiles/27.gif'),
(28, ':read', 'inc/smiles/28.gif'),
(29, ':overlook', 'inc/smiles/29.gif'),
(30, ':oops', 'inc/smiles/30.gif'),
(31, ':?', 'inc/smiles/31.gif'),
(32, ':@', 'inc/smiles/32.gif'),
(33, ';/', 'inc/smiles/33.gif'),
(34, ':off', 'inc/smiles/34.gif'),
(35, ':lol', 'inc/smiles/35.gif'),
(36, ':hack', 'inc/smiles/36.gif'),
(37, ':sorry', 'inc/smiles/37.gif')");
			mysql_query("CREATE TABLE IF NOT EXISTS `users` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `login` varchar(12) DEFAULT NULL,
  `email` varchar(50) DEFAULT NULL,
  `pass` varchar(32) DEFAULT NULL,
  `access` int(1) NOT NULL,
  `regtime` int(10) DEFAULT NULL,
  `karma` int(11) NOT NULL,
  `locked` int(10) NOT NULL,
  `locked_who` int(11) NOT NULL,
  `reason` varchar(250) NOT NULL,
  `name` varchar(20) NOT NULL,
  `from` varchar(25) NOT NULL,
  `icq` int(9) NOT NULL,
  `site` varchar(20) NOT NULL,
  `birthday` varchar(10) NOT NULL,
  `sex` int(1) NOT NULL,
  `about` varchar(150) DEFAULT NULL,
  `style` varchar(50) NOT NULL,
  `onpage` int(2) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
			mysql_query("INSERT INTO `users` SET `login` = '$login', `pass` = '".md5(md5($pass))."', `access` = 3, `email` = '$email', `regtime` = '".time()."', `onpage` = 10");
			mysql_query("INSERT INTO `news`(`title`,`text`,`time`) VALUES('CoolCMS v$v', 'Если вы читаете эту новость, CoolCMS v$v успешно установлен! :) Скачать его можно на официальном сайте http://wmclub.mobi', '".time()."')");
			tp('Информация');
			echo 'Установка прошла успешно. Вы зарегистрированы.<br />
			Логин: '.$login.'<br />
			Пароль: '.$pass.'<br />
			Автологин:<br /><input name="auto" type="text" value="http://'.$config['copy'].'/a.php?l='.$login.'&amp;p='.$pass.'" /><br />
			<a href="a.php?l='.$login.'&amp;p='.$pass.'">Ввойти по автологину</a>';
			nav_main();
		} else {
			error('Вы не заполнили поля.');
			nav('?');
		}
	break;
}

require_once 'system/tail.php';
?>