| version 1.35, 2006/09/15 08:28:39 |
version 1.36, 2006/09/16 22:53:25 |
|
|
| * http://platon.sk/projects/Metafox/ |
* http://platon.sk/projects/Metafox/ |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/functions.inc.php,v 1.34 2006-09-14 10:03:38 nepto Exp $ */ |
/* $Platon: Metafox/functions.inc.php,v 1.35 2006-09-15 08:28:39 nepto Exp $ */ |
| |
|
| function ezin_eval($evalcode) /* {{{ */ |
function ezin_eval($evalcode) /* {{{ */ |
| { |
{ |
| Line 140 function ezin_handle_special_tags(&$str, |
|
| Line 140 function ezin_handle_special_tags(&$str, |
|
| .'<param name="movie" value="'.$repository_url.'\\1"><embed src="'.$repository_url.'\\1"\\2></object>'; |
.'<param name="movie" value="'.$repository_url.'\\1"><embed src="'.$repository_url.'\\1"\\2></object>'; |
| } /* }}} */ |
} /* }}} */ |
| if (strpos($mask, 'i') !== false) { /* {{{ */ |
if (strpos($mask, 'i') !== false) { /* {{{ */ |
| |
preg_match_all('|<image\s+([^>\s]+)([^>]*width=([^>\s]+)[^>]*)>|i', $str, $matches, PREG_SET_ORDER); |
| |
foreach ($matches as $key => $val) { |
| |
$old_file = $val[1]; |
| |
$width = $val[3]; |
| |
$new_file = ezin_scale_upload_image($old_file, $width); |
| |
if ($new_file != false && $new_file != $val[1]) { |
| |
$pattern[] = '|<image\s+'.$old_file.'([^>]*)width='.$width.'([^>]*)>|i'; |
| |
$replacement[] = "<image $new_file\\1\\2>"; |
| |
} |
| |
//echo "FILE: $val[1], WIDTH: $val[3], RET: $ret<br>"; |
| |
} |
| |
|
| $pattern[] = '|<image\s+(\w{3,6}://[^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
$pattern[] = '|<image\s+(\w{3,6}://[^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
| $pattern[] = '|<image/\s+([^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
$pattern[] = '|<image\s+/([^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
| $pattern[] = '|<image\s+([^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
$pattern[] = '|<image\s+([^>\s]+)([^>]*)>((?:(?!<image).){0,499}?)</image>|si'; |
| $pattern[] = '|<image\s+(\w{3,6}://[^>\s]+)([^>]*)>|i'; |
$pattern[] = '|<image\s+(\w{3,6}://[^>\s]+)([^>]*)>|i'; |
| $pattern[] = '|<image/\s+([^>\s]+)([^>]*)>|i'; |
$pattern[] = '|<image\s+/([^>\s]+)([^>]*)>|i'; |
| $pattern[] = '|<image\s+([^>\s]+)([^>]*)>|i'; |
$pattern[] = '|<image\s+([^>\s]+)([^>]*)>|i'; |
| $replacement[] = '<img alt="\\3" title="\\3" border="0" src="\\1"\\2>'; |
$replacement[] = '<img alt="\\3" title="\\3" border="0" src="\\1"\\2>'; |
| $replacement[] = '<img alt="\\3" title="\\3" border="0" src="'.$ezin_url.'\\1"\\2>'; |
$replacement[] = '<img alt="\\3" title="\\3" border="0" src="'.$ezin_url.'\\1"\\2>'; |
| Line 611 function ezin_get_upload_image_html($dir |
|
| Line 623 function ezin_get_upload_image_html($dir |
|
| return $default_str; |
return $default_str; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
function ezin_scale_upload_image($input_image, $width) /* {{{ */ |
| |
{ |
| |
global $ezin_cfg; |
| |
$width = preg_replace('/["\']/', '', trim($width)); |
| |
$width_int = intval($width); |
| |
$width_pct = $width[strlen($width) - 1] == '%'; |
| |
$cache_dir = '_cache'; |
| |
$uni_prefix = $ezin_cfg['upload']['dir'].'/'; |
| |
if ($width_int <= 0) { |
| |
return $input_image; |
| |
} |
| |
if (! file_exists($uni_prefix.$input_image)) { |
| |
return $input_image; |
| |
} |
| |
if (! is_dir($uni_prefix.$cache_dir)) { |
| |
if (mkdir($uni_prefix.$cache_dir) == false) { |
| |
return $input_image; |
| |
} |
| |
} |
| |
$output_image .= "$cache_dir/$width_int"; |
| |
$output_image .= ($width_pct ? 'pct' : 'abs').'--'; |
| |
$output_image .= str_replace('/','--', $input_image); |
| |
if (file_exists($uni_prefix.$output_image)) { |
| |
return $output_image; |
| |
} |
| |
include_once 'Image/Transform.php'; |
| |
$img = Image_Transform::factory('GD'); |
| |
$img->load($uni_prefix.$input_image); |
| |
if ($width_pct) { |
| |
$img->scalebyPercentage($width_int); |
| |
} else { |
| |
$img->scaleByX($width_int); |
| |
} |
| |
$img->save($uni_prefix.$output_image); |
| |
return $output_image; |
| |
} /* }}} */ |
| |
|
| /* |
/* |
| * Message process function |
* Message process function |
| */ |
*/ |