[Linpha-cvs] SF.net SVN: linpha: [4498] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-09 19:46:36
|
Revision: 4498 Author: fangehrn Date: 2006-04-09 12:46:00 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4498&view=rev Log Message: ----------- * adding config entries (reset_database.php needed) * partially finished image class - get_image.php - imagemagick and gdlib - image cache Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/settings_layout.php trunk/linpha2/get_image.php trunk/linpha2/get_thumb.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/install/sql/sql.mysql.php trunk/linpha2/install/sql/sql.postgres.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/install/sql/sql.tables.php trunk/linpha2/lib/classes/image/gdlib/thumbnail.php trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.identify.class.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/thumbnails.js trunk/linpha2/lib/include/common.php trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/css/view_thumb.css trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/home.html.php trunk/linpha2/templates/default/view_thumb.html.php Added Paths: ----------- trunk/linpha2/lib/classes/image/gdlib/image.php trunk/linpha2/lib/classes/image/gdlib/thumbnail_folder.php trunk/linpha2/lib/classes/image/imagemagick/image.php trunk/linpha2/lib/classes/image/imagemagick/thumbnail_folder.php Removed Paths: ------------- trunk/linpha2/lib/include/image.gdlib.thumbnail.php trunk/linpha2/lib/include/image.imagemagick.thumbnail.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/ChangeLog 2006-04-09 19:46:00 UTC (rev 4498) @@ -1,3 +1,13 @@ +2006-04-09 flo + * testing another way of setting the height of main div in javascript thumbnail viewer + - #main { height: 85%; } and do not set the height in thumbnails.js + this way we always have scrollbars, but we see more (after scrolling..) + * adding config entries (reset_database.php needed) + * partially finished image class + - get_image.php + - imagemagick and gdlib + - image cache + 2006-04-09 bzrudi <linpha2_AT_tuxpower_DOT_de> * Installer -> added database port support Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/admin/settings_layout.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -7,7 +7,8 @@ } $array_menu = Array( - 'home' => Array('name' => 'Home Site', 'link' => 'settings_layout_home'), + 'homesite' => Array('name' => 'Home Site', 'link' => 'settings_layout_home'), + 'thumb' => Array('name' => 'Thumb View', 'link' => 'settings_layout_thumb'), 'others' => Array('name' => 'Others', 'link' => 'settings_layout_others') ); @@ -73,6 +74,12 @@ printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',getSortOrders()); break; +case 'thumb': + printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate'); + break; +case 'image': + printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs'); + break; case 'others': Modified: trunk/linpha2/get_image.php =================================================================== --- trunk/linpha2/get_image.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/get_image.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -19,16 +19,12 @@ */ /** - * Image view + * Thumb view related methods and functions * @package Image */ if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } -include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); -$linpha = new linpha(); -$linpha->sql->startSession(); - /** * check for valid id */ @@ -36,38 +32,35 @@ { if(!isset( $_GET['id'] ) ) { - throw new Exception("no id supplied!"); + throw new Exception("no id supplied!"); } - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $_GET['id'] )."'"); - - if($query->RecordCount() != 1) - { - throw new Exception("wrong id supplied!"); - } - - $data = $query->FetchRow(); - if( ! LinSql::photoIsAllowed( $data['id'] ) ) + /** + * create overrideSettings + */ + $overrideSettings = Array(); + if(isset($_GET['width']) && isset($_GET['height'])) { - throw new Exception("not permitted!"); + $overrideSettings['max_width'] = $_GET['width']; + $overrideSettings['max_height'] = $_GET['height']; } - if( isset($_GET['force'] ) ) { - $force = true; - } else { - $force = false; - } + include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + $linpha = new linpha(); + $linpha->sql->startSession(); - $output_file = LinImage::createImage($data['id'],$data['img_type'],$force); - if(file_exists($output_file)) + $image = new LinImage(); + if( ! $image->createImage($_GET['id'],$overrideSettings) ) { - Header("Content-type: image/jpeg"); - readfile( $output_file ); + throw new Exception("Error while creating image!<br />Error: ".$image->error_msg); } + + $image->printFileToScreen(); } catch(Exception $error) { echo "Error: ".$error -> getMessage(); } + ?> \ No newline at end of file Modified: trunk/linpha2/get_thumb.php =================================================================== --- trunk/linpha2/get_thumb.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/get_thumb.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -25,10 +25,6 @@ if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','.'); } -include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); -$linpha = new linpha(); -$linpha->sql->startSession(); - /** * check for valid id */ @@ -36,34 +32,19 @@ { if(!isset( $_GET['id'] ) ) { - throw new Exception("no id supplied!"); + throw new Exception("no id supplied!"); } - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $_GET['id'] )."'"); - - if($query->RecordCount() != 1) - { - throw new Exception("wrong id supplied!"); - } - - $data = $query->FetchRow(); - if( ! LinSql::photoIsAllowed( $data['id'] ) ) - { - throw new Exception("not permitted!"); - } + include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + $linpha = new linpha(); + $linpha->sql->startSession(); - if( isset($_GET['force'] ) ) { - $force = true; - } else { - $force = false; - } - $thumbnail = new LinImage(); - if( ! $thumbnail->createFile('thumb',$data['id'],$data['img_type'],$force) ) + if( ! $thumbnail->createThumbnail($_GET['id']) ) { - throw new Exception("Error while creating thumbnail!"); + throw new Exception("Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg); } - + $thumbnail->printFileToScreen(); } catch(Exception $error) @@ -71,4 +52,5 @@ echo "Error: ".$error -> getMessage(); } + ?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -39,17 +39,25 @@ 'sys_path_album_dir' => $_SESSION['album_dir'], 'sys_path_cache_dir' => $_SESSION['cache_dir'], 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], - 'sys_style_image_quality' => '75', - 'sys_style_image_size' => '700', + + 'sys_style_sortorder' => 'nameasc', + 'sys_style_template' => 'default', 'sys_style_home_showbrowsebydate' => '1', 'sys_style_home_nrrandomimages' => '4', 'sys_style_home_showalbums' => '1', 'sys_style_home_usedefaultwelcometext' => '1', 'sys_style_home_firstsortorder' => 'nameasc', - 'sys_style_sortorder' => 'nameasc', - 'sys_style_template' => 'default', 'sys_style_thumb_size_max' => '200', 'sys_style_thumb_size_display' => '150', + 'sys_style_thumb_showsubfoldersseparate' => '0', + 'sys_style_thumb_selectsizes' => '50,75,100,150,200,250,300,400,500', + 'sys_style_thumb_selectnrimages' => 'auto,10,25,50,100,200,all', + 'sys_style_thumb_nojsnrrows' => '3', + 'sys_style_thumb_nojsnrcols' => '4', + 'sys_style_image_quality' => '75', + 'sys_style_image_size' => '700', + 'sys_style_image_nrprevnextthumbs' => '3', + 'sys_user_autologin' => '1' ); Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -72,6 +72,21 @@ "stats_downloads INT NOT NULL default '0', " . "PRIMARY KEY (id) " . ")", + "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". + "id INT NOT NULL AUTO_INCREMENT, " . + "photo_id INT NOT NULL default '0', " . + "img_width INT NOT NULL default '0', " . + "img_height INT NOT NULL default '0', " . + "img_quality INT NOT NULL default '0', " . + "img_size INT NOT NULL default '0', " . + "is_rotated INT NOT NULL default '0', " . + "has_watermark INT NOT NULL default '0', " . + "time_add INT NOT NULL default '0', " . + "time_use INT NOT NULL default '0', " . + "time_creating INT NOT NULL default '0', " . + "hits INT NOT NULL default '0', " . + "PRIMARY KEY (id) " . + ")", "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id INT NOT NULL AUTO_INCREMENT, " . "name VARCHAR(255) NOT NULL default '', " . Modified: trunk/linpha2/install/sql/sql.postgres.php =================================================================== --- trunk/linpha2/install/sql/sql.postgres.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/install/sql/sql.postgres.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -20,6 +20,7 @@ /** * linpha installer */ + $sql_tables = array( "CREATE TABLE ".$linpha_tables['config']." ( ". "id SERIAL PRIMARY KEY, " . @@ -65,6 +66,20 @@ "stats_views INT NOT NULL default '0', " . "stats_downloads INT NOT NULL default '0' " . ")", + "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". + "id SERIAL PRIMARY KEY, " . + "photo_id INT NOT NULL default '0', " . + "img_width INT NOT NULL default '0', " . + "img_height INT NOT NULL default '0', " . + "img_quality INT NOT NULL default '0', " . + "img_size INT NOT NULL default '0', " . + "is_rotated INT NOT NULL default '0', " . + "has_watermark INT NOT NULL default '0', " . + "time_add INT NOT NULL default '0', " . + "time_use INT NOT NULL default '0', " . + "time_creating INT NOT NULL default '0', " . + "hits INT NOT NULL default '0' " . + ")", "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id SERIAL PRIMARY KEY, " . "name VARCHAR(255) NOT NULL default '', " . Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -66,6 +66,20 @@ "stats_views INTEGER NOT NULL default '0', " . "stats_downloads INTEGER NOT NULL default '0' " . ")", + "CREATE TABLE ".$linpha_tables['photos_cache']." ( ". + "id INTEGER PRIMARY KEY, " . + "photo_id INTEGER NOT NULL default '0', " . + "img_width INTEGER NOT NULL default '0', " . + "img_height INTEGER NOT NULL default '0', " . + "img_quality INTEGER NOT NULL default '0', " . + "img_size INTEGER NOT NULL default '0', " . + "is_rotated INTEGER NOT NULL default '0', " . + "has_watermark INTEGER NOT NULL default '0', " . + "time_add INTEGER NOT NULL default '0', " . + "time_use INTEGER NOT NULL default '0', " . + "time_creating INTEGER NOT NULL default '0', " . + "hits INTEGER NOT NULL default '0' " . + ")", "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id INTEGER PRIMARY KEY, " . "name VARCHAR(255) NOT NULL default '', " . Modified: trunk/linpha2/install/sql/sql.tables.php =================================================================== --- trunk/linpha2/install/sql/sql.tables.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/install/sql/sql.tables.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -28,6 +28,7 @@ "user_group" => "user_group", "permissions" => "permissions", "photos" => "photos", + "photos_cache" => "photos_cache", "meta_fields" => "meta_fields", "meta_category" => "meta_category", "meta_exif" => "meta_exif", Added: trunk/linpha2/lib/classes/image/gdlib/image.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/image.php (rev 0) +++ trunk/linpha2/lib/classes/image/gdlib/image.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -0,0 +1,66 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Create thumbnails with gdlib + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** + * create image resources + */ + switch($this->img_type) + { + case 1: $src_image = imagecreatefromgif($this->src_file); break; + case 2: $src_image = imagecreatefromjpeg($this->src_file); break; + case 3: $src_image = imagecreatefrompng($this->src_file); break; + default: return false;; + } + $scaled_image = imagecreatetruecolor($this->img_width, $this->img_height); + +/** + * resize and crop image + */ + imagecopyresized( + $scaled_image,$src_image, + 0,0, // int dstX, int dstY + 0,0, // int srcX, int srcY + $this->img_width,$this->img_height, // int dstW, int dstH + $this->org_width,$this->org_height // int srcW, int srcH + ); + +/** + * destroy source image + */ + imagedestroy($src_image); + +/** + * save image + */ + imagejpeg($scaled_image,$this->output_file,$this->img_quality); + +/** + * destroy scaled image + */ + imagedestroy($scaled_image); + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/image/gdlib/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/image/gdlib/thumbnail.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -28,44 +28,44 @@ /** * calculate crop */ - $ratio = $org_width/$org_height; + $ratio = $this->org_width/$this->org_height; if($ratio==1) { $x = 0; $y = 0; - $w = $thumbsize; - $h = $thumbsize; + $w = $this->img_thumbsize; + $h = $this->img_thumbsize; } elseif($ratio>1) { - $x = ( $org_width - $org_height )/2; + $x = ( $this->org_width - $this->org_height )/2; $y = 0; - $w = $thumbsize; - $h = $thumbsize; - $src_size = $org_height; + $w = $this->img_thumbsize; + $h = $this->img_thumbsize; + $src_size = $this->org_height; } elseif($ratio<1) { - $y = ( $org_height - $org_width )/2; + $y = ( $this->org_height - $this->org_width )/2; $x = 0; - $w = $thumbsize; - $h = $thumbsize; + $w = $this->img_thumbsize; + $h = $this->img_thumbsize; - $src_size = $org_width; + $src_size = $this->org_width; } /** * create image resources */ - switch($img_type) + switch($image_type) { - case 1: $src_image = imagecreatefromgif($input); break; - case 2: $src_image = imagecreatefromjpeg($input); break; - case 3: $src_image = imagecreatefrompng($input); break; + case 1: $src_image = imagecreatefromgif($this->src_file); break; + case 2: $src_image = imagecreatefromjpeg($this->src_file); break; + case 3: $src_image = imagecreatefrompng($this->src_file); break; default: return false;; } - $scaled_image = imagecreatetruecolor($thumbsize, $thumbsize); + $scaled_image = imagecreatetruecolor($this->img_thumbsize, $this->img_thumbsize); /** * resize and crop image @@ -86,7 +86,7 @@ /** * save image */ - imagejpeg($scaled_image,$output,$q); + imagejpeg($scaled_image,$this->output_file,$this->img_quality); /** * destroy scaled image Added: trunk/linpha2/lib/classes/image/gdlib/thumbnail_folder.php =================================================================== --- trunk/linpha2/lib/classes/image/gdlib/thumbnail_folder.php (rev 0) +++ trunk/linpha2/lib/classes/image/gdlib/thumbnail_folder.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -0,0 +1,34 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Create folder thumbnails with gdlib + * don't think we are going to create the same nice folder icons as with imagemagick + * -> use first image in this folder as thumbnail + * + * + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +copy( LinImage::getCachePath('thumb',$array_ids[0]), $this->output_file ); + +?> \ No newline at end of file Added: trunk/linpha2/lib/classes/image/imagemagick/image.php =================================================================== --- trunk/linpha2/lib/classes/image/imagemagick/image.php (rev 0) +++ trunk/linpha2/lib/classes/image/imagemagick/image.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -0,0 +1,41 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Create thumbnails with imagemagick + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + + +$convert_str = $this->imagemagick_path.'convert'. + ' -quality '.$this->img_quality. + ' -size "'.$this->img_width.'x'.$this->img_height.'"'. // new size + ' '.linEscapeString($this->src_file).'[0]'. // [0] -> take only first frame!!! + ' -resize "'.$this->img_width.'x'.$this->img_height.'"'. // new size + ' +profile "*"'. // delete all profiles + ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images + ' '.linEscapeString($this->output_file); + +LinFilesys::linExec( $convert_str ); + + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php =================================================================== --- trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/image/imagemagick/thumbnail.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -27,42 +27,45 @@ /** * crop image + * first, scaled down image to $w x $h + * keep ratio: + * if image is wider than heigh, the height is $thumbsize, and width is "empty" + * (-> imagemagick will set the correct width to keep the ratio) + * after the resize, the image is too wide + * -> crop it */ -$ratio = $org_width/$org_height; -if($ratio==1) -{ - $x = 0; - $y = 0; - $w = $thumbsize; - $h = $thumbsize; -} -elseif($ratio>1) -{ - $x = ( ($thumbsize*$ratio) - $thumbsize )/2; - $y = 0; - $w = ''; - $h = $thumbsize; -} -elseif($ratio<1) -{ - $y = ( $thumbsize - ($thumbsize*$ratio) )/2; - $x = 0; - $w = $thumbsize; - $h = ''; -} + $ratio = $this->org_width/$this->org_height; + if($ratio==1) + { + $x = 0; + $y = 0; + $w = $this->img_thumbsize; + $h = $this->img_thumbsize; + } + elseif($ratio>1) + { + $x = ( ($this->img_thumbsize*$ratio) - $this->img_thumbsize )/2; + $y = 0; + $w = ''; + $h = $this->img_thumbsize; + } + elseif($ratio<1) + { + $y = ( $this->img_thumbsize - ($this->img_thumbsize*$ratio) )/2; + $x = 0; + $w = $this->img_thumbsize; + $h = ''; + } -$q = 100; - - -$convert_str = 'convert'. - ' -quality '.$q. +$convert_str = $this->imagemagick_path.'convert'. + ' -quality '.$this->img_quality. ' -size '.$w.'x'.$h. // new size - ' -crop '.$thumbsize.'x'.$thumbsize.'+'.$x.'+'.$y. // crop - ' '.lin_escape_string( $input ).'[0]'. // [0] -> take only first frame!!! + ' -crop '.$this->img_thumbsize.'x'.$this->img_thumbsize.'+'.$x.'+'.$y. // crop + ' '.linEscapeString( $this->src_file ).'[0]'. // [0] -> take only first frame!!! ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images - ' '.lin_escape_string( $output ); + ' '.linEscapeString( $this->output_file ); -exec( $convert_str ); +LinFilesys::linExec( $convert_str ); ?> \ No newline at end of file Added: trunk/linpha2/lib/classes/image/imagemagick/thumbnail_folder.php =================================================================== --- trunk/linpha2/lib/classes/image/imagemagick/thumbnail_folder.php (rev 0) +++ trunk/linpha2/lib/classes/image/imagemagick/thumbnail_folder.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -0,0 +1,75 @@ +<?php +/* +* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> +* Florian Angehrn +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/** + * Create folder thumbnail with imagemagick + * @package Image + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + + +/** + * create new tmp folder + */ + for($i=0; file_exists(LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i); $i++) { } + $tmp_folder = LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i; + mkdir($tmp_folder,0700); + +/** + * run imagemagick + */ + for($i=1; list($key,$value) = each($array_ids) ; $i++) + { + LinFilesys::linExec("convert ". LinImage::getCachePath('thumb',$value) . " -resize 80x80 ".$tmp_folder."/".$i.".jpg" ); + } + + LinFilesys::linExec("convert -size 180x180 xc:lemonchiffon -mattecolor peru -frame 9x9+3+3 ".$this->output_file); + + for($i=1; $i<=count($array_ids); $i++ ) + { + switch($i) + { + case 1: + LinFilesys::linExec("composite -geometry +10+10 ".$tmp_folder."/1.jpg ".$this->output_file." ".$this->output_file); + break; + case 2: + LinFilesys::linExec("composite -geometry +100+10 ".$tmp_folder."/2.jpg ".$this->output_file." ".$this->output_file); + break; + case 3: + LinFilesys::linExec("composite -geometry +10+100 ".$tmp_folder."/3.jpg ".$this->output_file." ".$this->output_file); + break; + case 4: + LinFilesys::linExec("composite -geometry +100+100 ".$tmp_folder."/4.jpg ".$this->output_file." ".$this->output_file); + break; + } + } + +/** + * delete tmp folder + */ + reset($array_ids); + for($i=1; list($key,$value) = each($array_ids) ; $i++) + { + unlink( $tmp_folder .'/'. $i . '.jpg' ); + } + rmdir($tmp_folder); + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -26,7 +26,24 @@ class LinFilesys { + /** + * close session before exec() + * if exec() is called twice (like on the print preview), apache will hang + * on windows + * + * $_SESSION is still available after session_write_close! + * but we cannot edit it!!!! + */ +function linExec($str) +{ + session_write_close(); + + exec( $str ); +} + + +/** * if $path is absolute, input is just returned, if $path is relative, * the relative path starting from the linpha root directory is returned * Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/linpha.functions.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -30,8 +30,8 @@ * If option tr_learn is set - all new entries will be autolearned. * @param string $text phrase/word to translate */ - function i18n($text) - { +function i18n($text) +{ global $translate; $tr_learn = true; //autolearn new language entries @@ -195,7 +195,7 @@ * @return string escape string * @package filesys */ -function lin_escape_string($str) +function linEscapeString($str) { if(getOS() == 'win') { @@ -259,4 +259,34 @@ return $str; } -?> +/** + * some functions to calculate the page rendering time + * this is very useful while trying to speed up LinPHA :-) + */ +function startTimer($string) +{ + global $timer; + $timer[$string]=getRenderTime(); +} + +/** + * some functions to calculate the page rendering time + * this is very useful while trying to speed up LinPHA :-) + */ +function stopTimer($string) +{ + global $timer; + return number_format(getRenderTime()-$timer[$string],4); +} + +/** + * some functions to calculate the page rendering time + * this is very useful while trying to speed up LinPHA :-) + */ +function getRenderTime() +{ + list ($usec, $sec)=explode(" ", microtime()); + return ((float)$usec + (float)$sec); +} + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.identify.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.identify.class.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/linpha.identify.class.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -143,7 +143,7 @@ /** * $array_output[0] contains something like '2272 1704 JPEG' */ - exec ( $identify_path.' -format "%w %h %m" '.lin_escape_string($path), $array_output = Array(), $return_value = 0); + linExec ( $identify_path.' -format "%w %h %m" '.linEscapeString($path), $array_output = Array(), $return_value = 0); if($return_value == 0) // identify succeed { @@ -154,7 +154,7 @@ $g = explode( " ", $array_output[0] ); - $g[2] = linIdentify::convertImagetype($g[2],$path); + $g[2] = LinIdentify::convertImagetype($g[2],$path); } } } @@ -164,13 +164,13 @@ { if($g[2] == 15) { - if(linIdentify::convertImagetype($ext) == 1000) // 1000 = mpg, mpeg, mpe, ... + if(LinIdentify::convertImagetype($ext) == 1000) // 1000 = mpg, mpeg, mpe, ... { - $g[2] = linIdentify::convertImagetype('mpg'); // get imagetype of mpg + $g[2] = LinIdentify::convertImagetype('mpg'); // get imagetype of mpg }elseif($ext == 'mov'){ - $g[2] = linIdentify::convertImagetype('mov'); + $g[2] = LinIdentify::convertImagetype('mov'); }elseif($ext == 'mp4'){ - $g[2] = linIdentify::convertImagetype('mp4'); + $g[2] = LinIdentify::convertImagetype('mp4'); } } } @@ -181,10 +181,10 @@ */ if( !$g[2] ) { - $type = linIdentify::getImagetypeFromFilename($path); + $type = LinIdentify::getImagetypeFromFilename($path); if($type < 1000) { - $g[2] = linIdentify::convertImagetype('unsupported'); + $g[2] = LinIdentify::convertImagetype('unsupported'); } else { Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -27,15 +27,18 @@ class LinImage { +public $error_msg; - -private $id; +private $photo_id, $cached_id; private $img_type; private $mode; +private $image_tool; private $output_file; -private $src_file, $org_width, $org_height; - +private $src_file; +private $org_width, $org_height, $img_width, $img_height; +private $img_quality; + /** * constructor */ @@ -43,12 +46,172 @@ { } +/** + * set cached_id and output_file + * in image mode set also rotate, watermark, quality, ... + * and add an empty entry in the cache database + */ +function setCachedInfos() +{ + if($this->mode == 'thumb') + { + $this->cached_id = $this->photo_id; + $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id); + } + elseif($this->mode == 'img') + { + /** + * check additional settings + */ + /** + * max_width and max_height + */ + if(isset($this->overrideSettings['max_width']) && isset($this->overrideSettings['max_height'])) + { + $this->max_width = $this->overrideSettings['max_width']; + $this->max_height = $this->overrideSettings['max_height']; + } + else + { + $this->max_width = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + $this->max_height = $GLOBALS['linpha']->sql->config->value['sys_style_image_size']; + } + + /** + * rotate (printing, ...) + */ + if(isset($this->overrideSettings['rotate'])) + { + $this->rotate = $this->overrideSettings['rotate']; + } + else + { + $this->rotate = 0; + } + + /** + * watermark + */ + if(isset($this->overrideSettings['watermark'])) + { + $this->watermark = $this->overrideSettings['watermark']; + } + else + { + /** + * @todo place need_watermark() here + */ + $this->watermark = 0; + } + + /** + * quality + */ + if(isset($this->overrideSettings['quality'])) + { + $this->img_quality = intval($this->overrideSettings['quality']); // oh, do intval() for security, comes from $_GET and will be included in exec() commands + } + else + { + $this->img_quality = intval($GLOBALS['linpha']->sql->config->value['sys_style_image_quality']); + } + + /** + * in image mode this is done earlier, because we need already org_width and org_height + * to determine if image is cached or not + * in thumb mode this can only be done later, because there are also folders and videos + */ + if( ! $this->setSourceFileInformation() ) + { + return false; + } + + $array = $this->scaleToFit($this->org_width,$this->org_height,$this->max_width,$this->max_height); + $this->img_width = $array['w']; + $this->img_height = $array['h']; + + /** + * check if entry in linpha_photos_cache exists + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."photos_cache WHERE " . + "photo_id = '".$this->photo_id."' AND " . + "img_width = '".$this->img_width."' AND " . + "img_height = '".$this->img_height."' AND " . + "img_quality = '".$this->img_quality."' AND " . + "is_rotated = '".$this->rotate."' AND " . + "has_watermark = '".$this->watermark."'"); + + if(isset($data['id']) && !empty($data['id'])) + { + $this->cached_id = $data['id']; + $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id); + } + else + { + /** + * insert an empty entry and get cached_id + * we will update correct values only if create cached image has been successfull + */ + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."photos_cache " . + "(photo_id) VALUES ('".$this->photo_id."')"); + $this->cached_id = $GLOBALS['linpha']->db->Insert_ID(); + $this->output_file = LinImage::getCachePath($this->mode,$this->cached_id); + + if(file_exists($this->output_file)) + { + /** + * o-oh, we're leaking old files in cache path, -> delete it + */ + unlink($this->output_file); + } + } + } + + +} + function setFileInformation() { /** - * check if already exists OR if forced + * check for valid id */ - $this->output_file = LinImage::getCachePath($this->mode,$this->id); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); + + if($query->RecordCount() != 1) + { + $this->error_msg = "wrong id supplied!"; + return false; + } + + $data = $query->FetchRow(); + + if( ! LinSql::photoIsAllowed( $data['id'] ) ) + { + $this->error_msg = "not permitted!"; + return false; + } + + if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) + { + $this->error_msg = "only images possible!"; + return false; + } + + /** + * checke force parameter + */ + if( isset($_GET['force'] ) ) { + $this->force = true; + } else { + $this->force = false; + } + + $this->img_type = $data['img_type']; + $this->setCachedInfos(); + + /** + * check if file already exists OR if forced + */ if( file_exists( $this->output_file ) AND !$this->force ) { $this->isCached = true; @@ -64,7 +227,7 @@ { if( ! @mkdir( dirname($this->output_file) ) ) { - echo "Cannot create folder ".dirname($this->output_file)." check permissions!"; + $this->error_msg = "Cannot create folder ".dirname($this->output_file)." check permissions!"; return false; } } @@ -75,11 +238,12 @@ */ if($GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) { - $this->include_str = 'imagemagick'; + $this->image_tool = 'imagemagick'; + $this->imagemagick_path = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path']; } else { - $this->include_str = 'gdlib'; + $this->image_tool = 'gdlib'; } return true; @@ -92,7 +256,7 @@ */ if($this->img_type != 0 && $this->img_type != 9999999) { - $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->id ); + $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->photo_id ); $album_dir = $GLOBALS['linpha']->sql->getPath('album'); $this->src_file = $album_dir .'/'. implode('/',$array_path); @@ -111,109 +275,81 @@ return true; } -function printFileToScreen() -{ - if(file_exists($this->output_file)) + +/** + * thumbnail functions + */ + function createThumbnail($photo_id) { - Header("Content-type: image/jpeg"); - readfile( $this->output_file ); - } -} + $this->mode = 'thumb'; + $this->photo_id = $photo_id; -function createFile($mode,$id,$img_type,$force) -{ - $this->id = $id; - $this->mode = $mode; - $this->force = $force; - $this->img_type = $img_type; - - if( ! $this->setFileInformation() ) - { - return false; - } - - if( ! $this->isCached) - { - if( ! $this->setSourceFileInformation() ) + if( ! $this->setFileInformation() ) { return false; } - - if($this->mode == 'thumb') + + if( ! $this->isCached ) { - $this->createThumbnail(); - } - elseif($this->mode == 'image') - { - $this->createImage(); - } - } + if( ! $this->setSourceFileInformation() ) + { + return false; + } + + /** + * image thumbnail + */ + if( LinIdentify::isSupportedImage( $this->img_type ) ) + { + + $this->createThumbnailImage(); + } + /** + * folder thumbnail + */ + elseif($this->img_type == 0) + { + if( ! $this->createThumbnailFolder() ) + { + $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; + } + } + /** + * video thumbnail + */ + elseif( LinIdentify::isVideo( $this->img_type ) ) + { + $this->createThumbnailVideo(); + } - if( ! file_exists( $this->output_file ) ) - { - return false; - } - return true; -} - - -/** - * thumbnail functions - */ - function createThumbnail() - { - /** - * create folder thumbnail - */ - if($this->img_type == 0) - { - if( ! $this->createThumbnailFolder() ) + if( ! file_exists( $this->output_file ) ) { - $this->output_file = LINPHA_DIR.'/lib/graphics/subfolder_image.png'; + return false; } - } - elseif( linIdentify::isVideo( $this->img_type ) ) - { - $this->createThumbnailVideo(); - } - elseif( linIdentify::isSupportedImage( $this->img_type ) ) - { - - $this->createThumbnailImage(); - } + } + + return true; } function createThumbnailImage() { /** - * include the file which contains the imagemagick strings and exec() + * include the file which contains the imagemagick strings and exec() / gdlib instructions */ - $thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; - $q = 75; - $img_type = $this->img_type; - $input = $this->src_file; - $output = $this->output_file; - $org_height = $this->org_height; - $org_width = $this->org_width; + $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; + $this->img_quality = 75; - include(LINPHA_DIR.'/lib/include/image.'.$this->include_str.'.thumbnail.php'); + include(LINPHA_DIR.'/lib/classes/image/'.$this->image_tool.'/thumbnail.php'); } function createThumbnailFolder() { /** - * thumbnail icon only available with imagemagick - */ - if(! $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick']) - { - return false; - } - - /** * check if we have already some thumbnails in this folder + * and create array_ids which holds 4 image ids */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->id )."'"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes( $this->photo_id )."'"); $array_ids = Array(); $i=0; while($data = $query->FetchRow()) @@ -230,56 +366,17 @@ } } + /** + * no images found in this folder + */ if(count($array_ids) == 0) { return false; } - /** - * create new tmp folder - */ - for($i=0; file_exists(LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i); $i++) { } - $tmp_folder = LinSql::getPath('tmp').'/thumb_folder_'.session_id().'_'.$i; - mkdir($tmp_folder,0700); - - /** - * run imagemagick - */ - for($i=1; list($key,$value) = each($array_ids) ; $i++) - { - exec("convert ". LinImage::getCachePath('thumb',$value) . " -resize 80x80 ".$tmp_folder."/".$i.".jpg" ); - } - - exec("convert -size 180x180 xc:lemonchiffon -mattecolor peru -frame 9x9+3+3 ".$this->output_file); - - for($i=1; $i<=count($array_ids); $i++ ) - { - switch($i) - { - case 1: - exec("composite -geometry +10+10 ".$tmp_folder."/1.jpg ".$this->output_file." ".$this->output_file); - break; - case 2: - exec("composite -geometry +100+10 ".$tmp_folder."/2.jpg ".$this->output_file." ".$this->output_file); - break; - case 3: - exec("composite -geometry +10+100 ".$tmp_folder."/3.jpg ".$this->output_file." ".$this->output_file); - break; - case 4: - exec("composite -geometry +100+100 ".$tmp_folder."/4.jpg ".$this->output_file." ".$this->output_file); - break; - } - } - - /** - * delete tmp folder - */ - reset($array_ids); - for($i=1; list($key,$value) = each($array_ids) ; $i++) - { - unlink( $tmp_folder .'/'. $i . '.jpg' ); - } - rmdir($tmp_folder); + include(LINPHA_DIR.'/lib/classes/image/'.$this->image_tool.'/thumbnail_folder.php'); + + return true; } function createThumbnailVideo() @@ -294,9 +391,66 @@ /** * image functions */ - function createImage() + function createImage($photo_id, $overrideSettings) { + $this->mode = 'img'; + $this->photo_id = $photo_id; + $this->overrideSettings = $overrideSettings; + + if( ! $this->setFileInformation() ) + { + return false; + } + + if( ! $this->isCached ) + { + /** + * include the create image script + */ + startTimer("createimage"); + include(LINPHA_DIR.'/lib/classes/image/'.$this->image_tool.'/image.php'); + $time = stopTimer("createimage") * 1000000; + + //echo $time; exit(); + + if( ! file_exists( $this->output_file ) ) + { + return false; + } + + /** + * finish cache entry + */ + $filesize = filesize( $this->output_file ); + if($filesize <= 0) + { + $this->error_msg = "Incorrect filesize (".$filesize.")"; + return false; + } + + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos_cache SET " . + "img_width = '".$this->img_width."', " . + "img_height = '".$this->img_height."', " . + "img_quality = '".$this->img_quality."', " . + "img_size = '".$filesize."', " . + "is_rotated = '".$this->rotate."', " . + "has_watermark = '".$this->watermark."', " . + "time_add = '".time()."', " . + "time_creating = '".$time."' " . + "WHERE id = '".$this->cached_id."'"); + } + else + { + /** + * got a cached copy, increment counter and time_use + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos_cache " . + "SET hits = hits + 1, time_use = '".time()."' " . + "WHERE id = '".$this->cached_id."'"); + } + + return true; } @@ -346,7 +500,7 @@ * calculated from $src_h and $src_w * if $no_increase is set, the image is only decreased */ -function scaleToFit($src_h,$src_w,$dst_h,$dst_w,$no_increase) +function scaleToFit($src_w,$src_h,$dst_w,$dst_h,$no_increase=1) { if($src_h == 0 OR $src_w == 0) { @@ -376,14 +530,25 @@ $tmp_height = $dst_w / $img_relation; // calc the new height with screen width if ($tmp_height > $dst_h) { // we were wrong, it's still widther than screen -> $dst_h is decisive $array['w'] = round($img_relation*$dst_h); - $array['h'] = $dst_h; + $array['h'] = intval($dst_h); // oh, do intval() for security, comes from $_GET and will be included in exec() commands } else { - $array['w'] = $dst_w; + $array['w'] = intval($dst_w); // oh, do intval() for security, comes from $_GET and will be included in exec() commands $array['h'] = round($tmp_height); } } + return $array; } +/** + * send correct header and file + */ +function printFileToScreen() +{ + Header("Content-type: image/jpeg"); + readfile( $this->output_file ); +} + + } // end class linImage ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -25,17 +25,6 @@ if(!defined('LINPHA_DIR')) { exit(1); } -/** - * config stuff - * @todo make vars db entries - */ -$show_subfolders_separate = 0; -$nr_prev_next_thumbs = 3; -$array_tn_sizes = Array(50,75,100,150,200,250,300,400,500); -$array_nr_images = Array('auto',10,25,50,100,200,'all'); -$no_js_nr_rows = 3; -$no_js_nr_cols = 4; - class LinImgview { public $mode; // 'home', 'thumb', 'image' @@ -290,12 +279,14 @@ switch($this->mode) { case 'thumb': - - foreach($GLOBALS['array_tn_sizes'] AS $value) + $array = explode(',',$GLOBALS['linpha']->sql->config->value['sys_style_thumb_selectsizes']); + foreach($array AS $value) { $array_tn_sizes_links[] = Array('name' => $value.' '.i18n("Pixel"), 'value' => 'javascript:set_tn_size('.$value.')'); } - foreach($GLOBALS['array_nr_images'] AS $value) + + $array = explode(',',$GLOBALS['linpha']->sql->config->value['sys_style_thumb_selectnrimages']); + foreach($array AS $value) { $array_nr_links[] = Array('name' => $value, 'value' =>"javascript:set_nr_images('".$value."')"); } @@ -473,7 +464,8 @@ { foreach($this->photos_filtered AS $key=>$value) { - if( ( $GLOBALS['show_subfolders_separate'] && $value['img_type'] != 0 ) OR !$GLOBALS['show_subfolders_separate'] ) + if( ( $GLOBALS['linpha']->sql->config->value['sys_style_thumb_showsubfoldersseparate'] && $value['img_type'] != 0 ) + OR !$GLOBALS['linpha']->sql->config->value['sys_style_thumb_showsubfoldersseparate'] ) { $before = $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['before']; $after = $GLOBALS['linpha']->template->output['thumb_infos'][$value['id']]['after']; @@ -506,7 +498,7 @@ /** * prepare variables */ - $max_photos_per_page = $GLOBALS['no_js_nr_rows'] * $GLOBALS['no_js_nr_cols']; + $max_photos_per_page = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrrows'] * $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrrows']; $this->nr_pages = ceil( $this->tot_photos / $max_photos_per_page ); if(isset($_GET['pn']) && $_GET['pn'] > 1) { @@ -532,8 +524,9 @@ foreach($this->photos_filtered AS $value) { - if($i >= $startup_img_nr && $img_nr <= $max_photos_per_page - && ( ( $GLOBALS['show_subfolders_separate'] && $value['img_type'] != 0 ) OR !$GLOBALS['show_subfolders_separate'] ) ) + if($i >= $startup_img_nr && $img_nr <= $max_photos_per_page // add images only while in current page + && ( ( $GLOBALS['linpha']->sql->config->value['sys_style_thumb_showsubfoldersseparate'] && $value['img_type'] != 0 ) // add images only if no folder because they are shown separate + OR !$GLOBALS['linpha']->sql->config->value['sys_style_thumb_showsubfoldersseparate'] ) ) // add folders only if they are not shown separate { $this->photos_show[] = $value; $img_nr++; @@ -641,7 +634,7 @@ $GLOBALS['linpha']->template->output['navigation'] = ''; } - if($GLOBALS['show_subfolders_separate']) + if($GLOBALS['linpha']->sql->config->value['sys_style_thumb_showsubfoldersseparate']) { foreach($this->photos_filtered AS $key=>$value) { @@ -1022,6 +1015,8 @@ */ function viewImgSetPrevNextThumb() { + $nr_prev_next_thumbs = $GLOBALS['linpha']->sql->config->value['sys_style_image_nrprevnextthumbs']; + /** * search current key in array */ @@ -1046,7 +1041,7 @@ * set prev thumbs */ $GLOBALS['linpha']->template->output['prev_thumb'] = ''; - for($i=$GLOBALS['nr_prev_next_thumbs']; $i > 0; $i--) + for($i=$nr_prev_next_thumbs; $i > 0; $i--) { if($this->current_key >= $i) { @@ -1058,7 +1053,7 @@ * set next thumbs */ $GLOBALS['linpha']->template->output['next_thumb'] = ''; - for($i=0; $i < $GLOBALS['nr_prev_next_thumbs']; $i++) + for($i=0; $i < $nr_prev_next_thumbs; $i++) { if($this->current_key < ( count($this->photos_filtered) - ($i+1) ) ) { Modified: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-04-09 19:46:00 UTC (rev 4498) @@ -55,10 +55,10 @@ } /** - * set correct main height + * set correct main height only if photos_per_page == auto */ - document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; - +// document.getElementById('main').style.height = linInnerHeight - document.getElementById('spacer_height')['offsetHeight']; + /** * calculate nr of photos per page (from select form) */ Modified: trunk/linpha2/lib/include/common.php =================================================================== --- trunk/linpha2/lib/include/common.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/include/common.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -11,6 +11,8 @@ * If you disable magic quotes, you must be very careful * to protect yourself from SQL injection attacks. * For details see http://www.php.net/manual/en/function.get-magic-quotes-gpc.php + * + * There is also a nice UnifyMagicQuotes() function in the getid3 library... * * @author flo */ @@ -56,5 +58,9 @@ { $_FILES[$key]['name'] = stripslashes($_FILES[$key]['name']); } + + $HTTP_GET_VARS = $_GET; + $HTTP_POST_VARS = $_POST; + $HTTP_COOKIE_VARS = $_COOKIE; } ?> Deleted: trunk/linpha2/lib/include/image.gdlib.thumbnail.php =================================================================== --- trunk/linpha2/lib/include/image.gdlib.thumbnail.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/include/image.gdlib.thumbnail.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -1,96 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * Create thumbnails with gdlib - * @package Image - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * calculate crop - */ - $ratio = $org_width/$org_height; - if($ratio==1) - { - $x = 0; - $y = 0; - $w = $thumbsize; - $h = $thumbsize; - } - elseif($ratio>1) - { - $x = ( $org_width - $org_height )/2; - $y = 0; - $w = $thumbsize; - $h = $thumbsize; - $src_size = $org_height; - } - elseif($ratio<1) - { - $y = ( $org_height - $org_width )/2; - $x = 0; - $w = $thumbsize; - $h = $thumbsize; - - $src_size = $org_width; - } - - -/** - * create image resources - */ - switch($img_type) - { - case 1: $src_image = imagecreatefromgif($input); break; - case 2: $src_image = imagecreatefromjpeg($input); break; - case 3: $src_image = imagecreatefrompng($input); break; - default: return false;; - } - $scaled_image = imagecreatetruecolor($thumbsize, $thumbsize); - -/** - * resize and crop image - */ - imagecopyresized( - $scaled_image,$src_image, - 0,0, // int dstX, int dstY - $x,$y, // int srcX, int srcY - $w,$h, // int dstW, int dstH - $src_size,$src_size // int srcW, int srcH - ); - -/** - * destroy source image - */ - imagedestroy($src_image); - -/** - * save image - */ - imagejpeg($scaled_image,$output,$q); - -/** - * destroy scaled image - */ - imagedestroy($scaled_image); - -?> \ No newline at end of file Deleted: trunk/linpha2/lib/include/image.imagemagick.thumbnail.php =================================================================== --- trunk/linpha2/lib/include/image.imagemagick.thumbnail.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/lib/include/image.imagemagick.thumbnail.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -1,68 +0,0 @@ -<?php -/* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/** - * Create thumbnails with imagemagick - * @package Image - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * crop image - */ -$ratio = $org_width/$org_height; -if($ratio==1) -{ - $x = 0; - $y = 0; - $w = $thumbsize; - $h = $thumbsize; -} -elseif($ratio>1) -{ - $x = ( ($thumbsize*$ratio) - $thumbsize )/2; - $y = 0; - $w = ''; - $h = $thumbsize; -} -elseif($ratio<1) -{ - $y = ( $thumbsize - ($thumbsize*$ratio) )/2; - $x = 0; - $w = $thumbsize; - $h = ''; -} - -$q = 100; - - -$convert_str = 'convert'. - ' -quality '.$q. - ' -size '.$w.'x'.$h. // new size - ' -crop '.$thumbsize.'x'.$thumbsize.'+'.$x.'+'.$y. // crop - ' '.lin_escape_string( $input ).'[0]'. // [0] -> take only first frame!!! - ' -thumbnail "'.$w.'x'.$h.'"'. // new size and delete profiles, no need anymore for ' +profile "*"'. // delete all profiles - ' -colorspace RGB'. // change colorspace always to RGB because all browsers only can display RGB images - ' '.lin_escape_string( $output ); - -exec( $convert_str ); - -?> \ No newline at end of file Modified: trunk/linpha2/templates/default/css/global.css =================================================================== --- trunk/linpha2/templates/default/css/global.css 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/templates/default/css/global.css 2006-04-09 19:46:00 UTC (rev 4498) @@ -132,10 +132,6 @@ /** * menu */ - #divmenu { - height: 40px; - } - #menu { margin-left: 50px; } Modified: trunk/linpha2/templates/default/css/view_thumb.css =================================================================== --- trunk/linpha2/templates/default/css/view_thumb.css 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/templates/default/css/view_thumb.css 2006-04-09 19:46:00 UTC (rev 4498) @@ -1,5 +1,5 @@ #main { - min-height: 500px; /*@todo floated divs in thumb view without javascript doesnt count to the main div height */ + height: 85%; } /** @@ -27,8 +27,6 @@ width: 530px; height: 35px; margin-left: -265px; /* should be the half of 'width' */ - - /* border: 1px #000000 solid;*/ } .page_nr_divs { float: left; Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/templates/default/global.html.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -65,11 +65,6 @@ </div> <!-- menu --> -<!-- -need an outer div for the correct height, because elements in #menu are floated -and doesn't count to the this elements height ---> -<div id="divmenu"> <div id="menu"> <ul> <li><a href="./"><?php echo i18n("Home"); ?></a></li> @@ -126,7 +121,7 @@ </ul> <?php $GLOBALS['linpha']->template->printMenu("Admin","./admin/"); ?> </div> -</div> +<div style="clear: both;"></div> <!-- end menu --> <?php $GLOBALS['linpha']->template->includeFile('body'); ?> Modified: trunk/linpha2/templates/default/home.html.php =================================================================== --- trunk/linpha2/templates/default/home.html.php 2006-04-09 15:45:06 UTC (rev 4497) +++ trunk/linpha2/templates/default/home.html.php 2006-04-09 19:46:00 UTC (rev 4498) @@ -3,68 +3,66 @@ <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> </div> -<div id="main"> - -<?php echo $GLOBALS['linpha']->template->output['welcome']; ?> -<br /> - -<!-- Random Images --> -<?php if( count($GLOBALS['linpha']->template->output['random_images']) > 0 ) { ?> - <hr /> - <h1><?php echo i18n("Random images"); ?></h1> - <?php - foreach($GLOBALS['linpha']->template->output['random_images'] AS $key=>$value) - { - ?> - <div class="div_random_img"> - <?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">' - . '<img class="img_random_thumbnail" title="'.htmlentities($value['path']).'" src="'. LINPHA_DIR.'/get_thumb.php?id=' .$value['id'] .'" alt="randomimage" /></a>'; ?> - <br /><br /> - </div> + <div id="main"> + + <?php echo $GLOBALS['linpha']->template->output['welcome']; ?> + <br /> + + <!-- Random Images --> + <?php if( count($GLOBALS['linpha']->template->output['random_images']) > 0 ) { ?> + <hr /> + <h1><?php echo i18n("Random images"); ?></h1> <?php + foreach($GLOBALS['linpha']->template->output['random_images'] AS $key=>$value) + { + ?> + <div class="div_random_img"> + <?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">' + . '<img class="img_random_thumbnail" title="'.htmlentities($value['path']).'" src="'. LINPHA_DIR.'/get_thumb.php?id=' .$value['id'] .'" alt="randomimage" /></a>'; ?> + <br /><br /> + </div> + <?php + } + ?> + <div style="clear: both;"></div> + <?php } ?> + + <!-- Browse by Date --> + <?php + if($GLOBALS['linpha']->sql->config->value['sys_style_home_showbrowsebydate'] && + !empty($GLOBALS['linpha']->template->output['browse_by_date'])) { + echo "<hr />"; + echo i18n("Browse by Date").': '.$GLOBALS['linpha']->template->output['browse_by_date']; + echo "<br />"; } ?> - <div style="clear: both;"></div> -<?php } ?> - -<!-- Browse by Date --> -<?php -if($GLOBALS['linpha']->sql->config->value['sys_style_home_showbrowsebydate'] && - !empty($GLOBALS['linpha']->template->output['browse_by_date'])) { - echo "<hr />"; - echo i18n("Browse by Date").': '.$GLOBALS['linpha']->template->output['browse_by_date']; - echo "<br />"; -} -?> - -<!-- Albums --> -<?php if($GLOBALS['linpha']->sql->config->value['sys_style_home_showalbums']) { ?> - <hr /> - <h1><?php echo i18n("Albums"); ?></h1> - <?php - foreach($GLOBALS['linpha']->imgview->photos_filtered AS $key=>$value) - { - ?> - <div class='div_folder'> - <?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">' - . '<img class="img_folder_thumbnail" src="'. LINPHA_DIR.'/get_thumb.php?id=' .$value['id'] .'" alt="thumbnail_album" /></a>'; ?> - - <div class='div_folder_text'> - <h2><?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">'.$value['name'].'</a>'; ?></h2> - - <?php echo $value['stats_numbers'].' '.i18n("Photos"); ?> - - <br /> - <?php echo strftime("%x %X",$value['time_add']); ?> - - </div> - </div> + <!-- Albums --> + <?php if($GLOBALS['linpha']->sql->config->value['sys_style_home_showalbums']) { ?> + <hr /> + <h1><?php echo i18n("Albums"); ?></h1> + <?php - } -} -?> -</div> + foreach($GLOBALS['linpha']->imgview->photos_filtered AS $key=>$value) + { + ?> + <div class="div_folder"> + <?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">' + . '<img class="img_folder_thumbnail" src="'. LINPHA_DIR.'/get_thumb.php?id=' .$value['id'] .'" alt="thumbnail_album" /></a>'; ?> + + <div class="div_folder_text"> + <h2><?php echo '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$value['id'].'">'.$value['name... [truncated message content] |