forked from wizwizdev/wizwizxui-timebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
288 lines (270 loc) · 13.9 KB
/
install.php
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'){
form("ربات باید روی دامنه ی دارای ssl فعال نصب بشه!");
exit();
}
if(!file_exists("../createDB.php") || !file_exists("../baseInfo.php") || !file_exists("../bot.php") || !file_exists("../config.php")){
form("فایل های مورد نیاز ربات یافت نشد");
exit();
}
$fileAddress = str_replace(["install.php","?webhook", "?install", "?updateBot", "?update", "/install"],"", "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$botUrl = $fileAddress . "bot.php";
if(isset($_REQUEST['webhook'])){
$botToken = $_POST['bottoken'];
$adminId = $_POST['adminid'];
$dbName = $_POST['dbname'];
$dbUser = $_POST['dbuser'];
$dbPassword = $_POST['dbpassword'];
$connection = new mysqli('localhost',$dbUser,$dbPassword,$dbName);
if($connection->connect_error){
form("خطای دیتابیس: " . $connection->connect_error);
exit();
}
$checkBot = json_decode(file_get_contents("https://api.telegram.org/bot" . $botToken . "/getwebhookinfo"));
if($checkBot->ok){
if($checkBot->result->url != ""){
form("این ربات قبلاً نصب شده");
exit();
}
}else{
form("رباتی با این توکن یافت نشد");
exit();
}
$baseInfo = file_get_contents("../baseInfo.php");
$baseInfo = str_replace(['[BOTTOKEN]','[DBUSERNAME]','[DBPASSWORD]','[DBNAME]','[ADMIN]','[BOTURL]'],
[$botToken, $dbUser, $dbPassword, $dbName, $adminId, $fileAddress],
$baseInfo);
file_put_contents("../baseInfo.php", $baseInfo);
file_get_contents($fileAddress. "createDB.php");
$response = json_decode(file_get_contents("https://api.telegram.org/bot" . $botToken . "/setWebhook?url=" . $botUrl));
if($response->ok){
file_get_contents("https://api.telegram.org/bot" . $botToken . "/sendMessage?chat_id=" . $adminId . "&text=✅| ربات ویزیز با موفقیت نصب شد");
form("ربات با موفقیت نصب شد", false);
}
}elseif(isset($_REQUEST['install'])){
$baseInfo = file_get_contents("../baseInfo.php");
if(!strstr($baseInfo, '[BOTTOKEN]') || !strstr($baseInfo, '[DBUSERNAME]')
|| !strstr($baseInfo, '[DBPASSWORD]') || !strstr($baseInfo, '[DBNAME]')
|| !strstr($baseInfo, '[ADMIN]')){
form('روی این سورس قبلاً رباتی نصب شده!');
exit();
}
showForm("install");
}elseif(isset($_REQUEST['update'])){
showForm("update");
}
elseif(isset($_REQUEST['updateBot'])){
if (!file_exists("update.php")){
echo '<script type="text/javascript">alert("فایل آپدیت یافت نشد");history.go(-1)</script>';
exit();
}
require "update.php";
require "../baseInfo.php";
$connection = new mysqli('localhost',$dbUserName,$dbPassword,$dbName);
if($connection->connect_error){
form("خطای دیتابیس: " . $connection->connect_error);
exit();
}
updateBot();
form("ربات با موفقیت آپدیت شد نسخه 7.5.3 می باشد",false);
}
else{
showForm("unknown");
}
?>
<?php
function showForm($type){
?>
<html lang="en">
<head>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', });
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'>m_auth=>m_preview=>m_cookies_win=x';
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-MSN6P6G');</script>
<meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title><?php if($type=="unknown") echo "نصب و آپدیت خودکار ویزویز";
elseif ($type=="install") echo "نصب ربات";
elseif ($type=="update") echo "آپدیت ربات";
?></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" href="../assets/style.css" rel="stylesheet" />
<style>
body{
direction: rtl;
padding-top: 15px;
text-align: center;
background: #345987;
}
button{
cursor: pointer;
font-size: 18px;
width: 90%;
margin-bottom: 10px;
border-radius: 10px;
padding: 10px;
border: 1px #eae1e1 solid;
font-family: iransans !important;
}
type[input]{
direction: rtl;
}
</style>
</head>
<body>
<?php if ($type=="unknown"){?>
<div>
<img src="../assets/logo.png" width="200px">
</div>
<br>
<div>
<a href="./install.php?install">
<button style="background-color: #e0eeee;
border: none;font-weight: 600;color: #000509" type="button">
<span>نصب ربات</span>
</button>
</a>
<a href="./install.php?update">
<button style="margin: 5px;background-color: #eccfde;
border: none;font-weight: 600;color: #620738">
<span>آپدیت ربات</span>
</button>
</a>
</div>
<div style="margin-top: 5px">
<span>
<a target="_blank" href="https://t.me/wizwizch">
<button style="width: 150px;margin: 5px;padding: 3px;font-size: 16px">
<span>کانال تلگرام</span>
</button>
</a>
</span>
<span>
<a target="_blank" href="https://t.me/wizwizdev">
<button style="width: 150px;margin: 5px;padding: 3px;font-size: 16px">
<span>گروه تلگرام</span>
</button>
</a>
</span>
</div>
<?php }elseif($type=="update"){
?>
<h1 style="font-size: 25px">لطفا جهت آپدیت روی دکمه زیر رو بزنید</h1>
<a href="./install.php?updateBot">
<button type="button" class="ant-btn ant-btn-primary ant-btn-block ant-btn-rtl PayPing-button always-white">
<span>آپدیت ربات</span>
</button>
</a>
<?php
}
elseif($type=="install"){ ?>
<h1>نصب ربات ویزویز</h1>
<div class="container">
<form id="contact" action="install.php?webhook" method="post">
<h3>لطفا اطلاعات خواسته شده را وارد کنید</h3>
<h4>نظرات و پیشنهادات خود را در گروه تلگرامی wizwizdev ارسال کنید</h4>
<fieldset>
<input placeholder="توکن ربات" type="text" name="bottoken" autocomplete="off" required >
</fieldset>
<fieldset>
<input placeholder="آیدی عددی ادمین" type="text" name="adminid" autocomplete="off" required>
</fieldset>
<fieldset>
<input placeholder="اسم دیتابیس" type="text" name="dbname" autocomplete="off" required>
</fieldset>
<fieldset>
<input placeholder="یوزرنیم دیتابیس" type="text" name="dbuser" autocomplete="off" required>
</fieldset>
<fieldset>
<input placeholder="پسورد دیتابیس" type="text" name="dbpassword" autocomplete="off" required>
</fieldset>
<fieldset>
<button class="btninstall" type="submit">نصب ربات</button>
</fieldset>
<p style="font-size:13px">Made with 🖤 in <a target="_blank" href="https://github.com/wizwizdev/wizwizxui-timebot">wizwiz</a></p>
</form>
</div>
<br>
<br>
<?php } ?>
</body>
</html>
<?php
}
function form($msg, $error = true){
?>
<html dir="rtl">
<head>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];
w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js', });
var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'>m_auth=>m_preview=>m_cookies_win=x';
f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-MSN6P6G');
</script>
<meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>نصب ربات ویزویز</title>
<meta name="next-head-count" content="4">
</head>
<style>
.ant-layout1 {
background: #f0f2f5;
display: flex;
flex: auto;
flex-direction: column;
min-height: 0;
}
.PayPing-layout1 {
background-color: #fff;
}
body, html {
padding: 0;
margin: 0;
font-family: iransans !important;
}
a {
color: inherit;
text-decoration: none;
}
* {
box-sizing: border-box;
}
.w-100 {
width: 100%
}
.align-center {
align-items: center!important;display: flex;
}
.justify-center {
display: flex;justify-content: center!important;
}
</style>
<body>
<div id="__next">
<section class="ant-layout1 PayPing-layout1 " style="min-height:100vh;display: flex;justify-content: center!important;background-color: #172b4d;direction: rtl;">
<main class="" style="display: flex;flex-direction: column!important;align-items: center!important;display: flex;display: flex;justify-content: center!important;">
<div class="justify-center align-center w-100">
<div style="background-color: #fff;border-radius: 5px;padding: 20px;position: relative;display: block;flex: 0 0 50.83333333%;max-width: 50.83333333%;right: auto;left: auto;align-items: center;display: flex;justify-content: center!important;" class="">
<div style="padding-bottom: 2rem!important;padding-top: 2rem!important;align-items: center!important;display: flex;color: #e31b23;display: flex;flex-direction: column!important;" class="">
<?php if ($error == true){ ?> <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24" class="PayPing-icon" stroke-width="1" width="100">
<circle cx="12" cy="12" r="11"></circle>
<path d="M15.3 8.7l-6.6 6.6M8.7 8.7l6.6 6.6"></path>
</svg>
<?php }?>
<div class="" style="padding: 40px 30px" > <?php echo $msg ?></div>
</div>
</div>
</div>
</main>
</section>
</div>
</body>
</html>
<?php
}
?>