<?php
/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: install.php
-----------------------------------------------------------------
Назначение: Инсталятор модуля Bullet Energy.
=================================================================
*/
error_reporting(E_ALL ^ E_NOTICE);
@ini_set('display_errors', true);
@ini_set('html_errors', false);
@ini_set('error_reporting', E_ALL ^ E_NOTICE);
define('DATALIFEENGINE', true);
define('ROOT_DIR', dirname(__file__));
define('ENGINE_DIR', ROOT_DIR . '/engine');
require_once (ROOT_DIR . '/language/Russian/adminpanel.lng');
include ENGINE_DIR . '/data/config.php';
require_once ENGINE_DIR . '/modules/functions.php';
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/sitelogin.php';
require_once ENGINE_DIR . '/bullet_energy/library/install/install_function.php';
require_once ENGINE_DIR . '/bullet_energy/library/install/query/sql.php';
$action = strtolower(trim($_REQUEST['action']));
$option = array();
if (!$action) {
  $option['title'] = 'Пожалуйста, внимательно прочитайте пользовательское соглашение по использованию Bullet Energy.';
  $option['message'] = getLicense();
  $option['click'] = '<input type="hidden" name="action" value="go" /><input type="submit" name="install" value="Установить" alt="Установить" />';
} elseif ($action == 'go') {
  $option['title'] = 'Проверка директорий и файлов.';
  $option['click'] = '<input type="hidden" name="action" value="go2" /><input type="submit" name="install" value="Далее" alt="Далее" />';
  $dir = array('./uploads/forum/', 
               './uploads/forum/files/', 
               './uploads/forum/images/', 
               './engine/bullet_energy/cache/system/',
               './engine/bullet_energy/cache/',
               './engine/bullet_energy/data/',);
  foreach ($dir as $file) {
    if (!file_exists($file)) {
      $file_status = "<strong class=\"red\">не найден!</strong>";
      $not_found_errors++;
    } elseif (is_writable($file)) {
      $file_status = "<strong class=\"green\">разрешено</strong>";
    } else {
      @chmod($file, 0777);
      if (is_writable($file)) {
        $file_status = "<strong class=\"green\">разрешено</strong>";
      } else {
        @chmod("$file", 0755);
        if (is_writable($file)) {
          $file_status = "<strong class=\"green\">разрешено</strong>";
        } else {
          $file_status = "<strong class=\"red\">запрещено</strong>";
          $chmod_errors++;
        }
      }
    }
    $chmod_value = @decoct(@fileperms($file)) % 1000;
    $wh .= '<dd>' . substr($file, 2) . $file_status . '</dd>';
  }
  $dir = "<dl><dt>Проверка директорий:</dt>" . $wh . "</dl>";
  $file = array('./engine/bullet_energy/core.php', './engine/bullet_energy/modules/download.php', './engine/bullet_energy/library/bbcode/bbcodes.js', './engine/bullet_energy/library/bbcode/bbcode_message.css', './engine/bullet_energy/library/bbcode/bbcode.css', './engine/bullet_energy/library/colorpicker/utils.js', './engine/bullet_energy/library/colorpicker/eye.js', './engine/bullet_energy/library/colorpicker/utils.js', './engine/bullet_energy/library/colorpicker/colorpicker.js', './engine/bullet_energy/library/colorpicker/colorpicker.css', './engine/bullet_energy/library/jquery/jqueryui.js', './engine/bullet_energy/library/jquery/jquery-ui.css', './engine/bullet_energy/library/jquery/jquery.js', './engine/bullet_energy/library/language/Russian/admin.lng', './engine/bullet_energy/library/language/Russian/site.lng', './engine/bullet_energy/library/upload/uploadify.swf', './engine/bullet_energy/library/upload/upload.js', './engine/bullet_energy/library/upload/upload.css', './engine/bullet_energy/library/upload/swfobject.js', './engine/bullet_energy/classes/admin.class.php', './engine/bullet_energy/classes/ajax.class.php', './engine/bullet_energy/classes/ajax_handler.class.php', './engine/bullet_energy/classes/ajax_viewer.class.php', './engine/bullet_energy/classes/filter.class.php', './engine/bullet_energy/classes/linck.class.php', './engine/bullet_energy/classes/main.class.php', './engine/bullet_energy/classes/main_handler.class.php', './engine/bullet_energy/classes/main_viewer.class.php', './engine/bullet_energy/classes/upload.class.php', './engine/bullet_energy/ajax/site.php', './engine/bullet_energy/ajax/upload.php', );
  foreach ($file as $file) {
    if (!file_exists($file)) {
      $file_status = "<strong class=\"red\">не найден!</strong>";
      $not_found_errors++;
    } else {
      $file_status = "<strong class=\"green\">найден!</strong>";
    }
    $wh1 .= '<dd>' . substr($file, 1) . $file_status . '</dd>';
    $file = "<dl><dt>Проверка файлов:</dt>" . $wh1 . "</dl>";
  }
  $option['message'] = '<div class="license">' . $dir . $file . '</div>';
} elseif ($action == 'go2') {
  $option['title'] = 'Инсталляция модуля.';
  $option['clickAdmin'] = $config['http_home_url'] . $config['admin_path'] . '?mod=bullet_energy';
  dropTableColum(array('table' => '_users', 'colum_prefix' => 'forum_'));
  $option['click'] = '<form action="" name="redirect"><input type="button" onclick="document.location.href=\'' . $option['clickAdmin'] . '\';" value="Перейти в админцентр" alt="Перейти в админцентр" /></form>';
  $operation[] = '<dd>Модуль "Bullet Energy 1.0" установлен и добавлен в админцентр.</dd>';
  installAdminCP(array('version' => '1.0'));
  foreach ($tableSchema as $table) {
    $db->query($table);
  }
  $option['message'] = "<div class=\"license\"><dl><dt>Выполненные действия:</dt>" . implode("\r\n", $operation) . "</dl></div>";
}
echo <<< HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$config['charset']}" />
<title>Установка Bullet Energy 1.0</title>
<style type="text/css">
/*
 * YUI reset-fonts.css
 *
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.7.0
*/
html {
	color:#000;
	background:#FFF;
}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td {
	margin:0;
	padding:0;
}
table {
	border-collapse:collapse;
	border-spacing:0;
}
fieldset, img {
	border:0;
}
address, caption, cite, code, dfn, em, strong, th, var, optgroup {
	font-style:inherit;
	font-weight:inherit;
}
del, ins {
	text-decoration:none;
}
li {
	list-style:square outside none;margin-left:20px;
}
caption, th {
	text-align:left;
}
h1, h2, h3, h4, h5, h6 {
	font-size:100%;
	font-weight:normal;
}
q:before, q:after {
	content:'';
}
abbr, acronym {
	border:0;
	font-variant:normal;
}
sup {
	vertical-align:baseline;
}
sub {
	vertical-align:baseline;
}
legend {
	color:#000;
}
input, button, textarea, select, optgroup, option {
	font-family:inherit;
	font-size:inherit;
	font-style:inherit;
	font-weight:inherit;
}
input, button, textarea, select {
*font-size:100%;
}
body {
	font:13px/1.231 arial, helvetica, clean, sans-serif;
*font-size:small;
*font:x-small;
}
select, input, button, textarea, button {
	font:99% arial, helvetica, clean, sans-serif;
}
table {
	font-size:inherit;
	font:100%;
}
pre, code, kbd, samp, tt {
	font-family:monospace;
*font-size:108%;
	line-height:100%
}
body {
	font-family:'Trebuchet MS', Helvetica, Arial, sans-serif
}
html {
	color:#000;
	background:#D5D8DB
}
strong {
	font-weight:bold
}
.mainBox .mainBoxInnert {
	margin:100px auto 0;
	width:700px
}
.mainBoxInnert {
	padding:10px;
	border:1px solid white;
	border-color: rgba(255, 255, 255, 0.75);
	background: rgba(255, 255, 255, 0.2);
	-moz-border-radius:0.8em;
	-webkit-border-radius: 0.8em;
	-webkit-background-clip:padding-box;
	border-radius:10px;
	-webkit-border-radius:10px;
	-moz-border-radius:10px;
	-khtml-border-radius:10px;
	-moz-box-shadow:0 0 4px rgba(50, 50, 50, 0.5);
	-webkit-box-shadow: 0 0 4px rgba(50, 50, 50, 0.5);
	box-shadow:0 0 4px rgba(50, 50, 50, 0.5)
}
.mainBoxInnert form {
	border:1px solid #999999;
	border-radius:4px;
	-webkit-border-radius:4px;
	-moz-border-radius:4px;
	-khtml-border-radius:4px;
	-webkit-background-clip: padding-box;
	border-radius: 0.25em;
	padding:10px;
	background: white;
	-moz-box-shadow: 0 0 0.8em rgba(255, 255, 255, 0.5);
	-webkit-box-shadow: 0 0 0.8em rgba(255, 255, 255, 0.5);
	box-shadow: 0 0 0.8em rgba(255, 255, 255, 0.5);
	position:relative;
	min-height:350px
}
div.contentBox dl{ }
.mainBoxInnert form h1 {
	color:white;
	font-size:14px;
	font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Sans", Arial, Helvetica, sans-serif;
	border:1px solid;
	border-color:#50a3c8 #297cb4 #083f6f;
	background:#0c5fa5 url(title-bg.png) repeat-x top;
	-webkit-background-size:100% 100%;
	-moz-background-size:100% 100%;
	-o-background-size:100% 100%;
	background-size:100% 100%;
	background:-moz-linear-gradient(top, white, #72c6e4 4%, #0c5fa5);
	background:-webkit-gradient(linear, left top, left bottom, from(white), to(#0c5fa5), color-stop(0.03, #72c6e4));
	-moz-text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.2);
	-webkit-text-shadow:-1px -1px 0 rgba(0, 0, 0, 0.2);
	text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.2);
	padding:4px 6px;
	position:absolute;
	left:10px;
	top:-5px;
	z-index:100;
	-moz-box-shadow:0 1px 3px rgba(0, 0, 0, 0.5);
	-webkit-box-shadow:0 1px 3px rgba(0, 0, 0, 0.5);
	box-shadow:0 1px 3px rgba(0, 0, 0, 0.5);
	-webkit-background-clip: padding-box;
	border-radius:4px;
	-webkit-border-radius:4px;
	-moz-border-radius:4px;
	-khtml-border-radius:4px
}
div.contentBox {
	margin-top:15px
}
div.license {
	padding:10px 0;
	font-size:11px;
	height:350px;
	overflow:auto
}
div.license dl dd{border-bottom: 1px solid #D9D9D9;margin-bottom:3px;padding-bottom:3px}
div.license dl dt{display:none}
div.license dl dd strong.green{color:green;float:right;padding-right:5px}
div.license dl dd strong.red{color:red;float: right;padding-right:5px}
div.textProcess {
	border-bottom:1px solid #999999;
	padding-bottom:10px
}
div.submitBox {
	background-color:#E4E4DC;
	margin-bottom:10px;
	padding:5px;
	border-top:1px solid #999999;
	text-align:right
}
.mt5 {
	margin-top:5px
}
input[type="radio"], input[type="checkbox"] {
	vertical-align:-10%
}
input[type="submit"], input[type="button"]{
	font-size:12px;
	text-decoration:none;
	cursor:pointer;
	display:inline-block;
	position: relative;
	padding:2px;
	color:#4c4c4c;
	-webkit-border-radius:4px;
	-moz-border-radius: 4px;
	border-radius: 4px;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
	background: #f6f6f6;
	background: -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#d4d4d4));
	background: -webkit-linear-gradient(#f6f6f6, #d4d4d4);
	background-image: -moz-linear-gradient(top, #f6f6f6, #d4d4d4);
	background-image: -moz-gradient(top, #f6f6f6, #d4d4d4);
	border: 1px solid #a1a1a1
}
input[type="submit"]:hover, input[type="button"]:hover{
	background: #f6f6f6;
	background: -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#ececec));
	background: -webkit-linear-gradient(#f6f6f6, #ececec);
	background-image: -moz-linear-gradient(top, #f6f6f6, #ececec);
background-image: -moz-gradient(top, #f6f6f6, #ececec)text-decoration:none!important
}
input[type="submit"]:active, input[type="button"]:active {
	top: 1px;
	background: #ececec;
	background: -webkit-gradient(linear, left top, left bottom, from(#ececec), to(#f6f6f6));
	background: -webkit-linear-gradient(#ececec, #f6f6f6);
	background-image: -moz-linear-gradient(top, #ececec, #f6f6f6);
	background-image: -moz-gradient(top, #ececec, #f6f6f6);
	-webkit-box-shadow: inset 0 0 3px 0 rgba(0, 0, 0, 0.4), 0 1px 0 0 #ffffff;
	-moz-box-shadow: inset 0 0 3px 0 rgba(0, 0, 0, 0.4), 0 1px 0 0 #ffffff;
	box-shadow: inset 0 0 3px 0 rgba(0, 0, 0, 0.4), 0 1px 0 0 #ffffff
}
label {
	-moz-user-select:none;
	-khtml-user-select:none;
	user-select:none;
	padding-left:5px
}
</style>
</head>
<body>
<div class="mainBox">
  <div class="mainBoxInnert">
    <form action="" method="post" id="install_form" name="install_form">
      <h1>Установка Bullet Energy 1.0</h1>
      <div class="contentBox">
        <div class="textProcess">{$option['title']}</div>
         {$option['message']}
        <div class="submitBox">
          {$option['click']}
        </div>
      </div> 
    </form>
  </div>
</div>
</body>
</html>
HTML;

?>