mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Add proper exit() code to bin/ commands
This commit is contained in:
parent
dd1e604155
commit
75d1ed6eea
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(PHP_SAPI !== 'cli') {
|
||||
die('This script can be run only in command line mode.');
|
||||
echo 'This script can be run only in command line mode.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../common.php';
|
||||
@ -9,10 +10,9 @@ require_once SYSTEM . 'functions.php';
|
||||
require_once SYSTEM . 'init.php';
|
||||
|
||||
if(clearCache()) {
|
||||
echo 'Cache cleared.';
|
||||
echo 'Cache cleared.' . PHP_EOL;
|
||||
}
|
||||
else {
|
||||
echo 'Unexpected error.';
|
||||
echo 'Unexpected error.' . PHP_EOL;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(PHP_SAPI !== 'cli') {
|
||||
die('This script can be run only in command line mode.');
|
||||
echo 'This script can be run only in command line mode.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../common.php';
|
||||
@ -11,17 +12,20 @@ require_once SYSTEM . 'hooks.php';
|
||||
require_once LIBS . 'plugins.php';
|
||||
|
||||
if($argc !== 2) {
|
||||
exit('This command expects one parameter: zip file name (plugin)' . PHP_EOL);
|
||||
echo 'This command expects one parameter: zip file name (plugin)' . PHP_EOL;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$path_to_file = $argv[1];
|
||||
$ext = strtolower(pathinfo($path_to_file, PATHINFO_EXTENSION));
|
||||
if($ext !== 'zip') {// check if it is zipped/compressed file
|
||||
exit('Please install only .zip files.' . PHP_EOL);
|
||||
echo 'Please install only .zip files.' . PHP_EOL;
|
||||
exit(3);
|
||||
}
|
||||
|
||||
if(!file_exists($path_to_file)) {
|
||||
exit('ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL);
|
||||
echo 'ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL;
|
||||
exit(4);
|
||||
}
|
||||
|
||||
if(Plugins::install($path_to_file)) {
|
||||
@ -30,9 +34,9 @@ if(Plugins::install($path_to_file)) {
|
||||
}
|
||||
|
||||
$info = Plugins::getPlugin();
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.';
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.' . PHP_EOL;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: ' . Plugins::getError() . PHP_EOL;
|
||||
exit(5);
|
||||
}
|
||||
else
|
||||
echo 'ERROR: ' . Plugins::getError();
|
||||
|
||||
echo PHP_EOL;
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
if(PHP_SAPI !== 'cli') {
|
||||
die('This script can be run only in command line mode.');
|
||||
echo 'This script can be run only in command line mode.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../common.php';
|
||||
@ -9,7 +10,8 @@ require_once SYSTEM . 'functions.php';
|
||||
require_once SYSTEM . 'init.php';
|
||||
|
||||
if($argc !== 3) {
|
||||
exit('This command expects two parameters: account_name_or_id|player_name|email address, subject.' . PHP_EOL);
|
||||
echo 'This command expects two parameters: account_name_or_id|player_name|email address, subject.' . PHP_EOL;
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$email_account_name = $argv[1];
|
||||
@ -35,21 +37,25 @@ if(strpos($email_account_name, '@') === false) {
|
||||
$email_account_name = $player->getAccount()->getEMail();
|
||||
}
|
||||
else {
|
||||
exit('Cannot find player or account with name: ' . $email_account_name . '.' . PHP_EOL);
|
||||
echo 'Cannot find player or account with name: ' . $email_account_name . '.' . PHP_EOL;
|
||||
exit(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!Validator::email($email_account_name)) {
|
||||
exit('Invalid E-Mail format.' . PHP_EOL);
|
||||
echo 'Invalid E-Mail format.' . PHP_EOL;
|
||||
exit(4);
|
||||
}
|
||||
|
||||
if(strlen($subject) > 255) {
|
||||
exit('Subject max length is 255 characters.' . PHP_EOL);
|
||||
echo 'Subject max length is 255 characters.' . PHP_EOL;
|
||||
exit(5);
|
||||
}
|
||||
|
||||
if(!_mail($email_account_name, $subject, $message)) {
|
||||
exit('Error while sending mail: ' . $mailer->ErrorInfo . PHP_EOL);
|
||||
echo 'Error while sending mail: ' . $mailer->ErrorInfo . PHP_EOL;
|
||||
exit(6);
|
||||
}
|
||||
|
||||
echo 'Mail sent to ' . $email_account_name . '.' . PHP_EOL;
|
||||
echo 'Mail sent to ' . $email_account_name . '.' . PHP_EOL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user