-
Notifications
You must be signed in to change notification settings - Fork 44
/
compatibilityCore.php
573 lines (557 loc) · 34.9 KB
/
compatibilityCore.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<?php
/*
HRCLOUD2 VERSION INFORMATION
THIS VERSION : v3.5.3
WRITTEN ON : 4/13/2021
*/
// / -----------------------------------------------------------------------------------
// / This file is the HRCloud2 Compatibility Core! It is responsible for making sure HRCloud2 works. It will also
// / keep HRCloud2 up-to-date, and remove deprecated files that could pose security risks. Lastly, this file will
// / clean and regenerate HRCloud2 cache files.
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The follwoing code checks for required core files and terminates if they are missing.
if (!file_exists(realpath(dirname(__FILE__)).'/commonCore.php')) die ('ERROR!!! HRC2CompatCore14, Cannot process the HRCloud2 Common Core file (commonCore.php).<br />');
else require_once (realpath(dirname(__FILE__)).'/commonCore.php');
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code will check the PHP version installed on the server and return a warning message if anything less than 7.0 is detected.
if (version_compare(PHP_VERSION, '7.0.0') <= 0) {
$txt = 'WARNING!!! HRC2CompatCore35, This server is running PHP version '.PHP_VERSION.'. HRCloud2 performs best using PHP 7.0 or later!';
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code will check the O/S installed on the server and return a warning message if Windows is detected.
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$txt = 'WARNING!!! HRC2CompatCore44, HRCloud2 was designed to be run on a Linux-based operating system!';
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code sets the global variables for the session.
$ResourceDir = $InstLoc.'/Resources/TEMP';
$ResourceDir1 = $ResourceDir.'/HRCloud2-master';
$UpdatedZIP1 = $ResourceDir.'/HRC2UPDATE1.zip';
$UpdatedZIPURL = 'https://github.com/zelon88/HRCloud2/archive/master.zip';
$HRC2Config = $InstLoc.'/config.php';
$HRAIConfig = $InstLoc.'/Applications/HRAI/adminINFO.php';
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed whenever a user selects to clear their user cache.
if ($ClearCachePOST == '1' or $ClearCachePOST == 'true' or $ClearCachePOST == 'Clear User Cache') {
if ($UserIDRAW == 0) {
$txt = 'ERROR!!! HRC2CompatCore54, A non-logged-in user attempted to Clear the User Cache on '.$Time.'.';
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
$txt = ('OP_Act: Initiated User Cache Cleaner on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
unlink($UserConfig);
if (!file_exists($UserConfig)) {
copy($LogInstallDir.'.config.php', $UserConfig); }
if (!file_exists($UserConfig)) {
$txt = ('ERROR!!! HRC2CompatCore55, There was a problem creating the user config file on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die ($txt.$hr); }
if (file_exists($UserConfig)) {
$txt = ('OP-Act: Cleaned user cache files on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
require ($UserConfig); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed whenever a user selects to clear their user cache.
if ($ClearFavoritesPOST == '1' or $ClearFavoritesPOST == 'true' or $ClearFavoritesPOST == 'Clear Favorites') {
if ($UserIDRAW == 0) {
$txt = 'ERROR!!! HRC2CompatCore96, A non-logged-in user attempted to Clear User Favorites on '.$Time.'.';
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
$txt = ('OP_Act: Initiated User Favorites Cleaner on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
@unlink($FavoritesCacheFileCloud);
copy($LogInstallDir.'.favorites.php', $FavoritesCacheFileCloud);
@unlink($FavoritesCacheFileInst);
copy($LogInstallDir.'.favorites.php', $FavoritesCacheFileInst);
if (!file_exists($FavoritesCacheFileCloud)) {
$txt = ('ERROR!!! HRC2CompatCore106, There was a problem creating the user favorites file on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die ($txt.$hr); }
if (file_exists($FavoritesCacheFileCloud)) {
$txt = ('OP-Act: Cleaned user favorite cache files on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed whenever a user requests that HRCloud2 Auto-Update to the latest version.
// / Will establish a CuRL connection to Github and download the latest Master commit in .zip form and unpack it
// / to the $InstLoc. Temporary files will then be deleted.
if ($AutoUpdatePOST == '1' or $AutoUpdatePOST == 'true' or $AutoUpdatePOST == 'Automatic Update') {
$AutoDownloadPOST = $AutoInstallPOST = $AutoInstallPOST = $CheckCompatPOST = 'true';
$txt = ('OP-Act: Initiating Auto-Updater on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
if ($UserIDRAW !== 1) {
$txt = ('ERROR!!! HRC2CompatCore43, A non-administrator attempted to update the system on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
if (!file_exists($ResourceDir)) {
mkdir($ResourceDir, 0755);
$txt = ('OP-Act: Created a TEMP directory in /Resources to store pending updates on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed whenever a user selects to download an update package.
if ($AutoDownloadPOST == '1' or $AutoDownloadPOST== 'true' or $AutoDownloadPOST == 'Download Update') {
$txt = ('OP-Act: Initiating Update-Downloader on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
if ($UserIDRAW !== 1) {
$txt = ('ERROR!!! HRC2CompatCore89, A non-administrator attempted to download a system update on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
set_time_limit(0);
$txt = ('OP-Act: Opening a connection to Github and downloading data on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$MAKEUpdatedZIP = file_put_contents($UpdatedZIP1, @fopen($UpdatedZIPURL, 'r'));
if (!file_exists($UpdatedZIP1)) {
$txt = ('ERROR!!! HRC2CompatCore110, Could not open a connection to Github on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die ($txt.$hr); }
set_time_limit(0);
if (file_exists($UpdatedZIP1)) {
$txt = ('OP-Act: The latest version of HRCloud2 was sucessfully downloaded on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed whenever a user selects to install an update package.
if ($AutoInstallPOST == '1' or $AutoInstallPOST == 'true' or $AutoInstallPOST == 'Install Update') {
$txt = ('OP-Act: Initiating Update-Installer on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
echo($txt.$hr);
// / The following code checks that the user is an administrator.
if ($UserIDRAW !== 1) {
$txt = ('ERROR!!! HRC2CompatCore51, A non-administrator attempted to install a cached update on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
// / The following code checks that there is an update .zip package to install before continuing.
// / If a .zip file does exist, it is unpacked.
if (file_exists($UpdatedZIP1)) {
shell_exec('unzip -o '.$UpdatedZIP1.' -d '.$ResourceDir);
$txt = ('OP-Act: Unpacked archive on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
// / The following code is an error handler for if an update .zip package does NOT exist.
if (!file_exists($UpdatedZIP1)) {
$txt = ('ERROR!!! HRC2CompatCore108, There are no stored update packages on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
// / The following code is performed as a check that the update .zip package was unpacked.
if (!file_exists($ResourceDir1.'/config.php')) {
$txt = ('ERROR!!! HRC2CompatCore130, There was a problem unpacking the update packages on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
// / The following code is performed when an update .zip package was sucessfully unpacked.
// / It will recursively copy all update files and directories to a folder, and then zip that folder
// / into an "installation image" that we can over-write the $InstLoc with.
if (!file_exists($ResourceDir1.'/config.php')) {
$txt = ('ERROR!!! HRC2175, Unable to download data! Check that Github is not undergoing maintanence on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die(); }
if (file_exists($ResourceDir1.'/config.php')) {
$txt = ('OP-Act: The update packages were unpacked sucessfully on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$UPDATEFiles = scandir($ResourceDir1); }
// / The following code checks the HRCloud2 version and stops the update process if an old version was prepared.
if (!file_exists($ResourceDir1.'/versionInfo.php')) {
$txt = ('ERROR!!! HRC2CompatCore223, Could not verify the latest "versionInfo.php" on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
require ($InstLoc.'/versionInfo.php');
$Version0 = trim($Version, 'v');
$V0Len = strlen($Version0);
require ($ResourceDir1.'/versionInfo.php');
$Version1 = trim($Version, 'v');
$V1Len = strlen($Version1);
if ($V0Len >= $V1Len) {
$VLenDiff = $V0Len - $V1Len; }
while ($VLenDiff !== 0) {
$Version1 = $Version1.'0';
$VLenDiff--; }
if ($V1Len >= $V0Len) {
$VLenDiff = $V1Len - $V0Len; }
while ($VLenDiff !== 0) {
$Version0 = $Version0.'0';
$VLenDiff--; }
require ($InstLoc.'/versionInfo.php');
if ($Version1 < $Version0) {
$txt = ('ERROR!!! HRC2CompatCore139, The pending HRCloud2 update is older than the one already in use on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die ($txt.$hr); }
// / The following code preserves the base HRCloud2 configuration files to be restored after the update.
$txt = ('OP-Act: Preserving server configuration data on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$BAKinc = 0;
while (file_exists($InstLoc.'/BACKUP/configBACKUP'.$BAKinc.'.php')) {
$BAKinc++; }
copy ($InstLoc.'/config.php', $InstLoc.'/BACKUP/configBACKUP'.$BAKinc.'.php');
rename ($ResourceDir1.'/config.php', $ResourceDir1.'/configLATEST.php');
copy ($InstLoc.'/config.php', $ResourceDir1.'/config.php');
// / The following code preserves HRAI configuration files to be restored after the update.
$BAKinc1 = 0;
while (file_exists($InstLoc.'Applications/HRAI/adminINFOBACKUP'.$BAKinc1.'.php')) {
$BAKinc1++; }
@copy ($InstLoc.'/Applications/HRAI/adminINFO.php', $InstLoc.'/Applications/HRAI/adminINFO'.$BAKinc.'.php');
rename ($ResourceDir1.'/Applications/HRAI/adminINFO.php', $ResourceDir1.'/Applications/HRAI/adminINFOLATEST.php');
copy ($InstLoc.'/Applications/HRAI/adminINFO.php', $ResourceDir1.'/Applications/HRAI/adminINFO.php');
foreach($UPDATEFiles as $UF) {
if ($UF == '.' or $UF == '..' or $UF == 'var' or $UF == 'www' or $UF == 'html' or $UF == 'HRProprietary') continue;
$UFSrcDir = $ResourceDir1.'/'.$UF;
$UFDstDir = $InstLoc.'/'.$UF;
if (is_dir($ResourceDir1)) @mkdir($InstLoc, 0755);
if (is_file($UFSrcDir)) @copy ($UFSrcDir, $UFDstDir);
if (is_dir($UFSrcDir)) {
@mkdir ($UFDstDir);
$UPDATEFiles2 = scandir ($UFSrcDir);
foreach ($UPDATEFiles2 as $UF2) {
if ($UF2 == '.' or $UF2 == '..' or $UF2 == 'var' or $UF2 == 'www' or $UF2 == 'html' or $UF2 == 'HRProprietary') continue;
$UFSrcDir2 = $ResourceDir1.'/'.$UF.'/'.$UF2;
$UFDstDir2 = $InstLoc.'/'.$UF.'/'.$UF2;
if (is_dir($ResourceDir1.'/'.$UF)) @mkdir($InstLoc.'/'.$UF, 0755);
if (is_file($UFSrcDir2)) @copy ($UFSrcDir2, $UFDstDir2);
if (is_dir($UFSrcDir2)) {
@mkdir ($UFDstDir2);
$UPDATEFiles3 = scandir ($UFSrcDir2);
foreach ($UPDATEFiles3 as $UF3) {
if ($UF3 == '.' or $UF3 == '..' or $UF3 == 'var' or $UF3 == 'www' or $UF3 == 'html' or $UF3 == 'HRProprietary') continue;
$UFSrcDir3 = $ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3;
$UFDstDir3 = $InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3;
if (is_dir($ResourceDir1.'/'.$UF.'/'.$UF2)) @mkdir($InstLoc.'/'.$UF.'/'.$UF2, 0755);
if (is_file($UFSrcDir3)) @copy ($UFSrcDir3, $UFDstDir3);
if (is_dir($UFSrcDir3)) {
@mkdir ($UFDstDir3);
$UPDATEFiles4 = scandir ($UFSrcDir3);
foreach ($UPDATEFiles4 as $UF4) {
if ($UF4 == '.' or $UF4 == '..' or $UF4 == 'var' or $UF4 == 'www' or $UF4 == 'html' or $UF4 == 'HRProprietary') continue;
$UFSrcDir4 = $ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4;
$UFDstDir4 = $InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4;
if (is_dir($ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3)) @mkdir($InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3, 0755);
if (is_file($UFSrcDir4)) @copy ($UFSrcDir4, $UFDstDir4);
if (is_dir($UFSrcDir4)) {
@mkdir ($UFDstDir4);
$UPDATEFiles5 = scandir ($UFSrcDir4);
foreach ($UPDATEFiles5 as $UF5) {
if ($UF5 == '.' or $UF5 == '..' or $UF5 == 'var' or $UF5 == 'www' or $UF5 == 'html' or $UF5 == 'HRProprietary') continue;
$UFSrcDir5 = $ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4.'/'.$UF5;
$UFDstDir5 = $InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4.'/'.$UF5;
if (is_dir($ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4)) @mkdir($InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4, 0755);
if (is_file($UFSrcDir5)) @copy ($UFSrcDir5, $UFDstDir5);
if (is_dir($UFSrcDir5)) {
@mkdir ($UFDstDir5);
$UPDATEFiles6 = scandir ($UFSrcDir5);
foreach ($UPDATEFiles6 as $UF6) {
if ($UF6 == '.' or $UF6 == '..' or $UF6 == 'var' or $UF6 == 'www' or $UF6 == 'html' or $UF6 == 'HRProprietary') continue;
$UFSrcDir6 = $ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF5.'/'.$UF5.'/'.$UF6;
$UFDstDir6 = $InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF5.'/'.$UF5.'/'.$UF6;
if (is_dir($ResourceDir1.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4.'/'.$UF5)) @mkdir($InstLoc.'/'.$UF.'/'.$UF2.'/'.$UF3.'/'.$UF4.'/'.$UF5, 0755);
if (is_file($UFSrcDir6)) @copy ($UFSrcDir6, $UFDstDir6); } } } } } } } } } } }
$txt = ('OP-Act: Copied update data on '.$Time.'.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
// / The following code checks that HRCloud2 was sucessfully updated.
require ($ResourceDir1.'/versionInfo.php');
$Version1 = trim($Version, 'v');
require ($InstLoc.'/versionInfo.php');
if ($Version1 !== $Version0) {
$txt = ('WARNING!!! HRC2CompatCore94, Version discrepency detected after unpacking the installation image on '.$Time.'!'.$br.
' Important Note: Manual install reccomended! Try using "Clean Update" and "Check Compatibility." If problem persists,
check permissions to all HRC2 directories and use a terminal window or file manager to update.');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
echo($txt.$hr); }
if ($Version1 == $Version0) {
$txt = ('OP-Act: Sucessfully installed version '.$Version.' of HRCloud2 on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code is performed when a user selects to Clean temporary update package files.
if ($AutoCleanPOST == '1' or $AutoCleanPOST == 'true' or $AutoCleanPOST == 'Clean Update') {
$txt = ('OP-Act: Initiating Update-Cleaner on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
if ($UserIDRAW !== 1) {
$txt = ('ERROR!!! HRC2CompatCore184, A non-administrator attempted to clear the system update cache on '.$Time.'!');
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
die($txt.$hr); }
if (!file_exists($UpdatedZIP1)) {
$txt = ('OP-Act: No update packages detected on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
if (file_exists($UpdatedZIP1)) {
@unlink($UpdatedZIP1);
$txt = ('OP-Act: Deleted update package on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
if (file_exists($UpdatedZIP1)) {
$txt = ('Warning!!! HRC2CompatCore165, There was a problem deleting update packages on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
if (!file_exists($UpdatedZIP1)) {
$txt = ('OP-Act: Deleted update packages on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
if (is_dir($ResourceDir1)) {
$ResourceDirFiles = scandir($ResourceDir1);
$CleanFiles = $ResourceDirFiles;
include ($InstLoc.'/janitor.php');
foreach ($ResourceDirFiles as $ResourceDirFile) {
if ($ResourceDirFile == '.' or $ResourceDirFile == '..') continue;
$CleanDir = $ResourceDir1.'/'.$ResourceDirFile;
if (is_file($CleanDir)) {
@unlink($CleanDir); }
if (is_dir($CleanDir)) {
$CleanFiles = scandir($CleanDir.'/');
include ($InstLoc.'/janitor.php');
@chmod($CleanDir.'/config.php');
@unlink($CleanDir.'/config.php');
@chmod($CleanDir.'/index.html');
@unlink($CleanDir.'/index.html');
@chmod($CleanDir.'/jquery-3.1.0.min.js');
@unlink($CleanDir.'/jquery-3.1.0.min.js');
@chmod($CleanDir.'/wordpress_1-28-17.zip');
@unlink($CleanDir.'/wordpress_1-28-17.zip');
@chmod($CleanDir.'/wordpress_3-16-17.zip');
@unlink($CleanDir.'/wordpress_3-16-17.zip');
@chmod($CleanDir.'/Database/Words/index.html');
@unlink($CleanDir.'/Database/Words/index.html');
@chmod($CleanDir.'/Words/index.html');
@unlink($CleanDir.'/Words/index.html');
@chmod($CleanDir.'/Database/Words');
@rmdir($CleanDir.'/Database/Words');
@chmod($CleanDir.'/Words');
@rmdir($CleanDir.'/Words');
@chmod($CleanDir.'/displaydirectorycontents_72716');
@rmdir($CleanDir.'/displaydirectorycontents_72716');
@chmod($CleanDir.'/displaydirectorycontents_logs');
@rmdir($CleanDir.'/displaydirectorycontents_logs');
@chmod($CleanDir.'/displaydirectorycontents_logs1');
@rmdir($CleanDir.'/displaydirectorycontents_logs1');
@chmod($CleanDir.'/displaydirectorycontents_shared');
@rmdir($CleanDir.'/displaydirectorycontents_shared');
@chmod($CleanDir.'/Applications/index.html');
@unlink($CleanDir.'/Applications/index.html');
@chmod($CleanDir.'/Applications');
@rmdir($CleanDir.'/Applications');
@chmod($CleanDir.'/Resources');
@rmdir($CleanDir.'/Resources');
@chmod($CleanDir.'/Screenshots');
@rmdir($CleanDir.'/Screenshots');
@chmod($CleanDir.'/HRAI');
@rmdir($CleanDir.'/HRAI');
@chmod($CleanDir.'/HRStreamer');
@rmdir($CleanDir.'/HRStreamer');
@chmod($CleanDir);
@rmdir($CleanDir);
foreach ($CleanFiles as $ResourceDirFile2) {
if ($ResourceDirFile2 == '.' or $ResourceDirFile2 == '..') continue;
$CleanDir = $ResourceDir1.'/'.$ResourceDirFile.'/'.$ResourceDirFile2;
if (is_dir($CleanDir)) {
$CleanFiles = scandir($CleanDir.'/');
include ($InstLoc.'/janitor.php');
@chmod($CleanDir.'/config.php');
@unlink($CleanDir.'/config.php');
@chmod($CleanDir.'/index.html');
@unlink($CleanDir.'/index.html');
@chmod($CleanDir.'/jquery-3.1.0.min.js');
@unlink($CleanDir.'/jquery-3.1.0.min.js');
@chmod($CleanDir.'/wordpress_1-28-17.zip');
@unlink($CleanDir.'/wordpress_1-28-17.zip');
@chmod($CleanDir.'/wordpress_3-16-17.zip');
@unlink($CleanDir.'/wordpress_3-16-17.zip');
@chmod($CleanDir.'/Database/Words/index.html');
@unlink($CleanDir.'/Database/Words/index.html');
@chmod($CleanDir.'/Words/index.html');
@unlink($CleanDir.'/Words/index.html');
@chmod($CleanDir.'/Database/Words');
@rmdir($CleanDir.'/Database/Words');
@chmod($CleanDir.'/Words');
@rmdir($CleanDir.'/Words');
@chmod($CleanDir.'/displaydirectorycontents_72716');
@rmdir($CleanDir.'/displaydirectorycontents_72716');
@chmod($CleanDir.'/displaydirectorycontents_logs');
@rmdir($CleanDir.'/displaydirectorycontents_logs');
@chmod($CleanDir.'/displaydirectorycontents_logs1');
@rmdir($CleanDir.'/displaydirectorycontents_logs1');
@chmod($CleanDir.'/displaydirectorycontents_shared');
@rmdir($CleanDir.'/displaydirectorycontents_shared');
@chmod($CleanDir.'/Applications/index.html');
@unlink($CleanDir.'/Applications/index.html');
@chmod($CleanDir.'/Applications');
@rmdir($CleanDir.'/Applications');
@chmod($CleanDir.'/Resources');
@rmdir($CleanDir.'/Resources');
@chmod($CleanDir.'/Screenshots');
@rmdir($CleanDir.'/Screenshots');
@chmod($CleanDir.'/HRAI');
@rmdir($CleanDir.'/HRAI');
@chmod($CleanDir.'/HRStreamer');
@rmdir($CleanDir.'/HRStreamer');
@chmod($CleanDir);
@rmdir($CleanDir);
foreach ($CleanFiles as $ResourceDirFile3) {
if ($ResourceDirFile3 == '.' or $ResourceDirFile4 == '..') continue;
$CleanDir = $ResourceDir1.'/'.$ResourceDirFile.'/'.$ResourceDirFile2.'/'.$ResourceDirFile3;
if (is_dir($CleanDir)) {
$CleanFiles = scandir($CleanDir.'/');
include ($InstLoc.'/janitor.php');
@chmod($CleanDir.'/config.php');
@unlink($CleanDir.'/config.php');
@chmod($CleanDir.'/index.html');
@unlink($CleanDir.'/index.html');
@chmod($CleanDir.'/jquery-3.1.0.min.js');
@unlink($CleanDir.'/jquery-3.1.0.min.js');
@chmod($CleanDir.'/wordpress_1-28-17.zip');
@unlink($CleanDir.'/wordpress_1-28-17.zip');
@chmod($CleanDir.'/Database/Words/index.html');
@unlink($CleanDir.'/Database/Words/index.html');
@chmod($CleanDir.'/Words/index.html');
@unlink($CleanDir.'/Words/index.html');
@chmod($CleanDir.'/Database/Words');
@rmdir($CleanDir.'/Database/Words');
@chmod($CleanDir.'/Words');
@rmdir($CleanDir.'/Words');
@chmod($CleanDir.'/displaydirectorycontents_72716');
@rmdir($CleanDir.'/displaydirectorycontents_72716');
@chmod($CleanDir.'/displaydirectorycontents_logs');
@rmdir($CleanDir.'/displaydirectorycontents_logs');
@chmod($CleanDir.'/displaydirectorycontents_logs1');
@rmdir($CleanDir.'/displaydirectorycontents_logs1');
@chmod($CleanDir.'/displaydirectorycontents_shared');
@rmdir($CleanDir.'/displaydirectorycontents_shared');
@chmod($CleanDir.'/Applications/index.html');
@unlink($CleanDir.'/Applications/index.html');
@chmod($CleanDir.'/Applications');
@rmdir($CleanDir.'/Applications');
@chmod($CleanDir.'/Resources');
@rmdir($CleanDir.'/Resources');
@chmod($CleanDir.'/Screenshots');
@rmdir($CleanDir.'/Screenshots');
@chmod($CleanDir.'/HRAI');
@rmdir($CleanDir.'/HRAI');
@chmod($CleanDir.'/HRStreamer');
@rmdir($CleanDir.'/HRStreamer');
@chmod($CleanDir);
@rmdir($CleanDir); } } } } } }
if (is_dir($CleanDir)) {
$CleanDir = $ResourceDir1;
@chmod($CleanDir);
@rmdir($CleanDir); }
if (is_dir($CleanDir)) {
copy ($InstLoc.'/index.html', $CleanDir.'/index.html');
$txt = ('Warning!!! HRC2CompatCore220, Some files could not be deleted on '.$Time.'!');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
if (!is_dir($CleanDir)) {
$txt = ('OP-Act: Deleted temporary update data on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
@copy ($InstLoc.'/index.html', $ResourceDir.'/index.html'); } }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code cleans and deletes old, unused, or otherwise deprecated files from HRCloud2.
if ($CheckCompatPOST == '1' or $CheckCompatPOST == 'true' or $CheckCompatPOST == 'Compat Check') {
$txt = ('OP-Act: Initiating Compatibility Checker on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$ChkFileIsBACKUP = scandir($InstLoc);
foreach ($ChkFileIsBACKUP as $ChkFileIsBACKUP1) {
if (strpos($ChkFileIsBACKUP1, 'configBACKUP') == 'true') {
rename($InstLoc.'/'.$ChkFileIsBACKUP1, $BackupDir.'/'.$ChkFileIsBACKUP1);
$txt = ('OP-Act: Copied the backup file "'.$ChkFileIsBACKUP1.'" to the Backup Directory on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); } }
if (file_exists($InstLoc.'/appSettings.php')) @unlink($InstLoc.'/appSettings.php');
if (file_exists($InstLoc.'/apiCore.php')) @unlink($InstLoc.'/apiCore.php');
if (file_exists($InstLoc.'/SAVEappSettings.php')) @unlink($InstLoc.'/SAVEappSettings.php');
if (file_exists($InstLoc.'/search2.php')) @unlink($InstLoc.'/search2.php');
if (file_exists($InstLoc.'/createUserFiles.php')) @unlink($InstLoc.'/createUserFiles.php');
if (file_exists($InstLoc.'/DocScan.php')) @unlink($InstLoc.'/DocScan.php');
if (file_exists($InstLoc.'/clipboardTester.php')) @unlink($InstLoc.'/clipboardTester.php');
if (file_exists($InstLoc.'/clipboardTESTER.php')) @unlink($InstLoc.'/clipboardTESTER.php');
if (file_exists($InstLoc.'/TEST.php')) @unlink($InstLoc.'/TEST.php');
if (file_exists($InstLoc.'/TEST1.php')) @unlink($InstLoc.'/TEST1.php');
if (file_exists($InstLoc.'/TEST2.php')) @unlink($InstLoc.'/TEST2.php');
if (file_exists($InstLoc.'/TEST3.php')) @unlink($InstLoc.'/TEST3.php');
if (file_exists($InstLoc.'/TEST4.php')) @unlink($InstLoc.'/TEST4.php');
if (file_exists($InstLoc.'/search.php')) @unlink($InstLoc.'/search.php');
if (file_exists($InstLoc.'/HRAIMiniGui.php')) @unlink($InstLoc.'/HRAIMiniGui.php');
if (file_exists($InstLoc.'/coreCOMMANDS.php')) @unlink($InstLoc.'/coreCOMMANDS.php');
if (file_exists($InstLoc.'/adminLogin.php')) @unlink($InstLoc.'/adminLogin.php');
if (file_exists($InstLoc.'/AdminLogin.php')) @unlink($InstLoc.'/AdminLogin.php');
if (file_exists($InstLoc.'/Applications/HRAI/awake.php'))@unlink($InstLoc.'/Applications/HRAI/awake.php');
if (file_exists($InstLoc.'/Applications/HRAI/online.php')) @unlink($InstLoc.'/Applications/HRAI/online.php');
if (file_exists($InstLoc.'/Applications/HRAI/coreArr.php')) @unlink($InstLoc.'/Applications/HRAI/coreArr.php');
if (file_exists($InstLoc.'/Applications/HRAI/CoreCommands/CMDcfh.php')) @unlink($InstLoc.'/Applications/HRAI/CoreCommands/CMDcfh.php');
if (file_exists($InstLoc.'/Applications/HRAI/CoreCommands/CMDsync.php')) @unlink($InstLoc.'/Applications/HRAI/CoreCommands/CMDsync.php');
if (file_exists($InstLoc.'/Applications/HRAI/CallForHelp.php')) @unlink($InstLoc.'/Applications/HRAI/CallForHelp.php');
if (file_exists($InstLoc.'/Applications/HRAI/ForceCallForHelp.php')) @unlink($InstLoc.'/Applications/HRAI/ForceCallForHelp.php');
if (file_exists($InstLoc.'/Applications/HRAI/langPar.php')) @unlink($InstLoc.'/Applications/HRAI/langPar.php');
if (file_exists($InstLoc.'/Applications/HRAI/langParVar.php')) @unlink($InstLoc.'/Applications/HRAI/langParVar.php');
if (file_exists($InstLoc.'/Applications/wordpress_1-28-17.zip')) @unlink($InstLoc.'/Applications/wordpress_1-28-17.zip');
if (file_exists($InstLoc.'/Applications/HRAI/wordpress_11416.zip')) @unlink($InstLoc.'/Applications/wordpress_11416.zip');
if (file_exists($InstLoc.'/Applications/HRAI/HRAIMiniGui.php')) @unlink($InstLoc.'/Applications/HRAI/HRAIMiniGui.php');
if (file_exists($InstLoc.'/Applications/ServMonitor/cpuUpdate.php')) @unlink($InstLoc.'/Applications/ServMonitor/cpuUpdate.php');
if (file_exists($InstLoc.'/Applications/ServMonitor/ramUpdate.php')) @unlink($InstLoc.'/Applications/ServMonitor/ramUpdate.php');
if (file_exists($InstLoc.'/Applications/HRConvert2/uploaderNOGUI.php')) @unlink($InstLoc.'/Applications/HRConvert2/uploaderNOGUI.php');
if (file_exists($InstLoc.'/Applications/displaydirectorycontents_logs1/index.php')) @unlink($InstLoc.'/Applications/displaydirectorycontents_logs1/index.php');
if (file_exists($InstLoc.'/Applications/displaydirectorycontents_logs/index.php')) @unlink($InstLoc.'/Applications/displaydirectorycontents_logs1/index.php');
if (file_exists($InstLoc.'/windows')) @unlink($InstLoc.'/windows');
if (file_exists($InstLoc.'/linux')) @unlink($InstLoc.'/linux');
if (file_exists($InstLoc.'/osx')) @unlink($InstLoc.'/osx');
$txt = ('OP-Act: Cleaned and optimized HRCloud2 on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$c1 = 0;
foreach ($iterator = new \RecursiveIteratorIterator (
new \RecursiveDirectoryIterator ($InstLoc, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST) as $item) {
@chmod($item, 0755);
if ($item->isDir()) {
copy('index.html', $item.'/index.html');
$c1++; } }
$txt = ('OP-Act: Purged '.$c1.' index files on '.$Time.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
$txt = ('OP-Act: This server is running HRCloud2 '.$Version.'.');
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND); }
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code attempts to correct file permissions for HRCloud2 controlled directories.
if ($CheckPermsPOST == '1' or $CheckPermsPOST == 'true' or $CheckPermsPOST == 'Perms Check') {
@system("/bin/chmod -R 0755 $CloudLoc");
$txt = 'Op-Act: The current permission level of the CloudLoc is "'.substr(sprintf('%o', fileperms($CloudLoc)), -4).'".' ;
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
@system("/bin/chmod -R 0755 $InstLoc");
$txt = 'Op-Act: The current permission level of the InstLoc is "'.substr(sprintf('%o', fileperms($InstLoc)), -4).'".' ;
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
@system("/bin/chgrp -R $user $CloudLoc");
$txt = 'Op-Act: The current user:group of the CloudLoc is "'.posix_getpwuid(fileowner($CloudLoc))['name'].':'.posix_getgrgid(filegroup($CloudLoc))['name'].'".' ;
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);
@system("/bin/chgrp -R $user $InstLoc");
$txt = 'Op-Act: The current user:group of the InstLoc is "'.posix_getpwuid(fileowner($InstLoc))['name'].':'.posix_getgrgid(filegroup($InstLoc))['name'].'".' ;
echo($txt.$hr);
$MAKELogFile = file_put_contents($LogFile, $txt.PHP_EOL, FILE_APPEND);}
// / -----------------------------------------------------------------------------------
// / -----------------------------------------------------------------------------------
// / The following code displays the navigation buttons for when a user selects a compatibility related operation that this page has satisfied.
if (isset($_POST['ClearCache']) or isset($_POST['AutoUpdate']) or isset($_POST['AutoDownload']) or isset($_POST['AutoInstall']) or
isset($_POST['AutoClean']) or isset($_POST['CheckCompatibility'])) {
echo('<div align="center"><form target ="_parent" action="index1.php" method="get"><button id="button" name="home" value="1">Home</button></form></div>'); }
// / -----------------------------------------------------------------------------------