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

Размер файла: 11.91Kb
<?php
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//
// SitchiCMS - Mobile Content Management System //
// The author:  Nikoloz Sitchinava [sitchi]      //
// Link:        http://sitchicms.num.ge          //
// Skype:       SitchiCMS                        //
// License:     LICENSE.txt (see attached file)  //
// Version:     VERSION.txt (see attached file)  //
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
define('_SITCHICMS', 1);
/*სესიის დაწყება*/
session_name('SDG'); 
session_start();
/*დამ. ფუნქციები*/
mb_internal_encoding('UTF-8');
error_reporting(0); // შეცდომების დამალვა
/*სკრიპტის გაშვების დრო*/
$microtime = microtime(1);
$time=&$time;
if (!isset($_GET['act']))$_GET['act']='';
$act=htmlspecialchars(trim($_GET['act']));
$root_path='../';
require $root_path.'includes/start.php';
require $root_path.'includes/functions.php';
$version='0.5 [beta]';
$title='SitchiCMS '.$version.' dayeneba';
header("Content-type: text/html");
echo'<?xml version="1.0" encoding="utf-8"?>';
echo'
<!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="ru">
<head>
<title>'.$title.'</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head><body>
<div class="header"><table style="width: 100%;"><tr>' .
'<td valign="bottom"><a href="'.$root_path.'install/"><img src="images/logo.png" alt=""/></a></td>
</table></div>';
echo'<div class="maintxt">';
switch ($act) 
{
/**მთავარი გვერდი**/
default:
if (file_exists($root_path.'includes/db_config.php')) {
echo'<div class="errmenu">instalacia SeuZlebelia! waSaleT db_config.php instalaciis dasawyebad!<br/>';
}else{
echo'<div class="menu">mogesalmebiT, <font color="red">SitchiCMS '.$version.'</font> instalacia <br/>';
echo'sanam daiwyebdeT instalacia yuradRebiT waikiTxeT saqaRalde <a href="'.$root_path.'readme/"><b>/readme/</b><br/>';
echo'<hr><a href="'.$root_path.'readme/LICENSE.txt"><span style="color:#ff0000"><b>licenzia(LICENSE)</b></span></a><br/>';
echo'<a href="'.$root_path.'readme/INSTALL.txt"><span style="color:#ff0000"><b>instalacia(INSTALL)</b></span></a><br/>';
echo'<a href="'.$root_path.'readme/VERSION.txt"><span style="color:#ff0000"><b>versia(VERSION)</b></span></a><br/>';
echo'<hr><b><font color="red">instalaciis dasrulebis Semdeg waSaleT /install/ saqaRalde!!!</font></b><br/>';
echo'<form action="?">';
echo'<button type="submit" value="check" name="act">instalaciis dawyeba</button>';
echo'</form></div>';}
break;
/**სისტემის პარამეტრების შემოწმება**/
case 'check':
if (file_exists($root_path.'includes/db_config.php')) {
echo'<div class="errmenu">instalacia SeuZlebelia! waSaleT db_config.php instalaciis dasawyebad!<br/>';
}else{
if (version_compare(phpversion(), '5.2.0', '>'))
{
echo'<div class="menu">PHP versia: '.phpversion().'<span style="color:green">+</span>';
}
else 
{
$err[]='PHP versia romelic gamoiyeneba hostingze moZveleburia';
}
if (extension_loaded('mysql')) 
{
echo'<br/>MySQL: <span style="color:green">+</span>';
}
else 
{
$err[]='<br/>MySQL gafarToeba ar aris';
}
if (extension_loaded('mbstring')) 
{
echo'<br/>mbstring: <span style="color:green">+</span>';
}
else 
{
$err[]='biblioTeka mbstring ar aris';
}
if(filter_list())
{
echo'<br/>Filter var: <span style="color:green">+</span></div>';
}
else
{
$err[]='ar aris Filter var';
}
if(!isset($err))
{
msg('SegiZliaT instalaciis gagrZeleba');
echo'<br/>hostingis konfiguracia Tavsebadia<br/>';
echo'<form action="?">';
echo'<button type="submit" value="db" name="act">instalaciis gagrZeleba</button>';
echo'</form>';
}
else
{
echo'<br/>CMS dayeneba ver xerxdeba. ZiriTadi gafarToebebi ar aris<br/>';
echo'Tu Tqven iyenebT Localhost,SeamowmeT nebadarTulia Tu ara mbstring';
err();
}}
break;
/**MySQL ბაზის დაყენება**/
case 'db':
if (file_exists($root_path.'includes/db_config.php')) {
echo'<div class="errmenu">instalacia SeuZlebelia! waSaleT db_config.php instalaciis dasawyebad!<br/>';
}else{
if(isset($_GET['install']) && $_GET['install']=='db')
{
$dbhost = trim($_POST['host']);
$dblogin = trim($_POST['user']);
$dbpass = trim($_POST['pass']);
$dbbase = trim($_POST['name']);
$dblink= mysql_connect($dbhost,$dblogin,$dbpass);
if(!$dblink)
{
$err[]= 'ver moxerxda dakavSireba monacemTa bazis servertze';
}
$selected = mysql_select_db($dbbase, $dblink); 
if($selected)
{
mysql_query('set charset utf8',$dblink); 
mysql_query('SET names utf8',$dblink); 
mysql_query('set character_set_client="utf8"',$dblink); 
mysql_query('set character_set_connection="utf8"',$dblink); 
mysql_query('set character_set_result="utf8"',$dblink);
msg ('<div class="menu">monacemTa bazasTan dakavSireba warmatebiT moxda</div>');
//ვქმნით პარამეტრების ფაილს
$text = '<?php
$dbhost="'.$dbhost.'";
$dblogin="'.$dblogin.'"; 
$dbpass="'.$dbpass.'"; 
$dbbase="'.$dbbase.'";
?>';
$fp = @ fopen($root_path.'includes/db_config.php', 'w');
fputs($fp, $text);
fclose($fp);
msg('<div class="menu">kavSiri bazasTan warmatebulia</div>');
/*მონაცემების შეტანა ბაზაში*/
require 'data/sql.php';
}
else
{
$err[]= 'ar aris napovni monacmeTa baza';
}
if(!isset($err))
{
echo'<div class="menu">SitchiCMS dayeneba TiTqmis dasrulebulia, darCa mxolod administratoris daregistrireba';
echo'<form action="?">';
echo'<button type="submit" value="install_admin" name="act">gagrZeleba</button>';
echo'</form></div>';
}
else 
{
err();
echo'SeamowmeT kavSiri monacemTa bazasTan';
echo'<br/><a href="index.php?act=db">ukan</a>';
}
}
else
{
echo'<form action="?act=db&amp;install=db" method="POST"><div class="egmenu">';
echo'SeiyvaneT aucilebeli parametrebi monacemtTa bazis dasakavSireblad.<br/>';
echo'serveris misamarTi<br/><input type="text" name="host" value="localhost"/><br/>';
echo'bazis saxelwodeba<br/><input type="text" name="name" value=""/><br/>';
echo'momxmareblis saxeli<br/><input type="text" name="user" value=""/><br/>';
echo'MySQL paroli<br/><input type="text" name="pass"/><br/>';
echo'<input type="submit" value="gagrZeleba"/></div></form>';
}}
break;
/**ადმინის რეგისტრაცია**/
case 'install_admin':
require $root_path.'/includes/db_connect.php'; // ბაზასთან დაკავშირება
if (isset($_POST['login']) && isset($_POST['pass1']) && isset($_POST['pass2']) && isset($_POST['title']) )
{
$login = stripslashes(htmlspecialchars($_POST['login']));
$pass1 = stripslashes(htmlspecialchars($_POST['pass1']));
$pass2 = stripslashes(htmlspecialchars($_POST['pass2']));
$time=$time;


mysql_query("INSERT INTO `user_guest` (`title`, `timeshift`, `p_count`, `set_them`, `show_err_php`, `guest_guestbook_write`, `guest_komm_write`, `guest_forum_create_theme`, `guest_forum_write`, `forum_edit_time`, ``, ``) VALUES ('$ip', '".mysql_real_escape_string($ua)."', '".$time."')");

$set['title'] = stripslashes(htmlspecialchars($_POST['title']));
$set['timeshift']="0";
$set['p_count']="10";
$set['set_them']="Default";
$set['show_err_php']="1";
$set['guest_guestbook_write']="1";
$set['guest_komm_write']="1";
$set['guest_forum_create_theme']="1";
$set['guest_forum_write']="1";
$set['forum_edit_time']="600";
$set['permission_reg']="1";
$set['email_reg']="1";
$set['set_lang']="ka";
$set['meta_key']="";
$set['meta_desc']="";
// პაროლის შემოწმება
if(mb_strlen($pass1)<6)
{
$err[]='Zalian moklea paroli (min 4)';
}
if(mb_strlen($pass1)>20)
{
$err[]='Zalian grZelia paroli (max 20)';
}
if ($pass1!=$pass2)
{
$err[]='parolebi ar emTxveva';
}
if (!isset($_POST['email']) || $_POST['email']==NULL)
{
$err[]='aucilebelia SeiyvanoT E-MAILi';
}
if (!preg_match('#^[A-z0-9-\._]+@[A-z0-9]{2,}\.[A-z]{2,4}$#ui',$_POST['email']))
{
$err[]='arasworia E-MAILis formati';
}
if(mb_strlen($login)<2)
{
$err[]='Zalian moklea logini (min 3)';
}
if(mb_strlen($login)>32)
{
$err[]='Zalian grZelia logini (max 32)';
}
if (!preg_match("#^[a-zა-ჰ0-9\-\_\ ]+$#ui", $login))
{
$err[]='loginSi gamoyenebulia akrZaluli simboloebi';
}
if(mb_strlen($set['title'])<2)
{
$err[]='Zalian moklea saitis saxelwodeba (min 2)';
}
if(mb_strlen($set['title'])>64)
{
$err[]='Zalian grZelia saitis saxelwodeba (max 64)';
}
if (preg_match("#[a-z]+#ui", $login) && preg_match("#[ა-ჰ]+#ui", $login))
{
$err[]='nebadarTulia mxolod latinuri da rusulia alfaviti';
}
if (preg_match("#(^\ )|(\ $)#ui", $login))
{
$err[]='akrZalulia probelis gamoyeneba loginis dasawyisSi da dasasrulSi';
}
if (!isset($err))
{
mysql_query("INSERT INTO `settings` (`id`,`title`, `timeshift`, `p_count`, `set_them`, `show_err_php`, `guest_guestbook_write`, `guest_komm_write`, `guest_forum_create_theme`, `guest_forum_write`, `forum_edit_time`, `permission_reg`, `email_reg`, `set_lang`, `meta_key`, `meta_desc`) VALUES ('1', '".$set['title']."', '".$set['timeshift']."', '".$set['p_count']."', '".$set['set_them']."', '".$set['show_err_php']."', '".$set['guest_guestbook_write']."', '".$set['guest_komm_write']."', '".$set['guest_forum_create_theme']."', '".$set['guest_forum_write']."', '".$set['forum_edit_time']."', '".$set['permission_reg']."', '".$set['email_reg']."', '".$set['set_lang']."', '', '')");
}
if (!isset($err))
{
mysql_query("INSERT INTO `users` SET `login`='".mres($login)."', `pass`='".md5($pass1.$login)."', `regtime`='".$time."', `lastvisit`='".$time."', `sqe`='".intval($_POST['pol'])."', `email`='".mres($_POST['email'])."'");
$users['id']=mysql_insert_id();
mysql_query('UPDATE `users` SET `level` = "10" WHERE `id` = "'.$users['id'].'" LIMIT 1');
msg('<div class="menu">Tqven warmatebiT daregistrirdiT</div>');
$users=mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$users[id]' LIMIT 1"));
echo'<div class="menu">Tqveni logini: <b>'.$login.'</b><br/>
Tqveni paroli: <b>'.$pass1.'</b><br/>';
echo'dayeneba dasrulebulia<br/>
<span style="color:#ff0000">aucileblad waSalet saqaRalde /install/</span><br/>';
echo'<span style="color:#ff0000">daayeneT ufleba 755 saqaRalde /incfiles</span><br/>';
echo'<span style="color:#ff0000">daayeneT ufleba 644 failze  /includes/db_connect.php</span>';
echo'<form action="'.$root_path.'pages/login.php?" method="post" />';
echo'<input type="hidden" name="login" value="'.$login.'"  />';
echo'<input type="hidden" name="pass" value="'.$pass1.'"  />';
echo'<input type="submit" value="saitze Sesvla" />';
echo'</form></div>';
}
err();
}
else
{
if(mysql_num_rows(mysql_query('SELECT * FROM `users` LIMIT 1')))
{
echo'<div class="errmenu">monacemTa bazaSi ukve arsebobs momxmarebeli!</div>';
}else{
echo'<div class="hdr"><b>ZiriTadi parametrebi da adminis registracia</b></div>';
echo'<div class="egmenu"><form action="index.php?act=install_admin" method="POST">';
echo'logini(max 20):<br/>';
echo'<input type="text" name="login" maxlength="20" /><br/>';
echo "Tqveni sqesi:<br/><select name='pol'><option value='1'>kaci</option><option value='0'>qali</option></select><br/>\n";
echo "E-mail:<br/><input type='text' name='email' maxlength='50' /><br/>\n";
echo'paroli(max 20):<br/>';
echo'<input type="text" name="pass1" maxlength="20" /><br/>';
echo'SeiyvaneT kidev erTxel:<br/>';
echo'<input type="text" name="pass2" maxlength="20" /><br/>';
echo'<div class="razdel">saitis parametrebi</div>';
echo'saitis saxelwodeba(max 64):<br/>';
echo'<input type="text" name="title" maxlength="64" /><br/>';
echo'<input type="submit" value="dayeneba">';
echo'</form></div>';
echo'<div class="hdr"><small>*paroli unda Seicavdes asoebs da cifrebs</small></div>';
}}
break;
}
echo'</div></div><div class="footer">';
echo'&copy; SitchiCMS<br/>';
echo''.round(microtime(1)-$microtime,4);
echo'</div></body></html>';
exit;
?>