I am trying to embed gallery into YaBBSE. I'm starting this by first getting it to use my templates.... a typical page on my site would be like this
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
<?php
$title="A Typical Page";
include ('/home/www/html/template/topnew.php');
<B>Main Content of Page</B>
include ('/home/www/html/template/bottomnew.php');
?>
</TD></TR></TABLE><!-- BBCode End -->
After a bit of reading I tried to add this in init.php (so it doesn't get over written)
$GALLERY_EMBEDDED_INSIDE = "mysite";
and then in wrapper.header I added
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
case "mysite":
$title="gallery page";
include ('/home/www/html/template/topnew.php');
break;
</TD></TR></TABLE><!-- BBCode End -->
This topnew.php file does a bunch of things. It checks if the user is logged into mysite via cookies and outputs top and left nav html. I'm having the problem (I think) that gallery has already sent the headers, and then wrapper.header includes my topnew.php which tries to check cookies etc. and it fails giving me errors...
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
Warning: Cannot modify header information - headers already sent by (output started at /home/www/html/gallery/albums.php:32) in /home/www/html/forum/Sources/Load.php on line 48
Warning: Cannot modify header information - headers already sent by (output started at /home/www/html/gallery/albums.php:32) in /home/www/html/forum/Sources/Load.php on line 49
Warning: Cannot modify header information - headers already sent by (output started at /home/www/html/gallery/albums.php:32) in /home/www/html/forum/Sources/Load.php on line 50
Warning: Cannot modify header information - headers already sent by (output started at /home/www/html/gallery/albums.php:32) in /home/www/html/forum/Sources/Load.php on line 51
</TD></TR></TABLE><!-- BBCode End -->
Other errors that are happening....
- its not using mod_rewrite any more - the full path is displayed
- the login does not show up any more....
Am I missing something? Do I need to prevent gallery from creating a session or sending headers?
Posts: 18
Ok, I got most of these issues solved through hacking of files rather than using the wrapper (had to put cookie and session info in init.php)
My question now is, is there a good reason that Mod Rewrite gets turned off when you embed?
And second, is it possible to recursivly change ownership of albums? (perl script?)
Posts: 3474
1)
There's a good reason. Embedded URLs are complicated and inconsistent, and Nuke actually forbids them by default. That said, it can be done (though I don't speak from personal experience). Search the Customization and Nuke forums.
I did a quick search to get you started in the right direction:
http://gallery.sf.net/forums.php?topic=5364
http://gallery.sf.net/forums.php?topic=879
2)
Well you *could* write a Perl script. You'd be better off (and have an easier time) writing a PHP script and utilising the Gallery API. If you want to write a mass-permissions editor page for us, we'll gladly put it into Gallery! :smile: Until such a feature gets written though, you'll have to go one at a time.
-Beckett (
)
Posts: 18
I haxored the edit_all_props script that I found floating around. I commented out all the changes it was making and added this
$gallery->album->setOwner(3);
I may clean it up so each option has a checkbox and you can select the owner UID from a list if I get a chance. But this worked nicely.
(not cleaned up - but did change all the owners in this case to a user with UID 3
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> <?php
/*
* edit_all_properties.php: Change settings for multiple albums
* By Beckett Madden-Woods (beck@beckettmw.com)
*
* Version 0.1
* November 25, 2002
*
* Adaptation for:
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2002 Bharat Mediratta
* http://gallery.sourceforge.net/
*
*/
/* Hack prevention. */
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
print "Security violation
";
exit;
}
require($GALLERY_BASEDIR . "init.php");
/* defines */
define("LOAD_PHOTOS", TRUE);
define("DONT_LOAD_PHOTOS", FALSE);
define("INCLUDE_HIDDEN", TRUE);
$albumDB = new AlbumDB(LOAD_PHOTOS);
/* scan album for sub-albums */
function scanAlbum($albumName) {
global $gallery;
global $albumDB;
$album = $albumDB->getAlbumbyName($albumName);
$numPhotos = $album->numPhotos(INCLUDE_HIDDEN);
for ($i = 1; $i <= $numPhotos; $i++) {
$nestedAlbum = $album->isAlbumName($i);
if ($nestedAlbum) {
print "<tr><td></td><td align="left">
" .
"<table border="0" cellpadding="0" cellspacing="0">" .
"<tr><td align="center" class="fineprint">" .
"<input type="checkbox" name="gall[]" value="$nestedAlbum"" .
" checked /></td><td align="left" class="fineprint">" .
"$nestedAlbum</td></tr>
";
scanAlbum($nestedAlbum);
print "</table></td></tr>
";
}
}
}
?>
<html>
<head>
<title>Edit Properties</title>
<?php echo getStyleSheetLink() ?>
</head>
<body>
<?php
/* change properties */
if ($save) {
print "<center><b>Changing Album Properties</b></center><br /><br />
";
foreach ($gall as $albumName) {
$gallery->album = $albumDB->getAlbumbyName($albumName);
print "<b>Album:</b> $albumName<br />
";
if (!$gallery->user->canWriteToAlbum($gallery->album)) {
print "<span class="error"><b>Error: </b>" .
"You cannot write to this album!</span><br />
";
}
else {
/* $gallery->album->fields["bgcolor"] = $bgcolor;
$gallery->album->fields["textcolor"] = $textcolor;
$gallery->album->fields["linkcolor"] = $linkcolor;
$gallery->album->fields["font"] = $font;
$gallery->album->fields["bordercolor"] = $bordercolor;
$gallery->album->fields["border"] = $border;
$gallery->album->fields["background"] = $background;
$gallery->album->fields["thumb_size"] = $thumb_size;
$gallery->album->fields["resize_size"] = $resize_size;
$gallery->album->fields["returnto"] = $returnto;
$gallery->album->fields["rows"] = $rows;
$gallery->album->fields["cols"] = $cols;
$gallery->album->fields["fit_to_window"] = $fit_to_window;
$gallery->album->fields["use_fullOnly"] = $use_fullOnly;
$gallery->album->fields["print_photos"] = $print_photos;
$gallery->album->fields["use_exif"] = $use_exif;
$gallery->album->fields["display_clicks"] = $display_clicks;
$gallery->album->fields["public_comments"] = $public_comments; */
$gallery->album->setOwner(3);
$gallery->album->save();
}
}
print "<br />
";
print "<center><form>" .
"<input type="submit" value="Dismiss" onClick="opener.location.reload(); parent.close();">" .
"</form></center><br />
";
print "</body></html>";
exit;
}
?>
<script language="javascript">
// <!--
function setCheck(val) {
ufne=document.theform;
len = ufne.elements.length;
for(i = 0 ; i < len ; i++) {
if (ufne.elements[i].name==&#039;gall[]&#039;) {
ufne.elements[i].checked=val;
}
}
}
function invertCheck() {
ufne=document.theform;
len = ufne.elements.length;
for(i = 0 ; i < len ; i++) {
if (ufne.elements[i].name==&#039;gall[]&#039;) {
ufne.elements[i].checked = !(ufne.elements[i].checked);
}
}
}
// -->
</script>
<center>
<b>Edit Properties</b><br /><br />
<?php
print "<table border="0" cellpadding="0" cellspacing="0">
";
/* print out albums with checkboxes */
print "<tr><td width="50%" valign="top">
";
echo makeFormIntro("edit_all_owners.php",
array("name" => "theform",
"method" => "POST"));
print '<input type="hidden" name="save" value="TRUE">' . "
";
print "<table border="0" cellpadding="0" cellspacing="0">
";
print '<tr><td align="center" colspan="3" class="fineprint">'
. '<a href="javascript:setCheck(1)">Check All</a> - '
. '<a href="javascript:setCheck(0)">Clear All</a> - '
. '<a href="javascript:invertCheck()">Invert Selection</a>'
. "</td></tr>
";
print "<tr><td align="center" class="fineprint" " .
"style="font-weight: bold;"> </td><td align="left" " .
"class="fineprint" style="font-weight: bold;">Album Name" .
"</td><td align="center" class="fineprint" style="" .
"font-weight: bold;">Owner</td></tr>
";
$numAlbums = $albumDB->numAlbums($gallery->user);
$noAlbums = 1;
for ($i=1; $i <= $numAlbums; $i++) {
$gallery->album = $albumDB->getAlbum($gallery->user, $i);
$albumName = $gallery->album->fields["name"];
$isRoot = $gallery->album->isRoot();
if ($isRoot) {
$owner = $gallery->album->getOwner();
$user = $owner->getUsername();
}
else {
$user = " ";
}
if ($gallery->user->canWriteToAlbum($gallery->album)) {
$noAlbums = 0;
print "<tr><td align="center" class="fineprint">" .
"<input type="checkbox" name="gall[]" value="$albumName"" .
" checked /></td><td align="left" class="fineprint">" .
"$albumName</td><td align="center" " .
"class="fineprint">$user</td></tr>
";
/* scan album for sub-albums */
scanAlbum($albumName);
}
}
print "</table>
";
/* if no editable albums, print an error message */
if ($noAlbums) {
print "<span class="error"><b>You cannot edit any albums!</b>" .
"</span><br />
";
}
print "</td>
";
?>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="fineprint">Background Color</td>
<td class="fineprint"><input type=text name="bgcolor" value="<?php echo $gallery->album->fields["bgcolor"]?>"></td>
</tr>
<tr>
<td class="fineprint">Text Color</td>
<td class="fineprint"><input type=text name="textcolor" value="<?php echo $gallery->album->fields["textcolor"]?>"></td>
</tr>
<tr>
<td class="fineprint">Link Color</td>
<td class="fineprint"><input type=text name="linkcolor" value="<?php echo $gallery->album->fields["linkcolor"]?>"></td>
</tr>
<tr>
<td class="fineprint">Background Image (URL)</td>
<td class="fineprint"><input type=text name="background" value="<?php echo $gallery->album->fields["background"]?>"></td>
</tr>
<tr>
<td class="fineprint">Font</td>
<td class="fineprint"><input type=text name="font" value="<?php echo $gallery->album->fields["font"]?>"></td>
</tr>
<tr>
<td class="fineprint">Borders</td>
<td class="fineprint"><select name="border">
<?php
foreach (array("off", 1, 2, 3, 4) as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["border"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Border color</td>
<td class="fineprint"><input type=text name="bordercolor" value="<?php echo $gallery->app->default["bordercolor"]?>"></td>
</tr>
<tr>
<td class="fineprint">Thumbnail size</td>
<td class="fineprint"><input type=text name="thumb_size" value="<?php echo $gallery->app->default["thumb_size"]?>"></td>
</tr>
<tr>
<td class="fineprint">Auto-Resize</td>
<td class="fineprint"><select name="resize_size">
<?
foreach (array("off", 400, 500, 600, 640, 700, 800, 1024) as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["resize_size"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Show <i>Return to</i> link</td>
<td class="fineprint"><select name="returnto">
<?
foreach (array("yes", "no") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["returnto"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Rows</td>
<td class="fineprint"><select name="rows">
<?
foreach (array(1, 2, 3, 4, 5, 6, 7, 8, 9) as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["rows"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Columns</td>
<td class="fineprint"><select name="cols">
<?
foreach (array(1, 2, 3, 4, 5, 6, 7, 8, 9) as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["cols"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Auto fit-to-window for<br>images without a resized copy</td>
<td class="fineprint"><select name="fit_to_window">
<?
foreach (array("yes", "no") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["fit_to_window"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Offer visitors ability to specify<br>preference for full-size or resized images</td>
<td class="fineprint"><select name="use_fullOnly">
<?
foreach (array("yes", "no") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["use_fullOnly"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Which photo printing service<br>do you want to let visitors use?</td>
<td class="fineprint"><select name="print_photos">
<?
foreach (array("none", "shutterfly") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["print_photos"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<?php
if ($gallery->app->use_exif) {
?>
<tr>
<td class="fineprint">Display EXIF data?</td>
<td class="fineprint"><select name="use_exif"><?php echo selectOptions($gallery->album, "use_exif", array("no", "yes")) ?></select></td>
</tr>
<?php
} // end if
?>
<tr>
<td class="fineprint">Display click counter for this album?</td>
<td class="fineprint"><select name="display_clicks">
<?
foreach (array("yes", "no") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["display_clicks"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
<tr>
<td class="fineprint">Allow public commenting for photos in this album?</td>
<td class="fineprint"><select name="public_comments">
<?
foreach (array("yes", "no") as $opt) {
$sel = "";
if (!strcmp($opt, $gallery->app->default["public_comments"])) {
$sel = " selected";
}
echo "<option$sel>$opt";
}
?>
</select></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<br />
<input type=submit name="submit" value="Apply">
<input type=reset value="Undo">
<input type=submit name="submit" value="Close" onclick='parent.close()'>
</form>
<script language="javascript1.2">
<!--
// position cursor in top form field
document.theform.bgcolor.focus();
//-->
</script>
</body>
</html>
</TD></TR></TABLE><!-- BBCode End -->
Posts: 3474
Cool! Right... I'd forgotten about that script.
Maybe getting this working wouldn't be that hard, if you work off of this script.
I'd write it, but it'd be pretty low on my todo list.
Ideally, it would be possible to edit all the permissions, not just the owner. :smile: