Thread: [Linpha-cvs] SF.net SVN: linpha: [4499] trunk/linpha2 (Page 3)
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-10 09:41:05
|
Revision: 4499 Author: fangehrn Date: 2006-04-10 02:40:47 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4499&view=rev Log Message: ----------- * fixed some eclipse warnings * change linpha_photo.name form TEXT to varchar(255) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/sql/sql.mysql.php trunk/linpha2/install/sql/sql.postgres.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/lib/classes/linpha.functions.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/ChangeLog 2006-04-10 09:40:47 UTC (rev 4499) @@ -1,3 +1,7 @@ +2006-04-10 flo + * fixed some eclipse warnings + * change linpha_photo.name form TEXT to varchar(255) + 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 Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/install/lib.install.php 2006-04-10 09:40:47 UTC (rev 4499) @@ -335,7 +335,7 @@ while(strlen($http_accept_language)) { - if(preg_match( "/$eachbit/", $http_accept_language, $m)) + if(preg_match( "/$eachbit/", $http_accept_language, $m=Array())) { $tag = $m[1]; $quality = $m[2]; Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-04-10 09:40:47 UTC (rev 4499) @@ -62,8 +62,8 @@ "id INT NOT NULL AUTO_INCREMENT, " . "parent_id INT NOT NULL default '0', " . "img_type INT NOT NULL default '0', " . - "name text NOT NULL, " . - "md5sum VARCHAR(40) NOT NULL default '', " . + "name VARCHAR(255) NOT NULL, " . + "md5sum VARCHAR(32) NOT NULL default '', " . "time_add INT NOT NULL default '0', " . "time_mod INT NOT NULL default '0', " . "time_exif INT NOT NULL default '0', " . Modified: trunk/linpha2/install/sql/sql.postgres.php =================================================================== --- trunk/linpha2/install/sql/sql.postgres.php 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/install/sql/sql.postgres.php 2006-04-10 09:40:47 UTC (rev 4499) @@ -57,7 +57,7 @@ "id SERIAL PRIMARY KEY, " . "parent_id INT NOT NULL default '0', " . "img_type INT NOT NULL default '0', " . - "name TEXT NOT NULL, " . + "name VARCHAR(255) NOT NULL, " . "md5sum VARCHAR(32) NOT NULL default '', " . "time_add INT NOT NULL default '0', " . "time_mod INT NOT NULL default '0', " . Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-04-10 09:40:47 UTC (rev 4499) @@ -57,8 +57,8 @@ "id INTEGER PRIMARY KEY, " . "parent_id INTEGER NOT NULL default '0', " . "img_type INTEGER NOT NULL default '0', " . - "name text NOT NULL, " . - "md5sum VARCHAR(40) NOT NULL default '', " . + "name VARCHAR(255) NOT NULL, " . + "md5sum VARCHAR(32) NOT NULL default '', " . "time_add INTEGER NOT NULL default '0', " . "time_mod INTEGER NOT NULL default '0', " . "time_exif INTEGER NOT NULL default '0', " . Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2006-04-09 19:46:00 UTC (rev 4498) +++ trunk/linpha2/lib/classes/linpha.functions.php 2006-04-10 09:40:47 UTC (rev 4499) @@ -149,18 +149,10 @@ { switch($order) { - case 'nameasc': - return "name ASC"; - break; - case 'namedesc': - return "name DESC"; - break; - case 'dateasc': - return "time_add ASC"; - break; - case 'datedesc': - return "time_add DESC"; - break; + case 'nameasc': return "name ASC"; + case 'namedesc': return "name DESC"; + case 'dateasc': return "time_add ASC"; + case 'datedesc': return "time_add DESC"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-04-10 15:41:47
|
Revision: 4502 Author: bzrudi Date: 2006-04-10 08:41:20 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4502&view=rev Log Message: ----------- renamed some preserved table field names. !!! make sure to run reset_database.php !!! Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/permissions_usergroup.php trunk/linpha2/admin/permissions_users.php trunk/linpha2/admin/settings_layout.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/step11_finish.php trunk/linpha2/install/step2_requirements.php trunk/linpha2/install/step8_testing.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/view_comment.html.php trunk/linpha2/templates/default/view_img.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/ChangeLog 2006-04-10 15:41:20 UTC (rev 4502) @@ -1,3 +1,11 @@ +2006-04-10 bzrudi <linpha2_AT_tuxpower_DOT_de> + * Database + - renamed some preserved table field names. e.g. don't use "date", "name" as + field name to have better portability as these are preserved by many + databases. + - make sure to run reset_database.php! + - ...still more to rename + 2006-04-10 flo * fixed some eclipse warnings * change linpha_photo.name form TEXT to varchar(255) Modified: trunk/linpha2/admin/permissions_usergroup.php =================================================================== --- trunk/linpha2/admin/permissions_usergroup.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/admin/permissions_usergroup.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -18,7 +18,7 @@ */ echo '<b>'.i18n("Edit User Memberships").'</b><br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, username FROM ".PREFIX."users ORDER by username"); -while($data = $query->FetchRow()) +while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_usergroup&edit=user&id='.$data['id'].'">'.$data['username'].'</a><br />'; } Modified: trunk/linpha2/admin/permissions_users.php =================================================================== --- trunk/linpha2/admin/permissions_users.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/admin/permissions_users.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -33,7 +33,7 @@ "username='".LinSql::linAddslashes($_POST['mod_user_name'])."', ". "display_name='".LinSql::linAddslashes($_POST['mod_user_fullname'])."', ". $new_password. - "email='".LinSql::linAddslashes($_POST['mod_user_mail'])."' ". + "user_email='".LinSql::linAddslashes($_POST['mod_user_mail'])."' ". "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); /** @@ -61,7 +61,7 @@ break; case 'new_user': $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."users " . - "(username, password, email, display_name) ". + "(username, password, user_email, display_name) ". "VALUES " . "('".LinSql::linAddslashes($_POST['new_user_name'])."', '".md5($_POST['new_user_pass'])."', ". "'".LinSql::linAddslashes($_POST['new_user_mail'])."', '".LinSql::linAddslashes($_POST['new_user_fullname'])."')"); @@ -90,7 +90,7 @@ /** * show users */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, username, display_name, email FROM ".PREFIX."users ORDER BY username"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, username, display_name, user_email FROM ".PREFIX."users ORDER BY username"); while($data = $query->FetchRow()) { ?> @@ -106,7 +106,7 @@ <input type="password" name="mod_user_pass" size="20" maxlength="255"> </td> <td> - <input type="text" name="mod_user_mail" size="20" maxlength="255" value="<?php echo $data['email']; ?>"> + <input type="text" name="mod_user_mail" size="20" maxlength="255" value="<?php echo $data['user_email']; ?>"> </td> <td> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/admin/settings_layout.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -22,10 +22,10 @@ { case 'home': $welcometxt = i18n("Add Your Own Welcome Text Here"); - $data = $GLOBALS['linpha']->db->GetRow("SELECT comment FROM ".PREFIX."meta_comments WHERE md5sum='welcometext'"); - if(isset($data['comment'])) + $data = $GLOBALS['linpha']->db->GetRow("SELECT meta_comment FROM ".PREFIX."meta_comments WHERE md5sum='welcometext'"); + if(isset($data['meta_comment'])) { - $welcometxt = $data['comment']; + $welcometxt = $data['meta_comment']; $update = true; } @@ -47,13 +47,13 @@ if(isset($update)) { $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."meta_comments SET " . - "comment = '".LinSql::linAddslashes($_POST['welcometext'])."'" . + "meta_comment = '".LinSql::linAddslashes($_POST['welcometext'])."'" . "WHERE md5sum='welcometext'"); $welcometxt = $_POST['welcometext']; } else { - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (md5sum, comment) " . + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (md5sum, meta_comment) " . "VALUES ('welcometext', '".LinSql::linAddslashes($_POST['welcometext'])."')"); $welcometxt = $_POST['welcometext']; } Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -66,7 +66,7 @@ */ while( list($name, $value) = each($options) ) { - $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, userid) " . + $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, user_id) " . "VALUES ('".$name."', '".$value."', '0')"; } Modified: trunk/linpha2/install/sql/sql.mysql.php =================================================================== --- trunk/linpha2/install/sql/sql.mysql.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/sql/sql.mysql.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -26,15 +26,15 @@ "id INT NOT NULL AUTO_INCREMENT, " . "option_name VARCHAR(255) NOT NULL default '', " . "option_value VARCHAR(255) NOT NULL default '', " . - "userid INT default '0', " . - "override INT default '0', " . + "user_id SMALLINT default '0', " . + "override SMALLINT default '0', " . "PRIMARY KEY (id) " . ")", "CREATE TABLE ".$linpha_tables['users']." ( ". "id INT NOT NULL AUTO_INCREMENT , " . "username VARCHAR(255) NOT NULL default '' , " . "password VARCHAR(32) NOT NULL default '' , " . - "email VARCHAR(255) NOT NULL default '' , " . + "user_email VARCHAR(255) NOT NULL default '' , " . "display_name VARCHAR(255) NOT NULL default '' , " . "stats_downloads INT NOT NULL , " . "stats_downloads_size INT NOT NULL, " . @@ -75,12 +75,12 @@ "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_width SMALLINT NOT NULL default '0', " . + "img_height SMALLINT NOT NULL default '0', " . + "img_quality SMALLINT 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', " . + "is_rotated SMALLINT NOT NULL default '0', " . + "has_watermark SMALLINT 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', " . @@ -90,7 +90,7 @@ "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id INT NOT NULL AUTO_INCREMENT, " . "name VARCHAR(255) NOT NULL default '', " . - "field_type INT NOT NULL default '0', " . + "field_type SMALLINT NOT NULL default '0', " . "flags INT NOT NULL default '0', " . "PRIMARY KEY (id) " . ")", @@ -98,7 +98,7 @@ "id INT NOT NULL AUTO_INCREMENT, " . "field_id INT NOT NULL default '0', " . "name VARCHAR(255) NOT NULL default '', " . - "isprivate INT default NULL, " . + "isprivate SMALLINT default NULL, " . "PRIMARY KEY (id) " . ")", "CREATE TABLE ".$linpha_tables['meta_exif']." ( ". @@ -126,10 +126,10 @@ ")", "CREATE TABLE ".$linpha_tables['meta_comments']." ( ". "id INT NOT NULL AUTO_INCREMENT, " . - "time INT NOT NULL default '0', " . + "meta_time INT NOT NULL default '0', " . "md5sum VARCHAR(32) NOT NULL default '', " . - "author VARCHAR(255) NOT NULL default '', " . - "comment text NOT NULL, " . + "meta_author VARCHAR(255) NOT NULL default '', " . + "meta_comment text NOT NULL, " . " PRIMARY KEY (id) " . ")", "CREATE TABLE ".$linpha_tables['meta_data']." ( ". Modified: trunk/linpha2/install/sql/sql.postgres.php =================================================================== --- trunk/linpha2/install/sql/sql.postgres.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/sql/sql.postgres.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -26,14 +26,14 @@ "id SERIAL PRIMARY KEY, " . "option_name VARCHAR(255) NOT NULL default '', " . "option_value VARCHAR(255) NOT NULL default '', " . - "userid INT default '0', " . - "override INT default '0' " . + "user_id INT default '0', " . + "override SMALLINT default '0' " . ")", "CREATE TABLE ".$linpha_tables['users']." ( ". "id SERIAL PRIMARY KEY, " . "username VARCHAR(255) NOT NULL default '' , " . "password VARCHAR(32) NOT NULL default '' , " . - "email VARCHAR(255) NOT NULL default '' , " . + "user_email VARCHAR(255) NOT NULL default '' , " . "display_name VARCHAR(255) NOT NULL default '' , " . "stats_downloads INT NOT NULL default 0 , " . "stats_downloads_size INT NOT NULL default 0 " . @@ -69,12 +69,12 @@ "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_width SMALLINT NOT NULL default '0', " . + "img_height SMALLINT NOT NULL default '0', " . + "img_quality SMALLINT 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', " . + "is_rotated SMALLINT NOT NULL default '0', " . + "has_watermark SMALLINT 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', " . @@ -83,14 +83,14 @@ "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id SERIAL PRIMARY KEY, " . "name VARCHAR(255) NOT NULL default '', " . - "field_type INT NOT NULL default '0', " . + "field_type SMALLINT NOT NULL default '0', " . "flags INT NOT NULL default '0' " . ")", "CREATE TABLE ".$linpha_tables['meta_category']." ( ". "id SERIAL PRIMARY KEY, " . "field_id INT NOT NULL default '0', " . "name VARCHAR(255) NOT NULL default '', " . - "isprivate INT default NULL " . + "isprivate SMALLINT default NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_exif']." ( ". "md5sum VARCHAR(32) NOT NULL default '', " . @@ -113,10 +113,10 @@ ")", "CREATE TABLE ".$linpha_tables['meta_comments']." ( ". "id SERIAL PRIMARY KEY, " . - "time INT NOT NULL default '0', " . + "meta_time INT NOT NULL default '0', " . "md5sum VARCHAR(32) NOT NULL default '', " . - "author VARCHAR(255) NOT NULL default '', " . - "comment TEXT NOT NULL " . + "meta_author VARCHAR(255) NOT NULL default '', " . + "meta_comment TEXT NOT NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_data']." ( ". "id SERIAL PRIMARY KEY, " . Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -23,20 +23,20 @@ $sql_tables = array( "CREATE TABLE ".$linpha_tables['config']." ( ". - "id SMALLINT PRIMARY KEY, " . + "id INTEGER PRIMARY KEY, " . "option_name VARCHAR(255) NOT NULL default '', " . "option_value VARCHAR(255) NOT NULL default '', " . - "userid INT default '0', " . - "override INT default '0' " . + "user_id INTEGER default '0', " . + "override SMALLINT default '0' " . ")", "CREATE TABLE ".$linpha_tables['users']." ( ". "id INTEGER PRIMARY KEY, " . "username VARCHAR(255) NOT NULL default '' , " . "password VARCHAR(32) NOT NULL default '' , " . - "email VARCHAR(255) NOT NULL default '' , " . + "user_email VARCHAR(255) NOT NULL default '' , " . "display_name VARCHAR(255) NOT NULL default '' , " . - "stats_downloads INT NOT NULL default '0'' , " . - "stats_downloads_size INT NOT NULL default '0'' " . + "stats_downloads INTEGER NOT NULL default '0'' , " . + "stats_downloads_size INTEGER NOT NULL default '0'' " . ")", "CREATE TABLE ".$linpha_tables['groups']." ( ". "id INTEGER PRIMARY KEY, " . @@ -44,8 +44,8 @@ ")", "CREATE TABLE ".$linpha_tables['user_group']." ( ". "id INTEGER PRIMARY KEY, " . - "group_id INT NOT NULL default '0', " . - "user_id INT NOT NULL default '0'" . + "group_id INTEGER NOT NULL default '0', " . + "user_id INTEGER NULL default '0'" . ")", "CREATE TABLE ".$linpha_tables['permissions']." ( ". "id INTEGER PRIMARY KEY, " . @@ -69,12 +69,12 @@ "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_width SMALLINT NOT NULL default '0', " . + "img_height SMALLINT NOT NULL default '0', " . + "img_quality SMALLINT 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', " . + "is_rotated SMALLINT NOT NULL default '0', " . + "has_watermark SMALLINT 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', " . @@ -83,14 +83,14 @@ "CREATE TABLE ".$linpha_tables['meta_fields']." ( ". "id INTEGER PRIMARY KEY, " . "name VARCHAR(255) NOT NULL default '', " . - "field_type INTEGER NOT NULL default '0', " . + "field_type SMALLINT NOT NULL default '0', " . "flags INTEGER NOT NULL default '0' " . ")", "CREATE TABLE ".$linpha_tables['meta_category']." ( ". "id INTEGER PRIMARY KEY, " . "field_id INTEGER NOT NULL default '0', " . "name VARCHAR(255) NOT NULL default '', " . - "isprivate INTEGER default NULL " . + "isprivate SMALLINT default NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_exif']." ( ". "md5sum VARCHAR(32) NOT NULL default '', " . @@ -113,10 +113,10 @@ ")", "CREATE TABLE ".$linpha_tables['meta_comments']." ( ". "id INTEGER PRIMARY KEY, " . - "time INTEGER NOT NULL default '0', " . + "meta_time INTEGER NOT NULL default '0', " . "md5sum VARCHAR(32) NOT NULL default '', " . - "author VARCHAR(255) NOT NULL default '', " . - "comment text NOT NULL " . + "meta_author VARCHAR(255) NOT NULL default '', " . + "meta_comment text NOT NULL " . ")", "CREATE TABLE ".$linpha_tables['meta_data']." ( ". "id INTEGER PRIMARY KEY, " . Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/step11_finish.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -55,7 +55,7 @@ } echo "Adding linpha admin user... "; - $result = $linpha->db->Execute("INSERT INTO ".PREFIX."users (username, password, email) VALUES (" . + $result = $linpha->db->Execute("INSERT INTO ".PREFIX."users (username, password, user_email) VALUES (" . "'".LinSql::linAddslashes($_POST['admin_name'])."', " . "'".md5($_POST['admin_pass'])."', " . "'".LinSql::linAddslashes($_POST['admin_email'])."')"); Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/step2_requirements.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -124,7 +124,6 @@ list($convert_avail, $convert_path, $convert_version) = check_convert(); if($convert_avail) { - echo $convert_path ; /** * the imagemagick versions 6.1.1 - 6.1.3 contains a bug with the switch Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/install/step8_testing.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -28,6 +28,14 @@ include_once(LINPHA_DIR.'/install/header_html.php'); /** + * prevent php notices, as sqlite doesn't know about ports' + */ +if(false == isset($_SESSION['sql_port'])) +{ + $_SESSION['sql_dbport'] = "0"; +} + +/** * save settings from previous page */ if(isset($_POST['sql_prefix'])) @@ -156,8 +164,7 @@ * close connection and connect with just created user */ $test_conn = NewADOConnection($_SESSION['sql_dbtype']); - if(! $test_conn->Connect("$_SESSION['sql_hostname']:$_SESSION['sql_dbport']", - $random_user, $random_pass, $_SESSION['sql_dbname']) ) + if(! $test_conn->Connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $random_user, $random_pass, $_SESSION['sql_dbname']) ) { echo warning_msg(); echo "<br />".tr("Failed To Create New LinPHA User"); Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -820,16 +820,16 @@ if($query->RecordCount()==0) // insert { - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (meta_time, md5sum, meta_author, meta_comment)" . "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->id_current."','".linSql::linAddslashes($_POST['author'])."'," . "'".linSql::linAddslashes($_POST['comment'])."')"); } else // update { $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."meta_comments SET ". - "time = '".time()."', ". - "author = '".linSql::linAddslashes($_POST['author'])."', " . - "comment = '".linSql::linAddslashes($_POST['comment'])."' " . + "meta_time = '".time()."', ". + "meta_author = '".linSql::linAddslashes($_POST['author'])."', " . + "meta_comment = '".linSql::linAddslashes($_POST['comment'])."' " . "WHERE md5sum = '".$GLOBALS['linpha']->imgview->id_current."'"); } } @@ -837,7 +837,7 @@ /** * get data */ - $GLOBALS['linpha']->template->output['comment'] = $GLOBALS['linpha']->db->GetRow("SELECT id, time, author, comment FROM ".PREFIX."meta_comments"); + $GLOBALS['linpha']->template->output['comment'] = $GLOBALS['linpha']->db->GetRow("SELECT id, meta_time, meta_author, meta_comment FROM ".PREFIX."meta_comments"); } function viewImgCommon() @@ -882,7 +882,7 @@ $comment = $_POST['comment_text']; } - $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (time, md5sum, author, comment)" . + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."meta_comments (meta_time, md5sum, meta_author, meta_comment)" . "VALUES ('".time()."','".$GLOBALS['linpha']->imgview->md5sum."','".linSql::linAddslashes($_POST['author'])."'," . "'".linSql::linAddslashes($comment)."')"); } @@ -890,7 +890,7 @@ /** * get comments */ - $GLOBALS['linpha']->template->output['image_comments'] = $GLOBALS['linpha']->db->Execute("SELECT id, time, author, comment FROM ".PREFIX."meta_comments " . + $GLOBALS['linpha']->template->output['image_comments'] = $GLOBALS['linpha']->db->Execute("SELECT id, meta_time, meta_author, meta_comment FROM ".PREFIX."meta_comments " . "WHERE md5sum = '".$GLOBALS['linpha']->imgview->md5sum."'"); } } Modified: trunk/linpha2/templates/default/view_comment.html.php =================================================================== --- trunk/linpha2/templates/default/view_comment.html.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/templates/default/view_comment.html.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -4,9 +4,9 @@ <br /><br /> Author: -<input type="text" name="author" value="<?php echo $GLOBALS['linpha']->template->output['comment']['author']; ?>" size="40" maxlength="40" /> +<input type="text" name="author" value="<?php echo $GLOBALS['linpha']->template->output['meta_comment']['meta_author']; ?>" size="40" maxlength="40" /> <br /> -<textarea name="comment" rows="10" cols="50"><?php echo $GLOBALS['linpha']->template->output['comment']['comment']; ?></textarea> +<textarea name="comment" rows="10" cols="50"><?php echo $GLOBALS['linpha']->template->output['comment']['meta_comment']; ?></textarea> <br /> <input type="hidden" name="cmd" value="add_comment" /> <input type="submit" name="submit" value="submit" /> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-04-10 10:22:20 UTC (rev 4501) +++ trunk/linpha2/templates/default/view_img.html.php 2006-04-10 15:41:20 UTC (rev 4502) @@ -57,11 +57,11 @@ <br /><br /> <!-- show image comments --> - <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> + <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow(ADODB_FETCH_ASSOC)) { ?> <div class="comments"> - <?php echo $data['time']; ?> <?php echo $data['author']; ?> + <?php echo $data['meta_time']; ?> <?php echo $data['meta_author']; ?> <br /> - <?php echo $data['comment']; ?> + <?php echo $data['meta_comment']; ?> <br /><br /> </div> <?php } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-04-10 17:48:12
|
Revision: 4504 Author: bzrudi Date: 2006-04-10 10:47:47 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4504&view=rev Log Message: ----------- Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/admin/import.php trunk/linpha2/admin/permissions_groups.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_usergroup.php trunk/linpha2/admin/permissions_users.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/templates/default/view_meta.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/ChangeLog 2006-04-10 17:47:47 UTC (rev 4504) @@ -5,6 +5,7 @@ databases. - make sure to run reset_database.php! - ...still more to rename + - add ADODB_FETCH_ASSOC where we should have it, don't rely on defaults 2006-04-10 flo * fixed some eclipse warnings Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/image_fields_define.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -65,7 +65,7 @@ * get builtin fields */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags FROM ".PREFIX."meta_fields WHERE flags = '5' OR flags = '6' "); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<tr><td>'; echo $data['name']; @@ -135,7 +135,7 @@ </tr> <?php - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { ?> <tr> @@ -181,7 +181,7 @@ function show_add_data() { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '2'"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { ?> <h3><?php echo $data['name']; ?></h3> @@ -194,7 +194,7 @@ </tr> <?php $query2 = $GLOBALS['linpha']->db->Execute("SELECT id, name, isprivate FROM ".PREFIX."meta_category WHERE field_id = '".$data['id']."'"); - while($data2 = $query2->FetchRow()) + while($data2 = $query2->FetchRow(ADODB_FETCH_ASSOC)) { ?> <tr> Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/image_fields_select.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -70,7 +70,7 @@ <select id="select_image_fields" name="select_image_fields[]" size="25" style="width: 200px;" multiple="multiple"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<option value="'.$data['name'].'">'.$MetaData->getNameOfField($data['name'],true).'</option>'; } @@ -94,7 +94,7 @@ <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . "WHERE flags = '1' OR flags = '5'"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<option value="builtin_'.$data['name'].'">'.i18n( ucfirst( $data['name'] ) ).'</option>'; } @@ -112,7 +112,7 @@ <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . "WHERE flags = '7'"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<option value="id_'.$data['id'].'">'.$data['name'].'</option>'; } Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/import.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -20,7 +20,7 @@ * first, only for images */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { LinImage::createThumbnail($data['id'],$data['img_type'],$force=false); } Modified: trunk/linpha2/admin/permissions_groups.php =================================================================== --- trunk/linpha2/admin/permissions_groups.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/permissions_groups.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -75,7 +75,7 @@ </tr> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER BY group_name"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { ?> <tr> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/permissions_others.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -102,7 +102,7 @@ <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER by group_name"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { if(in_array($data['id'],$array_permissions)) { Modified: trunk/linpha2/admin/permissions_usergroup.php =================================================================== --- trunk/linpha2/admin/permissions_usergroup.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/permissions_usergroup.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -6,7 +6,7 @@ */ echo '<b>'.i18n("Edit Group Members").'</b><br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER by group_name"); -while($data = $query->FetchRow()) +while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_usergroup&edit=group&id='.$data['id'].'">'.$data['group_name'].'</a><br />'; } @@ -106,7 +106,7 @@ <select name="usergroup[]" size="5" style="width: 200;" multiple="multiple"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, ".$other_select_name." FROM ".PREFIX.$other_table_name." ORDER by ".$other_select_name); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { /** * check if selected Modified: trunk/linpha2/admin/permissions_users.php =================================================================== --- trunk/linpha2/admin/permissions_users.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/admin/permissions_users.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -91,7 +91,7 @@ * show users */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, username, display_name, user_email FROM ".PREFIX."users ORDER BY username"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { ?> <tr> Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -183,7 +183,7 @@ return false; } - $data = $query->FetchRow(); + $data = $query->FetchRow(ADODB_FETCH_ASSOC); if( ! LinSql::photoIsAllowed( $data['id'] ) ) { @@ -352,7 +352,7 @@ $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()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { if($i >= 4) { Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -76,7 +76,7 @@ function readInformations($full_filename,$filename,$md5sum,$flag_nr) { $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); - while($fields_data = $query->FetchRow()) + while($fields_data = $query->FetchRow(ADODB_FETCH_ASSOC)) { $name = MetaData::getNameOfField( $fields_data['name'], false ); $value = ''; Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -178,7 +178,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT username, display_name FROM ".PREFIX."users ". "WHERE id = '".LinSql::linAddslashes($_COOKIE['linpha_userid'])."' ". "AND password = '".LinSql::linAddslashes($_COOKIE['linpha_password'])."'"); - if($data = $query->FetchRow()) + if($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { //linpha_log('login','notice','User '.$_POST['user_name'].": successfully logged in."); linSysLog(i18n("Successfully Logged In!<br />")); @@ -336,7 +336,7 @@ * get user_groups */ $query = $GLOBALS['linpha']->db->Execute("SELECT group_id FROM ".PREFIX."user_group WHERE user_id = '".$userid."'"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { $_SESSION['user_groups'][] = $data['group_id']; } Modified: trunk/linpha2/templates/default/view_meta.html.php =================================================================== --- trunk/linpha2/templates/default/view_meta.html.php 2006-04-10 17:46:35 UTC (rev 4503) +++ trunk/linpha2/templates/default/view_meta.html.php 2006-04-10 17:47:47 UTC (rev 4504) @@ -22,7 +22,7 @@ <td rowspan="<?php echo $num+1; ?>"><?php echo $GLOBALS['linpha']->template->output['image']; ?></td> </tr> <?php - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { ?> <tr> @@ -55,7 +55,7 @@ <?php $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_category " . "WHERE field_id = '".$data['id']."'"); - while($cat_data = $cat_query->FetchRow()) + while($cat_data = $cat_query->FetchRow(ADODB_FETCH_ASSOC)) { if(in_array($cat_data['id'],$array_pieces)) { $checked = ' selected="selected"'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-10 21:25:52
|
Revision: 4507 Author: fangehrn Date: 2006-04-10 14:25:19 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4507&view=rev Log Message: ----------- * implement lightbox slideshow features things that work yet: autoplay, random play order Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/import.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/templates/default/css/global.css trunk/linpha2/templates/default/global.html.php Added Paths: ----------- trunk/linpha2/lib/classes/lightbox/ trunk/linpha2/lib/classes/lightbox/css/ trunk/linpha2/lib/classes/lightbox/css/lightbox.css trunk/linpha2/lib/classes/lightbox/effects.js trunk/linpha2/lib/classes/lightbox/images/ trunk/linpha2/lib/classes/lightbox/images/blank.gif trunk/linpha2/lib/classes/lightbox/images/close.gif trunk/linpha2/lib/classes/lightbox/images/closelabel.gif trunk/linpha2/lib/classes/lightbox/images/loading.gif trunk/linpha2/lib/classes/lightbox/images/next.gif trunk/linpha2/lib/classes/lightbox/images/nextlabel.gif trunk/linpha2/lib/classes/lightbox/images/prev.gif trunk/linpha2/lib/classes/lightbox/images/prevlabel.gif trunk/linpha2/lib/classes/lightbox/lightbox.js trunk/linpha2/lib/classes/lightbox/linpha_changes.txt trunk/linpha2/lib/classes/lightbox/prototype.js trunk/linpha2/lib/classes/lightbox/scriptaculous.js Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-10 19:22:28 UTC (rev 4506) +++ trunk/linpha2/ChangeLog 2006-04-10 21:25:19 UTC (rev 4507) @@ -10,6 +10,8 @@ 2006-04-10 flo * fixed some eclipse warnings * change linpha_photo.name form TEXT to varchar(255) + * implement lightbox slideshow features + things that work yet: autoplay, random play order 2006-04-09 flo * testing another way of setting the height of main div in javascript thumbnail viewer Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-04-10 19:22:28 UTC (rev 4506) +++ trunk/linpha2/admin/import.php 2006-04-10 21:25:19 UTC (rev 4507) @@ -16,13 +16,18 @@ * create thumbnails */ + $thumbnail = new LinImage(); + /** * first, only for images */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) { - LinImage::createThumbnail($data['id'],$data['img_type'],$force=false); + if( ! $thumbnail->createThumbnail($data['id']) ) + { + echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + } } /** Added: trunk/linpha2/lib/classes/lightbox/css/lightbox.css =================================================================== --- trunk/linpha2/lib/classes/lightbox/css/lightbox.css (rev 0) +++ trunk/linpha2/lib/classes/lightbox/css/lightbox.css 2006-04-10 21:25:19 UTC (rev 4507) @@ -0,0 +1,104 @@ +#lightbox{ + position: absolute; + top: 40px; + left: 0; + width: 100%; + z-index: 100; + text-align: center; + line-height: 0; + } + +#lightbox a img{ border: none; } + +#outerImageContainer{ + position: relative; + background-color: #fff; + width: 250px; + height: 250px; + margin: 0 auto; + } + +#imageContainer{ + padding: 10px; + } + +#loading{ + position: absolute; + top: 40%; + left: 0%; + height: 25%; + width: 100%; + text-align: center; + line-height: 0; + } +#hoverNav{ + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 10; + } +#imageContainer>#hoverNav{ left: 0;} +#hoverNav a{ outline: none;} + +#prevLink, #nextLink{ + width: 49%; + height: 100%; + background: transparent url(../images/blank.gif) no-repeat; /* Trick IE into showing hover */ + display: block; + } +#prevLink { left: 0; float: left;} +#nextLink { right: 0; float: right;} +#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; } +#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; } + + +#imageDataContainer{ + font: 10px Verdana, Helvetica, sans-serif; + background-color: #fff; + margin: 0 auto; + line-height: 1.4em; + } + +#imageData{ + padding:0 10px; + } +#imageData #imageDetails{ width: 70%; float: left; text-align: left; } +#imageData #caption{ font-weight: bold; } +#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; } +#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; } + +#overlay{ + position: absolute; + top: 0; + left: 0; + z-index: 90; + width: 100%; + height: 500px; + background-color: #000; + filter:alpha(opacity=60); + -moz-opacity: 0.6; + opacity: 0.6; + } + + +.clearfix:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + } + +* html>body .clearfix { + display: inline-block; + width: 100%; + } + +* html .clearfix { + /* Hides from IE-mac \*/ + height: 1%; + /* End hide from IE-mac */ + } + \ No newline at end of file Added: trunk/linpha2/lib/classes/lightbox/effects.js =================================================================== --- trunk/linpha2/lib/classes/lightbox/effects.js (rev 0) +++ trunk/linpha2/lib/classes/lightbox/effects.js 2006-04-10 21:25:19 UTC (rev 4507) @@ -0,0 +1,903 @@ +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Contributors: +// Justin Palmer (http://encytemedia.com/) +// Mark Pilgrim (http://diveintomark.org/) +// Martin Bialasinki +// +// See scriptaculous.js for full license. + +/* ------------- element ext -------------- */ + +// converts rgb() and #xxx to #xxxxxx format, +// returns self (or first argument) if not convertable +String.prototype.parseColor = function() { + var color = '#'; + if(this.slice(0,4) == 'rgb(') { + var cols = this.slice(4,this.length-1).split(','); + var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); + } else { + if(this.slice(0,1) == '#') { + if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); + if(this.length==7) color = this.toLowerCase(); + } + } + return(color.length==7 ? color : (arguments[0] || this)); +} + +Element.collectTextNodes = function(element) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); + }).flatten().join(''); +} + +Element.collectTextNodesIgnoreClass = function(element, className) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? + Element.collectTextNodes(node) : '')); + }).flatten().join(''); +} + +Element.setStyle = function(element, style) { + element = $(element); + for(k in style) element.style[k.camelize()] = style[k]; +} + +Element.setContentZoom = function(element, percent) { + Element.setStyle(element, {fontSize: (percent/100) + 'em'}); + if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); +} + +Element.getOpacity = function(element){ + var opacity; + if (opacity = Element.getStyle(element, 'opacity')) + return parseFloat(opacity); + if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) + if(opacity[1]) return parseFloat(opacity[1]) / 100; + return 1.0; +} + +Element.setOpacity = function(element, value){ + element= $(element); + if (value == 1){ + Element.setStyle(element, { opacity: + (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? + 0.999999 : null }); + if(/MSIE/.test(navigator.userAgent)) + Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); + } else { + if(value < 0.00001) value = 0; + Element.setStyle(element, {opacity: value}); + if(/MSIE/.test(navigator.userAgent)) + Element.setStyle(element, + { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + + 'alpha(opacity='+value*100+')' }); + } +} + +Element.getInlineOpacity = function(element){ + return $(element).style.opacity || ''; +} + +Element.childrenWithClassName = function(element, className) { + return $A($(element).getElementsByTagName('*')).select( + function(c) { return Element.hasClassName(c, className) }); +} + +Array.prototype.call = function() { + var args = arguments; + this.each(function(f){ f.apply(this, args) }); +} + +/*--------------------------------------------------------------------------*/ + +var Effect = { + tagifyText: function(element) { + var tagifyStyle = 'position:relative'; + if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; + element = $(element); + $A(element.childNodes).each( function(child) { + if(child.nodeType==3) { + child.nodeValue.toArray().each( function(character) { + element.insertBefore( + Builder.node('span',{style: tagifyStyle}, + character == ' ' ? String.fromCharCode(160) : character), + child); + }); + Element.remove(child); + } + }); + }, + multiple: function(element, effect) { + var elements; + if(((typeof element == 'object') || + (typeof element == 'function')) && + (element.length)) + elements = element; + else + elements = $(element).childNodes; + + var options = Object.extend({ + speed: 0.1, + delay: 0.0 + }, arguments[2] || {}); + var masterDelay = options.delay; + + $A(elements).each( function(element, index) { + new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); + }); + }, + PAIRS: { + 'slide': ['SlideDown','SlideUp'], + 'blind': ['BlindDown','BlindUp'], + 'appear': ['Appear','Fade'] + }, + toggle: function(element, effect) { + element = $(element); + effect = (effect || 'appear').toLowerCase(); + var options = Object.extend({ + queue: { position:'end', scope:(element.id || 'global') } + }, arguments[2] || {}); + Effect[Element.visible(element) ? + Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); + } +}; + +var Effect2 = Effect; // deprecated + +/* ------------- transitions ------------- */ + +Effect.Transitions = {} + +Effect.Transitions.linear = function(pos) { + return pos; +} +Effect.Transitions.sinoidal = function(pos) { + return (-Math.cos(pos*Math.PI)/2) + 0.5; +} +Effect.Transitions.reverse = function(pos) { + return 1-pos; +} +Effect.Transitions.flicker = function(pos) { + return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; +} +Effect.Transitions.wobble = function(pos) { + return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; +} +Effect.Transitions.pulse = function(pos) { + return (Math.floor(pos*10) % 2 == 0 ? + (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); +} +Effect.Transitions.none = function(pos) { + return 0; +} +Effect.Transitions.full = function(pos) { + return 1; +} + +/* ------------- core effects ------------- */ + +Effect.ScopedQueue = Class.create(); +Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), { + initialize: function() { + this.effects = []; + this.interval = null; + }, + _each: function(iterator) { + this.effects._each(iterator); + }, + add: function(effect) { + var timestamp = new Date().getTime(); + + var position = (typeof effect.options.queue == 'string') ? + effect.options.queue : effect.options.queue.position; + + switch(position) { + case 'front': + // move unstarted effects after this effect + this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { + e.startOn += effect.finishOn; + e.finishOn += effect.finishOn; + }); + break; + case 'end': + // start effect after last queued effect has finished + timestamp = this.effects.pluck('finishOn').max() || timestamp; + break; + } + + effect.startOn += timestamp; + effect.finishOn += timestamp; + this.effects.push(effect); + if(!this.interval) + this.interval = setInterval(this.loop.bind(this), 40); + }, + remove: function(effect) { + this.effects = this.effects.reject(function(e) { return e==effect }); + if(this.effects.length == 0) { + clearInterval(this.interval); + this.interval = null; + } + }, + loop: function() { + var timePos = new Date().getTime(); + this.effects.invoke('loop', timePos); + } +}); + +Effect.Queues = { + instances: $H(), + get: function(queueName) { + if(typeof queueName != 'string') return queueName; + + if(!this.instances[queueName]) + this.instances[queueName] = new Effect.ScopedQueue(); + + return this.instances[queueName]; + } +} +Effect.Queue = Effect.Queues.get('global'); + +Effect.DefaultOptions = { + transition: Effect.Transitions.sinoidal, + duration: 1.0, // seconds + fps: 25.0, // max. 25fps due to Effect.Queue implementation + sync: false, // true for combining + from: 0.0, + to: 1.0, + delay: 0.0, + queue: 'parallel' +} + +Effect.Base = function() {}; +Effect.Base.prototype = { + position: null, + start: function(options) { + this.options = Object.extend(Object.extend({},Effect.DefaultOptions), options || {}); + this.currentFrame = 0; + this.state = 'idle'; + this.startOn = this.options.delay*1000; + this.finishOn = this.startOn + (this.options.duration*1000); + this.event('beforeStart'); + if(!this.options.sync) + Effect.Queues.get(typeof this.options.queue == 'string' ? + 'global' : this.options.queue.scope).add(this); + }, + loop: function(timePos) { + if(timePos >= this.startOn) { + if(timePos >= this.finishOn) { + this.render(1.0); + this.cancel(); + this.event('beforeFinish'); + if(this.finish) this.finish(); + this.event('afterFinish'); + return; + } + var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); + var frame = Math.round(pos * this.options.fps * this.options.duration); + if(frame > this.currentFrame) { + this.render(pos); + this.currentFrame = frame; + } + } + }, + render: function(pos) { + if(this.state == 'idle') { + this.state = 'running'; + this.event('beforeSetup'); + if(this.setup) this.setup(); + this.event('afterSetup'); + } + if(this.state == 'running') { + if(this.options.transition) pos = this.options.transition(pos); + pos *= (this.options.to-this.options.from); + pos += this.options.from; + this.position = pos; + this.event('beforeUpdate'); + if(this.update) this.update(pos); + this.event('afterUpdate'); + } + }, + cancel: function() { + if(!this.options.sync) + Effect.Queues.get(typeof this.options.queue == 'string' ? + 'global' : this.options.queue.scope).remove(this); + this.state = 'finished'; + }, + event: function(eventName) { + if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); + if(this.options[eventName]) this.options[eventName](this); + }, + inspect: function() { + return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>'; + } +} + +Effect.Parallel = Class.create(); +Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), { + initialize: function(effects) { + this.effects = effects || []; + this.start(arguments[1]); + }, + update: function(position) { + this.effects.invoke('render', position); + }, + finish: function(position) { + this.effects.each( function(effect) { + effect.render(1.0); + effect.cancel(); + effect.event('beforeFinish'); + if(effect.finish) effect.finish(position); + effect.event('afterFinish'); + }); + } +}); + +Effect.Opacity = Class.create(); +Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + // make this work on IE on elements without 'layout' + if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) + Element.setStyle(this.element, {zoom: 1}); + var options = Object.extend({ + from: Element.getOpacity(this.element) || 0.0, + to: 1.0 + }, arguments[1] || {}); + this.start(options); + }, + update: function(position) { + Element.setOpacity(this.element, position); + } +}); + +Effect.Move = Class.create(); +Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + var options = Object.extend({ + x: 0, + y: 0, + mode: 'relative' + }, arguments[1] || {}); + this.start(options); + }, + setup: function() { + // Bug in Opera: Opera returns the "real" position of a static element or + // relative element that does not have top/left explicitly set. + // ==> Always set top and left for position relative elements in your stylesheets + // (to 0 if you do not need them) + Element.makePositioned(this.element); + this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); + this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0'); + if(this.options.mode == 'absolute') { + // absolute movement, so we need to calc deltaX and deltaY + this.options.x = this.options.x - this.originalLeft; + this.options.y = this.options.y - this.originalTop; + } + }, + update: function(position) { + Element.setStyle(this.element, { + left: this.options.x * position + this.originalLeft + 'px', + top: this.options.y * position + this.originalTop + 'px' + }); + } +}); + +// for backwards compatibility +Effect.MoveBy = function(element, toTop, toLeft) { + return new Effect.Move(element, + Object.extend({ x: toLeft, y: toTop }, arguments[3] || {})); +}; + +Effect.Scale = Class.create(); +Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { + initialize: function(element, percent) { + this.element = $(element) + var options = Object.extend({ + scaleX: true, + scaleY: true, + scaleContent: true, + scaleFromCenter: false, + scaleMode: 'box', // 'box' or 'contents' or {} with provided values + scaleFrom: 100.0, + scaleTo: percent + }, arguments[2] || {}); + this.start(options); + }, + setup: function() { + this.restoreAfterFinish = this.options.restoreAfterFinish || false; + this.elementPositioning = Element.getStyle(this.element,'position'); + + this.originalStyle = {}; + ['top','left','width','height','fontSize'].each( function(k) { + this.originalStyle[k] = this.element.style[k]; + }.bind(this)); + + this.originalTop = this.element.offsetTop; + this.originalLeft = this.element.offsetLeft; + + var fontSize = Element.getStyle(this.element,'font-size') || '100%'; + ['em','px','%'].each( function(fontSizeType) { + if(fontSize.indexOf(fontSizeType)>0) { + this.fontSize = parseFloat(fontSize); + this.fontSizeType = fontSizeType; + } + }.bind(this)); + + this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; + + this.dims = null; + if(this.options.scaleMode=='box') + this.dims = [this.element.offsetHeight, this.element.offsetWidth]; + if(/^content/.test(this.options.scaleMode)) + this.dims = [this.element.scrollHeight, this.element.scrollWidth]; + if(!this.dims) + this.dims = [this.options.scaleMode.originalHeight, + this.options.scaleMode.originalWidth]; + }, + update: function(position) { + var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); + if(this.options.scaleContent && this.fontSize) + Element.setStyle(this.element, {fontSize: this.fontSize * currentScale + this.fontSizeType }); + this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); + }, + finish: function(position) { + if (this.restoreAfterFinish) Element.setStyle(this.element, this.originalStyle); + }, + setDimensions: function(height, width) { + var d = {}; + if(this.options.scaleX) d.width = width + 'px'; + if(this.options.scaleY) d.height = height + 'px'; + if(this.options.scaleFromCenter) { + var topd = (height - this.dims[0])/2; + var leftd = (width - this.dims[1])/2; + if(this.elementPositioning == 'absolute') { + if(this.options.scaleY) d.top = this.originalTop-topd + 'px'; + if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; + } else { + if(this.options.scaleY) d.top = -topd + 'px'; + if(this.options.scaleX) d.left = -leftd + 'px'; + } + } + Element.setStyle(this.element, d); + } +}); + +Effect.Highlight = Class.create(); +Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); + this.start(options); + }, + setup: function() { + // Prevent executing on elements not in the layout flow + if(Element.getStyle(this.element, 'display')=='none') { this.cancel(); return; } + // Disable background image during the effect + this.oldStyle = { + backgroundImage: Element.getStyle(this.element, 'background-image') }; + Element.setStyle(this.element, {backgroundImage: 'none'}); + if(!this.options.endcolor) + this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff'); + if(!this.options.restorecolor) + this.options.restorecolor = Element.getStyle(this.element, 'background-color'); + // init color calculations + this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); + this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); + }, + update: function(position) { + Element.setStyle(this.element,{backgroundColor: $R(0,2).inject('#',function(m,v,i){ + return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) }); + }, + finish: function() { + Element.setStyle(this.element, Object.extend(this.oldStyle, { + backgroundColor: this.options.restorecolor + })); + } +}); + +Effect.ScrollTo = Class.create(); +Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), { + initialize: function(element) { + this.element = $(element); + this.start(arguments[1] || {}); + }, + setup: function() { + Position.prepare(); + var offsets = Position.cumulativeOffset(this.element); + if(this.options.offset) offsets[1] += this.options.offset; + var max = window.innerHeight ? + window.height - window.innerHeight : + document.body.scrollHeight - + (document.documentElement.clientHeight ? + document.documentElement.clientHeight : document.body.clientHeight); + this.scrollStart = Position.deltaY; + this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart; + }, + update: function(position) { + Position.prepare(); + window.scrollTo(Position.deltaX, + this.scrollStart + (position*this.delta)); + } +}); + +/* ------------- combination effects ------------- */ + +Effect.Fade = function(element) { + var oldOpacity = Element.getInlineOpacity(element); + var options = Object.extend({ + from: Element.getOpacity(element) || 1.0, + to: 0.0, + afterFinishInternal: function(effect) { with(Element) { + if(effect.options.to!=0) return; + hide(effect.element); + setStyle(effect.element, {opacity: oldOpacity}); }} + }, arguments[1] || {}); + return new Effect.Opacity(element,options); +} + +Effect.Appear = function(element) { + var options = Object.extend({ + from: (Element.getStyle(element, 'display') == 'none' ? 0.0 : Element.getOpacity(element) || 0.0), + to: 1.0, + beforeSetup: function(effect) { with(Element) { + setOpacity(effect.element, effect.options.from); + show(effect.element); }} + }, arguments[1] || {}); + return new Effect.Opacity(element,options); +} + +Effect.Puff = function(element) { + element = $(element); + var oldStyle = { opacity: Element.getInlineOpacity(element), position: Element.getStyle(element, 'position') }; + return new Effect.Parallel( + [ new Effect.Scale(element, 200, + { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], + Object.extend({ duration: 1.0, + beforeSetupInternal: function(effect) { with(Element) { + setStyle(effect.effects[0].element, {position: 'absolute'}); }}, + afterFinishInternal: function(effect) { with(Element) { + hide(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, arguments[1] || {}) + ); +} + +Effect.BlindUp = function(element) { + element = $(element); + Element.makeClipping(element); + return new Effect.Scale(element, 0, + Object.extend({ scaleContent: false, + scaleX: false, + restoreAfterFinish: true, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); }} + }, arguments[1] || {}) + ); +} + +Effect.BlindDown = function(element) { + element = $(element); + var oldHeight = Element.getStyle(element, 'height'); + var elementDimensions = Element.getDimensions(element); + return new Effect.Scale(element, 100, + Object.extend({ scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { with(Element) { + makeClipping(effect.element); + setStyle(effect.element, {height: '0px'}); + show(effect.element); + }}, + afterFinishInternal: function(effect) { with(Element) { + undoClipping(effect.element); + setStyle(effect.element, {height: oldHeight}); + }} + }, arguments[1] || {}) + ); +} + +Effect.SwitchOff = function(element) { + element = $(element); + var oldOpacity = Element.getInlineOpacity(element); + return new Effect.Appear(element, { + duration: 0.4, + from: 0, + transition: Effect.Transitions.flicker, + afterFinishInternal: function(effect) { + new Effect.Scale(effect.element, 1, { + duration: 0.3, scaleFromCenter: true, + scaleX: false, scaleContent: false, restoreAfterFinish: true, + beforeSetup: function(effect) { with(Element) { + [makePositioned,makeClipping].call(effect.element); + }}, + afterFinishInternal: function(effect) { with(Element) { + [hide,undoClipping,undoPositioned].call(effect.element); + setStyle(effect.element, {opacity: oldOpacity}); + }} + }) + } + }); +} + +Effect.DropOut = function(element) { + element = $(element); + var oldStyle = { + top: Element.getStyle(element, 'top'), + left: Element.getStyle(element, 'left'), + opacity: Element.getInlineOpacity(element) }; + return new Effect.Parallel( + [ new Effect.Move(element, {x: 0, y: 100, sync: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 }) ], + Object.extend( + { duration: 0.5, + beforeSetup: function(effect) { with(Element) { + makePositioned(effect.effects[0].element); }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, arguments[1] || {})); +} + +Effect.Shake = function(element) { + element = $(element); + var oldStyle = { + top: Element.getStyle(element, 'top'), + left: Element.getStyle(element, 'left') }; + return new Effect.Move(element, + { x: 20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: 40, y: 0, duration: 0.1, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { with(Element) { + undoPositioned(effect.element); + setStyle(effect.element, oldStyle); + }}}) }}) }}) }}) }}) }}); +} + +Effect.SlideDown = function(element) { + element = $(element); + Element.cleanWhitespace(element); + // SlideDown need to have the content of the element wrapped in a container element with fixed height! + var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); + var elementDimensions = Element.getDimensions(element); + return new Effect.Scale(element, 100, Object.extend({ + scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { with(Element) { + makePositioned(effect.element); + makePositioned(effect.element.firstChild); + if(window.opera) setStyle(effect.element, {top: ''}); + makeClipping(effect.element); + setStyle(effect.element, {height: '0px'}); + show(element); }}, + afterUpdateInternal: function(effect) { with(Element) { + setStyle(effect.element.firstChild, {bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, + afterFinishInternal: function(effect) { with(Element) { + undoClipping(effect.element); + undoPositioned(effect.element.firstChild); + undoPositioned(effect.element); + setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} + }, arguments[1] || {}) + ); +} + +Effect.SlideUp = function(element) { + element = $(element); + Element.cleanWhitespace(element); + var oldInnerBottom = Element.getStyle(element.firstChild, 'bottom'); + return new Effect.Scale(element, 0, + Object.extend({ scaleContent: false, + scaleX: false, + scaleMode: 'box', + scaleFrom: 100, + restoreAfterFinish: true, + beforeStartInternal: function(effect) { with(Element) { + makePositioned(effect.element); + makePositioned(effect.element.firstChild); + if(window.opera) setStyle(effect.element, {top: ''}); + makeClipping(effect.element); + show(element); }}, + afterUpdateInternal: function(effect) { with(Element) { + setStyle(effect.element.firstChild, {bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); + undoPositioned(effect.element.firstChild); + undoPositioned(effect.element); + setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); }} + }, arguments[1] || {}) + ); +} + +// Bug in opera makes the TD containing this element expand for a instance after finish +Effect.Squish = function(element) { + return new Effect.Scale(element, window.opera ? 1 : 0, + { restoreAfterFinish: true, + beforeSetup: function(effect) { with(Element) { + makeClipping(effect.element); }}, + afterFinishInternal: function(effect) { with(Element) { + hide(effect.element); + undoClipping(effect.element); }} + }); +} + +Effect.Grow = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransistion: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.full + }, arguments[1] || {}); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: Element.getInlineOpacity(element) }; + + var dims = Element.getDimensions(element); + var initialMoveX, initialMoveY; + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + initialMoveX = initialMoveY = moveX = moveY = 0; + break; + case 'top-right': + initialMoveX = dims.width; + initialMoveY = moveY = 0; + moveX = -dims.width; + break; + case 'bottom-left': + initialMoveX = moveX = 0; + initialMoveY = dims.height; + moveY = -dims.height; + break; + case 'bottom-right': + initialMoveX = dims.width; + initialMoveY = dims.height; + moveX = -dims.width; + moveY = -dims.height; + break; + case 'center': + initialMoveX = dims.width / 2; + initialMoveY = dims.height / 2; + moveX = -dims.width / 2; + moveY = -dims.height / 2; + break; + } + + return new Effect.Move(element, { + x: initialMoveX, + y: initialMoveY, + duration: 0.01, + beforeSetup: function(effect) { with(Element) { + hide(effect.element); + makeClipping(effect.element); + makePositioned(effect.element); + }}, + afterFinishInternal: function(effect) { + new Effect.Parallel( + [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), + new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), + new Effect.Scale(effect.element, 100, { + scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, + sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) + ], Object.extend({ + beforeSetup: function(effect) { with(Element) { + setStyle(effect.effects[0].element, {height: '0px'}); + show(effect.effects[0].element); }}, + afterFinishInternal: function(effect) { with(Element) { + [undoClipping, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, options) + ) + } + }); +} + +Effect.Shrink = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransistion: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.none + }, arguments[1] || {}); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: Element.getInlineOpacity(element) }; + + var dims = Element.getDimensions(element); + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + moveX = moveY = 0; + break; + case 'top-right': + moveX = dims.width; + moveY = 0; + break; + case 'bottom-left': + moveX = 0; + moveY = dims.height; + break; + case 'bottom-right': + moveX = dims.width; + moveY = dims.height; + break; + case 'center': + moveX = dims.width / 2; + moveY = dims.height / 2; + break; + } + + return new Effect.Parallel( + [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), + new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), + new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) + ], Object.extend({ + beforeStartInternal: function(effect) { with(Element) { + [makePositioned, makeClipping].call(effect.effects[0].element) }}, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping, undoPositioned].call(effect.effects[0].element); + setStyle(effect.effects[0].element, oldStyle); }} + }, options) + ); +} + +Effect.Pulsate = function(element) { + element = $(element); + var options = arguments[1] || {}; + var oldOpacity = Element.getInlineOpacity(element); + var transition = options.transition || Effect.Transitions.sinoidal; + var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; + reverser.bind(transition); + return new Effect.Opacity(element, + Object.extend(Object.extend({ duration: 3.0, from: 0, + afterFinishInternal: function(effect) { Element.setStyle(effect.element, {opacity: oldOpacity}); } + }, options), {transition: reverser})); +} + +Effect.Fold = function(element) { + element = $(element); + var oldStyle = { + top: element.style.top, + left: element.style.left, + width: element.style.width, + height: element.style.height }; + Element.makeClipping(element); + return new Effect.Scale(element, 5, Object.extend({ + scaleContent: false, + scaleX: false, + afterFinishInternal: function(effect) { + new Effect.Scale(element, 1, { + scaleContent: false, + scaleY: false, + afterFinishInternal: function(effect) { with(Element) { + [hide, undoClipping].call(effect.element); + setStyle(effect.element, oldStyle); + }} }); + }}, arguments[1] || {})); +} Added: trunk/linpha2/lib/classes/lightbox/images/blank.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/blank.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/close.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/close.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/closelabel.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/closelabel.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/loading.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/loading.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/next.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/next.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/nextlabel.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/nextlabel.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/prev.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/prev.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/images/prevlabel.gif =================================================================== (Binary files differ) Property changes on: trunk/linpha2/lib/classes/lightbox/images/prevlabel.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/linpha2/lib/classes/lightbox/lightbox.js =================================================================== --- trunk/linpha2/lib/classes/lightbox/lightbox.js (rev 0) +++ trunk/linpha2/lib/classes/lightbox/lightbox.js 2006-04-10 21:25:19 UTC (rev 4507) @@ -0,0 +1,689 @@ +// ----------------------------------------------------------------------------------- +// +// Lightbox v2.01 +// by Lokesh Dhakar - http://www.huddletogether.com +// 3/31/06 +// +// For more information on this script, visit: +// http://huddletogether.com/projects/lightbox2/ +// +// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ +// +// Credit also due to those who have helped, inspired, and made their code available to the public. +// Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.org), Thomas Fuchs(mir.aculo.us), and others. +// +// +// ----------------------------------------------------------------------------------- +/* + + Table of Contents + ----------------- + Configuration + Global Variables + + Extending Built-in Objects + - Object.extend(Element) + - Array.prototype.removeDuplicates() + - Array.prototype.empty() + + Lightbox Class Declaration + - initialize() + - start() + - changeImage() + - resizeImageContainer() + - showImage() + - updateDetails() + - updateNav() + - enableKeyboardNav() + - disableKeyboardNav() + - keyboardAction() + - preloadNeighborImages() + - end() + + Miscellaneous Functions + - getPageScroll() + - getPageSize() + - getKey() + - listenKey() + - showSelectBoxes() + - hideSelectBoxes() + - pause() + - initLightbox() + + Function Calls + - addLoadEvent(initLightbox) + +*/ +// ----------------------------------------------------------------------------------- + +// +// Configuration +// +//var fileLoadingImage = "images/loading.gif"; +//var fileBottomNavCloseImage = "images/closelabel.gif"; + +var resizeSpeed = 7; // controls the speed of the image resizing (1=slowest and 10=fastest) + +var borderSize = 10; //if you adjust the padding in the CSS, you will need to update this variable + +// ----------------------------------------------------------------------------------- + +// +// Global Variables +// +//var imageArray = new Array; +var activeImage; + +if(resizeSpeed > 10){ resizeSpeed = 10;} +if(resizeSpeed < 1){ resizeSpeed = 1;} +resizeDuration = (11 - resizeSpeed) * 0.15; + +// ----------------------------------------------------------------------------------- + +// +// Additional methods for Element added by SU, Couloir +// - further additions by Lokesh Dhakar (huddletogether.com) +// +Object.extend(Element, { + getWidth: function(element) { + element = $(element); + return element.offsetWidth; + }, + setWidth: function(element,w) { + element = $(element); + element.style.width = w +"px"; + }, + setHeight: function(element,h) { + element = $(element); + element.style.height = h +"px"; + }, + setTop: function(element,t) { + element = $(element); + element.style.top = t +"px"; + }, + setSrc: function(element,src) { + element = $(element); + element.src = setImageUrl(src); + }, + setHref: function(element,href) { + element = $(element); + element.href = href; + }, + setInnerHTML: function(element,content) { + element = $(element); + element.innerHTML = content; + } +}); + +// ----------------------------------------------------------------------------------- + +// +// Extending built-in Array object +// - array.removeDuplicates() +// - array.empty() +// +Array.prototype.removeDuplicates = function () { + for(i = 1; i < this.length; i++){ + if(this[i][0] == this[i-1][0]){ + this.splice(i,1); + } + } +} + +// ----------------------------------------------------------------------------------- + +Array.prototype.empty = function () { + for(i = 0; i <= this.length; i++){ + this.shift(); + } +} + +// ----------------------------------------------------------------------------------- + +// +// Lightbox Class Declaration +// - initialize() +// - start() +// - changeImage() +// - resizeImageContainer() +// - showImage() +// - updateDetails() +// - updateNav() +// - enableKeyboardNav() +// - disableKeyboardNav() +// - keyboardNavAction() +// - preloadNeighborImages() +// - end() +// +// Structuring of code inspired by Scott Upton (http://www.uptonic.com/) +// +var Lightbox = Class.create(); + +Lightbox.prototype = { + + // initialize() + // Constructor runs on completion of the DOM loading. Loops through anchor tags looking for + // 'lightbox' references and applies onclick events to appropriate links. The 2nd section of + // the function inserts html at the bottom of the page which is used to display the shadow + // overlay and the image container. + // + initialize: function() { +/* if (!document.getElementsByTagName){ return; } + var anchors = document.getElementsByTagName('a'); + + // loop through all anchor tags + for (var i=0; i<anchors.length; i++){ + var anchor = anchors[i]; + + var relAttribute = String(anchor.getAttribute('rel')); + + // use the string.match() method to catch 'lightbox' references in the rel attribute + if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){ + anchor.onclick = function () {myLightbox.start(this); return false;} + } + }*/ + + // The rest of this code inserts html at the bottom of the page that looks similar to this: + // + // <div id="overlay"></div> + // <div id="lightbox"> + // <div id="outerImageContainer"> + // <div id="imageContainer"> + // <img id="lightboxImage"> + // <div style="" id="hoverNav"> + // <a href="#" id="prevLink"></a> + // <a href="#" id="nextLink"></a> + // </div> + // <div id="loading"> + // <a href="#" id="loadingLink"> + // <img src="images/loading.gif"> + // </a> + // </div> + // </div> + // </div> + // <div id="imageDataContainer"> + // <div id="imageData"> + // <div id="imageDetails"> + // <span id="caption"></span> + // <span id="numberDisplay"></span> + // </div> + // <div id="bottomNav"> + // <a href="#" id="bottomNavClose"> + // <img src="images/close.gif"> + // </a> + // </div> + // </div> + // </div> + // </div> + + + var objBody = document.getElementsByTagName("body").item(0); + + var objOverlay = document.createElement("div"); + objOverlay.setAttribute('id','overlay'); + objOverlay.style.display = 'none'; + objOverlay.onclick = function() { myLightbox.end(); return false; } + objBody.appendChild(objOverlay); + + var objLightbox = document.createElement("div"); + objLightbox.setAttribute('id','lightbox'); + objLightbox.style.display = 'none'; + objBody.appendChild(objLightbox); + + var objOuterImageContainer = document.createElement("div"); + objOuterImageContainer.setAttribute('id','outerImageContainer'); + objLightbox.appendChild(objOuterImageContainer); + + var objImageContainer = document.createElement("div"); + objImageContainer.setAttribute('id','imageContainer'); + objOuterImageContainer.appendChild(objImageContainer); + + var objLightboxImage = document.createElement("img"); + objLightboxImage.setAttribute('id','lightboxImage'); + objImageContainer.appendChild(objLightboxImage); + + var objHoverNav = document.createElement("div"); + objHoverNav.setAttribute('id','hoverNav'); + objImageContainer.appendChild(objHoverNav); + + var objPrevLink = document.createElement("a"); + objPrevLink.setAttribute('id','prevLink'); + objPrevLink.setAttribute('href','#'); + objHoverNav.appendChild(objPrevLink); + + var objNextLink = document.createElement("a"); + objNextLink.setAttribute('id','nextLink'); + objNextLink.setAttribute('href','#'); + objHoverNav.appendChild(objNextLink); + + var objLoading = document.createElement("div"); + objLoading.setAttribute('id','loading'); + objImageContainer.appendChild(objLoading); + + var objLoadingLink = document.createElement("a"); + objLoadingLink.setAttribute('id','loadingLink'); + objLoadingLink.setAttribute('href','#'); + objLoadingLink.onclick = function() { myLightbox.end(); return false; } + objLoading.appendChild(objLoadingLink); + + var objLoadingImage = document.createElement("img"); + objLoadingImage.setAttribute('src', fileLoadingImage); + objLoadingLink.appendChild(objLoadingImage); + + var objImageDataContainer = document.createElement("div"); + objImageDataContainer.setAttribute('id','imageDataContainer'); + objImageDataContainer.className = 'clearfix'; + objLightbox.appendChild(objImageDataContainer); + + var objImageData = document.createElement("div"); + objImageData.setAttribute('id','imageData'); + objImageDataContainer.appendChild(objImageData); + + var objImageDetails = document.createElement("div"); + objImageDetails.setAttribute('id','imageDetails'); + objImageData.appendChild(objImageDetails); + + var objCaption = document.createElement("span"); + objCaption.setAttribute('id','caption'); + objImageDetails.appendChild(objCaption); + + var objNumberDisplay = document.createElement("span"); + objNumberDisplay.setAttribute('id','numberDisplay'); + objImageDetails.appendChild(objNumberDisplay); + + var objBottomNav = document.createElement("div"); + objBottomNav.setAttribute('id','bottomNav'); + objImageData.appendChild(objBottomNav); + + var objBottomNavCloseLink = document.createElement("a"); + objBottomNavCloseLink.setAttribute('id','bottomNavClose'); + objBottomNavCloseLink.setAttribute('href','#'); + objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; } + objBottomNav.appendChild(objBottomNavCloseLink); + + var objBottomNavCloseImage = document.createElement("img"); + objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage); + objBottomNavCloseLink.appendChild(objBottomNavCloseImage); + }, + + // + // start() + // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. + // + start: function() { + + hideSelectBoxes(); + + // stretch overlay to fill page and fade in + var arrayPageSize = getPageSize(); + Element.setHeight('overlay', arrayPageSize[1]); + new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 }); + +// imageArray = []; + imageNum = 0; + +/* if (!document.getElementsByTagName){ return; } + var anchors = document.getElementsByTagName('a'); + + // if image is NOT part of a set.. + if((imageLink.getAttribute('rel') == 'lightbox')){ + // add single image to imageArray + imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title'))); + } else { + // if image is part of a set.. + + // loop through anchors, find other images in set, and add them to imageArray + for (var i=0; i<anchors.length; i++){ + var anchor = anchors[i]; + if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){ + imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title'))); + } + } + imageArray.removeDuplicates(); + while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;} + }*/ + + // calculate top offset for the lightbox and display + var arrayPageSize = getPageSize(); + var arrayPageScroll = getPageScroll(); + var lightboxTop = 20; /*arrayPageScroll[1] + (arrayPageSize[3] / 15);*/ + + Element.setTop('lightbox', lightboxTop); + Element.show('lightbox'); + + this.changeImage(imageNum); + }, + + // + // changeImage() + // Hide most elements and preload image in preparation for resizing image container. + // + changeImage: function(imageNum) { + + activeImage = imageNum; // update global var + + // hide elements during transition + Element.show('loading'); + Element.hide('lightboxImage'); + Element.hide('hoverNav'); + Element.hide('prevLink'); + Element.hide('nextLink'); + Element.hide('imageDataContainer'); + Element.hide('numberDisplay'); + + imgPreloader = new Image(); + + // once image is preloaded, resize image container + imgPreloader.onload=function(){ + Element.setSrc('lightboxImage', imageArray[activeImage][0]); + myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height); + } + imgPreloader.src = setImageUrl(imageArray[activeImage][0]); + }, + + // + // resizeImageContainer() + // + resizeImageContainer: function( imgWidth, imgHeight) { + + // get current height and width + this.wCur = Element.getWidth('outerImageContainer'); + this.hCur = Element.getHeight('outerImageContainer'); + + // scalars based on change from old to new + this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100; + this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100; + + // calculate size difference between new and old image, and resize if necessary + wDiff = (this.wCur - borderSize * 2) - imgWidth; + hDiff = (this.hCur - borderSize * 2) - imgHeight; + + if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); } + if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); } + + // if new and old image are same size and no scaling transition is necessary, + // do a quick pause to prevent image flicker. + if((hDiff == 0) && (wDiff == 0)){ + if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} + } + + Element.setHeight('prevLink', imgHeight); + Element.setHeight('nextLink', imgHeight); + Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2)); + + this.showImage(); + }, + + // + // showImage() + // Display image and begin preloading neighbors. + // + showImage: function(){ + Element.hide('loading'); + new Effect.Appear('lightboxImage', { duration: 0.5, queue: 'end', afterFinish: function(){ myLightbox.updateDetails(); } }); + this.preloadNeighborImages(); + }, + + // + // updateDetails() + // Display caption, image number, and bottom nav. + // + updateDetails: function() { + + Element.show('caption'); + Element.setInnerHTML( 'caption', imageArray[activeImage][1]); + + // if image is part of set display 'Image x of x' + if(imageArray.length > 1){ + Element.show('numberDisplay'); + Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length); + } + + new Effect.Parallel( + [ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration + 0.25, from: 0.0, to: 1.0 }), + new Effect.Appear('imageDataContainer', { sync: true, duration: 1.0 }) ], + { duration: 0.65, afterFinish: function() { myLightbox.updateNav();} } + ); + }, + + // + // updateNav() + // Display appropriate previous and next hover navigation. + // + updateNav: function() { + + Element.show('hoverNav'); + + // if not first image in set, display prev image button + if(activeImage != 0){ + Element.show('prevLink'); + document.getElementById('prevLink').onclick = function() { + myLightbox.changeImage(activeImage - 1); return false; + } + } + + // if not last image in set, display next image button + if(activeImage != (imageArray.length - 1)){ + Element.show('nextLink'); + document.getElementById('nextLink').onclick = function() { + myLightbox.changeImage(activeImage + 1); return false; + } + } + + this.enableKeyboardNav(); + }, + + // + // enableKeyboardNav() + // + enableKeyboardNav: function() { + document.onkeydown = this.keyboardAction; + }, + + // + // disableKeyboardNav() + // + disableKeyboardNav: function() { + document.onkeydown = ''; + }, + + // + // keyboardAction() + // + keyboardAction: function(e) { + if (e == null) { // ie + keycode = event.keyCode; + } else { // mozilla + keycode = e.which; + } + + key = String.fromCharCode(keycode).toLowerCase(); + + if((key == 'x') || (key == 'o') || (key == 'c')){ // close lightbox + myLightbox.end(); + } else if(key == 'p'){ // display previous image + if(activeImage != 0){ + myLightbox.disableKeyboardNav(); + myLightbox.changeImage(activeImage - 1); + } + } else if(key == 'n'){ // display next image + if(activeImage != (imageArray.length - 1)){ + myLightbox.disableKeyboardNav(); + myLightbox.changeImage(activeImage + 1); + } + } + + + }, + + // + // preloadNeighborImages() + // Preload previous and next images. + // + preloadNeighborImages: function(){ + + if((imageArray.length - 1) > activeImage){ + preloadNextImage = new Image(); + preloadNextImage.src = setImageUrl(imageArray[activeImage + 1][0]); + } + if(activeImage > 0){ + preloadPrevImage = new Image(); + preloadPrevImage.src = setImageUrl(imageArray[activeImage - 1][0]); + } + + }, + + // + // end() + // + end: function() { + this.disableKeyboardNav(); + Element.hide('lightbox'); + new Effect.Fade('overlay', { duration: 0.2}); + showSelectBoxes(); + } +} + +// ----------------------------------------------------------------------------------- + +// +// getPageScroll() +// Returns array with x,y page scroll values. +// Core code from - quirksmode.org +// +function getPageScroll(){ + + var yScroll; + + if (self.pageYOffset) { + yScroll = self.pageYOffset; + } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict + yScroll = document.documentElement.scrollTop; + } else if (document.body) {// all other Explorers + yScroll = document.body.scrollTop; + } + + arrayPageScroll = new Array('',yScroll) + return arrayPageScroll; +} + +// ----------------------------------------------------------------------------------- + +// +// getPageSize() +// Returns array with page width, height and window width, height +// Core code from - quirksmode.org +// Edit for Firefox by pHaez +// +function getPageSize(){ + + var xScroll, yScroll; + + if (window.innerHeight && window.scrollMaxY) { + xScroll = document.body.scrollWidth; + yScroll = window.innerHeight + window.scrollMaxY; + } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac + xScroll = document.body.scrollWidth; + yScroll = document.body.scrollHeight; + } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari + xScroll = document.body.offsetWidth; + yScroll = document.body.offsetHeight; + } + + var windowWidth, windowHeight; + if (self.innerHeight) { // all except Explorer + windowWidth = self.innerWidth; + windowHeight = self.innerHeight; + } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode + windowWidth = document.documentElement.clientWidth; + windowHeight = document.documentElement.clientHeight; + } else if (document.body) { // other Explorers + windowWidth = document.body.clientWidth; + windowHeight = document.body.clientHeight; + } + + // for small pages with total height less then height of the viewport + if(yScroll < windowHeight){ + pageHeight = windowHeight; + } else { + pageHeight = yScroll; + } + + // for small pages with total width less then width of the viewport + if(xScroll < windowWidth){ + pageWidth = windowWidth; + } else { + pageWidth = xScroll; + } + + + arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) + return arrayPageSize; +} + +// ----------------------------------------------------------------------------------- + +... [truncated message content] |
From: <bz...@us...> - 2006-04-11 08:09:05
|
Revision: 4509 Author: bzrudi Date: 2006-04-11 01:08:38 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4509&view=rev Log Message: ----------- DB fetch mode is now set to ADODB_FETCH_ASSOC by default, no longer BOTH Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/admin/import.php trunk/linpha2/admin/permissions_groups.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_read.php trunk/linpha2/admin/permissions_usergroup.php trunk/linpha2/admin/permissions_users.php trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step8_testing.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_meta.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/ChangeLog 2006-04-11 08:08:38 UTC (rev 4509) @@ -1,3 +1,9 @@ +2006-04-11 bzrudi <linpha2_AT_tuxpower_DOT_de> + * DB fetch mode is now set to ADODB_FETCH_ASSOC by default, so no need + for fetchRow(ADODB_FETCH_ASSOC) any more. If you need to fetch NUM, use this + fetchRow(ADODB_FETCH_NUM). + - replace some ASSOCS due NUM for speed improvements + 2006-04-10 bzrudi <linpha2_AT_tuxpower_DOT_de> * Database - renamed some preserved table field names. e.g. don't use "date", "name" as Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/image_fields_define.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -64,8 +64,11 @@ /** * get builtin fields */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags FROM ".PREFIX."meta_fields WHERE flags = '5' OR flags = '6' "); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . + "FROM ".PREFIX."meta_fields " . + "WHERE flags = '5' OR flags = '6' "); + + while($data = $query->FetchRow()) { echo '<tr><td>'; echo $data['name']; @@ -135,7 +138,7 @@ </tr> <?php - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { ?> <tr> @@ -181,7 +184,7 @@ function show_add_data() { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '2'"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { ?> <h3><?php echo $data['name']; ?></h3> @@ -194,7 +197,7 @@ </tr> <?php $query2 = $GLOBALS['linpha']->db->Execute("SELECT id, name, isprivate FROM ".PREFIX."meta_category WHERE field_id = '".$data['id']."'"); - while($data2 = $query2->FetchRow(ADODB_FETCH_ASSOC)) + while($data2 = $query2->FetchRow()) { ?> <tr> Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/image_fields_select.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -70,7 +70,7 @@ <select id="select_image_fields" name="select_image_fields[]" size="25" style="width: 200px;" multiple="multiple"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { echo '<option value="'.$data['name'].'">'.$MetaData->getNameOfField($data['name'],true).'</option>'; } @@ -94,7 +94,7 @@ <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . "WHERE flags = '1' OR flags = '5'"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { echo '<option value="builtin_'.$data['name'].'">'.i18n( ucfirst( $data['name'] ) ).'</option>'; } @@ -112,7 +112,7 @@ <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields " . "WHERE flags = '7'"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { echo '<option value="id_'.$data['id'].'">'.$data['name'].'</option>'; } Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/import.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -21,10 +21,10 @@ /** * first, only for images */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - if( ! $thumbnail->createThumbnail($data['id']) ) + if( ! $thumbnail->createThumbnail($data['0']) ) { echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; } Modified: trunk/linpha2/admin/permissions_groups.php =================================================================== --- trunk/linpha2/admin/permissions_groups.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/permissions_groups.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -75,7 +75,7 @@ </tr> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER BY group_name"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { ?> <tr> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/permissions_others.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -102,7 +102,7 @@ <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER by group_name"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { if(in_array($data['id'],$array_permissions)) { Modified: trunk/linpha2/admin/permissions_read.php =================================================================== --- trunk/linpha2/admin/permissions_read.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/permissions_read.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -89,7 +89,7 @@ */ $array_groups = Array(); $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups WHERE group_name <> 'admin'"); - while($data = $query->FetchRow()) + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { $array_groups[$data[0]] = $data[1]; } @@ -120,7 +120,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."photos " . "WHERE id = '".linSql::linAddslashes($_GET['id'])."'"); - $data = $query->FetchRow(); + $data = $query->FetchRow(ADODB_FETCH_NUM); ?> <form name="permission" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$parent_id; ?>"> <h3>Change/Add permissions of folder/file "<?php echo $data[0]; ?>"</h3> @@ -202,7 +202,7 @@ function print_dir_perms_entry( $parent_id , $recursive , $stage) { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".$parent_id."'"); - while( $data = $query->FetchRow(ADODB_FETCH_ASSOC) ) + while( $data = $query->FetchRow() ) { list($i, $perm) = $GLOBALS['linpha']->sql->getPerm( $data['id'] ); Modified: trunk/linpha2/admin/permissions_usergroup.php =================================================================== --- trunk/linpha2/admin/permissions_usergroup.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/permissions_usergroup.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -6,7 +6,7 @@ */ echo '<b>'.i18n("Edit Group Members").'</b><br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups ORDER by group_name"); -while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) +while($data = $query->FetchRow()) { echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_usergroup&edit=group&id='.$data['id'].'">'.$data['group_name'].'</a><br />'; } @@ -18,7 +18,7 @@ */ echo '<b>'.i18n("Edit User Memberships").'</b><br />'; $query = $GLOBALS['linpha']->db->Execute("SELECT id, username FROM ".PREFIX."users ORDER by username"); -while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) +while($data = $query->FetchRow()) { echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_usergroup&edit=user&id='.$data['id'].'">'.$data['username'].'</a><br />'; } @@ -105,8 +105,10 @@ <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_usergroup&edit='.$_GET['edit'].'&id='.$_GET['id']; ?>"> <select name="usergroup[]" size="5" style="width: 200;" multiple="multiple"> <?php - $query = $GLOBALS['linpha']->db->Execute("SELECT id, ".$other_select_name." FROM ".PREFIX.$other_table_name." ORDER by ".$other_select_name); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + $query = $GLOBALS['linpha']->db->Execute("SELECT id, ".$other_select_name." " . + "FROM ".PREFIX.$other_table_name." " . + "ORDER by ".$other_select_name); + while($data = $query->FetchRow()) { /** * check if selected @@ -121,7 +123,9 @@ $userid = LinSql::linAddslashes($_GET['id']); $groupid = $data['id']; } - $data2 = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."user_group WHERE user_id = '".$userid."' AND group_id = '".$groupid."'"); + $data2 = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."user_group " . + "WHERE user_id = '".$userid."' " . + "AND group_id = '".$groupid."'"); if(isset($data2['id'])) { $checked = ' selected="selected"'; Modified: trunk/linpha2/admin/permissions_users.php =================================================================== --- trunk/linpha2/admin/permissions_users.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/admin/permissions_users.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -91,7 +91,7 @@ * show users */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, username, display_name, user_email FROM ".PREFIX."users ORDER BY username"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { ?> <tr> Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/install/step10_postsettings.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -83,7 +83,7 @@ $query = $linpha->db->Execute("SELECT option_value FROM ".PREFIX."config " . "WHERE option_name='sys_im_use_imagemagick'"); -$data = $query->FetchRow(); +$data = $query->FetchRow(ADODB_FETCH_NUM); if(false === $data[0]) { Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/install/step8_testing.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -237,7 +237,7 @@ $error = false; if($key == "SELECT") { - $data = $result->FetchRow(); + $data = $result->FetchRow(ADODB_FETCH_NUM); if( !$data OR @$data[1] != md5('the life ist beautiful')) { $error = true; Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -175,7 +175,8 @@ /** * check for valid id */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, img_type FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes( $this->photo_id )."'"); if($query->RecordCount() != 1) { @@ -183,15 +184,15 @@ return false; } - $data = $query->FetchRow(ADODB_FETCH_ASSOC); + $data = $query->FetchRow(ADODB_FETCH_NUM); - if( ! LinSql::photoIsAllowed( $data['id'] ) ) + if( ! LinSql::photoIsAllowed( $data['0'] ) ) { $this->error_msg = "not permitted!"; return false; } - if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['img_type'] ) ) + if($this->mode == 'img' && ! LinIdentify::isSupportedImage( $data['1'] ) ) { $this->error_msg = "only images possible!"; return false; @@ -206,7 +207,7 @@ $this->force = false; } - $this->img_type = $data['img_type']; + $this->img_type = $data['1']; $this->setCachedInfos(); /** @@ -352,16 +353,16 @@ $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(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { if($i >= 4) { break; } - if( file_exists( LinImage::getCachePath('thumb',$data['id']) ) ) + if( file_exists( LinImage::getCachePath('thumb',$data['0']) ) ) { - $array_ids[] = $data['id']; + $array_ids[] = $data['0']; $i++; } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -813,15 +813,15 @@ for($i = 1; $i <= $nr_random_images ; ) { - $data = $query->FetchRow(ADODB_FETCH_ASSOC); - if(isset($data['id'])) + $data = $query->FetchRow(ADODB_FETCH_NUM); + if(isset($data['0'])) { - $array = LinSql::getFullFilenameFromId( $data['id'] ); + $array = LinSql::getFullFilenameFromId( $data['0'] ); $path = LinSql::getPath('album') .'/'. implode('/',$array); - if(file_exists(LinFilesys::getFullPath($path)) && LinSql::photoIsAllowed($data['id'])) + if(file_exists(LinFilesys::getFullPath($path)) && LinSql::photoIsAllowed($data['0'])) { - $GLOBALS['linpha']->template->output['random_images'][] = Array('id'=>$data['id'],'path'=>$path); + $GLOBALS['linpha']->template->output['random_images'][] = Array('id'=>$data['0'],'path'=>$path); $i++; } } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -118,12 +118,12 @@ */ if($recursive) { - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . + $query = $GLOBALS['linpha']->db->Execute("SELECT id " . "FROM ".PREFIX."photos WHERE img_type = '0' " . "AND parent_id = '".$parent_id."'"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - LinImport::updateDir($data['id'], $recursive); + LinImport::updateDir($data['0'], $recursive); } } } @@ -202,9 +202,9 @@ */ $query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . "FROM ".PREFIX."photos WHERE parent_id = '".$photo_id."' "); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - linImport::deleteEntry( $data['id'], $full_filename.'/'.$data['name']); + linImport::deleteEntry( $data['0'], $full_filename.'/'.$data['1']); } linSysLog('delete entry '.$full_filename.'<br />'); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -75,15 +75,17 @@ */ function readInformations($full_filename,$filename,$md5sum,$flag_nr) { - $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."meta_fields WHERE flags = '".$flag_nr."' ORDER by id"); - while($fields_data = $query->FetchRow(ADODB_FETCH_ASSOC)) + $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."meta_fields " . + "WHERE flags = '".$flag_nr."' ORDER by id"); + + while($fields_data = $query->FetchRow(ADODB_FETCH_NUM)) { - $name = MetaData::getNameOfField( $fields_data['name'], false ); + $name = MetaData::getNameOfField( $fields_data['0'], false ); $value = ''; - $pos = strpos($fields_data['name'],'_'); - $first_part = substr($fields_data['name'],0,$pos); - $last_part = substr($fields_data['name'],$pos+1); + $pos = strpos($fields_data['0'],'_'); + $first_part = substr($fields_data['0'],0,$pos); + $last_part = substr($fields_data['0'],$pos+1); switch($first_part) { case 'builtin': Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -41,6 +41,11 @@ */ function dbConnect() { + /** + * set adodb global default to fetch ASSOC + */ + $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC'; + if(isset($_SESSION['installmode1'])) { $db_type = $_SESSION['sql_dbtype']; @@ -110,7 +115,7 @@ } break; - } + } } if( !isset($GLOBALS['linpha']->db) OR !$GLOBALS['linpha']->db->isConnected() ) @@ -178,7 +183,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT username, display_name FROM ".PREFIX."users ". "WHERE id = '".LinSql::linAddslashes($_COOKIE['linpha_userid'])."' ". "AND password = '".LinSql::linAddslashes($_COOKIE['linpha_password'])."'"); - if($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + if($data = $query->FetchRow()) { //linpha_log('login','notice','User '.$_POST['user_name'].": successfully logged in."); linSysLog(i18n("Successfully Logged In!<br />")); @@ -336,7 +341,7 @@ * get user_groups */ $query = $GLOBALS['linpha']->db->Execute("SELECT group_id FROM ".PREFIX."user_group WHERE user_id = '".$userid."'"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { $_SESSION['user_groups'][] = $data['group_id']; } @@ -500,16 +505,18 @@ */ function getFullFilenameFromId( $photos_id ) { - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos WHERE id = '".$GLOBALS['linpha']->sql->linAddslashes($photos_id)."'"); - $data = $query->FetchRow(ADODB_FETCH_ASSOC); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos " . + "WHERE id = '".$GLOBALS['linpha']->sql->linAddslashes($photos_id)."'"); + $data = $query->FetchRow(); $array_names[ $photos_id ] = $data['name']; $parent_id = $data['parent_id']; for($i = 0; $parent_id != 0 ; $i++) { - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos WHERE id = '".$parent_id."'"); - $data = $query->FetchRow(ADODB_FETCH_ASSOC); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos " . + "WHERE id = '".$parent_id."'"); + $data = $query->FetchRow(); $array_names[ $data['id'] ] = $data['name']; $parent_id = $data['parent_id']; @@ -639,10 +646,12 @@ { unset($this->value); - $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config"); - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - $this->value[$data['option_name']] = $data['option_value']; + $this->value[$data['0']] = $data['1']; } } Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -42,7 +42,10 @@ if( isset( $_GET['ref_id'] ) ) { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> '0' AND parent_id = '".linSql::linAddslashes($_GET['ref_id'])."'"); + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos " . + "WHERE img_type <> '0' " . + "AND parent_id = '".linSql::linAddslashes($_GET['ref_id'])."'"); + while($data = $query->FetchRow()) { if($GLOBALS['linpha']->sql->photoIsAllowed($data[0])) Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/templates/default/view_img.html.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -57,7 +57,7 @@ <br /><br /> <!-- show image comments --> - <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow(ADODB_FETCH_ASSOC)) { ?> + <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> <div class="comments"> <?php echo $data['meta_time']; ?> <?php echo $data['meta_author']; ?> <br /> Modified: trunk/linpha2/templates/default/view_meta.html.php =================================================================== --- trunk/linpha2/templates/default/view_meta.html.php 2006-04-10 21:28:38 UTC (rev 4508) +++ trunk/linpha2/templates/default/view_meta.html.php 2006-04-11 08:08:38 UTC (rev 4509) @@ -10,7 +10,8 @@ if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type FROM ".PREFIX."meta_fields " . + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type " . + "FROM ".PREFIX."meta_fields " . "WHERE flags = '5' OR flags = '7' ORDER by id"); $num = $query->RecordCount(); ?> @@ -22,7 +23,7 @@ <td rowspan="<?php echo $num+1; ?>"><?php echo $GLOBALS['linpha']->template->output['image']; ?></td> </tr> <?php - while($data = $query->FetchRow(ADODB_FETCH_ASSOC)) + while($data = $query->FetchRow()) { ?> <tr> @@ -53,9 +54,10 @@ ?> <select name="field[<?php echo $data['id']; ?>][]" multiple="multiple" style="width: 200px;"> <?php - $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_category " . + $cat_query = $GLOBALS['linpha']->db->Execute("SELECT id, name " . + "FROM ".PREFIX."meta_category " . "WHERE field_id = '".$data['id']."'"); - while($cat_data = $cat_query->FetchRow(ADODB_FETCH_ASSOC)) + while($cat_data = $cat_query->FetchRow()) { if(in_array($cat_data['id'],$array_pieces)) { $checked = ' selected="selected"'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-04-12 12:45:05
|
Revision: 4512 Author: bzrudi Date: 2006-04-12 05:44:38 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4512&view=rev Log Message: ----------- added basic support for ORACLE XE Database Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/step11_finish.php trunk/linpha2/install/step3_dbtype.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step7_selectprefix.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.sql.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/ChangeLog 2006-04-12 12:44:38 UTC (rev 4512) @@ -1,3 +1,8 @@ +2006-04-12 bzrudi <linpha2_AT_tuxpower_DOT_de> + * Installer: + - added support for ORACLE XE Database - at least tables are created + and autoincrement works for now ;-) + 2006-04-11 bzrudi <linpha2_AT_tuxpower_DOT_de> * DB fetch mode is now set to ADODB_FETCH_ASSOC by default, so no need for fetchRow(ADODB_FETCH_ASSOC) any more. If you need to fetch NUM, use this Modified: trunk/linpha2/install/step11_finish.php =================================================================== --- trunk/linpha2/install/step11_finish.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step11_finish.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -63,7 +63,7 @@ { echo failed_msg(); } else { - $userid = $GLOBALS['linpha']->db->Insert_ID(); + $userid = $GLOBALS['linpha']->db->PO_Insert_ID(PREFIX."users", "id"); /** * adding user to group 'admin' Modified: trunk/linpha2/install/step3_dbtype.php =================================================================== --- trunk/linpha2/install/step3_dbtype.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step3_dbtype.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -63,8 +63,15 @@ if(function_exists('sqlite_open')) { $supported_db['sqlite'] = 1; } +if(function_exists('oci_connect')) { + $supported_db['oci8'] = 1; +} /** + * @todo run thru foreach + */ + +/** * define disabled and checked variables */ if(! isset($supported_db['mysql'])) @@ -85,12 +92,20 @@ } else { $disabled_sqlite = ''; } + if(! isset($supported_db['oci8'])) + { + $disabled_oci8 = ' disabled="disabled"'; + } else { + $disabled_oci8 = ''; + } $checked_mysql = ''; $checked_postgres = ''; $checked_sqlite = ''; + $checked_oci8 = ''; + if(isset($_SESSION['sql_dbtype'])) { switch($_SESSION['sql_dbtype']) @@ -98,6 +113,7 @@ case "mysql": $checked_mysql = ' checked="checked"'; break; case "postgres": $checked_postgres = ' checked="checked"'; break; case "sqlite": $checked_sqlite = ' checked="checked"'; break; + case "oci8": $checked_oci8 = ' checked="checked"'; break; } } else { $checked_mysql = ' checked="checked"'; @@ -131,7 +147,18 @@ { echo '<b>'.tr("No Support In PHP Config (php.ini)");'</b><br />'; } +?> +<br /> + +<input type='radio' name='sql_dbtype' value='oci8'<?php echo $disabled_oci8; ?> +<?php echo $checked_oci8; ?>>Oracle<br /> +<?php +if(!isset($supported_db['oci8'])) +{ + echo '<b>'.tr("No Support In PHP Config (php.ini)");'</b><br />'; +} + ?> <br /><br /> <h1><?php echo tr("Select Installation Mode"); ?></h1> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step5_getlogin.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -215,6 +215,11 @@ "from commandline before you proceed.")."<br /><br />"; $_SESSION['sql_dbport'] = '5432'; } +elseif($_SESSION['sql_dbtype'] == 'oci8') +{ + echo tr("WOW, playing with the big ones"); + $_SESSION['sql_dbport'] = '1521'; +} ?> <div class="boxalign"> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step6_selectdatabase.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -101,6 +101,10 @@ case "postgres": $_SESSION['allowed_to_create_db'] = false; break; +case "oci8": + $_SESSION['allowed_to_create_db'] = false; +break; + // case "sqlite": sqlite goes directly to stage8 } Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step7_selectprefix.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -200,6 +200,24 @@ } } break; +case "oci8": + include_once('../lib/adodb/adodb.inc.php'); + $link = NewADOConnection('oci8'); + $link ->connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $_SESSION['sql_username'], $_SESSION['sql_password'], $_SESSION['sql_dbname']); + if (!$link) + { + echo failed_msg(); + echo "<br />".tr("Error Connecting To Server").":"; + $error_nr = 2; + } + else + { + echo success_msg(); + $link->close(); + } + +break; + } if(isset($error_nr)) Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/install/step9_createtables.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -57,7 +57,7 @@ /** * finally create tables */ - echo tr("Creating Tables")."... "; + echo tr("Creating Tables")."...<br /> "; $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) @@ -71,6 +71,46 @@ $error_nr = 1; } } + /** + * take care of oracle seqeunces and triggers + */ + if($_SESSION['sql_dbtype'] == 'oci8') + { + + echo tr("Creating Sequences")."...<br /> "; + + /** + * create sequences + */ + while( list($key, $query) = each($sql_sequence) ) + { + $result = $linpha->db->Execute($query); + if(!$result) + { + echo tr("Failed To Create Sequence for [$key]."); + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } + } + + /** + * create triggers + */ + echo tr("Creating Triggers")."...<br /> "; + while( list($key, $query) = each($sql_trigger) ) + { + $result = $linpha->db->Execute($query); + if(!$result) + { + echo tr("Failed To Create Trigger for [$key]."); + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; + } + } + } + if(!isset($error_nr)) { echo success_msg(); Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-11 08:43:29 UTC (rev 4511) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-12 12:44:38 UTC (rev 4512) @@ -41,10 +41,6 @@ */ function dbConnect() { - /** - * set adodb global default to fetch ASSOC - */ - $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC'; if(isset($_SESSION['installmode1'])) { @@ -77,8 +73,19 @@ define('PREFIX', $db_prefix); define('DB_TYPE', $db_type); - + /** + * set adodb global default to fetch ASSOC + */ + if(DB_TYPE == 'oci8') + { + $ADODB_FETCH_MODE = 'ADODB_FETCH_BOTH'; + } + else + { + $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC'; + } + /** * connect to db and check if connection was succesfull */ include_once(LINPHA_DIR.'/lib/adodb/adodb.inc.php'); @@ -116,6 +123,12 @@ break; } + case "oci8": + { + $GLOBALS['linpha']->db->Connect($db_hostname, $db_username, $db_password, $db_name); + + break; + } } if( !isset($GLOBALS['linpha']->db) OR !$GLOBALS['linpha']->db->isConnected() ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-12 16:32:53
|
Revision: 4521 Author: fangehrn Date: 2006-04-12 09:32:29 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4521&view=rev Log Message: ----------- * replace some recordCount() with EOF Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/permissions_read.php trunk/linpha2/lib/classes/thumbnails.js Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-12 16:10:57 UTC (rev 4520) +++ trunk/linpha2/ChangeLog 2006-04-12 16:32:29 UTC (rev 4521) @@ -1,3 +1,6 @@ +2006-04-12 flo + * replace some recordCount() with EOF + 2006-04-12 bzrudi <linpha2_AT_tuxpower_DOT_de> * added ORACLE EXPRESS DB support, still some things open but at least the basics work :-) Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-04-12 16:10:57 UTC (rev 4520) +++ trunk/linpha2/admin/image_fields_define.php 2006-04-12 16:32:29 UTC (rev 4521) @@ -121,23 +121,12 @@ /** * get own fields */ - /** - * @todo check if this works for all databases, record count makes - * some dbs extreme slowly and should be diabled by default - */ - $number_query = $GLOBALS['linpha']->db->GetRow("SELECT id, name, field_type, flags " . - "FROM ".PREFIX."meta_fields " . - "WHERE flags = '7' " . - "OR flags = '8'"); - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, field_type, flags " . "FROM ".PREFIX."meta_fields " . "WHERE flags = '7' " . "OR flags = '8'"); -// if($query->RecordCount()>0) - - if(true == $number_query) //at least we found a single record + if( ! $query->EOF ) { ?> <h3>Own fields</h3> Modified: trunk/linpha2/admin/permissions_read.php =================================================================== --- trunk/linpha2/admin/permissions_read.php 2006-04-12 16:10:57 UTC (rev 4520) +++ trunk/linpha2/admin/permissions_read.php 2006-04-12 16:32:29 UTC (rev 4521) @@ -11,21 +11,9 @@ { /** * insert or update - * @todo WARNING Check if this worls for all dbs!! */ - //$query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions WHERE photos_id = '".$linpha->sql->linAddslashes($_POST['photo_id'])."'"); - //$num = $query->RecordCount(); - - $query = $linpha->db->GetRow("SELECT id FROM ".PREFIX."permissions " . - "WHERE photos_id = '".$linpha->sql->linAddslashes($_POST['photo_id'])."'"); - if(true == $query) - { - $num = 10; //set > 0 - } - else - { - $num = 0; - } + $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); /** * if inherit is selected, delete if an entry exists @@ -34,10 +22,10 @@ */ if(isset($_POST['inherit'])) { - if($num != 0 && $_POST['photo_id'] != 0) + if( ! $query->EOF && $_POST['photo_id'] != 0) { $linpha->db->Execute("DELETE FROM ".PREFIX."permissions " . - "WHERE photos_id = '".$linpha->sql->linAddslashes($_POST['photo_id'])."'"); + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); } } else @@ -62,16 +50,16 @@ $str_groups = ''; } - if($num != 0) + if( ! $query->EOF ) { - $linpha->db->Execute("UPDATE ".PREFIX."permissions SET permission = ';".$linpha->sql->linAddslashes($str_groups).";' " . - "WHERE photos_id = '".$linpha->sql->linAddslashes($_POST['photo_id'])."'"); + $linpha->db->Execute("UPDATE ".PREFIX."permissions SET permission = ';".LinSql::linAddslashes($str_groups).";' " . + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); } else { $linpha->db->Execute("INSERT into ".PREFIX."permissions (photos_id, perm_type, permission) VALUES (" . - "'".$linpha->sql->linAddslashes($_POST['photo_id'])."', 'read'," . - "';".$linpha->sql->linAddslashes($str_groups).";' )"); + "'".LinSql::linAddslashes($_POST['photo_id'])."', 'read'," . + "';".LinSql::linAddslashes($str_groups).";' )"); } } } @@ -84,7 +72,7 @@ $parent_id = $_GET['parent_id']; $view_mode = 'files'; - $array = $GLOBALS['linpha']->sql->getFullFilenameFromId( linSql::linAddslashes($parent_id) ); + $array = $GLOBALS['linpha']->sql->getFullFilenameFromId( LinSql::linAddslashes($parent_id) ); $parent_name = '<b>'.implode('/',$array).'</b>'; $recursive = false; @@ -117,22 +105,11 @@ /** * check wether add or edit (insert or update) - * @todo WARNING !!! */ -// $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions WHERE photos_id = '".linSql::linAddslashes($_GET['id'])."'"); -// $num = $query->RecordCount(); - $query = $linpha->db->GetRow("SELECT id FROM ".PREFIX."permissions " . - "WHERE photos_id = '".linSql::linAddslashes($_GET['id'])."'"); - if(true == $query) - { - $num = 10; //set > 0 - } - else - { - $num = 0; - } + $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . + "WHERE photos_id = '".LinSql::linAddslashes($_GET['id'])."'"); - if( $num > 0 ) + if( ! $query->EOF ) { list($stage, $perm) = $GLOBALS['linpha']->sql->getPerm( $_GET['id'] ); $array_perms = explode(';',$perm); @@ -144,7 +121,7 @@ } $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."photos " . - "WHERE id = '".linSql::linAddslashes($_GET['id'])."'"); + "WHERE id = '".LinSql::linAddslashes($_GET['id'])."'"); $data = $query->FetchRow(ADODB_FETCH_NUM); ?> <form name="permission" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$parent_id; ?>"> Modified: trunk/linpha2/lib/classes/thumbnails.js =================================================================== --- trunk/linpha2/lib/classes/thumbnails.js 2006-04-12 16:10:57 UTC (rev 4520) +++ trunk/linpha2/lib/classes/thumbnails.js 2006-04-12 16:32:29 UTC (rev 4521) @@ -138,13 +138,14 @@ '<div id="div' + i + '"' + htmltext + ' class="imgdiv">' + img_ids[i]['before'] + '<a href="' + link_url + "&id=" + img_ids[i]['id'] + '">' + - '<img src="' + link_get_thumb + img_ids[i]['id'] + '" height="' + tn_size + - '" alt="' + img_ids[i]['title'] + '" title="' + + '<img src="' + link_get_thumb + img_ids[i]['id'] + '"' + + ' height="' + tn_size + '"' + ' width="' + tn_size + '" ' + ' alt="' + img_ids[i]['title'] + '" title="' + img_ids[i]['title'] + '" class="img_thumbnail" />' + '</a>' + img_ids[i]['after'] + '</div>'; /** - * flush buffer on end of line + * flush buffer of divhtmltext on end of line * with this buffer, we're 3-4 as fast as without !! * see also http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=JavascriptStringConcatenation !! */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-12 21:44:16
|
Revision: 4526 Author: fangehrn Date: 2006-04-12 14:44:03 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4526&view=rev Log Message: ----------- * startet implementing search feature Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/modules/module.search.php Added Paths: ----------- trunk/linpha2/templates/default/search.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-12 18:19:52 UTC (rev 4525) +++ trunk/linpha2/ChangeLog 2006-04-12 21:44:03 UTC (rev 4526) @@ -1,5 +1,6 @@ 2006-04-12 flo * replace some recordCount() with EOF + * startet implementing search feature 2006-04-12 bzrudi <linpha2_AT_tuxpower_DOT_de> * added ORACLE EXPRESS DB support, still some things open but at least Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-12 18:19:52 UTC (rev 4525) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-12 21:44:03 UTC (rev 4526) @@ -112,7 +112,7 @@ $this->mode = 'home'; $this->orderby = getSqlSortOrder($GLOBALS['linpha']->sql->config->value['sys_style_home_firstsortorder']); } - else // $modulename=='browse', others will come.. + else // $modulename=='browse' | 'search' , others will come.. { $this->mode = 'thumb'; Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-12 18:19:52 UTC (rev 4525) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-12 21:44:03 UTC (rev 4526) @@ -22,5 +22,437 @@ * Albums view related methods and functions * @package Template */ - ?> - \ No newline at end of file + + + + + +/** +* call from exif href in img_view +*/ +if(isset($_REQUEST['sk'])) { + $_REQUEST['date_from']=$_REQUEST['sk']; + $_REQUEST['date_to']=$_REQUEST['sk']; + $_REQUEST['album_select'] = Array('all'=>'all'); + $_REQUEST['cmd'] = 'search'; +} + +if(isset($_REQUEST['cmd'])) +{ + switch($_REQUEST['cmd']) + { + case 'search': + + /** + * search string to short + */ + if( !empty($_REQUEST['search_text']) && strlen($_REQUEST['search_text']) < 2 ) + { + $error = 1; + } + /** + * check for valid input + * @todo + */ + elseif((!empty($_REQUEST['search_text']) && strlen($_REQUEST['search_text'])>=2) OR + isset($_REQUEST['category']) OR + (!empty($_REQUEST['date_from']) OR !empty($_REQUEST['date_to'])) OR true) + { + /** + * save search string in session + */ + $_SESSION['search'] = $_REQUEST; + } + else + { + $error = 2; + } + + break; + case 'new': + unset($_SESSION['search']); + $_REQUEST['b_all'] = true; + break; + case 'edit': + if(isset($_SESSION['search'])) + { + /** + * copy session to request + */ + foreach($_SESSION['search'] AS $key=>$value) + { + $_REQUEST[$key] = $value; + } + unset($_SESSION['search']); + } + break; + } +} +else +{ + $_REQUEST['b_all'] = 1; +} + +if(isset($_SESSION['search'])) +{ +/** + * init + */ + include_once(LINPHA_DIR . '/lib/classes/linpha.imgview.class.php'); + $linpha->imgview = new linImgview(); + $linpha->imgview->setCurrentView('search'); + $linpha->template->URL_base = LINPHA_DIR.'/?cat=search'; + $linpha->template->URL_full = LINPHA_DIR.'/?cat=search'; + $linpha->template->output['title'] = i18n("Search"); + + +/** +* create sql search query +*/ + /** + * copy session to request + */ + foreach($_SESSION['search'] AS $key=>$value) + { + $_REQUEST[$key] = $value; + } + + /** + * buttons + */ + + $sql_buttons = ''; + if(!empty($_REQUEST['search_text'])) + { + /** + * Split textfield into particular words + */ + + /** + * replace \" with {quotes} to be sure the \" isn't handled as delimiter + * later it will be replaced back + * + * * my cat ==> returns all results for my AND/OR cat + e.g. my house, my cat, cute cat... + * "my cat" ==> returns all results for my cat + e.g. this is my cat, but not a cute cat, this is my house..." + * \"my cat\" ==> returns all results for "my cat" + e.g. this is "my cat" smilla, but not this is my cat smilla... + * + */ + $_REQUEST['search_text'] = str_replace('\"','{quotes}',$_REQUEST['search_text']); + + /** + * extract strings with '"blal asdf"' into 'blal asdf' + */ + $array_strings = Array(); + while( ($pos1 = strpos($_REQUEST['search_text'],'"')) !== false) + { + /** + * no ending " found, take the whole string after $pos1 + */ + if( ($pos2 = strpos(substr($_REQUEST['search_text'],$pos1+1),'"')) === false) + { + $substr = substr($_REQUEST['search_text'],$pos1); + } + else + { + $substr = substr($_REQUEST['search_text'],$pos1,$pos2+2); + } + + /** + * delete this entry in the search string to be sure the next time we get the next entry + */ + $_REQUEST['search_text'] = str_replace($substr,'',$_REQUEST['search_text']); + + /** + * add the string to the array (without starting and ending '"') + */ + $array_strings[] = substr($substr,1,strlen($substr)-2); + } + + /** + * extract normal strings with 'blaab asd' into 'blals' and 'asd' + */ + $array_strings = array_merge($array_strings,explode(" ", $_REQUEST['search_text'])); + + /** + * remove empty strings and add slashes + */ + foreach($array_strings AS $key=>$value) + { + if(empty($value)) { + unset($array_strings[$key]); + } else { + $array_strings[$key] = LinSql::linAddslashes($value); + } + } + + + /** + * get text fields + */ + $sql_buttons = "(1=2"; + $and_or = get_and_or($_REQUEST['text_and_or']); + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."meta_fields WHERE field_type = '1' AND (flags = '5' OR flags = '7')"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + if(isset($_REQUEST['button']['meta'][$data[0]]) OR isset($_REQUEST['button']['meta']['all'])) + { + $sql_buttons .= " OR ("; + + $num = count($array_strings); + reset($array_strings); + for($i = 1; list($key,$value) = each($array_strings); $i++) + { + $sql_buttons .= " (".PREFIX."meta_data.field_id = '".$data[0]."' AND ".PREFIX."meta_data.meta_data LIKE '%".$value."%') "; + + /** + * append AND/OR, but not on last item + */ + if($i < $num) + { + $sql_buttons .= $and_or; + } + } + + $sql_buttons .= ")"; + + $need_metadata_table = true; + } + } + + /** + * build search string + */ + $search_string = "{colname} LIKE '%"; + $search_string .= implode("%' ".$and_or." {colname} LIKE '%",$array_strings); + $search_string .= "%'"; + + if(isset($_REQUEST['button']['meta']['cmt']) OR isset($_REQUEXT['button']['meta']['all'])) + { + $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_comments.meta_comment",$search_string); + $need_meta_comment_table = true; + } + if(isset($_REQUEST['button']['meta']['name']) OR isset($_REQUEXT['button']['meta']['all'])) + { + $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."photos.name",$search_string); + } + + + + /** + * exif/iptc + */ + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + $MetaData = new MetaData(); + + /** + * exif + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) + { + $MetaData->setFields('exif'); + foreach($MetaData->defined_fields['exif'] AS $key=>$value) + { + if(isset($_REQUEST['button']['exif'][$key]) OR isset($_REQUEST['button']['exif']['all'])) + { + $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_exif.".$key,$search_string); + $need_exif_table = true; + } + } + } + + /** + * iptc + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) + { + $MetaData->setFields('iptc'); + foreach($MetaData->defined_fields['iptc'] AS $key=>$value) + { + if(isset($_REQUEST['button']['iptc'][$key]) OR isset($_REQUEST['button']['iptc']['all'])) + { + $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_iptc.".$key,$search_string); + $need_exif_table = true; + } + } + } + + $sql_buttons .= ") AND "; + } + //echo $sql_buttons.'<br />'; + + + /** + * categories + */ + $sql_categories = ''; + if(isset($_REQUEST['category'])) + { + /** + * add slashes ( and remove empty strings) + */ + $_REQUEST['category'] = addslashes_array($_REQUEST['category']); + + $and_or = get_and_or($_REQUEST['and_or']); + $sql_categories .= "(".C.".category LIKE '%;"; + $sql_categories .= implode(";%' ".$and_or." ".C.".category LIKE '%;",$_REQUEST['category']); + $sql_categories .= ";%'"; + $sql_categories .= ") AND "; + + $need_image_comment_table = true; + } + + //echo $sql_categories.'<br />'; + + + /** + * exif date + */ + $sql_exif_date = ''; + if( (isset($_REQUEST['date_from']['exif']) && $_REQUEST['date_from']['exif']!="") + OR (isset($_REQUEST['date_to']['exif']) && $_REQUEST['date_to']['exif']!="")) + { + if($_REQUEST['date_from']['exif']=="") { + $_REQUEST['date_from']['exif'] = "0000:00:00 00:00:00"; + } + if($_REQUEST['date_to']['exif']=="") { + $_REQUEST['date_to']['exif'] = "4000:00:00 00:00:00"; + } + + $sql_exif_date = "(".PREFIX.".meta_exif.datetimeoriginal between ". + "'".LinSql::linAddslashes($_REQUEST['date_from']['exif'])." 00:00:00' AND ". + "'".LinSql::linAddslashes($_REQUEST['date_to']['exif'])." 23:59:59') AND "; + + $need_exif_table = true; + } + + //echo $sql_exif_date.'<br />'; + + /** + * albums selected + */ + $sql_albums = ""; + if( isset($_REQUEST['album_select']) && !in_array('all',$_REQUEST['album_select']) ) + { + /** + * create an array which holds the addslashed ids + */ + foreach($_REQUEST['album_select'] AS $value) + { + $array_paths[] = LinSql::linAddslashes($value); + } + + $sql_albums .= "(".PREFIX."photos.parent_id = '"; + $sql_albums .= implode("' OR ".PREFIX."photos.parent_id = '",$array_paths); + $sql_albums .= "'"; + $sql_albums .= ") AND "; + } + + //echo $sql_albums.'<br />'; + + + /** + * set sql query string + *DISTINCT + */ + $sql_begin = "SELECT ".PREFIX."photos.id AS id, ".PREFIX."photos.name AS name, ". + PREFIX."photos.md5sum AS md5sum, " . + PREFIX."photos.img_type AS img_type, ". + PREFIX."photos.stats_numbers AS stats_numbers, ".PREFIX."photos.time_add AS time_add "; + + + $sql_where = " FROM ".PREFIX."photos ". + (isset($need_meta_comment_table) ? "LEFT OUTER JOIN ".PREFIX."meta_comments ON ".PREFIX."photos.md5sum = ".PREFIX."meta_comments.md5sum " : ''). + (isset($need_exif_table) ? "LEFT OUTER JOIN ".PREFIX."meta_exif ON ".PREFIX.".photos.md5sum = ".PREFIX."meta_exif.md5sum " : ''). + (isset($need_iptc_table) ? "LEFT OUTER JOIN ".PREFIX."meta_iptc ON ".PREFIX.".photos.md5sum = ".PREFIX."meta_iptc.md5sum " : ''). + "WHERE ".$sql_buttons.$sql_categories.$sql_exif_date.$sql_albums.'1=1'; + + $linpha->db->debug = true; + $linpha->imgview->photos = $GLOBALS['linpha']->db->GetAssoc($sql_begin.$sql_where); + $linpha->db->debug = false; + + //echo '<br /><br /><br />'.$sql_begin.$sql_where.'<br /><br /><br />'; + + if( count($linpha->imgview->photos) == 0 ) + { + $GLOBALS['linpha']->template->output['navigation'] = + '<b>'.i18n("Sorry, Your search did not match any content").'</b><br />'; + } + else + { + $GLOBALS['linpha']->template->output['navigation'] = ''; + } + $GLOBALS['linpha']->template->output['navigation'] .= + '<a class="button" href="'.LINPHA_DIR.'/?cat=search&cmd=new">'. + i18n("New Search").'</a>'. + '<a class="button" href="'.LINPHA_DIR.'/?cat=search&cmd=edit">'. + i18n("Edit Search").'</a>'; + + $linpha->imgview->buildImgView(); +} +else +{ + $linpha->template->setModuleName('search'); + $linpha->template->URL_full = LINPHA_DIR.'/?cat=search'; + $linpha->template->output['title'] = i18n("Search"); + include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/global.html.php'); +} + + + +/** +* validate incoming data from $_GET +*/ +function get_and_or($and_or) +{ + if($and_or == 'AND') { + return 'AND'; + } else { + return 'OR'; + } +} + +function build_album_select($with_all_albs_entry) +{ + ?> + <select name="album_select[]" size="10" multiple="multiple"> + <?php + if($with_all_albs_entry) + { + if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select']=='all') { + $select = ' selected'; + $_REQUEST['album_select'] = Array('all'=>'all'); + } else { + $select = ''; + } + echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'."\n"; + } + + build_album_select_sub_entry(0); + ?> + </select><br /> + <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font> + <?php +} + +function build_album_select_sub_entry($id) +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); + while($data = $query->FetchRow()) + { + if(!isset($_REQUEST['album_select'])) { + $_REQUEST['album_select'] = array(); + } + if(in_array($data['id'],$_REQUEST['album_select'])) { + $select = ' selected'; + } else { + $select = ''; + } + echo '<option value="'.$data['id'].'"'.$select.'>'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; + + build_album_select_sub_entry($data['id']); + } +} +?> \ No newline at end of file Added: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php (rev 0) +++ trunk/linpha2/templates/default/search.html.php 2006-04-12 21:44:03 UTC (rev 4526) @@ -0,0 +1,258 @@ +<style> +.searchcolumn +{ + float: left; + border: 1px solid black; + margin: 10px; + padding: 5px; + width: 300px; +} +</style> +<br /><img src='<?php echo LINPHA_DIR; ?>/lib/graphics/xmag.jpg' alt="Searching Linpha"> + <font size='+1'><?php echo i18n("LinPHA Search Page"); ?></font> +<hr noshade> +<?php +if(isset($error)) +{ + echo "<div align='center'><b>"; + switch($error) + { + case 1: echo i18n("Search string to short, must be at least 2 characters long!"); break; + case 2: echo i18n("Error, please check input!"); break; + } + echo "</b><br /><br /></div>"; +} +?> + +<form name="searchform" method="POST" action="<?php echo LINPHA_DIR; ?>/?cat=search"> + <div class="searchcolumn"> + <!-- search text box //--> + <span class="leftmenulabel"><?php echo i18n("Search Keyword"); ?></span><br /> + <input type="text" name="search_text" style="width:180" value="<?php echo @$_REQUEST['search_text']; ?>"> + + <?php + // text and / or + if(isset($_REQUEST['text_and_or'])) + { + if($_REQUEST['text_and_or']=='AND') + { + $txt_checked_and = " checked"; + $txt_checked_or = ""; + } else { + $txt_checked_and = ""; + $txt_checked_or = " checked"; + } + } else { + $txt_checked_and = " checked"; + $txt_checked_or = ""; + } + ?> + <br /> + (<input type="radio" id="text_and_or_and" name="text_and_or" value="AND"<?php echo $txt_checked_and; ?>><label for="text_and_or_and"><?php echo i18n("AND"); ?></label> + <input type="radio" id="text_and_or_or" name="text_and_or" value="OR"<?php echo $txt_checked_or; ?>><label for="text_and_or_or"><?php echo i18n("OR"); ?></label>) + <br /><br /> + + <input type="checkbox" id="b_all" name="button[meta][all]" value="1"<?php echo isset($_REQUEST['button']['meta']['all']) ? ' checked' : ''; ?> onClick="check_all()"> + <label for="b_all"><b><?php echo i18n("All"); ?></b></label><br /> + + <input type="checkbox" id="b_name" name="button[meta][name]" value="1"<?php echo isset($_REQUEST['button']['meta']['name']) ? ' checked' : ''; ?>> + <label for="b_name"><?php echo i18n("Filename"); ?></label><br /> + + <input type="checkbox" id="b_cmt" name="button[meta][cmt]" value="1"<?php echo isset($_REQUEST['button']['meta']['cmt']) ? ' checked' : ''; ?>> + <label for="b_cmt"><?php echo i18n("Comments"); ?></label><br /> + + <?php + /** + * get text fields + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '1' AND (flags = '5' OR flags = '7')"); + while($data = $query->FetchRow()) + { + echo '<input type="checkbox" id="b_'.$data['id'].'" name="button['.$data['id'].']" value="1"'.(isset($_REQUEST['button'][$data['id']]) ? ' checked' : '').'>'; + echo ' <label for="b_'.$data['id'].'">'.$data['name'].'</label><br />'; + } + + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + $MetaData = new MetaData(); + + /** + * Exif Informations + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) + { + $MetaData->setFields('exif'); + $exif_count = $MetaData->defined_fields['exif']; + ?> + <br /><b><?php echo i18n("Search EXIF"); ?></b><br /> + <input type="checkbox" id="b_exif_all" name="button[exif][all]" value="1"<?php echo isset($_REQUEST['b_exif_all']) ? ' checked' : ''; ?> onClick="check_all()"> + <label for="b_exif_all"><b><?php echo i18n("All"); ?></b></label><br /> + <?php + for($i=1; list($key,$value) = each($MetaData->defined_fields['exif']); $i++) + { + echo '<input type="checkbox" id="b_exif_'.$i.'" name="button[exif]['.$key.']" value="1"'; + echo isset($_REQUEST['button_exif'][$key]) ? ' checked="checked">' : '>'; + echo '<label for="b_exif_'.$i.'">'.$value.'</label><br />'; + } + } + + /** + * Iptc Informations + + if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) + { + $MetaData->setFields('iptc'); + $iptc_count = $MetaData->defined_fields['iptc']; + ?> + <br /><b><?php echo i18n("Search IPTC"); ?></b><br /> + <input type="checkbox" id="b_iptc_all" name="b_iptc_all" value="1"<?php echo isset($_REQUEST['b_iptc_all']) ? ' checked' : ''; ?> onClick="check_all()"> + <?php + echo '<b>'.i18n("All").'</b><br />'; + + for($i=1; list($key,$value) = each($MetaData->defined_fields['iptc']); $i++) + { + echo '<input type="checkbox" id="b_iptc_'.$i.'" name="b_iptc_'.$value.'" value="1"'; + echo isset($_REQUEST['b_iptc_'.$value]) ? ' checked="checked">' : '>'; + echo translateIptcSearchTags($value, "single")."<br />"; + } + }*/ + ?> + <script language="JavaScript" type="text/javascript"> + function check_all(/*start,elem_name,elem_count*/) + { + /* for(var i = 1; i <= elem_count; i++) + { + elem = document.getElementById(elem_name+i); + elemall = document.getElementById(elem_name+'all'); + if(elemall.checked == true) { + elem.checked = true; + elem.disabled = true; + } else { + if(start != 'start') { + elem.checked = false; + elem.disabled = false; + } + } + }*/ + } + // run at startup to select all after startup + //check_all('start','b_',4); + <?php + if(isset($exif_count)) + { + // echo "check_all('start','b_exif_',".$exif_count.");"; + } + if(isset($iptc_count)) + { + //echo "check_all('start','b_iptc_',".$iptc_count.");"; + } + ?> + </script> + </div> + +<!-- select album //--> + <div class="searchcolumn"> + <span class='leftmenulabel'><?php echo i18n("Search In Album"); ?></span><br /> + <?php build_album_select($with_all_albs_entry=true); ?> + </div> + +<!-- date --> + <div class="searchcolumn"> + <!-- exif date --> + <span class='leftmenulabel'><?php echo i18n("Date"); ?> + <a class='FromTo' href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_from','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / + <a class='FromTo' href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_to','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> (Exif) + </span><br /> + + <input type='text' name='date_from[exif]' value='<?php echo @$_REQUEST['date_from']['exif']; ?>' style='width:80'> / + <input type='text' name='date_to[exif]' value='<?php echo @$_REQUEST['date_to']['exif']; ?>' style='width:80'><br /><br /> + + + + <?php + /** + * get date fields + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '3' AND (flags = '5' OR flags = '7')"); + while($data = $query->FetchRow()) + { + ?> + <span><?php echo $data['name']; ?> + <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_from','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / + <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_to','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> + </span><br /> + <input type='text' name='date_from[<?php echo $data['id']; ?>]' value='<?php echo @$_REQUEST['date_from'][$data['id']]; ?>' style='width:80'> / + <input type='text' name='date_to[<?php echo $data['id']; ?>]' value='<?php echo @$_REQUEST['date_to'][$data['id']]; ?>' style='width:80'><br /><br /> + <?php + } + ?> + +<!-- Category --> + <?php + /** + * get select fields + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '2' AND (flags = '5' OR flags = '7')"); + while($data = $query->FetchRow()) + { + if($GLOBALS['linpha']->sql->isAdmin()) + { + $str_isprivate = ''; + } + else + { + $str_isprivate = " AND isprivate = '0'"; + } + + $sub_query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_category WHERE field_id = '".$data['id']."'".$str_isprivate." ORDER by name"); + + /** + * only show categories if they are at least one + */ + if( ! $sub_query->EOF ) + { + // category select + echo '<span>'.$data['name'].'</span><br />'."\n"; + + // and / or + if(isset($_REQUEST['select_and_or'][$data['id']])) + { + if($_REQUEST['select_and_or'][$data['id']]=='AND') + { + $checked_and = " checked"; + $checked_or = ""; + } else { + $checked_and = ""; + $checked_or = " checked"; + } + } else { + $checked_and = " checked"; + $checked_or = ""; + } + ?> + + <input type="radio" name="select_and_or[<?php echo $data['id']; ?>]" value="AND"<?php echo $checked_and; ?>><?php echo i18n("AND"); ?> + <input type="radio" name="select_and_or[<?php echo $data['id']; ?>]" value="OR"<?php echo $checked_or; ?>><?php echo i18n("OR"); ?><br /> + <select name="select[<?php echo $data['id']; ?>][]" size="5" style="width: 180px;" multiple="multiple"> + <?php + while($sub_data = $sub_query->FetchRow()) + { + echo '<option value="'.$sub_data['id'].'">'.$sub_data['name'].'</option>'; + } + ?> + </select><br /> + <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font><br /><br /> + <?php + } + } + ?> + </div> + <div style="clear: both;"></div> + +<!-- submit //--> + <div> + <input type="hidden" name="cmd" value="search"> + <input type="submit" class="button" name="sub" value=" <?php echo i18n("Search"); ?> "> + <a class="button" href="<?php echo LINPHA_DIR; ?>/?cat=search&cmd=new"><?php echo i18n("Reset"); ?></a> + </div> + + </form> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-13 13:19:34
|
Revision: 4532 Author: fangehrn Date: 2006-04-13 06:19:09 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4532&view=rev Log Message: ----------- * finished search feature Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/index.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.search.php trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/search.html.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_meta.html.php trunk/linpha2/templates/default/view_thumb.html.php Added Paths: ----------- trunk/linpha2/admin/settings_features.php trunk/linpha2/lib/include/calender.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/ChangeLog 2006-04-13 13:19:09 UTC (rev 4532) @@ -1,3 +1,7 @@ +2006-04-1* flo + * finished search feature + hope it will work with oracle... ;-) + 2006-04-12 flo * replace some recordCount() with EOF * startet implementing search feature Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/admin/index.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -143,10 +143,8 @@ } echo $text; ?> - <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /> - <label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> - <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/> - <label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> + <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> + <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> <br /> <?php break; Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/admin/settings.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -8,6 +8,7 @@ $array_menu = Array( 'layout' => Array('name' => 'Layout', 'link' => 'settings_layout'), + 'features' => Array('name' => 'Features', 'link' => 'settings_features'), 'others' => Array('name' => 'Others', 'link' => 'settings_others') ); @@ -18,6 +19,9 @@ case 'layout': include_once(LINPHA_DIR.'/admin/settings_layout.php'); break; + case 'features': + include_once(LINPHA_DIR.'/admin/settings_features.php'); + break; case 'others': break; } Added: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php (rev 0) +++ trunk/linpha2/admin/settings_features.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -0,0 +1,44 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +if(!isset($cat3)) +{ + $cat3 = 'others'; +} + +$array_menu = Array( + 'others' => Array('name' => 'Others', 'link' => 'settings_features_others') +); + +print_admin_menu($array_menu,$cat3); +?> + +<form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_features_'.$cat3; ?>"> +<?php + +switch($cat3) +{ +case 'others': + /** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + saveConfig(Array( + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp' + )); + } + + + printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif'); + printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc'); + printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp'); + break; +} +?> +<br /><br /><hr /> +<input type="hidden" name="cmd" value="saveconfig" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> +</form> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/admin/settings_layout.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -7,7 +7,7 @@ } $array_menu = Array( - 'homesite' => Array('name' => 'Home Site', 'link' => 'settings_layout_home'), + 'home' => 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') ); Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -34,6 +34,7 @@ 'sys_import_autoimport' => '1', 'sys_image_exif' => '1', 'sys_image_iptc' => '0', + 'sys_image_xmp' => '0', 'sys_lang' => $_SESSION['language'], 'sys_lang_autolang' => '1', 'sys_path_album_dir' => $_SESSION['album_dir'], Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -338,7 +338,7 @@ break; case 'image': - $GLOBALS['linpha']->template->output['menu_More'] = Array( + $GLOBALS['linpha']->template->output['menu_More']['basket'] = Array( 'name' => i18n("Basket"), 'value' => Array( @@ -346,27 +346,37 @@ Array('name' => i18n("Open Basket"), 'value' => $open_basket_link), Array('name' => i18n("Images In Basket").': '.count($_SESSION['basket_ids']), 'value' => '#') ) - ), - Array( + ); + $GLOBALS['linpha']->template->output['menu_More']['view'] = + Array( 'name' => i18n("View"), 'value' => Array( Array('name' => i18n("Sort"), 'value' => $array_sort_orders_links) ) - ), + ); + + if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) + { + $GLOBALS['linpha']->template->output['menu_More']['edit'] = Array( 'name' => i18n("Edit"), 'value' => Array( Array('name' => i18n("Rotate Left"), 'value' => '#'), Array('name' => i18n("Rotate Right"), 'value' => '#') ) - ), + ); + } + if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) + { + $GLOBALS['linpha']->template->output['menu_More']['metainfo'] = Array( 'name' => i18n("Metainfo"), 'value' => Array( Array('name' => i18n("Edit Image Information"), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=meta') ) - ) - ); + ); + } + break; } } @@ -555,7 +565,7 @@ /** * prepare variables */ - $max_photos_per_page = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrrows'] * $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrrows']; + $max_photos_per_page = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrrows'] * $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrcols']; $this->nr_pages = ceil( $this->tot_photos / $max_photos_per_page ); if(isset($_GET['pn']) && $_GET['pn'] > 1) { Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -513,8 +513,28 @@ $str = addslashes($str); } return $str; -} // end function linpha_addslashes +} // end method linAddslashes +/** +* addslashes to all values of an array +* used for posted data from <select>'s +*/ +function linAddslashesArray(&$array) +{ + if(is_array($array)) + { + foreach($array AS $key=>$value) + { + $array2[$key] = LinSql::linAddslashes($value); + } + } + else + { + $array2 = Array(); + } + + return $array2; +} /** * returns an array with the full pathname of the given id Added: trunk/linpha2/lib/include/calender.php =================================================================== --- trunk/linpha2/lib/include/calender.php (rev 0) +++ trunk/linpha2/lib/include/calender.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -0,0 +1,165 @@ +<?php +/* +* Copyright (c) 2004 Heiko Rutenbeck <bz...@tu...> +* +* 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. +*/ + +if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','../..'); } +$style['tablebg']="#B3BCDE"; + +include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); +?> +<title>Calender - LinPHA</title> +</head> +<body> +<?php + $m = (!isset($_GET['m'])) ? date("n",mktime()) : $_GET['m']; // wenn $m $y noch nicht existiert, aktuellen monat und aktuelles jahr in $m und $y schreiben + $y = (!isset($_GET['y'])) ? date("Y",mktime()) : $_GET['y']; +?> +<div align="center"> +<table bgcolor="<?php echo $style['tablebg']; ?>"> + <tr> + <td valign="top"> +<?php + /*== get what weekday the first is on ==*/ + $month_in_dec = strftime("%m",mktime(0,0,0,$m,1,$y)); + + $tmpd = getdate(mktime(0,0,0,$m,1,$y)); + $firstwday= $tmpd["wday"]; + + $lastday = mk_getLastDayofMonth($m,$y); + + $arr_month_long = Array( + '1' => i18n("January"), + '2' => i18n("February"), + '3' => i18n("March"), + '4' => i18n("April"), + '5' => i18n("May"), + '6' => i18n("June"), + '7' => i18n("July"), + '8' => i18n("August"), + '9' => i18n("September"), + '10' => i18n("October"), + '11' => i18n("November"), + '12' => i18n("December") + ); +?> +<table cellpadding=2 cellspacing=0 border=1> + <tr> + <td colspan=7 bgcolor="<?php echo $style['tablebg']; ?>"> + <table cellpadding=0 cellspacing=0 border=0 width="100%"> + <tr> + <td width="20"><a href="?m=<?php echo (($m-1)<1) ? 12 : $m-1 ; ?>&y=<?php echo (($m-1)<1) ? $y-1 : $y ; ?>&form=<?php echo $_GET['form']; ?>"><<</a></td> + <td bgcolor="<?php echo $style['tablebg']; ?>" align="center"><font size=2> + <?php echo $arr_month_long[intval($month_in_dec)]." ".$y; ?> + </font></td> + <td width="20"><a href="?m=<?php echo (($m+1)>12) ? 1 : $m+1 ; ?>&y=<?php echo (($m+1)>12) ? $y+1 : $y ; ?>&form=<?php echo $_GET['form']; ?>">>></a></td> + </tr> + </table></td> + </tr> + <tr> + <td width="22"><?php echo i18n("Sun"); ?></td> + <td width="22"><?php echo i18n("Mon"); ?></td> + <td width="22"><?php echo i18n("Tue"); ?></td> + <td width="22"><?php echo i18n("Wed"); ?></td> + <td width="22"><?php echo i18n("Thu"); ?></td> + <td width="22"><?php echo i18n("Fri"); ?></td> + <td width="22"><?php echo i18n("Sat"); ?></td> + </tr> + <?php + $d = 1; + $wday = $firstwday; + $firstweek = true; + + /*== loop through all the days of the month ==*/ + while ( $d <= $lastday) + { + + /*== set up blank days for first week ==*/ + if ($firstweek) { + print "<tr>"; + for ($i=1; $i<=$firstwday; $i++) + { print '<td><font size="2"></font></td>'; } + $firstweek = false; + } + + /*== Sunday start week with <tr> ==*/ + if ($wday==0) { print "<tr>"; } + + /*== check for event ==*/ + print "<td>"; + if($d<10) { + if($m<10) { + $tag = "$y:0$m:0$d"; + } else { + $tag = "$y:$m:0$d"; + } + } else { + if($m<10) { + $tag = "$y:0$m:$d"; + } else { + $tag = "$y:$m:$d"; + } + } + + $heute = date("Y:m:d",mktime()); // "01" bis "12" + if($tag==$heute) + { + $font1 = "<font color=\"#FF0000\">"; + $font2 = "</font>"; + } + else + { + $font1 = ""; + $font2 = ""; + } + print "<a href=\"#\" onClick=\"opener.document.getElementById('".$_GET['form']."').value='$tag',window.close();\">$font1$d$font2</a>"; + print "</td>\n"; + + /*== Saturday week with </tr> ==*/ + if ($wday==6) { print "</tr>\n"; } + + $wday++; + $wday = $wday % 7; + $d++; + } +?> +</tr> +</table> +<div align="center"><a href="#" onClick="window.close()"><?php echo i18n("Close Window"); ?></a></div> + + </td> + </tr> +</table> +</div> +</body> +</html> +<?php +/*== get the last day of the month ==*/ +function mk_getLastDayofMonth($mon,$year) +{ + for ($tday=28; $tday <= 31; $tday++) + { + $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); + if ($tdate["mon"] != $mon) + { break; } + + } + $tday--; + + return $tday; +} +?> Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -88,9 +88,9 @@ break; } } -else +elseif(!isset($_SESSION['search'])) { - $_REQUEST['b_all'] = 1; + $_REQUEST['button']['meta']['all'] = 1; } if(isset($_SESSION['search'])) @@ -229,20 +229,18 @@ $search_string .= implode("%' ".$and_or." {colname} LIKE '%",$array_strings); $search_string .= "%'"; - if(isset($_REQUEST['button']['meta']['cmt']) OR isset($_REQUEXT['button']['meta']['all'])) + if(isset($_REQUEST['button']['meta']['cmt']) OR isset($_REQUEST['button']['meta']['all'])) { $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_comments.meta_comment",$search_string); $need_meta_comment_table = true; } - if(isset($_REQUEST['button']['meta']['name']) OR isset($_REQUEXT['button']['meta']['all'])) + if(isset($_REQUEST['button']['meta']['name']) OR isset($_REQUEST['button']['meta']['all'])) { $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."photos.name",$search_string); } - - /** - * exif/iptc + * exif/iptc/xmp */ include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); $MetaData = new MetaData(); @@ -274,7 +272,7 @@ if(isset($_REQUEST['button']['iptc'][$key]) OR isset($_REQUEST['button']['iptc']['all'])) { $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_iptc.".$key,$search_string); - $need_exif_table = true; + $need_iptc_table = true; } } } @@ -288,48 +286,88 @@ * categories */ $sql_categories = ''; - if(isset($_REQUEST['category'])) + if(isset($_REQUEST['select'])) { - /** - * add slashes ( and remove empty strings) - */ - $_REQUEST['category'] = addslashes_array($_REQUEST['category']); + foreach($_REQUEST['select'] AS $key=>$value) + { + $sql_categories .= " ("; - $and_or = get_and_or($_REQUEST['and_or']); - $sql_categories .= "(".C.".category LIKE '%;"; - $sql_categories .= implode(";%' ".$and_or." ".C.".category LIKE '%;",$_REQUEST['category']); - $sql_categories .= ";%'"; - $sql_categories .= ") AND "; - - $need_image_comment_table = true; + /** + * add slashes ( and remove empty strings) + */ + $value = LinSql::linAddslashesArray($value); + + $and_or = get_and_or($_REQUEST['select_and_or'][$key]); + + $num = count($value); + reset($value); + for($i = 1; list($sub_key,$sub_value) = each($value); $i++) + { + $sql_categories .= " (".PREFIX."meta_data.field_id = '".$key."' AND ".PREFIX."meta_data.meta_data LIKE '%;".$sub_value.";%') "; + + /** + * append AND/OR, but not on last item + */ + if($i < $num) + { + $sql_categories .= $and_or; + } + } + $need_metadata_table = true; + + $sql_categories .= " ) AND "; + } } //echo $sql_categories.'<br />'; /** - * exif date - */ + * date (exif) + */ $sql_exif_date = ''; - if( (isset($_REQUEST['date_from']['exif']) && $_REQUEST['date_from']['exif']!="") - OR (isset($_REQUEST['date_to']['exif']) && $_REQUEST['date_to']['exif']!="")) + if( (isset($_REQUEST['date_from_exif']) && $_REQUEST['date_from_exif']!="") + OR (isset($_REQUEST['date_to_exif']) && $_REQUEST['date_to_exif']!="")) { - if($_REQUEST['date_from']['exif']=="") { - $_REQUEST['date_from']['exif'] = "0000:00:00 00:00:00"; + if($_REQUEST['date_from_exif']=="") { + $_REQUEST['date_from_exif'] = "0000:00:00 00:00:00"; } - if($_REQUEST['date_to']['exif']=="") { - $_REQUEST['date_to']['exif'] = "4000:00:00 00:00:00"; + if($_REQUEST['date_to_exif']=="") { + $_REQUEST['date_to_exif'] = "4000:00:00 00:00:00"; } - $sql_exif_date = "(".PREFIX.".meta_exif.datetimeoriginal between ". - "'".LinSql::linAddslashes($_REQUEST['date_from']['exif'])." 00:00:00' AND ". - "'".LinSql::linAddslashes($_REQUEST['date_to']['exif'])." 23:59:59') AND "; + $sql_exif_date = "(".PREFIX."meta_exif.datetimeoriginal BETWEEN ". + "'".LinSql::linAddslashes($_REQUEST['date_from_exif'])." 00:00:00' AND ". + "'".LinSql::linAddslashes($_REQUEST['date_to_exif'])." 23:59:59') AND "; $need_exif_table = true; } //echo $sql_exif_date.'<br />'; + $sql_date = ''; + foreach($_REQUEST['date_from'] AS $key=>$value) + { + if( !empty($_REQUEST['date_from'][$key]) OR !empty($_REQUEST['date_to'][$key])) + { + if($_REQUEST['date_from'][$key]=="") { + $_REQUEST['date_from'][$key] = "0000:00:00 00:00:00"; + } + if($_REQUEST['date_to'][$key]=="") { + $_REQUEST['date_to'][$key] = "4000:00:00 00:00:00"; + } + + $sql_date .= "(".PREFIX."meta_exif.datetimeoriginal BETWEEN ". + "'".LinSql::linAddslashes($_REQUEST['date_from'][$key])." 00:00:00' AND ". + "'".LinSql::linAddslashes($_REQUEST['date_to'][$key])." 23:59:59') AND "; + + $need_exif_table = true; + } + } + + //echo $sql_date.'<br />'; + + /** * albums selected */ @@ -364,17 +402,16 @@ $sql_where = " FROM ".PREFIX."photos ". + (isset($need_metadata_table) ? "LEFT OUTER JOIN ".PREFIX."meta_data ON ".PREFIX."photos.md5sum = ".PREFIX."meta_data.md5sum " : ''). (isset($need_meta_comment_table) ? "LEFT OUTER JOIN ".PREFIX."meta_comments ON ".PREFIX."photos.md5sum = ".PREFIX."meta_comments.md5sum " : ''). - (isset($need_exif_table) ? "LEFT OUTER JOIN ".PREFIX."meta_exif ON ".PREFIX.".photos.md5sum = ".PREFIX."meta_exif.md5sum " : ''). - (isset($need_iptc_table) ? "LEFT OUTER JOIN ".PREFIX."meta_iptc ON ".PREFIX.".photos.md5sum = ".PREFIX."meta_iptc.md5sum " : ''). + (isset($need_exif_table) ? "LEFT OUTER JOIN ".PREFIX."meta_exif ON ".PREFIX."photos.md5sum = ".PREFIX."meta_exif.md5sum " : ''). + (isset($need_iptc_table) ? "LEFT OUTER JOIN ".PREFIX."meta_iptc ON ".PREFIX."photos.md5sum = ".PREFIX."meta_iptc.md5sum " : ''). "WHERE ".$sql_buttons.$sql_categories.$sql_exif_date.$sql_albums.'1=1'; $linpha->db->debug = true; $linpha->imgview->photos = $GLOBALS['linpha']->db->GetAssoc($sql_begin.$sql_where); $linpha->db->debug = false; - //echo '<br /><br /><br />'.$sql_begin.$sql_where.'<br /><br /><br />'; - if( count($linpha->imgview->photos) == 0 ) { $GLOBALS['linpha']->template->output['navigation'] = @@ -417,7 +454,7 @@ function build_album_select($with_all_albs_entry) { ?> - <select name="album_select[]" size="10" multiple="multiple"> + <select name="album_select[]" size="10" multiple="multiple" style="overflow: scroll; width: 200px;"> <?php if($with_all_albs_entry) { @@ -430,14 +467,14 @@ echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'."\n"; } - build_album_select_sub_entry(0); + build_album_select_sub_entry(0,''); ?> </select><br /> <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font> <?php } -function build_album_select_sub_entry($id) +function build_album_select_sub_entry($id,$text) { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); while($data = $query->FetchRow()) @@ -450,9 +487,9 @@ } else { $select = ''; } - echo '<option value="'.$data['id'].'"'.$select.'>'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; + echo '<option value="'.$data['id'].'"'.$select.'>'.$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; - build_album_select_sub_entry($data['id']); + build_album_select_sub_entry($data['id'],$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES)); } } ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/templates/default/global.html.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -80,7 +80,11 @@ <li><a href="./?cat=search"><?php echo i18n("Extended Search"); ?></a></li> <li> <div> - <input type="text" name="search" value="" /> + <form method="GET" action="<?php echo LINPHA_DIR; ?>/?cat=search"> + <input type="text" name="search_text" value="" /> + <input type="hidden" name="button[meta][all]" value="1" /> + <input type="hidden" name="cmd" value="search" /> + <input type="hidden" name="cat" value="search" /> <input type="submit" name="submit" value="<?php echo i18n("Search"); ?>" /> </div> </li> Modified: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/templates/default/search.html.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -1,20 +1,22 @@ <style> -.searchcolumn +.divcolumn { float: left; border: 1px solid black; - margin: 10px; + margin-left: 20px; padding: 5px; width: 300px; + min-height: 380px; } </style> -<br /><img src='<?php echo LINPHA_DIR; ?>/lib/graphics/xmag.jpg' alt="Searching Linpha"> - <font size='+1'><?php echo i18n("LinPHA Search Page"); ?></font> + +<img src="<?php echo LINPHA_DIR; ?>/lib/graphics/xmag.jpg" alt="Searching Linpha"> + <font size="+1"><?php echo i18n("LinPHA Search Page"); ?></font> <hr noshade> <?php if(isset($error)) { - echo "<div align='center'><b>"; + echo '<div align="center"><b>'; switch($error) { case 1: echo i18n("Search string to short, must be at least 2 characters long!"); break; @@ -23,151 +25,110 @@ echo "</b><br /><br /></div>"; } ?> +<div id="divmain"> + <div class="roundtop"> + <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"> -<form name="searchform" method="POST" action="<?php echo LINPHA_DIR; ?>/?cat=search"> - <div class="searchcolumn"> - <!-- search text box //--> - <span class="leftmenulabel"><?php echo i18n("Search Keyword"); ?></span><br /> - <input type="text" name="search_text" style="width:180" value="<?php echo @$_REQUEST['search_text']; ?>"> - - <?php - // text and / or - if(isset($_REQUEST['text_and_or'])) +<div class="divcolumn"> + <form name="searchform" method="GET" action="<?php echo LINPHA_DIR; ?>/"> + + <input type="submit" class="button" name="sub" value=" <?php echo i18n("Search"); ?> "> + <a class="button" href="<?php echo LINPHA_DIR; ?>/?cat=search&cmd=new"><?php echo i18n("Reset"); ?></a> + <br /><br /> + + <!-- search text box //--> + <?php echo i18n("Search Keyword"); ?><br /> + <input type="text" name="search_text" style="width: 180px;" value="<?php echo @$_REQUEST['search_text']; ?>"> + + <?php + // text and / or + if(isset($_REQUEST['text_and_or'])) + { + if($_REQUEST['text_and_or']=='AND') { - if($_REQUEST['text_and_or']=='AND') - { - $txt_checked_and = " checked"; - $txt_checked_or = ""; - } else { - $txt_checked_and = ""; - $txt_checked_or = " checked"; - } - } else { $txt_checked_and = " checked"; $txt_checked_or = ""; + } else { + $txt_checked_and = ""; + $txt_checked_or = " checked"; } - ?> - <br /> - (<input type="radio" id="text_and_or_and" name="text_and_or" value="AND"<?php echo $txt_checked_and; ?>><label for="text_and_or_and"><?php echo i18n("AND"); ?></label> - <input type="radio" id="text_and_or_or" name="text_and_or" value="OR"<?php echo $txt_checked_or; ?>><label for="text_and_or_or"><?php echo i18n("OR"); ?></label>) - <br /><br /> - - <input type="checkbox" id="b_all" name="button[meta][all]" value="1"<?php echo isset($_REQUEST['button']['meta']['all']) ? ' checked' : ''; ?> onClick="check_all()"> - <label for="b_all"><b><?php echo i18n("All"); ?></b></label><br /> + } else { + $txt_checked_and = " checked"; + $txt_checked_or = ""; + } + ?> + <br /> + (<input type="radio" id="text_and_or_and" name="text_and_or" value="AND"<?php echo $txt_checked_and; ?>><label for="text_and_or_and"><?php echo i18n("AND"); ?></label> + <input type="radio" id="text_and_or_or" name="text_and_or" value="OR"<?php echo $txt_checked_or; ?>><label for="text_and_or_or"><?php echo i18n("OR"); ?></label>) + <br /><br /> + + <input type="checkbox" id="b_meta_all" name="button[meta][all]" value="1"<?php echo isset($_REQUEST['button']['meta']['all']) ? ' checked' : ''; ?> onClick="check_all('b_meta_all','meta')"><label for="b_meta_all"><b><?php echo i18n("All"); ?></b></label><br /> + <input type="checkbox" id="b_name" name="button[meta][name]" value="1"<?php echo isset($_REQUEST['button']['meta']['name']) ? ' checked' : ''; ?>><label for="b_name"><?php echo i18n("Filename"); ?></label><br /> + <input type="checkbox" id="b_cmt" name="button[meta][cmt]" value="1"<?php echo isset($_REQUEST['button']['meta']['cmt']) ? ' checked' : ''; ?>><label for="b_cmt"><?php echo i18n("Comments"); ?></label><br /> - <input type="checkbox" id="b_name" name="button[meta][name]" value="1"<?php echo isset($_REQUEST['button']['meta']['name']) ? ' checked' : ''; ?>> - <label for="b_name"><?php echo i18n("Filename"); ?></label><br /> + <?php + /** + * get text fields + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '1' AND (flags = '5' OR flags = '7')"); + while($data = $query->FetchRow()) + { + echo '<input type="checkbox" id="b_'.$data['id'].'" name="button[meta]['.$data['id'].']" value="1"'.(isset($_REQUEST['button']['meta'][$data['id']]) ? ' checked' : '').'>'; + echo '<label for="b_'.$data['id'].'">'.$data['name'].'</label><br />'; + } - <input type="checkbox" id="b_cmt" name="button[meta][cmt]" value="1"<?php echo isset($_REQUEST['button']['meta']['cmt']) ? ' checked' : ''; ?>> - <label for="b_cmt"><?php echo i18n("Comments"); ?></label><br /> + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + $MetaData = new MetaData(); - <?php - /** - * get text fields - */ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."meta_fields WHERE field_type = '1' AND (flags = '5' OR flags = '7')"); - while($data = $query->FetchRow()) - { - echo '<input type="checkbox" id="b_'.$data['id'].'" name="button['.$data['id'].']" value="1"'.(isset($_REQUEST['button'][$data['id']]) ? ' checked' : '').'>'; - echo ' <label for="b_'.$data['id'].'">'.$data['name'].'</label><br />'; - } - - include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); - $MetaData = new MetaData(); - - /** - * Exif Informations - */ - if($GLOBALS['linpha']->sql->config->value['sys_image_exif']) - { - $MetaData->setFields('exif'); - $exif_count = $MetaData->defined_fields['exif']; - ?> - <br /><b><?php echo i18n("Search EXIF"); ?></b><br /> - <input type="checkbox" id="b_exif_all" name="button[exif][all]" value="1"<?php echo isset($_REQUEST['b_exif_all']) ? ' checked' : ''; ?> onClick="check_all()"> - <label for="b_exif_all"><b><?php echo i18n("All"); ?></b></label><br /> - <?php - for($i=1; list($key,$value) = each($MetaData->defined_fields['exif']); $i++) - { - echo '<input type="checkbox" id="b_exif_'.$i.'" name="button[exif]['.$key.']" value="1"'; - echo isset($_REQUEST['button_exif'][$key]) ? ' checked="checked">' : '>'; - echo '<label for="b_exif_'.$i.'">'.$value.'</label><br />'; - } - } - - /** - * Iptc Informations - - if($GLOBALS['linpha']->sql->config->value['sys_image_iptc']) - { - $MetaData->setFields('iptc'); - $iptc_count = $MetaData->defined_fields['iptc']; - ?> - <br /><b><?php echo i18n("Search IPTC"); ?></b><br /> - <input type="checkbox" id="b_iptc_all" name="b_iptc_all" value="1"<?php echo isset($_REQUEST['b_iptc_all']) ? ' checked' : ''; ?> onClick="check_all()"> - <?php - echo '<b>'.i18n("All").'</b><br />'; - - for($i=1; list($key,$value) = each($MetaData->defined_fields['iptc']); $i++) - { - echo '<input type="checkbox" id="b_iptc_'.$i.'" name="b_iptc_'.$value.'" value="1"'; - echo isset($_REQUEST['b_iptc_'.$value]) ? ' checked="checked">' : '>'; - echo translateIptcSearchTags($value, "single")."<br />"; - } - }*/ - ?> - <script language="JavaScript" type="text/javascript"> - function check_all(/*start,elem_name,elem_count*/) - { - /* for(var i = 1; i <= elem_count; i++) - { - elem = document.getElementById(elem_name+i); - elemall = document.getElementById(elem_name+'all'); - if(elemall.checked == true) { - elem.checked = true; - elem.disabled = true; - } else { - if(start != 'start') { - elem.checked = false; - elem.disabled = false; - } - } - }*/ - } - // run at startup to select all after startup - //check_all('start','b_',4); - <?php - if(isset($exif_count)) - { - // echo "check_all('start','b_exif_',".$exif_count.");"; - } - if(isset($iptc_count)) - { - //echo "check_all('start','b_iptc_',".$iptc_count.");"; - } - ?> - </script> - </div> - + /** + * Exif/Iptc/Xmp Informations + */ + $array = Array('exif','iptc','xmp'); + foreach($array AS $meta_type) + { + if($GLOBALS['linpha']->sql->config->value['sys_image_'.$meta_type]) + { + $MetaData->setFields($meta_type); + $exif_count = $MetaData->defined_fields[$meta_type]; + ?> + <br /><b><?php echo i18n("Search").strtoupper($meta_type); ?></b><br /> + <input type="checkbox" id="b_<?php echo $meta_type; ?>_all" name="button[<?php echo $meta_type; ?>][all]" value="1"<?php echo isset($_REQUEST['b_'.$meta_type.'_all']) ? ' checked' : ''; ?> onClick="check_all('b_<?php echo $meta_type; ?>_all','<?php echo $meta_type; ?>')"><label for="b_<?php echo $meta_type; ?>_all"><b><?php echo i18n("All"); ?></b></label> + <a href="javascript:div_expand('div_<?php echo $meta_type; ?>');"><img border="0" src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/expand.gif'; ?>" /></a> + <br /> + <div id="div_<?php echo $meta_type; ?>" style="border: 1px solid black; width: 200px;"> + <?php + for($i=1; list($key,$value) = each($MetaData->defined_fields[$meta_type]); $i++) + { + echo '<input type="checkbox" id="b_'.$meta_type.'_'.$i.'" name="button['.$meta_type.']['.$key.']" value="1"'; + echo isset($_REQUEST['button'][$meta_type][$key]) ? ' checked="checked">' : '>'; + echo '<label for="b_'.$meta_type.'_'.$i.'">'.$value.'</label><br />'; + } + ?> + </div> + <?php + } + } + ?> + <br /> +</div> +<div class="divcolumn"> <!-- select album //--> - <div class="searchcolumn"> - <span class='leftmenulabel'><?php echo i18n("Search In Album"); ?></span><br /> + <b><?php echo i18n("Search In Album"); ?><b><br /> <?php build_album_select($with_all_albs_entry=true); ?> - </div> + <br /><br /> <!-- date --> - <div class="searchcolumn"> - <!-- exif date --> - <span class='leftmenulabel'><?php echo i18n("Date"); ?> - <a class='FromTo' href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_from','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / - <a class='FromTo' href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_to','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> (Exif) - </span><br /> - - <input type='text' name='date_from[exif]' value='<?php echo @$_REQUEST['date_from']['exif']; ?>' style='width:80'> / - <input type='text' name='date_to[exif]' value='<?php echo @$_REQUEST['date_to']['exif']; ?>' style='width:80'><br /><br /> + <!-- exif date --> + <?php echo i18n("Date"); ?> (EXIF) + <a class="FromTo" href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/lib/include/calender.php?form=date_from_exif','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / + <a class="FromTo" href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/lib/include/calender.php?form=date_to_exif','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> + </span><br /> + + <input type="text" id="date_from_exif" name="date_from_exif" value="<?php echo @$_REQUEST['date_from_exif']; ?>" style="width: 80px;"> / + <input type="text" id="date_to_exif" name="date_to_exif" value="<?php echo @$_REQUEST['date_to_exif']; ?>" style="width: 80px;"><br /><br /> - - <?php /** * get date fields @@ -177,11 +138,11 @@ { ?> <span><?php echo $data['name']; ?> - <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_from','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / - <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/actions/calender.php?form=searchform.date_to','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> + <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/lib/include/calender.php?form=date_from_<?php echo $data['id']; ?>','Calender','height=250,width=300,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("From"); ?></a> / + <a href="javascript:void(0);" onclick="var loginWin = window.open('<?php echo LINPHA_DIR; ?>/lib/include/calender.php?form=date_to_<?php echo $data['id']; ?>','Calender','height=250,width=250,scrollbars=no,menubar=no,status=no');" target="_top"><?php echo i18n("To"); ?></a> </span><br /> - <input type='text' name='date_from[<?php echo $data['id']; ?>]' value='<?php echo @$_REQUEST['date_from'][$data['id']]; ?>' style='width:80'> / - <input type='text' name='date_to[<?php echo $data['id']; ?>]' value='<?php echo @$_REQUEST['date_to'][$data['id']]; ?>' style='width:80'><br /><br /> + <input type="text" id="date_from_<?php echo $data['id']; ?>" name="date_from[<?php echo $data['id']; ?>]" value="<?php echo @$_REQUEST['date_from'][$data['id']]; ?>" style="width: 80px;"> / + <input type="text" id="date_to_<?php echo $data['id']; ?>" name="date_to[<?php echo $data['id']; ?>]" value="<?php echo @$_REQUEST['date_to'][$data['id']]; ?>" style="width: 80px;"><br /><br /> <?php } ?> @@ -230,13 +191,20 @@ } ?> - <input type="radio" name="select_and_or[<?php echo $data['id']; ?>]" value="AND"<?php echo $checked_and; ?>><?php echo i18n("AND"); ?> - <input type="radio" name="select_and_or[<?php echo $data['id']; ?>]" value="OR"<?php echo $checked_or; ?>><?php echo i18n("OR"); ?><br /> + <input type="radio" id="select_and[<?php echo $data['id']; ?>]" name="select_and_or[<?php echo $data['id']; ?>]" value="AND"<?php echo $checked_and; ?>><label for="select_and[<?php echo $data['id']; ?>]"><?php echo i18n("AND"); ?></label> + <input type="radio" id="select_or[<?php echo $data['id']; ?>]" name="select_and_or[<?php echo $data['id']; ?>]" value="OR"<?php echo $checked_or; ?>><label for="select_or[<?php echo $data['id']; ?>]"><?php echo i18n("OR"); ?></label><br /> + <select name="select[<?php echo $data['id']; ?>][]" size="5" style="width: 180px;" multiple="multiple"> <?php while($sub_data = $sub_query->FetchRow()) { - echo '<option value="'.$sub_data['id'].'">'.$sub_data['name'].'</option>'; + if(isset($_REQUEST['select'][$data['id']]) && in_array($sub_data['id'],$_REQUEST['select'][$data['id']])) { + $select = ' selected'; + } else { + $select = ''; + } + + echo '<option value="'.$sub_data['id'].'"'.$select.'>'.$sub_data['name'].'</option>'; } ?> </select><br /> @@ -245,14 +213,84 @@ } } ?> - </div> - <div style="clear: both;"></div> <!-- submit //--> <div> - <input type="hidden" name="cmd" value="search"> - <input type="submit" class="button" name="sub" value=" <?php echo i18n("Search"); ?> "> - <a class="button" href="<?php echo LINPHA_DIR; ?>/?cat=search&cmd=new"><?php echo i18n("Reset"); ?></a> + <input type="hidden" name="cmd" value="search" /> + <input type="hidden" name="cat" value="search" /> </div> +</div> +<div style="clear: both;"></div> - </form> \ No newline at end of file + </form> + + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> + +<script language="JavaScript" type="text/javascript"> +function div_expand(tag_id) +{ + if( document.getElementById(tag_id) ) + { + if( document.getElementById(tag_id).style.display != 'none' ) + { + document.getElementById(tag_id).style.display = 'none'; + } + else + { + document.getElementById(tag_id).style.display = ''; + } + } +} + +div_expand('div_exif'); +div_expand('div_iptc'); +div_expand('div_xmp'); + + +function check_all(tag_id,section) +{ + if (!document.getElementsByTagName){ return; } + var checkboxes = document.getElementsByTagName('input'); + + elemall = document.getElementById(tag_id); + + // loop through anchors, find other images in set, and add them to imageArray + for (var i=0; i<checkboxes.length; i++){ + var checkbox = checkboxes[i]; + + var relAttribute = String(checkbox.getAttribute('name')); + + if (checkbox.getAttribute('type') && checkbox.getAttribute('type') == 'checkbox' + && (relAttribute.toLowerCase().match(section)) + && checkbox.getAttribute('id')!=tag_id) // do not disable the 'all' button! + { + if(elemall.checked == true) { + checkbox.checked = true; + checkbox.disabled = true; + } else { + checkbox.checked = false; + checkbox.disabled = false; + } + } + } +} + + +// run at startup to select all after startup +check_all('b_meta_all','meta'); +<?php +if(isset($exif_count)) +{ + // echo "check_all('start','b_exif_',".$exif_count.");"; +} +if(isset($iptc_count)) +{ + //echo "check_all('start','b_iptc_',".$iptc_count.");"; +} +?> +</script> \ No newline at end of file Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/templates/default/view_img.html.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -54,7 +54,18 @@ <input type="submit" name="submit" value="<?php echo i18n("submit"); ?>" /> </form> </div> + <script language="JavaScript" type="text/javascript"> + function open_textarea() + { + document.getElementById('comment_textarea').style.display = 'block'; + document.getElementById('comment_div_text').style.display = 'none'; + + document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; + } + </script> + <br /><br /> + <?php } /* end if checkPermission('metadata_comments') */ ?> <!-- show image comments --> <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> @@ -66,17 +77,6 @@ </div> <?php } ?> - <script language="JavaScript" type="text/javascript"> - function open_textarea() - { - document.getElementById('comment_textarea').style.display = 'block'; - document.getElementById('comment_div_text').style.display = 'none'; - - document.getElementById('comment_textarea').value = document.getElementById('comment_input_text').value; - } - </script> - <?php } /* end if checkPermission('metadata_comments') */ ?> - <?php } /* end if view!=meta */ ?> </div> Modified: trunk/linpha2/templates/default/view_meta.html.php =================================================================== --- trunk/linpha2/templates/default/view_meta.html.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/templates/default/view_meta.html.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -4,6 +4,12 @@ */ ?> +<style> +#mainimage +{ + width: 300px; +} +</style> <a href="<?php echo $GLOBALS['linpha']->template->URL_full.'&view=img'; ?>">Back to normal view</a> <h1><?php i18n("Edit Image Imformation"); ?></h1> <?php Modified: trunk/linpha2/templates/default/view_thumb.html.php =================================================================== --- trunk/linpha2/templates/default/view_thumb.html.php 2006-04-13 11:03:12 UTC (rev 4531) +++ trunk/linpha2/templates/default/view_thumb.html.php 2006-04-13 13:19:09 UTC (rev 4532) @@ -49,12 +49,12 @@ <div id="main"> <?php // javascript disabled - if( ! $GLOBALS['linpha']->imgview->use_javascript) + if( ! $GLOBALS['linpha']->imgview->use_javascript && isset($GLOBALS['linpha']->imgview->photos_show)) { for($i=1; list($key,$value) = each($GLOBALS['linpha']->imgview->photos_show); $i++) { // add clear float to last div on row - if( ($i-1) % $GLOBALS['no_js_nr_cols'] == 0) { + if( ($i-1) % $GLOBALS['linpha']->sql->config->value['sys_style_thumb_nojsnrcols'] == 0) { $str_clear = ' clear: left;'; } else { $str_clear = ''; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-04-13 13:31:14
|
Revision: 4533 Author: bzrudi Date: 2006-04-13 06:30:53 -0700 (Thu, 13 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4533&view=rev Log Message: ----------- Oracle related improvements Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/step10_postsettings.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step7_selectprefix.php trunk/linpha2/install/step8_testing.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/ChangeLog 2006-04-13 13:30:53 UTC (rev 4533) @@ -1,4 +1,10 @@ -2006-04-1* flo +2006-04-13 bzrudi <linpha2_AT_tuxpower_DOT_de> + * replace all remaining recordCount() with EOF + * some oracle related fixes + * Installer: + - Oracle related improvements + +2006-04-13 flo * finished search feature hope it will work with oracle... ;-) Modified: trunk/linpha2/install/step10_postsettings.php =================================================================== --- trunk/linpha2/install/step10_postsettings.php 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/install/step10_postsettings.php 2006-04-13 13:30:53 UTC (rev 4533) @@ -62,7 +62,7 @@ <div class="boxalign"> <?php echo tr("Admin Username").":"; ?> <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" - name="admin_name" value="admin"> + name="admin_name" value="root"> </div> <div class="boxalign"> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/install/step5_getlogin.php 2006-04-13 13:30:53 UTC (rev 4533) @@ -217,7 +217,9 @@ } elseif($_SESSION['sql_dbtype'] == 'oci8po') { - echo tr("WOW, playing with the big ones"); + echo tr("NOTE: Oracle support is only testet on XE the \"Free\" Edition. " . + "If you get things running using a \"real\" Oracle Database please " . + "drop us a note!")."<br /><br />"; $_SESSION['sql_dbport'] = '1521'; } ?> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/install/step6_selectdatabase.php 2006-04-13 13:30:53 UTC (rev 4533) @@ -213,8 +213,15 @@ } if($_SESSION['allowed_to_create_db'] == false AND !isset($database)) -{ - echo tr("Name Of Database To Use (Must Exist)").":<br />"; +{ + if($_SESSION['sql_dbname'] == 'oci8po') + { + echo tr("Name Of Database To Use, this is usually \"XE\" For Oracle Express Edition"); + } + else + { + echo tr("Name Of Database To Use (Must Exist)").":<br />"; + } ?> <input type="text" name="sql_dbname_installinto" value="<?php echo isset($_SESSION['sql_dbname']) ? Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/install/step7_selectprefix.php 2006-04-13 13:30:53 UTC (rev 4533) @@ -201,9 +201,14 @@ } break; case "oci8po": + echo tr("Testing Server Connection")."<br /><br />"; + echo tr("Connecting ORACLE-Server")."... "; + /** + * make already use of ADBDO as native oci_connet() sucks + */ include_once('../lib/adodb/adodb.inc.php'); - $link = NewADOConnection('oci8po'); - $link ->connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $_SESSION['sql_username'], $_SESSION['sql_password'], $_SESSION['sql_dbname']); + $link = ADONewConnection('oci8po'); + $link ->Connect($_SESSION['sql_hostname'].":".$_SESSION['sql_dbport'], $_SESSION['sql_username'], $_SESSION['sql_password'], $_SESSION['sql_dbname']); if (!$link) { echo failed_msg(); @@ -237,7 +242,7 @@ <br /><br /> <hr> <br /> - <?php echo tr("Please Enter Database Prefix For Linpha Tables (Leave For Default)").": <br />" ?> + <?php echo tr("Please Enter Database Prefix For Linpha Tables (Default: linpha_)").": <br />" ?> <input type="text" id="check01" onKeyup="checkForm()" name="sql_prefix" value="<?php echo isset($_SESSION['sql_prefix']) ? $_SESSION['sql_prefix'] : 'linpha_' ; ?>"> Modified: trunk/linpha2/install/step8_testing.php =================================================================== --- trunk/linpha2/install/step8_testing.php 2006-04-13 13:19:09 UTC (rev 4532) +++ trunk/linpha2/install/step8_testing.php 2006-04-13 13:30:53 UTC (rev 4533) @@ -128,7 +128,7 @@ * try to create a new db user */ $n_runs = 1; -if($_SESSION['sql_dbtype']=="mysql") +if($_SESSION['sql_dbtype'] == "mysql") { echo tr("Trying To Create New LinPHA Database User")."... "; $random_pass = random_password(8); @@ -286,7 +286,10 @@ } } else -{ +{ + /** + * skip tests for sqlite + */ echo tr("Skipping Database Tests"); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-14 14:04:22
|
Revision: 4534 Author: fangehrn Date: 2006-04-14 07:03:58 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4534&view=rev Log Message: ----------- 2006-04-14 flo * startet implementing basket checkout features (download, print, mail) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/TODO.txt trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/lib/modules/module.search.php trunk/linpha2/templates/default/basket.html.php trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/search.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/ChangeLog 2006-04-14 14:03:58 UTC (rev 4534) @@ -1,3 +1,10 @@ +2006-04-14 flo + * startet implementing basket checkout features (download, print, mail) + +2006-04-13 flo + * finished search feature + hope it will work with oracle... ;-) + 2006-04-13 bzrudi <linpha2_AT_tuxpower_DOT_de> * replace all remaining recordCount() with EOF * some oracle related fixes @@ -4,10 +11,6 @@ * Installer: - Oracle related improvements -2006-04-13 flo - * finished search feature - hope it will work with oracle... ;-) - 2006-04-12 flo * replace some recordCount() with EOF * startet implementing search feature Modified: trunk/linpha2/docs/TODO.txt =================================================================== --- trunk/linpha2/docs/TODO.txt 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/docs/TODO.txt 2006-04-14 14:03:58 UTC (rev 4534) @@ -21,7 +21,6 @@ -> an idea: only delete content of tmp, cache and sql folders if they are not changed - DONT add feature to drop tables if they already exists -- Search (copy from linpha1) - Basket (finish) - Support for the Icons @@ -54,7 +53,7 @@ DONE ==== - +- Search (copy from linpha1) - use lightbox http://www.huddletogether.com/projects/lightbox2/ - get_image.php (Image View, Image Cache) Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -148,7 +148,6 @@ function buildImgView() { $this->filterPhotosNotPermitted(); - $this->setMenu(); /** * doing some special commands @@ -160,6 +159,12 @@ $this->slideshow(); } + /** + * set admin menu and more menu + * this should be done after adminCommands, because of + * "nr images in basket" is changed in adminCommands() + */ + $this->setMenu(); /** * set mode specific things @@ -167,7 +172,7 @@ switch($this->mode) { case 'home': - $this->viewHome_view(); + $this->viewHome(); break; case 'thumb': switch($_SESSION['mode_thumbview']) @@ -281,7 +286,8 @@ $array_sort_orders_links[] = Array('name' => i18n($value), 'value' => $GLOBALS['linpha']->template->URL_full.'&order_by='.$value); } - $open_basket_link = LINPHA_DIR.'?cat=basket&ref_id='.$this->id_current; + $_SESSION['basket_ref_url'] = $GLOBALS['linpha']->template->URL_full; + $open_basket_link = LINPHA_DIR.'/?cat=basket&ref_id='.$this->id_current; switch($this->mode) { @@ -306,10 +312,9 @@ Array( 'name' => i18n("Basket"), 'value' => Array( - Array('name' => i18n("Add all To Basket"), 'value' => $open_basket_link.'&cmd=add_all'), + Array('name' => i18n("Add All To Basket"), 'value' => $GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all'), Array('name' => i18n("Switch To Basket View"), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=basket'), - Array('name' => i18n("Open Basket"), 'value' => $open_basket_link), - Array('name' => i18n("Images In Basket").': '.count($_SESSION['basket_ids']), 'value' => '#') + Array('name' => i18n("Open Basket").' ('.count($_SESSION['basket_ids']).' '.i18n("Images").')', 'value' => $open_basket_link) ) ); @@ -342,9 +347,8 @@ Array( 'name' => i18n("Basket"), 'value' => Array( - Array('name' => i18n("Add To Basket"), 'value' => '#'), - Array('name' => i18n("Open Basket"), 'value' => $open_basket_link), - Array('name' => i18n("Images In Basket").': '.count($_SESSION['basket_ids']), 'value' => '#') + Array('name' => i18n("Add To Basket"), 'value' => $GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this'), + Array('name' => i18n("Open Basket").' ('.count($_SESSION['basket_ids']).' '.i18n("Images").')', 'value' => $open_basket_link) ) ); $GLOBALS['linpha']->template->output['menu_More']['view'] = @@ -389,17 +393,32 @@ */ function adminCommands() { - if($GLOBALS['linpha']->sql->isAdmin()) + switch($_GET['admin_cmd']) { - switch($_GET['admin_cmd']) + case 'recreate': + if($GLOBALS['linpha']->sql->isAdmin()) { - case 'recreate': - LinImage::createThumbnail($this->id_current,$this->img_type,$force=true); - break; - case 'rotate_left': - case 'rotate_right': - break; + LinImage::createThumbnail($this->id_current,$this->img_type,$force=true); } + break; + case 'rotate_left': + case 'rotate_right': + if($GLOBALS['linpha']->sql->isAdmin()) + { + } + break; + case 'basket_add_all': // coming from imgview, mode=viewThumb + foreach($this->photos_filtered AS $value) + { + if($value['img_type']!=0) + { + $_SESSION['basket_ids'][] = $value['id']; + } + } + break; + case 'basket_add_this': // coming from imgview, mode=viewImg + $_SESSION['basket_ids'][] = $this->id_current; + break; } } @@ -728,7 +747,7 @@ /** * setup main/home view layout */ -function viewHome_view() +function viewHome() { $GLOBALS['linpha']->template->setModuleName('home'); Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -34,38 +34,12 @@ { switch($_GET['cmd']) { + case 'checkout': + break; /** - * add all - */ - case 'add_all': - - if( isset( $_GET['ref_id'] ) ) - { - $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos " . - "WHERE img_type <> '0' " . - "AND parent_id = '".linSql::linAddslashes($_GET['ref_id'])."'"); - - while($data = $query->FetchRow()) - { - if($GLOBALS['linpha']->sql->photoIsAllowed($data[0])) - { - $_SESSION['basket_ids'][] = $data[0]; - } - } - $ref_id = $_GET['ref_id']; - } - else - { - $ref_id = 0; - } - - Header("Location: ".LINPHA_DIR."/?cat=alb&id=".$ref_id."&ref=imgids_added"); - exit(); - - - /** * add ids to session if allowed + * coming from imgview, mode=viewBasket */ case 'add_selected': @@ -79,7 +53,8 @@ } } } - Header("Location: ".LINPHA_DIR."/?cat=alb&id=".$_GET['ref_id']."&ref=imgids_added"); + + Header("Location: ".convert_amp($_SESSION['basket_ref_url'])); exit(); /** Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -42,7 +42,6 @@ switch($_REQUEST['cmd']) { case 'search': - /** * search string to short */ @@ -71,7 +70,7 @@ break; case 'new': unset($_SESSION['search']); - $_REQUEST['b_all'] = true; + $_REQUEST['button']['meta']['all'] = 1; break; case 'edit': if(isset($_SESSION['search'])) @@ -193,7 +192,13 @@ * get text fields */ $sql_buttons = "(1=2"; - $and_or = get_and_or($_REQUEST['text_and_or']); + + if( !isset($_REQUEST['text_and_or']) OR $_REQUEST['text_and_or'] == "AND") { + $and_or = "AND"; + } else { + $and_or = "OR"; + } + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."meta_fields WHERE field_type = '1' AND (flags = '5' OR flags = '7')"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { @@ -277,6 +282,22 @@ } } + /** + * xmp + */ + if($GLOBALS['linpha']->sql->config->value['sys_image_xmp']) + { + $MetaData->setFields('xmp'); + foreach($MetaData->defined_fields['xmp'] AS $key=>$value) + { + if(isset($_REQUEST['button']['xmp'][$key]) OR isset($_REQUEST['button']['xmp']['all'])) + { + $sql_buttons .= " OR ".str_replace('{colname}',PREFIX."meta_xmp.".$key,$search_string); + $need_xmp_table = true; + } + } + } + $sql_buttons .= ") AND "; } //echo $sql_buttons.'<br />'; @@ -297,7 +318,11 @@ */ $value = LinSql::linAddslashesArray($value); - $and_or = get_and_or($_REQUEST['select_and_or'][$key]); + if( !isset($_REQUEST['select_and_or'][$key]) OR $_REQUEST['select_and_or'][$key] == "AND") { + $and_or = "AND"; + } else { + $and_or = "OR"; + } $num = count($value); reset($value); @@ -326,13 +351,13 @@ * date (exif) */ $sql_exif_date = ''; - if( (isset($_REQUEST['date_from_exif']) && $_REQUEST['date_from_exif']!="") - OR (isset($_REQUEST['date_to_exif']) && $_REQUEST['date_to_exif']!="")) + if( (isset($_REQUEST['date_from_exif']) && !empty($_REQUEST['date_from_exif']) ) + OR (isset($_REQUEST['date_to_exif']) && !empty($_REQUEST['date_to_exif']) ) ) { - if($_REQUEST['date_from_exif']=="") { + if( !isset($_REQUEST['date_from_exif']) OR empty($_REQUEST['date_from_exif']) ) { $_REQUEST['date_from_exif'] = "0000:00:00 00:00:00"; } - if($_REQUEST['date_to_exif']=="") { + if( !isset($_REQUEST['date_to_exif']) OR empty($_REQUEST['date_to_exif']) ) { $_REQUEST['date_to_exif'] = "4000:00:00 00:00:00"; } @@ -346,22 +371,27 @@ //echo $sql_exif_date.'<br />'; $sql_date = ''; - foreach($_REQUEST['date_from'] AS $key=>$value) + if(isset($_REQUEST['date_from'])) { - if( !empty($_REQUEST['date_from'][$key]) OR !empty($_REQUEST['date_to'][$key])) + foreach($_REQUEST['date_from'] AS $key=>$value) { - if($_REQUEST['date_from'][$key]=="") { - $_REQUEST['date_from'][$key] = "0000:00:00 00:00:00"; + + if( (isset($_REQUEST['date_from'][$key]) && !empty($_REQUEST['date_from'][$key]) ) + OR (isset($_REQUEST['date_to'][$key]) && !empty($_REQUEST['date_to'][$key]) ) ) + { + if( !isset($_REQUEST['date_from'][$key]) OR empty($_REQUEST['date_from'][$key]) ) { + $_REQUEST['date_from'][$key] = "0000:00:00 00:00:00"; + } + if( !isset($_REQUEST['date_to'][$key]) OR empty($_REQUEST['date_to'][$key]) ) { + $_REQUEST['date_to'][$key] = "4000:00:00 00:00:00"; + } + + $sql_date .= "(".PREFIX."meta_exif.datetimeoriginal BETWEEN ". + "'".LinSql::linAddslashes($_REQUEST['date_from'][$key])." 00:00:00' AND ". + "'".LinSql::linAddslashes($_REQUEST['date_to'][$key])." 23:59:59') AND "; + + $need_exif_table = true; } - if($_REQUEST['date_to'][$key]=="") { - $_REQUEST['date_to'][$key] = "4000:00:00 00:00:00"; - } - - $sql_date .= "(".PREFIX."meta_exif.datetimeoriginal BETWEEN ". - "'".LinSql::linAddslashes($_REQUEST['date_from'][$key])." 00:00:00' AND ". - "'".LinSql::linAddslashes($_REQUEST['date_to'][$key])." 23:59:59') AND "; - - $need_exif_table = true; } } @@ -438,19 +468,6 @@ } - -/** -* validate incoming data from $_GET -*/ -function get_and_or($and_or) -{ - if($and_or == 'AND') { - return 'AND'; - } else { - return 'OR'; - } -} - function build_album_select($with_all_albs_entry) { ?> Modified: trunk/linpha2/templates/default/basket.html.php =================================================================== --- trunk/linpha2/templates/default/basket.html.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/templates/default/basket.html.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -1,4 +1,3 @@ -<form name="basket" action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&cmd=remove_selected" method="POST"> <div id="divnavigation"> <div class="roundtop"> @@ -6,11 +5,176 @@ </div> <div id="navigation"> - <a href="<?php echo LINPHA_DIR.'/?cat=alb&id='.$_GET['ref_id']; ?>"><?php echo i18n("Go Back"); ?></a> - <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&cmd=remove_all"><?php echo i18n("Remove all"); ?></a> - <input type="submit" name="submit" value="<?php echo i18n("Remove selected"); ?>" /> + <a style="float: left; margin-right: 2px;" class="button" href="<?php echo $_SESSION['basket_ref_url']; ?>"><?php echo i18n("Go Back"); ?></a> + <form name="basket_checkout" style="float: left; margin-right: 2px;" action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>" method="POST"> + <select class="button" name="checkout_as" onchange="document.basket_checkout.submit()"> + <option value=""><?php echo i18n("Checkout"); ?></option> + <option value="download"><?php echo i18n("Download"); ?></option> + <option value="mail"><?php echo i18n("Send As Mail"); ?></option> + <option value="print"><?php echo i18n("Print"); ?></option> + </select> + </form> + + <form name="basket_remove" action="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&cmd=remove_selected" method="POST"> + <a class="button" href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&cmd=remove_all"><?php echo i18n("Remove all"); ?></a> + <input class="button" type="submit" name="submit" value="<?php echo i18n("Remove selected"); ?>" /> <br /><br /> <?php echo i18n("Images in basket");?>: <?php echo count($_SESSION['basket_ids']); ?> + + <?php + if(isset($_POST['checkout_as'])) + { + switch($_POST['checkout_as']) + { + case 'download': + /** + * error handling + */ + if(isset($_GET['error'])) + { + switch($_GET['error']) + { + case 1: linSysLog(i18n("Error").": ".i18n("No Images Selected!")); break; // user tried to download zip, but didn't even select a single image ;-) + case 2: linSysLog(i18n("Error").": ".i18n("The download couldn't be started for some reasons!")); break; // created archive doesn't exists... + case 3: linSysLog(i18n("Error").": ".i18n("Wrong input data")); break; // no valid imgid's + } + } + + echo i18n("Select Type Of Archive"); + ?> + <br /><br /> + <form name="zip_selected" action="<?php echo LINPHA_DIR; ?>/actions/basket_build_zip.php" method="POST"> + <select name="ziptype" size="1" style="width: 175px;"> + <?php + /*include_once(TOP_DIR.'/include/archiver.class.php'); + $apps = new Archive_Applications(); + $apps->searchApps(); + + foreach($apps->found_apps AS $key=>$value) + { + $value = $key.' (.'.$apps->apps[$key]['file_ext'].')'; + echo '<option value="'.$key.'">'.sprintf(i18n("Create %s Archiv"),$value).'</option>'."\n"; + }*/ + ?> + </select><br /> + <?php + /*if(in_group('admin')) + {*/ + echo i18n("Add More Apps"); + //putHelpButton('archive_apps'); + echo "<br />\n\n"; + //} + ?> + <br /> + <input type="submit" name="submit" value="<?php echo i18n("Download Archive"); ?>"> + <?php + break; // end checkout - download + case 'mail': + + $default_text_message = ($GLOBALS['img_view']->mode=='viewer' ? $prev_path."\n"."http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"]).'/viewer.php?albid='.$_REQUEST['albid'].'&stage='.$_REQUEST['stage'].'&pn='.$_REQUEST['pn'] : ''); + + $mail_address = (isset($_SESSION['mail_address']) ? $_SESSION['mail_address'] : ''); + $sender_address = (isset($_SESSION['sender_address']) ? $_SESSION['sender_address'] : ''); + $subject = (isset($_SESSION['subject']) ? $_SESSION['subject'] : ''); + $text_message = (isset($_SESSION['text_message']) ? $_SESSION['text_message'] : $default_text_message); + + (@$_SESSION['mail_mode'] == "html") ? $html = ' checked="checked"' : $txt = ' checked="checked"'; + + if(isset($_GET['error_mail'])) + { + $mail_size = round($_SESSION['tot_filesize']*$_SESSION['overhead_base64']); + echo '<h3><font color="red">'; + switch($_GET['error_mail']) + { + case 0: + echo $mail_sent_to.': <span title="'.$_SESSION['mail_address'].'">'; + echo cut_overloaded_strings($_SESSION['mail_address'],18); + echo '</span>'; + echo '<br /><br />'; + echo i18n("Size Of E-Mail").": ".nice_filesize($mail_size,1); + break; // success + case 1: linSysLog(i18n("Error").": ".i18n("No Images Selected!")); break; // no images selected + case 2: linSysLog(i18n("Error: E-Mail couldn't be sent. Contact the Administrator.")); break; // error in mail() + case 3: linSysLog(sprintf(i18n("Error: The E-Mail is too big.<br /><br />Allowed size: %sBytes. Your selected images use %sBytes.<br /><br />Remove some images or use the download zipped albums feature!"),$max_mail_size,$mail_size)); break; // mail too big + case 4: linSysLog(i18n("Please Fill In All Fields!")); break; + } + echo '</font></h3>'; + } + ?> + <form name="mail_selected" action="<?php echo TOP_DIR; ?>/actions/basket_build_mail.php" method="POST"> + </div><div align="left"> + <?php echo i18n("Recipient"); ?>:<br /> + </div><div align="center"> + <input type="text" name="mail_address" value="<?php echo $mail_address; ?>" style="width:175"><br /> + </div><div align="left"> + <?php echo i18n("Sender"); ?>:<br /> + </div><div align="center"> + <input type="text" name="sender_address" value="<?php echo $sender_address; ?>" style="width:175"><br /> + </div><div align="left"> + <?php echo i18n("Subject"); ?><br /> + </div><div align="center"> + <input type="text" name="subject" value="<?php echo $subject; ?>" style="width:175"><br /> + </div><div align="left"> + <?php echo i18n("Message"); ?><br /> + </div><div align="center"> + <textarea name="text_message" style="width: 175px;" rows="5" cols="40"><?php echo $text_message; ?></textarea><br /> + </div> + <div align="left"> <?php echo i18n("Mail Format"); ?><br/> + <input type="radio" name="mail_mode" value="txt"<?php echo @$txt; ?>><?php echo i18n("TXT (images attached)"); ?><br /> + <input type="radio" name="mail_mode" value="html"<?php echo @$html; ?>><?php echo i18n("HTML (images inline)"); ?><br /> + </div><br> + <div align="center"> + <input type="submit" value="<?php echo i18n("Send Mail"); ?>"> + + <?php + break; // end checkout - mail + case 'print': + ?> + <script language="JavaScript" type="text/javascript"> + function update_quality_settings() + { + switch(document.print_selected.images.value) + { + case '2': + document.print_selected.l_or_h_quality.selectedIndex = '1'; + break; + case '4': + break; + case '8': + break; + case '16': + document.print_selected.l_or_h_quality.selectedIndex = '0'; + break; + case '28': + document.print_selected.l_or_h_quality.selectedIndex = '0'; + + checkflag = 0; + document.print_selected.button_check_all.value = check_all(); + break; + } + } + </script> + <form name="print_selected" action="<?php echo TOP_DIR; ?>/actions/basket_build_print.php" method="POST" target="_blank"> + <br/><select name="images" size="1" onchange="update_quality_settings()"> + <option value="2">2 <?php echo i18n("Images/Page"); ?></option> + <option value="4" selected>4 <?php echo i18n("Images/Page"); ?></option> + <option value="8">8 <?php echo i18n("Images/Page"); ?></option> + <option value="16">16 <?php echo i18n("Images/Page"); ?></option> + <option value="28"><?php echo i18n("Images/Page"); ?></option> + </select> + <br/><br/> + <select name="l_or_h_quality"> + <option value="l"><?php echo i18n("Normal Quality"); ?></option> + <option value="h"><?php echo i18n("High Quality (Very Slow!)"); ?></option> + </select> + <br/><br/> + <input type="submit" value="<?php echo i18n("Print Preview"); ?>"> + <br /><hr /> + <strong><?php echo i18n("NOTE:"); ?></strong><?php echo i18n("You may have to adjust your browsers \"page setup\" before printing, to make sure all photos fit on page !!!"); + break; // end checkout - print + } + } + ?> </div> <div class="roundbottom"> Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/templates/default/global.html.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -85,7 +85,8 @@ <input type="hidden" name="button[meta][all]" value="1" /> <input type="hidden" name="cmd" value="search" /> <input type="hidden" name="cat" value="search" /> - <input type="submit" name="submit" value="<?php echo i18n("Search"); ?>" /> + <input type="submit" name="submit" value="<?php echo i18n("Search"); ?>" /> + </form> </div> </li> </ul> Modified: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php 2006-04-13 13:30:53 UTC (rev 4533) +++ trunk/linpha2/templates/default/search.html.php 2006-04-14 14:03:58 UTC (rev 4534) @@ -14,15 +14,15 @@ <font size="+1"><?php echo i18n("LinPHA Search Page"); ?></font> <hr noshade> <?php -if(isset($error)) +if(isset($GLOBALS['linpha']->template->output['search_error'])) { echo '<div align="center"><b>'; - switch($error) + switch($GLOBALS['linpha']->template->output['search_error']) { case 1: echo i18n("Search string to short, must be at least 2 characters long!"); break; case 2: echo i18n("Error, please check input!"); break; } - echo "</b><br /><br /></div>"; + echo '</b><br /><br /></div>'; } ?> <div id="divmain"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-14 14:24:56
|
Revision: 4535 Author: fangehrn Date: 2006-04-14 07:24:45 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4535&view=rev Log Message: ----------- * added settings all feature in admin section Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/index.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php Added Paths: ----------- trunk/linpha2/admin/settings_all.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-14 14:03:58 UTC (rev 4534) +++ trunk/linpha2/ChangeLog 2006-04-14 14:24:45 UTC (rev 4535) @@ -1,5 +1,6 @@ 2006-04-14 flo * startet implementing basket checkout features (download, print, mail) + * added settings all feature in admin section 2006-04-13 flo * finished search feature Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-04-14 14:03:58 UTC (rev 4534) +++ trunk/linpha2/admin/index.php 2006-04-14 14:24:45 UTC (rev 4535) @@ -128,37 +128,45 @@ function printAdminConfig($type,$text,$id,$options=array()) { + ?> + <div style="width: 600px; border: 1px solid black; padding: 5px; margin-bottom: 5px;"> + <div align="left" style="float: left;"> + <?php switch($type) { case 'radio': - if($GLOBALS['linpha']->sql->config->value[$id]) - { - $str_enabled = ' checked="checked"'; - $str_disabled = ''; - } - else - { - $str_enabled = ''; - $str_disabled = ' checked="checked"'; - } - echo $text; - ?> - <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> - <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> - <br /> - <?php + if($GLOBALS['linpha']->sql->config->value[$id]) + { + $str_enabled = ' checked="checked"'; + $str_disabled = ''; + } + else + { + $str_enabled = ''; + $str_disabled = ' checked="checked"'; + } + echo $text; + ?> + </div> + <div align="right"> + <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> + <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> + <?php break; case 'text': - echo $text; - ?> - <input type="text" name="<?php echo $id; ?>" value="<?php echo $GLOBALS['linpha']->sql->config->value[$id]; ?>" maxlength="255"/> - <br /> - <?php + echo $text; + ?> + </div> + <div align="right"> + <input type="text" name="<?php echo $id; ?>" value="<?php echo $GLOBALS['linpha']->sql->config->value[$id]; ?>" maxlength="255"/> + <?php break; case 'select': echo $text; ?> + </div> + <div align="right"> <select name="<?php echo $id; ?>" size="1"> <?php foreach($options AS $key=>$value) @@ -178,6 +186,10 @@ <?php break; } + ?> + </div> + </div> + <?php } function saveConfig($array) Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2006-04-14 14:03:58 UTC (rev 4534) +++ trunk/linpha2/admin/settings.php 2006-04-14 14:24:45 UTC (rev 4535) @@ -9,7 +9,8 @@ $array_menu = Array( 'layout' => Array('name' => 'Layout', 'link' => 'settings_layout'), 'features' => Array('name' => 'Features', 'link' => 'settings_features'), - 'others' => Array('name' => 'Others', 'link' => 'settings_others') + 'others' => Array('name' => 'Others', 'link' => 'settings_others'), + 'all' => Array('name' => 'All', 'link' => 'settings_all') ); print_admin_menu($array_menu,$cat2); @@ -24,5 +25,12 @@ break; case 'others': break; + case 'all': + include_once(LINPHA_DIR.'/admin/settings_all.php'); + break; } -?> \ No newline at end of file +?> +<br /><br /><hr /> +<input type="hidden" name="cmd" value="saveconfig" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> +</form> \ No newline at end of file Added: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php (rev 0) +++ trunk/linpha2/admin/settings_all.php 2006-04-14 14:24:45 UTC (rev 4535) @@ -0,0 +1,87 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +$options = array( + 'sys_db_version', + 'sys_im_bracket_support', + 'sys_im_imagemagick_path', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + 'sys_import_autoimport', + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang', + 'sys_lang_autolang', + 'sys_path_album_dir', + 'sys_path_cache_dir', + 'sys_path_tmp_dir', + + 'sys_style_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_max', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_selectsizes', + 'sys_style_thumb_selectnrimages', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_quality', + 'sys_style_image_size', + 'sys_style_image_nrprevnextthumbs', + + 'sys_user_autologin' +); + +$radio_options = array( + 'sys_im_bracket_support', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + 'sys_import_autoimport', + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang_autolang', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_user_autologin' +); + + +echo '<b>'.i18n("This Stuff here is only for advanced Users, don't play around...").'</b>'; +?> +<br /><br /> +<form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_all'; ?>"> +<?php + + + + /** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + saveConfig($options); + } + + foreach($options AS $value) + { + if(in_array($value,$radio_options)) + { + $type = 'radio'; + } + else + { + $type = 'text'; + } + printAdminConfig($type,$value,$value); + } + +?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2006-04-14 14:03:58 UTC (rev 4534) +++ trunk/linpha2/admin/settings_features.php 2006-04-14 14:24:45 UTC (rev 4535) @@ -37,8 +37,4 @@ printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp'); break; } -?> -<br /><br /><hr /> -<input type="hidden" name="cmd" value="saveconfig" /> -<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> -</form> \ No newline at end of file +?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-04-14 14:03:58 UTC (rev 4534) +++ trunk/linpha2/admin/settings_layout.php 2006-04-14 14:24:45 UTC (rev 4535) @@ -86,8 +86,4 @@ break; } -?> -<br /><br /><hr /> -<input type="hidden" name="cmd" value="saveconfig" /> -<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> -</form> \ No newline at end of file +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-14 23:18:43
|
Revision: 4537 Author: fangehrn Date: 2006-04-14 16:18:08 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4537&view=rev Log Message: ----------- * finished implementing basket checkout features (download, print, mail) print and mail works quite smooth download needs still some improvements (chdir() to album dir to no get relative or absolute paths) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/settings_all.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/templates/default/basket.html.php Added Paths: ----------- trunk/linpha2/docs/dev/external_libraries.txt trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/archiver.config.php trunk/linpha2/lib/classes/phpmailer.class.php trunk/linpha2/lib/classes/smtp.class.php trunk/linpha2/lib/include/basket_build_mail.php trunk/linpha2/lib/include/basket_build_print.php trunk/linpha2/lib/include/basket_build_zip.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/ChangeLog 2006-04-14 23:18:08 UTC (rev 4537) @@ -1,3 +1,9 @@ +2006-04-15 flo + * finished implementing basket checkout features (download, print, mail) + print and mail works quite smooth + download needs still some improvements + (chdir() to album dir to no get relative or absolute paths) + 2006-04-14 flo * startet implementing basket checkout features (download, print, mail) * added settings all feature in admin section Modified: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/admin/settings_all.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -17,6 +17,9 @@ 'sys_path_cache_dir', 'sys_path_tmp_dir', + 'sys_basket_mail_max_size', + 'sys_basket_download_limit', + 'sys_style_sortorder', 'sys_style_template', 'sys_style_home_showbrowsebydate', Added: trunk/linpha2/docs/dev/external_libraries.txt =================================================================== --- trunk/linpha2/docs/dev/external_libraries.txt (rev 0) +++ trunk/linpha2/docs/dev/external_libraries.txt 2006-04-14 23:18:08 UTC (rev 4537) @@ -0,0 +1,10 @@ + + +phpmail.class.php + +line 560 + +from + include_once($this->PluginDir . "class.smtp.php"); +to + include_once(LINPHA_DIR . "/lib/classes/smtp.class.php"); \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -41,6 +41,9 @@ 'sys_path_cache_dir' => $_SESSION['cache_dir'], 'sys_path_tmp_dir' => $_SESSION['tmp_dir'], + 'sys_basket_mail_max_size' => (1024*1024*2), + 'sys_basket_download_limit' => '0', + 'sys_style_sortorder' => 'nameasc', 'sys_style_template' => 'default', 'sys_style_home_showbrowsebydate' => '1', Added: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php (rev 0) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -0,0 +1,330 @@ +<?php +/* +* Copyright (c) 2004 Heiko Rutenbeck <bz...@tu...> +* +* 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. +*/ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** +* Class to create album archives for download +* +* This class uses the system tools tar/bzip/zip to create archives +* for download. Using PHP sucks due limitations (runtime and memory limits)... +* +* @author bzrudi +*/ + +class Archive +{ + +var $files; +var $tmpname; +var $sleeptime; +var $ziptype; +var $apps; +var $md5sums; + +/** +* constructor +*/ +function Archive($ziptype,$speed=0) +{ + $this->ziptype = $ziptype; + $this->setDownloadSpeedLimit($speed); + + $this->apps = new Archive_Applications(); + $this->apps->searchApp($ziptype); + + /** + * set tmpname + */ + $this->tmpname = LinFilesys::linTempnam( + 'linpha_download', // prefix + '.'.$this->apps->apps[$this->ziptype]['file_ext'] // suffix + ); +} + +/** +* Method to calculate max download speed rate +* @return integer sleeptime in usec +*/ +function setDownloadSpeedLimit($sleep) +{ + switch($sleep) + { + case "0": $this->sleeptime = "0"; break; + case "4": $this->sleeptime = "900000"; break; + case "8": $this->sleeptime = "450000"; break; + case "12": $this->sleeptime = "335000"; break; + case "16": $this->sleeptime = "225000"; break; + case "32": $this->sleeptime = "115000"; break; + case "64": $this->sleeptime = "56500"; break; + default: $this->sleeptime = "0"; break; + } +} + +/** +* Method to create filelist/path for files to download +* @return string fullpath,path,src_path +*/ +function getImageList($img_ids) +{ + $this->files = ''; + + foreach($img_ids AS $image_id) + { + $full_filename = LinSql::getFullImagePath( $image_id ); + + $this->files .= linEscapeString($full_filename)." "; + + /** + * store md5sum for later use (statistics) + * @todo + */ + //$this->md5sums[] = $data['md5sum']; + } +} + + +/** +* Method to finaly create the archive on HD +*/ +function makeArchive() +{ + $command = $this->apps->GetCommand($this->ziptype); + + /** + * get executable path + */ + $this->apps->searchApp($this->ziptype); + $path = $this->apps->found_apps[$this->ziptype]; + $exec = $this->apps->apps[$this->ziptype]['executable']; + $executable = $path.$exec; + $command = str_replace('{executable}',$executable,$command); + + $command = str_replace('{files}',$this->files,$command); // $this->files is already escaped + $command = str_replace('{archive_name}',linEscapeString($this->tmpname),$command); + + //error_log($command); + + if(!chdir(LINPHA_DIR)) { + echo 'cannot chdir(LINPHA_DIR)!<br />'; + return false; + } + + /** + * delete tempfile first because winrar cannot write into this empty file (created with touch())! + * -> it could be possible that linpha_tempnam() generates now a duplicate tmpname if another user + * is currently using the download mode too + * very unlikely because the session_id is included in tmpname and there is not much time between unlink() and exec() + */ + unlink($this->tmpname); + + exec($command,$array_output=Array(),$return_value=0); + + if(!file_exists($this->tmpname)) { + echo 'Created archive doesnt exists<br />'; + $fail = true; + } + + if($return_value != 0) { + echo 'archive program returned an error!<br />'; + echo 'Return value: '.$return_value.'<br />'; + $fail = true; + } + + if(isset($fail)) + { + echo '<pre>'; + echo $command.'<br />'; + print_r($array_output); + echo '</pre><br />'; + + return false; + } + else + { + return true; + } +} + +/** +* Method to send created archive to client. +* Makes use of additional header defines to let client know about +* content type and length. +*/ +function startDownload() +{ + set_magic_quotes_runtime(0); + /** + * disable zlib compression to avoid broken archives + */ + @ini_set ('zlib.output_compression', 'Off'); + + $mime = $this->apps->apps[$this->ziptype]['mime']; + $ext = $this->apps->apps[$this->ziptype]['file_ext']; + + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Content-Type: ".$mime); + + $user_agent = @strtolower($_SERVER["HTTP_USER_AGENT"]); + + if ((is_integer (strpos($user_agent, "msie"))) && (is_integer (strpos($user_agent, "win")))) { + header( "Content-Disposition: filename=Linpha_download.".$ext.";" ); + }else{ + header( "Content-Disposition: attachment; filename=Linpha_download.".$ext.";" ); + } + + header("Content-Transfer-Encoding: binary"); + header("Content-Length: ".filesize($this->tmpname)); + + $fp=fopen($this->tmpname, "rb"); + + if($this->sleeptime == 0){ + while(!feof($fp)) { + $sendbuffer=fread($fp, 4096); + echo $sendbuffer; + } + } else { + while(!feof($fp)) { + $sendbuffer=fread($fp, 4096); + usleep($this->sleeptime); + echo $sendbuffer; + } + } + + fclose($fp); + unlink($this->tmpname); +} + +} // end class + +class Archive_Applications +{ + //var $path_delimiter; + var $array_path; + var $apps; + var $found_apps; + + // Constructor + function Archive_Applications() + { + /** + * not use include_once() ! + */ + include(LINPHA_DIR.'/lib/classes/archiver.config.php'); + + $this->array_path = get_PATH('PATH'); + } + + function getCommand($ziptype) + { + return $this->apps[$ziptype]['command']; + } + + /** + * ignoreFileext doesn't mean that these files are exluded from the archive + * but these are excluded from compression, so we get speed improvements + * + * it doesn't make sense to compress already compressed image files + * but it makes sense to compress uncompressed image files like BMP or TIFF + * + * what about movies..?! + */ + function ignoreFileext($prefix,$delimiter) + { + $exts = Array('jpg','JPG','jpeg','JPEG','gif','GIF','png','PNG','mov','MOV','avi','AVI','mpg','MPG','mpeg','MPEG'); + + $str = ''; + foreach($exts AS $value) { + $str .= $prefix.$value.$delimiter; + } + + /** + * remove last delimiter + */ + $str = substr($str,0,strlen($str)-strlen($delimiter)); + + return $str; + } + + function searchApps() + { + foreach($this->apps AS $app=>$value) + { + $this->searchApp($app); + } + } + + function searchApp($app) + { + if(isset($this->apps[$app]['look_for'][0]) && $this->apps[$app]['look_for'][0] == 'no') + { + $this->found_apps[$app] = ''; + return true; + } + + /** + * search file in other (given) locations + * + * get_PATH remove directories not allowed by safemode or open_basedir + */ + $array_lookfor = get_PATH($this->apps[$app]['look_for']); + foreach($array_lookfor AS $value) + { + if(file_exists($value.'/'.$this->apps[$app]['executable'])) + { + /** + * make sure the executable path contains no spaces because this won't work + * this behaviour has only be seen under windows, maybe we have to separate linux and + * windows. but then, we have to escape the executable. + * + * calls like + * $cmd = '"c:/program files/winrar/rar.exe" a "c:/temp/test.rar" "c:/directory with spaces/rar.txt"'; + * exec($cmd); + * don't work! + * + * if somebody finds a solution, please let me know :) + */ + if( strpos($value,' ')!==false ) + { + } + else + { + $this->found_apps[$app] = $value.'/'; + return true; + } + } + } + + /** + * search file in PATH + */ + foreach($this->array_path AS $value) + { + if(file_exists($value.'/'.$this->apps[$app]['executable'])) + { + $this->found_apps[$app] = $value.'/'; + return true; + } + } + + return false; + } +} \ No newline at end of file Added: trunk/linpha2/lib/classes/archiver.config.php =================================================================== --- trunk/linpha2/lib/classes/archiver.config.php (rev 0) +++ trunk/linpha2/lib/classes/archiver.config.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -0,0 +1,199 @@ +<?php +/* +* Copyright (c) 2004 Heiko Rutenbeck <bz...@tu...> +* +* 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. +*/ + +if(!defined('LINPHA_DIR')) { exit(1); } + +/** +* you can add own paths or new apps +* +* use only forward slashes ('/') for paths, even under windows +* +* if 'look_for' is an array with the first entry 'no', this app isn't searched +* use this only if you are sure that this app is in the path, like 'tar' which is normally always +* in one of the path variable +* +* {executable}, {archive_name} and {files} will be replaced with the correct parameters +* hint: {executable} will be replaced with the fullpath executable, not only the executable given +* in the array $appps[]['executable'] +* +* the extract commands are used for the integrated filemanager, so don't forget +* +* you cannot use spaces in the executable path!! if you want to use a program which is installed in c:/program files/... +* you have to use c:/progra~1/... +* alternatively you can install it in another place or add the executable path to the PATH variable +* +* and if it works, please mail me a copy of your new entries +* at linpha AT angehrn DOT com +* OR bzrudi AT tuxpower DOT de +*/ + +switch(getOS()) +{ + case 'unix': + // tar + $this->apps['tar'] = Array('look_for' => Array('no'), + 'executable' => 'tar', + 'command' => 'tar -cf {archive_name} {files}', + 'executable_extract' => 'tar', + 'command_extract' => 'tar -xf {archive_name}', + 'file_ext' => 'tar', + 'mime' => 'application/x-tar'); + + // gzip + $this->apps['gzip'] = Array('look_for' => Array('/bin','/usr/bin','/usr/local/bin'), + 'executable' => 'gzip', + 'command' => 'tar -cf - {files} | {executable} -1 > {archive_name}', + 'executable_extract' => 'gzip', + 'command_extract' => '{executable} -d < {archive_name} | tar -xvf -', + 'file_ext' => 'tar.gz', + 'mime' => 'application/x-compressed-tar'); + + // bzip2 + $this->apps['bzip2'] = Array('look_for' => Array('/usr/bin','/bin','/usr/local/bin'), + 'executable' => 'bzip2', + 'command' => 'tar -cf - {files} | {executable} -1 > {archive_name}', + 'executable_extract' => 'bzip2', + 'command_extract' => '{executable} -d < {archive_name} | tar -xvf -', + 'file_ext' => 'tar.bz2', + 'mime' => 'application/x-bzip-compressed-tar'); + + // zip + $this->apps['unixzip'] = Array('look_for' => Array('/usr/bin','/bin','/usr/local/bin'), + 'executable' => 'zip', + 'command' => '{executable} -1jvn '.$this->ignoreFileext('.',':').' {archive_name} {files}', + 'executable_extract' => 'unzip', + 'command_extract' => '{executable} -o -L {archive_name}', + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + + // rar + $this->apps['winrar'] = Array('look_for' => Array('/usr/bin','/bin','/usr/local/bin'), + 'executable' => 'rar', + 'command' => '{executable} a -ms['.$this->ignoreFileext('',',').'] {archive_name} {files}', + 'executable_extract' => 'rar', + 'command_extract' => '{executable} x -y {archive_name}', + 'file_ext' => 'rar', + 'mime' => 'application/x-rar-compressed'); + /** + * @todo arj, ?? + */ + + //$this->path_delimiter = ':'; + break; + case 'win': + // WinZip Command Line Support Add-On + // tested with WinZip version 9.0 + // not working with the evalution mode!! + // not working if cmd string is longer than 2048 chars! + // this problem does not exists with winrar and 7-Zip + $this->apps['winzip'] = Array('look_for' => Array('c:/progra~1/winzip','c:/winzip'), + 'executable' => 'wzzip.exe', + 'command' => '{executable} -ybc {archive_name} {files}', + 'executable_extract' => 'wzunzip.exe', + 'command_extract' => '{executable} -ybc {archive_name}', // x: extract, -y answer always 'yes' (for overwriting) + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + + + // winrar + // tested with winrar version 3.2 + $this->apps['winrar'] = Array('look_for' => Array('c:/progra~1/winrar','c:/winrar'), + 'executable' => 'rar.exe', + 'command' => '{executable} a -ms['.$this->ignoreFileext('',',').'] {archive_name} {files}', + 'executable_extract' => 'rar.exe', + 'command_extract' => '{executable} x -y {archive_name}', // x: extract, -y answer always 'yes' (for overwriting) + 'file_ext' => 'rar', + 'mime' => 'application/x-rar'); + + // PowerArchiver Command Line (PACL) + // tested with PowerArchiver Command Line Version 3.51 + $this->apps['PAcl_zip'] = Array('look_for' => Array('c:/Pacl','c:/progra~1/Pacl'), + 'executable' => 'Pacomp.exe', + 'command' => '{executable} -a {archive_name} {files}', + 'executable_extract' => 'Paext.exe', + 'command_extract' => '{executable} -d {archive_name}', + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + + // pkzip + /* doesn't supported!! pkzip only allows a few images as parameters, use pkzip32 or pkzipc instead! + $this->apps['pkzip'] = Array('look_for' => Array(), + 'executable' => 'pkzip.exe', + 'command' => '{executable} -a {archive_name} {files}', + 'executable_extract' => '', + 'command_extract' => '', + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + */ + + // pkzip32 + /* not yet tested, does pkzip32 still exists..?! + $this->apps['pkzip32'] = Array('look_for' => Array(), + 'executable' => 'pkzip32.exe', + 'command' => '', + 'executable_extract' => '', + 'command_extract' => '{executable} -nofix -ext -dir -overwrite -nozipextension {archive_name} 2>&1'; + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + */ + + // pkzipc PKZIP Command Line + // tested with pkzip cli version 8.0 + $this->apps['pkzipc'] = Array('look_for' => Array('c:/progra~1/pkware/pkzipc'), + 'executable' => 'pkzipc.exe', + 'command' => '{executable} -add {archive_name} {files}', + 'executable_extract' => 'pkzipc.exe', + 'command_extract' => '{executable} -extract -overwrite=all {archive_name}', + 'file_ext' => 'zip', + 'mime' => 'application/zip'); + + // Commandline Ace (ACE f?r DOS) + // tested with Commandline Ace version 2.04 + // no default installation directory + $this->apps['ace'] = Array('look_for' => Array('c:/progra~1/WinAce','c:/ace'), + 'executable' => 'Ace32.exe', + 'command' => '{executable} a {archive_name} {files}', + 'executable_extract' => 'Ace32.exe', + 'command_extract' => '{executable} x -o -y {archive_name}', // -o: overwrite, -y answer always 'yes' + 'file_ext' => 'ace', + 'mime' => 'application/x-ace'); + + // 7-Zip http://www.7-zip.org/ + // tested with Version 3.13 + // thanks to adrian + $this->apps['7Zip'] = Array('look_for' => Array('c:/progra~1/7-Zip','c:/progra~1/xampp/7Zip'), + 'executable' => '7z.exe', + 'command' => '{executable} a -tzip {archive_name} {files}', + 'executable_extract' => '7z.exe', + 'command_extract' => '{executable} e {archive_name}', + 'file_ext' => 'zip', + 'mime' => 'application/Zip'); + + /** + * @todo !Freebyte Zip http://www.freebyte.com/fbzip/#cmd + * @todo Ultimate Zip http://www.ultimatezip.com/download.htm +@todo Arj http://arj.sourceforge.net/ + */ + + //$this->path_delimiter = ';'; + break; +} + + +?> \ 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-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -28,6 +28,44 @@ { /** +* returns a unique filename, but different to tempnam() the file doesn't exists +* +* @author flo +* @param string $prefix prefix for the tmp_file +* @param string $suffix suffix for the tmp_file, formerly the file extension +* @return string unique temporary filename +* @package filesys +* +* http://ch.php.net/manual/de/function.uniqid.php +*/ +function linTempnam($prefix,$suffix) +{ + $tmp_dir = LinSql::getPath('tmp'); + if(!is_writable($tmp_dir)) { + error_log("linpha_tempnam: tmp_dir ($tmp_dir) isn't writable! Using /tmp instead"); + $tmp_dir = '/tmp'; + } + + for($i=0; file_exists($tmp_dir.'/'.$prefix.'_'.session_id().'_'.$i.$suffix); $i++) { } + $tmp_file = $tmp_dir.'/'.$prefix.'_'.session_id().'_'.$i.$suffix; + touch($tmp_file); + + return $tmp_file; +} + +/** + * create a unique tmp folder + */ +function createTmpFolder($prefix) +{ + $tmp_dir = $GLOBALS['linpha']->sql->config->value['sys_path_tmp_dir']; + for($i=0; file_exists(LinFilesys::getFullPath($tmp_dir).'/'.$prefix.'_'.session_id().'_'.$i); $i++) { } + $tmp_folder = LinFilesys::getFullPath($tmp_dir).'/'.$prefix.'_'.session_id().'_'.$i; + mkdir($tmp_folder,0700); + return $tmp_folder; +} + +/** * close session before exec() * if exec() is called twice (like on the print preview), apache will hang * on windows Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.functions.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -22,8 +22,132 @@ * Just a couple of useful functions * @package Functions */ - + + /** +* get content of the systems PATH variable and remove dirs not in open_basedir and safe_mode_exec_dir (only if activated) +*/ +function get_PATH($array_path) +{ + /** + * use the path variable instead of own array + */ + if($array_path == 'PATH') + { + unset($array_path); + if(!empty($_SERVER['PATH'])) + { + $path = $_SERVER['PATH']; + } + elseif(!empty($_SERVER['Path'])) + { + $path = $_SERVER['Path']; + } + else + { + $path = ''; + } + $array_path = explode(PATH_SEPARATOR,$path); + } + // if we have open_basedir restrictions, take only the paths which are allowed from open_basedir to prevent errors + $open_basedir = ini_get('open_basedir'); + if(!empty($open_basedir)) { + $arr_open_basedir = explode(PATH_SEPARATOR,$open_basedir); + + $array_path = array_intersect($array_path, $arr_open_basedir); + } + + // same with safemode + if(ini_get('safe_mode')) + { + $safe_mode_exec_dir = ini_get('safe_mode_exec_dir'); + if(!empty($safe_mode_exec_dir)) { + + $arr_safe_mode_exec_dir = explode(PATH_SEPARATOR,$safe_mode_exec_dir); + + $array_path = array_intersect($array_path, $arr_safe_mode_exec_dir); + } + } + + return $array_path; +} + +/** + * get the memory limit set in php.ini + * if php was compiled without memory_limit + */ +function getMemoryLimit() +{ + $memlimit=ini_get('memory_limit'); + if(empty($memlimit)) + { + $memlimit = get_cfg_var('memory_limit'); + } + + /** + * mem limit disabled (-1) or not compiled in + */ + if(empty($memlimit) OR $memlimit == -1) + { + return false; + } + else + { + $memlimit=str_replace("M", "", $memlimit); + return $memlimit; + } +} + +/** + * This function formats the filesize (byte) value to kB/MB/GB + */ +function niceFilesize($filesize, $precision) +{ + if ($filesize < 1000) { + $sizeunit = 'Bytes'; + $precision = 0; + } else { + $filesize /= 1024; + $sizeunit = 'KB'; + } + if ($filesize >= 1000) { + $filesize /= 1024; + $sizeunit = 'MB'; + } + if ($filesize >= 1000) { + $filesize /= 1024; + $sizeunit = 'GB'; + } + return number_format($filesize, $precision).' '.$sizeunit; +} + +/** + * cut a string to the given size + */ +function cutString($string,$len,$with_span_title) +{ + $append = '...'; + + if( strlen($string) > ($len+strlen($append)) ) + { + $str_cutted = substr_replace($string, $append, $len); + if($with_span_title) + { + return '<span title="'.$string.'">'.$str_cutted.'</span>'; + } + else + { + return $str_cutted; + } + } + else + { + return $string; + } + +} + +/** * Take care of translation * * This simple method takes care of all translation related stuff. Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -28,13 +28,13 @@ class LinImage { public $error_msg; +public $output_file; private $photo_id, $cached_id; private $img_type; private $mode; private $image_tool; -private $output_file; private $src_file; private $org_width, $org_height, $img_width, $img_height; private $img_quality; @@ -258,9 +258,7 @@ */ if($this->img_type != 0 && $this->img_type != 9999999) { - $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->photo_id ); - $album_dir = $GLOBALS['linpha']->sql->getPath('album'); - $this->src_file = $album_dir .'/'. implode('/',$array_path); + $this->src_file = LinSql::getFullImagePath( $this->photo_id ); if(! file_exists($this->src_file)) { Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -287,7 +287,7 @@ } $_SESSION['basket_ref_url'] = $GLOBALS['linpha']->template->URL_full; - $open_basket_link = LINPHA_DIR.'/?cat=basket&ref_id='.$this->id_current; + $open_basket_link = LINPHA_DIR.'/?cat=basket'; switch($this->mode) { @@ -495,8 +495,7 @@ $filename = $photo_value['name']; $md5sum = $photo_value['md5sum']; - $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_value['id'] ); - $full_filename = LinSql::getPath('album').'/'.implode('/',$array_files); + $full_filename = LinSql::getFullImagePath( $photo_value['id'] ); $array_image_infos = MetaData::readInformations( $full_filename, $filename, $md5sum, $flag_nr=13 ); @@ -846,10 +845,9 @@ $data = $query->FetchRow(ADODB_FETCH_NUM); if(isset($data['0'])) { - $array = LinSql::getFullFilenameFromId( $data['0'] ); - $path = LinSql::getPath('album') .'/'. implode('/',$array); + $path = LinSql::getFullImagePath( $data[0] ); - if(file_exists(LinFilesys::getFullPath($path)) && LinSql::photoIsAllowed($data['0'])) + if(file_exists($path) && LinSql::photoIsAllowed($data['0'])) { $GLOBALS['linpha']->template->output['random_images'][] = Array('id'=>$data['0'],'path'=>$path); $i++; @@ -1023,8 +1021,7 @@ */ function viewImgStoreImageInformation() { - $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $this->id_current ); - $this->full_filename = LinSql::getPath('album').'/'.implode('/',$array_files); + $this->full_filename = LinSql::getFullImagePath( $this->id_current ); /** * set image informations Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -45,8 +45,7 @@ } else { - $array = LinSql::getFullFilenameFromId( $parent_id ); - $dirname = LinSql::getPath('album') .'/'. implode('/',$array); + $dirname = LinSql::getFullImagePath( $parent_id ); } if( ! file_exists( $dirname ) ) Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-14 15:52:03 UTC (rev 4536) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -587,8 +587,15 @@ return $array_names; } +function getFullImagePath( $photo_id ) +{ + $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_id ); + $album_dir = $GLOBALS['linpha']->sql->getPath('album'); + return $album_dir .'/'. implode('/',$array_path); +} + /** - * returns the correct path to the albums directory + * returns the correct path to the album, cache or tmp directory * pay attention to use this getPath and not access directly 'sys_path_album_dir' ! */ function getPath($what) Added: trunk/linpha2/lib/classes/phpmailer.class.php =================================================================== --- trunk/linpha2/lib/classes/phpmailer.class.php (rev 0) +++ trunk/linpha2/lib/classes/phpmailer.class.php 2006-04-14 23:18:08 UTC (rev 4537) @@ -0,0 +1,1499 @@ +<?php +//////////////////////////////////////////////////// +// PHPMailer - PHP email class +// +// Class for sending email using either +// sendmail, PHP mail(), or SMTP. Methods are +// based upon the standard AspEmail(tm) classes. +// +// Copyright (C) 2001 - 2003 Brent R. Matzelle +// +// License: LGPL, see LICENSE +//////////////////////////////////////////////////// + +/** + * PHPMailer - PHP email transport class + * @package PHPMailer + * @author Brent R. Matzelle + * @copyright 2001 - 2003 Brent R. Matzelle + */ +class PHPMailer +{ + ///////////////////////////////////////////////// + // PUBLIC VARIABLES + ///////////////////////////////////////////////// + + /** + * Email priority (1 = High, 3 = Normal, 5 = low). + * @var int + */ + var $Priority = 3; + + /** + * Sets the CharSet of the message. + * @var string + */ + var $CharSet = "iso-8859-1"; + + /** + * Sets the Content-type of the message. + * @var string + */ + var $ContentType = "text/plain"; + + /** + * Sets the Encoding of the message. Options for this are "8bit", + * "7bit", "binary", "base64", and "quoted-printable". + * @var string + */ + var $Encoding = "8bit"; + + /** + * Holds the most recent mailer error message. + * @var string + */ + var $ErrorInfo = ""; + + /** + * Sets the From email address for the message. + * @var string + */ + var $From = "root@localhost"; + + /** + * Sets the From name of the message. + * @var string + */ + var $FromName = "Root User"; + + /** + * Sets the Sender email (Return-Path) of the message. If not empty, + * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. + * @var string + */ + var $Sender = ""; + + /** + * Sets the Subject of the message. + * @var string + */ + var $Subject = ""; + + /** + * Sets the Body of the message. This can be either an HTML or text body. + * If HTML then run IsHTML(true). + * @var string + */ + var $Body = ""; + + /** + * Sets the text-only body of the message. This automatically sets the + * email to multipart/alternative. This body can be read by mail + * clients that do not have HTML email capability such as mutt. Clients + * that can read HTML will view the normal Body. + * @var string + */ + var $AltBody = ""; + + /** + * Sets word wrapping on the body of the message to a given number of + * characters. + * @var int + */ + var $WordWrap = 0; + + /** + * Method to send mail: ("mail", "sendmail", or "smtp"). + * @var string + */ + var $Mailer = "mail"; + + /** + * Sets the path of the sendmail program. + * @var string + */ + var $Sendmail = "/usr/sbin/sendmail"; + + /** + * Path to PHPMailer plugins. This is now only useful if the SMTP class + * is in a different directory than the PHP include path. + * @var string + */ + var $PluginDir = ""; + + /** + * Holds PHPMailer version. + * @var string + */ + var $Version = "1.73"; + + /** + * Sets the email address that a reading confirmation will be sent. + * @var string + */ + var $ConfirmReadingTo = ""; + + /** + * Sets the hostname to use in Message-Id and Received headers + * and as default HELO string. If empty, the value returned + * by SERVER_NAME is used or 'localhost.localdomain'. + * @var string + */ + var $Hostname = ""; + + ///////////////////////////////////////////////// + // SMTP VARIABLES + ///////////////////////////////////////////////// + + /** + * Sets the SMTP hosts. All hosts must be separated by a + * semicolon. You can also specify a different port + * for each host by using this format: [hostname:port] + * (e.g. "smtp1.example.com:25;smtp2.example.com"). + * Hosts will be tried in order. + * @var string + */ + var $Host = "localhost"; + + /** + * Sets the default SMTP server port. + * @var int + */ + var $Port = 25; + + /** + * Sets the SMTP HELO of the message (Default is $Hostname). + * @var string + */ + var $Helo = ""; + + /** + * Sets SMTP authentication. Utilizes the Username and Password variables. + * @var bool + */ + var $SMTPAuth = false; + + /** + * Sets SMTP username. + * @var string + */ + var $Username = ""; + + /** + * Sets SMTP password. + * @var string + */ + var $Password = ""; + + /** + * Sets the SMTP server timeout in seconds. This function will not + * work with the win32 version. + * @var int + */ + var $Timeout = 10; + + /** + * Sets SMTP class debugging on or off. + * @var bool + */ + var $SMTPDebug = false; + + /** + * Prevents the SMTP connection from being closed after each mail + * sending. If this is set to true then to close the connection + * requires an explicit call to SmtpClose(). + * @var bool + */ + var $SMTPKeepAlive = false; + + /**#@+ + * @access private + */ + var $smtp = NULL; + var $to = array(); + var $cc = array(); + var $bcc = array(); + var $ReplyTo = array(); + var $attachment = array(); + var $CustomHeader = array(); + var $message_type = ""; + var $boundary = array(); + var $language = array(); + var $error_count = 0; + var $LE = "\n"; + /**#@-*/ + + ///////////////////////////////////////////////// + // VARIABLE METHODS + ///////////////////////////////////////////////// + + /** + * Sets message type to HTML. + * @param bool $bool + * @return void + */ + function IsHTML($bool) { + if($bool == true) + $this->ContentType = "text/html"; + else + $this->ContentType = "text/plain"; + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + function IsSMTP() { + $this->Mailer = "smtp"; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + function IsMail() { + $this->Mailer = "mail"; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + function IsSendmail() { + $this->Mailer = "sendmail"; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + function IsQmail() { + $this->Sendmail = "/var/qmail/bin/sendmail"; + $this->Mailer = "sendmail"; + } + + + ///////////////////////////////////////////////// + // RECIPIENT METHODS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void + */ + function AddAddress($address, $name = "") { + $cur = count($this->to); + $this->to[$cur][0] = trim($address); + $this->to[$cur][1] = $name; + } + + /** + * Adds a "Cc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddCC($address, $name = "") { + $cur = count($this->cc); + $this->cc[$cur][0] = trim($address); + $this->cc[$cur][1] = $name; + } + + /** + * Adds a "Bcc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddBCC($address, $name = "") { + $cur = count($this->bcc); + $this->bcc[$cur][0] = trim($address); + $this->bcc[$cur][1] = $name; + } + + /** + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return void + */ + function AddReplyTo($address, $name = "") { + $cur = count($this->ReplyTo); + $this->ReplyTo[$cur][0] = trim($address); + $this->ReplyTo[$cur][1] = $name; + } + + + ///////////////////////////////////////////////// + // MAIL SENDING METHODS + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + function Send() { + $header = ""; + $body = ""; + $result = true; + + if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) + { + $this->SetError($this->Lang("provide_address")); + return false; + } + + // Set whether the message is multipart/alternative + if(!empty($this->AltBody)) + $this->ContentType = "multipart/alternative"; + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); + + if($body == "") { return false; } + + // Choose the mailer + switch($this->Mailer) + { + case "sendmail": + $result = $this->SendmailSend($header, $body); + break; + case "mail": + $result = $this->MailSend($header, $body); + break; + case "smtp": + $result = $this->SmtpSend($header, $body); + break; + default: + $this->SetError($this->Mailer . $this->Lang("mailer_not_supported")); + $result = false; + break; + } + + return $result; + } + + /** + * Sends mail using the $Sendmail program. + * @access private + * @return bool + */ + function SendmailSend($header, $body) { + if ($this->Sender != "") + $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender); + else + $sendmail = sprintf("%s -oi -t", $this->Sendmail); + + if(!@$mail = popen($sendmail, "w")) + { + $this->SetError($this->Lang("execute") . $this->Sendmail); + return false; + } + + fputs($mail, $header); + fputs($mail, $body); + + $result = pclose($mail) >> 8 & 0xFF; + if($result != 0) + { + $this->SetError($this->Lang("execute") . $this->Sendmail); + return false; + } + + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @access private + * @return bool + */ + function MailSend($header, $body) { + $to = ""; + for($i = 0; $i < count($this->to); $i++) + { + if($i != 0) { $to .= ", "; } + $to .= $this->to[$i][0]; + } + + if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1) + { + $old_from = ini_get("sendmail_from"); + ini_set("sendmail_from", $this->Sender); + $params = sprintf("-oi -f %s", $this->Sender); + $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, + $header, $params); + } + else + $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header); + + if (isset($old_from)) + ini_set("sendmail_from", $old_from); + + if(!$rt) + { + $this->SetError($this->Lang("instantiate")); + return false; + } + + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP (Author: + * Chris Ryan). Returns bool. Returns false if there is a + * bad MAIL FROM, RCPT, or DATA input. + * @access private + * @return bool + */ + function SmtpSend($header, $body) { + include_once(LINPHA_DIR . "/lib/classes/smtp.class.php"); + $error = ""; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) + return false; + + $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) + { + $error = $this->Lang("from_failed") . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + // Attempt to send attach all recipients + for($i = 0; $i < count($this->to); $i++) + { + if(!$this->smtp->Recipient($this->to[$i][0])) + $bad_rcpt[] = $this->to[$i][0]; + } + for($i = 0; $i < count($this->cc); $i++) + { + if(!$this->smtp->Recipient($this->cc[$i][0])) + $bad_rcpt[] = $this->cc[$i][0]; + } + for($i = 0; $i < count($this->bcc); $i++) + { + if(!$this->smtp->Recipient($this->bcc[$i][0])) + $bad_rcpt[] = $this->bcc[$i][0]; + } + + if(count($bad_rcpt) > 0) // Create error message + { + for($i = 0; $i < count($bad_rcpt); $i++) + { + if($i != 0) { $error .= ", "; } + $error .= $bad_rcpt[$i]; + } + $error = $this->Lang("recipients_failed") . $error; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + if(!$this->smtp->Data($header . $body)) + { + $this->SetError($this->Lang("data_not_accepted")); + $this->smtp->Reset(); + return false; + } + if($this->SMTPKeepAlive == true) + $this->smtp->Reset(); + else + $this->SmtpClose(); + + return true; + } + + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access private + * @return bool + */ + function SmtpConnect() { + if($this->smtp == NULL) { $this->smtp = new SMTP(); } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(";", $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + // Retry while there is no connection + while($index < count($hosts) && $connection == false) + { + if(strstr($hosts[$index], ":")) + list($host, $port) = explode(":", $hosts[$index]); + else + { + $host = $hosts[$index]; + $port = $this->Port; + } + + if($this->smtp->Connect($host, $port, $this->Timeout)) + { + if ($this->Helo != '') + $this->smtp->Hello($this->Helo); + else + $this->smtp->Hello($this->ServerHostname()); + + if($this->SMTPAuth) + { + if(!$this->smtp->Authenticate($this->Username, + $this->Password)) + { + $this->SetError($this->Lang("authenticate")); + $this->smtp->Reset(); + $connection = false; + } + } + $connection = true; + } + $index++; + } + if(!$connection) + $this->SetError($this->Lang("connect_host")); + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + function SmtpClose() { + if($this->smtp != NULL) + { + if($this->smtp->Connected()) + { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type, $lang_path = "language/") { + if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) + include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); + else if(file_exists($lang_path.'phpmailer.lang-en.php')) + include($lang_path.'phpmailer.lang-en.php'); + else + { + $this->SetError("Could not load language file"); + return false; + } + $this->language = $PHPMAILER_LANG; + + return true; + } + + ///////////////////////////////////////////////// + // MESSAGE CREATION METHODS + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access private + * @return string + */ + function AddrAppend($type, $addr) { + $addr_str = $type . ": "; + $addr_str .= $this->AddrFormat($addr[0]); + if(count($addr) > 1) + { + for($i = 1; $i < count($addr); $i++) + $addr_str .= ", " . $this->AddrFormat($addr[$i]); + } + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access private + * @return string + */ + function AddrFormat($addr) { + if(empty($addr[1])) + $formatted = $addr[0]; + else + { + $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . + $addr[0] . ">"; + } + + return $formatted; + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @access private + * @return string + */ + function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) + $message = substr($message, 0, -1); + + $line = explode($this->LE, $message); + $message = ""; + for ($i=0 ;$i < count($line); $i++) + { + $line_part = explode(" ", $line[$i]); + $buf = ""; + for ($e = 0; $e<count($line_part); $e++) + { + $word = $line_part[$e]; + if ($qp_mode and (strlen($word) > $length)) + { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) + { + if ($space_left > 20) + { + $len = $space_left; + if (substr($word, $len - 1, 1) == "=") + $len--; + elseif (substr($word, $len - 2, 1) == "=") + $len -= 2; + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= " " . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } + else + { + $message .= $buf . $soft_break; + } + $buf = ""; + } + while (strlen($word) > 0) + { + $len = $length; + if (substr($word, $len - 1, 1) == "=") + $len--; + elseif (substr($word, $len - 2, 1) == "=") + $len -= 2; + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) + $message .= $part . sprintf("=%s", $this->LE); + else + $buf = $part; + } + } + else + { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (" " . $word); + + if (strlen($buf) > $length and $buf_o != "") + { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Set the body wrapping. + * @access private + * @return void + */ + function SetWordWrap() { + if($this->WordWrap < 1) + return; + + switch($this->message_type) + { + case "alt": + // fall through + case "alt_attachments": + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access private + * @return string + */ + function CreateHeader() { + $result = ""; + + // Set the boundaries + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = "b1_" . $uniq_id; + $this->boundary[2] = "b2_" . $uniq_id; + + $result .= $this->HeaderLine("Date", $this->RFCDate()); + if($this->Sender == "") + $result .= $this->HeaderLine("Return-Path", trim($this->From)); + else + $result .= $this->HeaderLine("Return-Path", trim($this->Sender)); + + // To be created automatically by mail() + if($this->Mailer != "mail") + { + if(count($this->to) > 0) + $result .= $this->AddrAppend("To", $this->to); + else if (count($this->cc) == 0) + $result .= $this->HeaderLine("To", "undisclosed-recipients:;"); + if(count($this->cc) > 0) + $result .= $this->AddrAppend("Cc", $this->cc); + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend("From", $from); + + // sendmail and mail() extract Bcc from the header before sending + if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) + $result .= $this->AddrAppend("Bcc", $this->bcc); + + if(count($this->ReplyTo) > 0) + $result .= $this->AddrAppend("Reply-to", $this->ReplyTo); + + // mail() sets the subject itself + if($this->Mailer != "mail") + $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject))); + + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + $result .= $this->HeaderLine("X-Priority", $this->Priority); + $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]"); + + if($this->ConfirmReadingTo != "") + { + $result .= $this->HeaderLine("Disposition-Notification-To", + "<" . trim($this->ConfirmReadingTo) . ">"); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) + { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), + $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + $result .= $this->HeaderLine("MIME-Version", "1.0"); + + switch($this->message_type) + { + case "plain": + $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", + $this->ContentType, $this->CharSet); + break; + case "attachments": + // fall through + case "alt_attachments": + if($this->InlineImageExists()) + { + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", + "multipart/related", $this->LE, $this->LE, + $this->boundary[1], $this->LE); + } + else + { + $result .= $this->HeaderLine("Content-Type", "multipart/mixed;"); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case "alt": + $result .= $this->HeaderLine("Content-Type", "multipart/alternative;"); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != "mail") + $result .= $this->LE.$this->LE; + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access private + * @return string + */ + function CreateBody() { + $result = ""; + + $this->SetWordWrap(); + + switch($this->message_type) + { + case "alt": + $result .= $this->GetBoundary($this->boundary[1], "", + "text/plain", ""); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], "", + "text/html", ""); + + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + + $result .= $this->EndBoundary($this->boundary[1]); + break; + case "plain": + $result .= $this->EncodeString($this->Body, $this->Encoding); + break; + case "attachments": + $result .= $this->GetBoundary($this->boundary[1], "", "", ""); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; + + $result .= $this->AttachAll(); + break; + case "alt_attachments": + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . + "\tboundary=\"%s\"%s", + "multipart/alternative", $this->LE, + $this->boundary[2], $this->LE.$this->LE); + + // Create text body + $result .= $this->GetBoundary($this->boundary[2], "", + "text/plain", "") . $this->LE; + + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + + // Create the HTML body + $result .= $this->GetBoundary($this->boundary[2], "", + "text/html", "") . $this->LE; + + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + + $result .= $this->EndBoundary($this->boundary[2]); + + $result .= $this->AttachAll(); + break; + } + if($this->IsError()) + $result = ""; + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access private + */ + function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ""; + if($charSet == "") { $charSet = $this->CharSet; } + if($contentType == "") { $contentType = $this->ContentType; } + if($encoding == "") { $encoding = $this->Encoding; } + + $result .= $this->TextLine("--" . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", + $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access private + */ + function EndBoundary($boundary) { + return $this->LE . "--" . $boundary . "--" . $this->LE; + } + + /** + * Sets the message type. + * @access private + * @return void + */ + function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) + $this->message_type = "plain"; + else + { + if(count($this->attachment) > 0) + $this->message_type = "attachments"; + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) + $this->message_type = "alt"; + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) + $this->message_type = "alt_attachments"; + } + } + + /** + * Returns a formatted header line. + * @access private + * @return string + */ + function HeaderLine($name, $value) { + return $name . ": " . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access private + * @return string + */ + function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // ATTACHMENT METHODS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false... [truncated message content] |
From: <fan...@us...> - 2006-04-15 17:58:53
|
Revision: 4538 Author: fangehrn Date: 2006-04-15 10:58:34 -0700 (Sat, 15 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4538&view=rev Log Message: ----------- * basket - download currently broken, working on todos... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/include/basket_build_print.php trunk/linpha2/lib/include/basket_build_zip.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/templates/default/global.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/ChangeLog 2006-04-15 17:58:34 UTC (rev 4538) @@ -4,6 +4,10 @@ download needs still some improvements (chdir() to album dir to no get relative or absolute paths) + * added icon support + + * basket - download currently broken, working on todos... + 2006-04-14 flo * startet implementing basket checkout features (download, print, mail) * added settings all feature in admin section Modified: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -81,22 +81,9 @@ * Method to create filelist/path for files to download * @return string fullpath,path,src_path */ -function getImageList($img_ids) +function setImageList($files) { - $this->files = ''; - - foreach($img_ids AS $image_id) - { - $full_filename = LinSql::getFullImagePath( $image_id ); - - $this->files .= linEscapeString($full_filename)." "; - - /** - * store md5sum for later use (statistics) - * @todo - */ - //$this->md5sums[] = $data['md5sum']; - } + $this->files = $files; } @@ -118,14 +105,8 @@ $command = str_replace('{files}',$this->files,$command); // $this->files is already escaped $command = str_replace('{archive_name}',linEscapeString($this->tmpname),$command); - - //error_log($command); - - if(!chdir(LINPHA_DIR)) { - echo 'cannot chdir(LINPHA_DIR)!<br />'; - return false; - } + /** * delete tempfile first because winrar cannot write into this empty file (created with touch())! * -> it could be possible that linpha_tempnam() generates now a duplicate tmpname if another user @@ -133,8 +114,24 @@ * very unlikely because the session_id is included in tmpname and there is not much time between unlink() and exec() */ unlink($this->tmpname); + + + /** + * change dir to the albums dir to get nicer filenames in the archiv + */ + $olddir = getcwd(); + if(!chdir( $GLOBALS['linpha']->sql->getPath('album') )) { + echo 'cannot chdir(LINPHA_DIR)!<br />'; + return false; + } + exec($command,$array_output=Array(),$return_value=0); + + /** + * chdir back + */ + chdir($olddir); if(!file_exists($this->tmpname)) { echo 'Created archive doesnt exists<br />'; Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -384,6 +384,35 @@ break; } } + + /** + * Icons + */ + $GLOBALS['linpha']->template->output['menu_Icons'] = ''; + if($this->mode == 'thumb') + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=download">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Images").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Images").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_all_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Images").'" />' + .'</a>'."\n"; + } + elseif($this->mode == 'image') + { + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.LINPHA_DIR.'/download_file.php?id='.$this->id_current.'">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png" border="0" title="'.i18n("Download Image").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=print">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png" border="0" title="'.i18n("Print Image").'" />' + .'</a>'."\n"; + $GLOBALS['linpha']->template->output['menu_Icons'] .= '<a href="'.$GLOBALS['linpha']->template->URL_full.'&admin_cmd=basket_add_this_with_checkout&checkout_as=mail">'. + '<img src="'.LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png" border="0" title="'.i18n("Mail Image").'" />' + .'</a>'."\n"; + } } @@ -407,7 +436,12 @@ { } break; - case 'basket_add_all': // coming from imgview, mode=viewThumb + case 'basket_add_all': + case 'basket_add_all_with_checkout': + /** + * coming from imgview, mode=viewThumb + * the permission check with photoIsAllowed() is done while checking out + */ foreach($this->photos_filtered AS $value) { if($value['img_type']!=0) @@ -415,9 +449,25 @@ $_SESSION['basket_ids'][] = $value['id']; } } + + if($_GET['admin_cmd'] == 'basket_add_all_with_checkout') + { + header("Location: ".LINPHA_DIR."/?cat=basket&checkout_as=".$_GET['checkout_as']); + exit(); + } break; - case 'basket_add_this': // coming from imgview, mode=viewImg + case 'basket_add_this': + case 'basket_add_this_with_checkout': + /** + * coming from imgview, mode=viewImg + */ $_SESSION['basket_ids'][] = $this->id_current; + + if($_GET['admin_cmd'] == 'basket_add_this_with_checkout') + { + header("Location: ".LINPHA_DIR."/?cat=basket&checkout_as=".$_GET['checkout_as']); + exit(); + } break; } } Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -542,7 +542,7 @@ function getFullFilenameFromId( $photos_id ) { $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, parent_id FROM ".PREFIX."photos " . - "WHERE id = '".$GLOBALS['linpha']->sql->linAddslashes($photos_id)."'"); + "WHERE id = '".LinSql::linAddslashes($photos_id)."'"); $data = $query->FetchRow(); $array_names[ $photos_id ] = $data['name']; Modified: trunk/linpha2/lib/include/basket_build_print.php =================================================================== --- trunk/linpha2/lib/include/basket_build_print.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/include/basket_build_print.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -104,8 +104,10 @@ /** * read array with images to print */ +reset($_SESSION['basket_ids']); while(list($key, $image_id) = each($_SESSION['basket_ids'])) { + $full_filename = LinSql::getFullImagePath( $image_id ); /** Modified: trunk/linpha2/lib/include/basket_build_zip.php =================================================================== --- trunk/linpha2/lib/include/basket_build_zip.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/include/basket_build_zip.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -25,12 +25,23 @@ if(!defined('LINPHA_DIR')) { exit(1); } +/** + * set file list for direct use in exec() command + */ + $files = ''; + foreach($_SESSION['basket_ids'] AS $image_id) + { + $array_names = LinSql::getFullFilenameFromId( $image_id ); + + $filename = implode('/',$array_names); + + $files .= linEscapeString($filename)." "; + } + include_once(LINPHA_DIR.'/lib/classes/archiver.class.php'); - $archive = new Archive($_POST['ziptype'], $GLOBALS['linpha']->sql->config->value['sys_basket_download_limit']); +$archive->setImageList($files); -$archive->getImageList($_SESSION['basket_ids']); - if($archive->makeArchive()) { $archive->startDownload(); @@ -44,7 +55,14 @@ foreach($archive->md5sums AS $value) { linStats('download',$value,$time); - }*/ + } + /** + * store md5sum for later use (statistics) + * @todo + + //$this->md5sums[] = $data['md5sum']; + * + **/ } ?> Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -27,7 +27,6 @@ /** * parse POST data and GET commands */ - /** * download error handling */ @@ -47,72 +46,96 @@ switch($_REQUEST['cmd']) { case 'checkout': - if(! $GLOBALS['linpha']->sql->checkPermission($_REQUEST['checkout_as'])) + /** + * do the final checkout + */ + + try { - linSysLog(i18n("No Access")); - } - else - { /** + * check basket permission + */ + if(! $GLOBALS['linpha']->sql->checkPermission($_REQUEST['checkout_as'])) + { + throw new Exception(i18n("No Access")); + } + + /** * no images selected */ if( count($_SESSION['basket_ids']) == 0 ) { - echo linSysLog(i18n("No Images Selected!")); + throw new Exception(i18n("No Images Selected!")); } - else + + /** + * check permission of each image id + */ + foreach($_SESSION['basket_ids'] AS $value) { - - switch($_REQUEST['checkout_as']) + if(! $GLOBALS['linpha']->sql->photoIsAllowed($value)) { - case 'download': - include_once(LINPHA_DIR.'/lib/include/basket_build_zip.php'); - exit(); - break; - case 'print': - include_once(LINPHA_DIR.'/lib/include/basket_build_print.php'); - exit(); - break; - case 'mail': - include_once(LINPHA_DIR.'/lib/include/basket_build_mail.php'); - break; + throw new Exception(i18n("No Access")); } } + + /** + * do the final checkout + * exit script in download (the file download is startet in this file) and print (opens in a new page) + */ + switch($_REQUEST['checkout_as']) + { + case 'download': + include_once(LINPHA_DIR.'/lib/include/basket_build_zip.php'); + exit(); + break; + case 'print': + include_once(LINPHA_DIR.'/lib/include/basket_build_print.php'); + exit(); + break; + case 'mail': + include_once(LINPHA_DIR.'/lib/include/basket_build_mail.php'); + break; + } } + catch(Exception $error) + { + linSysLog(i18n("Error").": ".$error -> getMessage()); + } + break; - /** - * add ids to session if allowed - * coming from imgview, mode=viewBasket - */ case 'add_selected': + /** + * add ids to session + * coming from imgview, mode=viewBasket + * the permission check with photoIsAllowed() is done while checking out + */ if( isset( $_POST['img_id'] ) ) { foreach($_POST['img_id'] AS $value) { - if($GLOBALS['linpha']->sql->photoIsAllowed($value)) - { - $_SESSION['basket_ids'][] = $value; - } + $_SESSION['basket_ids'][] = $value; } } Header("Location: ".convert_amp($_SESSION['basket_ref_url'])); exit(); - - /** - * remove all - */ + case 'remove_all': + /** + * remove all + */ $_SESSION['basket_ids'] = Array(); break; - /** - * remove selected - */ case 'remove_selected': + /** + * remove selected + */ + if( isset( $_POST['img_id'] ) ) { foreach($_POST['img_id'] AS $value) Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-04-14 23:18:08 UTC (rev 4537) +++ trunk/linpha2/templates/default/global.html.php 2006-04-15 17:58:34 UTC (rev 4538) @@ -122,8 +122,10 @@ $GLOBALS['linpha']->template->printMenu("More"); } ?> <div> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/download.png'; ?>" title="<?php echo i18n("Download Images"); ?>" /> - <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/print.png'; ?>" title="<?php echo i18n("Print Images"); ?>" /> + <!-- icons --> + <?php if( isset( $GLOBALS['linpha']->template->output['menu_Icons'] ) ) { + echo $GLOBALS['linpha']->template->output['menu_Icons']; + } ?> <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> <ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-16 16:31:12
|
Revision: 4539 Author: fangehrn Date: 2006-04-16 09:30:56 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4539&view=rev Log Message: ----------- * changed way of selecting and saving paths during install (all folder paths are always stores without ending slash) * fixed some notices in installer * finished basket checkout features Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/lib.requirements.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/include/basket_build_mail.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/ChangeLog 2006-04-16 16:30:56 UTC (rev 4539) @@ -1,3 +1,9 @@ +2006-04-16 flo + * changed way of selecting and saving paths during install + (all folder paths are always stores without ending slash) + * fixed some notices in installer + * finished basket checkout features + 2006-04-15 flo * finished implementing basket checkout features (download, print, mail) print and mail works quite smooth Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/lib.install.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -104,7 +104,7 @@ } } -function get_PATH($array_path) +function linInstallget_PATH($array_path) { /** * use the path variable instead of own array @@ -335,7 +335,8 @@ while(strlen($http_accept_language)) { - if(preg_match( "/$eachbit/", $http_accept_language, $m=Array())) + $m = Array(); // do not this directly in preg_match() ! + if(preg_match( "/$eachbit/", $http_accept_language, $m)) { $tag = $m[1]; $quality = $m[2]; Modified: trunk/linpha2/install/lib.requirements.php =================================================================== --- trunk/linpha2/install/lib.requirements.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/lib.requirements.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -27,8 +27,8 @@ } else { $convert = 'convert'; } - $array_path = get_PATH('PATH'); - $array_lookfor = get_PATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); + $array_path = linInstallget_PATH('PATH'); + $array_lookfor = linInstallget_PATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); /** * need a special check if safe_mode is on @@ -44,8 +44,8 @@ if( !isset($array) ) { //echo $value.'<br />'; - - exec($value.'/'.$convert.' -help',$arr=array(),$return_var=''); + $arr=array(); $return_var=''; // do not this directly in exec() ! + exec($value.'/'.$convert.' -help',$arr,$return_var); //print_r($arr); @@ -61,6 +61,7 @@ { if( !isset($array) ) { + $arr=array(); $return_var=''; // do not this directly in exec() ! exec($value.'/'.$convert.' -help',$arr,$return_var); if(isset($return_var) && $return_var == 0) Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -27,9 +27,9 @@ include_once(LINPHA_DIR.'/install/header.php'); $album_dir = (isset($_SESSION['album_dir']) ? $_SESSION['album_dir'] : 'albums'); -$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir_parent'] : 'var/'); -$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir_parent'] : 'var/'); -$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir_parent'] : 'var/'); +$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir'] : 'var/sql'); +$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : 'var/cache'); +$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : 'var/tmp'); /** @@ -81,7 +81,7 @@ <input class="boxalignelement" type="text" id="check02" onKeyup="checkForm()" name="sql_dir" size="30" value="<?php echo $sql_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($sql_dir) ); ?>/sql) +(-> <?php echo linpha_realpath( get_full_path($sql_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -89,7 +89,7 @@ <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="cache_dir" size="30" value="<?php echo $cache_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($cache_dir) ); ?>/cache) +(-> <?php echo linpha_realpath( get_full_path($cache_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -97,7 +97,7 @@ <input class="boxalignelement" type="text" id="check04" onKeyup="checkForm()" name="tmp_dir" size="30" value="<?php echo $tmp_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($tmp_dir) ); ?>/tmp) +(-> <?php echo linpha_realpath( get_full_path($tmp_dir) ); ?>) <br /><br /> <?php Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step5_getlogin.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -53,40 +53,26 @@ $array = array('album', 'sql','cache','tmp'); foreach($array AS $value) { - if( isset( $_POST[$value.'_dir'] ) ) + /** + * remove '/' if not already done + */ + $len = strlen( $_POST[$value.'_dir'] ); + $lastsign = substr( $_POST[$value.'_dir'], $len-1); + if($lastsign == '/' && $lastsign == '\\') { - /** - * save correctly in session - */ - /** - * append '/' if not already done - */ - $len = strlen( $_POST[$value.'_dir'] ); - $lastsign = substr( $_POST[$value.'_dir'], $len-1); - if($lastsign != '/' && $lastsign != '\\') - { - $_POST[$value.'_dir'] .= '/'; - } - - /** - * save current value and append correct dir names - */ - $_SESSION[$value.'_dir_parent'] = $_POST[$value.'_dir']; - switch($value) - { - case 'album': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; break; - case 'sql': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'sql/'; break; - case 'cache': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'cache/'; break; - case 'tmp': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'tmp/'; break; - } + $_POST[$value.'_dir'] = substr($_POST[$value.'_dir'],0,$len-1); } + + /** + * save current value and append correct dir names + */ + $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; /** * get correct dir names (take care of relativ and absolute paths, add * LINPHA_DIR if necessary) */ $dirs[$value] = get_full_path( $_SESSION[$value.'_dir'] ); - $dirs[$value.'_parent'] = get_full_path( $_SESSION[$value.'_dir_parent'] ); } /** @@ -105,7 +91,10 @@ * validate writable directories */ echo "<h2>".tr("Checking Directory Permissions")."</h2><br />"; - + +/** + * checking album directory + */ echo tr("Album Directory")."... "; if( is_dir( $dirs['album'] ) ) { @@ -127,30 +116,24 @@ echo '<br /> ('.$_SESSION['album_dir'].')'; echo "<br />".tr("No Valid Directory Found")."!"; } - - $array = array('sql','cache','tmp'); - foreach($array AS $value) + +/** + * checking sql, cache and tmp directory + */ + try { - echo "<br /><br />Checking ".$value." Directory... "; - if(! is_dir( $dirs[$value.'_parent'] ) ) + $array = array('sql','cache','tmp'); + foreach($array AS $value) { - echo warning_msg(); - echo "<br />".tr("Directory ".$dirs[$value.'_parent']." Doesnt Exists - Trying To Create")."... "; - if( mkdir_p( $dirs[$value.'_parent'] ) ) + echo "<br /><br />".tr("Checking Directory").": ".$value."..."; + + if( file_exists( $dirs[$value] ) ) { - echo success_msg(); - } - else - { - echo failed_msg(); - } - } - - if( is_dir( $dirs[$value.'_parent'] ) ) - { - if( is_writable( $dirs[$value.'_parent'] ) ) - { - if( file_exists( $dirs[$value] ) ) + /** + * oh oh, pay attention, only try to delete the folder on default values! + * if the users choose wrongly the albums folder, all images would be deleted.!!!! + */ + if( $_SESSION[$value.'_dir'] == 'var/'.$value) { echo warning_msg(); echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; @@ -160,44 +143,43 @@ } else { - echo failed_msg(); - echo "<br />".tr("Please Delete Folder Manually").""; - $error_nr = 2; + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); } } else { - echo success_msg(); + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); } - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value.'_parent'] ).'/'.$value.')'; } + + echo "<br /> ".tr("Trying To Create Directory")."... "; + if( mkdir_p( $dirs[$value] ) ) + { + echo success_msg(); + + if( ! is_writable( $dirs[$value] ) ) + { + echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); + } + } else { - echo failed_msg(); - echo "<br />".tr("No Write Permissions. Please Change Permissions Or Choose Another Directory")."!"; - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value.'_parent'] ).'/'.$value.')'; - $error_nr = 1; + throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); } + + echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value] ).')<br />'; } - else - { - echo failed_msg(); - echo "<br />".tr("Directory Doesn't Exist")."!"; - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.$dirs[$value.'_parent'].'/'.$value.')'; // no realpath() because if dir does not exists realpath will show something strange... - $error_nr = 1; - } - } - - echo '<br /><br />'; - - if(isset($error_nr)) + catch(Exception $error) { + echo "Error: ".$error -> getMessage(); + $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); exit(); } ?> +<br /><br /> <hr /> <h1><?php echo tr("$title_str[$key]"); ?></h1> <br /> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step6_selectdatabase.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -214,7 +214,7 @@ if($_SESSION['allowed_to_create_db'] == false AND !isset($database)) { - if($_SESSION['sql_dbname'] == 'oci8po') + if($_SESSION['sql_dbtype'] == 'oci8po') { echo tr("Name Of Database To Use, this is usually \"XE\" For Oracle Express Edition"); } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step9_createtables.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -57,7 +57,7 @@ /** * finally create tables */ - echo tr("Creating Tables")."...<br /> "; + echo tr("Creating Tables")."... "; $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) @@ -76,8 +76,7 @@ */ if($_SESSION['sql_dbtype'] == 'oci8po') { - - echo tr("Creating Sequences")."...<br /> "; + echo tr("Creating Sequences")."...<br /> "; /** * create sequences @@ -155,21 +154,10 @@ /** * create cache directories */ - echo "<br /><br />".tr("Creating Directories")."... "; - @mkdir(get_full_path( $_SESSION['cache_dir'] ), 0700 ); - @mkdir(get_full_path( $_SESSION['cache_dir'] ).'img', 0700); - @mkdir(get_full_path( $_SESSION['cache_dir'] ).'thumb', 0700); + echo "<br /><br />".tr("Creating Cache Directories")."... "; + mkdir(get_full_path( $_SESSION['cache_dir'] ).'/img', 0700); + mkdir(get_full_path( $_SESSION['cache_dir'] ).'/thumb', 0700); - /** - * create tmp dirs - */ - @mkdir( get_full_path( $_SESSION['tmp_dir'] ), 0700 ); - - /** - * create sql dir - */ - @mkdir( get_full_path( $_SESSION['sql_dir'] ), 0700 ); - echo success_msg(); /** @@ -210,7 +198,7 @@ * create config.sql.php file */ echo "<br />".tr("Writing config.sql.php File")."... "; - $fp = fopen( get_full_path( $_SESSION['sql_dir'] )."config.sql.php","w+" ); + $fp = fopen( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php","w+" ); if($fp) { $comment[1] = ''; @@ -226,7 +214,7 @@ fwrite( $fp, $str ); fclose($fp); - if( !@chmod( get_full_path( $_SESSION['sql_dir'] )."config.sql.php", 0600 ) ) + if( !@chmod( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php", 0600 ) ) { echo warning_msg().'<br />'; echo tr("Chmod Failed For config.sql.php")."<br />"; Modified: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -36,7 +36,6 @@ var $sleeptime; var $ziptype; var $apps; -var $md5sums; /** * constructor @@ -55,6 +54,7 @@ $this->tmpname = LinFilesys::linTempnam( 'linpha_download', // prefix '.'.$this->apps->apps[$this->ziptype]['file_ext'] // suffix + ,$use_absolutepath=true // need absolute path because we use chdir()! ); } @@ -126,6 +126,7 @@ return false; } + $array_output=array(); $return_value=''; // do not this directly in exec() ! exec($command,$array_output=Array(),$return_value=0); /** Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -28,6 +28,30 @@ { /** + * realpath() doesnt work somtimes if path is absolute + * linRealpath takes care of this + */ +function linRealpath( $path) +{ + if( ! LinFilesys::isAbsolutePath( $path ) ) + { + $path = realpath( $path ); + } + + /** + * remove ending '/' if exists + */ + $len = strlen( $path ); + $lastsign = substr( $path, $len-1); + if($lastsign == '/' OR $lastsign == '\\') + { + $path = substr($path,0,$len-1); + } + + return $path; +} + +/** * returns a unique filename, but different to tempnam() the file doesn't exists * * @author flo @@ -38,9 +62,15 @@ * * http://ch.php.net/manual/de/function.uniqid.php */ -function linTempnam($prefix,$suffix) +function linTempnam($prefix,$suffix,$use_absolutepath=false) { $tmp_dir = LinSql::getPath('tmp'); + + if($use_absolutepath) + { + $tmp_dir = LinFilesys::LinRealpath($tmp_dir); + } + if(!is_writable($tmp_dir)) { error_log("linpha_tempnam: tmp_dir ($tmp_dir) isn't writable! Using /tmp instead"); $tmp_dir = '/tmp'; Modified: trunk/linpha2/lib/include/basket_build_mail.php =================================================================== --- trunk/linpha2/lib/include/basket_build_mail.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/include/basket_build_mail.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -63,23 +63,24 @@ return $available_mem; } -if( empty($_POST['mail_address']) OR empty($_POST['sender_address']) OR empty($_POST['subject']) ) + +try { - linSysLog(i18n("Please Fill In All Fields!")); - $error = true; -} + if( empty($_POST['mail_address']) OR empty($_POST['sender_address']) OR empty($_POST['subject']) ) + { + throw new Exception(i18n("Please Fill In All Fields!")); + } -if(!isset($error)) -{ + $tmp_folder = LinFilesys::createTmpFolder('mail'); /** * create temporary folder containing all images */ + reset($_SESSION['basket_ids']); while(list($key, $image_id) = each($_SESSION['basket_ids'])) { $data = $GLOBALS['linpha']->db->GetRow("SELECT img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $image_id )."'"); - if(isset($data['img_type']) && LinIdentify::isSupportedImage( $data['img_type'] ) ) { $at_least_one_image = true; @@ -118,24 +119,19 @@ */ if(!$at_least_one_image) { - echo linSysLog(i18n("No Images Available! Videos are currently not supported.")); - $error = true; + throw new Exception(i18n("No Images Available! Videos are currently not supported.")); } - elseif( - ($real_mail_size > $max_mail_size ) // only overhead of base64 (33%) - OR - ( !$no_mem_limit AND $real_mail_size > get_available_mem()) - ) + + + /** + * check if mail is getting to big + */ + if( + ($real_mail_size > $max_mail_size ) // only overhead of base64 (33%) + OR + ( !$no_mem_limit AND $real_mail_size > get_available_mem()) + ) { - linSysLog( - i18n("Error: The E-Mail is too big."). - "<br /><br />". - sprintf(i18n("Allowed size: %sBytes. Your selected images use %sBytes."),$max_mail_size,$real_mail_size). - "<br /><br />". - i18n("Remove some images or use the download zipped albums feature!") - ); - $error = true; - /** * but still delete images */ @@ -152,87 +148,95 @@ * delete temporary folder */ rmdir($tmp_folder); + + throw new Exception( + i18n("Error: The E-Mail is too big."). + "<br /><br />". + sprintf(i18n("Allowed size: %sBytes. Your selected images use %sBytes."),$max_mail_size,$real_mail_size). + "<br /><br />". + i18n("Remove some images or use the download zipped albums feature!") + ); } - if(!isset($error)) + include_once(LINPHA_DIR.'/lib/classes/phpmailer.class.php'); + + $mail = new PHPMailer(); + + $mail->IsSmtp(); + $mail->Host = "localhost"; + $mail->From = $_POST['sender_address']; + $mail->FromName = $_POST['sender_address']; // otherwise, a default name like "Root User" is taken + $mail->AddAddress($_POST['mail_address']); + $mail->Subject = $_POST['subject']; + $mail->Body = $_POST['text_message']; + + $d = dir($tmp_folder); + while (false !== ($entry = $d->read())) { - include_once(LINPHA_DIR.'/lib/classes/phpmailer.class.php'); - - $mail = new PHPMailer(); - - $mail->IsSmtp(); - $mail->Host = "localhost"; - $mail->From = $_POST['sender_address']; - $mail->FromName = $_POST['sender_address']; // otherwise, a default name like "Root User" is taken - $mail->AddAddress($_POST['mail_address']); - $mail->Subject = $_POST['subject']; - $mail->Body = $_POST['text_message']; - - $d = dir($tmp_folder); - while (false !== ($entry = $d->read())) + if($entry != '.' && $entry != '..') { - if($entry != '.' && $entry != '..') + if($_POST['mail_mode'] == "txt") { - if($_POST['mail_mode'] == "txt") - { - $handle = fopen($tmp_folder.'/'.$entry,"rb"); - $file_content = fread( $handle, filesize( $tmp_folder.'/'.$entry ) ); - fclose($handle); - - $mail->AddStringAttachment("$file_content", "$entry"); + $handle = fopen($tmp_folder.'/'.$entry,"rb"); + $file_content = fread( $handle, filesize( $tmp_folder.'/'.$entry ) ); + fclose($handle); - unlink($tmp_folder.'/'.$entry); - } - else - { - $image_filename = "$tmp_folder/$entry"; - - $mail->AddAttachment("$image_filename", "$entry", "base64", "image/jpeg"); - - /** - * We have to delete tmp files later, as AddAttachment() - * just adds a reference to the images and unlink would delete - * them before they were send out... - */ - $array_files[] = $image_filename; - } + $mail->AddStringAttachment("$file_content", "$entry"); + + unlink($tmp_folder.'/'.$entry); } + else + { + $image_filename = "$tmp_folder/$entry"; + + $mail->AddAttachment("$image_filename", "$entry", "base64", "image/jpeg"); + + /** + * We have to delete tmp files later, as AddAttachment() + * just adds a reference to the images and unlink would delete + * them before they were send out... + */ + $array_files[] = $image_filename; + } } - $d->close(); + } + $d->close(); + + if($_POST['mail_mode'] == "html") + { + $mail->IsHTML(true); + } - if($_POST['mail_mode'] == "html") + if(!$mail->Send()) + { + /** + * no exception, because we still need to delete the images + */ + linSysLog(i18n("Error: E-Mail couldn't be sent. Contact the Administrator.")); + } + + $mail->ClearAddresses(); + $mail->ClearAttachments(); + + /** + * delete temporary folder + */ + if($_POST['mail_mode'] == "html") + { + foreach($array_files as $filename) { - $mail->IsHTML(true); + unlink($filename); } - - if(!$mail->Send()) - { - linSysLog(i18n("Error: E-Mail couldn't be sent. Contact the Administrator.")); - $error = true; - } + } + rmdir($tmp_folder); - $mail->ClearAddresses(); - $mail->ClearAttachments(); - - /** - * delete temporary folder - */ - if($_POST['mail_mode'] == "html") - { - foreach($array_files as $filename) - { - unlink($filename); - } - } - rmdir($tmp_folder); - } -} - -if(!isset($error)) -{ linSysLog( i18n("Email Sent To").': '.$_POST['mail_address']. - '<br /><br />'.i18n("Size Of E-Mail").": ".niceFilesize($real_mail_size,1) + '<br />'.i18n("Size Of E-Mail").": ".niceFilesize($real_mail_size,1) ); } +catch(Exception $error) +{ + linSysLog("Error: ".$error -> getMessage()); +} ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-16 16:41:35
|
Revision: 4540 Author: fangehrn Date: 2006-04-16 09:41:19 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4540&view=rev Log Message: ----------- * added "install" prefix to all functions in lib.install.php and lib.requirements.php Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/lib.requirements.php trunk/linpha2/install/step2_requirements.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step7_selectprefix.php trunk/linpha2/install/step9_createtables.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/ChangeLog 2006-04-16 16:41:19 UTC (rev 4540) @@ -3,6 +3,7 @@ (all folder paths are always stores without ending slash) * fixed some notices in installer * finished basket checkout features + * added "install" prefix to all functions in lib.install.php and lib.requirements.php 2006-04-15 flo * finished implementing basket checkout features (download, print, mail) Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/lib.install.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -104,7 +104,7 @@ } } -function linInstallget_PATH($array_path) +function installGetPATH($array_path) { /** * use the path variable instead of own array @@ -152,7 +152,7 @@ /** * delete directory recurisvely - same as "rm -rf" */ -function rm_rf($path,$followLinks=false) +function installRm_rf($path,$followLinks=false) { $dir = opendir($path) ; while (false !== ($entry = readdir($dir))) @@ -163,7 +163,7 @@ } elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) { - rm_rf( "$path/$entry" ); + installRm_rf( "$path/$entry" ); } } closedir($dir) ; @@ -173,7 +173,7 @@ /** * create directory recursively - same as "mkdir -p" */ -function mkdir_p($target,$mode='0700') +function installMkdir_p($target,$mode='0700') { if(is_dir($target) || empty($target)) { // best case check first return true; @@ -181,7 +181,7 @@ if(file_exists($target) && !is_dir($target)) { // target exists bug isn't a directory.. return false; } - if( mkdir_p( substr( $target,0,strrpos( $target,'/') ) ) ) + if( installMkdir_p( substr( $target,0,strrpos( $target,'/') ) ) ) { return mkdir($target,intval($mode,8)); // crawl back up & create dir tree } @@ -193,11 +193,11 @@ /** * realpath() doesnt work if path is absolute - * linpha_realpath takes care of this + * installLinRealpath takes care of this */ -function linpha_realpath( $path) +function installLinRealpath( $path) { - if( ! is_absolute_path( $path ) ) + if( ! installIsAbsolutePath( $path ) ) { $path = realpath( $path ); } @@ -225,9 +225,9 @@ * @uses actions/submit_mod_data.php,photo_cache_cleanup_by_id(),photo_cache_delete_folder() * @package filesys */ -function get_full_path($path) +function installGetFullPath($path) { - if(is_absolute_path($path)) { + if(installIsAbsolutePath($path)) { $full_path = $path; } else { $full_path = LINPHA_DIR.'/'.$path; @@ -242,10 +242,10 @@ * @author flo * @param string $path a path * @return ture|false is an absolute path or not -* @uses get_full_path() +* @uses installGetFullPath() * @package filesys */ -function is_absolute_path($path) +function installIsAbsolutePath($path) { if(substr($path,0,1) == '/' OR // string begins with a '/' -> absolut path ((strpos($path, ':') !== false) AND (strpos( PHP_OS, 'WIN' ) !== FALSE)) // we are on windows and the string contains a ':' -> absolut path (c:/..) @@ -261,7 +261,7 @@ */ function get_available_language_files() { - $folder = get_full_path('install/lang'); + $folder = installGetFullPath('install/lang'); $file_handle = opendir($folder); $file = readdir($file_handle); Modified: trunk/linpha2/install/lib.requirements.php =================================================================== --- trunk/linpha2/install/lib.requirements.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/lib.requirements.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -20,15 +20,15 @@ /** * @package Installation */ -function check_convert() +function installCheckConvert() { if(installGetOS()=='win') { $convert = 'convert.exe'; } else { $convert = 'convert'; } - $array_path = linInstallget_PATH('PATH'); - $array_lookfor = linInstallget_PATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); + $array_path = installGetPATH('PATH'); + $array_lookfor = installGetPATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); /** * need a special check if safe_mode is on @@ -149,7 +149,7 @@ * @uses sec_stage_install.php, plugins/ftp/index.php * @package requirements */ -function check_posix() +function installCheckPosix() { $array_needed_functions = Array( 'posix_getuid', @@ -182,7 +182,7 @@ /** * @package requirements */ -function get_mem_limit() +function installGetMemLimit() { $memlimit=ini_get('memory_limit'); Modified: trunk/linpha2/install/step2_requirements.php =================================================================== --- trunk/linpha2/install/step2_requirements.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/step2_requirements.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -121,7 +121,7 @@ */ print_line_left("ImageMagick"); - list($convert_avail, $convert_path, $convert_version) = check_convert(); + list($convert_avail, $convert_path, $convert_version) = installCheckConvert(); if($convert_avail) { @@ -248,7 +248,7 @@ if(installGetOS() != "win") { print_line_left("Posix Extension"); - if(check_posix()) + if(installCheckPosix()) { print_line_middle("Yes"); print_line_right(success_msg()); @@ -301,7 +301,7 @@ * memory limit */ print_line_left("PHP Memory limit"); - $limit = get_mem_limit(); + $limit = installGetMemLimit(); if($limit === false) { print_line_middle("Unlimited"); Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -70,7 +70,7 @@ <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="album_dir" size="30" value="<?php echo $album_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($album_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($album_dir) ); ?>) <br /><br /> <h2><?php echo tr("Warning: All Existing Subdirectories Will Be Deleted"); ?></h2> @@ -81,7 +81,7 @@ <input class="boxalignelement" type="text" id="check02" onKeyup="checkForm()" name="sql_dir" size="30" value="<?php echo $sql_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($sql_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($sql_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -89,7 +89,7 @@ <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="cache_dir" size="30" value="<?php echo $cache_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($cache_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($cache_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -97,7 +97,7 @@ <input class="boxalignelement" type="text" id="check04" onKeyup="checkForm()" name="tmp_dir" size="30" value="<?php echo $tmp_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($tmp_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($tmp_dir) ); ?>) <br /><br /> <?php Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/step5_getlogin.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -72,7 +72,7 @@ * get correct dir names (take care of relativ and absolute paths, add * LINPHA_DIR if necessary) */ - $dirs[$value] = get_full_path( $_SESSION[$value.'_dir'] ); + $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); } /** @@ -101,12 +101,12 @@ if( is_writable( $dirs['album'] ) ) { echo success_msg(); - echo '<br /> ('.$_SESSION['album_dir'].' => '.linpha_realpath( $dirs['album'] ).')'; + echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; } else { echo warning_msg(); - echo '<br /> ('.$_SESSION['album_dir'].' => '.linpha_realpath( $dirs['album'] ).')'; + echo '<br /> ('.$_SESSION['album_dir'].' => '.installLinRealpath( $dirs['album'] ).')'; echo "<br />".tr("Album Directory Not Writable. Some Features May Not Work")."<br />"; } } @@ -137,7 +137,7 @@ { echo warning_msg(); echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; - if( rm_rf( $dirs[$value] ) ) + if( installRm_rf( $dirs[$value] ) ) { echo success_msg(); } @@ -153,7 +153,7 @@ } echo "<br /> ".tr("Trying To Create Directory")."... "; - if( mkdir_p( $dirs[$value] ) ) + if( installMkdir_p( $dirs[$value] ) ) { echo success_msg(); @@ -167,7 +167,7 @@ throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); } - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value] ).')<br />'; + echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; } } catch(Exception $error) Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/step7_selectprefix.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -158,24 +158,16 @@ /** * save current value and append correct dir names */ - $_SESSION[$value.'_dir_parent'] = $_POST[$value.'_dir']; - switch($value) - { - case 'album': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; break; - case 'sql': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'sql/'; break; - case 'cache': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'cache/'; break; - case 'tmp': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'tmp/'; break; - } + $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; } /** * get correct dir names (take care of relativ and absolute paths, add * LINPHA_DIR if necessary) */ - $dirs[$value] = get_full_path( $_SESSION[$value.'_dir'] ); - $dirs[$value.'_parent'] = get_full_path( $_SESSION[$value.'_dir_parent'] ); + $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); } - if(file_exists(LINPHA_DIR.'/'.$_SESSION['sql_dir'].$_SESSION['sql_dbname'])) + if(file_exists(LINPHA_DIR.'/'.$_SESSION['sql_dir'].'/'.$_SESSION['sql_dbname'])) { echo failed_msg(); echo "<br />".tr("Database Already Exists, Delete The File ".$_SESSION['sql_dbname']." first!").""; @@ -188,7 +180,7 @@ * store in session to be used when switching to adodb */ - if ($db = @sqlite_open(LINPHA_DIR.'/'.$_SESSION['sql_dir'].$_SESSION['sql_dbname'], 0666, $sqliteerror)) + if ($db = @sqlite_open(LINPHA_DIR.'/'.$_SESSION['sql_dir'].'/'.$_SESSION['sql_dbname'], 0666, $sqliteerror)) { echo success_msg(); } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2006-04-16 16:30:56 UTC (rev 4539) +++ trunk/linpha2/install/step9_createtables.php 2006-04-16 16:41:19 UTC (rev 4540) @@ -155,8 +155,8 @@ * create cache directories */ echo "<br /><br />".tr("Creating Cache Directories")."... "; - mkdir(get_full_path( $_SESSION['cache_dir'] ).'/img', 0700); - mkdir(get_full_path( $_SESSION['cache_dir'] ).'/thumb', 0700); + mkdir(installGetFullPath( $_SESSION['cache_dir'] ).'/img', 0700); + mkdir(installGetFullPath( $_SESSION['cache_dir'] ).'/thumb', 0700); echo success_msg(); @@ -198,7 +198,7 @@ * create config.sql.php file */ echo "<br />".tr("Writing config.sql.php File")."... "; - $fp = fopen( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php","w+" ); + $fp = fopen( installGetFullPath( $_SESSION['sql_dir'] )."/config.sql.php","w+" ); if($fp) { $comment[1] = ''; @@ -214,7 +214,7 @@ fwrite( $fp, $str ); fclose($fp); - if( !@chmod( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php", 0600 ) ) + if( !@chmod( installGetFullPath( $_SESSION['sql_dir'] )."/config.sql.php", 0600 ) ) { echo warning_msg().'<br />'; echo tr("Chmod Failed For config.sql.php")."<br />"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-18 11:18:49
|
Revision: 4545 Author: fangehrn Date: 2006-04-18 04:18:37 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4545&view=rev Log Message: ----------- * calendar: apply previous update from linpha1 + change "set date" field also automatically to custom if using the calendar Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/include/calender.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-17 17:26:25 UTC (rev 4544) +++ trunk/linpha2/ChangeLog 2006-04-18 11:18:37 UTC (rev 4545) @@ -1,3 +1,7 @@ +2006-04-18 flo + * calendar: apply previous update from linpha1 + + change "set date" field also automatically to custom if using the calendar + 2006-04-16 flo * changed way of selecting and saving paths during install (all folder paths are always stores without ending slash) Modified: trunk/linpha2/lib/include/calender.php =================================================================== --- trunk/linpha2/lib/include/calender.php 2006-04-17 17:26:25 UTC (rev 4544) +++ trunk/linpha2/lib/include/calender.php 2006-04-18 11:18:37 UTC (rev 4545) @@ -20,6 +20,9 @@ if(!defined('LINPHA_DIR')) { define('LINPHA_DIR','../..'); } $style['tablebg']="#B3BCDE"; +/** + * @todo do we need the startSession() for the language stuff? + */ include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); ?> <title>Calender - LinPHA</title> @@ -126,7 +129,15 @@ $font1 = ""; $font2 = ""; } - print "<a href=\"#\" onClick=\"opener.document.getElementById('".$_GET['form']."').value='$tag',window.close();\">$font1$d$font2</a>"; + if(isset($_GET['additional_cmd'])) + { + $str = ",opener.".$_GET['additional_cmd']; + } + else + { + $str = ""; + } + echo '<a href="#" onClick="opener.document.getElementById(\''.$_GET['form'].'\').value=\''.$tag.'\'' . $str . ',window.close();">'.$font1.$d.$font2.'</a>'; print "</td>\n"; /*== Saturday week with </tr> ==*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-24 20:09:10
|
Revision: 4546 Author: fangehrn Date: 2006-04-24 13:08:47 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4546&view=rev Log Message: ----------- * created import/index/create thumbnail/re-create-scripts in admin-import section Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/import.php trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.image.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.browse.php trunk/linpha2/lib/modules/module.search.php trunk/linpha2/templates/default/search.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/ChangeLog 2006-04-24 20:08:47 UTC (rev 4546) @@ -1,3 +1,6 @@ +2006-04-24 flo + * created import/index/create thumbnail/re-create-scripts in admin-import section + 2006-04-18 flo * calendar: apply previous update from linpha1 + change "set date" field also automatically to custom if using the calendar Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/admin/import.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -1,41 +1,334 @@ <?php if(!defined('LINPHA_DIR')) { exit(1); } -include_once(LINPHA_DIR.'/lib/adodb/tohtml.inc.php'); +$array_meta = Array('exif','iptc','xmp'); -//linImport::emptyTable(); +if( isset($_POST['cmd']) && $_POST['cmd']=='import') +{ + if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') + { + $all_albums = true; + } + else + { + $all_albums = false; + } -if($linpha->sql->config->value['sys_import_autoimport']) + + /** + * import + */ + if($_REQUEST['index_import']=='index') + { + echo i18n("Running Import...").'<br />'; + if($all_albums) + { + echo i18n("Parsing All Directories...").'<br />'; + LinImport::updateDir( $parent_id = 0, $recursive = true, $dryrun = false ); + } + else + { + foreach($_REQUEST['album_select'] AS $key=>$value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); + echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; + LinImport::updateDir( $parent_id = $value, $recursive = true, $dryrun = false ); + } + } + + if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + { + echo $GLOBALS['linpha']->template->output['sys_log']; + unset($GLOBALS['linpha']->template->output['sys_log']); + } + + echo '<br />'; + } + + /** + * thumbnails + */ + /** + * @todo should we create the folder thumbnails here? + * they will be automatically created on each visit + * we would have to take care to the script backwards, + * that means first of the depest subfolder until we're on top + */ + if($_REQUEST['index_thumbnails']!='no') + { + echo i18n("Creating Thumbnails...").'<br />'; + + $thumbnail = new LinImage(); + + if($_REQUEST['index_thumbnails']=='recreate') + { + $_GET['force'] = true; + } + + if($all_albums) + { + echo i18n("Parsing All Directories...").'<br />'; + echo i18n("Create Thumbnail"); + + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + if( ! $thumbnail->createThumbnail($data[0]) ) + { + echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + } + if( ! $thumbnail->isCached ) + { + echo " ".$data[0].","; + } + flush(); + } + + } + else + { + foreach($_REQUEST['album_select'] AS $key=>$value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); + echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; + echo i18n("Create Thumbnail"); + + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE " . + "parent_id = '".LinSql::linAddslashes($value)."' AND " . + "img_type <> 0 AND img_type <> 9999999"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + if( ! $thumbnail->createThumbnail($data[0]) ) + { + echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + } + if( ! $thumbnail->isCached ) + { + echo " ".$data[0].","; + } + flush(); + } + } + } + + echo '<br /><br />'; + } + + + /** + * exif, iptc, xmp + */ + include_once(LINPHA_DIR.'/lib/classes/linpha.metadata.class.php'); + $MetaData = new MetaData(); + + foreach($array_meta AS $meta_value) + { + if( isset( $_REQUEST['index_'.$meta_value] ) ) + { + echo i18n("Indexing Files...").' ('.strtoupper($meta_value).')<br />'; + + /** + * get imgids to indexing, if reindex is selected: delete these entries first + */ + if($all_albums) + { + echo i18n("Parsing All Directories...").'<br />'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); + while($data = $query->FetchRow()) + { + if( $_REQUEST['index_'.$meta_value] != 'no') + { + $array_meta_ids[$data['id']] = $data['md5sum']; + } + + if( isset($_REQUEST['index_'.$meta_value.'_delete'])) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); + } + } + + } + else + { + foreach($_REQUEST['album_select'] AS $key=>$value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($value)."'"); + echo i18n("Parsing Directory:").' '.$data['name'].'<br />'; + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, md5sum FROM ".PREFIX."photos WHERE " . + "parent_id = '".LinSql::linAddslashes($value)."' AND " . + "img_type <> 0 AND img_type <> 9999999"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + if( $_REQUEST['index_'.$meta_value] != 'no') + { + $array_meta_ids[$data['id']] = $data['md5sum']; + } + + if( isset($_REQUEST['index_'.$meta_value.'_delete'])) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."meta_".$meta_value." WHERE md5sum = '".$data['md5sum']."'"); + } + } + } + } + + /** + * parse all ids + */ + if(isset($array_meta_ids)) + { + $MetaData->setFields($meta_value); + + echo i18n("Index Image"); + + foreach($array_meta_ids AS $id=>$md5sum) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum ". + "FROM ".PREFIX."meta_exif WHERE md5sum = '".$md5sum."'"); + + if( $query->EOF) // not a single value returned + { + $full_filename = LinSql::getFullImagePath($id); + + switch($meta_value) + { + case 'exif': + include_once(LINPHA_DIR.'/lib/classes/phpmeta/JPEG.php'); // used for jpeg comment + include_once(LINPHA_DIR.'/lib/classes/phpmeta/EXIF.php'); + $MetaData->saveExifData( $full_filename,$md5sum ); + break; + case 'iptc': + include_once(LINPHA_DIR.'/lib/classes/phpmeta/Photoshop_IRB.php'); + include_once(LINPHA_DIR.'/lib/classes/phpmeta/JPEG.php'); + $MetaData->saveIptcData( $full_filename,$md5sum ); + break; + case 'xmp': + break; + } + + echo " ".$id.","; + flush(); + } + } + } + + echo '<br />'; + } + unset($array_meta_ids); + } +} + + +echo '<h2>'.i18n("Import").'</h2>'; +echo i18n("Select Folders For Import/Update:"); +?> +<br /> +<form action="./?cat=import" method="POST"> +<select name="album_select[]" size="10" multiple="multiple" style="width: 500px;"> +<?php buildAlbumSelect($with_all_albs_entry=true); ?> +</select> +<br /><br /> + +<?php echo i18n("Import").':'; ?> +<br /> +<input type="radio" id="index_import_no" name="index_import" value="no" /><label for="index_import_no"> <?php echo i18n("No Import"); ?></label><br /> +<input type="radio" id="index_import_index" name="index_import" value="index" checked="checked" /><label for="index_import_index"> <?php echo i18n("Import"); ?></label><br /> +<br /> + +<?php echo i18n("Thumbnails").':'; ?> +<br /> +<input type="radio" id="index_thumbnails_deletefirstreindex" name="index_thumbnails" value="recreate" /><label for="index_thumbnails_reindex"> <?php echo i18n("Re-create"); ?></label><br /> +<input type="radio" id="index_thumbnails_no" name="index_thumbnails" value="no" /><label for="index_thumbnails_no"> <?php echo i18n("No Create"); ?></label><br /> +<input type="radio" id="index_thumbnails_index" name="index_thumbnails" value="create" checked="checked" /><label for="index_thumbnails_index"> <?php echo i18n("Create"); ?></label><br /> +<br /> + +<?php +foreach($array_meta AS $value) { - LinImport::updateDir( $parent_id = 0, $recursive = true ); + if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) + { + echo strtoupper($value).":<br />"; + echo '<input type="checkbox" id="index_'.$value.'_deletefirst" name="index_'.$value.'_delete" value="delete" /><label for="index_'.$value.'_deletefirst"> '.i18n("Delete First").'</label><br />'; + echo '<input type="radio" id="index_'.$value.'_no" name="index_'.$value.'" value="no" /><label for="index_'.$value.'_no"> '.i18n("No indexing").'</label><br />'; + echo '<input type="radio" id="index_'.$value.'_index" name="index_'.$value.'" value="index" checked="checked" /><label for="index_'.$value.'_index"> '.i18n("Indexing").'</label><br />'; + echo '<br />'; + } } +?> +<input type="hidden" name="cmd" value="import"> +<input type="submit" name="submit" value="<?php echo i18n("Start"); ?>" /> +</form> +<br /><br /> +<?php + + /** - * create thumbnails + * dry-run */ +echo '<h2>'.i18n("Stuff Not Up-To-Date").'</h2>'; - $thumbnail = new LinImage(); +/** + * import + */ + if($linpha->sql->config->value['sys_import_autoimport']) + { + LinImport::updateDir( $parent_id = 0, $recursive = true, $dryrun = true ); + } /** - * first, only for images + * flush buffer */ + echo '<b>'.i18n("Following files/folders needs updating:").'</b><br />'; + if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + { + echo $GLOBALS['linpha']->template->output['sys_log']; + unset($GLOBALS['linpha']->template->output['sys_log']); + } + else + { + echo i18n("Nothing, we're up-to-date!").'<br />'; + } + + echo '<br />'; + +/** + * thumbnails + */ + $thumbnail = new LinImage(); + + $num = 0; $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - if( ! $thumbnail->createThumbnail($data['0']) ) + + $thumbnail->mode = 'thumb'; + $thumbnail->photo_id = $data[0]; + + $thumbnail->setFileInformation(); + + if( ! $thumbnail->isCached ) { - echo "Error while creating thumbnail!<br />Error: ".$thumbnail->error_msg."<br />"; + $num++; } } + echo '<b>'.i18n("Nr Thumbnails To Create:").' '.$num.'<br />'; - /** - * @todo should we create the folder thumbnails here? - * they will be automatically created on each visit - * we would have to take care to the script backwards, - * that means first of the depest subfolder until we're on top - */ - +/** + * exif, iptc, xmp + */ + $nr_total = $GLOBALS['linpha']->db->GetRow("SELECT sum(stats_numbers) FROM ".PREFIX."photos WHERE parent_id = '0' GROUP BY parent_id"); + foreach($array_meta AS $value) + { + if($GLOBALS['linpha']->sql->config->value['sys_image_'.$value]) + { + $nr_indexed = $GLOBALS['linpha']->db->GetRow("SELECT count(md5sum) FROM ".PREFIX."meta_".$value); + echo strtoupper($value).': '.i18n("Nr Images Needs Indexing:").' ' . ($nr_total[0] - $nr_indexed[0]) .' <br />'; + } + } ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/classes/linpha.functions.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -223,6 +223,7 @@ return $str; } + /** * linpha syslog window, shows up system info like "images added" */ @@ -236,7 +237,48 @@ $GLOBALS['linpha']->template->output['sys_log'] .= $str; } +/** + * functions to create a html select form with all albums + */ +function buildAlbumSelect($with_all_albs_entry) +{ + ?> + + <?php + if($with_all_albs_entry) + { + if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select'][0]=='all') { + $select = ' selected'; + $_REQUEST['album_select'] = Array('all'=>'all'); + } else { + $select = ''; + } + echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'."\n"; + } + + buildAlbumSelectSubEntry(0,''); +} +function buildAlbumSelectSubEntry($id,$text) +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); + while($data = $query->FetchRow()) + { + if(!isset($_REQUEST['album_select'])) { + $_REQUEST['album_select'] = array(); + } + if(in_array($data['id'],$_REQUEST['album_select'])) { + $select = ' selected'; + } else { + $select = ''; + } + echo '<option value="'.$data['id'].'"'.$select.'>'.$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; + + buildAlbumSelectSubEntry($data['id'],$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES)); + } +} + + /** * returns the Operating System used * used to enable/disable OS related features Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -30,10 +30,11 @@ public $error_msg; public $output_file; -private $photo_id, $cached_id; -private $img_type; -private $mode; -private $image_tool; +public $photo_id, $cached_id; +public $isCached; +public $img_type; +public $mode; +public $image_tool; private $src_file; private $org_width, $org_height, $img_width, $img_height; Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -851,10 +851,16 @@ */ for($i = $min_year; $i <= $max_year; $i++) { - $data = $GLOBALS['linpha']->db->GetRow("SELECT count(datetimeoriginal) FROM ".PREFIX."meta_exif WHERE datetimeoriginal LIKE '".$i."%'"); - if($data[0]>0) + /** + * exclude all wrong/empty/... dates + */ + if($i > 1900) { - $GLOBALS['linpha']->template->output['browse_by_date'] .= '<a href="'.LINPHA_DIR.'/?cat=browse&year='.$i.'">'.$i.'</a> ('.$data[0].'), '; + $data = $GLOBALS['linpha']->db->GetRow("SELECT count(datetimeoriginal) FROM ".PREFIX."meta_exif WHERE datetimeoriginal LIKE '".$i."%'"); + if($data[0]>0) + { + $GLOBALS['linpha']->template->output['browse_by_date'] .= '<a href="'.LINPHA_DIR.'/?cat=browse&year='.$i.'">'.$i.'</a> ('.$data[0].'), '; + } } } } @@ -1094,7 +1100,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum ". "FROM ".PREFIX."meta_exif WHERE md5sum = '".$this->md5sum."'"); - if( $query->EOF) // not a sigle value returned + if( $query->EOF) // not a single value returned { include_once(LINPHA_DIR.'/lib/classes/phpmeta/JPEG.php'); // used for jpeg comment include_once(LINPHA_DIR.'/lib/classes/phpmeta/EXIF.php'); @@ -1111,7 +1117,7 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT md5sum ". "FROM ".PREFIX."meta_iptc WHERE md5sum = '".$this->md5sum."'"); - if( $query->EOF) // not a sigle value returned + if( $query->EOF) // not a single value returned { include_once(LINPHA_DIR.'/lib/classes/phpmeta/Photoshop_IRB.php'); include_once(LINPHA_DIR.'/lib/classes/phpmeta/JPEG.php'); Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -31,12 +31,10 @@ * if recursive, all sub directories are checked too! * @param int $parent_id Parent id of directory in database * @param bool $recursive scan directory recursive if true + * @param bool $dryrun do actually nothing, just report */ -function updateDir($parent_id, $recursive) +function updateDir($parent_id, $recursive, $dryrun) { - /** - * try/catch include errors (PHP5 exceptions)! - */ try { if($parent_id == 0) @@ -90,7 +88,15 @@ */ foreach($array_delete AS $key=>$value) { - LinImport::deleteEntry( $key, $dirname.'/'.$value); + if($dryrun) + { + linSysLog("Delete Entry: ".$dirname.'/'.$value."<br />"); + $deleted_keys[] = $key; + } + else + { + LinImport::deleteEntry( $key, $dirname.'/'.$value); + } } /** @@ -98,13 +104,22 @@ */ foreach($array_new AS $value) { - LinImport::addNewEntry( $parent_id , $dirname , $value, $recursive ); + if($dryrun) + { + linSysLog("New Entry: ".$dirname.'/'.$value."<br />"); + } + else + { + LinImport::addNewEntry( $parent_id , $dirname , $value, $recursive ); + } + } /** - * parse updated entries, not by default! (performance issues) + * "detect file changes", parse updated entries + * not by default! (performance issues) */ - if(isset($force_update) OR isset($_GET['force_update'])) + if( isset($_GET['force_update']) ) { foreach($array_update AS $key=>$value) { @@ -122,7 +137,14 @@ "AND parent_id = '".$parent_id."'"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { - LinImport::updateDir($data['0'], $recursive); + /** + * on dryrun, the delete process isn't done completley + * so it would appear here again, prevent this! + */ + if( !isset($deleted_keys) OR !in_array($data['0'],$deleted_keys) ) + { + LinImport::updateDir($data['0'], $recursive, $dryrun); + } } } } Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -306,10 +306,13 @@ /** * set isAdmin */ - $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."groups WHERE group_name = 'admin'"); - if(in_array($data['id'],$_SESSION['user_groups'])) + if(isset($_SESSION['user_groups']) && is_array($_SESSION['user_groups'])) { - $this->isAdmin = true; + $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."groups WHERE group_name = 'admin'"); + if(in_array($data['id'],$_SESSION['user_groups'])) + { + $this->isAdmin = true; + } } } } @@ -587,6 +590,9 @@ return $array_names; } +/** + * extends getFullFilenameFromId with album path and implode for direct use in file operations + */ function getFullImagePath( $photo_id ) { $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_id ); Modified: trunk/linpha2/lib/modules/module.albums.php =================================================================== --- trunk/linpha2/lib/modules/module.albums.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/modules/module.albums.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -62,7 +62,7 @@ */ if( $linpha->sql->config->value['sys_import_autoimport'] && $linpha->imgview->img_type == 0) { - LinImport::updateDir( $linpha->imgview->id_current, $recursive = false ); + LinImport::updateDir( $linpha->imgview->id_current, $recursive = false, $dryrun = false ); } /** Modified: trunk/linpha2/lib/modules/module.browse.php =================================================================== --- trunk/linpha2/lib/modules/module.browse.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/modules/module.browse.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -88,19 +88,25 @@ */ for($i = $min_year; $i <= $max_year; $i++) { - $data = $GLOBALS['linpha']->db->GetRow("SELECT count(datetimeoriginal) FROM ".PREFIX."meta_exif WHERE datetimeoriginal LIKE '".$i."%'"); - if($data[0]>0) + /** + * exclude all wrong/empty/... dates + */ + if($i > 1900) { - if(isset($_GET['year']) && $i == $_GET['year']) + $data = $GLOBALS['linpha']->db->GetRow("SELECT count(datetimeoriginal) FROM ".PREFIX."meta_exif WHERE datetimeoriginal LIKE '".$i."%'"); + if($data[0]>0) { - $str_datelinks .= $i.' ('.$data[0].'), '; + if(isset($_GET['year']) && $i == $_GET['year']) + { + $str_datelinks .= $i.' ('.$data[0].'), '; + } + else + { + $str_datelinks .= '<a href="'.$url_base.'&year='.$i.'">'.$i.'</a> ('.$data[0].'), '; + } + + $sum += $data[0]; } - else - { - $str_datelinks .= '<a href="'.$url_base.'&year='.$i.'">'.$i.'</a> ('.$data[0].'), '; - } - - $sum += $data[0]; } } Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -467,46 +467,4 @@ include_once(LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/global.html.php'); } - -function build_album_select($with_all_albs_entry) -{ - ?> - <select name="album_select[]" size="10" multiple="multiple" style="overflow: scroll; width: 200px;"> - <?php - if($with_all_albs_entry) - { - if(!isset($_REQUEST['album_select']) OR $_REQUEST['album_select']=='all') { - $select = ' selected'; - $_REQUEST['album_select'] = Array('all'=>'all'); - } else { - $select = ''; - } - echo '<option value="all"'.$select.'>'.i18n("All Albums").'</option>'."\n"; - } - - build_album_select_sub_entry(0,''); - ?> - </select><br /> - <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font> - <?php -} - -function build_album_select_sub_entry($id,$text) -{ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); - while($data = $query->FetchRow()) - { - if(!isset($_REQUEST['album_select'])) { - $_REQUEST['album_select'] = array(); - } - if(in_array($data['id'],$_REQUEST['album_select'])) { - $select = ' selected'; - } else { - $select = ''; - } - echo '<option value="'.$data['id'].'"'.$select.'>'.$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES).'</option>'."\n"; - - build_album_select_sub_entry($data['id'],$text.'/'.htmlspecialchars($data['name'],ENT_QUOTES)); - } -} ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/search.html.php =================================================================== --- trunk/linpha2/templates/default/search.html.php 2006-04-18 11:18:37 UTC (rev 4545) +++ trunk/linpha2/templates/default/search.html.php 2006-04-24 20:08:47 UTC (rev 4546) @@ -116,7 +116,10 @@ <div class="divcolumn"> <!-- select album //--> <b><?php echo i18n("Search In Album"); ?><b><br /> - <?php build_album_select($with_all_albs_entry=true); ?> + <select name="album_select[]" size="10" multiple="multiple" style="width: 200px;"> + <?php buildAlbumSelect($with_all_albs_entry=true); ?> + </select><br /> + <font size="-2">(<?php echo i18n("Multiple Select Use 'Ctrl'"); ?>)</font> <br /><br /> <!-- date --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-24 21:02:30
|
Revision: 4547 Author: fangehrn Date: 2006-04-24 14:02:12 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4547&view=rev Log Message: ----------- * created a filemanager layout Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/lib/modules/module.browse.php trunk/linpha2/lib/modules/module.search.php Added Paths: ----------- trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/ChangeLog 2006-04-24 21:02:12 UTC (rev 4547) @@ -1,5 +1,6 @@ 2006-04-24 flo * created import/index/create thumbnail/re-create-scripts in admin-import section + * created a filemanager layout 2006-04-18 flo * calendar: apply previous update from linpha1 Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/index.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -35,6 +35,9 @@ case 'browse': include_once(LINPHA_DIR.'/lib/modules/module.browse.php'); break; +case 'filemanager': + include_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -562,7 +562,7 @@ /** * really need this hard limit - * because if we try to infos from an id which doesn't exist anymore + * because if we try to get infos from an id which doesn't exist anymore * we would run in an endless loop */ @@ -595,8 +595,8 @@ */ function getFullImagePath( $photo_id ) { - $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_id ); - $album_dir = $GLOBALS['linpha']->sql->getPath('album'); + $array_path = LinSql::getFullFilenameFromId( $photo_id ); + $album_dir = LinSql::getPath('album'); return $album_dir .'/'. implode('/',$array_path); } Modified: trunk/linpha2/lib/modules/module.albums.php =================================================================== --- trunk/linpha2/lib/modules/module.albums.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.albums.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Albums view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Basket view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Modified: trunk/linpha2/lib/modules/module.browse.php =================================================================== --- trunk/linpha2/lib/modules/module.browse.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.browse.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Navigation view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Added: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php (rev 0) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -0,0 +1,288 @@ +<?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. + */ + +/** + * Albums view related methods and functions + * @package Modules + */ +if(!defined('LINPHA_DIR')) { exit(1); } + +if(!isset($_GET['id'])) +{ + $parent_id = 0; +} +else +{ + $parent_id = $_GET['id']; +} + + +$i = 0; +$sum['size'] = 0; +$sum['files'] = 0; + +$use_posix = checkPosix(); + +if($use_posix) { + $uid = @posix_getuid(); // get user id of current process +} else { + $uid = 0; +} + + +?> + +<table border="1"> + + +<?php +if($parent_id != 0) +{ + $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); + + echo i18n("Current Folder:").' '.$data['name'].'<br />'; + ?> + <tr> + <td> </td> + <td><a href="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$data['parent_id']; ?>">..</a></td> + <td> </td> + <td> </td> + <td> </td> + </tr> + <?php +} + +$query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); +while($data = $query->FetchRow()) +{ + /** + * set file informations + */ + $full_filename = LinSql::getFullImagePath( $data['id'] ); + $filestat = stat($full_filename); + + /** + * size and nr files + */ + if( $data['img_type'] != 0 && $data['img_type'] != 9999999 ) + { + $sum['size'] += $filestat['size']; + $sum['files']++; + } + + /** + * owner and group name + */ + if($use_posix) { + $owner_info = @posix_getpwuid($filestat['uid']); // use @ because check_posix() can return true even if it fails... + $group_info = @posix_getgrgid($filestat['gid']); + } else { + $owner_info['name'] = ''; + $group_info['name'] = ''; + } + + /** + * file permissions + */ + if(getOS() == 'win') + { + $file_permissions = + '[' . + (is_readable($full_filename) ? '<font color="green">r</font>' : ' ') . + (is_writable($full_filename) ? '<font color="red">w</font>' : ' ') . + (function_exists('is_executable') ? + (is_executable($full_filename) ? '<font color="blue">x</font>' : ' ') + : + ' ' + ) . + ']'; + } else { + $perm = '['.getReadableFileperms($full_filename).']'; + + $perm = str_replace('r','<font color="green">r</font>',$perm); + $perm = str_replace('w','<font color="red">w</font>',$perm); + $perm = str_replace('x','<font color="blue">x</font>',$perm); + + if($uid == $filestat['uid']) + { + $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=change_perm_form">'. $perm . '</a>'; + } + else + { + $file_permissions = $perm; + } + } + + + + + + + + + ?> + <tr> + <td><input type="checkbox" name="checkedfiles[<?php echo $data['id']; ?>]" value="value" /></td> + <td width="500"> + <?php + if($data['img_type']==0) + { + echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.$data['name'].'</a>'; + } + else + { + echo $data['name']; + } + ?> + </td> + <td width="100" align="right"><?php echo ($data['img_type']==0 OR $data['img_type']==9999999) ? ' ' : niceFilesize($filestat['size'],1); ?></td> + <td width="150" align="center"><?php echo strftime("%x %X",$filestat['mtime']); ?></td> + <td width="100" align="center" title="<?php echo $owner_info['name'].' '.$group_info['name']; ?>"><?php echo $file_permissions; ?></td> + </tr> + <?php +} +?> +</table> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Rename"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Move"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Copy"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Delete"); ?></label> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>"/> +</form> + + +<br /><br /> +<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<input type="text" name="createfolder" value="" /> +<input type="hidden" name="cmd" value="createfolder" /> +<input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>"/> +</form> + +<br /><br /> +<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<input type="file" name="uploadfile0" value="" /><br /> +<input type="file" name="uploadfile1" value="" /><br /> +<input type="file" name="uploadfile2" value="" /><br /> +<input type="file" name="uploadfile3" value="" /><br /> +<input type="file" name="uploadfile4" value="" /><br /> + +<input type="hidden" name="cmd" value="upload" /> +<input type="submit" name="submit" value="<?php echo i18n("Upload Files"); ?>"/> +</form> + +<?php + +/** +* found on http://ch.php.net/manual/en/function.fileperms.php +*/ +function getReadableFileperms($file) +{ + $perms = fileperms($file); + + $info = ''; + + if (($perms & 0xC000) == 0xC000) { + // Socket + $info .= 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info .= 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info .= '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info .= 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info .= 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info .= 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info .= 'p'; + } else { + // Unknown + $info .= 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + + + return $info; +} + +/** +* this function checks if the posix functions are available +* +* @author flo +* @return bool true if posix enabled, false if not +* @package requirements +*/ +function checkPosix() +{ + $array_needed_functions = Array( + 'posix_getuid', + 'posix_getpwuid', + 'posix_getgrgid' + ); + + foreach($array_needed_functions AS $value) + { + if( !function_exists($value) ) + { + return false; + } + } + + /** + * can return true even if it fails...!!! seen on sf.net + */ + if($uid = @posix_getuid()) + { + if(@posix_getpwuid($uid)) + { + return true; + } + } + + return false; +} +?> \ No newline at end of file Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -1,32 +1,30 @@ <?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. -*/ + * 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. + */ /** * Albums view related methods and functions - * @package Template + * @package Modules */ +if(!defined('LINPHA_DIR')) { exit(1); } - - - /** * call from exif href in img_view */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-25 22:05:55
|
Revision: 4548 Author: fangehrn Date: 2006-04-25 15:05:37 -0700 (Tue, 25 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4548&view=rev Log Message: ----------- Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/permissions.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.filemanager.php Added Paths: ----------- trunk/linpha2/admin/permissions_readwrite.php Removed Paths: ------------- trunk/linpha2/admin/permissions_read.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/ChangeLog 2006-04-25 22:05:37 UTC (rev 4548) @@ -1,3 +1,6 @@ +2006-04-25 flo + * filemanager: implementing read/write + 2006-04-24 flo * created import/index/create thumbnail/re-create-scripts in admin-import section * created a filemanager layout Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/admin/permissions.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -24,18 +24,20 @@ case 'users': include_once('./permissions_users.php'); break; + case 'groups': include_once('./permissions_groups.php'); break; + case 'usergroup': include_once('./permissions_usergroup.php'); break; + case 'view': - include_once('./permissions_read.php'); - break; case 'write': - include_once('./permissions_write.php'); + include_once('./permissions_readwrite.php'); break; + case 'basket': case 'metadata': case 'others': Deleted: trunk/linpha2/admin/permissions_read.php =================================================================== --- trunk/linpha2/admin/permissions_read.php 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/admin/permissions_read.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -1,312 +0,0 @@ -<?php -if(!defined('LINPHA_DIR')) { exit(1); } - -include_once(LINPHA_DIR.'/lib/adodb/tohtml.inc.php'); - - -/** - * save POST data - */ -if(isset($_POST['cmd']) && $_POST['cmd'] == 'save_permissions') -{ - /** - * insert or update - */ - $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . - "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); - - /** - * if inherit is selected, delete if an entry exists - * and only if the photo_id != 0, because we can't delete - * the top permission entry!! - */ - if(isset($_POST['inherit'])) - { - if( ! $query->EOF && $_POST['photo_id'] != 0) - { - $linpha->db->Execute("DELETE FROM ".PREFIX."permissions " . - "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); - } - } - else - { - if(isset($_POST['group'])) - { - if(in_array('public',$_POST['group'])) - { - $str_groups = 'public'; - } - else - { - $str_groups = implode(';',$_POST['group']); - } - } - else - { - /** - * no group selected - * -> only admin has permissions - */ - $str_groups = ''; - } - - if( ! $query->EOF ) - { - $linpha->db->Execute("UPDATE ".PREFIX."permissions SET permission = ';".LinSql::linAddslashes($str_groups).";' " . - "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."'"); - } - else - { - $linpha->db->Execute("INSERT into ".PREFIX."permissions (photos_id, perm_type, permission) VALUES (" . - "'".LinSql::linAddslashes($_POST['photo_id'])."', 'read'," . - "';".LinSql::linAddslashes($str_groups).";' )"); - } - } -} - -/** - * set parameters - */ - if(isset($_GET['parent_id']) && $_GET['parent_id'] != 0) - { - $parent_id = $_GET['parent_id']; - $view_mode = 'files'; - - $array = $GLOBALS['linpha']->sql->getFullFilenameFromId( LinSql::linAddslashes($parent_id) ); - - $parent_name = '<b>'.implode('/',$array).'</b>'; - $recursive = false; - } - else - { - $parent_id = 0; - $view_mode = 'folders'; - $parent_name = 'Top directory (default permission)'; - $recursive = true; - } - -/** - * get groups - */ - $array_groups = Array(); - $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups WHERE group_name <> 'admin'"); - while($data = $query->FetchRow(ADODB_FETCH_NUM)) - { - $array_groups[$data[0]] = $data[1]; - } - -/** - * show edit/add permission dialog - */ -if(isset($_GET['cmd']) AND isset($_GET['id'])) -{ - $checked = ''; - $array_perms = array(); - - /** - * check wether add or edit (insert or update) - */ - $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . - "WHERE photos_id = '".LinSql::linAddslashes($_GET['id'])."'"); - - if( ! $query->EOF ) - { - list($stage, $perm) = $GLOBALS['linpha']->sql->getPerm( $_GET['id'] ); - $array_perms = explode(';',$perm); - - if(in_array('public',$array_perms)) - { - $checked = ' checked="checked"'; - } - } - - $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_GET['id'])."'"); - $data = $query->FetchRow(ADODB_FETCH_NUM); - ?> - <form name="permission" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$parent_id; ?>"> - <h3>Change/Add permissions of folder/file "<?php echo $data[0]; ?>"</h3> - - <?php - /** - * top folder can't be inherit - * -> make sure we cannot delete this entry! - */ - if($_GET['id'] != 0) - { - ?> - <input type="checkbox" name="inherit" value="1" />inherit from parent<br /> - <?php - } - ?> - - <input type="checkbox" name="admin" value="1" checked="checked" disabled="disabled"/>admin<br /> - <input type="checkbox" name="group[]" value="public"<?php echo $checked; ?> />public<br /> - - <?php - foreach($array_groups AS $key=>$value) - { - if(in_array($key,$array_perms)) - { - $checked = ' checked="checked"'; - } - else - { - $checked = ''; - } - - echo '<input type="checkbox" name="group[]" value="'.$key.'"'.$checked.' />'.$value.'<br />'; - } - ?> - <input type="hidden" name="photo_id" value="<?php echo $_GET['id']; ?>" /> - <input type="hidden" name="parent_id" value="<?php echo $parent_id; ?>" /> - <input type="hidden" name="cmd" value="save_permissions" /> - <input type="submit" name="submit" value="save" /> - <a href="<?php echo LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$parent_id; ?>">cancel</a> - </form> - <br /><br /> - <?php -} - -/** - * print permissions - */ - list($stage, $perm) = $GLOBALS['linpha']->sql->getPerm( $parent_id ); - ?> - Current directoy: <?php echo $parent_name; ?> - <?php - if(isset($_GET['parent_id']) && $_GET['parent_id'] != 0) - { - echo ' (<a href="'.LINPHA_DIR.'/admin/?cat=permissions_view&parent_id=0">Show all folders</a>)'; - } - ?> - <br /> - Permission set: <b><?php echo get_readable_perms($perm); ?></b> - (<a href="<?php echo LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$parent_id.'&cmd=edit&id='.$parent_id; ?>">change</a>) - <br /><br /> - <table border='1'> - <tr> - <td width='200'>Name</td> - <td width='200'>Permission set</td> - <td width='200'>Permission inherited</td> - <td width='200'>Modifications</td> - </tr> - <?php - print_dir_perms_entry( $parent_id , $recursive , $stage=0); - ?> - </table> - </form> - - <?php -/** - * print the permission entries - */ -function print_dir_perms_entry( $parent_id , $recursive , $stage) -{ - $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".$parent_id."'"); - while( $data = $query->FetchRow() ) - { - list($i, $perm) = $GLOBALS['linpha']->sql->getPerm( $data['id'] ); - - /** - * exclude files - */ - if($data['img_type'] == 0 // show folders - || $GLOBALS['view_mode']=='files' // show files if we not on top - || ( $data['img_type'] != 0 && $i == 0 ) ) // show files which have permissions explicitly set (not inherited) - { - echo '<tr><td>'; - echo str_repeat(' >',$stage).' '; - if($data['img_type']==0) - { - echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$data['id'].'">'.$data['name'].'</a>'; - } - else - { - echo $data['name']; - } - echo '</td><td>'; - - if($i == 0) - { - echo get_readable_perms($perm); - } - else - { - echo ' '; - } - - - echo '</td><td>'; - - if($i != 0) - { - echo get_readable_perms($perm); - } - else - { - echo ' '; - } - - echo '</td><td>'; - - if($i != 0) - { - echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$GLOBALS['parent_id'].'&cmd=edit&id='.$data['id'].'">add</a>'; - } - else - { - echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_view&parent_id='.$GLOBALS['parent_id'].'&cmd=edit&id='.$data['id'].'">change</a>'; - } - echo '</td></tr>'; - - if($recursive && $data['img_type'] == "0") - { - print_dir_perms_entry( $data['id'] , true , $stage+1 ); - } - } - } -} // end function print_dir_perms_entry - - -/** - * functions - */ - - -/** - * convert - * ';1;2;' -> 'friends, another group, ' - * and ';public;' -> 'public' - * and '' -> 'admin' - * and ';' -> 'admin' - * and ';;' -> 'admin' - */ -function get_readable_perms( $perm ) -{ - global $array_groups; - - $array = explodeAndSlice(';',$perm); - - $str = ''; - foreach($array AS $value) - { - if($value == 'public') - { - $str .= 'public'; - } - elseif(isset($array_groups[$value])) - { - $str .= $array_groups[$value].', '; - } - } - - if(empty($str)) - { - $str = 'admin'; - } - return $str; -} - - -?> \ No newline at end of file Copied: trunk/linpha2/admin/permissions_readwrite.php (from rev 4545, trunk/linpha2/admin/permissions_read.php) =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php (rev 0) +++ trunk/linpha2/admin/permissions_readwrite.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -0,0 +1,348 @@ +<?php +if(!defined('LINPHA_DIR')) { exit(1); } + +if($cat2 == 'view') +{ + $sql_perm_type = 'read'; +} +elseif($cat2 == 'write') +{ + $sql_perm_type = 'write'; + + ?> + <br /><hr /><br /> + <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2; ?>"> + <?php + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') + { + saveConfig( + Array( + 'plugins_filemanager_enable' + ) + ); + } + + + printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); + + ?> + <input type="hidden" name="cmd" value="saveconfig" /> + <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> + </form> + <br /><hr /><br /> + <?php + + if(! $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable']) + { + exit(); + } +} + +/** + * save POST data + */ +if(isset($_POST['cmd']) && $_POST['cmd'] == 'save_permissions') +{ + /** + * insert or update + */ + $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."' AND perm_type = '".$sql_perm_type."'"); + + /** + * if inherit is selected, delete if an entry exists + * and only if the photo_id != 0, because we can't delete + * the top permission entry!! + */ + if(isset($_POST['inherit'])) + { + if( ! $query->EOF && $_POST['photo_id'] != 0) + { + $linpha->db->Execute("DELETE FROM ".PREFIX."permissions " . + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."' " . + "AND perm_type = '".$sql_perm_type."'"); + } + } + else + { + if(isset($_POST['group'])) + { + if(in_array('public',$_POST['group'])) + { + $str_groups = 'public'; + } + else + { + $str_groups = implode(';',$_POST['group']); + } + } + else + { + /** + * no group selected + * -> only admin has permissions + */ + $str_groups = ''; + } + + if( ! $query->EOF ) + { + $linpha->db->Execute("UPDATE ".PREFIX."permissions SET permission = ';".LinSql::linAddslashes($str_groups).";' " . + "WHERE photos_id = '".LinSql::linAddslashes($_POST['photo_id'])."' AND perm_type = '".$sql_perm_type."'"); + } + else + { + $linpha->db->Execute("INSERT into ".PREFIX."permissions (photos_id, perm_type, permission) VALUES (" . + "'".LinSql::linAddslashes($_POST['photo_id'])."', '".$sql_perm_type."'," . + "';".LinSql::linAddslashes($str_groups).";' )"); + } + } +} + +/** + * set parameters + */ + if(isset($_GET['parent_id']) && $_GET['parent_id'] != 0) + { + $parent_id = $_GET['parent_id']; + $view_mode = 'files'; + + $array = $GLOBALS['linpha']->sql->getFullFilenameFromId( LinSql::linAddslashes($parent_id) ); + + $parent_name = '<b>'.implode('/',$array).'</b>'; + $recursive = false; + } + else + { + $parent_id = 0; + $view_mode = 'folders'; + $parent_name = 'Top directory (default permission)'; + $recursive = true; + } + +/** + * get groups + */ + $array_groups = Array(); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".PREFIX."groups WHERE group_name <> 'admin'"); + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $array_groups[$data[0]] = $data[1]; + } + +/** + * show edit/add permission dialog + */ +if(isset($_GET['cmd']) AND isset($_GET['id'])) +{ + $checked = ''; + $array_perms = array(); + + /** + * check wether add or edit (insert or update) + */ + $query = $linpha->db->Execute("SELECT id FROM ".PREFIX."permissions " . + "WHERE photos_id = '".LinSql::linAddslashes($_GET['id'])."' AND perm_type = '".$sql_perm_type."'"); + + if( ! $query->EOF ) + { + list($stage, $perm) = $GLOBALS['linpha']->sql->getPerm( $_GET['id'], $sql_perm_type ); + $array_perms = explode(';',$perm); + + if(in_array('public',$array_perms)) + { + $checked = ' checked="checked"'; + } + } + + $query = $GLOBALS['linpha']->db->Execute("SELECT name FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($_GET['id'])."'"); + $data = $query->FetchRow(ADODB_FETCH_NUM); + ?> + <form name="permission" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'&parent_id='.$parent_id; ?>"> + <h3><?php echo i18n("Change/Add permissions of folder/file"); ?> "<?php echo $data[0]; ?>"</h3> + + <?php + /** + * top folder can't be inherit + * -> make sure we cannot delete this entry! + */ + if($_GET['id'] != 0) + { + ?> + <input type="checkbox" id="group_inherit" name="inherit" value="1" /><label for="group_inherit"> <?php echo i18n("Inherit From Parent"); ?></label><br /> + <?php + } + ?> + + <input type="checkbox" id="group_admin" name="admin" value="1" checked="checked" disabled="disabled"/><label for="group_admin"> admin</label><br /> + <input type="checkbox" id="group_public" name="group[]" value="public"<?php echo $checked; ?> /><label for="group_public"> public</label><br /> + + <?php + foreach($array_groups AS $key=>$value) + { + if(in_array($key,$array_perms)) + { + $checked = ' checked="checked"'; + } + else + { + $checked = ''; + } + + echo '<input type="checkbox" id="group_'.$key.'" name="group[]" value="'.$key.'"'.$checked.' /><label for="group_'.$key.'"> '.$value.'</a><br />'; + } + ?> + <input type="hidden" name="photo_id" value="<?php echo $_GET['id']; ?>" /> + <input type="hidden" name="parent_id" value="<?php echo $parent_id; ?>" /> + <input type="hidden" name="cmd" value="save_permissions" /> + <input type="submit" name="submit" value="save" /> + <a href="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'&parent_id='.$parent_id; ?>">cancel</a> + </form> + <br /><br /> + <?php +} + + +/** + * print permissions + */ + list($stage, $perm) = $GLOBALS['linpha']->sql->getPerm( $parent_id, $sql_perm_type ); + ?> + Current directoy: <?php echo $parent_name; ?> + <?php + if(isset($_GET['parent_id']) && $_GET['parent_id'] != 0) + { + echo ' (<a href="'.LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'&parent_id=0">Show all folders</a>)'; + } + ?> + <br /> + <?php echo i18n("Permission Set"); ?>: <b><?php echo getReadablePerms($perm); ?></b> + (<a href="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'&parent_id='.$parent_id.'&cmd=edit&id='.$parent_id; ?>">change</a>) + <br /><br /> + <table border='1'> + <tr> + <td width='200'><?php echo i18n("Name"); ?></td> + <td width='200'><?php echo i18n("Permission Set"); ?></td> + <td width='200'><?php echo i18n("Permission Inherited"); ?></td> + <td width='200'><?php echo i18n("Modifications"); ?></td> + </tr> + <?php + printDirPermsEntry( $parent_id , $recursive , $stage=0); + ?> + </table> + </form> + + <?php +/** + * print the permission entries + */ +function printDirPermsEntry( $parent_id , $recursive , $stage) +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".$parent_id."'"); + while( $data = $query->FetchRow() ) + { + list($i, $perm) = $GLOBALS['linpha']->sql->getPerm( $data['id'], $GLOBALS['sql_perm_type'] ); + + /** + * exclude files + */ + if($data['img_type'] == 0 // show folders + || ($GLOBALS['view_mode']=='files' && $GLOBALS['cat2']=='read') // show files if we not on top (and it doesnt make sense to give write permissions to the file itself) + || ( $data['img_type'] != 0 && $i == 0 ) ) // show files which have permissions explicitly set (not inherited) + { + echo '<tr><td>'; + echo str_repeat(' >',$stage).' '; + if($data['img_type']==0) + { + echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_'.$GLOBALS['cat2'].'&parent_id='.$data['id'].'">'.$data['name'].'</a>'; + } + else + { + echo $data['name']; + } + echo '</td><td>'; + + if($i == 0) + { + echo getReadablePerms($perm); + } + else + { + echo ' '; + } + + + echo '</td><td>'; + + if($i != 0) + { + echo getReadablePerms($perm); + } + else + { + echo ' '; + } + + echo '</td><td>'; + + if($i != 0) + { + echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_'.$GLOBALS['cat2'].'&parent_id='.$GLOBALS['parent_id'].'&cmd=edit&id='.$data['id'].'">add</a>'; + } + else + { + echo '<a href="'.LINPHA_DIR.'/admin/?cat=permissions_'.$GLOBALS['cat2'].'&parent_id='.$GLOBALS['parent_id'].'&cmd=edit&id='.$data['id'].'">change</a>'; + } + echo '</td></tr>'; + + if($recursive && $data['img_type'] == "0") + { + printDirPermsEntry( $data['id'] , true , $stage+1 ); + } + } + } +} // end function printDirPermsEntry + + +/** + * functions + */ + + +/** + * convert + * ';1;2;' -> 'friends, another group, ' + * and ';public;' -> 'public' + * and '' -> 'admin' + * and ';' -> 'admin' + * and ';;' -> 'admin' + */ +function getReadablePerms( $perm ) +{ + global $array_groups; + + $array = explodeAndSlice(';',$perm); + + $str = ''; + foreach($array AS $value) + { + if($value == 'public') + { + $str .= 'public'; + } + elseif(isset($array_groups[$value])) + { + $str .= $array_groups[$value].', '; + } + } + + if(empty($str)) + { + $str = 'admin'; + } + return $str; +} + + +?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -62,7 +62,9 @@ 'sys_style_image_size' => '700', 'sys_style_image_nrprevnextthumbs' => '3', - 'sys_user_autologin' => '1' + 'sys_user_autologin' => '1', + + 'plugins_filemanager_enable' => '0' ); /** @@ -84,7 +86,10 @@ */ $sql_queries[] = "INSERT INTO ".PREFIX."permissions (photos_id, perm_type, permission) " . "VALUES (0, 'read', ';public;')"; +$sql_queries[] = "INSERT INTO ".PREFIX."permissions (photos_id, perm_type, permission) " . + "VALUES (0, 'write', ';;')"; + $sql_queries[] = "INSERT INTO ".PREFIX."permissions (perm_type, permission) " . "VALUES ('basket_print', '')"; $sql_queries[] = "INSERT INTO ".PREFIX."permissions (perm_type, permission) " . Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -378,25 +378,26 @@ * @param photo id * @return array array(stage, permission) stage=0 if permission is not inherited */ -function getPerm( $photos_id ) +function getPerm( $photos_id, $perm_type ) { /** * special behaviour for top permission * the top permission is only for inheritation * for example: - * top perm = ;admin; + * top perm = ;admin; * perm folder1 = ;public; * perm folder2 = ;admin; - * users must be able to see folder1 + * users must be able to see folder1 */ - if($photos_id == 0) + if($photos_id == 0 && $perm_type == 'read') { return array(0, ';public;'); } for($i = 0 ; true ; $i++) { - $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".PREFIX."permissions WHERE perm_type = 'read' " . + $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".PREFIX."permissions " . + "WHERE perm_type = '".LinSql::linAddslashes($perm_type)."' " . "AND photos_id = '".linSql::linAddslashes($photos_id)."'"); if( isset( $data[0] ) && !empty( $data[0] ) ) @@ -425,7 +426,7 @@ /** * returns true if we're allowed to see this photo */ -function photoIsAllowed( $photo_id ) +function photoIsAllowed( $photo_id, $sql_perm_type = 'read' ) { /** * admin sees always all photos @@ -435,7 +436,7 @@ return true; } - list($stage,$perm) = LinSql::getPerm( $photo_id ); + list($stage,$perm) = LinSql::getPerm( $photo_id, $sql_perm_type ); $array_photo_perm = explodeAndSlice(';',$perm); foreach($array_photo_perm AS $value) Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-04-24 21:02:12 UTC (rev 4547) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-25 22:05:37 UTC (rev 4548) @@ -19,39 +19,155 @@ */ /** - * Albums view related methods and functions + * Filemanager * @package Modules */ + +/** + * Short Permission Description + * If a user has write permission to folder A, it means that + * he can upload images to this folder, rename content, delete content + * But he cannot rename or delete the folder itself + * + * + * it doesnt make sense to give write permissions to the file itself + */ + if(!defined('LINPHA_DIR')) { exit(1); } -if(!isset($_GET['id'])) +/** + * init stuff + */ + if(!isset($_GET['id'])) + { + $parent_id = 0; + } + else + { + $parent_id = $_GET['id']; + } + + + $i = 0; + $sum['size'] = 0; + $sum['files'] = 0; + + $use_posix = checkPosix(); + + if($use_posix) { + $uid = @posix_getuid(); // get user id of current process + } else { + $uid = 0; + } + +/** + * check global permission + */ + if(! $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable'] + && !$GLOBALS['linpha']->sql->isAdmin()) + { + echo i18n("No Access!"); + exit(); + } + + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $parent_id, 'read' ) ) + { + echo i18n("No Access!"); + exit(); + } + + /** + * use this for child object + */ + if( $GLOBALS['linpha']->sql->photoIsAllowed( $parent_id, 'write' ) ) + { + $isWriteAble = true; + } + else + { + $isWriteAble = false; + } + +/** + * parsing POST data + */ +if(isset($_POST['cmd'])) { - $parent_id = 0; -} -else -{ - $parent_id = $_GET['id']; -} + switch($_POST['cmd']) + { + case 'file_action': + ?> + <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> + <?php + switch($_POST['file_action']) + { + case 'rename': + ?> + <input type="text" name="do_rename" value="" /> + <?php + break; + case 'move': + case 'copy': + ?> + <select> + <option value=""></option> + <option value=""></option> + <option value=""></option> + </selet> + <?php + break; + case 'delete': + echo i18n("Really Sure?"); + break; + } + ?> + <input type="hidden" name="cmd" value="do_file_action" /> + <input type="hidden" name="file_action" value="<?php echo $_POST['file_action']; ?>" /> + <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> + </form> + <?php + break; + case 'do_file_action': + switch($_POST['file_action']) + { + case 'rename': + break; -$i = 0; -$sum['size'] = 0; -$sum['files'] = 0; + case 'move': + break; -$use_posix = checkPosix(); + case 'copy': + break; -if($use_posix) { - $uid = @posix_getuid(); // get user id of current process -} else { - $uid = 0; -} + case 'delete': + break; + } + break; + case 'create_folder': + break; + case 'do_create_folder': + + break; + case 'upload': + + break; + } +} ?> +<form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <table border="1"> + <tr> + <td> </td> + <td width="500"> </td> + <td width="100"> </td> + <td width="150"> </td> + <td width="100"> </td> + </tr> - <?php if($parent_id != 0) { @@ -73,110 +189,116 @@ while($data = $query->FetchRow()) { /** - * set file informations + * check read permission */ - $full_filename = LinSql::getFullImagePath( $data['id'] ); - $filestat = stat($full_filename); - - /** - * size and nr files - */ - if( $data['img_type'] != 0 && $data['img_type'] != 9999999 ) - { - $sum['size'] += $filestat['size']; - $sum['files']++; - } - - /** - * owner and group name - */ - if($use_posix) { - $owner_info = @posix_getpwuid($filestat['uid']); // use @ because check_posix() can return true even if it fails... - $group_info = @posix_getgrgid($filestat['gid']); - } else { - $owner_info['name'] = ''; - $group_info['name'] = ''; - } - - /** - * file permissions - */ - if(getOS() == 'win') + if( $GLOBALS['linpha']->sql->photoIsAllowed( $data['id'], 'read' ) ) { - $file_permissions = - '[' . - (is_readable($full_filename) ? '<font color="green">r</font>' : ' ') . - (is_writable($full_filename) ? '<font color="red">w</font>' : ' ') . - (function_exists('is_executable') ? - (is_executable($full_filename) ? '<font color="blue">x</font>' : ' ') - : - ' ' - ) . - ']'; - } else { - $perm = '['.getReadableFileperms($full_filename).']'; - - $perm = str_replace('r','<font color="green">r</font>',$perm); - $perm = str_replace('w','<font color="red">w</font>',$perm); - $perm = str_replace('x','<font color="blue">x</font>',$perm); - - if($uid == $filestat['uid']) - { - $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=change_perm_form">'. $perm . '</a>'; + /** + * set file informations + */ + $full_filename = LinSql::getFullImagePath( $data['id'] ); + $filestat = stat($full_filename); + + /** + * size and nr files + */ + if( $data['img_type'] != 0 && $data['img_type'] != 9999999 ) + { + $sum['size'] += $filestat['size']; + $sum['files']++; + } + + /** + * owner and group name + */ + if($use_posix) { + $owner_info = @posix_getpwuid($filestat['uid']); // use @ because check_posix() can return true even if it fails... + $group_info = @posix_getgrgid($filestat['gid']); + } else { + $owner_info['name'] = ''; + $group_info['name'] = ''; } - else + + /** + * file permissions + */ + if(getOS() == 'win') { - $file_permissions = $perm; + $file_permissions = + '[' . + (is_readable($full_filename) ? '<font color="green">r</font>' : ' ') . + (is_writable($full_filename) ? '<font color="red">w</font>' : ' ') . + (function_exists('is_executable') ? + (is_executable($full_filename) ? '<font color="blue">x</font>' : ' ') + : + ' ' + ) . + ']'; + } else { + $perm = '['.getReadableFileperms($full_filename).']'; + + $perm = str_replace('r','<font color="green">r</font>',$perm); + $perm = str_replace('w','<font color="red">w</font>',$perm); + $perm = str_replace('x','<font color="blue">x</font>',$perm); + + if($uid == $filestat['uid']) + { + $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=change_perm_form">'. $perm . '</a>'; + } + else + { + $file_permissions = $perm; + } } + + ?> + <tr> + <td> + <?php if($isWriteAble) { ?> + <input type="checkbox" name="checkedfiles[<?php echo $data['id']; ?>]" value="value" /> + <?php } else { ?> + + <?php } ?> + </td> + <td> + <?php + if($data['img_type']==0) + { + echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.$data['name'].'</a>'; + } + else + { + echo $data['name']; + } + ?> + </td> + <td align="right"><?php echo ($data['img_type']==0 OR $data['img_type']==9999999) ? ' ' : niceFilesize($filestat['size'],1); ?></td> + <td align="center"><?php echo strftime("%x %X",$filestat['mtime']); ?></td> + <td align="center" title="<?php echo $owner_info['name'].' '.$group_info['name']; ?>"><?php echo $file_permissions; ?></td> + </tr> + <?php } - - - - - - - - - ?> - <tr> - <td><input type="checkbox" name="checkedfiles[<?php echo $data['id']; ?>]" value="value" /></td> - <td width="500"> - <?php - if($data['img_type']==0) - { - echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.$data['name'].'</a>'; - } - else - { - echo $data['name']; - } - ?> - </td> - <td width="100" align="right"><?php echo ($data['img_type']==0 OR $data['img_type']==9999999) ? ' ' : niceFilesize($filestat['size'],1); ?></td> - <td width="150" align="center"><?php echo strftime("%x %X",$filestat['mtime']); ?></td> - <td width="100" align="center" title="<?php echo $owner_info['name'].' '.$group_info['name']; ?>"><?php echo $file_permissions; ?></td> - </tr> - <?php } ?> </table> -<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Rename"); ?></label> -<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Move"); ?></label> -<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Copy"); ?></label> -<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Delete"); ?></label> -<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>"/> +<input type="radio" id="file_rename" name="file_action" value="rename" /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> +<input type="radio" id="file_move" name="file_action" value="move" /><label for="file_move"> <?php echo i18n("Move"); ?></label> +<input type="radio" id="file_copy" name="file_action" value="copy" /><label for="file_copy"> <?php echo i18n("Copy"); ?></label> +<input type="radio" id="file_delete" name="file_action" value="delete" /><label for="file_delete"> <?php echo i18n("Delete"); ?></label> +<input type="hidden" name="cmd" value="file_action" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> </form> <br /><br /> -<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <input type="text" name="createfolder" value="" /> -<input type="hidden" name="cmd" value="createfolder" /> -<input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>"/> +<input type="hidden" name="cmd" value="create_folder" /> +<input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>" /> </form> <br /><br /> -<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <input type="file" name="uploadfile0" value="" /><br /> <input type="file" name="uploadfile1" value="" /><br /> <input type="file" name="uploadfile2" value="" /><br /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-26 21:43:24
|
Revision: 4549 Author: fangehrn Date: 2006-04-26 14:43:06 -0700 (Wed, 26 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4549&view=rev Log Message: ----------- 2006-04-26 flo * filemanager: implementing rename, delete, create folder Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/import.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/ChangeLog 2006-04-26 21:43:06 UTC (rev 4549) @@ -1,3 +1,6 @@ +2006-04-26 flo + * filemanager: implementing rename, delete, create folder + 2006-04-25 flo * filemanager: implementing read/write Modified: trunk/linpha2/admin/import.php =================================================================== --- trunk/linpha2/admin/import.php 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/admin/import.php 2006-04-26 21:43:06 UTC (rev 4549) @@ -241,9 +241,9 @@ <?php echo i18n("Thumbnails").':'; ?> <br /> -<input type="radio" id="index_thumbnails_deletefirstreindex" name="index_thumbnails" value="recreate" /><label for="index_thumbnails_reindex"> <?php echo i18n("Re-create"); ?></label><br /> <input type="radio" id="index_thumbnails_no" name="index_thumbnails" value="no" /><label for="index_thumbnails_no"> <?php echo i18n("No Create"); ?></label><br /> <input type="radio" id="index_thumbnails_index" name="index_thumbnails" value="create" checked="checked" /><label for="index_thumbnails_index"> <?php echo i18n("Create"); ?></label><br /> +<input type="radio" id="index_thumbnails_reindex" name="index_thumbnails" value="recreate" /><label for="index_thumbnails_reindex"> <?php echo i18n("Re-create"); ?></label><br /> <br /> <?php Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-26 21:43:06 UTC (rev 4549) @@ -27,7 +27,86 @@ class LinFilesys { + /** +* create directory recursively - same as "mkdir -p" +*/ +function mkdir_p($target,$mode='0700') +{ + if(is_dir($target) || empty($target)) { // best case check first + return 1; + } + if(file_exists($target) && !is_dir($target)) { // target exists bug isn't a directory.. + return 0; + } + if( mkdir_p( substr( $target,0,strrpos( $target,'/') ) ) ) + { + return mkdir($target,intval($mode,8)); // crawl back up & create dir tree + } + return 0; +} + +/** +* copy recursive - same as "cp -R" +*/ +function copy_r($source,$dest) +{ + if( !is_dir($source) ) + { + if( is_file($source) ) + { + @copy($source,$dest); + return 1; + } + else + { + return 0; + } + } + if (!is_dir($dest)) { + mkdir_p($dest); + } + $h=@dir($source); + while (@($entry=$h->read()) !== false) + { + if (($entry!=".")&&($entry!="..")) + { + if (is_dir("$source/$entry")&&$dest!=="$source/$entry") + { + copy_r("$source/$entry","$dest/$entry"); + } + else + { + @copy("$source/$entry","$dest/$entry"); + } + } + } + $h->close(); + return 1; +} + +/** + * delete directory recurisvely - same as "rm -rf" + */ +function rm_rf($path,$followLinks=false) +{ + $dir = opendir($path) ; + while (false !== ($entry = readdir($dir))) + { + if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) + { + @unlink( "$path/$entry" ); + } + elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) + { + rm_rf( "$path/$entry" ); + } + } + closedir($dir) ; + return @rmdir($path); +} + +/** * realpath() doesnt work somtimes if path is absolute * linRealpath takes care of this */ Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-26 21:43:06 UTC (rev 4549) @@ -205,7 +205,10 @@ $d = dir( $dirname ); while( false !== ($entry = $d->read() ) ) { - LinImport::addNewEntry( $parent_id , $dirname , $entry, $recursive ); + if($entry != '.' AND $entry != '..') + { + LinImport::addNewEntry( $parent_id , $dirname , $entry, $recursive ); + } } $d->close(); } Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-26 21:43:06 UTC (rev 4549) @@ -596,8 +596,14 @@ */ function getFullImagePath( $photo_id ) { + $album_dir = LinSql::getPath('album'); + + if($photo_id == 0) + { + return $album_dir; // return album_dir without ending slash + } + $array_path = LinSql::getFullFilenameFromId( $photo_id ); - $album_dir = LinSql::getPath('album'); return $album_dir .'/'. implode('/',$array_path); } Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-04-25 22:05:37 UTC (rev 4548) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-26 21:43:06 UTC (rev 4549) @@ -30,7 +30,7 @@ * But he cannot rename or delete the folder itself * * - * it doesnt make sense to give write permissions to the file itself + * it doesnt make sense to give write permissions to the files itself */ if(!defined('LINPHA_DIR')) { exit(1); } @@ -93,68 +93,198 @@ */ if(isset($_POST['cmd'])) { - switch($_POST['cmd']) + try { - case 'file_action': - ?> - <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> - <?php - switch($_POST['file_action']) + switch($_POST['cmd']) { - case 'rename': + case 'file_action': + if(!isset($_POST['checkedfiles'])) + { + throw new Exception(i18n("No Files Selected")); + } + if(!isset($_POST['file_action'])) + { + throw new Exception(i18n("No Action Selected")); + } + ?> - <input type="text" name="do_rename" value="" /> + <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <?php - break; - - case 'move': - case 'copy': + switch($_POST['file_action']) + { + case 'rename': + $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($_POST['checkedfiles'][0])."'"); + + echo '<b>'.i18n("Rename File/Folder").':</b><br />'; + ?> + <input type="text" name="new_name" value="<?php echo $data['name']; ?>" style="width: 300px;" /> + <input type="hidden" name="file_id" value="<?php echo $_POST['checkedfiles'][0]; ?>" /> + <?php + break; + + case 'move': + case 'copy': + ?> + <select> + <option value=""></option> + <option value=""></option> + <option value=""></option> + </selet> + <?php + break; + case 'delete': + echo i18n("Delete All The Following Files/Folders including contensts:").'<br />'; + foreach($_POST['checkedfiles'] AS $value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($value)."'"); + echo $data['name'].', '; + } + echo '<br /><br />'; + echo i18n("Really Sure?"); + ?> + <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_POST['checkedfiles']); ?>" /> + <?php + break; + } ?> - <select> - <option value=""></option> - <option value=""></option> - <option value=""></option> - </selet> + <input type="hidden" name="cmd" value="do_file_action" /> + <input type="hidden" name="file_action" value="<?php echo $_POST['file_action']; ?>" /> + <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> + </form> + <hr /><br /> <?php + break; + case 'do_file_action': + switch($_POST['file_action']) + { + case 'rename': + $new_name = removeUnWantedChars( $_POST['new_name'] ); + + $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); + $parent_dirname = dirname($full_filename); + + /** + * check write permission of parent folder + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT parent_id FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $data['parent_id'], 'write') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + + if( nameAlreadyExists( $new_name, $data['parent_id'] )) + { + throw new Exception(i18n("A File/Folder with the same name already exists!")); + } + + if( @rename( $full_filename , $parent_dirname."/".$new_name ) ) + { + /** + * rename on filesys was successful + * -> rename also in db + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos SET name = '".LinSql::linAddslashes($new_name)."' " . + "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); + + linSysLog(i18n("Successfully Renamed!")."<br />"); + } + else + { + linSysLog(i18n(sprintf(i18n("Error While Renaming File/Folder \"%s\" to \"%s\"!"),$full_filename,$parent_dirname.'/'.$new_name)).'<br />'); + linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + } break; - case 'delete': - echo i18n("Really Sure?"); + + case 'move': break; - } - ?> - <input type="hidden" name="cmd" value="do_file_action" /> - <input type="hidden" name="file_action" value="<?php echo $_POST['file_action']; ?>" /> - <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> - </form> - <?php - break; - case 'do_file_action': - switch($_POST['file_action']) - { - case 'rename': - break; + + case 'copy': + break; + + case 'delete': + $checkedfiles = explode(';',$_POST['checkedfiles']); + foreach($checkedfiles AS $value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT parent_id FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($value)."'"); - case 'move': - break; + /** + * check write permission of parent folder + */ + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $data['parent_id'], 'write') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + + $full_filename = LinSql::getFullImagePath( $value ); + + if(LinFilesys::rm_rf($full_filename)) + { + LinImport::deleteEntry( $value, $full_filename); + + linSysLog(i18n("File/Folder deleted successfully!").'<br />'); + } + else + { + linSysLog(i18n("Error While Deleting Folder")." \"".$full_filename."\"".'<br />'); + linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + } + } + break; - case 'copy': - break; + case 'create_folder': + /** + * check write permission of parent folder + */ + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $_POST['file_id'], 'write') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + + $new_name = removeUnWantedChars( $_POST['folder_name'] ); + + if( nameAlreadyExists( $new_name, $_POST['file_id'] )) + { + throw new Exception(i18n("A File/Folder with the same name already exists!")); + } + + $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); - case 'delete': + if( @mkdir( $full_filename .'/'. $new_name )) + { + linSysLog(i18n("Folder Created Successfully!").'<br />'); + linSysLog(i18n("You may now want to start the Import to make your changes appear").'<br />'); + } + else + { + linSysLog(i18n("Error While Creating Folder")." \"".$new_name."\"".'<br />'); + linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + } + break; + } + break; + case 'upload': + + break; } - - break; - case 'create_folder': - - break; - case 'do_create_folder': - - break; - case 'upload': - - break; } + catch(Exception $error) + { + echo "Error: ".$error -> getMessage(); + } + + /** + * print Syslog + */ + if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + { + echo $GLOBALS['linpha']->template->output['sys_log']; + echo '<hr />'; + } } ?> @@ -188,15 +318,16 @@ $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); while($data = $query->FetchRow()) { + $full_filename = LinSql::getFullImagePath( $data['id'] ); + /** - * check read permission - */ - if( $GLOBALS['linpha']->sql->photoIsAllowed( $data['id'], 'read' ) ) + * show only if file exists and we have READ permissions + */ + if( file_exists( $full_filename ) && $GLOBALS['linpha']->sql->photoIsAllowed( $data['id'], 'read' ) ) { /** * set file informations */ - $full_filename = LinSql::getFullImagePath( $data['id'] ); $filestat = stat($full_filename); /** @@ -255,7 +386,7 @@ <tr> <td> <?php if($isWriteAble) { ?> - <input type="checkbox" name="checkedfiles[<?php echo $data['id']; ?>]" value="value" /> + <input type="checkbox" name="checkedfiles[]" value="<?php echo $data['id']; ?>" /> <?php } else { ?> <?php } ?> @@ -281,7 +412,7 @@ } ?> </table> -<input type="radio" id="file_rename" name="file_action" value="rename" /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> +<input type="radio" id="file_rename" name="file_action" value="rename" checked="checked" /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> <input type="radio" id="file_move" name="file_action" value="move" /><label for="file_move"> <?php echo i18n("Move"); ?></label> <input type="radio" id="file_copy" name="file_action" value="copy" /><label for="file_copy"> <?php echo i18n("Copy"); ?></label> <input type="radio" id="file_delete" name="file_action" value="delete" /><label for="file_delete"> <?php echo i18n("Delete"); ?></label> @@ -292,8 +423,10 @@ <br /><br /> <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> -<input type="text" name="createfolder" value="" /> -<input type="hidden" name="cmd" value="create_folder" /> +<input type="text" name="folder_name" value="" /> +<input type="hidden" name="file_id" value="<?php echo $parent_id; ?>" /> +<input type="hidden" name="cmd" value="do_file_action" /> +<input type="hidden" name="file_action" value="create_folder" /> <input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>" /> </form> @@ -407,4 +540,35 @@ return false; } + +/** + * make sure to keep in current directory + * @todo is this enough? + */ +function removeUnWantedChars( $str ) +{ + $str = str_replace('/','',$str); + $str = str_replace('\\','',$str); + + return $str; +} + +/** + * checks if a file/folder with the same name already exists in the same folder + */ +function nameAlreadyExists( $name, $parent_id ) +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."photos " . + "WHERE name = '".LinSql::linAddslashes($name)."' " . + "AND parent_id = '".LinSql::linAddslashes($parent_id)."'"); + + if( $query->EOF) // not a single value returned + { + return false; + } + else + { + return true; + } +} ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-28 22:27:52
|
Revision: 4552 Author: fangehrn Date: 2006-04-28 12:08:11 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4552&view=rev Log Message: ----------- * filemanager: implemeting move, copy, change permissions, upload @todo make upload more secure Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/modules/module.filemanager.php Added Paths: ----------- trunk/linpha2/templates/default/css/filemanager.css trunk/linpha2/templates/default/filemanager.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-26 21:54:14 UTC (rev 4551) +++ trunk/linpha2/ChangeLog 2006-04-28 19:08:11 UTC (rev 4552) @@ -1,3 +1,7 @@ +2006-04-28 flo + * filemanager: implemeting move, copy, change permissions, upload + @todo make upload more secure + 2006-04-26 flo * filemanager: implementing rename, delete, create folder Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-04-26 21:54:14 UTC (rev 4551) +++ trunk/linpha2/install/sql/sql.data.php 2006-04-28 19:08:11 UTC (rev 4552) @@ -64,7 +64,8 @@ 'sys_user_autologin' => '1', - 'plugins_filemanager_enable' => '0' + 'plugins_filemanager_enable' => '0', + 'plugins_filemanager_nruploads' => '5' ); /** Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-26 21:54:14 UTC (rev 4551) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-28 19:08:11 UTC (rev 4552) @@ -47,66 +47,36 @@ } /** -* copy recursive - same as "cp -R" -*/ -function copy_r($source,$dest) + * delete recurisvely - same as "rm -rf" + * @todo should we really have such a dangerous function in linpha? + */ +function rm_rf($path,$followLinks=false) { - if( !is_dir($source) ) + if( is_file($path) ) { - if( is_file($source) ) - { - @copy($source,$dest); - return 1; - } - else - { - return 0; - } + @unlink( $path ); + return true; } - if (!is_dir($dest)) { - mkdir_p($dest); - } - $h=@dir($source); - while (@($entry=$h->read()) !== false) + else { - if (($entry!=".")&&($entry!="..")) + $dir = opendir($path) ; + while (false !== ($entry = readdir($dir))) { - if (is_dir("$source/$entry")&&$dest!=="$source/$entry") + if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) { - copy_r("$source/$entry","$dest/$entry"); + @unlink( "$path/$entry" ); } - else + elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) { - @copy("$source/$entry","$dest/$entry"); + LinFilesys::rm_rf( "$path/$entry" ); } } + closedir($dir) ; + return @rmdir($path); } - $h->close(); - return 1; } /** - * delete directory recurisvely - same as "rm -rf" - */ -function rm_rf($path,$followLinks=false) -{ - $dir = opendir($path) ; - while (false !== ($entry = readdir($dir))) - { - if ( is_file( "$path/$entry" ) || ((!$followLinks) && is_link("$path/$entry")) ) - { - @unlink( "$path/$entry" ); - } - elseif ( is_dir( "$path/$entry" ) && $entry!='.' && $entry!='..' ) - { - rm_rf( "$path/$entry" ); - } - } - closedir($dir) ; - return @rmdir($path); -} - -/** * realpath() doesnt work somtimes if path is absolute * linRealpath takes care of this */ Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-26 21:54:14 UTC (rev 4551) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-28 19:08:11 UTC (rev 4552) @@ -264,8 +264,10 @@ } /** - * update entry (check md5sum and file_type) - * the file_type changes if a file changes to readable + * update entry "detect file changes"(check md5sum and file_type) + * this has nothing todo with the updateDir() method + * + * (the file_type changes if a file changes to readable) */ function updateEntry( $id , $dirname , $filename ) { @@ -308,6 +310,9 @@ * if the md5sum changes, update the md5sum in linpha_stats, linpha_meta_data * occurs while rotating images, or if LinImport detects a change of the file * (for example: image has been edited with an external program) + * + * @todo if the file changed, it is best to re-index image + * -> delete/update exif/iptc/xmp data! */ function updateMd5sum( $id, $old_md5sum, $new_md5sum ) { Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-04-26 21:54:14 UTC (rev 4551) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-28 19:08:11 UTC (rev 4552) @@ -38,6 +38,11 @@ /** * init stuff */ + /** + * some double used i18n entries + */ + $str_checkpermissions = "Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"; + if(!isset($_GET['id'])) { $parent_id = 0; @@ -59,6 +64,20 @@ } else { $uid = 0; } + + /** + * upload stuff + */ + include_once(LINPHA_DIR.'/lib/classes/archiver.class.php'); + $apps = new Archive_Applications(); + $apps->searchApps(); + + $appselect = '<option value="-">'. i18n("Extract Archive With"). '</option>'; + foreach($apps->found_apps AS $key=>$value) + { + $value = $key.' (.'.$apps->apps[$key]['file_ext'].')'; + $appselect .= '<option value="'.$key.'">'.$value.'</option>'; + } /** * check global permission @@ -88,21 +107,23 @@ $isWriteAble = false; } +ob_start(); + /** * parsing POST data */ -if(isset($_POST['cmd'])) +if(isset($_REQUEST['cmd'])) { try { - switch($_POST['cmd']) + switch($_REQUEST['cmd']) { case 'file_action': - if(!isset($_POST['checkedfiles'])) + if(!isset($_REQUEST['checkedfiles'])) { throw new Exception(i18n("No Files Selected")); } - if(!isset($_POST['file_action'])) + if(!isset($_REQUEST['file_action'])) { throw new Exception(i18n("No Action Selected")); } @@ -110,32 +131,53 @@ ?> <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <?php - switch($_POST['file_action']) + switch($_REQUEST['file_action']) { case 'rename': $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_POST['checkedfiles'][0])."'"); + "WHERE id = '".LinSql::linAddslashes($_REQUEST['checkedfiles'][0])."'"); echo '<b>'.i18n("Rename File/Folder").':</b><br />'; ?> <input type="text" name="new_name" value="<?php echo $data['name']; ?>" style="width: 300px;" /> - <input type="hidden" name="file_id" value="<?php echo $_POST['checkedfiles'][0]; ?>" /> + <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> <?php break; case 'move': case 'copy': + if( $_REQUEST['file_action'] == 'move') + { + echo i18n("Move These Files/Folders"); + } + elseif( $_REQUEST['file_action'] == 'copy') + { + echo i18n("Copy These Files/Folders"); + } + echo ':<br />'; + + foreach($_REQUEST['checkedfiles'] AS $value) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($value)."'"); + echo $data['name'].', '; + } + echo '<br /><br />'; + echo i18n("To").':'; + echo '<br />'; ?> - <select> - <option value=""></option> - <option value=""></option> - <option value=""></option> + <select name="movecopy_to"> + <option value="0">/</option> + <?php + buildAlbumSelect( $with_all_albs_entry=false ); + ?> </selet> + <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> <?php break; case 'delete': echo i18n("Delete All The Following Files/Folders including contensts:").'<br />'; - foreach($_POST['checkedfiles'] AS $value) + foreach($_REQUEST['checkedfiles'] AS $value) { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes($value)."'"); @@ -144,13 +186,59 @@ echo '<br /><br />'; echo i18n("Really Sure?"); ?> - <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_POST['checkedfiles']); ?>" /> + <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> <?php break; + case 'changeperm': + $full_filename = LinSql::getFullImagePath( $_REQUEST['checkedfiles'][0]); + $perm = getReadableFileperms($full_filename); + + (substr($perm, 1, 1)!="-" ? $ur = 1 : ''); + (substr($perm, 2, 1)!="-" ? $uw = 1 : ''); + (substr($perm, 3, 1)!="-" ? $ux = 1 : ''); + (substr($perm, 4, 1)!="-" ? $gr = 1 : ''); + (substr($perm, 5, 1)!="-" ? $gw = 1 : ''); + (substr($perm, 6, 1)!="-" ? $gx = 1 : ''); + (substr($perm, 7, 1)!="-" ? $or = 1 : ''); + (substr($perm, 8, 1)!="-" ? $ow = 1 : ''); + (substr($perm, 9, 1)!="-" ? $ox = 1 : ''); + + echo i18n("Change Permission Of:").' '.$full_filename; + ?> + <br /> + <table border="1" cellpadding="0" cellspacing="0"> + <tr> + <td width="100"> </td> + <td class='admintable' width="75"><?php echo i18n("Read"); ?></td> + <td class='admintable' width="75"><?php echo i18n("Write"); ?></td> + <td class='admintable' width="75"><?php echo i18n("Execute"); ?></td> + </tr> + <tr> + <td class='admintable'><?php echo i18n("Owner"); ?></td> + <td><input name="ur" type="checkbox" value="4"<?=(isset($ur) ? ' checked' : '')?>></td> + <td><input name="uw" type="checkbox" value="2"<?=(isset($uw) ? ' checked' : '')?>></td> + <td><input name="ux" type="checkbox" value="1"<?=(isset($ux) ? ' checked' : '')?>></td> + </tr> + <tr> + <td class='admintable'><?php echo i18n("Group"); ?></td> + <td><input name="gr" type="checkbox" value="4"<?=(isset($gr) ? ' checked' : '')?>></td> + <td><input name="gw" type="checkbox" value="2"<?=(isset($gw) ? ' checked' : '')?>></td> + <td><input name="gx" type="checkbox" value="1"<?=(isset($gx) ? ' checked' : '')?>></td> + </tr> + <tr> + <td class='admintable'><?php echo i18n("All Others"); ?></td> + <td><input name="or" type="checkbox" value="4"<?=(isset($or) ? ' checked' : '')?>></td> + <td><input name="ow" type="checkbox" value="2"<?=(isset($ow) ? ' checked' : '')?>></td> + <td><input name="ox" type="checkbox" value="1"<?=(isset($ox) ? ' checked' : '')?>></td> + </tr> + </table> + <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> + <?php + break; } ?> <input type="hidden" name="cmd" value="do_file_action" /> - <input type="hidden" name="file_action" value="<?php echo $_POST['file_action']; ?>" /> + <input type="hidden" name="file_action" value="<?php echo $_REQUEST['file_action']; ?>" /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> </form> <hr /><br /> @@ -194,14 +282,116 @@ else { linSysLog(i18n(sprintf(i18n("Error While Renaming File/Folder \"%s\" to \"%s\"!"),$full_filename,$parent_dirname.'/'.$new_name)).'<br />'); - linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); } break; case 'move': - break; - case 'copy': + /** + * check write permission of target folder + * AND it will also check if it is a valid id (?) + */ + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $_POST['movecopy_to'], 'write') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + + /** + * get target name + */ + $full_destparentname = LinSql::getFullImagePath( $_POST['movecopy_to'] ); + + /** + * go through each folder + */ + $checkedfiles = explode(';',$_POST['checkedfiles']); + foreach($checkedfiles AS $value) + { + /** + * get full source name + */ + $full_sourcename = LinSql::getFullImagePath( $value ); + + if( nameAlreadyExists( basename($full_sourcename), $_POST['movecopy_to'] )) + { + throw new Exception(i18n("A File/Folder with the same name already exists!")); + } + + /** + * move + */ + if( $_POST['file_action'] == 'move') + { + /** + * check write permission of parent source folder + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT parent_id FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($value)."'"); + if($_POST['file_action'] == 'move') + { + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $data['parent_id'], 'write') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + } + + if( rename($full_sourcename, $full_destparentname.'/'.basename($full_sourcename) ) ) + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos " . + "SET parent_id = '".LinSql::linAddslashes($_POST['movecopy_to'])."' " . + "WHERE id = '".LinSql::linAddslashes($value)."'"); + + linSysLog( + sprintf( + i18n("Successfully Moved \"%s\" to \"%s\"!"), + $full_sourcename, + $full_destparentname.'/'.basename($full_sourcename) + ) . "<br />" + ); + } + else + { + linSysLog(i18n(sprintf(i18n("Error While Moving Files/Folders \"%s\" to \"%s\"!"),$full_sourcename,$full_destparentname.'/'.basename($full_sourcename))).'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); + } + } + /** + * copy + */ + elseif( $_POST['file_action'] == 'copy') + { + /** + * check read permission of source folder (not parent! ...) and content + */ + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $value, 'read') ) + { + throw new Exception(i18n("You don't have permissions to this folder!")); + } + + if( is_writable($full_destparentname) ) + { + /** + * copy files/folders (only which we have read permission) + */ + copy_r( $value, $full_sourcename, $full_destparentname); + + linSysLog( + sprintf( + i18n("Successfully Copied \"%s\" to \"%s\"!"), + $full_sourcename, + $full_destparentname.'/'.basename($full_sourcename) + ) . "<br />" + ); + } + else + { + linSysLog(i18n(sprintf(i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"),$full_sourcename,$full_destparentname.'/'.basename($full_sourcename))).'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); + } + } + } + break; case 'delete': @@ -229,8 +419,8 @@ } else { - linSysLog(i18n("Error While Deleting Folder")." \"".$full_filename."\"".'<br />'); - linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + linSysLog(i18n("Error While Deleting Files/Folders")." \"".$full_filename."\"".'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); } } break; @@ -239,42 +429,170 @@ /** * check write permission of parent folder */ - if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $_POST['file_id'], 'write') ) + if( ! $GLOBALS['linpha']->sql->photoIsAllowed( $_GET['id'], 'write') ) { throw new Exception(i18n("You don't have permissions to this folder!")); } $new_name = removeUnWantedChars( $_POST['folder_name'] ); - if( nameAlreadyExists( $new_name, $_POST['file_id'] )) + if( nameAlreadyExists( $new_name, $_GET['id'] )) { throw new Exception(i18n("A File/Folder with the same name already exists!")); } - $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); + $full_filename = LinSql::getFullImagePath( $_GET['id'] ); if( @mkdir( $full_filename .'/'. $new_name )) { linSysLog(i18n("Folder Created Successfully!").'<br />'); - linSysLog(i18n("You may now want to start the Import to make your changes appear").'<br />'); + + if( ! $linpha->sql->config->value['sys_import_autoimport'] ) + { + linSysLog(i18n("Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that...").'<br />'); + } } else { linSysLog(i18n("Error While Creating Folder")." \"".$new_name."\"".'<br />'); - linSysLog(i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)").'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); } break; + case 'changeperm': + $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); + + isset($_POST['ur']) ? $ur = $_POST['ur'] : $ur = 0; + isset($_POST['uw']) ? $uw = $_POST['uw'] : $uw = 0; + isset($_POST['ux']) ? $ux = $_POST['ux'] : $ux = 0; + isset($_POST['gr']) ? $gr = $_POST['gr'] : $gr = 0; + isset($_POST['gw']) ? $gw = $_POST['gw'] : $gw = 0; + isset($_POST['gx']) ? $gx = $_POST['gx'] : $gx = 0; + isset($_POST['or']) ? $or = $_POST['or'] : $or = 0; + isset($_POST['ow']) ? $ow = $_POST['ow'] : $ow = 0; + isset($_POST['ox']) ? $ox = $_POST['ox'] : $ox = 0; + + $u = $ur+$uw+$ux; + $g = $gr+$gw+$gx; + $o = $or+$ow+$ox; + + $mode = $u.$g.$o; + + if(@chmod($full_filename,intval($mode,8))) + { + linSysLog(i18n("Permissions Changed Successfully!").'<br />'); + } + else + { + linSysLog(i18n("Error While Changing Permissions!").'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); + } + break; + } // end switch($_POST['file_action']) + break; // end case 'do_file_action': + + case 'upload': + $targetdir = LinSql::getFullImagePath( $_GET['id'] ); + + for($i = 0; $i < $GLOBALS['linpha']->sql->config->value['plugins_filemanager_nruploads']; $i++ ) + { + if( isset( $_FILES[ 'file' . $i ] ) && !empty( $_FILES[ 'file' . $i]['name'] ) ) // need empty check because it file$i exists in PHP 4.1 + { + $thisfile = $_FILES[ 'file' . $i ]; + $failed = 0; + + if (isset($thisfile['error']) && $thisfile['error'] != 0 ) // ['error'] was added in PHP 4.2.0 + { + switch ( $thisfile['error'] ) + { + case 1: + echo sprintf(i18n("Error: The uploaded file %s exceeds the upload_max_filesize directive in php.ini - %s"), $thisfile['name'], ini_get('upload_max_filesize') ); + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_EXCEEDS_INI_SIZE.")"); + break; + case 2: + echo sprintf(i18n("Error: size of uploaded file %s exceeds the HTML FORM settings"), $thisfile['name'] ); + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_EXCEEDS_FORM_SIZE.")"); + break; + case 3: + echo sprintf(i18n("Error: The uploaded file %s was only partially uploaded"), $thisfile['name'] ); + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_PARTIAL.")"); + break; + } + } + else + { + if ( !move_uploaded_file( $thisfile['tmp_name'], $targetdir . '/' . $thisfile['name']) ) + { + $failed = 1; + } + + if ( $_POST[ 'app' . $i ] != '-' ) // extracting selected + { + $command = $apps->apps[$_POST['app'.$i]]['command_extract']; + $apps->searchApp($_POST['app'.$i]); + + $executable = $apps->found_apps[$_POST['app'.$i]].$apps->apps[$_POST['app'.$i]]['executable_extract']; + + $command = str_replace('{executable}',$executable,$command); + $command = str_replace('{archive_name}',linEscapeString($thisfile['name']),$command); + + $oldpwd = getcwd(); + if ( !chdir( $targetdir ) ) { + $failed = 2; + } + else + { + exec( $command, $output, $return_value ); + chdir( $oldpwd ); + + + echo '<textarea cols="80" rows="4"">' . + $command . "\n". + implode( "\n", $output ) . + '</textarea><br />'; + + unset($output); + + if (!unlink( $targetdir . '/' . $thisfile['name'] )) { + $failed = 3; + } + } + } + + switch ($failed) + { + case 0: + //linpha_log('filemanager','notice', + // 'User '.$_SESSION['user_name'].": uploaded file (".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name'].")"); + + break; + case 1: + echo sprintf( i18n("Error: Unable to move file %s to directory %s"), $thisfile[ 'name' ], $targetdir ); + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR.")"); + break; + case 2: + echo sprintf( i18n("Error: Unable to switch (chdir) to %s directory. File being processed: %s"), $targetdir, $thisfile[ 'name' ] ); + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload chdir failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_CHDIR_ERROR.")"); + break; + case 3: + echo sprintf( i18n("Error: Unable to delete %s after processing."), $targetdir . '/' . $thisfile['name'] ); break; + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": upload unlink for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_UNLINK_ERROR.")"); + break; + } + } + } } - break; - case 'upload': - - break; } } catch(Exception $error) { - echo "Error: ".$error -> getMessage(); + echo "Error: ".$error -> getMessage().'<br /><br />'; } /** @@ -284,12 +602,38 @@ { echo $GLOBALS['linpha']->template->output['sys_log']; echo '<hr />'; + unset($GLOBALS['linpha']->template->output['sys_log']); } } + +/** + * do import + */ + if( $linpha->sql->config->value['sys_import_autoimport'] ) + { + /** + * empty syslog + */ + unset($GLOBALS['linpha']->template->output['sys_log']); + + LinImport::updateDir( $parent_id, $recursive = false, $dryrun = false ); + + /** + * print Syslog + */ + if( isset($GLOBALS['linpha']->template->output['sys_log']) ) + { + echo i18n("LinPHA Import:").'<br />'; + echo $GLOBALS['linpha']->template->output['sys_log']; + echo '<hr />'; + unset($GLOBALS['linpha']->template->output['sys_log']); + } + } ?> <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> -<table border="1"> +<div id="filemanager"> +<table> <tr> <td> </td> <td width="500"> </td> @@ -301,9 +645,9 @@ <?php if($parent_id != 0) { + echo i18n("Current Folder:").' / '.implode(' / ',LinSql::getFullFilenameFromId( $parent_id )).'<br />'; + $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); - - echo i18n("Current Folder:").' '.$data['name'].'<br />'; ?> <tr> <td> </td> @@ -374,7 +718,7 @@ if($uid == $filestat['uid']) { - $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=change_perm_form">'. $perm . '</a>'; + $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=file_action&file_action=changeperm&checkedfiles[]='.$data['id'].'">'. $perm . '</a>'; } else { @@ -385,8 +729,21 @@ ?> <tr> <td> - <?php if($isWriteAble) { ?> - <input type="checkbox" name="checkedfiles[]" value="<?php echo $data['id']; ?>" /> + <?php + if($isWriteAble) + { + if( isset($_REQUEST['checkedfiles']) + && is_array($_REQUEST['checkedfiles']) + && in_array($data['id'], $_REQUEST['checkedfiles']) ) + { + $str_checked = ' checked="checked"'; + } + else + { + $str_checked = ''; + } + ?> + <input type="checkbox" name="checkedfiles[]" value="<?php echo $data['id']; ?>"<?php echo $str_checked; ?> /> <?php } else { ?> <?php } ?> @@ -412,38 +769,93 @@ } ?> </table> -<input type="radio" id="file_rename" name="file_action" value="rename" checked="checked" /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> -<input type="radio" id="file_move" name="file_action" value="move" /><label for="file_move"> <?php echo i18n("Move"); ?></label> -<input type="radio" id="file_copy" name="file_action" value="copy" /><label for="file_copy"> <?php echo i18n("Copy"); ?></label> -<input type="radio" id="file_delete" name="file_action" value="delete" /><label for="file_delete"> <?php echo i18n("Delete"); ?></label> + +<?php +/** + * set checked radio buttons + */ + $array_values = Array('rename','move','copy','delete'); + foreach($array_values AS $value) + { + if(isset($_POST['file_action']) && $_POST['file_action'] == $value) + { + $arr_checked[$value] = ' checked="checked"'; + $somtething_checked = true; + } + else + { + $arr_checked[$value] = ''; + } + } + + /** + * default checked + */ + if(!isset($something_checked)) + { + $arr_checked['rename'] = ' checked="checked"'; + } + +if($isWriteAble) +{ +?> +<input type="radio" id="file_rename" name="file_action" value="rename"<?php echo $arr_checked['rename']; ?> /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> +<input type="radio" id="file_move" name="file_action" value="move"<?php echo $arr_checked['move']; ?> /><label for="file_move"> <?php echo i18n("Move"); ?></label> +<input type="radio" id="file_copy" name="file_action" value="copy"<?php echo $arr_checked['copy']; ?> /><label for="file_copy"> <?php echo i18n("Copy"); ?></label> +<input type="radio" id="file_delete" name="file_action" value="delete"<?php echo $arr_checked['delete']; ?> /><label for="file_delete"> <?php echo i18n("Delete"); ?></label> <input type="hidden" name="cmd" value="file_action" /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> </form> - <br /><br /> <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <input type="text" name="folder_name" value="" /> -<input type="hidden" name="file_id" value="<?php echo $parent_id; ?>" /> <input type="hidden" name="cmd" value="do_file_action" /> <input type="hidden" name="file_action" value="create_folder" /> <input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>" /> </form> <br /><br /> -<form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> -<input type="file" name="uploadfile0" value="" /><br /> -<input type="file" name="uploadfile1" value="" /><br /> -<input type="file" name="uploadfile2" value="" /><br /> -<input type="file" name="uploadfile3" value="" /><br /> -<input type="file" name="uploadfile4" value="" /><br /> +<h2><?php echo i18n("Upload Files"); ?></h2> +<form method="POST" enctype="multipart/form-data" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<?php echo i18n("Choose files you would like to upload. Choose desired action to accomplish upon succesful upload.").'<br />'; ?> +<?php echo i18n("Allowed filesize (each file!) maximum currently set in php.ini is:").' '.ini_get('upload_max_filesize').'<br />'; ?> +<br /> +<?php echo i18n("Note: You don't have to upload your images through this form. You can use whatever you want (ftp,scp,nfs,local,...). Just copy them to the albums folder."); ?> +<br /> +<?php +$max_uploads = 5; +for($i = 0; $i < $GLOBALS['linpha']->sql->config->value['plugins_filemanager_nruploads']; $i++) +{ + echo '<input type="file" name="file'.$i.'" value="" /> '; + echo '<select name="app'.$i.'">'.$appselect.'</select><br />'; +} +?> + <input type="hidden" name="cmd" value="upload" /> <input type="submit" name="submit" value="<?php echo i18n("Upload Files"); ?>"/> </form> +<?php +} +?> +</div> + <?php +$linpha->template->output['filemanager'] = ob_get_clean(); +?> +<?php +$linpha->template->setModuleName('filemanager'); +$linpha->template->URL_full = LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; +$linpha->template->output['title'] = i18n("Filemanager"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); +exit(); +?> + + +<?php /** * found on http://ch.php.net/manual/en/function.fileperms.php */ @@ -571,4 +983,37 @@ return true; } } + +/** + * recursively copy files/folders + * check read permission of source folder + * -> check each subentry! + */ +function copy_r( $source_id, $source, $dest ) +{ + if( $GLOBALS['linpha']->sql->photoIsAllowed( $source_id, 'read' ) ) + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT img_type FROM ".PREFIX."photos " . + "WHERE id = '".LinSql::linAddslashes($source_id)."'"); + + if($data['img_type']!=0) + { + @copy( $source, $dest.'/'.basename($source)); + } + else + { + mkdir( $dest.'/'.basename($source) ); + + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos " . + "WHERE parent_id = '".LinSql::linAddslashes($source_id)."'"); + while($data = $query->FetchRow()) + { + if( file_exists($source.'/'.$data['name'] ) ) + { + copy_r( $data['id'], $source.'/'.$data['name'], $dest.'/'.basename($source) ); + } + } + } + } +} ?> \ No newline at end of file Added: trunk/linpha2/templates/default/css/filemanager.css =================================================================== --- trunk/linpha2/templates/default/css/filemanager.css (rev 0) +++ trunk/linpha2/templates/default/css/filemanager.css 2006-04-28 19:08:11 UTC (rev 4552) @@ -0,0 +1,10 @@ +#filemanager table +{ + border-collapse:collapse; +} + +#filemanager td +{ + border:1px solid black; + padding:5px; +} \ No newline at end of file Added: trunk/linpha2/templates/default/filemanager.html.php =================================================================== --- trunk/linpha2/templates/default/filemanager.html.php (rev 0) +++ trunk/linpha2/templates/default/filemanager.html.php 2006-04-28 19:08:11 UTC (rev 4552) @@ -0,0 +1,19 @@ +<div id="divmain"> + <div class="roundtop"> + <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['filemanager']; +?> + + + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-04-29 22:13:30
|
Revision: 4553 Author: fangehrn Date: 2006-04-29 15:13:09 -0700 (Sat, 29 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4553&view=rev Log Message: ----------- * filemanager: implementing upload only images and videos, escape filenames correct (-> create a folder and file called "<script>" and you will find things which needs to be escaped) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.functions.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/classes/linpha.import.class.php trunk/linpha2/lib/classes/linpha.metadata.class.php trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/templates/default/basket.html.php trunk/linpha2/templates/default/view_img.html.php trunk/linpha2/templates/default/view_meta.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/ChangeLog 2006-04-29 22:13:09 UTC (rev 4553) @@ -1,6 +1,9 @@ +2006-04-29 flo + * filemanager: implementing upload only images and videos, escape filenames correct + (-> create a folder and file called "<script>" and you will find things which needs to be escaped) + 2006-04-28 flo * filemanager: implemeting move, copy, change permissions, upload - @todo make upload more secure 2006-04-26 flo * filemanager: implementing rename, delete, create folder Modified: trunk/linpha2/lib/classes/linpha.functions.php =================================================================== --- trunk/linpha2/lib/classes/linpha.functions.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/classes/linpha.functions.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -200,17 +200,19 @@ } // end tr() - -function set_navigation_line( $id ) +/** + * print a nice navigation line with links on each entry + */ +function setNavigationLine( $id, $link ) { - $str = '<a href="'.LINPHA_DIR.'/?cat=alb&id=0">></a> '; + $str = '<a href="'.$link.'=0">></a> '; $array_files = $GLOBALS['linpha']->sql->getFullFilenameFromId( $id ); foreach($array_files AS $key=>$value) { if($value != "") { - $array_values[] = '<a href="'.LINPHA_DIR.'/?cat=alb&id='.$key.'">'.$value.'</a>'; + $array_values[] = '<a href="'.$link.$key.'">'.htmlspecialchars($value,ENT_QUOTES).'</a>'; } } Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -222,6 +222,11 @@ { if( LinSql::photoIsAllowed( $value['id'] ) ) { + /** + * escape name here + * -> we do not have to do it in the templates + */ + $value['name'] = htmlspecialchars($value['name'],ENT_QUOTES); $this->photos_filtered[] = $value; } } @@ -329,6 +334,13 @@ ) ); + if($GLOBALS['linpha']->sql->photoIsAllowed( $this->id_parent, 'write')) + { + $GLOBALS['linpha']->template->output['menu_More']['edit']['name'] = i18n("Edit"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][2]['name'] = i18n("Open Filemanager"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][2]['value'] = LINPHA_DIR.'/?cat=filemanager&id='.$this->id_parent; + } + if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { $GLOBALS['linpha']->template->output['menu_More']['metainfo'] = @@ -361,15 +373,21 @@ if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { - $GLOBALS['linpha']->template->output['menu_More']['edit'] = - Array( - 'name' => i18n("Edit"), - 'value' => Array( - Array('name' => i18n("Rotate Left"), 'value' => '#'), - Array('name' => i18n("Rotate Right"), 'value' => '#') - ) - ); + $GLOBALS['linpha']->template->output['menu_More']['edit']['name'] = i18n("Edit"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][0]['name'] = i18n("Rotate Left"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][0]['value'] = '#'; + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][1]['name'] = i18n("Rotate Right"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][1]['value'] = '#'; } + + if($GLOBALS['linpha']->sql->photoIsAllowed( $this->id_parent, 'write')) + { + $GLOBALS['linpha']->template->output['menu_More']['edit']['name'] = i18n("Edit"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][2]['name'] = i18n("Open Filemanager"); + $GLOBALS['linpha']->template->output['menu_More']['edit']['value'][2]['value'] = LINPHA_DIR.'/?cat=filemanager&id='.$this->id_parent; + } + + if($GLOBALS['linpha']->sql->checkPermission('metadata_edit')) { $GLOBALS['linpha']->template->output['menu_More']['metainfo'] = @@ -563,16 +581,16 @@ { if($index == 'before') { - $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= $value['value'].'<br />'; + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= $value['value'].'<br />'; // $value['value'] is already escaped } elseif($index == 'after') { - $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= '<br />'.$value['value']; + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']][$index] .= '<br />'.$value['value']; // $value['value'] is already escaped } } } - $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']]['title'] = $photo_value['name']; + $GLOBALS['linpha']->template->output['thumb_infos'][$photo_value['id']]['title'] = $photo_value['name']; // $photo_value['name'] is already escaped } Modified: trunk/linpha2/lib/classes/linpha.import.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/classes/linpha.import.class.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -90,7 +90,7 @@ { if($dryrun) { - linSysLog("Delete Entry: ".$dirname.'/'.$value."<br />"); + linSysLog(i18n("Delete Entry").": ".htmlspecialchars($dirname.'/'.$value,ENT_QUOTES)."<br />"); $deleted_keys[] = $key; } else @@ -106,7 +106,7 @@ { if($dryrun) { - linSysLog("New Entry: ".$dirname.'/'.$value."<br />"); + linSysLog(i18n("New Entry").": ".htmlspecialchars($dirname.'/'.$value,ENT_QUOTES)."<br />"); } else { @@ -150,7 +150,7 @@ } catch(Exception $error) { - linSysLog("Error during import files/folders: ".$error -> getMessage()); + linSysLog(i18n("Error during import files/folders").": ".$error -> getMessage()); } } @@ -164,7 +164,7 @@ */ function addNewEntry( $parent_id , $dirname , $filename , $recursive ) { - linSysLog('new '.$dirname.'/'.$filename.'<br />'); + linSysLog(i18n("New").': '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES).'<br />'); list($md5sum,$file_type,$stats_number) = LinImport::getFileInformation($dirname,$filename); @@ -233,7 +233,7 @@ LinImport::deleteEntry( $data['id'], $full_filename.'/'.$data['name']); } - linSysLog('delete entry '.$full_filename.'<br />'); + linSysLog(i18n("Delete Entry").': '.htmlspecialchars($full_filename,ENT_QUOTES).'<br />'); /** * delete thumbnail and image in cache folder @@ -281,7 +281,7 @@ */ if($file_type != $data[0]) { - linSysLog("Detected a change of file_type in: ".$dirname.'/'.$filename.'<br />'); + linSysLog(i18n("Detected a change of file_type in:")." ".htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES).'<br />'); $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos " . "SET img_type = '".$file_type."', stats_numbers = '".$stats_number."' " . "WHERE id = '".$id."'"); @@ -296,7 +296,7 @@ */ if($md5sum != $data[1]) { - linSysLog("File ".$dirname.'/'.$filename." changed, updating data...<br />"); + linSysLog(sprintf(i18n("File %s changed, updating data..."),htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES))."<br />"); $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos " . "SET md5sum = '".$md5sum."' WHERE id = '".$id."'"); @@ -327,8 +327,6 @@ { if( $id != 0 ) { - linSysLog('updating photo number of id: '.$id.'<br />'); - $data = $GLOBALS['linpha']->db->GetRow("SELECT sum(stats_numbers) " . "FROM ".PREFIX."photos WHERE parent_id = '".$id."'"); $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."photos " . @@ -352,22 +350,22 @@ $ext = LinFilesys::getFileExtFromPath($filename); if($filename{0} == '.') { - linSysLog("File ".$dirname.'/'.$filename." Is Hidden<br />"); + linSysLog(htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)." ".i18n("Is Hidden")."<br />"); $file_type = 9999999; } elseif( in_array( $filename, LinImport::getIgnoreFilelist() ) ) { - linSysLog("File ".$dirname.'/'.$filename." Is In The Ignore List<br />"); + linSysLog(htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)." ".i18n("Is In The Ignore List")."<br />"); $file_type = 9999999; } elseif( in_array($ext, LinImport::getIgnoreFileext() ) ) { - linSysLog("File ".$dirname.'/'.$filename." Is In The Ignore List<br />"); + linSysLog(htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)." ".i18n("Is In The Ignore List")."<br />"); $file_type = 9999999; } elseif( !is_readable( $dirname.'/'.$filename) ) { - linSysLog("File ".$dirname.'/'.$filename." Is Not Readable<br />"); + linSysLog(htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES)." ".i18n("Is Not Readable")."<br />"); $file_type = 9999999; } /** @@ -409,7 +407,7 @@ } else { - linSysLog('Error: what am i? '.$dirname.'/'.$filename.'<br />'); + linSysLog('Error: what am i? '.htmlspecialchars($dirname.'/'.$filename,ENT_QUOTES).'<br />'); } return array($md5sum,$file_type,$stats_number); Modified: trunk/linpha2/lib/classes/linpha.metadata.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/classes/linpha.metadata.class.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -103,7 +103,7 @@ switch($last_part) { case 'filename': - $value = $filename; + $value = $filename; // is already escaped break; case 'imagesize': $value = filesize( $full_filename ); @@ -123,7 +123,7 @@ "AND md5sum = '".$md5sum."'"); if(isset($meta_data['meta_data'])) { - $value = $meta_data['meta_data']; + $value = htmlspecialchars($meta_data['meta_data'],ENT_QUOTES); } } case 'id': @@ -133,7 +133,7 @@ "AND md5sum = '".$md5sum."'"); if(isset($meta_data['meta_data'])) { - $value = $meta_data['meta_data']; + $value = htmlspecialchars($meta_data['meta_data'],ENT_QUOTES); } break; case 'exif': @@ -142,7 +142,7 @@ "FROM ".PREFIX."meta_exif WHERE md5sum = '".$md5sum."'"); if(isset($exif_data[$last_part])) { - $value = $exif_data[$last_part]; + $value = htmlspecialchars($exif_data[$last_part],ENT_QUOTES); } } break; @@ -152,7 +152,7 @@ "FROM ".PREFIX."meta_iptc WHERE md5sum = '".$md5sum."'"); if(isset($iptc_data[$last_part])) { - $value = $iptc_data[$last_part]; + $value = htmlspecialchars($iptc_data[$last_part],ENT_QUOTES); } } break; Modified: trunk/linpha2/lib/modules/module.albums.php =================================================================== --- trunk/linpha2/lib/modules/module.albums.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/modules/module.albums.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -68,7 +68,7 @@ /** * set navigation line */ - $GLOBALS['linpha']->template->output['title'] = set_navigation_line( $linpha->imgview->id_current ); + $GLOBALS['linpha']->template->output['title'] = setNavigationLine( $linpha->imgview->id_current, LINPHA_DIR.'/?cat=alb&id=' ); /** Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -36,13 +36,14 @@ if(!defined('LINPHA_DIR')) { exit(1); } /** - * init stuff + * some double used i18n entries */ - /** - * some double used i18n entries - */ $str_checkpermissions = "Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"; + $str_autoimportdisabled = "Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that..."; +/** + * init stuff + */ if(!isset($_GET['id'])) { $parent_id = 0; @@ -52,7 +53,6 @@ $parent_id = $_GET['id']; } - $i = 0; $sum['size'] = 0; $sum['files'] = 0; @@ -96,7 +96,7 @@ } /** - * use this for child object + * use this for child objects */ if( $GLOBALS['linpha']->sql->photoIsAllowed( $parent_id, 'write' ) ) { @@ -107,10 +107,16 @@ $isWriteAble = false; } +/** + * output buffering, to use in template + */ ob_start(); /** * parsing POST data + * + * cmd = file_action -> show forms + * cmd = do_file_action -> do actions */ if(isset($_REQUEST['cmd'])) { @@ -118,7 +124,7 @@ { switch($_REQUEST['cmd']) { - case 'file_action': + case 'file_action': if(!isset($_REQUEST['checkedfiles'])) { throw new Exception(i18n("No Files Selected")); @@ -139,7 +145,7 @@ echo '<b>'.i18n("Rename File/Folder").':</b><br />'; ?> - <input type="text" name="new_name" value="<?php echo $data['name']; ?>" style="width: 300px;" /> + <input type="text" name="new_name" value="<?php echo htmlspecialchars($data['name'],ENT_QUOTES); ?>" style="width: 300px;" /> <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> <?php break; @@ -160,7 +166,7 @@ { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo $data['name'].', '; + echo htmlspecialchars($data['name'],ENT_QUOTES).', '; } echo '<br /><br />'; echo i18n("To").':'; @@ -181,7 +187,7 @@ { $data = $GLOBALS['linpha']->db->GetRow("SELECT name FROM ".PREFIX."photos " . "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo $data['name'].', '; + echo htmlspecialchars($data['name'],ENT_QUOTES).', '; } echo '<br /><br />'; echo i18n("Really Sure?"); @@ -203,7 +209,7 @@ (substr($perm, 8, 1)!="-" ? $ow = 1 : ''); (substr($perm, 9, 1)!="-" ? $ox = 1 : ''); - echo i18n("Change Permission Of:").' '.$full_filename; + echo i18n("Change Permission Of:").' '.htmlspecialchars($full_filename,ENT_QUOTES); ?> <br /> <table border="1" cellpadding="0" cellspacing="0"> @@ -244,7 +250,8 @@ <hr /><br /> <?php break; - case 'do_file_action': + + case 'do_file_action': switch($_POST['file_action']) { case 'rename': @@ -281,7 +288,13 @@ } else { - linSysLog(i18n(sprintf(i18n("Error While Renaming File/Folder \"%s\" to \"%s\"!"),$full_filename,$parent_dirname.'/'.$new_name)).'<br />'); + linSysLog( + sprintf( + i18n("Error While Renaming File/Folder \"%s\" to \"%s\"!"), + htmlspecialchars($full_filename,ENT_QUOTES), + htmlspecialchars($parent_dirname.'/'.$new_name,ENT_QUOTES) + ).'<br />' + ); linSysLog(i18n($str_checkpermissions).'<br />'); } break; @@ -345,14 +358,20 @@ linSysLog( sprintf( i18n("Successfully Moved \"%s\" to \"%s\"!"), - $full_sourcename, - $full_destparentname.'/'.basename($full_sourcename) + htmlspecialchars($full_sourcename,ENT_QUOTES), + htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) ) . "<br />" ); } else { - linSysLog(i18n(sprintf(i18n("Error While Moving Files/Folders \"%s\" to \"%s\"!"),$full_sourcename,$full_destparentname.'/'.basename($full_sourcename))).'<br />'); + linSysLog( + sprintf( + i18n("Error While Moving Files/Folders \"%s\" to \"%s\"!"), + htmlspecialchars($full_sourcename,ENT_QUOTES), + htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) + ).'<br />' + ); linSysLog(i18n($str_checkpermissions).'<br />'); } } @@ -376,17 +395,37 @@ */ copy_r( $value, $full_sourcename, $full_destparentname); + if(file_exists( $full_destparentname.'/'.basename($full_sourcename) )) + { + linSysLog( + sprintf( + i18n("Successfully Copied \"%s\" to \"%s\"!"), + $full_sourcename, + $full_destparentname.'/'.basename($full_sourcename) + ) . "<br />" + ); + } + else + { + linSysLog( + sprintf( + i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"), + htmlspecialchars($full_sourcename,ENT_QUOTES), + htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) + ).'<br />' + ); + linSysLog(i18n($str_checkpermissions).'<br />'); + } + } + else + { linSysLog( sprintf( - i18n("Successfully Copied \"%s\" to \"%s\"!"), - $full_sourcename, - $full_destparentname.'/'.basename($full_sourcename) - ) . "<br />" + i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"), + htmlspecialchars($full_sourcename,ENT_QUOTES), + htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) + ).'<br />' ); - } - else - { - linSysLog(i18n(sprintf(i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"),$full_sourcename,$full_destparentname.'/'.basename($full_sourcename))).'<br />'); linSysLog(i18n($str_checkpermissions).'<br />'); } } @@ -411,17 +450,19 @@ $full_filename = LinSql::getFullImagePath( $value ); - if(LinFilesys::rm_rf($full_filename)) + LinFilesys::rm_rf($full_filename); + + if(file_exists($full_filename)) { + linSysLog(i18n("Error While Deleting Files/Folders")." \"".htmlspecialchars($full_filename,ENT_QUOTES)."\"".'<br />'); + linSysLog(i18n($str_checkpermissions).'<br />'); + } + else + { LinImport::deleteEntry( $value, $full_filename); linSysLog(i18n("File/Folder deleted successfully!").'<br />'); } - else - { - linSysLog(i18n("Error While Deleting Files/Folders")." \"".$full_filename."\"".'<br />'); - linSysLog(i18n($str_checkpermissions).'<br />'); - } } break; @@ -449,12 +490,12 @@ if( ! $linpha->sql->config->value['sys_import_autoimport'] ) { - linSysLog(i18n("Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that...").'<br />'); + linSysLog(i18n($str_autoimportdisabled).'<br />'); } } else { - linSysLog(i18n("Error While Creating Folder")." \"".$new_name."\"".'<br />'); + linSysLog(i18n("Error While Creating Folder")." \"".htmlspecialchars($new_name,ENT_QUOTES)."\"".'<br />'); linSysLog(i18n($str_checkpermissions).'<br />'); } break; @@ -495,104 +536,98 @@ for($i = 0; $i < $GLOBALS['linpha']->sql->config->value['plugins_filemanager_nruploads']; $i++ ) { - if( isset( $_FILES[ 'file' . $i ] ) && !empty( $_FILES[ 'file' . $i]['name'] ) ) // need empty check because it file$i exists in PHP 4.1 + if( isset( $_FILES[ 'file' . $i ] ) && !empty( $_FILES[ 'file' . $i]['name'] ) ) // need empty check because "file$i" exists in PHP 4.1 { $thisfile = $_FILES[ 'file' . $i ]; - $failed = 0; if (isset($thisfile['error']) && $thisfile['error'] != 0 ) // ['error'] was added in PHP 4.2.0 { switch ( $thisfile['error'] ) { case 1: - echo sprintf(i18n("Error: The uploaded file %s exceeds the upload_max_filesize directive in php.ini - %s"), $thisfile['name'], ini_get('upload_max_filesize') ); - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_EXCEEDS_INI_SIZE.")"); + throw new Exception( sprintf(i18n("Error: The uploaded file %s exceeds the upload_max_filesize directive in php.ini - %s"), + htmlspecialchars($thisfile['name'],ENT_QUOTES), ini_get('upload_max_filesize') ) ); break; case 2: - echo sprintf(i18n("Error: size of uploaded file %s exceeds the HTML FORM settings"), $thisfile['name'] ); - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_EXCEEDS_FORM_SIZE.")"); + throw new Exception( sprintf(i18n("size of uploaded file %s exceeds the HTML FORM settings"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); break; case 3: - echo sprintf(i18n("Error: The uploaded file %s was only partially uploaded"), $thisfile['name'] ); - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR_FILE_PARTIAL.")"); + throw new Exception( sprintf(i18n("The uploaded file %s was only partially uploaded"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); break; } } - else + + if ( $_POST[ 'app' . $i ] == '-' ) { - if ( !move_uploaded_file( $thisfile['tmp_name'], $targetdir . '/' . $thisfile['name']) ) + if ( !move_uploaded_file( $thisfile['tmp_name'], $targetdir . '/' . $thisfile['name'] ) ) { - $failed = 1; + throw new Exception( sprintf(i18n("Unable to move file %s to directory %s"),htmlspecialchars($thisfile[ 'name' ],ENT_QUOTES),htmlspecialchars($targetdir,ENT_QUOTES ) ) ); } - - if ( $_POST[ 'app' . $i ] != '-' ) // extracting selected + } + else // $_POST[ 'app' . $i ] != '-' + { + $tmpfolder = LinFilesys::createTmpFolder('filemanager'); + + if ( !move_uploaded_file( $thisfile['tmp_name'], $tmpfolder . '/' . $thisfile['name'] ) ) { - $command = $apps->apps[$_POST['app'.$i]]['command_extract']; - $apps->searchApp($_POST['app'.$i]); - - $executable = $apps->found_apps[$_POST['app'.$i]].$apps->apps[$_POST['app'.$i]]['executable_extract']; - - $command = str_replace('{executable}',$executable,$command); - $command = str_replace('{archive_name}',linEscapeString($thisfile['name']),$command); - - $oldpwd = getcwd(); - if ( !chdir( $targetdir ) ) { - $failed = 2; - } - else - { - exec( $command, $output, $return_value ); - chdir( $oldpwd ); - - - echo '<textarea cols="80" rows="4"">' . - $command . "\n". - implode( "\n", $output ) . - '</textarea><br />'; - - unset($output); - - if (!unlink( $targetdir . '/' . $thisfile['name'] )) { - $failed = 3; - } - } + throw new Exception(sprintf( i18n("Unable to move file %s to directory %s"), htmlspecialchars($thisfile[ 'name' ],ENT_QUOTES), htmlspecialchars($targetdir,ENT_QUOTES) ) ); } - - switch ($failed) + + + $command = $apps->apps[$_POST['app'.$i]]['command_extract']; + $apps->searchApp($_POST['app'.$i]); + + $executable = $apps->found_apps[$_POST['app'.$i]].$apps->apps[$_POST['app'.$i]]['executable_extract']; + + $command = str_replace('{executable}',$executable,$command); + $command = str_replace('{archive_name}',linEscapeString($thisfile['name']),$command); + + $oldpwd = getcwd(); + if ( !chdir( $tmpfolder ) ) { - case 0: - //linpha_log('filemanager','notice', - // 'User '.$_SESSION['user_name'].": uploaded file (".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name'].")"); - - break; - case 1: - echo sprintf( i18n("Error: Unable to move file %s to directory %s"), $thisfile[ 'name' ], $targetdir ); - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_ERROR.")"); - break; - case 2: - echo sprintf( i18n("Error: Unable to switch (chdir) to %s directory. File being processed: %s"), $targetdir, $thisfile[ 'name' ] ); - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload chdir failed for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_CHDIR_ERROR.")"); - break; - case 3: - echo sprintf( i18n("Error: Unable to delete %s after processing."), $targetdir . '/' . $thisfile['name'] ); break; - //linpha_log('filemanager','error', - // 'User '.$_SESSION['user_name'].": upload unlink for(".$thisfile['name'].") message: (".STR_FILE_UPLOAD_UNLINK_ERROR.")"); - break; + throw new Exception( sprintf( i18n("Unable to switch (chdir) to %s directory. File being processed: %s"), $tmpfolder, $thisfile[ 'name' ] ) ); } + + exec( $command, $output, $return_value ); + chdir( $oldpwd ); + + + echo '<textarea cols="80" rows="4"">' . + htmlspecialchars( $command . "\n". implode( "\n", $output ), ENT_QUOTES ) . + '</textarea><br />'; + + unset($output); + + /** + * move valid images and videos to target dir + * this will delete the archive file automatically... + * and also delete the tmpfolder + */ + moveValidEntries( $tmpfolder, $targetdir ); + + $somethingUploaded = true; + //linpha_log('filemanager','notice', + // 'User '.$_SESSION['user_name'].": uploaded file (".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name'].")"); } } } + + if(isset($somethingUploaded)) + { + if( ! $linpha->sql->config->value['sys_import_autoimport'] ) + { + linSysLog(i18n($str_autoimportdisabled).'<br />'); + } + } break; } } catch(Exception $error) { echo "Error: ".$error -> getMessage().'<br /><br />'; + //linpha_log('filemanager','error', + // 'User '.$_SESSION['user_name'].": ".$message); + } /** @@ -629,35 +664,36 @@ unset($GLOBALS['linpha']->template->output['sys_log']); } } + +echo i18n("Current Folder:").' '.setNavigationLine( $parent_id, LINPHA_DIR.'/?cat=filemanager&id=').'<br />'; ?> <form method="POST" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> <div id="filemanager"> <table> <tr> - <td> </td> - <td width="500"> </td> + <td width="20"> </td> + <td width="500"> + <?php + if($parent_id == 0) + { + echo ' '; + } + else + { + $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); + ?> + <a href="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$data['parent_id']; ?>">..</a> + <?php + } + ?> + </td> <td width="100"> </td> <td width="150"> </td> <td width="100"> </td> </tr> <?php -if($parent_id != 0) -{ - echo i18n("Current Folder:").' / '.implode(' / ',LinSql::getFullFilenameFromId( $parent_id )).'<br />'; - - $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); - ?> - <tr> - <td> </td> - <td><a href="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$data['parent_id']; ?>">..</a></td> - <td> </td> - <td> </td> - <td> </td> - </tr> - <?php -} $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); while($data = $query->FetchRow()) @@ -682,7 +718,7 @@ $sum['size'] += $filestat['size']; $sum['files']++; } - + /** * owner and group name */ @@ -752,15 +788,15 @@ <?php if($data['img_type']==0) { - echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.$data['name'].'</a>'; + echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.htmlspecialchars($data['name'],ENT_QUOTES).'</a>'; } else { - echo $data['name']; + echo htmlspecialchars($data['name'],ENT_QUOTES); } ?> </td> - <td align="right"><?php echo ($data['img_type']==0 OR $data['img_type']==9999999) ? ' ' : niceFilesize($filestat['size'],1); ?></td> + <td align="right"><?php echo $data['img_type']==0 ? ' ' : niceFilesize($filestat['size'],1); ?></td> <td align="center"><?php echo strftime("%x %X",$filestat['mtime']); ?></td> <td align="center" title="<?php echo $owner_info['name'].' '.$group_info['name']; ?>"><?php echo $file_permissions; ?></td> </tr> @@ -799,6 +835,7 @@ if($isWriteAble) { ?> + ^ <a href="javascript:select_all()"><?php echo i18n("Select All"); ?></a> <input type="radio" id="file_rename" name="file_action" value="rename"<?php echo $arr_checked['rename']; ?> /><label for="file_rename"> <?php echo i18n("Rename"); ?></label> <input type="radio" id="file_move" name="file_action" value="move"<?php echo $arr_checked['move']; ?> /><label for="file_move"> <?php echo i18n("Move"); ?></label> <input type="radio" id="file_copy" name="file_action" value="copy"<?php echo $arr_checked['copy']; ?> /><label for="file_copy"> <?php echo i18n("Copy"); ?></label> @@ -815,17 +852,24 @@ <input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>" /> </form> -<br /><br /> +<br /> <h2><?php echo i18n("Upload Files"); ?></h2> <form method="POST" enctype="multipart/form-data" action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> -<?php echo i18n("Choose files you would like to upload. Choose desired action to accomplish upon succesful upload.").'<br />'; ?> -<?php echo i18n("Allowed filesize (each file!) maximum currently set in php.ini is:").' '.ini_get('upload_max_filesize').'<br />'; ?> -<br /> -<?php echo i18n("Note: You don't have to upload your images through this form. You can use whatever you want (ftp,scp,nfs,local,...). Just copy them to the albums folder."); ?> -<br /> +<?php +echo i18n("Choose files you would like to upload. Choose desired action to accomplish upon succesful upload."); +echo '<br />'; +echo i18n("Allowed filesize (each file!) maximum currently set in php.ini is:").' '.ini_get('upload_max_filesize'); +echo '<br />'; +if( $GLOBALS['linpha']->sql->isAdmin() ) +{ + echo i18n("Note: You should set post_max_size to a higher value than upload_max_filesize (currently set to:".' '.ini_get('post_max_size').")"); + echo '<br />'; + echo i18n("Note: You don't have to upload your images through this form. You can use whatever you want (ftp,scp,nfs,local,...). Just copy them to the albums folder."); + echo '<br />'; +} -<?php -$max_uploads = 5; +echo '<br />'; + for($i = 0; $i < $GLOBALS['linpha']->sql->config->value['plugins_filemanager_nruploads']; $i++) { echo '<input type="file" name="file'.$i.'" value="" /> '; @@ -841,7 +885,42 @@ ?> </div> +<script language="JavaScript" type="text/javascript"> +var is_checked = false; +function select_all() +{ + var input_forms = document.getElementsByTagName('input'); + // loop through all anchor tags + for (var i=0; i < input_forms.length; i++) + { + var anchor = input_forms[i]; + + if(anchor.type == 'checkbox') + { + if( is_checked ) + { + anchor.checked = false; + } + else + { + anchor.checked = true; + } + } + } + + if( is_checked ) + { + is_checked = false; + } + else + { + is_checked = true; + } +} +</script> + + <?php $linpha->template->output['filemanager'] = ob_get_clean(); ?> @@ -1016,4 +1095,40 @@ } } } + +/** + * recursively move files/folders + * check that only valid images/videos will be uploaded + * and not any malicious data (like php scripts etc.) + */ +function moveValidEntries( $source, $dest ) +{ + $dirHandle = dir( $source ); + while (false !== ($entry = $dirHandle->read())) + { + if($entry != '.' && $entry != '..') + { + if(is_dir($source .'/'. $entry)) + { + mkdir( $dest.'/'.$entry ); + moveValidEntries( $source .'/'. $entry, $dest .'/'. $entry ); + } + else + { + list($org_width, $org_height, $org_type) = LinIdentify::linGetImageSize( $source .'/'. $entry ); + + if( LinIdentify::isSupportedImage( $org_type ) OR LinIdentify::isVideo( $org_type ) ) + { + rename( $source .'/'. $entry, $dest .'/'. $entry); + } + else + { + unlink( $source .'/'. $entry ); + } + } + } + } + $dirHandle->close(); + rmdir( $source ); +} ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/basket.html.php =================================================================== --- trunk/linpha2/templates/default/basket.html.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/templates/default/basket.html.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -185,7 +185,7 @@ $i = 1; foreach($GLOBALS['linpha']->template->output['basket_folders'] AS $value) { - echo set_navigation_line($value).'<br />'; + echo setNavigationLine( $value, LINPHA_DIR.'/?cat=alb&id=' ).'<br />'; foreach($GLOBALS['linpha']->template->output['basket_folder_contents'][$value] AS $sub_value) { ?> Modified: trunk/linpha2/templates/default/view_img.html.php =================================================================== --- trunk/linpha2/templates/default/view_img.html.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/templates/default/view_img.html.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -70,9 +70,9 @@ <!-- show image comments --> <?php while($data = $GLOBALS['linpha']->template->output['image_comments']->FetchRow()) { ?> <div class="comments"> - <?php echo $data['meta_time']; ?> <?php echo $data['meta_author']; ?> + <?php echo $data['meta_time']; ?> <?php echo htmlspecialchars($data['meta_author'],ENT_QUOTES); ?> <br /> - <?php echo $data['meta_comment']; ?> + <?php echo htmlspecialchars($data['meta_comment'],ENT_QUOTES); ?> <br /><br /> </div> <?php } ?> Modified: trunk/linpha2/templates/default/view_meta.html.php =================================================================== --- trunk/linpha2/templates/default/view_meta.html.php 2006-04-28 19:08:11 UTC (rev 4552) +++ trunk/linpha2/templates/default/view_meta.html.php 2006-04-29 22:13:09 UTC (rev 4553) @@ -50,11 +50,11 @@ case 1: case 3: if(isset($meta_data['meta_data'])) { - $value = $meta_data['meta_data']; + $value = htmlspecialchars($meta_data['meta_data'],ENT_QUOTES); } else { $value = ''; } - echo '<input type="text" name="field['.$data['id'].']" value="'.$value.'" style="width: 200px;" maxlength="255"/>'; + echo '<input type="text" name="field['.$data['id'].']" value="'.$value.'" style="width: 200px;" maxlength="255" />'; break; case 2: if(isset($meta_data['meta_data'])) { @@ -76,7 +76,7 @@ $checked = ''; } - echo '<option value="'.$cat_data['id'].'"'.$checked.'>'.$cat_data['name'].'</option>'."\n"; + echo '<option value="'.$cat_data['id'].'"'.$checked.'>'.htmlspecialchars($cat_data['name'],ENT_QUOTES).'</option>'."\n"; } ?> </select> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bz...@us...> - 2006-07-09 18:46:35
|
Revision: 4554 Author: bzrudi Date: 2006-07-09 11:46:23 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4554&view=rev Log Message: ----------- fixed bug in sqlite install Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step7_selectprefix.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/ChangeLog 2006-07-09 18:46:23 UTC (rev 4554) @@ -1,3 +1,12 @@ +2006-07-09 bzrudi + * install: fixed bug in sqlite install - $_SESSION vars not inited and initial + directories (sql/tmp/cache) under /var not created. Moved some functions to + lib.install.php as we need them in different places. + This was caused because we skipped step 5+6 during install if using SQLlite + where vars and directories are inited... + * fixed bug in sql.sqlite.php (parse error, tables not created) + * tested install under MySQL 5.0.18 -> worked! :-) + 2006-04-29 flo * filemanager: implementing upload only images and videos, escape filenames correct (-> create a folder and file called "<script>" and you will find things which needs to be escaped) Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/lib.install.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -199,7 +199,7 @@ { if( ! installIsAbsolutePath( $path ) ) { - $path = realpath( $path ); + $path = str_ireplace("../", " ", $path ); } /** @@ -248,7 +248,8 @@ function installIsAbsolutePath($path) { if(substr($path,0,1) == '/' OR // string begins with a '/' -> absolut path - ((strpos($path, ':') !== false) AND (strpos( PHP_OS, 'WIN' ) !== FALSE)) // we are on windows and the string contains a ':' -> absolut path (c:/..) + ((strpos($path, ':') !== false) AND (strpos( PHP_OS, 'WIN' ) !== FALSE)) + // we are on windows and the string contains a ':' -> absolut path (c:/..) ) { // absolut path return true; } else { @@ -407,7 +408,117 @@ return $str; } +/** + * As we need this twice make it a method. This is because we skip steps + * 5+6 when using sqlite but still need to init values + * @author bzrudi + * @param none + * @return array $dirs + * @package filesys + */ +function initSessionValues() +{ +/** + * save settings from previous page into global $_SESSION var + */ + $array = array('album','sql','cache','tmp'); + foreach($array AS $value) + { + /** + * remove '/' if not already done + */ + $len = strlen( $_POST[$value.'_dir'] ); + $lastsign = substr( $_POST[$value.'_dir'], $len-1); + if($lastsign == '/' && $lastsign == '\\') + { + $_POST[$value.'_dir'] = substr($_POST[$value.'_dir'],0,$len-1); + } + /** + * save current value and append correct dir names + */ + $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; + + /** + * get correct dir names (take care of relativ and absolute paths, add + * LINPHA_DIR if necessary) + */ + $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); + } +return $dirs; +} +/** + * As we need this twice make it a method. This is because we skip steps + * 5+6 when using sqlite but still need to init directories below /var + * @author bzrudi + * @param none + * @return true|false + * @package filesys + */ +function initInitialDirectories($dirs) +{ +$init_ok = true; +echo tr("Creating Required Directories")."... "; + try + { + $array = array('sql','cache','tmp'); + foreach($array AS $value) + { + echo "<br /><br />".tr("Checking Directory").": ".$value."..."; + + if( file_exists( $dirs[$value] ) ) + { + /** + * oh oh, pay attention, only try to delete the folder on default values! + * if the users choose wrongly the albums folder, all images would be deleted.!!!! + */ + if( $_SESSION[$value.'_dir'] == 'var/'.$value) + { + echo warning_msg(); + echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; + if( installRm_rf( $dirs[$value] ) ) + { + echo success_msg(); + } + else + { + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); + } + } + else + { + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); + } + } + + echo "<br /> ".tr("Trying To Create Directory")."... "; + if( installMkdir_p( $dirs[$value] ) ) + { + echo success_msg(); + + if( ! is_writable( $dirs[$value] ) ) + { + echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); + } + } + else + { + throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); + } + + echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; + } + } + catch(Exception $error) + { + echo "Error: ".$error -> getMessage(); + $init_ok = false; + } + +return $init_ok; +} + + ?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -35,8 +35,8 @@ "password VARCHAR(32) NOT NULL default '' , " . "user_email VARCHAR(255) NOT NULL default '' , " . "display_name VARCHAR(255) NOT NULL default '' , " . - "stats_downloads INTEGER NOT NULL default '0'' , " . - "stats_downloads_size INTEGER NOT NULL default '0'' " . + "stats_downloads INTEGER NOT NULL default '0' , " . + "stats_downloads_size INTEGER NOT NULL default '0' " . ")", "CREATE TABLE ".$linpha_tables['groups']." ( ". "id INTEGER PRIMARY KEY, " . Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -70,7 +70,7 @@ <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="album_dir" size="30" value="<?php echo $album_dir; ?>"> </div> -(-> <?php echo installLinRealpath( installGetFullPath($album_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($album_dir) ) ?>) <br /><br /> <h2><?php echo tr("Warning: All Existing Subdirectories Will Be Deleted"); ?></h2> @@ -81,7 +81,7 @@ <input class="boxalignelement" type="text" id="check02" onKeyup="checkForm()" name="sql_dir" size="30" value="<?php echo $sql_dir; ?>"> </div> -(-> <?php echo installLinRealpath( installGetFullPath($sql_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($sql_dir) );?>) <br /><br /> <div class="boxalign"> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step5_getlogin.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -47,34 +47,11 @@ exit(); } -/** - * save settings from previous page - */ - $array = array('album', 'sql','cache','tmp'); - foreach($array AS $value) - { - /** - * remove '/' if not already done - */ - $len = strlen( $_POST[$value.'_dir'] ); - $lastsign = substr( $_POST[$value.'_dir'], $len-1); - if($lastsign == '/' && $lastsign == '\\') - { - $_POST[$value.'_dir'] = substr($_POST[$value.'_dir'],0,$len-1); - } + /** + * save settings from previous page + */ + $dirs = initSessionValues(); - /** - * save current value and append correct dir names - */ - $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; - - /** - * get correct dir names (take care of relativ and absolute paths, add - * LINPHA_DIR if necessary) - */ - $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); - } - /** * goto manual mode */ @@ -120,60 +97,8 @@ /** * checking sql, cache and tmp directory */ - try + if(initInitialDirectories($dirs) != true) { - $array = array('sql','cache','tmp'); - foreach($array AS $value) - { - echo "<br /><br />".tr("Checking Directory").": ".$value."..."; - - if( file_exists( $dirs[$value] ) ) - { - /** - * oh oh, pay attention, only try to delete the folder on default values! - * if the users choose wrongly the albums folder, all images would be deleted.!!!! - */ - if( $_SESSION[$value.'_dir'] == 'var/'.$value) - { - echo warning_msg(); - echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; - if( installRm_rf( $dirs[$value] ) ) - { - echo success_msg(); - } - else - { - throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); - } - } - else - { - throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); - } - } - - echo "<br /> ".tr("Trying To Create Directory")."... "; - if( installMkdir_p( $dirs[$value] ) ) - { - echo success_msg(); - - if( ! is_writable( $dirs[$value] ) ) - { - echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); - } - } - else - { - throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); - } - - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; - } - } - catch(Exception $error) - { - echo "Error: ".$error -> getMessage(); - $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); exit(); Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step7_selectprefix.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -130,43 +130,11 @@ } break; case "sqlite": + $dirs = initSessionValues(); + initInitialDirectories($dirs); echo tr("Testing File Connection")."<br /><br />"; echo tr("Connecting SQLite Database")."... "; - /** - * save settings from previous page - * this is required for sqlite only as we skip step 4-6 and therefore - * need to init values again here - */ - $array = array('album', 'sql','cache','tmp'); - foreach($array AS $value) - { - if( isset( $_POST[$value.'_dir'] ) ) - { - /** - * save correctly in session - */ - /** - * append '/' if not already done - */ - $len = strlen( $_POST[$value.'_dir'] ); - $lastsign = substr( $_POST[$value.'_dir'], $len-1); - if($lastsign != '/' && $lastsign != '\\') - { - $_POST[$value.'_dir'] .= '/'; - } - - /** - * save current value and append correct dir names - */ - $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; - } - - /** - * get correct dir names (take care of relativ and absolute paths, add - * LINPHA_DIR if necessary) - */ - $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); - } + if(file_exists(LINPHA_DIR.'/'.$_SESSION['sql_dir'].'/'.$_SESSION['sql_dbname'])) { echo failed_msg(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fan...@us...> - 2006-07-15 17:01:38
|
Revision: 4555 Author: fangehrn Date: 2006-07-15 10:01:25 -0700 (Sat, 15 Jul 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4555&view=rev Log Message: ----------- updated Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/install/lib.requirements.php trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/linpha.imgview.class.php trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/ChangeLog 2006-07-15 17:01:25 UTC (rev 4555) @@ -1,3 +1,14 @@ +2006-07-15 flo + * fixed bracket support detection during installation + if we use exec($str, $array_output=array(), $return_value=''); + it will always return empty $array_output and $return_value + + you have to initialize $array_output and $return_value before! + + $array_output = array(); $return_value = ''; + exec($str, $array_output, $return_value); + + 2006-07-09 bzrudi * install: fixed bug in sqlite install - $_SESSION vars not inited and initial directories (sql/tmp/cache) under /var not created. Moved some functions to Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/docs/dev/TODO.txt 2006-07-15 17:01:25 UTC (rev 4555) @@ -22,7 +22,7 @@ - Write IPTC/XMP entries - UTF-8 support - see also - https://sourceforge.net/forum/message.php?msg_id=3648731) + https://sourceforge.net/forum/message.php?msg_id=3648731 and https://sourceforge.net/forum/message.php?msg_id=3674100 @@ -35,6 +35,8 @@ - Admin - User Settings +- ImageMagick + - Bracket Support, enable by default, only if old version found, disable it, or require imagemagick > "6.1.4" Modified: trunk/linpha2/install/lib.requirements.php =================================================================== --- trunk/linpha2/install/lib.requirements.php 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/install/lib.requirements.php 2006-07-15 17:01:25 UTC (rev 4555) @@ -107,6 +107,7 @@ /** * now, we do an improved check */ + $arr=array(); $return_var=''; // do not this directly in exec() ! exec($array[1].$convert.' -help',$arr,$return_var); if(isset($return_var) && $return_var == 0) Modified: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-07-15 17:01:25 UTC (rev 4555) @@ -127,7 +127,7 @@ } $array_output=array(); $return_value=''; // do not this directly in exec() ! - exec($command,$array_output=Array(),$return_value=0); + exec($command,$array_output,$return_value); /** * chdir back Modified: trunk/linpha2/lib/classes/linpha.imgview.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/lib/classes/linpha.imgview.class.php 2006-07-15 17:01:25 UTC (rev 4555) @@ -309,8 +309,8 @@ $array_nr_links[] = Array('name' => $value, 'value' =>"javascript:set_nr_images('".$value."')"); } - $array_views_links[] = Array('name' => i18n('Normal'), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=thumb'); - $array_views_links[] = Array('name' => i18n('Detail'), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=thumbdetail'); + $array_views_links[] = Array('name' => i18n("Normal"), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=thumb'); + $array_views_links[] = Array('name' => i18n("Detail"), 'value' => $GLOBALS['linpha']->template->URL_full.'&view=thumbdetail'); $GLOBALS['linpha']->template->output['menu_More']['basket'] = Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-07-09 18:46:23 UTC (rev 4554) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-07-15 17:01:25 UTC (rev 4555) @@ -588,6 +588,7 @@ throw new Exception( sprintf( i18n("Unable to switch (chdir) to %s directory. File being processed: %s"), $tmpfolder, $thisfile[ 'name' ] ) ); } + $output=array(); $return_value=''; // do not this directly in exec() ! exec( $command, $output, $return_value ); chdir( $oldpwd ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |