Author Topic: I hate this error: Warning: Invalid argument supplied for foreach()  (Read 6446 times)

0 Members and 1 Guest are viewing this topic.

Offline AntiNSA2

  • Hero Member
  • *****
  • Posts: 774
  • As long as I can finish my site before I die.
    • View Profile
    • http://www.thelifephotography.com
Warning: Invalid argument supplied for foreach() in /home/cyberfan/htdocs/4images/includes/page_header.php on line 224
 which is:
Code: [Select]
foreach ($rss->items as $item) {

This is part of a rss mod that is no longer on the board. The thing is the mod works great. I have no idea why I get the error... it pauses my page from loading...

the rss mod is one of the coolest thing on my site no way I can kill it... but it seems as though this is because of some simple common error?  I appreciate any help you can give.

Thanks-
Robert
Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: page_header.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7                                                  *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) f&#40693; weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die(
"Security violation");
}

// Cache Templates
$template_list 'header,footer,category_dropdown_form,user_logininfo,user_loginform';
if (isset(
$templates_used) && $templates_used != "") {
  
$template_list $template_list.",".$templates_used;
}
$site_template->cache_templates($template_list);

//-----------------------------------------------------
//--- Register Global Vars ----------------------------
//-----------------------------------------------------
$total_images 0;
$total_categories 0;
$auth_cat_sql['auth_viewcat']['IN'] = 0;
$auth_cat_sql['auth_viewcat']['NOTIN'] = 0;
if (!empty(
$cat_cache)) {
  foreach (
$cat_cache as $key => $val) {
    if (
check_permission("auth_viewcat"$key)) {
      
$total_categories++;
      if (isset(
$val['num_images'])) {
        
$total_images += $val['num_images'];
      }
      else {
        
$cat_cache[$key]['num_images'] = 0;
      }
      
$auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
    }
    else {
      
$auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
    }
  }
}

//----------------------------------------------------- 
//--- pm --------------------------------------------- 
//----------------------------------------------------- 
$inbox ""
$outbox ""
$sentbox ""
$newpm ""
$pm_popup_script ""
$pm_popup_head ""
$pm ""
if (
$config['pm'] && $user_info['user_level'] >= USER) { 
  
$sql "SELECT COUNT(pm_id) AS total 
              FROM "
.PM_TABLE.
              WHERE pm_to = "
.$user_info['user_id']." AND (pm_type = ".PM_SENT." OR pm_type = ".PM_SDLT." OR pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")"
  
$result $site_db->query_firstrow($sql); 
  
$pm_inbox $result['total']; 
  
$sql "SELECT COUNT(pm_id) AS total 
              FROM "
.PM_TABLE.
              WHERE pm_from = "
.$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.")"
  
$result $site_db->query_firstrow($sql); 
  
$pm_outbox $result['total']; 
  
$sql "SELECT COUNT(pm_id) AS total 
              FROM "
.PM_TABLE.
              WHERE pm_from = "
.$user_info['user_id']." AND (pm_type = ".PM_SENT." OR pm_type = ".PM_RDLT.")"
  
$result $site_db->query_firstrow($sql); 
  
$pm_sentbox $result['total']; 
  
$sql "SELECT COUNT(pm_id) AS new 
              FROM "
.PM_TABLE.
              WHERE pm_to = "
.$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.") 
              ORDER BY pm_date DESC"

  
$result $site_db->query_firstrow($sql); 
  
$pm_new_count $result['new']; 
  
$sql "SELECT pm_date 
              FROM "
.PM_TABLE.
              WHERE pm_to = "
.$user_info['user_id']." AND (pm_type = ".PM_UNREAD." OR pm_type = ".PM_USDLT.") 
              ORDER BY pm_date DESC"

  
$result $site_db->query_firstrow($sql); 
  
$pm_new "<a href=\"".$site_sess->url(ROOT_PATH."pm.php")."\">".(($pm_new_count) ? "<blink>".$pm_new_count."</blink>" 0)."</a>"
  
$pm preg_replace("/".$site_template->start."msg_new_count".$site_template->end."/siU"$pm_new$lang['pm_link']); 
  
$pm preg_replace("/".$site_template->start."inbox".$site_template->end."/siU""<a href=\"".$site_sess->url(ROOT_PATH."pm.php")."\">".$lang['pm_inbox']."</a>"$pm); 
  
$blink "<script language=\"JavaScript\">\n<!--\nvar flg=0;\nfunction blink(){\nvar myElement=document.getElementById('blnk');\nflg^=1;\nif(flg==1){\nmyElement.style.visibility='hidden';\n}\nelse{\nmyElement.style.visibility='visible';\n}\ntimerID = setTimeout( 'blink()' , 500 );\n}\n//-->\n</script>\n"
  
$show_inbox = ($pm_new_count) ? $blink."<span id=\"blnk\">".$lang['pm_inbox']."</span><script language=\"JavaScript\">blink();</script>" $lang['pm_inbox']; 
  
$inbox "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=inbox")."\" title=\"".(($pm_new_count) ? $lang['pm_new_messages'].": ".$pm_new_count."\n" "").$lang['pm_total'].": ".$pm_inbox."\">".$show_inbox."</a>"
  
$sentbox "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=sentbox")."\" title=\"".$lang['pm_total'].": ".$pm_sentbox."\">".$lang['pm_sentbox']."</a>"
  
$outbox "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=outbox")."\" title=\"".$lang['pm_total'].": ".$pm_outbox."\">".$lang['pm_outbox']."</a>"
  
$newpm "<a href=\"".$site_sess->url(ROOT_PATH."pm.php?action=new")."\">".$lang['pm_new']."</a>"

  if (
$result && $user_info['user_pm_popup']) { 
     
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME "4images_"
     
$cookie_pmnewpopup = isset($HTTP_COOKIE_VARS[$cookie_name.'pmnewpopup']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'pmnewpopup'])) : 0
     if (
$cookie_pmnewpopup $result['pm_date']) { 
      if (
ereg("pm.php"$self_url) && $action == "inbox") { 
          
$cookie_expire time() + 60 60 24 90
          
setcookie($cookie_name.'pmnewpopup'serialize($result['pm_date']), $cookie_expireCOOKIE_PATHCOOKIE_DOMAINCOOKIE_SECURE); 
      }elseif (!
ereg("pm.php"$self_url) || (ereg("pm.php"$self_url) && ($action == "sentbox" || $action == "outbox"))){ 
        
$cookie_expire gmdate('D, d M Y H:i:s \G\M\T'time() + 60 60 24 90); 
        
$pm_popup_script " <script language=\"JavaScript\"> 
        <!-- 
        function SetCookie (name, value, expire, path, domain, secure) { 
          document.cookie = name + '=' + escape(value) + ((expire)?(';expires=' + expire):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); 
        } 
        function confirm_newpm() { 
          input_box=confirm('"
.$lang['pm_popup_confirm']."'); 
          if (input_box==true) { // Output when OK is clicked 
            second_box=confirm('"
.$lang['pm_popup_newwindow']."'); 
            if (second_box==true) { 
              SetCookie('"
.$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."'); 
              window.open('"
.$site_sess->url(ROOT_PATH."pm.php")."','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50'); 
            } else { 
              SetCookie('"
.$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."'); 
              window.location='"
.$site_sess->url(ROOT_PATH."pm.php")."'; 
            } 
          } else { 
            SetCookie('"
.$cookie_name."pmnewpopup','".serialize($result['pm_date'])."','".$cookie_expire."','".COOKIE_PATH."','".COOKIE_DOMAIN."','".COOKIE_SECURE."'); 
          } 
        } 
        // --> 
      </script>"

        
$pm_popup_header " onload=\"Javascript:confirm_newpm()\""
       } 
    } 
  } 

$sql "SELECT c.comment_id 
      FROM "
.COMMENTS_TABLE." c 
      LEFT JOIN "
.IMAGES_TABLE." i ON i.image_id = c.image_id 
      WHERE i.user_id = "
.$user_info['user_id']." AND c.is_read = 0"
$result $site_db->query($sql); 
$new_comments $site_db->get_numrows($result);
$query_string ''
if (!empty(
$HTTP_GET_VARS)) { 
  foreach (
$HTTP_GET_VARS as $key => $val) { 
    if (
$key != "l") { 
      
$query_string .= ($query_string != '' '&' '?').$key."=".$val
    } 
  } 

$lang_url $site_sess->url($PHP_SELF.$query_string'&'); 
$lang_url preg_replace("'&(amp|#38);'i""&"$lang_url); 
$lang_url preg_replace("/[?|&]l=[^?|&]*/"""$lang_url); 
$lang_url str_replace("&""&amp;"$lang_url); 
$handle opendir(ROOT_PATH."lang"); 
$lang_select ""
while (
$folder = @readdir($handle)) { 
  if (@
is_dir(ROOT_PATH."lang/".$folder) && $folder != "." && $folder != "..") { 
    if (
$folder != $config['language_dir']) { 
      
$lang_select .= "<a class=\"lang\" href=\"".$lang_url.(preg_match("/".$config['language_dir_default']."/i",$folder) ? "" : ((preg_match("/\?/"$lang_url) ? "&" "?")."l=".$folder))."\" onMouseOver=\"(window.status='$folder'); return true\" onMouseOut=\"window.status=''; return true\"><img src=\"".TEMPLATE_PATH."/images/".$folder.".gif\" border=\"0\" alt=\"".$folder."\"></a>&nbsp;"
    }else{ 
    
$lang_select .= "<img src=\"".TEMPLATE_PATH."/images/".$folder."2.gif\" border=\"0\" alt=\"".$folder."\">&nbsp;"
    } 
  } 

// Register the dropdown code for the template engine 

$site_template->register_vars("lang_select"$lang_select);
require_once(
"rss/rss_fetch.inc"); 

if (
$cat_id) { 
  
$sql "SELECT * 
          FROM rssfeed 
          WHERE cat_id = 
$cat_id"
        
  
$result $site_db->query($sql); 
  
$num_rows $site_db->get_numrows($result); 
  if (!
$num_rows) { 
    
$rss_list "No feeds available."
  } 
  else { 
    
$rss_list ""
    while(
$rss_row $site_db->fetch_array($result)) { 
      
$url $rss_row['url']; 
      
$rss fetch_rss($url); 
      
$rss_list .= "<b>Channel Title: " $rss->channel['title'] . "</b><p>"
      
$rss_list .= "<ul>"
      foreach (
$rss->items as $item) { 
        
$href $item['link']; 
        
$title $item['title']; 
        
$rss_list .= "<li><a href=$href>$title</a></li>"
      }
      
$rss_list .= "</ul>"
    } 
  } 
  
$site_template->register_vars(array( 
    
"rss_list" => $rss_list 
  
)); 

else { 
  if (
$user_info['user_id'] == GUEST) { 
    
$sql "SELECT * 
              FROM rssfeed 
            LIMIT 3"

        
    
$result $site_db->query($sql); 
    
$num_rows $site_db->get_numrows($result); 
    if (!
$num_rows) { 
      
$rss_list "No feeds available."
    } 
    else { 
      
$rss_list ""
      while(
$rss_row $site_db->fetch_array($result)) { 
        
$url $rss_row['url']; 
        
$rss fetch_rss($url); 
        
$rss_list .= "<b>Channel Title: " $rss->channel['title'] . "</b><p>"
        
$rss_list .= "<ul>"
        foreach (
$rss->items as $item) {
        
$href $item['link']; 
        
$title $item['title']; 
        
$rss_list .= "<li><a href=$href>$title</a></li>"
      } 
      
$rss_list .= "</ul>"
    } 
  }
    
$site_template->register_vars(array( 
      
"rss_list" => $rss_list 
    
)); 
  } 
  else { 
    
$sql "SELECT * 
            FROM user_to_rss_feed b 
            LEFT JOIN rssfeed r ON r.rowID = b.rssid 
            WHERE b.userid = "
.$user_info['user_id'].""

    
$result $site_db->query($sql); 
    
$num_rows $site_db->get_numrows($result); 
    if (!
$num_rows) { 
      
$rss_list "You have not selected any feeds"
    } 
    else { 
      
$rss_list ""

      while(
$rss_row $site_db->fetch_array($result)) { 
        if (
$rss_row['rssid'] != 0) { 
          
$url $rss_row['url']; 
          
$rss fetch_rss($url); 
          
$rss_list .= (!$rss_row['title']) ? "<b>".$rss->channel['title']."</b><p>" "<b>".$rss_row['title']."</b><p>"
        } 
        else { 
          
$url $rss_row['rss_url']; 
          
$rss fetch_rss($url); 
          
$rss_list .= (!$rss_row['rss_title']) ? "<b>".$rss->channel['title']."</b><p>" "<b>".$rss_row['rss_title']."</b><p>"
        } 
        
$rss_list .= "<ul>"
        foreach (
$rss->items as $item) { 
          
$href $item['link']; 
          
$title $item['title']; 
          
$rss_list .= "<li><a href=$href>$title</a></li>"
        } 
        
$rss_list .= "</ul>"
      } 
    } 
    
$feed_url $site_sess->url(ROOT_PATH."member.php?action=editfeeds"); 
    
$rss_list .= "<br><br> <a href=\"".$feed_url."\"> Edit and Add your personal feeds </a> "
    
$site_template->register_vars(array( 
      
"rss_list" => $rss_list 
    
));
  } 
}
$site_template->register_vars(array( 
  
"pm" => $pm
  
"pm_boxes" => ($inbox) ? $inbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$sentbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$outbox."&nbsp;&nbsp;|&nbsp;&nbsp;".$newpm ""
  
"pm_inbox" => $inbox
  
"pm_sentbox" => $sentbox
  
"pm_outbox" => $outbox
  
"pm_newpm" => $newpm
  
"pm_popup_script" => $pm_popup_script
  
"pm_popup_header" => $pm_popup_header
  
"bbcode2" => (BBCODE == "bbcode") ? 1
  
"media_url" => MEDIA_PATH,
  
"thumb_url" => THUMB_PATH,
  
"icon_url" => ICON_PATH,
  
"template_url" => TEMPLATE_PATH,
  
"template_image_url" => TEMPLATE_PATH."/images",
  
"template_lang_image_url" => TEMPLATE_PATH."/images_".$config['language_dir'],
  
"site_name" => $config['site_name'],
   
"current_user_id" => $user_info['user_id'], 
  
"current_user_name" => ($user_info['user_level'] == GUEST) ? $lang['userlevel_guest'] : addslashes($user_info['user_name']),
  
"lang" => $l,
  
"site_email" => $config['site_email'],
  
"self" => $site_sess->url($self_url),
  
"self_full" => $site_sess->url($script_url."/".$self_url),
  
"script_version" => SCRIPT_VERSION,
  
"cp_link" => ($user_info['user_level'] != ADMIN) ? "" "\n<p align=\"center\">[<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php")."\">Control Panel</a>]</p>\n",
  
"total_categories" => $total_categories,
  
"total_images" => $total_images,
  
"new_comments" => $new_comments
  
"url_comments" => $site_sess->url(ROOT_PATH."member.php?action=readcomments"),
  
"url_new_images" => $site_sess->url(ROOT_PATH."search.php?search_new_images=1"),
  
"url_top_images" => $site_sess->url(ROOT_PATH."top.php"),
  
"url_top_cat_images" => $site_sess->url(ROOT_PATH."top.php".(($cat_id && preg_match("/categories.php/"$self_url)) ? "?".URL_CAT_ID."=".$cat_id "")),
  
"url_register" => (!empty($url_register)) ? $site_sess->url($url_register) : $site_sess->url(ROOT_PATH."register.php"),
  
"url_search" => $site_sess->url(ROOT_PATH."search.php"),
  
"url_lightbox" => $site_sess->url(ROOT_PATH."lightbox.php"),
  
"url_warenkorb" => $site_sess->url(ROOT_PATH."warenkorb.php"),
  
"url_userlist" => $site_sess->url(ROOT_PATH."memberlist.php"),
  
"url_control_panel" => (!empty($url_control_panel)) ? $site_sess->url($url_control_panel) : $site_sess->url(ROOT_PATH."member.php?action=editprofile"),
  
"url_categories" => $site_sess->url(ROOT_PATH."categories.php"),
  
"url_guestbook" => (!empty($url_guestbook)) ? $site_sess->url($url_guestbook) : $site_sess->url(ROOT_PATH."guestbook.php"),
  
"url_home" => $site_sess->url(ROOT_PATH."index.php"),
  
"url_login" => (!empty($url_login)) ? $site_sess->url($url_login) : $site_sess->url(ROOT_PATH."login.php"),
  
"url_logout" => (!empty($url_logout)) ? $site_sess->url($url_logout) : $site_sess->url(ROOT_PATH."logout.php"),
  
"url_member" => (!empty($url_member)) ? $site_sess->url($url_member) : $site_sess->url(ROOT_PATH."member.php"),
  
"url_upload" => (!empty($url_upload)) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH."member.php?action=uploadform"),
  
"user_avatar_current" => ($config['avatar_use']) ? "<img src=\"".TEMPLATE_PATH."/avatars/".(($user_info['user_avatar'] == "") ? "blank.gif" $user_info['user_avatar'])."\" name=\"icons\" border=\"0\" alt=\"\">" "",
  
"url_lost_password" => (!empty($url_lost_password)) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH."member.php?action=lostpassword")
));

if (!empty(
$additional_urls)) {
  
$register_array = array();
  foreach (
$additional_urls as $key => $val) {
    
$register_array[$key] = $site_sess->url($val);
  }
  
$site_template->register_vars($register_array);
}
// Replace Globals in $lang
$lang $site_template->parse_array($lang);

$site_template->register_vars(array(
  
"lang_site_stats" => $lang['site_stats'],
  
"lang_registered_user" => $lang['registered_user'],
  
"lang_random_image" => $lang['random_image'],
  
"lang_categories" => $lang['categories'],
  
"lang_sub_categories" => $lang['sub_categories'],
  
"lang_new_images" => $lang['new_images'],
  
"lang_top_images" => $lang['top_images'],
  
"lang_search" => $lang['search'],
  
"lang_advanced_search" => $lang['advanced_search'],
  
"lang_lightbox" => $lang['lightbox'],
  
"lang_warenkorb" => $lang['warenkorb'],
  
"lang_userlist_title" => $lang['lang_userlist_title'],
  
"lang_register" => $lang['register'],
  
"lang_control_panel" => $lang['control_panel'],
  
"lang_login" => $lang['login'],
  
"lang_auto_login" => $lang['lang_auto_login'],
  
"lang_logout" => $lang['logout'],
  
"lang_lost_password" => $lang['lost_password'],
  
"lang_user_name" => $lang['user_name'],
  
"lang_password" => $lang['password'],
  
"lang_go" => $lang['go'],
  
"lang_images_per_page" => $lang['images_per_page'],
  
"lang_user_online" => $lang['user_online'],
  
"lang_user_online_detail" => $lang['user_online_detail'],
  
"charset" => $lang['charset'],
  
"direction" => $lang['direction']
));

//-----------------------------------------------------
//--- Category Dropdown -------------------------------
//-----------------------------------------------------
$category_dropdown_selfjump get_category_dropdown($cat_id1);
$site_template->register_vars("category_dropdown_selfjump"$category_dropdown_selfjump);
$category_dropdown_form $site_template->parse_template("category_dropdown_form");
$site_template->register_vars(array("category_dropdown_form" => $category_dropdown_form));

$site_template->un_register_vars("category_dropdown_selfjump");
unset(
$category_dropdown_selfjump);
unset(
$category_dropdown_form);

//-----------------------------------------------------
//--- Random Image ------------------------------------
//-----------------------------------------------------
$random_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" get_random_image();
$site_template->register_vars("random_image"$random_image);
unset(
$random_image);
//--- Shop System -------- 
function FormatPrice ($nPrice

   
$nPrice number_format($nPrice"2"",""."); 
   return 
$nPrice

$kunde $user_info['user_id'];
//----------------------------------------------------- 
//--- Set Paging Vars --------------------------------- 
//----------------------------------------------------- 
if (isset($HTTP_POST_VARS['setperpage'])) { 
  
$setperpage intval($HTTP_POST_VARS['setperpage']); 
  if (
$setperpage) { 
    
$site_sess->set_session_var("perpage"$setperpage); 
    
$session_info['perpage'] = $setperpage
    
$site_sess->set_cookie_data("perpage"$setperpage); 
  } 


if (isset(
$session_info['perpage'])) { 
  
$perpage $session_info['perpage']; 

else if(
$site_sess->read_cookie_data("perpage")) { 
  
$perpage $site_sess->read_cookie_data("perpage"); 
  
$site_sess->set_session_var("perpage"$perpage); 
  
$session_info['perpage'] = $perpage

else { 
  
$perpage ceil($config['default_image_rows'] * $config['image_cells']); 
  
$site_sess->set_cookie_data("perpage"$perpage); 
}
//-----------------------------------------------------
//--- Set Perpage Dropdown ----------------------------
//-----------------------------------------------------
$setperpage_dropdown "\n<select name=\"setperpage\" class=\"setperpageselect\">\n";
for(
$i 1$i <= $config['custom_row_steps']; $i++) {
  
$setvalue $config['image_cells'] * $i;
  
$setperpage_dropdown .= "<option value=\"".$setvalue."\"";
    if (
$setvalue == $perpage) {
    
$setperpage_dropdown .= " selected=\"selected\"";
  }
  
$setperpage_dropdown .= ">";
  
$setperpage_dropdown .= $setvalue;
  
$setperpage_dropdown .= "</option>\n";
}
$setperpage_dropdown .= "</select>\n";
if (
$cat_id != 0) {
  
$setperpage_dropdown .= "<input type=\"hidden\" name=\"cat_id\" value=\"".$cat_id."\" />\n";
}
if (isset(
$show_result) && $show_result == 1) {
  
$setperpage_dropdown .= "<input type=\"hidden\" name=\"show_result\" value=\"1\" />\n";
}
$site_template->register_vars("setperpage_dropdown"$setperpage_dropdown);
$setperpage_dropdown_form $site_template->parse_template("setperpage_dropdown_form");
$site_template->register_vars("setperpage_dropdown_form"$setperpage_dropdown_form);

$site_template->un_register_vars("setperpage_dropdown");
unset(
$setperpage_dropdown);
unset(
$setperpage_dropdown_form);

//-----------------------------------------------------
//--- Add & Delete from Lists -------------------------
//-----------------------------------------------------
if ($action == "addtolightbox" && $id) {
  if (
$user_info['user_level'] >= USER) {
    
$msg = (add_to_lightbox($id)) ? $lang['lightbox_add_success'] : $lang['lightbox_add_error'];
  }
  else {
    
$msg $lang['lightbox_register'];
  }
}
if (
$action == "removefromlightbox" && $id) {
  if (
$user_info['user_level'] >= USER) {
    
$msg = (remove_from_lightbox($id)) ? $lang['lightbox_remove_success'] : $lang['lightbox_remove_error'];
  }
  else {
    
$msg $lang['lightbox_register'];
  }
}
if (
$action == "clearlightbox") {
  if (
$user_info['user_level'] >= USER) {
    
$msg = (clear_lightbox()) ? $lang['lightbox_delete_success'] : $lang['lightbox_delete_error'];
  }
  else {
    
$msg $lang['lightbox_register'];
  }
}
if (
$action == "addtowarenkorb" && $id) { 
  if (
$user_info['user_level'] >= USER) { 
    
$msg = (add_to_warenkorb($id)) ? $lang['warenkorb_add_success'] : $lang['warenkorb_add_error']; 
  } 
  else { 
    
$msg $lang['warenkorb_register']; 
  } 

if (
$action == "removefromwarenkorb" && $id) { 
  if (
$user_info['user_level'] >= USER) { 
    
$msg = (remove_from_warenkorb($id)) ? $lang['warenkorb_remove_success'] : $lang['warenkorb_remove_error']; 
  } 
  else { 
    
$msg $lang['warenkorb_register']; 
  } 


if (
$action == "anzahlverkleinernwarenkorb" && $id) { 
  if (
$user_info['user_level'] >= USER) { 
    
$msg = (anzahl_verkleinern_warenkorb($id)) ? $lang['anzahl_verkleinern_success'] : $lang['warenkorb_remove_error']; 
  } 
  else { 
    
$msg $lang['warenkorb_register']; 
  } 


if (
$action == "clearwarenkorb") { 
  if (
$user_info['user_level'] >= USER) { 
    
$msg = (clear_warenkorb()) ? $lang['warenkorb_delete_success'] : $lang['warenkorb_delete_error']; 
  } 
  else { 
    
$msg $lang['warenkorb_register']; 
  } 
}
//----------------------------------------------------- 
//--- Save Rating ------------------------------------- 
//----------------------------------------------------- 

//----- Settings ------------ 

//change to $rate_suffix = ""; if u dont want remmber votes for different users on same computer 
$rate_suffix "_".$user_info['user_id']; 

//--- End Settings ---------- 

if ($action == "rateimage" && $id) { 
  
$rating intval($HTTP_POST_VARS['rating']); 
  
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME "4images_"
  
$cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array(); 
  if (
$rating && $rating <= MAX_RATING && $id) { 
    if (!isset(
$session_info['rated_imgs'.$rate_suffix])) { 
      
$session_info['rated_imgs'.$rate_suffix] = $site_sess->get_session_var("rated_imgs".$rate_suffix); 
    } 
    
$split_list_array = array(); 
    if (!empty(
$session_info['rated_imgs'.$rate_suffix])) { 
      
$split_list_array explode(" "$session_info['rated_imgs'.$rate_suffix]); 
    } 
    
$split_list = array(); 
      foreach (
$split_list_array as $key) { 
         
$key explode(","$key); 
         
$split_list[] = $key[0]; 
     } 
    
$cookie_rated = array(); 
      foreach (
$cookie_rated_array as $key) { 
         
$key explode(","$key); 
         
$cookie_rated[] = $key[0]; 
      } 
    if (!
in_array($id$split_list) && !in_array($id$cookie_rated)) { 
      
$session_info['rated_imgs'.$rate_suffix] .= " ".$id.",".$rating
      
$session_info['rated_imgs'.$rate_suffix] = trim($session_info['rated_imgs'.$rate_suffix]); 
      
$site_sess->set_session_var("rated_imgs".$rate_suffix$session_info['rated_imgs'.$rate_suffix]); 
      
$cookie_rated_array[] = $id.",".$rating
      
$cookie_expire time() + 60 60 24 4
      
setcookie($cookie_name.'rated'.$rate_suffixserialize($cookie_rated_array), $cookie_expireCOOKIE_PATHCOOKIE_DOMAINCOOKIE_SECURE); 
      
update_image_rating($id$rating); 
      
//-------------------------------------------[ [Mod] Keep Track Of Each action ] 
//  if ($user_info['user_level'] >= USER)  
   
add_to_stats_user_ids($image_id"v"); // Mod: Track User action (voted pics) 
//-------------------------------------------[/[Mod] Keep Track Of Each action ]
      
$msg $lang['voting_success']; 
    } 
    else { 
      
$msg $lang['already_voted']; 
    } 
  } 
  else { 
    
$msg $lang['voting_error']; 
  } 


//----------------------------------------------------- 
//--- Parse Header & Footer --------------------------- 
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  
$header $site_template->parse_template("header");
  
$footer $site_template->parse_template("footer");
  
$site_template->register_vars(array(
    
"header" => $header,
    
"footer" => $footer
  
));
  unset(
$header);
  unset(
$footer);
}
//--- Warenkorb Summen --------- 
$sql "SELECT sum( w.image_quantity * i.price_1 ) AS total_price 
FROM "
.WARENKORB_TABLE." w, ".IMAGES_TABLE." i 
WHERE image_active = 1 
AND w.user_id = "
.$kunde.
AND i.image_id = w.warenkorb_image_id"

$result $site_db->query_firstrow($sql); 
$total_sum $result['total_price']; 
$porto $config['porto']; 
$bearbeitung $config['bearbeitung']; 
$sum_porto_bear_t = ($total_sum $porto $bearbeitung); 
$sum_porto_bear FormatPrice ($sum_porto_bear_t); 
$total_sum FormatPrice ($total_sum); 
$porto FormatPrice ($config['porto']); 
$bearbeitung FormatPrice ($config['bearbeitung']); 
$sql "SELECT sum( w.image_quantity) AS total_images_sum 
FROM "
.WARENKORB_TABLE." w, ".IMAGES_TABLE." i 
WHERE image_active = 1 
AND w.user_id = "
.$kunde.
AND i.image_id = w.warenkorb_image_id"

$result $site_db->query_firstrow($sql); 
$total_images_sum $result['total_images_sum']; 
$site_template->register_vars(array( 
"total_sum" => $total_sum
"total_images_sum" => $total_images_sum
"bearbeitung" => $bearbeitung
"sum_porto_bear" => $sum_porto_bear
"porto" => $porto 
));

//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  
$site_template->register_vars("lang_loggedin_msg"preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU"$user_info['user_name'], $lang['lang_loggedin_msg']));
  
$user_box $site_template->parse_template("user_logininfo");
  
$site_template->register_vars(array(
  
"user_box" => $user_box,
   
"lang_warenkorb" => $lang['warenkorb'], 
  
"bestellung" => $bestellung
  
"total_images_sum" => $total_images_sum
  
"total_sum" => $total_sum,
  
"user_loggedin" => 1,
  
"user_loggedout" => 0,
  
"is_admin" => ($user_info['user_level'] == ADMIN) ? 0
  
));  
  
$site_template->un_register_vars("user_logininfo");
  unset(
$user_box);
}
else {
  
$user_box $site_template->parse_template("user_loginform");
  
$site_template->register_vars(array(
    
"user_box" => $user_box,
    
"user_loggedin" => 0,
    
"user_loggedout" => 1,
    
"is_admin" => 0
  
));
  
$site_template->un_register_vars("user_loginform");
  unset(
$user_box);
}
//----------------------------------------------------- 
//---Show New Image count in category------------------ 
//----------------------------------------------------- 

$new_image_category "<table border=0 cellpadding=2 cellspacing=1 width=\"100%\">"

foreach (
$new_image_cache as $key => $val) { 
     if (
$val && check_permission("auth_viewcat"$key)) { 
     
$category_link "<a href=\"".$site_sess->url(ROOT_PATH."search.php?search_new_images=1&cat_id=".$key."&sub_cat=no")."\" class=bigmenusubCopy6 >".$val."</a>"
     
$new_image_category .= "<tr><td class=bigmenusubCopy6><a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$cat_cache[$key]['cat_id'])."\">".$cat_cache[$key]['cat_name']."</a></td><td><b>".$category_link."</b></td></tr>"
   } 

    
  
$new_image_category .= "</table>"
  
$site_template->register_vars("new_image_cats"$new_image_category); 
  unset(
$new_image_category);
//----------------------------------------------------- 
//--- Last active User -------------------------------- 
//----------------------------------------------------- 
$sql "SELECT user_name, user_id, user_lastaction FROM ".USERS_TABLE.
                 WHERE user_level >= '"
.GUEST."' 
                    ORDER BY user_lastaction DESC 
                 LIMIT 5"

    
$result $site_db->query($sql); 

    while (
$row $site_db->fetch_array($result)) { 
    
$last_action_user_list .= "<a href =\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\"><b>".$row['user_name']."</b></a><br ><span class=\"smalltext\">".format_date($config['date_format']." ".$config['time_format'], $row['user_lastaction'])."</span><br >"
    } 

$user_last_action_box $site_template->parse_template("user_last_action_box"); 
$site_template->register_vars(array( 
  
"user_last_action_box" => $user_last_action_box
  
"lang_user_last_action" => $lang['lang_user_last_action'],    
  
"user_last_action_list" => $last_action_user_list 
)); 
  unset(
$user_last_action_box); 
  unset(
$last_action_user_list);
 
?>

is the whole php....
As long as I can finish my site before I die.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: I hate this error: Warning: Invalid argument supplied for foreach()
« Reply #1 on: March 20, 2005, 07:08:03 PM »
I'm not going to sit here and count lines.  Which one is line 224???

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: I hate this error: Warning: Invalid argument supplied for foreach()
« Reply #2 on: March 20, 2005, 07:48:26 PM »
in fact this has nothing to do with 4images itself, your error is seems to be in RSS mod or something.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline AntiNSA2

  • Hero Member
  • *****
  • Posts: 774
  • As long as I can finish my site before I die.
    • View Profile
    • http://www.thelifephotography.com
Re: I hate this error: Warning: Invalid argument supplied for foreach()
« Reply #3 on: March 21, 2005, 04:04:49 AM »
I am hopping/guessing it must be some kind of simple(?) synatx error?

the line of that error code is:
Code: [Select]
foreach ($rss->items as $item) {
If it was an undefined error I could understand why......

I didnt really want to post my whole code likde that... I was thinking perhaps it was a missing bracket or something in thats fuction... but I can figure it out and rproctor unfortunately is MIA....

here is the complete partof the rss code...
Code: [Select]
$site_template->register_vars("lang_select", $lang_select);
require_once("rss/rss_fetch.inc");

if ($cat_id) {
  $sql = "SELECT *
          FROM rssfeed
          WHERE cat_id = $cat_id";
       
  $result = $site_db->query($sql);
  $num_rows = $site_db->get_numrows($result);
  if (!$num_rows) {
    $rss_list = "No feeds available.";
  }
  else {
    $rss_list = "";
    while($rss_row = $site_db->fetch_array($result)) {
      $url = $rss_row['url'];
      $rss = fetch_rss($url);
      $rss_list .= "<b>Channel Title: " . $rss->channel['title'] . "</b><p>";
      $rss_list .= "<ul>";
      foreach ($rss->items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        $rss_list .= "<li><a href=$href>$title</a></li>";
      }
      $rss_list .= "</ul>";
    }
  }
  $site_template->register_vars(array(
    "rss_list" => $rss_list
  ));
}
else {
  if ($user_info['user_id'] == GUEST) {
    $sql = "SELECT *
              FROM rssfeed
            LIMIT 3";
       
    $result = $site_db->query($sql);
    $num_rows = $site_db->get_numrows($result);
    if (!$num_rows) {
      $rss_list = "No feeds available.";
    }
    else {
      $rss_list = "";
      while($rss_row = $site_db->fetch_array($result)) {
        $url = $rss_row['url'];
        $rss = fetch_rss($url);
        $rss_list .= "<b>Channel Title: " . $rss->channel['title'] . "</b><p>";
        $rss_list .= "<ul>";
        foreach ($rss->items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        $rss_list .= "<li><a href=$href>$title</a></li>";
      }
      $rss_list .= "</ul>";
    }
  }
    $site_template->register_vars(array(
      "rss_list" => $rss_list
    ));
  }
  else {
    $sql = "SELECT *
            FROM user_to_rss_feed b
            LEFT JOIN rssfeed r ON r.rowID = b.rssid
            WHERE b.userid = ".$user_info['user_id']."";

    $result = $site_db->query($sql);
    $num_rows = $site_db->get_numrows($result);
    if (!$num_rows) {
      $rss_list = "You have not selected any feeds";
    }
    else {
      $rss_list = "";

      while($rss_row = $site_db->fetch_array($result)) {
        if ($rss_row['rssid'] != 0) {
          $url = $rss_row['url'];
          $rss = fetch_rss($url);
          $rss_list .= (!$rss_row['title']) ? "<b>".$rss->channel['title']."</b><p>" : "<b>".$rss_row['title']."</b><p>";
        }
        else {
          $url = $rss_row['rss_url'];
          $rss = fetch_rss($url);
          $rss_list .= (!$rss_row['rss_title']) ? "<b>".$rss->channel['title']."</b><p>" : "<b>".$rss_row['rss_title']."</b><p>";
        }
        $rss_list .= "<ul>";
        foreach ($rss->items as $item) {
          $href = $item['link'];
          $title = $item['title'];
          $rss_list .= "<li><a href=$href>$title</a></li>";
        }
        $rss_list .= "</ul>";
      }
    }
    $feed_url = $site_sess->url(ROOT_PATH."member.php?action=editfeeds");
    $rss_list .= "<br><br> <a href=\"".$feed_url."\"> Edit and Add your personal feeds </a> ";
    $site_template->register_vars(array(
      "rss_list" => $rss_list
    ));
  }
}

does it look like Im missing a ; or to many }..?


Its an awsome mod... it displays rss feeds and lets you customize them by user.... the only bug is the error code.... :(
As long as I can finish my site before I die.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: I hate this error: Warning: Invalid argument supplied for foreach()
« Reply #4 on: March 21, 2005, 04:50:12 AM »
actualy the error sais that $rss->items is not an array...perhaps u made a misstake when installed the mod?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline AntiNSA2

  • Hero Member
  • *****
  • Posts: 774
  • As long as I can finish my site before I die.
    • View Profile
    • http://www.thelifephotography.com
Re: I hate this error: Warning: Invalid argument supplied for foreach()
« Reply #5 on: March 21, 2005, 01:47:20 PM »
Ok... I tried to look at this for a while... I only get the error when I am a guest... logged in its no problem.

BUT, if you look at the else statement, it looks identical to the one a little above it....

Why is it not working?

I cant figure out which array is wrong... I checked googles cache before and the mod is gone... but I remember trying over and over reinstalling it with the same error......

It still works... feeds displayed, the only problem is the error code causes the whole page to pause...
Now this was such a cool mod and is a great mod....

Which array is wrong?

Thanks if you know V@no or anyone else too !

As long as I can finish my site before I die.