Jump to content


EtoGalGallerie error...


  • You cannot reply to this topic
8 replies to this topic

#1 Chris Fancy

    Etomite Forum Fan

  • Member
  • Pip
  • 115 posts

Posted 07 June 2006 - 03:37 PM

Hi,

I get the folling error when implementing EtoGalGallerie

I have created /assets/galleries/ and made it "755" server writable
I have created a page and put [[EtoGalGallerie]] in it, but i get the following error...

Any help would be great.


P.S. I have installed "EtoGal" successfully before and it works great, but this one is driving me nuts...

Regards,
Chris.




« Error »
Etomite encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »

PHP error debug
Error: getimagesize(): Read error!
Error type/ Nr.: Warning - 2
File: /home/sites/wilkinsons.tv/public_html/etomite/index.php(578) : eval()'d code
Line: 127

Parser timing
MySQL: 0.0000 s s (0 Requests)
PHP: 0.0725 s s
Total: 0.0725 s s


#2 Hans

    Likes Etomite Forums!

  • Member
  • PipPip
  • 152 posts

Posted 07 June 2006 - 05:12 PM

Strange.. I had too this yesterday, only don't know if it had to do with the fact that I deleted all images (not via FTP but via the script) because I didn't visit the site in between.
Hans

#3 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2006 - 06:32 PM

Please read the thread at http://www.etomite.com/index.php?showtopic=4899&st=0

Your problems may well be caused by not having an image in the gallery. If you have got images in the correct gallery page, can you give me more details please; if you haven't, can you use etogal to put an image in the right gallery page please, and then let me know whetherthis has fixed the problem. If this is the issue, the nextr release has a fix.

note, just to be sure, you CANNOT use EtoGalGallery, EtoGalThumb, EtoGalList, EtoGalSrchForm without EtoGal becuase only EtoGal can put images into the galleries.

#4 Hans

    Likes Etomite Forums!

  • Member
  • PipPip
  • 152 posts

Posted 07 June 2006 - 07:46 PM

Everything works okay now that I have added new images tot EtoGal.
Cite: "temporarily remove the EtoGalGallery snippet call from the page, add an imge to the gallery for that page and reinstate the EtoGalGallery snippet"
from post http://www.etomite.c...indpost&p=32160
That worked.
I will post here if there are strange behaviours afterwards.
Thanks.
Hans

Edited by Hans, 07 June 2006 - 07:55 PM.


#5 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 07 June 2006 - 09:04 PM

Thanks Hans!

Hopefully you won't see any other problems, its a very specific error!

#6 Chris Fancy

    Etomite Forum Fan

  • Member
  • Pip
  • 115 posts

Posted 08 June 2006 - 10:27 PM

Mike,

I've enabled EtoGal without EtoGalGallery just to check what you said and I think it's something else... as i can't get the basics working as I have on many other sites with no problem... I get the error below...!

SELECT id,title,filename FROM `web16-etom_whfn`.etomite_etogal WHERE gal_alias='used_cdplayers' ORDER BY date DESC ;

See it here... http://www.wilkinsons.tv/etomite/index.php?id=68

Regards,


Further to my investigation this is the EtoGal that gives me the error:

/*
Add this gallery to any page by calling [[EtoGal]].
A folder with the name of the page alias will be created automatically in $path_to_galleries (the only thing you have to adjust - see below), and all pictures/thumbnails for this page's gallery will be uploaded/created in this folder. Database creation and everything else is taken care of automatically.

Access rights for managing the pictures (uploading, changing the title, deleting) are granted according to the (Etomite-) access rights of the page that the gallery is created on. This of course means, the user has to have logged in before (in the Etomite-Manager), for managing pictures.

There are the following options you can pass to the EtoGal-Snippet:

[[EtoGal?display=embedded]]	   no title/description will be displayed for the gallery (useful to embed it within some text on any page).
[[EtoGal?display=childgalleries]] it will display an overview of all galleries that exist in its children pages
If none of these are passed (which should be what you use most of the time), it displays gallery title, gallery description, pictures with their titles and if approbiate the manage-link. Just try it out ...

[[EtoGal?pics_in_a_row=2]]		to make it display 3 pictures in a row (default: 3)

[[EtoGal?max_dim=150]]			to specify the maximum dimension for thumbnail CREATION (default: 150)

or e. g. [[EtoGal?display=embedded&pics_in_a_row=4]] for more then one Option.
*/

// ----- Setting(s) ------
// Path where the galleries will be stored (you have to create it and make it writeable!)
$path_to_galleries="assets/galleries/";
// ---------------------

$mydb=$etomite->dbConfig['dbase'].".".$etomite->dbConfig['table_prefix'];
$pics_tbl = $mydb."etogal";


function getIntTableRows($handle, $fields="*", $from="", $where="", $sort="", $dir="ASC", $limit="") {
// function to get rows from ANY internal database table
  if($from=="") {
	return false;
  } else {
	$where = ($where != "") ? "WHERE $where" : "";
	$sort = ($sort != "") ? "ORDER BY $sort $dir" : "";
	$limit = ($limit != "") ? "LIMIT $limit" : "";
	$tbl = $from;
	$sql = "SELECT $fields FROM $tbl $where $sort $limit;";
	$result = $handle->dbQuery($sql);
	$resourceArray = array();
	for($i=0;$i<@$handle->recordCount($result);$i++)  {
	  array_push($resourceArray,@$handle->fetchRow($result));
	}
	return $resourceArray;
  }
}


$returnstring="";

if(!isset($pics_in_a_row)) $pics_in_a_row=3;
if(!isset($max_dim)) $max_dim=150;

// If gallery table has not been created yet, create it now:
$query=mysql_query("SELECT COUNT(*) FROM $pics_tbl");
if(!$query) {
  $sql="  CREATE TABLE $pics_tbl (
		  `id` int(10) unsigned NOT NULL auto_increment,
		  `gal_alias` varchar(50) NOT NULL,
		  `filename` varchar(50) NOT NULL,
		  `title` text NOT NULL,
		  `date` datetime NOT NULL,
		  PRIMARY KEY  (`id`)
		  ) TYPE=MyISAM AUTO_INCREMENT=1;";
  $query1=$etomite->dbQuery($sql);
}



if($display=="childgalleries") {
  $pageinfo=$etomite->getPageInfo($etomite->documentIdentifier,1, "id, pagetitle, description, alias, createdby");
  $children = $etomite->getActiveChildren($pageinfo['id'], "menuindex", "ASC", $fields='id, pagetitle, longtitle, description, parent, alias');
  $returnstring.="<table border=\"0\" width=\"100%\">";

  $number_in_row=0;
  $total_number=0;
  foreach($children as $child) {
	$thumb=getIntTableRows($etomite,"filename", $pics_tbl, "gal_alias='" . $child['alias'] . "'","date","DESC","1");
	if($thumb[0]['filename']=="") continue;
	if($number_in_row==0) {
	  $returnstring.="<tr>";
	}
	$childself = $this->config['friendly_urls']==1 ? $child['alias'] : "index.php?id=".$child['id'];

	$returnstring.="
	  <td align=\"center\" style=\"width:" . floor(100/$pics_in_a_row) . "%\">
	  <a href=\"".$childself."\">
	  <img src=\"".$path_to_galleries.$child['alias']."/tn_".$thumb[0]['filename']."\" class=\"thumbnail\" title=\"Go to gallery ->\" alt=\"Preview of gallery\" />
	  </a>
	  <br/>" . htmlentities(stripslashes($child['pagetitle'])) . "</td>";

	if($number_in_row==($pics_in_a_row-1) || $total_number==count($children)) {
	  $returnstring.="</tr>";
	  $number_in_row=-1;
	}
	$number_in_row++;
	$total_number++;
  }

  $returnstring.="</table>";
  return $returnstring;
}



$pageinfo=$etomite->getPageInfo($etomite->documentIdentifier,1, "id, pagetitle, longtitle, description, alias, createdby");
$path_to_gal=$path_to_galleries.$pageinfo['alias']."/";

$phpself = $this->config['friendly_urls']==1 ? $pageinfo['alias'] : "index.php?id=".$pageinfo['id'];
$append = $this->config['friendly_urls']==1 ? "?" : "&";

// figure out access permissions of the user viewing this page
$userdetails=$etomite->userLoggedIn();
if($userdetails['id']) {
  // check whether user is allowed to modify this page (-> $result1=1)
  $rs1=$etomite->dbQuery("SELECT * FROM (" . $mydb . "member_groups JOIN " . $mydb . "membergroup_access ON user_group=membergroup) JOIN " . $mydb . "document_groups ON documentgroup=document_group WHERE member='" . $userdetails['id'] . "' and document='" . $etomite->documentIdentifier . "'");
  $result1=mysql_num_rows($rs1);

  // check if user is administrator (-> $result2=1)
  $rs2=$etomite->dbQuery("SELECT * FROM " . $mydb . "user_attributes WHERE id='" . $userdetails['id'] . "' AND role='1'");
  $result2=mysql_num_rows($rs2);

  if($result1>0 || $result2>0) $access_permitted=1;
  else $access_permitted=0;
}
else $access_permitted=0;



function createthumb($filename,$path_to_gal,$max_dim) {
  // Create thumbnails
  $src=imagecreatefromjpeg($path_to_gal.$filename);
  $src_size = getimagesize( $path_to_gal.$filename );

  if($src_size[0]>$src_size[1]) { //if width > height
	$new_width=$max_dim;
	$new_height=$src_size[1]*($new_width/$src_size[0]);
  }

  else {
	$new_height=$max_dim;
	$new_width=$src_size[0]*($new_height/$src_size[1]);
  }
  $dest=imagecreatetruecolor($new_width,$new_height);
  imagecopyresized($dest,$src,0,0,0,0,$new_width,$new_height,$src_size[0],$src_size[1]);
  imagejpeg($dest,$path_to_gal."tn_".$filename);
}





if($access_permitted==1) {
  if($_REQUEST['mode']=="admin") {  // if user is allowed to modify and has entered admin mode:
	// Processors -----------------
	if($_REQUEST['action']=="upload_pics") {	// If "Upload pictures" has been used
	  if(!file_exists($path_to_gal)) {
		mkdir($path_to_gal);
	  }
	  for($i=0;$i<10;$i++) {
		$name=strtolower($_FILES['file'.$i]['name']);
		if (file_exists($path_to_gal.$name)) { $name="a" . $name; }
		if($name!="" && $name!="a") {
		  // Upload file(s) to gallery folder
		  if(substr_count($name,".jpg")>0 || substr_count($name,".jpeg")>0) {
			move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $path_to_gal.$name );
			chmod($path_to_gal.$name,0644);
			createthumb($name,$path_to_gal,$max_dim);
			$rs1=$etomite->dbQuery("INSERT INTO " . $pics_tbl . " VALUES(NULL,'" . $pageinfo['alias'] . "','" . $name . "','',NOW())");
		  }

		  if(substr_count($name,".zip")>0) {
			move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $path_to_gal.$name );
			chmod($path_to_gal.$name,0644);

			$zip = zip_open($path_to_gal.$name);

			if ($zip) {
			  while ($zip_entry = zip_read($zip)) {
				$jpgfilename=strtolower(zip_entry_name($zip_entry));
				if (file_exists($path_to_gal.$jpgfilename)) { $jpgfilename="a" . $jpgfilename; }
				if (zip_entry_open($zip, $zip_entry, "r")) {
				  $jpgfile=fopen($path_to_gal.$jpgfilename,"a+b");
				  fwrite($jpgfile,zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
				  fclose($jpgfile);
				  createthumb($jpgfilename,$path_to_gal,$max_dim);
				  $rs1=$etomite->dbQuery("INSERT INTO " . $pics_tbl . " VALUES(NULL,'" . $pageinfo['alias'] . "','" . $jpgfilename . "','',NOW())");
				  zip_entry_close($zip_entry);
				}
			  }
			  zip_close($zip);
			}
			unlink($path_to_gal.$name);
		  }
		}
	  }
	  $returnstring.="Pictures successfully uploaded.";
	}
  

	if($_REQUEST['action']=="edit_pics") {	// If "Edit Gallery and its pictures" has been used
	  for($i=0;$i<$_REQUEST['number'];$i++) {
		if($_REQUEST['delete'.$i]=="yes") {
		  $rs0=$etomite->dbQuery("SELECT id,filename FROM $pics_tbl WHERE id='" . $_REQUEST['pic_id'.$i] . "'");
		  $deletepic=$etomite->fetchRow($rs0);
		  unlink($path_to_gal.$deletepic['filename']);
		  unlink($path_to_gal . "tn_" . $deletepic['filename']);
		  $rs1=$etomite->dbQuery("DELETE FROM $pics_tbl WHERE id='" . $_REQUEST['pic_id'.$i] . "'");
		}
		if($_REQUEST['modified'.$i]=="yes") {
		  $rs2=$etomite->dbQuery("UPDATE " . $pics_tbl . " SET title='" . addslashes($_REQUEST['title'.$i]) . "',date=NOW() WHERE id='" . $_REQUEST['pic_id'.$i] . "'");
		}
	  }
	  $returnstring.="Changes have been saved.";
	}

	// Forms -----------
	// Edit gallery and its pictures
	$returnstring.="
	<form action=\"".$phpself."\" method=\"post\" name=\"activateviewform\">
	<input type=\"hidden\" name=\"mode\" value=\"view\">
	<center><input type=\"submit\" value=\"Back to normal view\"></center>
	</form>";
	$returnstring.="<h2>" . htmlentities($pageinfo['pagetitle']) . "</h2>";
	$returnstring.="<p style=\"padding-left:4px;\">" . htmlentities($pageinfo['description']) . "</p>
	<form action=\"".$phpself."\" method=\"post\" name=\"editform\">
	<input type=\"hidden\" name=\"action\" value=\"edit_pics\">
	<input type=\"hidden\" name=\"mode\" value=\"admin\">
	<input type=\"submit\" value=\"Save changes\">
	<table border=\"0\">
	";
  
	$rs1=$etomite->dbQuery("SELECT id,title,filename FROM " . $pics_tbl . " WHERE gal_alias='" . $pageinfo['alias'] . "' ORDER BY date DESC");
  
	$i=0;
	while($pic=$etomite->fetchRow($rs1)) {
	  $file = $path_to_gal.$pic['filename'];
	  $tn_file = $path_to_gal . "tn_" . $pic['filename'];
  
	  $returnstring.="
	  <input type=\"hidden\" name=\"pic_id$i\" value=\"" . $pic['id'] . "\">
	  <input type=\"hidden\" name=\"modified$i\" value=\"no\">
	  <tr>
		<td><a href=\"$file\" target=_new><img src=\"$tn_file\" class=\"thumbnail\" alt=\"Thumbnail: Click to zoom ->\" /></a></td>
		<td>Delete: <input type=\"checkbox\" name=\"delete$i\" value=\"yes\" title=\"Check to delete this picture\"></td>
		<td>Title: <textarea name=\"title$i\" rows=\"3\" cols=\"30\" onKeyDown=\"document.editform.modified$i.value='yes'\">" . stripslashes($pic['title']) . "</textarea></td>
	  </tr>
	  ";
	  $i++;
	}
	$returnstring.="
	</table>
	<input type=\"hidden\" name=\"number\" value=\"$i\">
	<input type=\"submit\" value=\"Save changes\">
	</form>
	<form action=\"".$phpself."\" method=\"post\" enctype=\"multipart/form-data\" name=\"uploadform\">
	<input type=\"hidden\" name=\"action\" value=\"upload_pics\">
	<input type=\"hidden\" name=\"mode\" value=\"admin\">
	";
	for($i=0;$i<10;$i++) $returnstring.="<input name=\"file$i\" type=\"file\">";
	$returnstring.="
	<input type=\"submit\" value=\"Upload Pictures\">
	</form>
	";

	return $returnstring;
  }

  
  else { // if user is allowed to modify, but has not entered admin mode yet
	$returnstring.="
	<form action=\"".$phpself."\" method=\"post\" name=\"activateadminform\">
	<input type=\"hidden\" name=\"mode\" value=\"admin\">
	<center><input type=\"submit\" value=\"Manage Pictures\"></center>
	</form>
	";
  }
}



if ($_REQUEST['pic']) { // Show single Pic
  $pics=getIntTableRows($etomite,"title,filename", $pics_tbl, "id='" . $_REQUEST['pic'] . "'");

  $returnstring.="
  <p style=\"padding-left:10px;\">
	<a href=\"".$phpself."\">" . htmlentities($pageinfo['pagetitle']) . "</a> »
	<a href=\"" . $path_to_gal . $pics[0]['filename'] . "\" target=_blank>" . htmlentities($pics[0]['filename']) . "</a>
  </p>";

  $returnstring.="
  <center>
	<a href=\"".$phpself."\"><img src=\"" . $path_to_gal.$pics[0]['filename'] . "\" class=\"imageview\" title=\"<- Back\" alt=\"<- Click to go back\" /></a><br/>
  <p>" . htmlentities(stripslashes($pics[0]['title'])) . "</p></center>
  ";
}

else { // Show gallery overview with thumbnails
  if(!$display=="embedded") {
	$returnstring.="
	<h2>" . htmlentities($pageinfo['pagetitle']) . "</h2>";
	$returnstring.="
	<p style=\"padding-left:4px;\">" . htmlentities($pageinfo['description']) . "</p>";
  }

  $returnstring.="
  <table border=\"0\" width=\"100%\">";

  $pics=getIntTableRows($etomite,"id,title,filename", $pics_tbl, "gal_alias='" . $pageinfo['alias'] . "'","date","DESC");
  $number_in_row=0;
  $total_number=0;
  foreach($pics as $pic) {
	$file = $path_to_gal . $pic['filename'];
	$tn_file = $path_to_gal . "tn_" . $pic['filename'];

	if($number_in_row==0) {
	  $returnstring.="<tr>";
	}

	$link=($display==embedded) ? ($file) : ($phpself.$append."pic=" . $pic['id']);
	$returnstring.="
	<td align=\"center\" style=\"width:" . floor(100/$pics_in_a_row) . "%\">
	  <a href=\"" . $link . "\"><img src=\"$tn_file\" class=\"thumbnail\" title=\"Zoom ->\" alt=\"Click to zoom ->\" /></a><br/>
	  " . htmlentities(stripslashes($pic['title'])) . "
	</td>";

	if($number_in_row==($pics_in_a_row-1) || $total_number==(count($pics)-1)) {
	  $returnstring.="
	  </tr>";
	  $number_in_row=-1;
	}
	$number_in_row++;
	$total_number++;
  }
  $returnstring.="
  </table>";
}


return $returnstring;


... and this is the EtoGal that doesn't give me the error but I don't get any Manage buttons...!

[code]
//
// to fix
// handle alternate charsets (for churchyard)
//
// etogal version 1.1 beta 3
// Fixes
// 14/04/06: MySQL 3.x compatibility: Join replaced by Left Join
// 29/04/06: 'Save Changes' string corrected for internationalisation
// 6 May : added prefix of EG to class names to avoid conflicts (EGthumbnail and EGimageview)
// 7 may : fix descriptions handling in is_target display (contributed by doze)
// generate URLs using makeURL (tested with FURLs)
//
// Additions
// 29/04/06:
// quality low, medium or high (low is the original Etogal setting, high mikef's improved quality)
// delete 0 or 1 (0=only administrators can delete images)
// display additional option of 'none' gives no image display, only manage button or management functions (when valid)
//
// this version retains the EtoGal 1.0 database table structure
// ----- Setting(s) ------
// Path where the galleries will be stored (you have to create it and make it writeable!)
$path_to_galleries="assets/galleries/";
// -----------------------

// etoGal is copyright 2005-2006 Frank Siegert and Mike Finley
// and is available under the GPL licence

// Internationalization
$strings['previous']="« previous";
$strings['index']="Index";
$strings['next']="next »";
$strings['click_to_zoom']=" (Click to zoom ->)";
$strings['click_to_go_back']="<- Click to go back";
$strings['back_to_normal_view']="Back to normal view";
$strings['no_more_pictures_found_return_to']="No more pictures found. Return to ";
$strings['go_to_gallery']="Go to gallery ->";
$strings['pictures_successfully_uploaded']="Pictures successfully uploaded.";
$strings['changes_have_been_saved']="Changes have been saved.";
$strings['delete']="Delete";
$strings['title']="Title";
$strings['save_changes']="Save changes";
$strings['upload_pictures']="Upload pictures";
$strings['check_to_delete_this_picture']="Check to delete this picture";
$strings['manage_pictures']="Manage Pictures";
$strings['date']="Date";
$strings['description']="Description";
$strings['database_no_description_support']="<em>This database table does not permit the use of picture descriptions!</em><br />";

/*
// German
$strings['previous']="« vorheriges";
$strings['index']="Index";
$strings['next']="nächstes »";
$strings['click_to_zoom']="Zoom ->";
$strings['click_to_go_back']="<- Back";
$strings['back_to_normal_view']="Normalansicht";
$strings['no_more_pictures_found_return_to']="Keine weiteren Bilder gefunden. Zurück zu ";
$strings['go_to_gallery']="Galerie anschauen ->";
$strings['pictures_successfully_uploaded']="Bilder erfolgreich hochgeladen.";
$strings['changes_have_been_saved']="Änderungen gespeichert.";
$strings['delete']="Löschen";
$strings['title']="Titel";
$strings['save_changes']="Änderungen speichern";
$strings['upload_pictures']="Bilder hochladen";
$strings['check_to_delete_this_picture']="Ankreuzen, um Bild zu löschen";
$strings['manage_pictures']="Bilderverwaltung";
$strings['date']="Datum";
$strings['description']="Beschreibung";
$strings['database_no_description_support']="<em>Diese Datenbank unterstützt die Verwendung von Beschreibungen nicht.</em><br />";
*/

// set parameters
if(!isset($pics_in_a_row)) $pics_in_a_row=3;
if(!isset($max_thumb_size)) $max_thumb_size=150;
if(!isset($max_pic_size)) $max_pic_size=800;
if(!isset($order_by)) $order_by="date";
if(!isset($order_direction)) $order_direction="DESC";
if(!isset($gtable)) $gtable="etogal";
// new
if (!isset($quality)) $quality="low"; //"medium" probably a better choice, but "low" mtaches the original etoGal
if (!isset($delete)) $delete=1; //default to delete enabled (0 implies only admins can delete)

// image functions
function createthumb($filename,$path_to_gal,$max_thumb_size,$prefix="") {
// Create resized images
$src=imagecreatefromjpeg($path_to_gal.$filename);
$src_size = getimagesize( $path_to_gal.$filename );

if($src_size[0]>$src_size[1]) { //if width > height
$new_width=$max_thumb_size;
$new_height=$src_size[1]*($new_width/$src_size[0]);
} else {
$new_height=$max_thumb_size;
$new_width=$src_size[0]*($new_height/$src_size[1]);
}
$dest=imagecreatetruecolor($new_width,$new_height);
if ($quality=="low") {
imagecopyresized($dest,$src,0,0,0,0,$new_width,$new_height,$src_size[0],$src_size[1]);
} else {
imagecopyresampled($dest,$src,0,0,0,0,$new_width,$new_height,$src_size[0],$src_size[1]);
}
if ($quality=="high") {
imagejpeg($dest,$path_to_gal.$prefix.$filename, 100);
} else {
imagejpeg($dest,$path_to_gal.$prefix.$filename);
}
}

// access control functions
// shared data
global $canEdit, $canAdd, $canDelete, $access_permitted;
$canEdit = 0;
$canAdd = 0;
$canDelete = $delete;
$access_permitted = 0;

function checkPermissions()
{
global $etomite, $access_permitted, $canDelete;
// figure out access permissions of the user viewing this page
$userdetails=$etomite->userLoggedIn();
if($userdetails['id']) {
// check whether user is allowed to modify this page
$rs1=$etomite->dbQuery("SELECT * FROM (" . $etomite->db . "member_groups LEFT JOIN " . $etomite->db . "membergroup_access ON user_group=membergroup) LEFT JOIN " . $etomite->db . "document_groups ON documentgroup=document_group WHERE member='" . $userdetails['id'] . "' and document='" . $etomite->documentIdentifier . "'");
if (mysql_num_rows($rs1)) {
$access_permitted=1;
$canEdit=1;
}
// check if user is administrator (more efficient if this is first test ...)
$rs2=$etomite->dbQuery("SELECT * FROM " . $etomite->db . "user_attributes WHERE id='" . $userdetails['id'] . "' AND role='1'");
if(mysql_num_rows($rs2)) {
$access_permitted=1;
$canAdd=1;
$canEdit=1;
// $canDelete=1;
}
}
// return $access_permitted;
}

// retrieve data from etomite
$pageinfo=$etomite->getPageInfo($etomite->documentIdentifier,1, "id, pagetitle, longtitle, description, alias, createdby");
$path_to_gal=$path_to_galleries.$pageinfo['id']."/";
//$phpself="index.php?id=".$pageinfo['id'];
$phpself=$etomite->makeURL($pageinfo['id']);
if (strpos($phpself,"?")) $sep="&"; else $sep="?";

// check for table and descriptions
$pics_tbl = $etomite->db.$gtable;
// If gallery table has not been created yet, create it now:
$descvalid = 0; // assume descriptions not supported
$query=mysql_query("DESC $pics_tbl");
if(!$query) {
$sql="CREATE TABLE $pics_tbl (
`id` int(10) unsigned NOT NULL auto_increment,
`gal_id` int(10) unsigned NOT NULL,
`filename` varchar(50) NOT NULL,
`title` text NOT NULL,
`date` datetime NOT NULL,
`descr` text default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1;";
$query1=$etomite->dbQuery($sql);
$descvalid = 1; // they are with this table
}
else {
//test for the descr field
for($i=0;$i<$this->recordCount($query);$i++) {
$temprow=@$this->fetchRow($query, 'assoc');
if ($temprow["Field"]=="descr") {
$descvalid=1;
break;
}
}
if($descvalid==0) { // If no descr-field there: add it.
$query2=@$etomite->dbQuery("ALTER TABLE $pics_tbl ADD `descr` TEXT DEFAULT NULL;");
if($query2) { $descvalid=1; }
}
}



if($is_target=="yes" && $_REQUEST['gal_id']) { // only display the picture of another gallery
if ($_REQUEST['pic']) {
$pics=$etomite->getIntTableRows("id,title,filename,descr", $gtable, "gal_id='" . $_REQUEST['gal_id'] . "'", $order_by, $order_direction);

$i=0;
foreach($pics as $pic) {
if($pic['id']==$_REQUEST['pic']) {
$current=$i;
break;
}
$i++;
}
$returnstring.="
<p style='text-align:center;'>
<a href='".$phpself.$sep."pic=".$pics[$i-1]['id']."&gal_id=".$_REQUEST['gal_id']."'>" . $strings['previous'] . "</a> |
<a href='".$etomite->makeURL($_REQUEST['gal_id'])."'>". $strings['index'] . "</a> |
<a href='".$phpself.$sep."pic=".$pics[$i+1]['id']."&gal_id=".$_REQUEST['gal_id']."'>" . $strings['next'] . "</a>
</p>
<center>
<a href='".$etomite->makeURL($_REQUEST['gal_id'])."'><img src='" . $path_to_galleries.$_REQUEST['gal_id']."/".$pics[$i]['filename'] . "' class='EGimageview' title='".$strings['click_to_go_back']."' alt='".$strings['click_to_go_back']."' /></a><br/>
<p><b>" . htmlentities(stripslashes($pics[$i]['title'])) . "</b></p>";
if ($descvalid==1) $returnstring .= "<p>" . stripslashes($pics[$i]['descr']) . "</p>";
$returnstring .= "</center>";
}
else {
$returnstring.="<center>" . $strings['no_more_pictures_found_return_to'] . "<a href='".$etomite->makeURL($_REQUEST['gal_id'])."'>" . $strings['index'] . "</a></center>";
}
return $returnstring;
}

if($display=="childgalleries") {
$pageinfo=$etomite->getPageInfo($etomite->documentIdentifier,1, "id, pagetitle, description, alias, createdby");
$children = $etomite->getActiveChildren($pageinfo['id'], "menuindex", "ASC", $fields='id, pagetitle, longtitle, description, parent, alias');
$returnstring.="<table border=\"0\" width=\"100%\">";

$number_in_row=0;
$total_number=0;
foreach($children as $child) {
$thumb=$etomite->getIntTableRows("filename", $gtable, "gal_id='" . $child['id'] . "'",$order_by,$order_direction,"1");
if($thumb[0]['filename']=="") continue;
if($number_in_row==0) {
$returnstring.="<tr>";
}
$childself = "index.php?id=".$child['id']; //MF removed use of alias

$returnstring.="
<td align=\"center\" style=\"width:" . floor(100/$pics_in_a_row) . "%\">
<a href=\"".$childself."\">
<img src=\"".$path_to_galleries.$child['id']."/tn_".$thumb[0]['filename']."\" class=\"EGthumbnail\" title=\"" .$strings['go_to_gallery'] . "\" alt=\"" . $strings['go_to_gallery'] . "\" />
</a>
<br/>" . htmlentities(stripslashes($child['pagetitle'])) . "</td>";

if($number_in_row==($pics_in_a_row-1) || $total_number==count($children)) {
$returnstring.="</tr>";
$number_in_row=-1;
}
$number_in_row++;
$total_number++;
}

$returnstring.="</table>";
return $returnstring;
}

//************************************* begin admin block

// figure out access permissions of the user viewing this page
checkPermissions();

//at present we neither create nor use all access codes - only specific test is for delete capability
if($access_permitted==1) {
if($_REQUEST['mode']=="admin") { // if user is allowed to modify and has entered admin mode:
if($descvalid==0) $returnstring.=$strings['database_no_description_support']; //MF 2005
/* Processors -----------------*/
if($_REQUEST['action']=="upload_pics") { // If "Upload pictures" has been used
if(!file_exists($path_to_gal)) {
mkdir($path_to_gal);
chmod($path_to_gal,0777);
}
for($i=0;$i<10;$i++) { // for each of the ten upload fields:
$name=strtolower($_FILES['file'.$i]['name']);
if (file_exists($path_to_gal.$name)) { $name="a" . $name; }
if($name!="" && $name!="a") {
// Upload file(s) to gallery folder
//if(substr_count($name,".jpg")>0 || substr_count($name,".jpeg")>0) {
if(substr($name,-4)==".jpg" || substr($name,-5)==".jpeg") {
move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $path_to_gal.$name );
chmod($path_to_gal.$name,0666);
$pic_date = "NOW()";
// Read EXIF information
if(function_exists("exif_read_data")) {
$exif = exif_read_data($path_to_gal.$name, 0, true);
if(array_key_exists("EXIF", $exif)) {
$pic_date = " '".$exif["EXIF"]["DateTimeOriginal"]."' ";
}
}

createthumb($name,$path_to_gal,$max_thumb_size,"tn_");
$imagesize=getimagesize($path_to_gal.$name);
if($max_pic_size>0 && ($imagesize[0]>$max_pic_size || $imagesize[1]>$max_pic_size)) {
createthumb($name,$path_to_gal,$max_pic_size);
}
$rs1=$etomite->dbQuery("INSERT INTO " . $pics_tbl . "(id, gal_id, filename, title, date) VALUES(NULL,'" . $pageinfo['id'] . "','" . $name . "',''," . $pic_date . ")"); //MF Oct2005
}

//if(substr_count($name,".zip")>0) {
if(substr($name,-4)==".zip") {
move_uploaded_file( $_FILES['file'.$i]['tmp_name'] , $path_to_gal.$name );
chmod($path_to_gal.$name,0644);

$zip = zip_open($path_to_gal.$name);

if ($zip) {
while ($zip_entry = zip_read($zip)) {
$jpgfilename=strtolower(zip_entry_name($zip_entry));
if (file_exists($path_to_gal.$jpgfilename)) { $jpgfilename="a" . $jpgfilename; }
if (zip_entry_open($zip, $zip_entry, "r")) {
$jpgfile=fopen($path_to_gal.$jpgfilename,"a+b");
fwrite($jpgfile,zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
fclose($jpgfile);
$imagesize=getimagesize($path_to_gal.$jpgfilename);
if($max_pic_size>0 && ($imagesize[0]>$max_pic_size || $imagesize[1]>$max_pic_size)) {
createthumb($jpgfilename,$path_to_gal,$max_pic_size);
}

$pic_date = "NOW()";
// Read EXIF information
if(function_exists("exif_read_data")) {
$exif = exif_read_data($path_to_gal.$jpgfilename, 0, true);
if(array_key_exists("EXIF", $exif)) {
$pic_date = " '".$exif["EXIF"]["DateTimeOriginal"]."' ";
}
}

createthumb($jpgfilename,$path_to_gal,$max_thumb_size,"tn_");
$rs1=$etomite->dbQuery("INSERT INTO " . $pics_tbl . " (id, gal_id, filename, title, date)VALUES(NULL,'" . $pageinfo['id'] . "','" . $jpgfilename . "',''," . $pic_date . ")"); //MF Oct2005
zip_entry_close($zip_entry);
}
}
zip_close($zip);
}
unlink($path_to_gal.$name);
}



}
}
$returnstring.=$strings['pictures_successfully_uploaded'];
}


if($_REQUEST['action']=="edit_pics") { // If "Edit Gallery and its pictures" has been used
for($i=0;$i<$_REQUEST['number'];$i++) {
if($_REQUEST['delete'.$i]=="yes") {
$rs0=$etomite->dbQuery("SELECT id,filename FROM $pics_tbl WHERE id='" . $_REQUEST['pic_id'.$i] . "'");
$deletepic=$etomite->fetchRow($rs0);
if(file_exists($path_to_gal.$deletepic['filename'])) unlink($path_to_gal.$deletepic['filename']);
if(file_exists($path_to_gal."tn_".$deletepic['filename'])) unlink($path_to_gal . "tn_" . $deletepic['filename']);
$rs1=$etomite->dbQuery("DELETE FROM $pics_tbl WHERE id='" . $_REQUEST['pic_id'.$i] . "'");
}
if($_REQUEST['modified'.$i]=="yes") {
// restructured for clarity and extended MF oct2005
$updateQueryString= "UPDATE ".$pics_tbl." SET ";
$updateQueryString.= "title='".addslashes($_REQUEST['title'.$i])."'"; //add title content
if($keep_date!="yes") $updateQueryString.=",date=NOW()";
if($descvalid==1) $updateQueryString.=", descr='".addslashes($_REQUEST['descr'.$i])."'"; //MF add descr content
$updateQueryString.=" WHERE id='" .$_REQUEST['pic_id'.$i]."'";
$rs2=$etomite->dbQuery( $updateQueryString );
}
}
$returnstring.=$strings['changes_have_been_saved'];
}

/* Forms ----------- */
// Edit gallery and its pictures
$returnstring.="
<form action=\"".$phpself."\" method=\"post�

Edited by Chris Fancy, 08 June 2006 - 10:35 PM.


#7 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 08 June 2006 - 11:25 PM

The first version of Etogal you've listed is very old and obsolete. Its incompatible with any of the later snippets, as the database format was changed. It was left available when the new version ws created, as its compatible with Etomite 0.6. The later versions require Etomite 0.6.1.

If you're not getting a manager button with the other one, are you using a login snippet for the user (NOT logging in to the manager)? If you aren't please read Etogal 1.1 snippet - features and usage which explains what is needed and how to set it up.

#8 Chris Fancy

    Etomite Forum Fan

  • Member
  • Pip
  • 115 posts

Posted 09 June 2006 - 01:53 AM

Yoooohhhh...!!! :D :D

Sorted it...!

What a great snippet, Thanks Mike.

I tried what you said it works great, check it out

I'm going to try and format it to look like EtoGalGallery Exclusive from your demo site.... when my brian stops throbin' :blink:

Regards,

Edited by Chris Fancy, 10 June 2006 - 07:01 PM.


#9 mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 09 June 2006 - 09:37 AM

View PostChris Fancy, on Jun 9 2006, 02:53 AM, said:

I'm going to try and format it to look like EtoGalGallery Exclusive from your demo site.... when my brian stops throbin' :blink:
You'll find that hard work at the moment ... the functionality isn't in the released snippet!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users