-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathStartBot.php
More file actions
96 lines (96 loc) · 2.72 KB
/
Copy pathStartBot.php
File metadata and controls
96 lines (96 loc) · 2.72 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
<?php
/*
* StartBot.php - Starts and restarts the bot
*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2020 J-Soft and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
* - Temar (RK1)
*
* See Credits file for all acknowledgements.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
/*
Take a decent stab at what OS we run on and try using some sane defaults
*/
$os = getenv("OSTYPE");
if (empty($os)) {
$os = getenv("OS");
}
if (preg_match("/^windows/i", $os)) {
/*
This default should work for Windows installs where php is installed to the bot directory.
*/
$php_bin = "php.exe";
$php_args = " -c ./ ";
$main_php = "Main.php";
/*
If the above fails you can try specifying full paths, example:
$php_bin = "C:\php\php.exe";
$main_php = "C:\BeBot\Main.php";
*/
} else {
/*
This is a sane default for the php binary on Unix systems.
If your php binary is located someplace else, edit the php_bin path accordingly.
*/
$php_bin = trim(shell_exec('which php'));
$php_args = " -c ./ ";
$main_php = "Main.php";
}
$confc = true;
require_once "./Sources/Conf.php";
if (isset($argv[1]) && $argv[1] != $conf->argv) {
echo "Use \"StartBot.php " . $conf->argv . "\" to start bot next time\n";
$argv[1] = $conf->argv;
$conf->ask("Press Enter to load Bot");
if (!$argv[1] || $argv[1] == "") {
$argc = 1;
} else {
$argc = 2;
}
}
if (!empty($conf->pw)) {
$pw = $conf->pw;
$conf->pw = null;
}
// Create the command to execute in the system() call of the main loop:
$systemcommand = $php_bin . $php_args . " " . $main_php;
if ($argc > 1) {
$systemcommand .= " " . $argv[1];
}
while (true) {
if (isset($pw)) {
$fp = fopen('./Conf/pw', 'w');
fwrite($fp, $pw);
fclose($fp);
}
$last_line = system($systemcommand);
if (preg_match("/^The bot has been shutdown/i", $last_line)) {
die();
} else {
sleep(1);
}
}
?>