Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

invalid arguments for the "foreach()" method in se

 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Blocks View previous topicPrinter friendly versionView next topic
Author Message
gregwun

Beginner
Beginner


Joined: Aug 04, 2003
Posts: 5

PostPosted: Mon Aug 04, 2003 6:26 pm    Post subject: invalid arguments for the "foreach()" method in se Reply with quote

I get an error and want to replace the code on my gallery sessions.php page on/around the line that registers the complaint with
$_HTTP_SESSION_VARS ==> $_SESSION

Here is the error: Warning: Invalid argument supplied for foreach() in /home/sites/site32/web/nuking/html/modules/gallery/session.php on line 55

Here is the code I see in the sessions.php page:

53 /* emulate register_globals for sessions */
54 if (!$gallery->register_globals) {
55 foreach($HTTP_SESSION_VARS as $key => $value) {
56 eval("\$$key = & \$HTTP_SESSION_VARS[\"$key\"];");
57 }
58 }
59
60 /*

Could you give me a bit more detail on how to replace the code? Actually, could you post the code so I can just copy it?
thanks

Cobalt RaQ4
PHP 4.06
Gallery URL : http://www.lowpressurehawaii.com/nuking ... s/gallery/
Gallery version: 1.3.4.
Apache version: Apache/1.3.20 Sun Cobalt (Unix) mod_jk/1.1.0 mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.0.6 mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25 
PHP version (don't just say PHP 4, please):
Graphics Toolkit: Netpbm
Operating system: Mac
Web browser/version (if applicable): IE 5.0
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: invalid arguments for the "foreach()" method in se  

Back to top
fluentdesigns

User
User


Joined: Jul 31, 2003
Posts: 38

PostPosted: Mon Aug 04, 2003 6:45 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

im getting the exact error
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Mon Aug 04, 2003 7:34 pm    Post subject: Reply with quote

please search the forums, this has been answered numerous times before.

on lines 55 and 56, replace $HTTP_SESSION_VARS with $_SESSION

that will solve the problem.
Back to top
Offline View user's profile Send private message Visit poster's website
gregwun

Beginner
Beginner


Joined: Aug 04, 2003
Posts: 5

PostPosted: Tue Aug 05, 2003 1:45 am    Post subject: Reply with quote

Thanks for your help.
But I still get the error.

Maybe I need a bit of background. It's confusing to me that there is a Improved Random script and a Random Script. I have phpnuke 6.0 and Gallery 1.3.4 so can I use the Improved script?

If I can use the Improved Random script, does changing the $HTTP_SESSION_VARS TO $_SESSION rid me of the "Warning: Invalid argument supplied for foreach() in /home/sites/site32/web/" error? Do I have to restart my browser or my computer or what?

While using the older unimproved Random Block that that I downloaded from this site. I replaced the $HTTP_SESSION_VARS to $_SESSION (The one that has two files named block_random.php) and got a parse error exactly like this: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/sites/site32/web/nuking/html/modules/gallery/session.php on line 56.

I got the session.php code below from the help file on your site.
/* emulate register_globals for sessions */
if (!$gallery->register_globals) {
foreach($_SESSION as $key => $value) {
eval("$$key = & $_SESSION["$key"];");
}
}
It doesn't look like the code that I would Have if I replaced $HTTP_SESSION_VARS with $_SESSION like instructed above....What is up? You see there are a bunch of extra \\ s in there...
/* emulate register_globals for sessions */
if (!$gallery->register_globals) {
foreach($_SESSION as $key => $value) {
eval("\$$key = & \$_SESSION[\"$key\"];");
}
}

However both don't work... any help would be appreciated. Meanwhile I'll be searching the forum for clues.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Tue Aug 05, 2003 7:30 am    Post subject: Reply with quote

this is the chunk of code you want:
Code: ›
/* emulate register_globals for sessions */
if (!$gallery->register_globals) {
    foreach($_SESSION as $key => $value) {
        eval("\$$key = & \$_SESSION[\"$key\"];");
    }
}


copy that EXACT chunk of code and replace the corresponding line in your session.php file.

the two random block files are totally different. the original just does a random photo. period. if all you want is a random photo each time your users view the page you can grab this one.
the improved random block also does a photo of the hour and photo of the day. READ the articles associated with each block file for the information on what they do.
Back to top
Offline View user's profile Send private message Visit poster's website
gregwun

Beginner
Beginner


Joined: Aug 04, 2003
Posts: 5

PostPosted: Tue Aug 05, 2003 4:24 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

I've got the Improved Random Gallery with an edited sessions.php page uploaded into the gallery directory. I still get the invalid arguments for the "foreach()" method in ...line 55. The block seems to be working except for the warning.

Is there something I'm missing? Do I have to delete my cookies, exit the browser, or delete and reload the block?

Here is my sessions.php code :
Code: ›
<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2003 Bharat Mediratta
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
?>
<?php
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
      !empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
      !empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
   print "Security violation\n";
   exit;
}
?>
<?php
/*
 * PHP 4.0.1pl2 introduces a bug where you can't unserialize a
 * stdClass instance correctly.  So create a dummy class to hold all
 * of our session data.
 */
class GallerySession {}

if (session_id()) {
   /*
    * The session is being created externally.  This means that if
    * we store our data in a GallerySession class, we won't be able
    * to deserialize it (because it's not being defined before the
    * external session starts).  So, we'll have to fall back on using
    * stdClass() which will cause problems on older PHP4 servers.
    * oh well.
    */
   $useStdClass = 1;
}

/* Start a new session, or resume our current one */
session_start();

/* emulate register_globals for sessions */
if (!$gallery->register_globals) {
    foreach($_SESSION as $key => $value) {
        eval("\$$key = & \$_SESSION[\"$key\"];");
    }
}

/*
 * Are we resuming an existing session?  Determine this by checking
 * to see if the session container variable is already set.  If not, then
 * create the appropriate container for it.
 */
$sessionVar = $gallery->app->sessionVar . "_" . md5($gallery->app->userDir);
session_register($sessionVar);

if (isset($$sessionVar)) {
   /* Get a simple reference to the session container (for convenience) */
   $gallery->session =& $$sessionVar;

   /* Make sure our session is current.  If not, nuke it and restart. */
   /* Disabled this code -- it has too many repercussions */
   if (false) {
       if (strcmp($gallery->session->version, $gallery->version)) {
      session_destroy();
      header("Location: index.php");
      exit;
       }
   }
} else {
   /* Register the session variable */
   session_register($sessionVar);

   /* Create a new session container */
   if ($useStdClass) {
      $$sessionVar = new stdClass();
   } else {
      $$sessionVar = new GallerySession();
   }

   /* Get a simple reference to the session container (for convenience) */
   $gallery->session =& $$sessionVar;

   /* Tag this session with the gallery version */
   $gallery->session->version = $gallery->version;
}

update_session_var("albumName");
update_session_var("version");
update_session_var("albumListPage");
update_session_var("fullOnly");
update_session_var("username", 1);
update_session_var("offline");
update_session_var("offlineAlbums");
if (!isset($gallery->session->offlineAlbums) || $gallery->session->offlineAlbums == null)
{
      $gallery->session->offlineAlbums=array();
}

/*
 * Process changes to session variables via parameters submitted in a
 * POST or GET.
 */
function update_session_var($name, $protected=0) {
   global $gallery;

   // If this is a protected session variable, don't allow it
   // to be changed by data from POST or GET requests.
   if ($protected) {
      return;
   }

   $setname = "set_$name";
   if (!emptyFormVar($setname)) {
      $gallery->session->{$name} = formVar($setname);
   }
}
?>


Maybe it just doesn't work with my version of php which I think is 4.0.6.

Any suggestions? Thanks.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Tue Aug 05, 2003 7:33 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

yes, your PHP is 4.0.6.
your session.php looks fine. i would get a fresh install and overwrite your gallery files.
Back to top
Offline View user's profile Send private message Visit poster's website
gregwun

Beginner
Beginner


Joined: Aug 04, 2003
Posts: 5

PostPosted: Thu Aug 07, 2003 6:50 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

I reinstalled Gallery. I got a internal server error while trying to access the gallery's configuration wizard. I had to add this...
<Directory "/path/to/your/gallery/directory">
AllowOverride Options FileInfo
</Directory>
to my access.conf file which is located in /etc/httpd/conf/ . (My data center said that for Cobalts it's better to update that file rather than the httpd.conf file). I stopped and restarted httpd to get it that to work. I could then run the gallery setup wizard. I even tested the gallery's test page and it passed the sessions test.

I uploaded the random_support.php into the gallery directory and the block_random.php into the blocks directory. I activated the block. ... And got the error.... My last resort was to upload my edited sessions.php with$_SESSIONS replacing $_HTTP_SESSION_VARS on line 55 and 56. Expecting success and got denied....

I still get the "invalid arguments for the "foreach()" method" error....
Any ideas? Thanks in advance.
Back to top
Offline View user's profile Send private message
gregwun

Beginner
Beginner


Joined: Aug 04, 2003
Posts: 5

PostPosted: Fri Aug 08, 2003 4:48 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

Eureka! It's fixed!

I added this code
Code: › global $gallery;


to the top of the block_random.php just after <?php
So the top of the block_random.php looks like this:
Code: › <?php
global $gallery;


I found that solution in dari's post related to fluentdesigns post.

Ok... bye. And thanks dari.

Oh, and one more thing.... Since I'm using an Apple Mac I had to use the "save as" option "unix" on all the pages i edited using bbedit.
Back to top
Offline View user's profile Send private message
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Fri Aug 08, 2003 5:39 pm    Post subject: Re: invalid arguments for the "foreach()" method i Reply with quote

gregwun wrote: › Oh, and one more thing.... Since I'm using an Apple Mac I had to use the "save as" option "unix" on all the pages i edited using bbedit.


I am also MAC based but I use Golive as my HTML editor so I don't get any unix problems. It's caused by carriage returns I believe!

The worse thing with MAC is the limit on filename lengths (os9), especially on GALLERY HTML template directory where a few of the .tpl files are renamed! Confused
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Blocks View previous topicPrinter friendly versionView next topic

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Dedicated ServersDomain NamesWeb HostingDomain Name RegistrationDedicated Web HostingWeb Design New YorkCompare VoIPseo packagesSEO CompanyNew York Yellow PagesFind LocationsVOIP Phone ServiceNeckermannOnline internetSEORestaurant Locator • Get great HP coupons from CouponSnapshot • Search for great dell coupons at CouponSnapshot.com.au • Graduation DressesAndroid TabletSEO IndiaBuy Phen375fuel filterWorld Meds Direct

8th year online! 2003-2011
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia