<?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'] = 'Инсталляция модуля.';

   $configBullets = <<< HTML
<?PHP
// Bullet Energy config
\$bullet_energy_config = array (
'meta_titl' => "Форум",
'speedbar_titl' => "нашего сайта",
'url_site' => "",
'meta_descr' => "Форум",
'meta_keywords' => "Форум",
'time_cashe' => "15",
'reg_linck_5' => "1",
'cpu' => "1",
'is_cpu_type' => "1",
'handler_cpu' => "0",
'slash' => "0",
'moder_disable' => "1",
'adv' => "1",
'session_check' => "1",
'count_pagination_rez' => "3",
'forum_status' => "0",
'off_line_status' => "Форум находится на текущей реконструкции, после завершения всех работ форум будет открыт.Приносим вам свои извинения за доставленные неудобства.",
'upload_max_size' => "8000",
'upload_file_type' => "zip,rar",
'dowload_count' => "1",
'mass_upload' => "1",
'upload_count_file' => "10",
'topic_count' => "10",
'prefix_wan' => "Важно",
'color_prefixwan' => "#767676",
'prefix_cloze' => "Закрыто",
'color_prefixcloze' => "#767676",
'prefix_vote' => "Опрос",
'color_prefixvote' => "#767676",
'prefix_fire' => "Горячая",
'color_prefixfire' => "#767676",
'topic_view' => "1",
'mini_pag' => "1",
'title_case' => "1",
'topic_day' => "10",
'fire_topic' => "5",
'message_count' => "60000",
'message_count_mini' => "10",
'message_count_page' => "10",
'edit_time_post' => "3",
'msg_combine' => "0",
'wrap_count_msg' => "80",
'view_post_search' => "1",
'url_click' => "1",
'time_step_last_message' => "j F Y - H:i",
'time_step_last_message_cat' => "j F Y - H:i",
'time_step_message' => "j F Y - H:i",
'time_step_autor' => "j F Y",
'time_step_topic_new' => "j F в H:i",
'width' => "450",
'height' => "300",
'play' => "0",
'flv_watermark' => "1",
'flv_watermark_pos' => "left",
'flv_watermark_al' => "0.5",
'tube_related' => "1",
'tube_dle' => "1",
'youtube_q' => "hd720",
'startframe' => "1",
'preview' => "0",
'autohide' => "1",
'buffer' => "10",
'progressBarColor' => "0xFFFFFF",
'max_images_upload' => "800",
'size_image_th' => "200",
'wh_images' => "1",
'size_img_noupload' => "300",
'images_prev_insert' => "0",
'float_img' => "none",
'captha_type' => "0",
'republic' => "6LfoOroSAAAAAEg7PViyas0nRqCN9nIztKxWcDp_",
'reprivate' => "6LfoOroSAAAAAMgMr_BTRMZy20PFir0iGT2OQYZJ",
'anti_no' => "5",
'reputations' => "0",
'reputations_type' => "2",
'online' => "1",
'session_time' => "10",
'widget_last_post' => "0",
'widget_last_post_count' => "15",
'is_like' => "1",
'widget_preview' => "1",
'widget_warning' => "1",
'widget_warning_bann' => "3",
'widget_warning_count' => "100",
'enable_rss' => "1",
'enable_rss_topic' => "1",
'time_cashe_rss' => "20",
'count_feed' => "15",
'format_rss_tree' => "1",
'version' => "1.2",
);

?>
HTML;
   $con_file_forum = fopen("engine/bullet_energy/data/forum_config.php", "w+") or die("Извините, но невозможно создать файл <b>.engine/bullet_energy/data/forum_config.php</b>.<br />Проверьте правильность проставленного CHMOD!");
   fwrite($con_file_forum, $configBullets);
   fclose($con_file_forum);
   @chmod("engine/bullet_energy/data/forum_config.php", 0666);

   $option['clickAdmin'] = $config['http_home_url'] . $config['admin_path'] . '?mod=bullet_energy';
   dropTableColum(array('table' => '_users', 'colum_prefix' => 'forum_'));
   dropTableColum(array('table' => '_post', 'colum_prefix' => 'topic_id'));
   $option['click'] = '<form action="" name="redirect"><input type="button" onclick="document.location.href=\'' . $option['clickAdmin'] . '\';" value="Перейти в админцентр" alt="Перейти в админцентр" /></form>';
   $operation[] = '<dd>Модуль "Bullet Energy 1.2" установлен и добавлен в админцентр.</dd>';
   installAdminCP(array('version' => '1.2'));
   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.2</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.2</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;

?>