Skip to content

Commit

Permalink
1.0.7
Browse files Browse the repository at this point in the history
- PHP version changed to 7.4.5
- removed languages option/translation
- removed colours in console + extension
- changed error sound
- "Cannot connect" message with counter now
- some code cleanup
  • Loading branch information
S3x0r committed May 15, 2020
1 parent dfe5c35 commit 94ee379
Show file tree
Hide file tree
Showing 52 changed files with 2,054 additions and 423 deletions.
22 changes: 9 additions & 13 deletions BOT.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

define('N', PHP_EOL);

/* check os type and set path */
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
chdir('../');
} else {
Expand All @@ -30,30 +29,30 @@
}

$files = ['cli.php',
'config.php',
'misc.php',
'config.php',
'core_commands.php',
'ctcp.php',
'debug.php',
'define.php',
'events.php',
'language.php',
'logo.php',
'logs.php',
'misc.php',
'plugins.php',
'socket.php',
'timers.php',
'web.php'
'web.php',
'ctcp.php'
];

foreach ($files as $file) {
if (is_file($file)) {
require_once($file);
} else {
echo N.' ERROR: I need \''.$file.'\' file to run!'.N,
N.' You can download missing files from:'.N,
' https://github.com/S3x0r/MINION/releases'.N,
N.' Terminating program after 10 seconds.'.N.N.' ';
echo N;
echo " ERROR: I need a file '{$file}' to work!".N.N,
' You can download missing files from:'.N,
' https://github.com/S3x0r/MINION/releases'.N.N,
' Terminating program after 10 seconds.'.N.N.' ';
WinSleep(10);
exit;
}
Expand All @@ -62,9 +61,6 @@
/* Load startup needed variables */
StartupConfig();

/* Load translation file */
SetLanguage();

/* Check if cli arguments */
CheckCliArgs();

Expand Down
9 changes: 2 additions & 7 deletions CONFIG.INI
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ connect_delay = '6'
[OWNER]

; bot administrator information
bot_admin = 'S3x0r <olisek@gmail.com>'
bot_admin = 'S3x0r <user@localhost>'

; bot will give op's if this hosts join channel <nick!ident@hostname>
auto_op_list = ''
Expand Down Expand Up @@ -96,7 +96,7 @@ command_prefix = '!'
ctcp_response = 'yes'

; ctcp version response (please do not change it:)
ctcp_version = 'MINION (1.0.6) powered by minions!'
ctcp_version = 'MINION (1.0.7) powered by minions!'

; ctcf finger response
ctcp_finger = 'MINION'
Expand Down Expand Up @@ -125,11 +125,6 @@ web_login = 'changeme'
; web panel password
web_password = 'changeme'

[LANG]

; set BOT language: 'EN', 'PL'
language = 'EN'

[TIME]

; bot time zone
Expand Down
8 changes: 8 additions & 0 deletions DOCS/CHANGELOG.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@

v1.0.7 changes (15.05.2020):
- PHP version changed to 7.4.5
- removed languages option/translation
- removed colours in console + extension
- changed error sound
- "Cannot connect" message with counter now
- some code cleanup

v1.0.6 changes (29.09.2019):
- errors pause now only in Windows
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions DOCS/config.ini info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ web_login = 'changeme'
; web panel password (for panel plugin)
web_password = 'changeme'

[LANG]

; set BOT language: 'EN', 'PL'
language = 'EN'

[TIME]

; bot time zone
Expand Down
2 changes: 1 addition & 1 deletion PLUGINS/ADMIN/cham.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ function plugin_cham()
}
}
} catch (Exception $e) {
CLI_MSG('[ERROR]: '.TR_49.' '.__FUNCTION__.' '.TR_50, '1');
CLI_MSG('[ERROR]: Function: '.__FUNCTION__.' failed', '1');
}
}
2 changes: 1 addition & 1 deletion PLUGINS/ADMIN/say.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ function plugin_say()
$GLOBALS['channel'], '1');
}
} catch (Exception $e) {
CLI_MSG('[ERROR]: '.TR_49.' '.__FUNCTION__.' '.TR_50, '1');
CLI_MSG('[ERROR]: Function: '.__FUNCTION__.' failed', '1');
}
}
3 changes: 0 additions & 3 deletions PLUGINS/OWNER/showconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ function plugin_showconfig()
BOT_RESPONSE('[LOGS]');
BOT_RESPONSE('Logging : '.$GLOBALS['CONFIG_LOGGING'].'');

BOT_RESPONSE('[LANG]');
BOT_RESPONSE('Language : '.$GLOBALS['CONFIG_LANGUAGE'].'');

BOT_RESPONSE('[TIME]');
BOT_RESPONSE('Time Zone : '.$GLOBALS['CONFIG_TIMEZONE'].'');

Expand Down
2 changes: 0 additions & 2 deletions PLUGINS/OWNER/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ function v_extract()
$GLOBALS['CONFIG_LOGGING'] = $cfg->get("LOGS", "logging");
$GLOBALS['CONFIG_WEB_LOGIN'] = $cfg->get("PANEL", "web_login");
$GLOBALS['CONFIG_WEB_PASSWORD'] = $cfg->get("PANEL", "web_password");
$GLOBALS['CONFIG_LANGUAGE'] = $cfg->get("LANG", "language");
$GLOBALS['CONFIG_TIMEZONE'] = $cfg->get("TIME", "time_zone");
$GLOBALS['CONFIG_FETCH_SERVER'] = $cfg->get("FETCH", "fetch_server");
$GLOBALS['CONFIG_SHOW_LOGO'] = $cfg->get("PROGRAM", "show_logo");
Expand Down Expand Up @@ -223,7 +222,6 @@ function v_extract()
SaveData($new_cf, 'LOGS', 'logging', $GLOBALS['CONFIG_LOGGING']);
SaveData($new_cf, 'PANEL', 'web_login', $GLOBALS['CONFIG_WEB_LOGIN']);
SaveData($new_cf, 'PANEL', 'web_password', $GLOBALS['CONFIG_WEB_PASSWORD']);
SaveData($new_cf, 'LANG', 'language', $GLOBALS['CONFIG_LANGUAGE']);
SaveData($new_cf, 'TIME', 'time_zone', $GLOBALS['CONFIG_TIMEZONE']);
SaveData($new_cf, 'FETCH', 'fetch_server', $GLOBALS['CONFIG_FETCH_SERVER']);
SaveData($new_cf, 'PROGRAM', 'show_logo', $GLOBALS['CONFIG_SHOW_LOGO']);
Expand Down
2 changes: 1 addition & 1 deletion PLUGINS/USER/bash.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ function plugin_bash()
CLI_MSG('[PLUGIN: bash] by: '.$GLOBALS['USER'].' ('.$GLOBALS['USER_HOST'].') | chan: '.
$GLOBALS['channel'], '1');
} catch (Exception $e) {
CLI_MSG('[ERROR]: '.TR_49.' '.__FUNCTION__.' '.TR_50, '1');
CLI_MSG('[ERROR]: Function: '.__FUNCTION__.' failed', '1');
}
}
13 changes: 5 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
![Powered by S3x0r](http://minionki.com.pl/powered.png)

![extreme programming](http://minionki.com.pl/xp-logo.png)
### Easy to use IRC BOT in PHP language, ready to use from first start

<dl>
<pre>
Author: S3x0r, contact: olisek@gmail.com
Author: S3x0r
</pre>
</dl>

Expand All @@ -19,13 +16,13 @@ You can also edit owner host in CONFIG.INI:

<dl>
<pre>
nick ! ident@ host
| | |
example: S3x0r!~S3x0r@12-13-38-219.dsl.dynamic.simnet.is
nick!ident@hostname
| | |
example: S3x0r!~ident@hostname.com
</pre>
</dl>

Bot was writted to run from Windows systems (tested on Windows 7)
Bot was writted to run from Windows systems (tested on Windows 10)
but you can also run it from Linux/Unix by typing: 'php BOT.php'
To have almost all plugins working on Linux/Unix you need to enable
two extension modules in your 'php.ini' config:
Expand Down
37 changes: 18 additions & 19 deletions src/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ function CheckCliArgs()
if (isset($_SERVER['argv'][1])) {
switch ($_SERVER['argv'][1]) {
case '-h': /* show help */
echo N.' '.TR_62.N.N,
' -c '.TR_63.N, /* config file */
' -h '.TR_67.N, /* help */
echo N.' Bot cli commands usage: BOT.php [option]'.N.N,
' -c <config_file> loads config'.N, /* config file */
' -h this help'.N, /* help */
' -o connect to specified server: eg: BOT.php irc.dal.net 6667'.N, /* server */
' -p '.TR_64.N, /* hash */
' -s '.TR_65.N, /* silent mode */
' -p <password> hash password to SHA256'.N, /* hash */
' -s silent mode (no output from bot)'.N, /* silent mode */
' -u check if there is new bot version'.N, /* update */
' -v '.TR_66.N.N; /* version */
' -v prints bot version'.N.N; /* version */
exit;
break;

Expand All @@ -53,18 +53,18 @@ function CheckCliArgs()
break;

case '-p': /* encrypt password => sha256 */
echo N.' '.TR_68.N;
echo N.' '.TR_69.' ';
echo N.' I will encrypt your password to SHA256'.N;
echo N.' Password: ';
$STDIN = fopen('php://stdin', 'r');
$pwd = str_replace(' ', '', fread($STDIN, 30));
while (strlen($pwd) < 8) {
echo ' '.TR_16.N;
echo ' '.TR_69.' ';
echo ' Password too short, password must be at least 6 characters long'.N;
echo ' Password: ';
unset($pwd);
$pwd = fread($STDIN, 30);
}
$hash = hash('sha256', rtrim($pwd, "\n\r"));
echo N.' '.TR_70." $hash".N.N;
echo N." Hashed: {$hash}".N.N;

echo N.' Save password to Config file? (yes/no)'.N;
echo ' > ';
Expand Down Expand Up @@ -93,7 +93,7 @@ function CheckCliArgs()
break;

case '-v': /* show version */
echo N.' '.TR_71.' '.VER.N;
echo N.' MINION version: '.VER.N;
exit;
break;

Expand All @@ -111,8 +111,8 @@ function CheckCliArgs()
WinSleep(10);
exit;
} else {
echo N.' Checking if there is new BOT version...'.N;
echo N.' No new update, you have the latest version.'.N;
echo N.' I am checking if there is a newer version of MINION Bot...'.N;
echo N.' No new update, you have the latest version.'.N.N;
WinSleep(4);
exit;
}
Expand All @@ -134,7 +134,6 @@ function wcliStart()
{
if (!IsSilent()) {
if (extension_loaded('wcli')) {
wcli_maximize();
wcli_set_console_title('MINION '.VER);
wcli_hide_cursor();
}
Expand All @@ -145,8 +144,8 @@ function wcliExt()
{
if (!IsSilent()) {
if (extension_loaded('wcli')) {
wcli_set_console_title('MINION '.VER.' ('.TR_51.' '.$GLOBALS['CONFIG_SERVER'].':'
.$GLOBALS['CONFIG_PORT'].' | '.TR_52.' '.$GLOBALS['BOT_NICKNAME'].' | '.TR_53.' '
wcli_set_console_title('MINION '.VER.' (server: '.$GLOBALS['CONFIG_SERVER'].':'
.$GLOBALS['CONFIG_PORT'].' | nickname: '.$GLOBALS['BOT_NICKNAME'].' | channel: '
.$GLOBALS['CONFIG_CNANNEL'].')');
}
}
Expand All @@ -155,10 +154,10 @@ function wcliExt()
function CLI_MSG($message, $save = 0)
{
if (!IsSilent()) {
$line = '['.@date('H:i:s').'] '.$message.N;
$line = "[".@date('H:i:s')."] {$message}".N;

if (isset($GLOBALS['CONFIG_LOGGING']) && $GLOBALS['CONFIG_LOGGING'] == 'yes' && $save == '1') {
SaveToFile($GLOBALS['log_file'], $line, 'a');
SaveToFile($GLOBALS['logFile'], $line, 'a');
}
echo $line;
}
Expand Down
30 changes: 13 additions & 17 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ function LoadConfig($filename)
PlaySound('error_conn.mp3');

/* show info about it */
CLI_MSG(TR_13);
CLI_MSG(TR_14);
CLI_MSG('Default BOT owner(s) password detected!');
CLI_MSG('For security please change it (password can not contain spaces)');

/* 'New Password:' */
$new_pwd = getPasswd('['.@date('H:i:s').'] New Password: '.N);
$new_pwd = getPasswd('['.@date('H:i:s').'] New Password: ');

while (strlen($new_pwd) < 6) {
echo '['.@date('H:i:s').'] '.TR_16.N;
echo N.'['.@date('H:i:s').'] Password too short, password must be at least 6 characters long'.N;
unset($new_pwd);
$new_pwd = getPasswd('['.@date('H:i:s').'] New Password: '.N);
$new_pwd = getPasswd('['.@date('H:i:s').'] New Password: ');
}

/* join spaces in password */
Expand All @@ -187,15 +187,16 @@ function LoadConfig($filename)

/* Set first time change variable */
$GLOBALS['pwd_changed'] = '1';


echo N;
CLI_MSG('Password changed');

/* load config again */
LoadConfig($config_file);
}

/* from what file config loaded */
CLI_MSG(TR_17.' '.$config_file);
CLI_MSG("Configuration Loaded from: {$config_file}");
Line(COLOR);

/* logging init */
Expand All @@ -209,8 +210,8 @@ function LoadConfig($filename)
/* set default logging */
$GLOBALS['CONFIG_LOGGING'] = 'yes';

CLI_MSG(TR_18);
CLI_MSG(TR_19.' CONFIG.INI '.N);
CLI_MSG('Configuration file missing!');
CLI_MSG('Creating default config: CONFIG.INI '.N);

/* create default config if missing */
CreateDefaultConfig('../CONFIG.INI');
Expand Down Expand Up @@ -253,7 +254,7 @@ function CreateDefaultConfig($filename)
[OWNER]
; bot administrator information
bot_admin = \'S3x0r <olisek@gmail.com>\'
bot_admin = \'S3x0r <user@localhost>\'
; bot will give op\'s if this hosts join channel <nick!ident@hostname>
auto_op_list = \'\'
Expand Down Expand Up @@ -347,11 +348,6 @@ function CreateDefaultConfig($filename)
; web panel password
web_password = \'changeme\'
[LANG]
; set BOT language: \'EN\', \'PL\'
language = \'EN\'
[TIME]
; bot time zone
Expand Down Expand Up @@ -391,7 +387,7 @@ function CreateDefaultConfig($filename)
/* Load config again */
LoadConfig($filename);
} else { /* read only file system? */
CLI_MSG('[ERROR]: '.TR_20);
CLI_MSG('[ERROR]: Cannot make default config! Exiting');
WinSleep(6);
exit;
}
Expand All @@ -416,7 +412,7 @@ class IniParser
public $iniFilename = '';
public $iniParsedArray = array();

public function iniParser($file)
public function __construct($file)
{
$this->iniFilename = $file;
if ($this->iniParsedArray = parse_ini_file($file, true)) {
Expand Down
Loading

0 comments on commit 94ee379

Please sign in to comment.