|
From: Florin C B. <ory...@us...> - 2010-07-23 11:15:28
|
Update of /cvsroot/mxbb/mx_smartor/album_mod/includes In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv17054/includes Modified Files: album_constants.php album_image_class.php Log Message: Index: album_constants.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/includes/album_constants.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** album_constants.php 8 Jan 2009 20:43:41 -0000 1.12 --- album_constants.php 23 Jul 2010 11:15:17 -0000 1.13 *************** *** 189,192 **** define('ALBUM_WM_CACHE_PATH', $module_root_path . 'upload/wm_cache/'); define('ALBUM_WM_FILE', $module_root_path . 'album_mod/mark_fap.png'); ! } ?> \ No newline at end of file --- 189,195 ---- define('ALBUM_WM_CACHE_PATH', $module_root_path . 'upload/wm_cache/'); define('ALBUM_WM_FILE', $module_root_path . 'album_mod/mark_fap.png'); ! } ! ! define('POSTED_IMAGES_PATH', $module_root_path . 'upload/'); ! define('POSTED_IMAGES_THUMBS_PATH', $module_root_path . 'upload/cache/'); ?> \ No newline at end of file Index: album_image_class.php =================================================================== RCS file: /cvsroot/mxbb/mx_smartor/album_mod/includes/album_image_class.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** album_image_class.php 13 Mar 2008 03:43:58 -0000 1.2 --- album_image_class.php 23 Jul 2010 11:15:17 -0000 1.3 *************** *** 1889,1892 **** --- 1889,2052 ---- } + /* + Function get_full_image_info + */ + + define ('IMAGE_WIDTH', 'width'); + define ('IMAGE_HEIGHT', 'height'); + define ('IMAGE_TYPE', 'type'); + define ('IMAGE_ATTR', 'attr'); + define ('IMAGE_BITS', 'bits'); + define ('IMAGE_CHANNELS', 'channels'); + define ('IMAGE_MIME', 'mime'); + + /** + * mixed get_full_image_info( file $file [, string $out] ) + * + * Returns information about $file. + * + * If the second argument is supplied, a string representing that information will be returned. + * + * Valid values for the second argument are IMAGE_WIDTH, 'width', IMAGE_HEIGHT, 'height', IMAGE_TYPE, 'type', + * IMAGE_ATTR, 'attr', IMAGE_BITS, 'bits', IMAGE_CHANNELS, 'channels', IMAGE_MIME, and 'mime'. + * + * If only the first argument is supplied an array containing all the information is returned, + * which will look like the following: + * + * [width] => int (width), + * [height] => int (height), + * [type] => string (type), + * [attr] => string (attributes formatted for IMG tags), + * [bits] => int (bits), + * [channels] => int (channels), + * [mime] => string (mime-type) + * + * Returns false if $file is not a file, no arguments are supplied, $file is not an image, or otherwise fails. + * + **/ + function get_full_image_info($file = null, $out = null, $local = false) + { + // If $file is not supplied or is not a file, warn the user and return false. + if ($local == true) + { + if(is_null($file) || !is_file($file)) + { + //echo '<p><b>Warning:</b> image_info() => first argument must be a file.</p>'; + //echo '<br /><br />' . $file . '<br /><br />'; + return false; + } + } + else + { + if(is_null($file) || !any_url_exists($file)) + { + //echo '<p><b>Warning:</b> image_info() => first argument must be a file.</p>'; + //echo '<br /><br />' . $file . '<br /><br />'; + return false; + } + } + + // Defines the keys we want instead of 0, 1, 2, 3, 'bits', 'channels', and 'mime'. + $redefine_keys = array( + 'width', + 'height', + 'type', + 'attr', + 'bits', + 'channels', + 'mime', + ); + + // If $out is supplied, but is not a valid key, nullify it. + if (!is_null($out) && !in_array($out, $redefine_keys)) + { + $out = null; + } + + // Assign useful values for the third index. + $types = array( + 1 => 'GIF', + 2 => 'JPG', + 3 => 'PNG', + 4 => 'SWF', + 5 => 'PSD', + 6 => 'BMP', + 7 => 'TIFF(intel byte order)', + 8 => 'TIFF(motorola byte order)', + 9 => 'JPC', + 10 => 'JP2', + 11 => 'JPX', + 12 => 'JB2', + 13 => 'SWC', + 14 => 'IFF', + 15 => 'WBMP', + 16 => 'XBM' + ); + $temp = array(); + $data = array(); + + // Get the image info using getimagesize(). + // If $temp fails to populate, warn the user and return false. + if (!$temp = @getimagesize($file)) + { + //echo '<p><b>Warning:</b> image_info() => first argument must be an image.</p>'; + return false; + } + + // Get the values returned by getimagesize() + $temp = array_values($temp); + + // Make an array using values from $redefine_keys as keys and values from $temp as values. + foreach ($temp as $k => $v) + { + $data[$redefine_keys[$k]] = $v; + } + + // Make 'type' useful. + $data['type'] = $types[$data['type']]; + + // Return the desired information. + return !is_null($out) ? $data[$out] : $data; + } + + /* + Function any_url_exists to check whether a file exists on any domain. + */ + function any_url_exists($url) + { + $a_url = parse_url($url); + if (!isset($a_url['port'])) + { + $a_url['port'] = 80; + } + $errno = 0; + $errstr = ''; + $timeout = 30; + if(isset($a_url['host'])) + { + if(trim($a_url['host']) == gethostbyname(trim($a_url['host']))) + { + return true; + } + else + { + $fid = fsockopen($a_url['host'], $a_url['port'], $errno, $errstr, $timeout); + if (!$fid) + { + return false; + } + $page = isset($a_url['path']) ? $a_url['path'] : ''; + $page .= isset($a_url['query']) ? '?' . $a_url['query'] : ''; + fwrite($fid, 'HEAD ' . $page . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n"); + $head = fread($fid, 4096); + fclose($fid); + return preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head); + } + } + else + { + return false; + } + } /* |