commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
class bash implements module { |
|
3 |
static function register_cmd() { |
|
4 |
return array( |
|
5 |
'bash' => 'cmd_bash', |
|
6 |
'sh' => 'cmd_bash', |
|
7 |
'b' => 'cmd_bash', |
|
8 |
); |
|
9 |
} |
|
10 |
|
|
11 |
static function help($cmd=NULL) { |
|
12 |
if($cmd === NULL) { |
|
13 |
GGapi::putRichText('bash ', TRUE); |
|
14 |
GGapi::putRichText('[cytat]', FALSE, TRUE); |
|
15 |
GGapi::putRichText("\n".' Cytat z polskiego basha'."\n\n"); |
|
16 |
} |
|
17 |
else |
|
18 |
{ |
|
19 |
GGapi::putRichText('bash ', TRUE); |
|
20 |
GGapi::putRichText('[cytat]', FALSE, TRUE); |
|
21 |
GGapi::putRichText(' (alias: '); |
|
22 |
GGapi::putRichText('sh, b', TRUE); |
|
23 |
GGapi::putRichText(')'."\n".' Podaje cytat nr '); |
|
24 |
GGapi::putRichText('[cytat]', FALSE, TRUE); |
|
25 |
GGapi::putRichText(' lub wylosowaną regułkę, jeśli brak argumentu lub dany rekord nie istnieje.'); |
|
26 |
} |
|
27 |
} |
|
28 |
|
|
29 |
static function cmd_bash($name, $arg) { |
|
30 |
$data = unserialize(file_get_contents('./data/bash/index.txt')); |
|
31 |
|
|
32 |
$arg = (int)trim($arg); |
|
33 |
if(!$arg || !isset($data[$arg])) { |
|
34 |
$arg = array_rand($data); |
|
35 |
} |
|
36 |
|
|
37 |
$data = $data[$arg]; |
|
38 |
|
|
39 |
$fp = fopen('./data/bash/text.txt', 'r'); |
|
40 |
fseek($fp, $data); |
|
41 |
|
|
42 |
$data = ''; |
|
43 |
$line = ''; |
|
44 |
|
|
45 |
while(!feof($fp) && trim($line)!='%') { |
|
46 |
$data .= $line; |
|
47 |
$line = fgets($fp); |
|
48 |
} |
|
49 |
|
|
50 |
fclose($fp); |
|
51 |
|
|
52 |
GGapi::putRichText('Cytat #'.$arg, TRUE); |
|
53 |
GGapi::putText("\n".trim($data)); |
|
54 |
} |
|
55 |
} |
|
56 |
?> |