automatic thumbnail gallery generator compile problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iano
Forum Newbie
Posts: 7
Joined: Fri Jan 09, 2004 6:24 am

automatic thumbnail gallery generator compile problems

Post by iano »

I get the following error message when i include the file
Parse error: parse error, expecting `']'' in gallery/thumbgallery.txt on line 176

line 176 is the following:
$HTTP_GET_VARS[$this->page] = 0;

can anyone get this code to run properly? Thanks heaps guys!

the whole file is:
<?
class autogallery {

function autogallery($path="cache",$src="gallery",$tpl="gallery/frame.png" ) {

$this->path = $path;
$this->src = $src;
$this->tpl = $tpl;

$this->page = 'p';
$this->gallery = 'g';
$this->prefix = sprintf('%s_',substr(md5($this->src ), 0, 6 ) );
$this->idxfile = sprintf('_%s.txt',md5($this->src ) );

$this->resize();
$this->checkup();
}
}


function resize() {
$d = dir($this->src );

while($entry=$d->read() ) {
if(eregi(".+\.jpe?g$", $entry )) {


if (!file_exists("{$this->path}/_{$this->prefix}{$entry}")) {
$src = ImageCreateFromJPEG("{$d->path}/{$entry}");

$org_h = imagesy($src);
$org_w = imagesx($src);

if ($org_h > $org_w) {
$cfg['height'] = 120;
$cfg['width'] = floor ($cfg['height'] * $org_w / $org_h);

$cfg['dstX'] = 60 - ($cfg['width'] * 0.5);
$cfg['dstY'] = 0;
} else {
$cfg['width'] = 120;
$cfg['height'] = floor ($cfg['width'] * $org_h / $org_w);

$cfg['dstX'] = 0;
$cfg['dstY'] = 60 - ($cfg['height'] * 0.5);
}

$img = ImageCreateFromPNG ($this->tpl);

ImageCopyResized ($img, $src, $cfg['dstX'],
$cfg['dstY'], 0, 0, $cfg['width'],
$cfg['height'], $org_w, $org_h );
ImgeJPEG ($img, "{$this->path}/_{$this->prefix}{$entry}", 90);

ImageDestroy ($img);
ImageDestroy ($src);

if (!strstr (join ('', file ("{$this->path}/{$this->idxfile}")), $entry)) {

$fp = fopen("{$this->path}/{$this->idxfile}", "a+");

$str = "_{$this->prefix}{$entry}, $entry, $org_w, $org_h\n";
fwrite ($fp, $str, strlen($str));

fclose($fp);

} // End of index records check

} // End of check for previous thumbnail file

} // End of check for a file ending in .jp(e)g

} // End of While loop

$d->close();

} // End of resize() function





function checkup() {
$idx = file("{$this->path}/{$this->idxfile}" );
$i=0;

$d = dir($this->src );
while($entry=$d->read() ) {
$ref_idx .= "$entry,";
}
$d->close();

for($f = 0; $f < count($idx); $f++) {
$items = explode(",", $idx[$f] );
if(strstr($ref_idx, trim($items[1]) )) {
$new_idx[$i] = trim($idx[$f])."\n";
$i++;
} else {
if(file_exists("{$this->path}/{$items[0]}"))
unlink("{$this->path}/{$items[0]}");
}
}
}

$fp = fopen("{$this->path}/{$this->idxfile}", "w+" );
for($k = 0; $k < count($new_idx); $k++) {
fwrite($fp, trim($new_idx[$k])."\n",
strlen(trim($new_idx[$k])."\n"));
}
fclose($fp);





function url($var="page", $addon="" ) {
global $HTTP_GET_VARS;
$q = $HTTP_GET_VARS;

if(is_array($q)) {
unset($q[$var]);
foreach($q as $key => $val ) {
$str .= "$key=$val&";
}
return $str . $addon;
} else {
return $addon;
}
}





function show_jscript ($pagetitle = "autogallery")
{
global $SERVER_NAME, $SERVER_PORT, $PHP_SELF;

$host = "http://{$SERVER_NAME}".
($SERVER_PORT == 80 ? '' : ":{$SERVER_PORT}").
(strlen($PHP_SELF)
? str_replace(basename($PHP_SELF), '', $PHP_SELF )
: ''
);

$str = <<< EOS
<script language="JavaScript">
<!--
function popup (img,sx,sy,num)
{
image = "<a href='javascript:self.close()'><img src=" + img + " border=0 alt='Click to Close'></a>";
popupwin=window.open("", "image_"+num, "toolbar=no, location=no, directories=no, status=no, menubar=no, top=10, left=10, width="+sx+", height="+sy+"");
popupwin.document.write("<HTML><HEAD><TITLE>{$pagetitle}</TITLE><BASE HREF="{$host}"></HEAD> <BODY BGCOLOR=#FFFFFF><CENTER>" + image + "</CENTER></BODY></HTML>");
popupwin.document.close();
}

function go_menu(menu)
{
choice = menu.selectedIndex;
if (menu.options[choice].value != "") {
window.location.href =
menu.options[choice].value;
}
// -->
</script>EOS;

return $str;
}


function select_gallery ($multiple = array())
{
global $HTTP_GET_VARS;

// reset page-index to page 1
$HTTP_GET_VARS[$this->page] = 0;

// construct selection-form
$str = <<<EOS
<form name="navigator" method="get">
<select name=navMenu DEFANGED_STYLE="width:150; font:9pt"
onChange="return go_menu(navigator.navMenu);"
size="1">
<option selected>select ...</option>EOS;

for ($i = 1; $i <= count($multiple); $i++) {
$str .= "<option value='?".
$this->url($this->gallery,
"{$this->gallery}={$i}").
"'>{$multiple[$i][3]}</option>\n";

}
$str .= "</select>\n";
$str .= "</form>\n\n";
return $str;
}




function thumbnail_table($cols=3, $rows=3, $multiple=array() ) {
global $HTTP_GET_VARS, $PHP_SELF, $QUERY_STRING;


$idx = file("$this->path/$this->idxfile");
$cfg['start'] = $HTTP_GET_VARS[$this->page] * $cols * $rows;
$cfg['stop'] = ($HTTP_GET_VARS[$this->page]+1) * $cols * $rows;

$table .= "<table border='0' cellpadding='10' cellspacing='0'
align='center'><tr>";
$table .= "<tr><td colspan='$cols' align='right'>" .
$this->select_gallery($multiple ).'</td><tr>";

for($j = $cfg['start']; $j < $cfg['stop']; $j++, ++$k ) {
$itemlist = explode(',', $idx[$j] );

$table .= "<td bgcolor='#CC0033'>";
$table .= "<a href=\"javascript:popup('{$this->src}/{$itemlist[1]}',";
$table .= ($itemlist[2] + 20). ',';
$table .= $itemlist[3]+20. ",$j);\">";
$table .= "<img src='{$this->path}/{$itemlist[0]}' alt='Click'
border='0'></a>";
$table .= "</td>",
if ($k >= $cols) {
$table .= "</tr>\n<tr>\n";
$k = 0;
}
} /* End of the for loop */


$table .= "</tr><tr><td colspan='$cols'>";
for($n=0, $l=0; $n<count($idx); $n=$n+($cols*$rows) )
$table .= sprintf("<a href='?%s'>%s</a>", $this-
>url($this->page, "{$this->page}=$l" ), ++$l );

$table .= '</td></tr></table>';

return $table;
} /* End of the thumbnail_table() function */

?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

shouel the line not be

Code: Select all

$HTTP_GET_VARS['$this->page'] = 0;
Mark
iano
Forum Newbie
Posts: 7
Joined: Fri Jan 09, 2004 6:24 am

Post by iano »

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in gallery/thumbgallery.txt on line 176

This is what i get if I change it to what you suggested
Post Reply