Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Search bot producing invalid argument error:

Aloittaja eichelman, kesäkuu 05, 2006, 03:28:10 IP

« edellinen - seuraava »

eichelman

I installed the smf search bot for 1.1.4 for joomla 1.0.8. Everything looked good. But when I tried to install the bot, everything was ok. But I had an error when browsing in the admin panel the search bot. I saw that it was trying to access the smf.search.readme.txt.php file. So I changed the parameter for it to refer to the smf.search.php file. That seemed to work fine.

But

Now, when I use the search module in Joomla, I get this error message:

Warning: Invalid argument supplied for foreach() in /home/.makar/eichelman/interactplaza.org/includes/frontend.php on line 64

MULTIPLE TIMES, and I get this error

Table \'interactsmf.jos_menu\' doesn\'t exist SQL=SELECT m.*, sum(case when p.published=1 then 1 else 0 end) as cnt\nFROM jos_menu AS m\nLEFT JOIN jos_menu AS p ON p.parent = m.id [nofollow]\nWHERE m.menutype=\'topmenu\' AN

I dont think I have a interactsmf table, my joomla database is interact, my smf database is "smf". Is this another template problem, with Lightfast ??

Here is the "offending code" in Joomla that produces the first error messages, at for the foreach stmt:

function &initModules() {
   global $database, $my, $Itemid;

   if (!isset( $GLOBALS['_MOS_MODULES'] )) {
      $query = "SELECT id, title, module, position, content, showtitle, params"
      . "\n FROM #__modules AS m"
      . "\n INNER JOIN #__modules_menu AS mm ON mm.moduleid = m.id [nofollow]"
      . "\n WHERE m.published = 1"
      . "\n AND m.access <= '". $my->gid ."'"
      . "\n AND m.client_id != 1"
      . "\n AND ( mm.menuid = '". $Itemid ."' OR mm.menuid = 0 )"
      . "\n ORDER BY ordering";

      $database->setQuery( $query );
      $modules = $database->loadObjectList();
      foreach ($modules as $module) {
         $GLOBALS['_MOS_MODULES'][$module->position][] = $module;
      }
   }
   return $GLOBALS['_MOS_MODULES'];

Orstio

Then the module is not switching back to the joomla database before proceeding.

In the search bot, the last thing that should happen is this:

mysql_select_db($mosConfig_db);

eichelman

Not quite got it. I have tried placing the suggested code in the function below, before it returns, but I get the same error messages, including the warnings:

Warning: Invalid argument supplied for foreach() in /home/.makar/eichelman/interactplaza.org/includes/frontend.php on line 64

before the database error msg
Table \'interactsmf.jos_menu\' doesn\'t exist SQL=SELECT m.*,


You can see the web site error at:
http://www.interactplaza.org/index.php?searchword=video&option=com_search&Itemid=5 [nofollow]

The function I modified: (my change is commented by //fre -that didnt seem to do anything.

function smfsearchbot_GetBoardWhereClause() {
// The code in this function is derived from function loadUserSettings() in source/Load.php.
// Used by permission of [Unknown] at http://www.simplemachines.org/community/.
// Use of Simple Machines Forum is subject to the license agreement with which it is distributed.

   global $modSettings, $db_prefix, $database;
   global $cookiename;

   // Check first the integration, then the cookie, and last the session.
   if (isset($modSettings['integrate_verify_user']) && function_exists($modSettings['integrate_verify_user']))
   {
      $ID_MEMBER = (int) call_user_func($modSettings['integrate_verify_user']);
      $already_verified = $ID_MEMBER > 0;
   }
   else
      $ID_MEMBER = 0;

   if (empty($ID_MEMBER) && isset($_COOKIE[$cookiename]))
   {
      $_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);

      // Fix a security hole in PHP 4.3.9 and below...
      if (preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$cookiename]) == 1)
      {
         list ($ID_MEMBER, $password) = @unserialize($_COOKIE[$cookiename]);
         $ID_MEMBER = !empty($ID_MEMBER) && strlen($password) > 0 ? (int) $ID_MEMBER : 0;
      }
      else
         $ID_MEMBER = 0;
   }
   elseif (empty($ID_MEMBER) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
   {
      // !!! Perhaps we can do some more checking on this, such as on the first octet of the IP?
      list ($ID_MEMBER, $password, $login_span) = @unserialize(stripslashes($_SESSION['login_' . $cookiename]));
      $ID_MEMBER = !empty($ID_MEMBER) && strlen($password) == 40 && $login_span > time() ? (int) $ID_MEMBER : 0;
   }

   //Find the members groups
   $list = smfsearchbot_GetDBObjectList("SELECT is_activated, ID_GROUP, ID_POST_GROUP, additionalGroups FROM " . $db_prefix .
    "members WHERE ID_MEMBER = " . $ID_MEMBER);

   if ((! empty($list)) && ($list[0]->is_activated == 1)) {
      if (empty($list[0]->additionalGroups))
         $groups = array($list[0]->ID_GROUP, $list[0]->ID_POST_GROUP);
      else
         $groups = array_merge(
               array($list[0]->ID_GROUP, $list[0]->ID_POST_GROUP),
               explode(',', $list[0]->additionalGroups)
            );
      $is_guest = false;
      $is_admin = in_array(1, $groups);
   }
   // If the user is a guest, initialize all the critial user settings.
   else
   {
      // This is what a guest's variables should be.
      $groups = array(-1);
      $$is_guest = true;
   }

   mysql_select_db($mosConfig_db); //fre added per Orstio, Joomla 1.08 produced an error upon search without this.

   // Just build this here, it makes it easier to change/use.
   if ($is_guest)
      return 'FIND_IN_SET(-1, b.memberGroups)';
   // Administrators can see all boards.
   elseif ($is_admin)
      return '1';
   // Registered user.... just the groups in $user_info['groups'].
   else
      return '(FIND_IN_SET(' . implode(', b.memberGroups) OR FIND_IN_SET(', $groups) . ', b.memberGroups))';
}


Orstio

You're going to need one before this line:

function botSearchSMF( $text, $phrase='', $ordering='' ) {


eichelman

Below is how I changed the code, NO change in the error messages (warnings). Still a problem.

But I also noted, probably it was already ok, that I am getting the correct search result. I added the mysql BEFORE the function definition, which seems really strange to me, I am pretty new at php.

global $db_server, $db_user, $db_passwd, $db_name;
//include($mosConfig_absolute_path . "/administrator/components/com_smf/config.smf.php");
//include($smf_path . "/Settings.php");

//fre added per Orstio, Joomla 1.08 produced an error upon search without this.
mysql_select_db($mosConfig_db);

function botSearchSMF( $text, $phrase='', $ordering='' ) {

   global $context, $mosConfig_db, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $mos_prefix, $smf_prefix;
   global $my, $database, $mosConfig_live_site, $wrapped, $boardurl, $db_server, $db_user, $db_passwd;
   global $mosConfig_absolute_path, $mosConfig_lang, $mosConfig_offset;

Kindred

what searchbot for 1.1.4?   As far as I know, the searchbot has not been updated for 1.1.4
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

eichelman

0.6 version. The readme says:

IMPORTANT! THIS VERSION IS ONLY FOR Oristo's SMF Bridge 1.13 (or possibly later).
DO NOT USE IT WITH EARLIER VERSIONS OF THE BRIDGE!

I had hoped I was not the first person to try the searchbot on 1.14, and I couldnt find a more resent verison of the searchbot.

rjprince

This thread contains details on the fix for this problem.

It does not appear to be related to 1.1.4 - the searchbot apparently works fine with 1.1.4.

The fix is only needed if a different DB is used for SMF and Joomla. I forgot a global declaration.

I will try to post a fix over the weekend after upgradiing to Joomla 1.09 and Bridge 1.1.4.

And I'll try to remember to fix that darn .txt problem in the XML file. :)

Advertisement: