-
Notifications
You must be signed in to change notification settings - Fork 39
/
webserver.php
executable file
·161 lines (111 loc) · 4.79 KB
/
webserver.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
<?php
require '/var/www/classes/Session.class.php';
$session = new Session();
if($session->issetLogin()){
if($_SERVER['REQUEST_METHOD'] == 'POST'){
require '/var/www/classes/Player.class.php';
require '/var/www/classes/PC.class.php';
require '/var/www/classes/Internet.class.php';
require '/var/www/classes/Process.class.php';
$player = new Player();
$internet = new Internet();
$software = new SoftwareVPC();
$hardware = new HardwareVPC();
$process = new Process();
if(isset($_POST['uid']) && isset($_POST['content'])){
$uid = $_POST['uid'];
$content = $_POST['content'];
if(!ctype_digit($uid)){
die("Invalid user ID");
}
if(empty($content)){
die("Insert web server text");
}
$system = new System();
if(!$system->validate($content, 'text')){
echo "<br/>".$content."<br/>";
die("<br/><strong>Invalid web server text</strong>");
}
require '/var/www/classes/Purifier.class.php';
$purifier = new Purifier();
$purifier->set_config('text');
$content = $purifier->purify($content);
if(strlen($content) == 0){
exit("Please insert some valid text");
}
if($uid != $_SESSION['id']){
$redirect = 'internet?view=software';
$victimID = $uid;
$host = 'remote';
$valid = 0;
if($session->issetInternetSession()){
$victimInfo = $player->getIDByIP($_SESSION['LOGGED_IN'], 'VPC');
if($victimInfo['0']['existe'] == 1){
if($victimInfo['0']['id'] == $uid){
$valid = 1;
}
}
}
if($valid == 0){
die("For some reason, this web server edition is not valid. Sorry");
}
} else {
$redirect = 'software.php';
$victimID = 0;
$host = 'local';
}
if(!$player->isPremium($uid)){
die("This user is not premium");
}
$webServerSoftware = $software->getBestSoftware(18, $uid, 'VPC');
if($webServerSoftware['0']['exists'] == 0){
die("The user doesnt have webserver software");
}
$softID = $webServerSoftware['0']['id'];
$softInfo = $software->getSoftware($softID, $uid, 'VPC');
if($softInfo->softhidden != 0){
die("Unhid before running the webserver");
}
if(!$software->isInstalled($softID, $uid, 'VPC')){
$hardware = new HardwareVPC();
$ramInfo = $hardware->calculateRamUsage($uid, 'VPC');
if($ramInfo['AVAILABLE'] < $softInfo->softram){
die("Not enough ram to run the server");
}
}
if($process->newProcess($_SESSION['id'], 'INSTALL_WEBSERVER', $victimID, $host, $softID, '', $content, 0)){
header("Location:processes.php");
exit();
$process->getProcessInfo($_SESSION['pid']);
echo "<tr><td>";
$process->showProcess();
echo "</td></tr>";
} else {
if (!$session->issetMsg()) {
header("Location:processes.php");
exit();
if ($pid != NULL) {
$session->processID('add', $pid);
$process->getProcessInfo($_SESSION['pid']);
$session->processID('del');
echo "<tr><td>";
$process->showProcess();
echo "</td></tr>";
} else {
die("Process not found! :S");
}
} else {
header("Location:".$redirect);
}
}
} else {
echo 'bad';
}
} else {
$session->addMsg('Invalid get.', 'error');
header("Location:software.php");
}
} else {
header("Location:index.php");
}
?>