コード例 #1
0
ファイル: show.php プロジェクト: eistr2n/lansuite
function IsSupportedType($ext)
{
    $ext = strtolower($ext);
    if (($ext == "jpeg" or $ext == "jpg") and ImageTypes() & IMG_JPG or $ext == "png" and ImageTypes() & IMG_PNG or $ext == "gif" and ImageTypes() & IMG_GIF or $ext == "wbmp" and ImageTypes() & IMG_WBMP or $ext == "bmp" or IsSupportedVideo($ext)) {
        return true;
    } else {
        return false;
    }
}
コード例 #2
0
ファイル: GD.php プロジェクト: BackupTheBerlios/logicalframe
 /**
  * Check settings
  *
  * @return mixed true or  or a PEAR error object on error
  *
  * @see PEAR::isError()
  */
 function Image_Transform_GD()
 {
     if (!function_exists("ImageTypes")) {
         return PEAR::raiseError("libgd not compiled into PHP", true);
     }
     if (!ImageTypes()) {
         return PEAR::raiseError("No supported image types available", true);
     }
     return;
 }
コード例 #3
0
ファイル: VerifyCode.php プロジェクト: logdns/amh-4.2
 function IndexAction()
 {
     $str = "23456789ABCDEFGHJKMNPQRSTUVWXYZ";
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 4));
     $_SESSION['VerifyCode'] = strtolower(implode('', $code));
     $width = 115;
     $height = 29;
     $im = ImageCreate($width, $height);
     // 创建图形
     ImageColorAllocate($im, 255, 255, 255);
     // 填充背景颜色为白色
     // 用淡色给图形添加杂色
     for ($i = 0; $i < 100; $i++) {
         $pxcolor = ImageColorAllocate($im, 230, 104, 66);
         ImageSetPixel($im, mt_rand(0, $width), mt_rand(0, $height), $pxcolor);
     }
     // 用深色调绘制边框
     $bordercolor = ImageColorAllocate($im, 255, 255, 255);
     ImageRectangle($im, 0, 0, $width - 1, $height - 1, $bordercolor);
     $offset = rand(10, 30);
     $font = array('View/font/UniversityRomanStd.otf');
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 106);
         shuffle($font);
         imagettftext($im, 22, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += $width / 5 - rand(0, 2);
     }
     $code_str = str_shuffle($str);
     $code = str_split(substr($code_str, 0, 5));
     // 干扰字符
     $offset = rand(10, 30);
     foreach ($code as $char) {
         $textcolor = ImageColorAllocate($im, 230, 104, 66);
         shuffle($font);
         imagettftext($im, 8, rand(-20, 40), $offset, 26, $textcolor, $font[0], $char);
         $offset += rand(5, 10);
     }
     // 禁止缓存
     header("pragma:no-cache\r\n");
     header("Cache-Control:no-cache\r\n");
     header("Expires:0\r\n");
     if (ImageTypes() & IMG_PNG) {
         header('Content-Type:image/png');
         ImagePNG($im);
     } elseif (ImageTypes() & IMG_JPEG) {
         header('Content-Type:image/jpeg');
         ImageJPEG($im);
     } else {
         header('Content-Type:image/gif');
         ImageGif($im);
     }
 }
コード例 #4
0
ファイル: text2png.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (ImageTypes() & IMG_PNG) {
         // we have gd & png so go ahead.
         $args = $this->getArgs($argstr, $request);
         return $this->text2png($args);
     } else {
         // we don't have png and/or gd.
         $error_html = _("Sorry, this version of PHP cannot create PNG image files.");
         $link = "http://www.php.net/manual/pl/ref.image.php";
         $error_html .= sprintf(_("See %s"), $link) . ".";
         trigger_error($error_html, E_USER_NOTICE);
         return;
     }
 }
コード例 #5
0
ファイル: img.php プロジェクト: DarneoStudio/bitrix
function ShowImageHeader($ImageHandle)
{
    if (ImageTypes() & IMG_PNG) {
        Header("Content-type: image/png");
        ImagePng($ImageHandle);
    } elseif (ImageTypes() & IMG_GIF) {
        Header("Content-type: image/gif");
        ImageGif($ImageHandle);
    } elseif (ImageTypes() & IMG_JPEG) {
        Header("Content-type: image/jpeg");
        ImageJpeg($ImageHandle, "", 0.5);
    } else {
        die("No images support");
    }
    ImageDestroy($ImageHandle);
}
コード例 #6
0
 function VeriWord()
 {
     // Get Font-Files
     $handle = opendir($this->dir_font);
     $pre = 'captcha_';
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_font . $file)) {
             $nfo = pathinfo($this->dir_font . $file);
             $prefix = substr($nfo['basename'], 0, strlen($pre));
             if ($nfo['extension'] == 'ttf' && $prefix == $pre) {
                 $this->fonts[] = $nfo['basename'];
             }
         }
     }
     // Get Noise-Files
     $handle = opendir($this->dir_noise);
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_noise . $file)) {
             $nfo = pathinfo($this->dir_noise . $file);
             if ($nfo['extension'] == 'jpg' || $nfo['extension'] == 'jpeg') {
                 $this->noises[] = $nfo['basename'];
             }
         }
     }
     ImageTypes();
     $lang = new lang();
     $lang->group("thumbnail.class");
     $this->lang = $lang->return_array();
     if (function_exists('imagejpeg') && IMG_JPEG) {
         define('IMAGEJPEG', true);
     } else {
         define('IMAGEJPEG', false);
     }
     if (function_exists('imagegif') && IMG_GIF) {
         define('IMAGEGIF', true);
     } else {
         define('IMAGEGIF', false);
     }
     if (function_exists('imagepng') && IMG_PNG) {
         define('IMAGEPNG', true);
     } else {
         define('IMAGEPNG', false);
     }
     srand((double) microtime() * time());
     mt_srand((double) microtime() * 1000000);
 }
コード例 #7
0
function phpAds_GDImageFormat()
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $phpAds_GDImageFormat;
    // Determine php version
    $phpversion = preg_replace("/([^0-9])/D", "", phpversion());
    $phpversion = $phpversion / pow(10, strlen($phpversion) - 1);
    if ($phpversion >= 4.02 || $phpversion >= 3.018 && $phpversion < 4.0) {
        // Determine if GD is installed
        if (extension_loaded("gd")) {
            // Use ImageTypes() to dermine image format
            if (ImageTypes() & IMG_PNG) {
                $phpAds_GDImageFormat = "png";
            } elseif (ImageTypes() & IMG_JPG) {
                $phpAds_GDImageFormat = "jpeg";
            } elseif (ImageTypes() & IMG_GIF) {
                $phpAds_GDImageFormat = "gif";
            } else {
                $phpAds_GDImageFormat = "none";
            }
        } else {
            $phpAds_GDImageFormat = "none";
        }
    } elseif ($phpversion >= 4) {
        // No way to determine image format
        $phpAds_GDImageFormat = "gif";
        // assume gif?
    } else {
        // Use Function_Exists to determine image format
        if (function_exists("imagepng")) {
            $phpAds_GDImageFormat = "png";
        } elseif (function_exists("imagejpeg")) {
            $phpAds_GDImageFormat = "jpeg";
        } elseif (function_exists("imagegif")) {
            $phpAds_GDImageFormat = "gif";
        } else {
            $phpAds_GDImageFormat = "none";
        }
    }
    // Override detected GD foramt
    if (isset($pref['override_gd_imageformat']) && $pref['override_gd_imageformat'] != '') {
        $phpAds_GDImageFormat = $pref['override_gd_imageformat'];
    }
    return $phpAds_GDImageFormat;
}
コード例 #8
0
 function makeImage($session_expired_lang = 'Session Error<br>Refresh the Page')
 {
     global $config, $gpc;
     $challenge = $gpc->get('challenge');
     $this->settings['colortext'] = (bool) $config['botgfxtest_colortext'];
     $this->settings['filter'] = (bool) $config['botgfxtest_filter'];
     $jpeg_quality = (int) $config['botgfxtest_quality'];
     $format = $config['botgfxtest_format'] == 'png' ? 'PNG' : 'JPEG';
     if ((ImageTypes() & constant("IMG_{$format}")) == false) {
         $format = $format == 'PNG' ? 'JPEG' : 'PNG';
     }
     $lines = file($this->datasource);
     $lines = array_map('trim', $lines);
     foreach ($lines as $row) {
         if (empty($row)) {
             continue;
         }
         $data = explode("\t", $row);
         if ($data[0] == $challenge) {
             $this->session = array('word' => $data[2], 'id' => $data[1]);
             break;
         }
     }
     if (empty($this->session['word'])) {
         $this->_errorImage($session_expired_lang);
     }
     // Generate the image
     $im = $this->_drawImage();
     send_nocache_header();
     switch ($format) {
         case 'PNG':
             header("Content-type: image/png");
             imagepng($im);
             break;
         default:
             header("Content-type: image/jpeg");
             imagejpeg($im, '', $jpeg_quality);
     }
     imagedestroy($im);
 }
コード例 #9
0
 function thumbnail()
 {
     ImageTypes();
     $lang = new lang();
     $this->lang = $lang->return_array("classes");
     $this->path = '';
     $this->mime = array();
     if (viscacha_function_exists('imagejpeg') && IMG_JPEG) {
         define('IMAGEJPEG', true);
     } else {
         define('IMAGEJPEG', false);
     }
     if (viscacha_function_exists('imagegif') && IMG_GIF) {
         define('IMAGEGIF', true);
     } else {
         define('IMAGEGIF', false);
     }
     if (viscacha_function_exists('imagepng') && IMG_PNG) {
         define('IMAGEPNG', true);
     } else {
         define('IMAGEPNG', false);
     }
 }
コード例 #10
0
 function ReadImageFromFile($filename, $type)
 {
     $imagetypes = ImageTypes();
     switch ($type) {
         case 1:
             if ($imagetypes & IMG_GIF) {
                 return ImageCreateFromGIF($filename);
             } else {
                 $msg = "File type <b>.gif</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         case 2:
             if ($imagetypes & IMG_JPEG) {
                 return ImageCreateFromJPEG($filename);
             } else {
                 $msg = "File type <b>.jpg</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         case 3:
             if ($imagetypes & IMG_PNG) {
                 return ImageCreateFromPNG($filename);
             } else {
                 $msg = "File type <b>.png</b> not supported by GD version on server.";
                 $page = "?xl=Home";
                 page_load2($msg, $page);
                 return false;
             }
             break;
         default:
             echo "Chỉ hỗ trợ các loại tập tin với định dạng GIF,JPEG,PNG";
             return 0;
     }
 }
コード例 #11
0
 function ErrorImage($text, $width = 0, $height = 0, $forcedisplay = false)
 {
     $width = $width ? $width : $this->config_error_image_width;
     $height = $height ? $height : $this->config_error_image_height;
     $text = 'phpThumb() v' . $this->phpthumb_version . "\n" . 'http://phpthumb.sourceforge.net' . "\n\n" . ($this->config_disable_debug ? 'Error messages disabled' : $text);
     $this->FatalError($text);
     $this->DebugMessage($text, __FILE__, __LINE__);
     $this->purgeTempFiles();
     if ($this->phpThumbDebug && !$forcedisplay) {
         return false;
     }
     if (!$this->config_error_die_on_error && !$forcedisplay) {
         return false;
     }
     if ($this->config_error_silent_die_on_error) {
         exit;
     }
     if ($this->err || $this->config_error_message_image_default) {
         // Show generic custom error image instead of error message
         // for use on production sites where you don't want debug messages
         if ($this->err == 'showerror' || $this->phpThumbDebug) {
             // fall through and actually show error message even if default error image is set
         } else {
             header('Location: ' . ($this->err ? $this->err : $this->config_error_message_image_default));
             exit;
         }
     }
     $this->setOutputFormat();
     if (!$this->thumbnailFormat || phpthumb_functions::gd_version() < 1) {
         $this->thumbnailFormat = 'text';
     }
     if (@$this->thumbnailFormat == 'text') {
         // bypass all GD functions and output text error message
         if (!headers_sent()) {
             header('Content-type: text/plain');
             echo $text;
         } else {
             echo '<pre>' . htmlspecialchars($text) . '</pre>';
         }
         exit;
     }
     $FontWidth = ImageFontWidth($this->config_error_fontsize);
     $FontHeight = ImageFontHeight($this->config_error_fontsize);
     $LinesOfText = explode("\n", @wordwrap($text, floor($width / $FontWidth), "\n", true));
     $height = max($height, count($LinesOfText) * $FontHeight);
     $headers_file = '';
     $headers_line = '';
     if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=') && headers_sent($headers_file, $headers_line)) {
         echo "\n" . '**Headers already sent in file "' . $headers_file . '" on line "' . $headers_line . '", dumping error message as text:**<br><pre>' . "\n\n" . $text . "\n" . '</pre>';
     } elseif (headers_sent()) {
         echo "\n" . '**Headers already sent, dumping error message as text:**<br><pre>' . "\n\n" . $text . "\n" . '</pre>';
     } elseif ($gdimg_error = ImageCreate($width, $height)) {
         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bgcolor, true);
         $text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_textcolor, true);
         ImageFilledRectangle($gdimg_error, 0, 0, $width, $height, $background_color);
         $lineYoffset = 0;
         foreach ($LinesOfText as $line) {
             ImageString($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color);
             $lineYoffset += $FontHeight;
         }
         if (function_exists('ImageTypes')) {
             $imagetypes = ImageTypes();
             if ($imagetypes & IMG_PNG) {
                 header('Content-Type: image/png');
                 ImagePNG($gdimg_error);
             } elseif ($imagetypes & IMG_GIF) {
                 header('Content-Type: image/gif');
                 ImageGIF($gdimg_error);
             } elseif ($imagetypes & IMG_JPG) {
                 header('Content-Type: image/jpeg');
                 ImageJPEG($gdimg_error);
             } elseif ($imagetypes & IMG_WBMP) {
                 header('Content-Type: image/vnd.wap.wbmp');
                 ImageWBMP($gdimg_error);
             }
         }
         ImageDestroy($gdimg_error);
     }
     if (!headers_sent()) {
         echo "\n" . '**Failed to send graphical error image, dumping error message as text:**<br>' . "\n\n" . $text;
     }
     exit;
     return true;
 }
コード例 #12
0
ファイル: Image.php プロジェクト: CeusMedia/Image
 public function setType($type)
 {
     if (!(ImageTypes() & $type)) {
         throw new \InvalidArgumentException('Invalid type');
     }
     $this->type = $type;
     if ($this->fileName) {
         $baseName = pathinfo($this->fileName, PATHINFO_FILENAME);
         $pathName = pathinfo($this->fileName, PATHINFO_DIRNAME);
         $extension = image_type_to_extension($this->type);
         $this->fileName = $pathName . '/' . $baseName . $extension;
     }
 }
コード例 #13
0
 function ErrorImage($text, $width = 400, $height = 100)
 {
     $this->error = $text;
     if (!$this->config_error_die_on_error) {
         return true;
     }
     if (!empty($this->err) || !empty($this->config_error_message_image_default)) {
         // Show generic custom error image instead of error message
         // for use on production sites where you don't want debug messages
         if (@$this->err == 'showerror') {
             // fall through and actually show error message even if default error image is set
         } else {
             header('Location: ' . (!empty($this->err) ? $this->err : $this->config_error_message_image_default));
             exit;
         }
     }
     if (@$this->f == 'text') {
         // bypass all GD functions and output text error message
         die('<PRE>' . $text . '</PRE>');
     }
     $FontWidth = ImageFontWidth($this->config_error_fontsize);
     $FontHeight = ImageFontHeight($this->config_error_fontsize);
     $LinesOfText = explode("\n", wordwrap($text, floor($width / $FontWidth), "\n", true));
     $height = max($height, count($LinesOfText) * $FontHeight);
     if (headers_sent()) {
         echo "\n" . '**Headers already sent, dumping error message as text:**<br>' . "\n\n" . $text;
     } elseif ($gdimg_error = @ImageCreate($width, $height)) {
         $background_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_bgcolor, true);
         $text_color = phpthumb_functions::ImageHexColorAllocate($gdimg_error, $this->config_error_textcolor, true);
         ImageFilledRectangle($gdimg_error, 0, 0, $width, $height, $background_color);
         $lineYoffset = 0;
         foreach ($LinesOfText as $line) {
             ImageString($gdimg_error, $this->config_error_fontsize, 2, $lineYoffset, $line, $text_color);
             $lineYoffset += $FontHeight;
         }
         if (function_exists('ImageTypes')) {
             $imagetypes = ImageTypes();
             if ($imagetypes & IMG_PNG) {
                 header('Content-type: image/png');
                 ImagePNG($gdimg_error);
             } elseif ($imagetypes & IMG_GIF) {
                 header('Content-type: image/gif');
                 ImageGIF($gdimg_error);
             } elseif ($imagetypes & IMG_JPG) {
                 header('Content-type: image/jpeg');
                 ImageJPEG($gdimg_error);
             } elseif ($imagetypes & IMG_WBMP) {
                 header('Content-type: image/wbmp');
                 ImageWBMP($gdimg_error);
             }
         }
         ImageDestroy($gdimg_error);
     }
     if (!headers_sent()) {
         echo "\n" . '**Failed to send graphical error image, dumping error message as text:**<br>' . "\n\n" . $text;
     }
     exit;
     return true;
 }
コード例 #14
0
 imagecopyresampled($image_p, $im, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
 $thumb_file = substr($name, 0, strrpos($name, '.'));
 if (!preg_match("/(^[.a-zA-Z0-9-+_%&\$§~ ])/i", $thumb_file)) {
     $thumb_file = "non-ASCII";
     //  replacement for non-ASCII names. Visable only as name in thumbs subfolder
 }
 mysqltest();
 //  define thumbnail file
 if (ImageTypes() & IMG_GIF) {
     //  does gd-library support png ?
     $output = "." . $thumb_folder . "/" . $dba_act . "..." . $mysql_table_prefix . "..." . $link_id . "_-_" . $media_id . "-_-" . $thumb_file . ".gif";
     // create name for thumbnail
     imagegif($image_p, $output);
     // make a .gif file
 } else {
     if (ImageTypes() & IMG_PNG) {
         //  does gd-library support gif?
         $output = "." . $thumb_folder . "/" . $dba_act . "..." . $mysql_table_prefix . "..." . $link_id . "_-_" . $media_id . "-_-" . $thumb_file . ".png";
         imagepng($image_p, $output);
     }
 }
 //echo "\r\n\r\n<br /> output: $output<br />\r\n";
 //echo "\r\n\r\n<br /> image_p1: $image_p<br />\r\n";
 if ($output == '') {
     $output = "." . $thumb_folder . "/dummy.png";
     // no GD-library support for gif and png
 }
 $thumb = $db_con->real_escape_string(file_get_contents($output));
 mysqltest();
 //      store actual image in database
 $sql_query = "UPDATE " . $mysql_table_prefix . "media set thumbnail='{$thumb}' where media_link like '{$sql_link}' ";
コード例 #15
0
 function read_image_from_file($filename, $type)
 {
     $imagetypes = ImageTypes();
     switch ($type) {
         case 1:
             if ($imagetypes & IMG_GIF) {
                 return $im = ImageCreateFromGIF($filename);
             }
             break;
         case 2:
             if ($imagetypes & IMG_JPEG) {
                 return ImageCreateFromJPEG($filename);
             }
             break;
         case 3:
             if ($imagetypes & IMG_PNG) {
                 return ImageCreateFromPNG($filename);
             }
             break;
         default:
             return 0;
     }
 }
コード例 #16
0
function print_requirements_table()
{
    global $called_from_another_script, $path, $saurus_ver;
    $CONF = read_conf();
    # db connect data from config.php
    /*Assign required settings and their values*/
    $php_required_settings_to_check = array("register_globals", "file_uploads", "safe_mode");
    $php_setting_values_required = array(0, 1, 0);
    /*Assign recommended settings and their values*/
    $php_recommended_settings_to_check = array("post_max_size", "upload_max_filesize", "memory_limit");
    $php_setting_values_recommended = array(16, 16, 16);
    /* Directories to check (see also $saurus_ver) */
    $dirs = array($path . "classes/smarty/templates/", $path . "classes/smarty/templates_c/", $path . "classes/smarty/cache/");
    if ($saurus_ver == 3) {
        $dirs[] = $path . "failid/";
    }
    if ($saurus_ver == 4) {
        $dirs[] = $path . "public/";
        $dirs[] = $path . "shared/";
        $dirs[] = $path . "extensions/";
    }
    /* Get module information from phpinfo() */
    ob_start();
    phpinfo();
    $phpinfo = ob_get_contents();
    ob_end_clean();
    /* Find out if the webserver is running PHP asi CGI or as module 
    
    	Possible php_sapi_name() return values:
    
    	- aolserver
    	- activescript
    	- apache
    	- cgi-fcgi
    	- cgi
    	- isapi
    	- nsapi
    	- phttpd
    	- roxen
    	- java_servlet
    	- thttpd
    	- pi3web
    	- apache2filter
    	- caudium
    	- apache2handler
    	- tux
    	- webjames
    	- cli
    	- embed
    	- milter 
    
    	*/
    ## PHP running as CGI or FASTCGI
    if (php_sapi_name() == "cgi" || php_sapi_name() == "fcgi") {
        $mod_rewrite = -1;
        //mod_rewrite status unknown, because as CGI, phpinfo() doesn't show anything about loaded apache modules
    } else {
        //if PHP is running as module (php_sapi_name() == apache)
        /* Get module information from phpinfo() */
        if (strstr($phpinfo, "mod_rewrite")) {
            $mod_rewrite = 1;
        }
        //mod_rewrite exists
        //if $mod_rewrite doesn't exist up to this point, server is running PHP as module and it won't be shown by phpinfo()
    }
    ## if ISP==Zone then "mod_rewrite = YES"
    # (it's complicated to detect mod_rewrite module presence in PHP CGI mode)
    if ($_ENV['DZSP_CP_URL'] != '') {
        $mod_rewrite = 1;
        //mod_rewrite exists
    }
    /* Get PHP settings from php.ini */
    $ini = ini_get_all();
    /* Check if required and recommended settings and their value counts match */
    if (count($php_required_settings_to_check) != count($php_setting_values_required)) {
        die(" Count of php_required_settings_to_check and php_setting_values_required do not match!");
    }
    if (count($php_recommended_settings_to_check) != count($php_setting_values_recommended)) {
        die(" Count of php_recommended_settings_to_check and php_setting_values_recommended do not match!");
    }
    ############ styles
    ?>
	<style type="text/css">
	<!--
	/* Headline */
	<?php 
    if (!$path) {
        ?>
	.plk {font-size: 16px; font-family: Arial,Helvetica; color: #255AA6; font-weight: bold;}
	<?php 
    } else {
        ?>
	.plk { font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 14px; color: #333333; line-height: 16pt; font-weight: bold}
	<?php 
    }
    ?>
	/* Table */
	.scms_pane_header { font-family: Tahoma, Verdana, Helvetica; font-size: 13px; color: #FFFFFF; background-color: <?php 
    echo $path ? '#4040A9' : '#255AA6';
    ?>
; font-weight: bold; padding-right: 5px; padding-left: 8px; height: 30px}
	.scms_pane_header { font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #CCCCCC; font-weight: bold; padding-right: 5px; padding-left: 6px; height: 22px }
	.r1 { height: 22px; font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #FFFFFF; padding-right: 5px; padding-left: 6px; line-height: 16px; vertical-align: top}
	.r2 { height: 22px; font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #F0F0F0; padding-right: 5px; padding-left: 6px; line-height: 16px; vertical-align: top }
	-->
	</style>
	<?php 
    ?>
<?php############ / styles?>

	<?php 
    ?>
<?php##################### HTML START #################?>
	<?php 
    if (!$called_from_another_script) {
        ?>
	<font class="plk">Server requirements</font>
	<br>
	<br>
	<?php 
    }
    ?>

	<table border="0" cellspacing="0" cellpadding="3" width="<?php 
    echo $called_from_another_script ? '580' : '100%';
    ?>
">
	<tr class="scms_tableheader"> 
		<td>Setting</td><td>Required value</td><td>Local value</td>
	</tr>
	<?php 
    ?>
<?php##################### DATABASE and WEBSERVER #################?>
	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Database and Webserver</td>
	</tr>
	<?php 
    if (is_array($CONF)) {
        # conf file settings
        if (($conn = @mysql_connect($CONF['dbhost'] . ":" . $CONF['dbport'], $CONF['user'], $CONF['passwd'])) && $CONF['db']) {
            if ($dbh = @mysql_select_db($CONF['db'], $conn)) {
                $res = @mysql_fetch_array(@mysql_query("SELECT VERSION()"));
                $mysql_version = $res[0];
            }
            # dbh
        }
        # conn
    }
    if (!$mysql_version) {
        $word = 'Unknown (this value is OK during installation)';
    }
    ####### MYSQL version: 4.x - 5.1.35
    if (!$mysql_version || version_compare($mysql_version, "4.0") < 0 || version_compare($mysql_version, "5.6.20") > 0) {
        $color = "color='red'";
    } else {
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">MySQL version</font></td><td><font " . $color . ">4.x - 5.1.35</font></td><td><font " . $color . ">" . ($mysql_version ? $mysql_version : $word) . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ######## apache
    $tmp_arr = explode(")", $_SERVER['SERVER_SOFTWARE']);
    $webserver = $tmp_arr[0] . ($tmp_arr[1] ? ")" : "");
    if (!stristr(strtolower($webserver), 'apache')) {
        $color = "color='red'";
    }
    echo "<tr><td><font " . $color . ">Webserver software</font></td><td><font " . $color . ">Apache</font></td><td><font " . $color . ">" . ($webserver ? $webserver : 'Not found') . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ######## mod_rewrite
    if ($mod_rewrite == 1) {
        $color = "color='black'";
        $word = "Yes";
    } elseif ($mod_rewrite == -1) {
        $color = "color='red'";
        $word = "Unknown";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    echo "<tr><td><font " . $color . ">Apache module \"mod_rewrite\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ?>
	<?php 
    ?>
<?php##################### REQUIRED PHP #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Required PHP Settings</td>
	</tr>
	<?php 
    ####### PHP version: 5.0.0 - 5.6.3
    if (version_compare(phpversion(), "5.3.0") < 0 || version_compare(phpversion(), "5.6.2") > 0) {
        $color = "color='red'";
    }
    echo "<tr><td><font " . $color . ">PHP version</font></td><td><font " . $color . ">5.3.0 - 5.6.2</font></td><td><font " . $color . ">" . phpversion() . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ####### mysql support in php
    if (function_exists('mysql_connect')) {
        $word = "Yes";
        $color = "color='black'";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    echo "<tr><td><font " . $color . ">MySQL Support enabled</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ####### php flags/values
    reset($php_required_settings_to_check);
    for ($i = 0; $i < count($php_required_settings_to_check); $i++) {
        //$current_setting = $php_required_settings_to_check[$i];
        if ($php_setting_values_required[$i] != (int) $ini[$php_required_settings_to_check[$i]][local_value]) {
            $color = "color='red'";
        }
        if ($ini[$php_required_settings_to_check[$i]][local_value] == 0) {
            $local_value = "Off";
        } else {
            $local_value = "On";
        }
        if ($php_setting_values_required[$i] == 0) {
            $required_value = "Off";
        } else {
            $required_value = "On";
        }
        echo "<tr><td><font " . $color . ">{$php_required_settings_to_check[$i]}</font></td><td><font " . $color . ">{$required_value}</font></td><td><font " . $color . ">{$local_value}</font></td></tr>";
        $color = "color='black'";
        //restore default color
    }
    /* Check for track_vars. track_vars is  always enabled since PHP 4.0.3 */
    if (version_compare(phpversion(), "4.0.3") < 0) {
        # If version is < 4.0.3 => then check, if phpinfo has "enable-track-vars". If not, then track_vars=OFF.
        if (!strstr($phpinfo, "enable-track-vars")) {
            $local_value = "Off";
            $color = "color='red'";
        } else {
            $local_value = "On";
            $color = "color='black'";
        }
    } else {
        $local_value = "On";
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">track_vars</font></td><td><font " . $color . ">On</font></td><td><font " . $color . ">{$local_value}</font></td></tr>";
    # check for mbstring
    if (!strstr($phpinfo, "mbstring")) {
        # mbstring not found
        $local_value = "No";
        $color = "color='red'";
    } else {
        # mbstring exists
        $local_value = "Yes";
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">mbstring support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $local_value . "</font></td></tr>";
    ?>

	<?php 
    ?>
<?php##################### RECOMMENDED PHP #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Recommended PHP Settings</td>
	</tr>
	<?php 
    reset($php_recommended_settings_to_check);
    for ($i = 0; $i < count($php_recommended_settings_to_check); $i++) {
        echo "<tr><td>{$php_recommended_settings_to_check[$i]}</td><td>{$php_setting_values_recommended[$i]}</td><td>" . (int) $ini[$php_recommended_settings_to_check[$i]][local_value] . "</td></tr>";
        $color = "color='black'";
        //restore default color
    }
    ?>

	<?php 
    ?>
<?php##################### GD library #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">GD library</td>
	</tr>
	<?php 
    ######## GD
    #$gdinfo = gd_info();
    #printr($gdinfo['GD Version']);
    if (function_exists('imagetypes') && ImageTypes() & IMG_PNG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PNG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_GIF) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: GIF Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_JPG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: JPG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_JPEG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: JPEG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_WBMP) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: WBMP Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    ### GD functions:
    if (function_exists('getimagesize')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"getimagesize\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imageCreateTrueColor')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imageCreateTrueColor\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagecreatefromjpeg')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagecreatefromjpeg\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagecopyresampled')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagecopyresampled\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagesx')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagesx\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagesy')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagesy\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    ?>


	<?php 
    ?>
<?php##################### FILESYSTEM #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Filesystem permissions</td>
	</tr>

	<?php 
    foreach ($dirs as $value) {
        # check if exists
        if (file_exists($value)) {
            if (is_writeable($value)) {
                $color = "color='black'";
                $word = "Writable";
            } else {
                $color = "color='red'";
                $word = "Not writable";
            }
        } else {
            $color = "color='red'";
            $word = "Not found";
        }
        # exists
        $i++;
        echo "<tr><td><font " . $color . ">" . $value . "</font></td><td><font " . $color . ">Writable</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    }
    ?>
	</table>
	<?php 
}
コード例 #17
0
 private static function gd_info()
 {
     // Check if we need to emulate this function since it is built into PHP v4.3.0+ (with bundled GD2 library)
     if (!function_exists("gd_info")) {
         static $_gdinfo = array();
         // Check if need to get the requested information
         if (empty($_gdinfo)) {
             // Initialize array with default values
             $_gdinfo = array("GD Version" => "", "FreeType Support" => false, "FreeType Linkage" => "", "T1Lib Support" => false, "GIF Read Support" => false, "GIF Create Support" => false, "JPG Support" => false, "PNG Support" => false, "WBMP Support" => false, "XBM Support" => false);
             // Now we need to read the phpinfo() to detect the GD library support
             $_phpinfo = self::php_info();
             foreach ($_phpinfo as $_value) {
                 $_value = trim(strip_tags($_value));
                 foreach ($_gdinfo as $key => $value) {
                     if (strpos($_value, $key) === 0) {
                         $_new_value = trim(str_replace($key, "", $_value));
                         $_gdinfo[$key] = $_new_value;
                     }
                 }
             }
             // Check if GD version information is present now
             if (empty($_gdinfo["GD Version"])) {
                 // Check if we can detect GD library by bypassing the function: phpinfo()
                 if (function_exists("ImageTypes")) {
                     $_imagetypes = ImageTypes();
                     // Check JPG support
                     if ($_imagetypes & IMG_JPG) {
                         $_gdinfo["JPG Support"] = true;
                     }
                     // Check PNG support
                     if ($_imagetypes & IMG_PNG) {
                         $_gdinfo["PNG Support"] = true;
                     }
                     // Check GIF support
                     if ($_imagetypes & IMG_GIF) {
                         $_gdinfo["GIF Create Support"] = true;
                     }
                 }
                 // Detect capabilities of GIF support
                 if (function_exists('ImageCreateFromGIF')) {
                     if ($_tempfilename = we_base_file::saveTemp(base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw=='))) {
                         // GIF create support must be enabled if we're able to create a image
                         $_gif_test = @imagecreatefromgif($_tempfilename);
                         if ($_gif_test) {
                             $_gdinfo["GIF Read Support"] = true;
                         }
                         unlink($_tempfilename);
                     }
                 }
                 // Detect version of GD library
                 if (function_exists("ImageCreateTrueColor") && @imagecreatetruecolor(1, 1)) {
                     $_gdinfo["GD Version"] = "2.0.1 or higher (assumed)";
                 } else {
                     if (function_exists("ImageCreate") && @imagecreate(1, 1)) {
                         $_gdinfo["GD Version"] = "1.6.0 or higher (assumed)";
                     }
                 }
             }
         }
         return $_gdinfo;
     } else {
         return gd_info();
     }
 }
コード例 #18
0
ファイル: phPie.php プロジェクト: Geraldofilho1993/financ
function phPie($data, $width, $height, $CenterX, $CenterY, $DiameterX, $DiameterY, $MinDisplayPct, $DisplayColors, $BackgroundColor, $LineColor, $Legend, $FontNumber, $SortData = TRUE)
{
    if ($im = @ImageCreate($width, $height)) {
        $background_color = ImageColorAllocate($im, hexdec(substr($BackgroundColor, 0, 2)), hexdec(substr($BackgroundColor, 2, 2)), hexdec(substr($BackgroundColor, 4, 2)));
        $line_color = ImageColorAllocate($im, hexdec(substr($LineColor, 0, 2)), hexdec(substr($LineColor, 2, 2)), hexdec(substr($LineColor, 4, 2)));
        $fillcolorsarray = explode(';', $DisplayColors);
        for ($i = 0; $i < count($fillcolorsarray); $i++) {
            $fill_color[] = ImageColorAllocate($im, hexdec(substr($fillcolorsarray["{$i}"], 0, 2)), hexdec(substr($fillcolorsarray["{$i}"], 2, 2)), hexdec(substr($fillcolorsarray["{$i}"], 4, 2)));
            $label_color[] = ImageColorAllocate($im, hexdec(substr($fillcolorsarray["{$i}"], 0, 2)) * 0.8, hexdec(substr($fillcolorsarray["{$i}"], 2, 2)) * 0.8, hexdec(substr($fillcolorsarray["{$i}"], 4, 2)) * 0.8);
        }
        $TotalArrayValues = array_sum($data);
        if ($SortData) {
            arsort($data);
        }
        $Start = 0;
        $valuecounter = 0;
        $ValuesSoFar = 0;
        foreach ($data as $key => $value) {
            $ValuesSoFar += $value;
            if (!$SortData || $value / $TotalArrayValues > $MinDisplayPct) {
                $End = ceil($ValuesSoFar / $TotalArrayValues * 360);
                FilledArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color, $fill_color[$valuecounter % count($fill_color)]);
                if ($Legend) {
                    ImageString($im, $FontNumber, 5, round(ImageFontHeight($FontNumber) * 0.5 + $valuecounter * 1.5 * ImageFontHeight($FontNumber)), $key . ' (' . number_format($value / $TotalArrayValues * 100, 1) . '%)', $label_color[$valuecounter % count($label_color)]);
                }
                $Start = $End;
            } else {
                // too small to bother drawing - just finish off the arc with no fill and break
                $End = 360;
                if (($TotalArrayValues - $ValuesSoFar) / $TotalArrayValues > 0.0025) {
                    // only fill in if more than 0.25%, otherwise colors might bleed
                    FilledArc($im, $CenterX, $CenterY, $DiameterX, $DiameterY, $Start, $End, $line_color, $line_color);
                }
                if ($Legend) {
                    ImageString($im, $FontNumber, 5, round(ImageFontHeight($FontNumber) * 0.5 + $valuecounter * 1.5 * ImageFontHeight($FontNumber)), 'Other (' . number_format(($TotalArrayValues - $ValuesSoFar) / $TotalArrayValues * 100, 1) . '%)', $line_color);
                }
                break;
            }
            $valuecounter++;
        }
        // display image
        if (ImageTypes() & IMG_PNG) {
            header('Content-type: image/png');
            ImagePNG($im);
        } else {
            if (ImageTypes() & IMG_GIF) {
                header('Content-type: image/gif');
                ImageGIF($im);
            } else {
                if (ImageTypes() & IMG_JPG) {
                    header('Content-type: image/jpeg');
                    ImageJPEG($im);
                }
            }
        }
        ImageDestroy($im);
        return TRUE;
    } else {
        echo 'Cannot Initialize new GD image stream';
        return FALSE;
    }
}
コード例 #19
0
ファイル: hawxy.php プロジェクト: BackupTheBerlios/oos-svn
function handleParsedElement($parser, $pos, $name, $attrs)
{
    global $tag_stack;
    global $err;
    global $banner;
    global $img_conversion_enabled;
    global $skin;
    global $allow_skin_attribute;
    static $number_of_decks = 0;
    static $number_of_forms = 0;
    static $number_of_linksets = 0;
    static $markup_language = 0;
    static $raw_mode = false;
    if (function_exists("xml_get_current_line_number")) {
        $line = xml_get_current_line_number($parser);
    } else {
        $line = "???";
    }
    switch ($name) {
        case "HAWHAW":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_HAWHAW, $parser);
                $tag_stack->push(0, HAX_TAG_HAWHAW);
            } else {
                // HAX_PARSE_END
                $tag_stack->pop();
            }
            break;
        case "DECK":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_DECK, $parser);
                if ($number_of_decks++ > 0) {
                    error($err[5], $parser, $line);
                }
                // determine contructor arguments of HAW_deck
                if (isset($attrs["TITLE"])) {
                    $title = $attrs["TITLE"];
                } else {
                    $title = HAW_NOTITLE;
                }
                if (isset($attrs["ALIGN"]) && $attrs["ALIGN"] == "center") {
                    $alignment = HAW_ALIGN_CENTER;
                } elseif (isset($attrs["ALIGN"]) && $attrs["ALIGN"] == "right") {
                    $alignment = HAW_ALIGN_RIGHT;
                } else {
                    $alignment = HAW_ALIGN_LEFT;
                }
                $output = HAW_OUTPUT_AUTOMATIC;
                if (isset($attrs["OUTPUT"])) {
                    switch ($attrs["OUTPUT"]) {
                        case "bigscreen":
                            $output = HAW_OUTPUT_BIGSCREEN;
                            break;
                        case "wap":
                            $output = HAW_OUTPUT_WAP;
                            break;
                        case "hdml":
                            $output = HAW_OUTPUT_HDML;
                            break;
                        case "pda":
                            $output = HAW_OUTPUT_PDA;
                            break;
                        case "imode":
                            $output = HAW_OUTPUT_IMODE;
                            break;
                        case "mml":
                            $output = HAW_OUTPUT_MML;
                            break;
                        case "voicexml":
                            $output = HAW_OUTPUT_VOICEXML;
                            break;
                        case "xhtml":
                            $output = HAW_OUTPUT_XHTML;
                            break;
                    }
                }
                // initiate HAW_deck object
                $deck = new HAW_deck($title, $alignment, $output);
                $markup_language = $deck->ml;
                // modify HAW_deck objects according attribute list
                if (isset($attrs["REDIRECTION"])) {
                    $redirection = explode(";", $attrs["REDIRECTION"]);
                    $redirection[0] = trim($redirection[0]);
                    // strip whitespace
                    $redirection[1] = trim($redirection[1]);
                    if (isset($redirection[2])) {
                        $redirection[2] = trim(strtolower($redirection[2]));
                    }
                    if ($redirection[0] < 1 || $redirection[0] > 3600) {
                        error($err[3], $parser, $line);
                    }
                    // invalid time value
                    if (substr(strtolower($redirection[1]), 0, 4) != "url=") {
                        error($err[3], $parser, $line);
                    }
                    // invalid URL declaration
                    if (isset($redirection[2]) && $redirection[2] == "proxy=no") {
                        // redirect directly to target (needed for HawTags)
                        $deck->set_redirection($redirection[0], substr($redirection[1], 4));
                    } else {
                        // redirect via HAWXY
                        $deck->set_redirection($redirection[0], determine_url(qualify_url(substr($redirection[1], 4))));
                    }
                }
                if (isset($attrs["CACHE"]) && strtolower($attrs["CACHE"]) == "no") {
                    $deck->disable_cache();
                }
                if (isset($attrs["CHARSET"])) {
                    $deck->set_charset($attrs["CHARSET"]);
                }
                if (isset($attrs["LANGUAGE"])) {
                    $deck->set_language($attrs["LANGUAGE"]);
                }
                if (isset($attrs["CSS"])) {
                    $deck->set_css($attrs["CSS"]);
                }
                if (isset($attrs["CSS_CLASS"])) {
                    $deck->set_css_class($attrs["CSS_CLASS"]);
                }
                if (isset($attrs["BACKGROUND"])) {
                    $deck->set_background($attrs["BACKGROUND"]);
                }
                if (isset($attrs["BGCOLOR"])) {
                    $deck->set_bgcolor($attrs["BGCOLOR"]);
                }
                if (isset($attrs["SIZE"])) {
                    $deck->set_size($attrs["SIZE"]);
                }
                if (isset($attrs["COLOR"])) {
                    $deck->set_color($attrs["COLOR"]);
                }
                if (isset($attrs["LINK_COLOR"])) {
                    $deck->set_link_color($attrs["LINK_COLOR"]);
                }
                if (isset($attrs["VLINK_COLOR"])) {
                    $deck->set_vlink_color($attrs["VLINK_COLOR"]);
                }
                if (isset($attrs["LINK_BRACKETS"]) && strtolower($attrs["LINK_BRACKETS"]) == "no") {
                    $deck->use_link_brackets(false);
                }
                if (isset($attrs["FACE"])) {
                    $deck->set_face($attrs["FACE"]);
                }
                if (isset($attrs["WAPHOME"])) {
                    $deck->set_waphome($attrs["WAPHOME"]);
                } else {
                    $deck->set_waphome("http://" . getenv("HTTP_HOST") . getenv("REQUEST_URI"));
                }
                if (isset($attrs["VOICE_JINGLE"])) {
                    $deck->set_voice_jingle($attrs["VOICE_JINGLE"]);
                }
                if (isset($attrs["SKIN"]) && $allow_skin_attribute) {
                    if (strtolower($attrs["SKIN"]) == "none") {
                        $deck->use_simulator(HAW_SIM_NONE);
                    } else {
                        if (strtolower($attrs["SKIN"]) == "classic") {
                            $deck->use_simulator(HAW_SIM_CLASSIC);
                        } else {
                            $deck->use_simulator($attrs["SKIN"]);
                        }
                    }
                } else {
                    $deck->use_simulator($skin);
                }
                // display banners on top of simulator device
                while (list($key, $val) = each($banner)) {
                    // edit config file for banner control
                    $top_banner[$key] = new HAW_banner($val["img"], $val["url"], $val["alt"]);
                    $top_banner[$key]->set_size($val["width"], $val["height"]);
                    $deck->add_banner($top_banner[$key], HAW_TOP);
                }
                $tag_stack->push($deck, HAX_TAG_DECK);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                $deck = $element["element"];
                $deck->create_page();
            }
            break;
        case "FORM":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_FORM, $parser);
                if ($number_of_forms++ > 0) {
                    error($err[9], $parser, $line);
                }
                if (!isset($attrs["ACTION"])) {
                    error("<form> " . $err[7] . " action", $parser, $line);
                }
                // action attribute is missing
                // initiate HAW_form object
                if (isset($attrs["PROXY"]) && strtolower($attrs["PROXY"]) == "no") {
                    // send form data to action script (needed for HawTags)
                    $form = new HAW_form($attrs["ACTION"]);
                } else {
                    // send form data to hawxy server
                    $form = new HAW_form($_SERVER['SCRIPT_NAME']);
                    // add info about XML source where form input has to be propagated to
                    $hidden = new HAW_hidden("code", qualify_url($attrs["ACTION"]));
                    $form->add_hidden($hidden);
                }
                $tag_stack->push($form, HAX_TAG_FORM);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_form object
                $form = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck)
                $base_element = $element["element"];
                $base_element->add_form($form);
                // add HAW_form to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "TEXT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_TEXT, $parser);
                $format = "HAW_TEXTFORMAT_NORMAL";
                if (isset($attrs["BOLD"]) && strtolower($attrs["BOLD"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_BOLD;
                }
                if (isset($attrs["ITALIC"]) && strtolower($attrs["ITALIC"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_ITALIC;
                }
                if (isset($attrs["UNDERLINE"]) && strtolower($attrs["UNDERLINE"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_UNDERLINE;
                }
                if (isset($attrs["BIG"]) && strtolower($attrs["BIG"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_BIG;
                }
                if (isset($attrs["SMALL"]) && strtolower($attrs["SMALL"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_SMALL;
                }
                if (isset($attrs["BOXED"]) && strtolower($attrs["BOXED"]) == "yes") {
                    $format |= HAW_TEXTFORMAT_BOXED;
                }
                $text = new HAW_text("", $format);
                if (isset($attrs["BR"]) && $attrs["BR"] >= 0) {
                    $text->set_br($attrs["BR"] + 0);
                }
                // convert string to int!
                if (isset($attrs["CSS_CLASS"])) {
                    $text->set_css_class($attrs["CSS_CLASS"]);
                }
                if (isset($attrs["COLOR"])) {
                    $textcolor = $attrs["COLOR"];
                    if (isset($attrs["BOXCOLOR"])) {
                        $boxcolor = $attrs["BOXCOLOR"];
                    } else {
                        $boxcolor = "";
                    }
                    $text->set_color($textcolor, $boxcolor);
                }
                $tag_stack->push($text, HAX_TAG_TEXT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_text object
                $text = $element["element"];
                if (!$text->voice_text) {
                    $text->voice_text = $text->text;
                }
                // update voice_text if not already set
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_form, ...)
                $base_element = $element["element"];
                if ($element["tag"] == HAX_TAG_TD) {
                    // include HAW_text object in HAX_td pseudo class
                    $base_element->element = $text;
                    $base_element->tag = HAX_TAG_TEXT;
                } else {
                    $base_element->add_text($text);
                }
                // add HAW_text to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "IMG":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_IMAGE, $parser);
                if (!($alt = $attrs["ALT"])) {
                    error("<img> " . $err[7] . " alt", $parser, $line);
                }
                // alt attribute is missing
                if (isset($attrs["SRC"])) {
                    // source attribute ==> perform automatic image conversion
                    if (!$img_conversion_enabled) {
                        error($err[13], $parser, $line);
                    }
                    // image conversion deactivated per config
                    if (!function_exists("ImageTypes")) {
                        error($err[13], $parser, $line);
                    }
                    // GD is not loaded
                    if (!(ImageTypes() & (IMG_PNG | IMG_WBMP))) {
                        error($err[13], $parser, $line);
                    }
                    // not all necessary image types supported
                    $source = $attrs["SRC"];
                    $extension = strtolower(substr($source, -4));
                    $accept = strtolower($_SERVER['HTTP_ACCEPT']);
                    if ($extension == ".gif" && (strstr($accept, "image/gif") || $markup_language == HAW_HTML && !strstr($accept, "image/png")) || $extension == ".png" && (strstr($accept, "image/png") || $markup_language == HAW_HTML) || $extension == "wbmp" && $markup_language == HAW_WML) {
                        // requesting browser accepts given src image file
                        // ==> no conversion required
                        $src_html = $source;
                        $src_wbmp = $source;
                    } else {
                        // session-controlled image conversion
                        // convert images of HAWHAW XML files only
                        // (we don't want to act as conversion server for the whole world!)
                        static $img_counter = 0;
                        $varname = "i" . $img_counter;
                        session_register($varname);
                        $_SESSION[$varname] = $attrs["SRC"];
                        $_SESSION['img_ml'] = $markup_language;
                        //$url = sprintf("%s?index=%d", $_SERVER['PHP_SELF'] , $img_counter);
                        // auto-appending of SID does not work in some environments ?!?!?
                        // PHPSESSID may appear twice in url - and if? ...
                        $url = sprintf("%s?index=%d&amp;%s", $_SERVER['PHP_SELF'], $img_counter, SID);
                        // create image with session ID instead of image URL's
                        // ==> hawxy script will immediately receive a new request
                        //     and will create appropriate image on the fly
                        $src_html = $url;
                        $src_wbmp = $url;
                        $img_counter++;
                    }
                }
                if (!isset($src_wbmp) && !isset($attrs["WBMP"])) {
                    error("<img> " . $err[7] . " wbmp", $parser, $line);
                } elseif (isset($attrs["WBMP"])) {
                    $src_wbmp = $attrs["WBMP"];
                }
                // explicitely given WBMP file has precedence
                if (!isset($src_html) && !isset($attrs["HTML"])) {
                    error("<img> " . $err[7] . " html", $parser, $line);
                } elseif (isset($attrs["HTML"])) {
                    $src_html = $attrs["HTML"];
                }
                // explicitely given HTML file has precedence
                if (isset($attrs["BMP"])) {
                    $image = new HAW_image($src_wbmp, $src_html, $alt, $attrs["BMP"]);
                } else {
                    $image = new HAW_image($src_wbmp, $src_html, $alt);
                }
                if (isset($attrs["HTML"]) && isset($attrs["HTML_WIDTH"])) {
                    $image->set_html_width($attrs["HTML_WIDTH"]);
                }
                if (isset($attrs["HTML"]) && isset($attrs["HTML_HEIGHT"])) {
                    $image->set_html_height($attrs["HTML_HEIGHT"]);
                }
                if (isset($attrs["BR"]) && $attrs["BR"] >= 0) {
                    $image->set_br($attrs["BR"] + 0);
                }
                // convert string to int!
                if (isset($attrs["LOCALSRC"])) {
                    $image->use_localsrc($attrs["LOCALSRC"]);
                }
                if (isset($attrs["CHTML_ICON"])) {
                    $image->use_chtml_icon($attrs["CHTML_ICON"] + 0);
                }
                // convert string to int!
                if (isset($attrs["MML_ICON"]) && strlen($attrs["MML_ICON"]) == 2) {
                    $image->use_mml_icon($attrs["MML_ICON"]);
                }
                $tag_stack->push($image, HAX_TAG_IMAGE);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_image object
                $image = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_form, ...)
                $base_element = $element["element"];
                if ($element["tag"] == HAX_TAG_TD) {
                    // include HAW_text object in HAX_td pseudo class
                    $base_element->element = $image;
                    $base_element->tag = HAX_TAG_IMAGE;
                } else {
                    $base_element->add_image($image);
                }
                // add HAW_image to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "INPUT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_INPUT, $parser);
                if (!($name = $attrs["NAME"])) {
                    error("<input> " . $err[7] . " name", $parser, $line);
                }
                // name attribute is missing
                if (isset($attrs["FORMAT"])) {
                    $input = new HAW_input($name, $attrs["VALUE"], $attrs["LABEL"], $attrs["FORMAT"]);
                } else {
                    $input = new HAW_input($name, $attrs["VALUE"], $attrs["LABEL"]);
                }
                if (isset($attrs["SIZE"])) {
                    $input->set_size($attrs["SIZE"]);
                }
                if (isset($attrs["MAXLENGTH"])) {
                    $input->set_maxlength($attrs["MAXLENGTH"]);
                }
                if (isset($attrs["TYPE"]) && strtolower($attrs["TYPE"]) == "password") {
                    $input->set_type(HAW_INPUT_PASSWORD);
                }
                if (isset($attrs["MODE"])) {
                    if (strtolower($attrs["MODE"]) == "alphabet") {
                        $input->set_mode(HAW_INPUT_ALPHABET);
                    }
                    if (strtolower($attrs["MODE"]) == "katakana") {
                        $input->set_mode(HAW_INPUT_KATAKANA);
                    }
                    if (strtolower($attrs["MODE"]) == "hiragana") {
                        $input->set_mode(HAW_INPUT_HIRAGANA);
                    }
                    if (strtolower($attrs["MODE"]) == "numeric") {
                        $input->set_mode(HAW_INPUT_NUMERIC);
                    }
                }
                if (isset($attrs["BR"]) && $attrs["BR"] >= 0) {
                    $input->set_br($attrs["BR"] + 0);
                }
                // convert string to int!
                if (isset($attrs["VOICE_TYPE"])) {
                    $input->set_voice_type($attrs["VOICE_TYPE"]);
                }
                if (isset($attrs["VOICE_GRAMMAR_SRC"])) {
                    // set external grammar
                    if (isset($attrs["VOICE_GRAMMAR_TYPE"])) {
                        $input->set_voice_grammar($attrs["VOICE_GRAMMAR_SRC"], $attrs["VOICE_GRAMMAR_TYPE"]);
                    } else {
                        $input->set_voice_grammar($attrs["VOICE_GRAMMAR_SRC"]);
                    }
                    // requires HAWHAW V5.5 or higher!
                }
                $tag_stack->push($input, HAX_TAG_INPUT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_input object
                $input = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_input($input);
                // add HAW_input to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "RADIO":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_RADIO, $parser);
                if (!($name = $attrs["NAME"])) {
                    error("<radio> " . $err[7] . " name", $parser, $line);
                }
                // name attribute is missing
                $radio = new HAW_radio($name);
                $tag_stack->push($radio, HAX_TAG_RADIO);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_radio object
                $radio = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_radio($radio);
                // add HAW_radio to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "BUTTON":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_BUTTON, $parser);
                if (!($label = $attrs["LABEL"])) {
                    error("<button> " . $err[7] . " label", $parser, $line);
                }
                // label attribute is missing
                if (!($value = $attrs["VALUE"])) {
                    error("<button> " . $err[7] . " value", $parser, $line);
                }
                // value attribute is missing
                if (isset($attrs["CHECKED"]) && strtolower($attrs["CHECKED"]) == "yes") {
                    $checked = HAW_CHECKED;
                } else {
                    $checked = HAW_NOTCHECKED;
                }
                $element = $tag_stack->pop();
                // pop base object (HAW_radio)
                $base_element = $element["element"];
                $base_element->add_button($label, $value, $checked);
                // add button properties
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            } else {
                // HAX_PARSE_END
                // nothing to do any more
            }
            break;
        case "CHECKBOX":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_CHECKBOX, $parser);
                if (!($name = $attrs["NAME"])) {
                    error("<checkbox> " . $err[7] . " name", $parser, $line);
                }
                // name attribute is missing
                if (!($value = $attrs["VALUE"])) {
                    error("<checkbox> " . $err[7] . " value", $parser, $line);
                }
                // value attribute is missing
                if (!($label = $attrs["LABEL"])) {
                    error("<checkbox> " . $err[7] . " label", $parser, $line);
                }
                // label attribute is missing
                if (isset($attrs["CHECKED"]) && strtolower($attrs["CHECKED"]) == "yes") {
                    $checked = HAW_CHECKED;
                } else {
                    $checked = HAW_NOTCHECKED;
                }
                $checkbox = new HAW_checkbox($name, $value, $label, $checked);
                $tag_stack->push($checkbox, HAX_TAG_CHECKBOX);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_checkbox object
                $checkbox = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_checkbox($checkbox);
                // add HAW_checkbox to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "SELECT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_SELECT, $parser);
                if (!($name = $attrs["NAME"])) {
                    error("<select> " . $err[7] . " name", $parser, $line);
                }
                // name attribute is missing
                if (strtolower($attrs["TYPE"]) == "popup") {
                    $select = new HAW_select($name, HAW_SELECT_POPUP);
                } elseif (strtolower($attrs["TYPE"]) == "spin") {
                    $select = new HAW_select($name, HAW_SELECT_SPIN);
                } else {
                    $select = new HAW_select($name);
                }
                $tag_stack->push($select, HAX_TAG_SELECT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_select object
                $select = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_select($select);
                // add HAW_select to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "OPTION":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_OPTION, $parser);
                if (!($label = $attrs["LABEL"])) {
                    error("<option> " . $err[7] . " label", $parser, $line);
                }
                // label attribute is missing
                if (!($value = $attrs["VALUE"])) {
                    error("<option> " . $err[7] . " value", $parser, $line);
                }
                // value attribute is missing
                if (isset($attrs["SELECTED"]) && strtolower($attrs["SELECTED"]) == "yes") {
                    $selected = HAW_SELECTED;
                } else {
                    $selected = HAW_NOTSELECTED;
                }
                $element = $tag_stack->pop();
                // pop base object (HAW_select)
                $base_element = $element["element"];
                $base_element->add_option($label, $value, $selected);
                // add option properties
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            } else {
                // HAX_PARSE_END
                // nothing to do any more
            }
            break;
        case "HIDDEN":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_HIDDEN, $parser);
                if (!($name = $attrs["NAME"])) {
                    error("<hidden> " . $err[7] . " name", $parser, $line);
                }
                // name attribute is missing
                if (!($value = $attrs["VALUE"])) {
                    error("<hidden> " . $err[7] . " value", $parser, $line);
                }
                // value attribute is missing
                $hidden = new HAW_hidden($name, $value);
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_hidden($hidden);
                // add HAW_hidden to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            } else {
                // HAX_PARSE_END
                // nothing to do any more
            }
            break;
        case "SUBMIT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_SUBMIT, $parser);
                if (!($label = $attrs["LABEL"])) {
                    error("<submit> " . $err[7] . " label", $parser, $line);
                }
                // label attribute is missing
                if (isset($attrs["NAME"])) {
                    $submit = new HAW_submit($label, $attrs["NAME"]);
                } else {
                    $submit = new HAW_submit($label);
                }
                $tag_stack->push($submit, HAX_TAG_SUBMIT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_submit object
                $submit = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_form)
                $base_element = $element["element"];
                $base_element->add_submit($submit);
                // add HAW_submit to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "A":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_LINK, $parser);
                if (!isset($attrs["HREF"])) {
                    error("<a> " . $err[7] . " href", $parser, $line);
                }
                // href attribute is missing
                if (isset($attrs["PROXY"]) && strtolower($attrs["PROXY"]) == "no") {
                    $url = $attrs["HREF"];
                } else {
                    $url = determine_url(qualify_url($attrs["HREF"]));
                }
                // let HAWHAW proxy retrieve href
                if (isset($attrs["TITLE"])) {
                    $link = new HAW_link("", $url, $attrs["TITLE"]);
                } else {
                    $link = new HAW_link("", $url);
                }
                if (isset($attrs["BR"]) && $attrs["BR"] >= 0) {
                    $link->set_br($attrs["BR"] + 0);
                }
                // convert string to int!
                if (isset($attrs["CSS_CLASS"])) {
                    $link->set_css_class($attrs["CSS_CLASS"]);
                }
                if (isset($attrs["VOICE_DTMF"])) {
                    $link->set_voice_dtmf($attrs["VOICE_DTMF"]);
                }
                if (isset($attrs["VOICE_INPUT"])) {
                    $link->set_voice_input($attrs["VOICE_INPUT"]);
                } else {
                    unset($link->voice_input);
                }
                // we must destinguish missing attr from empty string
                if (isset($attrs["VOICE_TIMEOUT"])) {
                    $link->set_voice_timeout($attrs["VOICE_TIMEOUT"] + 0);
                }
                // convert string to int!
                $tag_stack->push($link, HAX_TAG_LINK);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_link object
                $link = $element["element"];
                if (!$link->voice_text) {
                    $link->voice_text = $link->label;
                }
                // update voice_text if not already set
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_linkset, ...)
                $base_element = $element["element"];
                if ($element["tag"] == HAX_TAG_TD) {
                    // include HAW_link object in HAX_td pseudo class
                    $base_element->element = $link;
                    $base_element->tag = HAX_TAG_LINK;
                } else {
                    $base_element->add_link($link);
                }
                // add HAW_link to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "LINKSET":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_LINKSET, $parser);
                if ($number_of_linksets++ > 0) {
                    error($err[8], $parser, $line);
                }
                $linkset = new HAW_linkset();
                $tag_stack->push($linkset, HAX_TAG_LINKSET);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_linkset object
                $linkset = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck)
                $base_element = $element["element"];
                $base_element->add_linkset($linkset);
                // add HAW_linkset to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "TABLE":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_TABLE, $parser);
                $table = new HAW_table();
                $tag_stack->push($table, HAX_TAG_TABLE);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_table object
                $table = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_form, ...)
                $base_element = $element["element"];
                $base_element->add_table($table);
                // add HAW_table to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "TR":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_ROW, $parser);
                $row = new HAW_row();
                $tag_stack->push($row, HAX_TAG_ROW);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_row object
                $row = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_table)
                $base_element = $element["element"];
                $base_element->add_row($row);
                // add HAW_row to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "TD":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_TD, $parser);
                $td = new HAX_td();
                $tag_stack->push($td, HAX_TAG_TD);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAX_td object
                $td = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_row)
                $base_element = $element["element"];
                $base_element->add_column($td->element);
                // add included element of HAX_td to row
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "HR":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_RULE, $parser);
                if (isset($attrs["WIDTH"]) && isset($attrs["SIZE"])) {
                    $rule = new HAW_rule($attrs["WIDTH"], $attrs["SIZE"]);
                } elseif (isset($attrs["WIDTH"])) {
                    $rule = new HAW_rule($attrs["WIDTH"]);
                } elseif (isset($attrs["SIZE"])) {
                    $rule = new HAW_rule("100%", $attrs["SIZE"]);
                } else {
                    $rule = new HAW_rule();
                }
                $tag_stack->push($rule, HAX_TAG_RULE);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_rule object
                $rule = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck or HAW_form)
                $base_element = $element["element"];
                $base_element->add_rule($rule);
                // add HAW_rule to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "PHONE":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_PHONE, $parser);
                if (isset($attrs["TITLE"])) {
                    $phone = new HAW_phone("", $attrs["TITLE"]);
                } else {
                    $phone = new HAW_phone("");
                }
                if (isset($attrs["CSS_CLASS"])) {
                    $phone->set_css_class($attrs["CSS_CLASS"]);
                }
                if (isset($attrs["VOICE_INPUT"])) {
                    $phone->set_voice_input($attrs["VOICE_INPUT"]);
                }
                if (isset($attrs["VOICE_DTMF"])) {
                    $phone->set_voice_dtmf($attrs["VOICE_DTMF"]);
                }
                if (isset($attrs["VOICE_TIMEOUT"])) {
                    $phone->set_voice_timeout($attrs["VOICE_TIMEOUT"] + 0);
                }
                // convert string to int!
                if (isset($attrs["BR"]) && $attrs["BR"] >= 0) {
                    $phone->set_br($attrs["BR"] + 0);
                }
                // convert string to int!
                $tag_stack->push($phone, HAX_TAG_PHONE);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_phone object
                $phone = $element["element"];
                if (!$phone->voice_text) {
                    $phone->voice_text = $phone->label;
                }
                // update voice_text if not already set
                $element = $tag_stack->pop();
                // pop base object (HAW_deck)
                $base_element = $element["element"];
                $base_element->add_phone($phone);
                // add HAW_phone to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "VOICE_TEXT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_VOICE_TEXT, $parser);
                if (isset($attrs["AUDIO_SRC"])) {
                    $audio_src = $attrs["AUDIO_SRC"];
                } else {
                    $audio_src = "";
                }
                $event = new HAX_voice_event(HAX_TAG_VOICE_TEXT, "", $audio_src);
                $tag_stack->push($event, HAX_TAG_VOICE_TEXT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAX_voice_event object
                $event = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_input, ...)
                $base_element = $element["element"];
                // set voice text for base element
                $base_element->set_voice_text($event->text, $event->audio_src);
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "VOICE_HELP":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_VOICE_HELP, $parser);
                if (isset($attrs["AUDIO_SRC"])) {
                    $audio_src = $attrs["AUDIO_SRC"];
                } else {
                    $audio_src = "";
                }
                if (isset($attrs["URL"])) {
                    $url = $attrs["URL"];
                } else {
                    $url = "";
                }
                $event = new HAX_voice_event(HAX_TAG_VOICE_HELP, "", $audio_src, $url);
                $tag_stack->push($event, HAX_TAG_VOICE_HELP);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAX_voice_event object
                $event = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_input, ...)
                $base_element = $element["element"];
                // activate voice help for base element
                $base_element->set_voice_help($event->text, $event->audio_src, $event->url);
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "VOICE_NOMATCH":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_VOICE_NOMATCH, $parser);
                if (isset($attrs["AUDIO_SRC"])) {
                    $audio_src = $attrs["AUDIO_SRC"];
                } else {
                    $audio_src = "";
                }
                if (isset($attrs["URL"])) {
                    $url = $attrs["URL"];
                } else {
                    $url = "";
                }
                $event = new HAX_voice_event(HAX_TAG_VOICE_NOMATCH, "", $audio_src, $url);
                $tag_stack->push($event, HAX_TAG_VOICE_NOMATCH);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAX_voice_event object
                $event = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_input, ...)
                $base_element = $element["element"];
                // activate voice nomatch for base element
                $base_element->set_voice_nomatch($event->text, $event->audio_src, $event->url);
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "VOICE_NOINPUT":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_VOICE_NOINPUT, $parser);
                if (isset($attrs["AUDIO_SRC"])) {
                    $audio_src = $attrs["AUDIO_SRC"];
                } else {
                    $audio_src = "";
                }
                if (isset($attrs["URL"])) {
                    $url = $attrs["URL"];
                } else {
                    $url = "";
                }
                $event = new HAX_voice_event(HAX_TAG_VOICE_NOINPUT, "", $audio_src, $url);
                $tag_stack->push($event, HAX_TAG_VOICE_NOINPUT);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAX_voice_event object
                $event = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck, HAW_input, ...)
                $base_element = $element["element"];
                // activate voice noinput for base element
                $base_element->set_voice_noinput($event->text, $event->audio_src, $event->url);
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        case "RAW":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_RAW, $parser);
                if (!isset($attrs["MARKUP_LANGUAGE"])) {
                    error("<raw> " . $err[7] . " markup_language", $parser, $line);
                }
                // markup_language attribute is missing
                if (strtolower($attrs["MARKUP_LANGUAGE"]) == "html") {
                    if (HAX_RAW_HTML_ALLOWED == false) {
                        error($err[4], $parser, $line);
                    }
                    // raw html not allowed
                    $raw = new HAW_raw(HAW_HTML, "");
                } elseif (strtolower($attrs["MARKUP_LANGUAGE"]) == "wml") {
                    if (HAX_RAW_WML_ALLOWED == false) {
                        error($err[4], $parser, $line);
                    }
                    // raw wml not allowed
                    $raw = new HAW_raw(HAW_WML, "");
                } elseif (strtolower($attrs["MARKUP_LANGUAGE"]) == "hdml") {
                    if (HAX_RAW_HDML_ALLOWED == false) {
                        error($err[4], $parser, $line);
                    }
                    // raw hdml not allowed
                    $raw = new HAW_raw(HAW_HDML, "");
                } elseif (strtolower($attrs["MARKUP_LANGUAGE"]) == "voicexml") {
                    if (HAX_RAW_VXML_ALLOWED == false) {
                        error($err[4], $parser, $line);
                    }
                    // raw VoiceXML not allowed
                    $raw = new HAW_raw(HAW_VXML, "");
                } else {
                    error("<raw> " . $err[14] . " markup_language", $parser, $line);
                }
                // invalid markup_language attribute
                $tag_stack->push($raw, HAX_TAG_RAW);
                $raw_mode = true;
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_raw object
                $raw = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck or HAW_form)
                $base_element = $element["element"];
                $base_element->add_raw($raw);
                // add HAW_raw to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
                $raw_mode = false;
            }
            break;
        case "PLUGIN":
            if ($pos == HAX_PARSE_BEGIN) {
                check_state(HAX_TAG_RAW, $parser);
                if (!isset($attrs["NAME"])) {
                    error("<plugin> " . $err[7] . " name", $parser, $line);
                }
                // markup_language attribute is missing
                // determine filename of plugin php script
                // must be located in the same directory as hawxy.php
                $plugin_filename = dirname(__FILE__) . '/' . HAX_PLUGIN_PREFIX . $attrs["NAME"] . '.php';
                // security check 1: test if plugin file exists
                if (!file_exists($plugin_filename)) {
                    error($err[15] . $attrs["NAME"], $parser, $line);
                }
                // plugin not found
                // setup php instructions
                $php_cmd = "require_once(\"{$plugin_filename}\");" . '$udef = new ' . HAX_PLUGIN_PREFIX . $attrs["NAME"] . "();";
                while (list($key, $val) = each($attrs)) {
                    // security check 2: allow alphanumeric characters only!
                    $param = preg_replace('/[^\\w]/', "", $val);
                    if (strtolower($key) != "name") {
                        $php_cmd .= '$udef->set_' . strtolower($key) . '(\'' . $param . '\');';
                    }
                }
                // create user-defined object and call set methods
                if (eval($php_cmd) === false) {
                    // eval might exit silently in case of fatal errors within the plugin!
                    error($err[16] . " " . $attrs["NAME"], $parser, $line);
                }
                // error in plugin's php code
                $tag_stack->push($udef, HAX_TAG_PLUGIN);
            } else {
                // HAX_PARSE_END
                $element = $tag_stack->pop();
                // pop HAW_plugin object
                $udef = $element["element"];
                $element = $tag_stack->pop();
                // pop base object (HAW_deck or HAW_form)
                $base_element = $element["element"];
                $base_element->add_userdefined($udef);
                // add HAW_plugin to base object
                $tag_stack->push($base_element, $element["tag"]);
                // re-push base object
            }
            break;
        default:
            if ($raw_mode == true) {
                // only in raw mode unknown tags will be handled
                $element = $tag_stack->pop();
                if ($element["tag"] == HAX_TAG_RAW) {
                    if ($pos == HAX_PARSE_BEGIN) {
                        // copy opening (raw) tag with all its attributes
                        $element["element"]->code .= "<" . strtolower($name);
                        while (list($key, $value) = each($attrs)) {
                            $element["element"]->code .= " " . strtolower($key) . "=\"" . $value . "\"";
                        }
                        $element["element"]->code .= ">";
                    } else {
                        // HAX_PARSE_END
                        $element["element"]->code .= "</" . strtolower($name) . ">";
                    }
                }
                $tag_stack->push($element["element"], $element["tag"]);
            }
            break;
    }
}
コード例 #20
0
 /**
  * returns the best supported image type by this PHP build
  *
  * @param	string	$desired_type	desired image type ("jpg" | "gif" | "png")
  *
  * @return	string					supported image type ("jpg" | "gif" | "png" | "")
  * @static
  * 
  */
 public static function getGDSupportedImageType($a_desired_type)
 {
     $a_desired_type = strtolower($a_desired_type);
     // get supported Image Types
     $im_types = ImageTypes();
     switch ($a_desired_type) {
         case "jpg":
             if ($im_types & IMG_JPG) {
                 return "jpg";
             }
             if ($im_types & IMG_GIF) {
                 return "gif";
             }
             if ($im_types & IMG_PNG) {
                 return "png";
             }
             break;
         case "gif":
             if ($im_types & IMG_GIF) {
                 return "gif";
             }
             if ($im_types & IMG_JPG) {
                 return "jpg";
             }
             if ($im_types & IMG_PNG) {
                 return "png";
             }
             break;
         case "png":
             if ($im_types & IMG_PNG) {
                 return "png";
             }
             if ($im_types & IMG_JPG) {
                 return "jpg";
             }
             if ($im_types & IMG_GIF) {
                 return "gif";
             }
             break;
     }
     return "";
 }
コード例 #21
0
ファイル: updatelib.php プロジェクト: alencarmo/OCF
function updateItemTable()
{
    global $thumbnailSizes;
    executeQueryForUpdate("\n        ALTER TABLE @item \n        DROP title, DROP picture, DROP keepPrivate,\n        CHANGE `active` `status` INT NOT NULL DEFAULT 1, \n        CHANGE `expirationTime` `expirationTime` DATETIME NOT NULL, \n        CHANGE `creationtime` `creationtime` DATETIME NOT NULL;", __FILE__, __LINE__);
    executeQueryForUpdate("UPDATE @item SET `expirationTime`=0, expEmailSent=0", __FILE__, __LINE__);
    G::load($cats, "SELECT * FROM @category WHERE expiration!=0");
    foreach ($cats as $cat) {
        executeQueryForUpdate("UPDATE @item SET `expirationTime`= NOW() + INTERVAL {$cat->expiration} DAY WHERE cid={$cat->id};", __FILE__, __LINE__);
    }
    CustomField::addCustomColumns("item");
    G::load($items, "SELECT * FROM @item WHERE col_1!=''");
    $create_fg = array("", "ImageCreateFromGIF", "ImageCreateFromJPEG", "ImageCreateFromPNG");
    $save_fg = array("", "ImageGIF", "ImageJPEG", "ImagePNG");
    $extensions = array("", "gif", "jpg", "png");
    $checkBits = array(0, IMG_GIF, IMG_JPG, IMG_PNG);
    $memoryLimit = byteStr2num(ini_get('memory_limit'));
    foreach ($items as $item) {
        $ext = strstr($item->col_1, "jpg") ? "jpg" : (strstr($item->col_1, "gif") ? "gif" : (strstr($item->col_1, "png") ? "png" : ""));
        if (!$ext) {
            continue;
        }
        executeQueryForUpdate("UPDATE @item SET col_1='{$ext}' WHERE id={$item->id}", __FILE__, __LINE__);
        $fname = AD_PIC_DIR . "/{$item->id}.{$ext}";
        if (file_exists($fname)) {
            @unlink(AD_PIC_DIR . "/th_{$item->id}.{$ext}");
            // a regi thumbnailt toroljuk
            copy($fname, AD_PIC_DIR . "/{$item->id}_1.{$ext}");
            // uj nev a full image-nek
            // mas fg-eket kell hivni az image tipusnak megfeleloen:
            $size = getimagesize($fname);
            $width = $size[0];
            $height = $size[1];
            $type = $size[2];
            // az image tipus, 1=>GIF, 2=>JPG, 3=>PNG
            $ext = $extensions[$type];
            $supported = FALSE;
            if (defined("IMG_GIF") && function_exists("ImageTypes")) {
                $supported = isset($checkBits[$type]) && ImageTypes() & $checkBits[$type];
            }
            // ha az adott image tipus supportalva van:
            if ($supported) {
                foreach ($thumbnailSizes as $thSize => $dimensions) {
                    if (function_exists('memory_get_usage') && $memoryLimit && $memoryLimit != -1) {
                        $channels = isset($size['channels']) ? $size['channels'] : 1;
                        // png has no channels
                        $memoryNeeded = Round(($size[0] * $size[1] * $size['bits'] * $channels / 8 + Pow(2, 16)) * 1.65);
                        $usage = memory_get_usage();
                        //FP::log("Current usage: $usage, limit: $memoryLimit, new to allocate: $memoryNeeded, rest after allocate: ". ($memoryLimit-$usage-$memoryNeeded));
                        // skipping if ImageCreate would exceed the memory limit:
                        if ($usage + $memoryNeeded > $memoryLimit) {
                            continue;
                        }
                    }
                    shrinkPicture($newWidth, $newHeight, $dimensions["width"], $dimensions["height"], $fname);
                    $src_im = $create_fg[$type]($fname);
                    $dst_im = ImageCreateTrueColor($newWidth, $newHeight);
                    imagecopyresampled($dst_im, $src_im, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
                    $th_foname = AD_PIC_DIR . "/th_{$thSize}_{$item->id}_1.{$ext}";
                    // pictures/ads/th_medium_2345_5.jpg
                    $save_fg[$type]($dst_im, $th_foname);
                    imagedestroy($src_im);
                }
            }
            @unlink($fname);
            // a full image-et a regi neven toroljuk
        }
    }
    global $gorumuser, $gorumrecognised;
    $gorumrecognised = TRUE;
    $gorumuser->isAdm = 1;
    $c = new AppCategory();
    $c->recalculateAllItemNums(TRUE);
}
コード例 #22
0
 function imageOpenFromFile($file)
 {
     // get Image type
     if ($this->imgType === null) {
         $imgType = $this->getImageTypeByFile($file);
     } else {
         $imgType = $this->imgType;
     }
     // 1. Check Image Type
     if ($imgType === 'gif' || $imgType === 'jpg' || $imgType === 'png') {
         // supported image type
         // save type
         if ($this->imgType == null) {
             $this->imgType = $imgType;
         }
         // 2. Check if file exists
         if (is_file($file)) {
             // valid file
             // 3. Check server (PHP) support for image type
             $support = false;
             if ($this->imgType == 'gif' && ImageTypes() & IMG_GIF) {
                 $support = true;
             }
             if ($this->imgType == 'jpg' && ImageTypes() & IMG_JPG) {
                 $support = true;
             }
             if ($this->imgType == 'png' && ImageTypes() & IMG_PNG) {
                 $support = true;
             }
             if ($support === true) {
                 // PHP supports image type
                 // 4. Open image as source
                 $src = '';
                 if ($this->imgType === 'gif') {
                     $src = imagecreatefromgif($file);
                 }
                 if ($this->imgType === 'jpg') {
                     $src = imagecreatefromjpeg($file);
                 }
                 if ($this->imgType === 'png') {
                     $src = imagecreatefrompng($file);
                 }
                 // check for errors
                 if ($src != '') {
                     // no error
                     $this->imgSrc = $src;
                     return true;
                 } else {
                     // error, cannot open image
                     $this->error[] = 'InstantImage: cannot open image as source';
                     return false;
                 }
             } else {
                 // PHP don't support image type (maybe wrong GD lib)
                 $this->error[] = 'InstantImage: your server (PHP ' . phpversion() . ') does not support ' . $this->imgType;
                 return false;
             }
         } else {
             // does not exist or is not a file
             $this->error[] = 'InstantImage: file does not exist (' . $file . ')';
             return false;
         }
     } else {
         // wrong (unsupported) image type
         if ($imgType !== false) {
             $this->error[] = 'InstantImage: unsupported image type';
         }
         return false;
     }
 }
コード例 #23
0
 function gd_info()
 {
     static $gd_info = array();
     if (empty($gd_info)) {
         // based on code by johnschaefer at gmx dot de
         // from PHP help on gd_info()
         $gd_info = array('GD Version' => '', 'FreeType Support' => false, 'FreeType Linkage' => '', 'T1Lib Support' => false, 'GIF Read Support' => false, 'GIF Create Support' => false, 'JPG Support' => false, 'PNG Support' => false, 'WBMP Support' => false, 'XBM Support' => false);
         $phpinfo_array = phpthumb_functions::phpinfo_array();
         foreach ($phpinfo_array as $line) {
             $line = trim(strip_tags($line));
             foreach ($gd_info as $key => $value) {
                 //if (strpos($line, $key) !== false) {
                 if (strpos($line, $key) === 0) {
                     $newvalue = trim(str_replace($key, '', $line));
                     $gd_info[$key] = $newvalue;
                 }
             }
         }
         if (empty($gd_info['GD Version'])) {
             // probable cause: "phpinfo() disabled for security reasons"
             if (function_exists('ImageTypes')) {
                 $imagetypes = ImageTypes();
                 if ($imagetypes & IMG_PNG) {
                     $gd_info['PNG Support'] = true;
                 }
                 if ($imagetypes & IMG_GIF) {
                     $gd_info['GIF Create Support'] = true;
                 }
                 if ($imagetypes & IMG_JPG) {
                     $gd_info['JPG Support'] = true;
                 }
                 if ($imagetypes & IMG_WBMP) {
                     $gd_info['WBMP Support'] = true;
                 }
             }
             // to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF
             if (function_exists('ImageCreateFromGIF')) {
                 if ($tempfilename = phpthumb::phpThumb_tempnam()) {
                     if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
                         fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw=='));
                         // very simple 1px GIF file base64-encoded as string
                         fclose($fp_tempfile);
                         // if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not
                         $gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
                     }
                     unlink($tempfilename);
                 }
             }
             if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
                 $gd_info['GD Version'] = '2.0.1 or higher (assumed)';
             } elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
                 $gd_info['GD Version'] = '1.6.0 or higher (assumed)';
             }
         }
     }
     return $gd_info;
 }
コード例 #24
0
ファイル: image.php プロジェクト: dimadmb/100shub
function Image_Filter($file, $jpg_quality, $filter)
{
    // Bildgröße und Type ermitteln
    list($width, $height, $type) = @getimagesize($file);
    // Neues Bild erstellen
    $image_p = imagecreatetruecolor($width, $height);
    switch ($type) {
        case 1:
            if (ImageTypes() & IMG_GIF) {
                // Bilddatei laden
                $image = imagecreatefromgif($file);
                // Filter anwenden
                switch ($filter) {
                    case 1:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        break;
                    case 2:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_CONTRAST, -5);
                        break;
                    case 3:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0);
                        break;
                }
                // Transparenz erhalten
                $trnprt_indx = imagecolortransparent($image);
                if ($trnprt_indx >= 0) {
                    $trnprt_color = imagecolorsforindex($image, $trnprt_indx);
                    $trnprt_indx = imagecolorallocate($image_p, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
                    imagefill($image_p, 0, 0, $trnprt_indx);
                    imagecolortransparent($image_p, $trnprt_indx);
                }
                // Bild kopieren
                imagecopy($image_p, $image, 0, 0, 0, 0, $width, $height);
                // Bilddatei speichern
                @imagegif($image_p, $file);
            } else {
                //
            }
            break;
        case 2:
            if (ImageTypes() & IMG_JPG) {
                // Bilddatei laden
                $image = imagecreatefromjpeg($file);
                // Filter anwenden
                switch ($filter) {
                    case 1:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        break;
                    case 2:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_CONTRAST, -5);
                        break;
                    case 3:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0);
                        break;
                }
                // Bild kopieren
                imagecopy($image_p, $image, 0, 0, 0, 0, $width, $height);
                // Bilddatei speichern
                @imagejpeg($image_p, $file, $jpg_quality);
            } else {
                //
            }
            break;
        case 3:
            if (ImageTypes() & IMG_PNG) {
                // Bilddatei laden
                $image = imagecreatefrompng($file);
                // Filter anwenden
                switch ($filter) {
                    case 1:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        break;
                    case 2:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_CONTRAST, -5);
                        break;
                    case 3:
                        @imagefilter($image, IMG_FILTER_GRAYSCALE);
                        @imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0);
                        break;
                }
                // Transparenz erhalten
                imagealphablending($image_p, false);
                $colorTransparent = imagecolorallocatealpha($image_p, 0, 0, 0, 127);
                imagefill($image_p, 0, 0, $colorTransparent);
                imagesavealpha($image_p, true);
                // Bild kopieren
                imagecopy($image_p, $image, 0, 0, 0, 0, $width, $height);
                // Bilddatei speichern
                @imagepng($image_p, $file);
            } else {
                //
            }
            break;
        default:
            //
            break;
    }
    // Speicher freigeben
    if (isset($image)) {
        imagedestroy($image);
    }
    if (isset($image_p)) {
        imagedestroy($image_p);
    }
}
コード例 #25
0
 function resizePicture($fullname, $basename = false)
 {
     if (!function_exists("imagetypes")) {
         return false;
     }
     if (!$basename) {
         $basename = md5(time() . $fullname);
     }
     if (!file_exists($fullname) || !is_readable($fullname)) {
         return false;
     }
     $origtype = false;
     if (ImageTypes() & IMG_JPG) {
         $original = ImageCreateFromJpeg($fullname);
         $origtype = IMG_JPG;
     }
     if (!$original && ImageTypes() & IMG_GIF) {
         $original = ImageCreateFromGif($fullname);
         $origtype = IMG_GIF;
     }
     if (!$original && ImageTypes() & IMG_PNG) {
         $original = ImageCreateFromPng($fullname);
         $origtype = IMG_PNG;
     }
     if (!$original) {
         return false;
     }
     $ow = ImageSX($original);
     $oh = ImageSY($original);
     $w = $this->maximalPictureWidth;
     if ($ow < $w) {
         /* We recreate smaller pictures, too, to prevent clients from attacks */
         $w = $ow;
     }
     $h = $oh * $w / $ow;
     $copy = ImageCreateTrueColor($w, $h);
     ImageCopyResampled($copy, $original, 0, 0, 0, 0, $w, $h, $ow, $oh);
     @unlink($fullname);
     $name = false;
     if ($origtype == IMG_PNG) {
         $name = $basename . '.png';
         ImagePNG($copy, $name);
     } elseif ($origtype == IMG_GIF) {
         $name = $basename . '.gif';
         ImageGIF($copy, $name);
     } else {
         $name = $basename . '.jpg';
         ImageJPEG($copy, $name);
     }
     return $name;
 }
コード例 #26
0
 /** 
  * Determines whether a needed image type may is available 
  * from the GD library and gives an alternative otherwise.
  *
  * @access  public static
  * @param   wish   string one of 'png', 'gif', 'jpeg', 'jpg'
  * @return         string the image type to be used ('png', 'gif', 'jpeg')
  *                        'html' in case of an error
  */
 function decideImgType($wish)
 {
     if ($wish == 'html') {
         return $wish;
     }
     if ($wish == 'jpg') {
         $wish = 'jpeg';
     }
     $supportedtypes = array();
     // Todo: swf, pdf, ...
     $imagetypes = array('png' => IMG_PNG, 'gif' => IMG_GIF, 'jpeg' => IMG_JPEG, 'wbmp' => IMG_WBMP, 'xpm' => IMG_XPM);
     if (function_exists('ImageTypes')) {
         $presenttypes = ImageTypes();
         foreach ($imagetypes as $imgtype => $bitmask) {
             if ($presenttypes && $bitmask) {
                 array_push($supportedtypes, $imgtype);
             }
         }
     } else {
         foreach ($imagetypes as $imgtype => $bitmask) {
             if (function_exists("Image" . $imgtype)) {
                 array_push($supportedtypes, $imgtype);
             }
         }
     }
     if (in_array($wish, $supportedtypes)) {
         return $wish;
     } elseif (!empty($supportedtypes)) {
         return reset($supportedtypes);
     } else {
         return 'html';
     }
 }
コード例 #27
0
ファイル: GD.php プロジェクト: joeymetal/v1
 /**
  * Check settings
  *
  * @since PHP 5
  */
 function __construct()
 {
     if (!PEAR::loadExtension('gd')) {
         $this->isError(PEAR::raiseError("GD library is not available.", IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
     } else {
         $types = ImageTypes();
         if ($types & IMG_PNG) {
             $this->_supported_image_types['png'] = 'rw';
         }
         if ($types & IMG_GIF || function_exists('imagegif')) {
             $this->_supported_image_types['gif'] = 'rw';
         } elseif (function_exists('imagecreatefromgif')) {
             $this->_supported_image_types['gif'] = 'r';
         }
         if ($types & IMG_JPG) {
             $this->_supported_image_types['jpeg'] = 'rw';
         }
         if ($types & IMG_WBMP) {
             $this->_supported_image_types['wbmp'] = 'rw';
         }
         if (!$this->_supported_image_types) {
             $this->isError(PEAR::raiseError("No supported image types available", IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
         }
     }
 }
コード例 #28
0
ファイル: function.php プロジェクト: kyhfan/babience_video
function getPrintToImage($txt_X, $txt_Y, $serial, $num, $szFilePath, &$objFont, $serial, $nFontAlign = 0x12)
{
    # 이미지 파일이 존재하는지 체크한다.
    if (!file_exists($szFilePath))
    {
        return FALSE;
    }

    # 이미지 파일 정보를 구한다.(크기및 타입)
    $arrImgInfo = GetImageSize($szFilePath);

    # 해당 이미지 포멧이 지원되는지 체크한다. 
    switch ($arrImgInfo[2])
    {
    case 1:
        # GIF
        if (!(ImageTypes() & IMG_GIF))
        {
            return FALSE;
        }

        $szContentType = "image/gif";

        break;
    case 2:
        # JPG
        if (!(ImageTypes() & IMG_JPG))
        {
            return FALSE;
        }

        $szContentType = "image/jpeg";

        break;
    case 3:
        # PNG
        if (!(ImageTypes() & IMG_PNG))
        {
            return FALSE;
        }

        $szContentType = "image/png";

        break;
    default:
        return FALSE;
    }

    //header ("Content-type: ".$szContentType);
    # 이미지 파일을 읽어 이미지를 생성한다.
    $fp = fopen($szFilePath, "rb");
    $szContent = fread($fp, filesize($szFilePath));
    fclose($fp);

    $nImage = ImageCreateFromString($szContent);

	# 프린트할 글의 색상을 준비한다.
    $nBlue  = $objFont->color & 0xFF;
    $nGreen = $objFont->color >> 0x08 & 0xFF;
    $nRed   = $objFont->color >> 0x10 & 0xFF;

    $nFontColor  = ImageColorAllocate($nImage, $nRed, $nGreen, $nBlue);

    # 프린트할 글의 위치를 결정한다.
    $arrTTFBBox  = ImageTTFBBox($objFont->size, $objFont->angle, $objFont->font, $objFont->text);

    $nMax = max($arrTTFBBox[0], $arrTTFBBox[2], $arrTTFBBox[4], $arrTTFBBox[6]);
    $nMin = min($arrTTFBBox[0], $arrTTFBBox[2], $arrTTFBBox[4], $arrTTFBBox[6]);

    if ($nFontAlign & LEFT)
    {
        $nX = $arrTTFBBox[0] - $nMin;
    }
    else if ($nFontAlign & CENTER)
    {
        $nX = ($arrImgInfo[0] - ($nMax + $nMin)) / 2 + $arrTTFBBox[0];
    }
    else
    {
        $nX = $arrImgInfo[0] - $nMax + $arrTTFBBox[0];
    }

    $nMax = max($arrTTFBBox[1], $arrTTFBBox[3], $arrTTFBBox[5], $arrTTFBBox[7]);
    $nMin = min($arrTTFBBox[1], $arrTTFBBox[3], $arrTTFBBox[5], $arrTTFBBox[7]);

    if ($nFontAlign & TOP)
    {
        $nY = $arrTTFBBox[1] - $nMin;
    }
    else if ($nFontAlign & MIDDLE)
    {
        $nY = ($arrImgInfo[1] - ($nMax + $nMin)) / 2 + $arrTTFBBox[1];
    }
    else
    {
        $nY = $arrImgInfo[1] - $nMax + $arrTTFBBox[1];
    }
	$nX = $txt_X;
	$nY = $txt_Y;
    ImageTTFText($nImage, $objFont->size, $objFont->angle, $nX, $nY, $nFontColor, $objFont->font, $objFont->text);

	$mydir = "certi_images/".date("d"); 
	 if(@mkdir($mydir, 0777)) { 
		if(is_dir($mydir)) { 
			@chmod($mydir, 0777); 
		} 
	 }

    switch ($arrImgInfo[2])
    {
		case 1:
			# GIF
			ImageGIF($nImage,'simpletext.gif');
			break;
		case 2:
			# JPG
			ImageJPEG($nImage,'./files/'.$serial.'/medium/final_'.$serial.'_'.$num.'.jpg',100);
			break;
		case 3:
			# PNG
			ImagePNG($nImage,'baby_merge1.jpg');
			break;
		default:
			return FALSE;
    }
	imagedestroy($nImage);
	//echo "complete";
    return TRUE;
}
コード例 #29
0
 /**
  * Create an image from the given image handler, cache it and return a url and the file path of the image.
  *
  * Always try to retrive the image from the cache before you compute it.
  *
  * @param    string  Image-ID. Used as a part of the cache filename.
  *                   Use md5() to generate a "unique" ID for your image
  *                   based on characteristic values such as the color, size etc.
  * @param    string  Image handler to create the image from.
  * @param    string  Image type: gif, jpg, png, wbmp. Also used as filename suffix.
  *                   If an unsupported type is requested the functions tries to 
  *                   fallback to a supported type before throwing an exeption.
  * @return   array  [ full path to the image file, image url ]
  * @throws   Cache_Error
  * @access   public
  */
 function cacheImageLink($id, &$img, $format = 'png')
 {
     if (!$id) {
         return new Cache_Error('You must provide an ID for and image to be cached!', __FILE__, __LINE__);
     }
     $id = $this->generateID($id, $format);
     $types = ImageTypes();
     // Check if the requested image type is supported by the GD lib.
     // If not, try a callback to the first available image type.
     if (!isset($this->imagetypes[$format]) || !($types & $this->imagetypes[$format])) {
         foreach ($this->imagetypes as $supported => $bitmask) {
             if ($types & $bitmask) {
                 new Cache_Error("The build in GD lib does not support the image type {$format}. Fallback to {$supported}.", __FILE__, __LINE__);
             } else {
                 return new Cache_Error("Hmm, is your PHP build with GD support? Can't find any supported types.", __FILE__, __LINE__);
             }
         }
     }
     $url = $this->cache_url . $this->cache_file_prefix . $id;
     $ffile = $this->container->getFilename($id, $this->cache_group);
     if ($this->isCached($id, $this->cache_group) && !isExpired($id, $this->cache_group)) {
         return array($ffile, $url);
     }
     if (strtoupper($format) == 'JPG') {
         $genFormat = 'JPEG';
     } else {
         $genFormat = strtoupper($format);
     }
     $func = 'Image' . $genFormat;
     $func($img, $ffile);
     ImageDestroy($img);
     return array($ffile, $url);
 }
コード例 #30
0
 function imageResizeSupported($info)
 {
     if (defined("IMG_GIF") && function_exists("ImageTypes")) {
         $checkBits = array(0, IMG_GIF, IMG_JPG, IMG_PNG);
         return isset($checkBits[$info[2]]) && ImageTypes() & $checkBits[$info[2]];
     }
     return FALSE;
 }