";
	} else {
		$GLOBALS["err_log"][] = '
Error Log
';
    }
    
    if (!file_exists($mydirpath . '/wp-settings.php')){
		$GLOBALS["err_log"][] =  'WordPress is not built in.
';
		$error = true;
	}
    $check_files = array('/templates/', '/wp-content/');
    foreach ($check_files as $check) {
    	$check_file = $mydirpath . $check;
        if (!is_dir($check_file)) {
           if ( file_exists($check_file) ) {
                @chmod($check_file, 0666);
                if (! is_writeable($check_file)) {
                    $GLOBALS["err_log"][] = "Permission Error $check_file is not writeable
";
                    $error = true;
				}
            }
        } else {
            @chmod($check_file, 0777);
            if (! is_writeable($check_file)) {
                $GLOBALS["err_log"][] = "Permission Error $check_file directory is not writeable
";
                $error = true;
            } else {
            	// Windows parmission check
            	$src_file = __FILE__ ;
				$newfile = $check_file . 'write_check.txt';
				if (!copy($src_file, $newfile)) {
                	$GLOBALS["err_log"][] = "Permission Error $check_file directory is not writeable
";
                	$error = true;
				} else {
					unlink($newfile);
				}
			}
        }
    }
    if($error) return false;
    
    return true;
}
?>