Exemplo n.º 1
0
/**
 * Show an inforamtion message
 *
 * @param string $text Text that will show as inforamtion message
 * @param string $title [optional] Title of the message page
 * @param bool $exit [optional] Stop script after showing the message
 * @param bool|string $redirect [optional] Redirect to given link after message
 * @param int $rs [optional] if $redirect set, then message will be stay those seconds
 * @param string $extra_code_header [optional] extra codes to be included between head tag
 * @return void
 */
function kleeja_info($text, $title = '', $exit = true, $redirect = false, $rs = 5, $extra_code_header = '')
{
    global $SQL, $plugin;
    ($hook = $plugin->run_hook('kleeja_info_func')) ? eval($hook) : null;
    //run hook
    return kleeja_error($text, $title, $exit, $redirect, $rs, $extra_code_header, 'info.php');
}
Exemplo n.º 2
0
Arquivo: ucp.php Projeto: omtim/kleeja
                    kleeja_info($text);
                }
            }
        }
        ($hook = $plugin->run_hook('end_get_pass')) ? eval($hook) : null;
        //run hook
        break;
        //
        // add your own code here
        //
    //
    // add your own code here
    //
    default:
        ($hook = $plugin->run_hook('default_usrcp_page')) ? eval($hook) : null;
        //run hook
        kleeja_error($lang['ERROR_NAVIGATATION']);
        break;
}
#end switch
($hook = $plugin->run_hook('end_usrcp_page')) ? eval($hook) : null;
//run hook
#no template, no title, set them to default
$current_title = empty($current_title) ? $lang['USERS_SYSTEM'] : $current_title;
$current_template = empty($current_template) ? 'info.php' : $current_template;
#header
kleeja_header($current_title, $extra_code_in_header);
#page template
include get_template_path($current_template);
#footer
kleeja_footer();
Exemplo n.º 3
0
/**
 * Creates a resized image
 *
 * @param string $source_path The file path
 * @param string $ext The file extension
 * @param string $dest_image The modified file path to save in
 * @param int $dw The wanted width
 * @param int $dh The wanted height
 * @return void
 * @example create_thumb('pics/apple.jpg','thumbs/tn_apple.jpg',100,100);
 */
function create_thumb($source_path, $ext, $dest_image, $dw, $dh)
{
    #no file, quit it
    if (!file_exists($source_path)) {
        return;
    }
    #if no GD lib detected, abort!
    if (!function_exists('imagecreatefromjpeg')) {
        kleeja_error('NO GD LIBRARY DETECTED!');
    }
    #check width, height
    if (intval($dw) == 0 || intval($dw) < 10) {
        $dw = 100;
    }
    if (intval($dh) == 0 || intval($dh) < 10) {
        $dh = $dw;
    }
    #if there is imagick lib, then we should use it
    if (function_exists('phpversion') && phpversion('imagick')) {
        create_thumb_imagick($source_path, $ext, $dest_image, $dw, $dh);
        return;
    }
    #get file info
    list($source_width, $source_height, $source_type) = array(false, false, false);
    if (function_exists('getimagesize')) {
        list($source_width, $source_height, $source_type) = @getimagesize($source_path);
    }
    switch (strtolower(preg_replace('/^.*\\./', '', $source_path))) {
        case 'gif':
            $source_gdim = imagecreatefromgif($source_path);
            break;
        case 'jpg':
        case 'jpeg':
            $source_gdim = imagecreatefromjpeg($source_path);
            break;
        case 'png':
            $source_gdim = imagecreatefrompng($source_path);
            break;
    }
    $source_width = !$source_width ? ImageSX($source_gdim) : $source_width;
    $source_height = !$source_height ? ImageSY($source_gdim) : $source_height;
    $source_aspect_ratio = $source_width / $source_height;
    $desired_aspect_ratio = $dw / $dh;
    if ($source_aspect_ratio > $desired_aspect_ratio) {
        #Triggered when source image is wider
        $temp_height = $dh;
        $temp_width = (int) ($dh * $source_aspect_ratio);
    } else {
        #Triggered otherwise (i.e. source image is similar or taller)
        $temp_width = $dw;
        $temp_height = (int) ($dw / $source_aspect_ratio);
    }
    #Resize the image into a temporary GD image
    $temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
    imagecopyresampled($temp_gdim, $source_gdim, 0, 0, 0, 0, $temp_width, $temp_height, $source_width, $source_height);
    #Copy cropped region from temporary image into the desired GD image
    $x0 = ($temp_width - $dw) / 2;
    $y0 = ($temp_height - $dh) / 2;
    $desired_gdim = imagecreatetruecolor($dw, $dh);
    imagecopy($desired_gdim, $temp_gdim, 0, 0, $x0, $y0, $dw, $dh);
    #Create thumbnail
    switch (strtolower(preg_replace('/^.*\\./', '', $dest_image))) {
        case 'jpg':
        case 'jpeg':
            $return = @imagejpeg($desired_gdim, $dest_image, 90);
            break;
        case 'png':
            $return = @imagepng($desired_gdim, $dest_image);
            break;
        case 'gif':
            $return = @imagegif($desired_gdim, $dest_image);
            break;
        default:
            # Unsupported format
            $return = false;
            break;
    }
    @imagedestroy($desired_gdim);
    @imagedestroy($src_img);
    return $return;
}