Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
include "include/header.php";
echo '<div class="main-info-left">
<form method="post" action="">
<fieldset>
<legend>Инсталация:</legend>
<ul>
<li>
Потребител: <input type="text" name="user" value="" class="input"/><br />
<small>Тук въведете потребителското име за вход в базата данни !</small>
</li>
<li>
Парола: <input type="text" name="pass" value="" class="input"/><br />
<small>Тук въведете потребителската парола за вход в базата данни !</small>
</li>
<li>
Хост: <input type="text" name="host" value="" class="input"/><br />
<small>Тук въведете хоста !</small>
</li>
<li>
База данни: <input type="text" name="db" value="" class="input"/><br />
<small>Тук въведете името на базата данни !</small>
</li>
<li>
<input type="submit" name="submit" value="Инсталирай" class="button" />
</li>
<li>
<input type="reset" name="reset" value="Изчисти" class="button" />
</li>
</ul>
</fieldset>
</form><br /><br />
</div>';
if (isset($_POST['submit']))
{
// ================================================================
$user = $_POST['user']; // ДБ потребител
$pass = $_POST['pass']; // ДБ парола
$db = $_POST['db']; // ДБ име
$host = $_POST['host']; // Дб хост
// ================================================================
if (empty($user) or empty($db) or empty($host))
{
echo "<center><b>Не може да оставяте задължителни полета празни !</b></center>";
}
else
{
// Свръзване с ДБ (Проверяваме за грешки)
$conn=mysql_connect($host,$user,$pass) or die("<center><b>Не може да се свърже със сървъра</b></center>");
mysql_query("CREATE DATABASE $db", $conn) or die(mysql_error());
//Създаваме таблиците
$db_file="db.txt";
$db_file_text=file_get_contents($db_file);
mysql_query($db_file_text, $conn);
// Затваряме връзката с MySQL
mysql_close();
//Редактиране config файла
$file="../include/config.php";
$fopen=fopen($file, "a");
$code='<?php
session_start();
ob_start();
//Connect to database
$user="'.$user.'";
$pass="'.$pass.'";
$db="'.$db.'";
$host="'.$host.'";
$connection=mysql_connect($host,$user,$pass) or die("Mysql error");
$db=mysql_select_db($db,$connection) or die("Mysql error2");
mysql_query("SET NAMES UTF8");
$lg=mysql_query("SELECT * FROM `users` WHERE `username` = \"$_SESSION[logged]\"") or die(mysql_error());
$logged=mysql_fetch_assoc($lg);
//Site options
$path=$_SERVER["REQUEST_URI"];
$path=explode("/", $path);
$path=explode("/", $path[1]);
$csspath=$path[0];
$path=$path[0];
$path=$_SERVER["DOCUMENT_ROOT"]."/".$path."/";
//About css,js
$style="http://".$_SERVER["SERVER_NAME"]."/"."$csspath"."/";
?>
';
fwrite($fopen, $code);
fclose($fopen);
echo "<center><b>Успешно инсталирахте Tilboo CMS, моля изтрийте цялата директория <b>install</b></center>";
}
}
echo '<br /><br />';
include "include/footer.php";
?>
Ти нещо не ме разбраkulov каза:То създава базата данни, не добавя таблиците в нея..![]()
mysql_query("CREATE DATABASE $db", $conn) or die(mysql_error());
mysql_query($db_file_text, $conn);
function getSQL($file)
{
$fh = fopen($file, 'r');
$text = fread($fh, filesize($file));
fclose($fh);
//$pattern = "%(#[^\r\n]+|/\*.*?\*/|//[^\r\n]+)%sim";
//$text= preg_replace($pattern,'',$text);
$sep=" |SEP| ";
$text = preg_replace("/USE/", " $sep USE", $text);
$text = preg_replace("/DROP/", " $sep DROP", $text);
$text = preg_replace("/INSERT/", " $sep INSERT", $text);
$text = preg_replace("/CREATE/", " $sep CREATE", $text);
$text = preg_replace("/UPDATE/", " $sep UPDATE", $text);
$text = preg_replace("/ALTER/", " $sep ALTER", $text);
$sqls = explode($sep, $text);
return $sqls;
}
if(substr($files, -3, 3) == "sql"){
foreach(getSQL($files) as $sql){
if($sql == "" || $sql == NULL){
//Do Nothing
}
else{
$query = mysql_query($sql);
}
}
}
if(!file_exists("../lib/config.php") || filesize("../lib/config.php") < 10){
$config = "<?php\n";
$config .= "\$selectSettings = mysql_query(\"SELECT * FROM `settings`\") or die(MYSQL_QUERY_ERROR.mysql_error());\n";
$config .= "\$getSettings = mysql_fetch_array(\$selectSettings);\n\n";
$config .= "\$dbs = explode(\",\", \$getSettings['databases']);\n\n";
$config .= "\$selectRows = mysql_query(\"SELECT * FROM `news`\") or die(MYSQL_QUERY_ERROR.mysql_query());\n";
$config .= "\$totalRows = mysql_num_rows(\$selectRows);\n\n";
$config .= "define(\"DEFAULT_PAGING\", 1);\n";
$config .= "define(\"MARGIN_PAGING\", 2);\n";
$config .= "define(\"ALLOW_DONATE\", \$getSettings['donateSystem']);\n";
$config .= "define(\"ALLOW_FORUM\", \$getSettings['allowForum']);\n";
$config .= "define(\"MARGIN\", \$getSettings['marginPage']);\n";
$config .= "define(\"PER_PAGE\", \$getSettings['perPage']);\n";
$config .= "define(\"TOTAL_ROWS\", \$totalRows);\n";
$config .= "define(\"SITE_TITLE\", \$getSettings['siteTitle']);\n";
$config .= "define(\"SITE_NAME\", \$getSettings['siteName']);\n";
$config .= "define(\"META_DESC\", \$getSettings['metaDescription']);\n";
$config .= "define(\"META_KEYWORDS\", \$getSettings['metaKeyWords']);\n";
$config .= "define(\"MANGOS_DB\", \$dbs[0]);\n";
$config .= "define(\"REALMD_DB\", \$dbs[1]);\n";
$config .= "define(\"CHAR_DB\", \$dbs[2]);\n";
$config .= "define(\"SERVER_EXPANSION\", \$getSettings['serverExpansion']);\n\n";
$config .= "\$prefix = (SERVER_EXPANSION > 1)? 54 : 34;\n";
$config .= "?>";
$fp = fopen("../lib/config.php", "w");
fputs($fp, $config, strlen($config));
fclose($fp);
$file_contents = file_get_contents("../lib/classes/class.database.php");
$explode_array = explode("\n",$file_contents);
$explode_array[22] = preg_replace("/private \\\$_host (=) (\")+(\S+)/m", "private \\\$_host $1 $2$33{$host}\";", $explode_array[22]);
$explode_array[23] = preg_replace("/private \\\$_user (=) (\")+(\S+)/m", "private \\\$_user $1 $2$33{$usr}\";", $explode_array[23]);
$explode_array[24] = preg_replace("/private \\\$_pass (=) (\")+(\S+)/m", "private \\\$_pass $1 $2$33{$pwd}\";", $explode_array[24]);
file_put_contents("../lib/classes/class.database.php", implode("\n", $explode_array));
}