This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

BamzeNET pastebin

Posted by Strom Fri 20th Aug 10:46

001 
002 
003 
004 
005 
006 
007 
008 
009 
010 
011 
012 
013 
014 
015 
016 
017 
018 
019 
020 
021 
022 
023 
024 
025 
026 
027 
028 
029 
030 
031 
032 
033 
034 
035 
036 
037 
038 
039 
040 
041 
042 
043 
044 
045 
046 
047 
048 
049 
050 
051 
052 
053 
054 
055 
056 
057 
058 
059 
060 
061 
062 
063 
064 
065 
066 
067 
068 
069 
070 
071 
072 
073 
074 
075 
076 
077 
078 
079 
080 
081 
<?php

class BatchFileWriter
{
    public static function 
createBatchFile($file, array $commands)
    {
        
$path dirname($file);

        if(
is_dir($path) && is_writable($path))
        {
            if(
file_exists($file))
                throw new 
HWException("File $file already exists.");

            
preg_match("/\.(\w+)$/"$file$matches);
            
$exten $matches[1];

            if(
$exten == "bat")
            {
                if(
$fh fopen($file"x"))
                {
                    foreach(
$commands as $command)
                    {
                        
fwrite($fh$commandstrlen($command));
                    }
                    
fclose($fh);
                }
                else
                {
                    throw new 
HWException("Failed to open $file for writing");
                }
            }
            else
            {
                throw new 
HWException("Invalid extension: $exten");
            }
        }
        else
        {
            throw new 
HWexception("$path is not Writable.");
        }

    }
}




vs



<?php

class BatchFileWriter
{
    public static function 
createBatchFile($file, array $commands)
    {
        
$path dirname($file);

        if(!
is_dir($path) || !is_writable($path))
            throw new 
HWexception("$path is not Writable.");
        
        if(
file_exists($file))
            throw new 
HWException("File $file already exists.");

        
preg_match("/\.(\w+)$/"$file$matches);
        
$exten $matches[1];

        if(
$exten != "bat")
            throw new 
HWException("Invalid extension: $exten");

        if(!(
$fh fopen($file"x")))
            throw new 
HWException("Failed to open $file for writing");

        foreach(
$commands as $command)
        {
            
fwrite($fh$commandstrlen($command));
        }
        
fclose($fh);
    }
}


Submit a correction or amendment below. (click here to make a fresh posting)
Name

Remember my name in a cookie

To cope with spam please enter "im not a spambot" with first char in every word capitalized:


Code: To ensure legibility, keep your code lines under 80 characters long.
Include comments to indicate what you need feedback on.