-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path_install.php
More file actions
131 lines (122 loc) · 3.84 KB
/
_install.php
File metadata and controls
131 lines (122 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?
// ===================================================================
// Sim Roulette -> Installer
// License: GPL v3 (http://www.gnu.org/licenses/gpl.html)
// Copyright (c) 2016-2025 Sim Roulette, https://sim-roulette.com
// ===================================================================
$GLOBALS['set_data']['main_menu']='Установка - index.php';
if ($_POST['save'])
{
if (!file_exists($_POST['root'].'/_install.php'))
{
$error='Неверный путь к скрипту!';
}
else
{
$txt=file_get_contents('api/handler.php');
$txt=str_replace('$root="[path]"','$root="'.$_POST['root'].'/"',$txt);
file_put_contents('api/handler.php',$txt);
$txt=file_get_contents('cron.php');
$txt=str_replace('$root="[path]"','$root="'.$_POST['root'].'/"',$txt);
file_put_contents('cron.php',$txt);
$txt=file_get_contents('link.php');
$txt=str_replace('$root="[path]"','$root="'.$_POST['root'].'/"',$txt);
file_put_contents('link.php',$txt);
$txt=file_get_contents('_config.php');
$txt=str_replace('$host="'.$host.'"','$host="'.$_POST['host'].'"',$txt);
$txt=str_replace('$username="'.$username.'"','$username="'.$_POST['username'].'"',$txt);
$txt=str_replace('$userpass="'.$userpass.'"','$userpass="'.$_POST['userpass'].'"',$txt);
$txt=str_replace('$dbname="'.$dbname.'"','$dbname="'.$_POST['dbname'].'"',$txt);
if ($_POST['host'] && $_POST['username'] && $_POST['userpass'] && $_POST['dbname'])
{
$db = mysqli_connect(
$_POST['host'],
$_POST['username'],
$_POST['userpass'],
$_POST['dbname']);
}
if (!$db)
{
$error='Нет соединения с БД!';
$host=$_POST['host'];
$username=$_POST['username'];
$userpass=$_POST['userpass'];
$dbname=$_POST['dbname'];
}
else
{
mysqli_set_charset($db, 'utf8');
$qry=explode("\n\n",str_replace("\r","",file_get_contents('install.dat')));
foreach ($qry as $data)
{
if (!mysqli_query($db, $data))
{
$error='Не удалось создать таблицу!';
$txt=file_get_contents('_config.php');
$txt=str_replace('$userpass="'.$_POST['userpass'].'"','$userpass=""',$txt);
file_put_contents('_config.php',$txt);
$userpass=$_POST['userpass'];
break;
}
}
}
file_put_contents('_config.php',$txt);
}
}
sr_header("Установка SR Navigator");
?>
<br>
<?
if ($_POST['save'] && !$error)
{
unlink('_install.php');
?>
<div class="status_ok">SR Navigator успешно установлен!</div>
— Пропишите в планировщике CRONTAB ежеминутный запуск файла <b><?=__DIR__?>/cron.php</b>
<br><br><br><br>
<a href="index.php" class="green-border">Начать работу</a>
<?
}
if (!$_POST['save'] || $error)
{
?>
<em>Системные требования: PHP 5.3 и выше, MySQL</em>
<br><br>
<?
if ($error)
{
?>
<div class="status_error">При установке произошла ошибка: <?=$error?></div>
<?
}
?>
<form method="post">
<h3>Настройки сервера</h3>
Путь к каталогу со скриптом на сервере
<br>
<input type="text" name="root" value="<?=__DIR__?>" maxlength="200">
<br>
<h3>Настройки MySQL</h3>
Хост
<br>
<input type="text" name="host" value="<?=$host?>" maxlength="100">
<br><br>
Имя пользователя
<br>
<input type="text" name="username" value="<?=$username?>" maxlength="100">
<br><br>
Пароль
<br>
<input type="text" name="userpass" value="<?=$userpass?>" maxlength="100">
<br><br>
Название Базы Данных
<br>
<input type="text" name="dbname" value="<?=$dbname?>" maxlength="100">
<br><br>
<div id="loading"><img src="sr/loading.gif"></div>
<input type="submit" name="save" value="Установить" onclick="this.style.display='none';document.getElementById('loading').style.display='block';" style="padding: 10px;">
</form>
<?
}
sr_footer();
?>