Added more santiy checks

This commit is contained in:
Jack-Benny Persson 2013-04-14 16:00:37 +02:00
parent 98892c9c03
commit 4672030dba
3 changed files with 14 additions and 4 deletions

Binary file not shown.

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.check_md5.php.swp

View File

@ -84,8 +84,9 @@ Options:
EOD; EOD;
// Print the help // Print the help
print_version(); print_version();
echo "$AUTHOR\n"; fwrite(STDOUT, "\n");
echo "\n$HELP_TEXT\n"; fwrite(STDOUT, "$AUTHOR\n");
fwrite(STDOUT, "\n$HELP_TEXT\n");
} }
@ -98,8 +99,10 @@ $longoptions = array("warning", "file=", "md5=");
$args = $options->readPHPArgv(); $args = $options->readPHPArgv();
$ret = $options->getopt($args, $shortoptions, $longoptions); $ret = $options->getopt($args, $shortoptions, $longoptions);
if (PEAR::isError($ret)) { if (PEAR::isError($ret))
fwrite(STDERR,$ret->getMessage() . "\n"); {
fwrite(STDERR,$ret->getMessage() . "\n\n");
print_help();
exit ($STATE_UNKNOWN); exit ($STATE_UNKNOWN);
} }
@ -144,6 +147,12 @@ if (empty($filename))
exit($STATE_UNKNOWN); exit($STATE_UNKNOWN);
} }
if (file_exists($filename) == FALSE)
{
fwrite(STDERR, "File $filename does not exsist!\n");
exit($STATE_UNKNOWN);
}
if (empty($md5)) if (empty($md5))
{ {
fwrite(STDERR,"You need to enter an MD5 checksum\n"); fwrite(STDERR,"You need to enter an MD5 checksum\n");