Added some sanity checks
This commit is contained in:
parent
c7f248dae6
commit
e038912a38
Binary file not shown.
@ -5,7 +5,7 @@
|
|||||||
include ("Console/Getopt.php");
|
include ("Console/Getopt.php");
|
||||||
|
|
||||||
$VERSION="1.1";
|
$VERSION="1.1";
|
||||||
$AUTHOR="(c) 2012 Jack-Benny Persson (jack-benny@cyberinfo.se)";
|
$AUTHOR="(c) 2013 Jack-Benny Persson (jack-benny@cyberinfo.se)";
|
||||||
|
|
||||||
// Exit codes
|
// Exit codes
|
||||||
$STATE_OK=0;
|
$STATE_OK=0;
|
||||||
@ -44,7 +44,7 @@ Options:
|
|||||||
--md5 md5checksum
|
--md5 md5checksum
|
||||||
Set the MD5 checksum for the file set by --file
|
Set the MD5 checksum for the file set by --file
|
||||||
EOD;
|
EOD;
|
||||||
// Print the help
|
// Print the help
|
||||||
print_version();
|
print_version();
|
||||||
echo "$AUTHOR\n";
|
echo "$AUTHOR\n";
|
||||||
echo "\n$HELP_TEXT\n";
|
echo "\n$HELP_TEXT\n";
|
||||||
@ -73,6 +73,7 @@ if(sizeof($opts) > 0)
|
|||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
print_help();
|
print_help();
|
||||||
|
exit ($STATE_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
@ -95,6 +96,17 @@ if(sizeof($opts) > 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($filename))
|
||||||
|
{
|
||||||
|
fwrite(STDERR,"A filename is requierd\n");
|
||||||
|
exit($STATE_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($md5))
|
||||||
|
{
|
||||||
|
fwrite(STDERR,"You need to enter an MD5 checksum\n");
|
||||||
|
exit($STATE_UNKNOWN);
|
||||||
|
}
|
||||||
$file = md5_file($filename);
|
$file = md5_file($filename);
|
||||||
|
|
||||||
if ($file == $md5)
|
if ($file == $md5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user