Beispiel #1
0
						My Account<i></i>
					</a></span>
				<div class="userWidget">
					<div class="details">
						<div class="userPic">
							<img alt="<?php 
echo $coder->handle;
?>
" src="<?php 
echo $photoLink;
?>
">
						</div>
						<div class="userDetails">
							<?php 
echo get_handle($coder->handle);
?>
							<p class="country"><?php 
echo $coder->country;
?>
</p>
							<p class="lbl">Member Since:</p>
							<p class="val"><?php 
echo $memberSince[2];
?>
</p>
							<p class="lbl">Total Earnings :</p>
							<p class="val"><?php 
echo $memberEarning;
?>
</p>
function image_preview($path_to_primary_image, $maximum_width)
{
    //Globalize appropriate variables.
    global $CONFIG, $lang_image_processor_php, $preview_image_directory;
    //Determine thumbnail method.
    $method = $CONFIG['thumb_method'];
    if ($method == 'gd2' and !function_exists('imageistruecolor')) {
        //Set ignore imageistruecolor to false.
        $ignore = 0;
    } else {
        //Set $ignore image is true color to true.
        $ignore = 1;
    }
    // Get image info.
    $source_image_size_and_type = getimagesize($path_to_primary_image) or die($lang_image_processor_php['file_corrupt']);
    $source_image_width = $source_image_size_and_type[0];
    $source_image_height = $source_image_size_and_type[1];
    $source_image_type = $source_image_size_and_type[2];
    //We need specify the path for the transitory file.
    // Create a prefix for easier human recognition.
    $prefix = "pre_";
    //Set the correct file extension.
    if ($source_image_type == '1') {
        $suffix = '.gif';
    } elseif ($source_image_type == '2') {
        $suffix = '.jpg';
    } elseif ($source_image_type == '3') {
        $suffix = '.png';
    }
    // Generate the unique name.
    do {
        $seed = substr(md5(microtime() . getmypid()), 0, 8);
        $path_to_preview_image = $preview_image_directory . $prefix . $seed . $suffix;
    } while (file_exists($path_to_preview_image));
    //Now we can upload the file.
    // Calculate dimensions.
    if ($source_image_width > $maximum_width) {
        $new_width = (int) $maximum_width;
        $new_height = (int) ($source_image_height * ($maximum_width / $source_image_width));
    } else {
        $new_width = $source_image_width;
        $new_height = $source_image_height;
    }
    //Begin processing if GD is used.
    if ($method == "gd2" or $method == "gd1") {
        // Get image handle
        $image_handle = get_handle($path_to_primary_image);
        // Create the destination image handle.
        if ($method == "gd2") {
            if ($ignore) {
                if (ImageIsTrueColor($image_handle)) {
                    $destination_image_handle = ImageCreateTrueColor($new_width, $new_height);
                } else {
                    $destination_image_handle = ImageCreate($new_width, $new_height);
                }
            } else {
                $destination_image_handle = ImageCreate($new_width, $new_height);
            }
        } elseif ($method == "gd1") {
            $destination_image_handle = ImageCreate($new_width, $new_height);
        }
        // Resize the image
        if ($method == "gd2") {
            //Use the higher quality function imagecopyresampled.
            imagecopyresampled($destination_image_handle, $image_handle, 0, 0, 0, 0, $new_width, $new_height, $source_image_width, $source_image_height);
        } elseif ($method == "gd1") {
            //Use the lower quality imagecopyresized.
            imagecopyresized($destination_image_handle, $image_handle, 0, 0, 0, 0, $new_width, $new_height, $source_image_width, $source_image_height);
        }
        //Destroy $image_handle
        imagedestroy($image_handle);
        // Write the image to disk.
        if ($source_image_type == "2") {
            imagejpeg($destination_image_handle, $path_to_preview_image) or die($lang_image_processor_php['no_write']);
        } elseif ($source_image_type == "3") {
            imagepng($destination_image_handle, $path_to_preview_image) or die($lang_image_processor_php['no_write']);
        }
        // Destroy $destination_image_handle.
        imagedestroy($destination_image_handle);
    } elseif ($method == "im") {
        // Set IM path.
        $im_path = $CONFIG['impath'];
        //Check the IM path for the final slash.
        if (eregi('/$', $im_path) or empty($im_path)) {
            $trailing_slash = "";
        } else {
            $trailing_slash = "/";
        }
        //Determine real paths to files.
        $real_path_to_primary_image = realpath($path_to_primary_image);
        $real_path_to_preview_image = realpath($path_to_preview_image);
        // Prevent the user from creating a process zombie by aborting while IM does its work.
        ignore_user_abort(true);
        // Issue the command for resizing to IM.  Have ImageMagick write the image to disk.
        $output = array();
        $cmd = "{$CONFIG['impath']}" . $trailing_slash . "convert -geometry {$new_width}x{$new_height} \"{$real_path_to_primary_image}\" \"{$real_path_to_preview_image}\"";
        exec($cmd, $output, $retval);
        // Restore the user abort setting.
        ignore_user_abort(false);
        if ($retval) {
            $ERROR = $lang_image_processor_php['IM_Error'] . $retval;
            if ($CONFIG['debug_mode']) {
                // Re-execute the command with the backtit operator in order to get all outputs
                // will not work is safe mode is enabled
                $output = `{$cmd} 2>&1`;
                $ERROR .= "<br /><br /><div align=\"left\">{$lang_image_processor_php['cmd_line']}<br /><font size=\"2\">" . nl2br(htmlspecialchars($cmd)) . "</font></div>";
                $ERROR .= "<br /><br /><div align=\"left\">{$lang_image_processor_php['mog_said']}<br /><font size=\"2\">";
                $ERROR .= nl2br(htmlspecialchars($output));
                $ERROR .= "</font></div>";
            }
            die($ERROR);
        }
    }
    return $path_to_preview_image;
}