Randon-pictures block from a standalone COPPERMINE installation Randon-pictures block from a standalone COPPERMINE installation
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Randon-pictures block from a standalone COPPERMINE installation

Started by moschos, December 10, 2004, 11:47:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

moschos

Hello..!! Three days now I am trying to make block-random-pictures.php to run without errors but without luck.. I have a standalone installation of Coppermine 1.3.2 in my site http://www.nuked.gr/cpg132/ and I want to display radom pictures from the Gallery to my main page (phpnuke based) on http://www.nuked.gr
I modified block-random-pic.php to include the load.init from the cpg132 standalone installation but now I am getting the error :

Parse error: parse error, unexpected T_STRING in /home/jnukedag/public_html/blocks/block-Random_pictures.php on line 55

The code I try to make it work (I LOAD IT AS A BLOCK FROM THE ADMINISTRATOR BLOCK PAGE) is the following :

<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* 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.       */
/************************************************************************/

/* Block to fit perfectly in the center of the site, remember that not all
   blocks looks good on Center, just try and see yourself what fits your needs */

if (eregi("block-Random_pictures.php", $PHP_SELF)) {
    Header("Location: index.php");
    die();
}

require('/home/nuked/public_html/cpg132/include/init.inc.php');
$numberpic=5; // you can change the number of pictures here
global $prefix, $dbi;

function truncate_string444($str)
{
   $maxlength = 20; // maximum lenght of name in block
   
   if (strlen($str) > $maxlength)
      return substr($str, 0, $maxlength)." ...";
   else
      return $str;
}

$content="<center>";
$result = sql_query("SELECT count(*) from cpg_pictures", $dbi);
   $nbEnr = mysql_fetch_array($result);
   $count = $nbEnr[0];

while ($stop<$numberpic)
{
   srand(time()+$stop);
   $random_number = rand(0, $count-1);
   $result2 = sql_query("SELECT pid, aid, filepath, filename  from cpg_pictures WHERE approved='YES' LIMIT $random_number,1", $dbi);
  $picture = mysql_fetch_array($result2);
 
   $img = "<img src=\"{$picture['filepath']}thumb_{$picture['filename']}\"  border=\"0\">";
   $content .= "<a href=\"http://www.nuked.gr/cpg132/displayimage.php&album=random&cat=&pos=-{$picture['pid']}\">$img<br>" . truncate_string444($picture['filename']) . "</a><br><br>";

$stop++;
}
?>


ANY HELP WILL BE MUCH MUCH APPRECIATED..!! Thanks a lot !

kegobeer

1.  Check for empty space after the closing ?>.  The code you posted only has 54 lines, but your error message says line 55.

2.  Try this:
<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* 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.       */
/************************************************************************/

/* Block to fit perfectly in the center of the site, remember that not all
   blocks looks good on Center, just try and see yourself what fits your needs */

if (eregi("block-Random_pictures.php"$PHP_SELF)) {
    
Header("Location: index.php");
    die();
}

require(
'/home/nuked/public_html/cpg132/include/init.inc.php');
$numberpic=5// you can change the number of pictures here
global $prefix$dbi;

function 
truncate_string444($str)
{
   
$maxlength 20// maximum lenght of name in block
   
   
if (strlen($str) > $maxlength)
      return 
substr($str0$maxlength)." ...";
   else
      return 
$str;
}

$content="<center>";
$result sql_query("SELECT count(*) from cpg_pictures"$dbi);
   
$nbEnr mysql_fetch_array($result);
   
$count $nbEnr;

while (
$stop<$numberpic)
{
   
srand(time()+$stop);
   
$random_number rand(0$count-1);
   
$result2 sql_query("SELECT pid, aid, filepath, filename  from cpg_pictures WHERE approved='YES' LIMIT $random_number,1"$dbi);
   
$picture mysql_fetch_array($result2);
 
   
$img '<img src="' $picture['filepath'] . 'thumb_' $picture['filename'] . '"  border="0">';
   
$content .= '<a href="http://www.nuked.gr/cpg132/displayimage.php&album=random&cat=&pos=-' $picture['pid'] . '">' $img '<br>' truncate_string444($picture['filename']) . '</a><br><br>';

   
$stop++;
}
?>


A side note - you should post your PHP code using the insert code button.
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

Joachim Müller

Obviously you're using the nuke port of coppermine, which goes unsupported here. Please read the sticky on the deprecated nuke support board I'm moving this thread to.

Joachim

Edit by kegobeer: Joachim, he has the standalone gallery but wants to display random images on his nuke site.  This should be moved back to the original post location.  Also, can you give me permissions to reply to threads on this board?

Joachim Müller

oops, sorry. Moving the thread back to where it was originally posted.

@Kegobeer: I didn't realize you don't have permissions to reply here, will change permissions asap.

Joachim