Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy do I get the error Call to a member function read() on a non-object?
    primarykey
    data
    text
    <p>Why do I get the following error <a href="http://projectstratos.com/forum" rel="nofollow">here</a> when trying to intergrate my site with myBB?:</p> <p><code>Fatal error: Call to a member function read() on a non-object in /hermes/bosweb/web035/b357/ipg.projectstratoscom/forum/global.php on line 24</code></p> <p>here is the full global.php file:</p> <pre><code>&lt;?php /** * MyBB 1.6 * Copyright 2010 MyBB Group, All Rights Reserved * * Website: http://mybb.com * License: http://mybb.com/about/license * * $Id: global.php 5016 2010-06-12 00:24:02Z RyanGordon $ */ $working_dir = dirname(__FILE__); if(!$working_dir) { $working_dir = '/forum/'; } // Load main MyBB core file which begins all of the magic require_once $working_dir."/inc/init.php"; $shutdown_queries = array(); // Read the usergroups cache as well as the moderators cache $groupscache = $cache-&gt;read("usergroups"); // If the groups cache doesn't exist, update it and re-read it if(!is_array($groupscache)) { $cache-&gt;update_usergroups(); $groupscache = $cache-&gt;read("usergroups"); } if(!defined('THIS_SCRIPT')) { define('THIS_SCRIPT', ''); } $current_page = my_strtolower(basename(THIS_SCRIPT)); // Send page headers - don't send no-cache headers for attachment.php if($current_page != "attachment.php") { send_page_headers(); } // Do not use session system for defined pages if((@isset($mybb-&gt;input['action']) &amp;&amp; @isset($nosession[$mybb-&gt;input['action']])) || (@isset($mybb-&gt;input['thumbnail']) &amp;&amp; $current_page == 'attachment.php')) { define("NO_ONLINE", 1); } // Create session for this user require_once MYBB_ROOT."inc/class_session.php"; $session = new session; $session-&gt;init(); $mybb-&gt;session = &amp;$session; $mybb-&gt;user['ismoderator'] = is_moderator("", "", $mybb-&gt;user['uid']); // Set our POST validation code here $mybb-&gt;post_code = generate_post_check(); // Set and load the language if($mybb-&gt;input['language'] &amp;&amp; $lang-&gt;language_exists($mybb-&gt;input['language'])) { $mybb-&gt;settings['bblanguage'] = $mybb-&gt;input['language']; // If user is logged in, update their language selection with the new one if($mybb-&gt;user['uid']) { $db-&gt;update_query("users", array("language" =&gt; $db-&gt;escape_string($mybb-&gt;settings['bblanguage'])), "uid='{$mybb-&gt;user['uid']}'"); } // Guest = cookie else { my_setcookie("mybblang", $mybb-&gt;settings['bblanguage']); } $mybb-&gt;user['language'] = $mybb-&gt;settings['bblanguage']; } // Cookied language! else if($mybb-&gt;cookies['mybblang'] &amp;&amp; $lang-&gt;language_exists($mybb-&gt;cookies['mybblang'])) { $mybb-&gt;settings['bblanguage'] = $mybb-&gt;cookies['mybblang']; } else if(!isset($mybb-&gt;settings['bblanguage'])) { $mybb-&gt;settings['bblanguage'] = "english"; } // Load language $lang-&gt;set_language($mybb-&gt;settings['bblanguage']); $lang-&gt;load("global"); $lang-&gt;load("messages"); // Run global_start plugin hook now that the basics are set up $plugins-&gt;run_hooks("global_start"); if(function_exists('mb_internal_encoding') &amp;&amp; !empty($lang-&gt;settings['charset'])) { @mb_internal_encoding($lang-&gt;settings['charset']); } // Select the board theme to use. $loadstyle = ''; $load_from_forum = 0; $style = array(); // This user has a custom theme set in their profile if(isset($mybb-&gt;user['style']) &amp;&amp; intval($mybb-&gt;user['style']) != 0) { $loadstyle = "tid='".$mybb-&gt;user['style']."'"; } $valid = array( "showthread.php", "forumdisplay.php", "newthread.php", "newreply.php", "ratethread.php", "editpost.php", "polls.php", "sendthread.php", "printthread.php", "moderation.php" ); if(in_array($current_page, $valid)) { // If we're accessing a post, fetch the forum theme for it and if we're overriding it if($mybb-&gt;input['pid']) { $query = $db-&gt;query(" SELECT f.style, f.overridestyle, p.* FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."posts p ON(f.fid=p.fid) WHERE p.pid='".intval($mybb-&gt;input['pid'])."' LIMIT 1 "); $style = $db-&gt;fetch_array($query); $load_from_forum = 1; } // We have a thread id and a forum id, we can easily fetch the theme for this forum else if($mybb-&gt;input['tid']) { $query = $db-&gt;query(" SELECT f.style, f.overridestyle, t.* FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."threads t ON (f.fid=t.fid) WHERE t.tid='".intval($mybb-&gt;input['tid'])."' LIMIT 1 "); $style = $db-&gt;fetch_array($query); $load_from_forum = 1; } // We have a forum id - simply load the theme from it else if($mybb-&gt;input['fid']) { cache_forums(); $style = $forum_cache[intval($mybb-&gt;input['fid'])]; $load_from_forum = 1; } } unset($valid); // From all of the above, a theme was found if(isset($style['style']) &amp;&amp; $style['style'] &gt; 0) { // This theme is forced upon the user, overriding their selection if($style['overridestyle'] == 1 || !isset($mybb-&gt;user['style'])) { $loadstyle = "tid='".intval($style['style'])."'"; } } // After all of that no theme? Load the board default if(empty($loadstyle)) { $loadstyle = "def='1'"; } // Fetch the theme to load from the database $query = $db-&gt;simple_select("themes", "name, tid, properties, stylesheets", $loadstyle, array('limit' =&gt; 1)); $theme = $db-&gt;fetch_array($query); // No theme was found - we attempt to load the master or any other theme if(!$theme['tid']) { // Missing theme was from a forum, run a query to set any forums using the theme to the default if($load_from_forum == 1) { $db-&gt;update_query("forums", array("style" =&gt; 0), "style='{$style['style']}'"); } // Missing theme was from a user, run a query to set any users using the theme to the default else if($load_from_user == 1) { $db-&gt;update_query("users", array("style" =&gt; 0), "style='{$style['style']}'"); } // Attempt to load the master or any other theme if the master is not available $query = $db-&gt;simple_select("themes", "name, tid, properties, stylesheets", "", array("order_by" =&gt; "tid", "limit" =&gt; 1)); $theme = $db-&gt;fetch_array($query); } $theme = @array_merge($theme, unserialize($theme['properties'])); // Fetch all necessary stylesheets $theme['stylesheets'] = unserialize($theme['stylesheets']); $stylesheet_scripts = array("global", basename($_SERVER['PHP_SELF'])); foreach($stylesheet_scripts as $stylesheet_script) { $stylesheet_actions = array("global"); if($mybb-&gt;input['action']) { $stylesheet_actions[] = $mybb-&gt;input['action']; } // Load stylesheets for global actions and the current action foreach($stylesheet_actions as $stylesheet_action) { if(!$stylesheet_action) { continue; } if($theme['stylesheets'][$stylesheet_script][$stylesheet_action]) { // Actually add the stylesheets to the list foreach($theme['stylesheets'][$stylesheet_script][$stylesheet_action] as $page_stylesheet) { if($already_loaded[$page_stylesheet]) { continue; } $stylesheets .= "&lt;link type=\"text/css\" rel=\"stylesheet\" href=\"{$mybb-&gt;settings['bburl']}/{$page_stylesheet}\" /&gt;\n"; $already_loaded[$page_stylesheet] = 1; } } } } // Are we linking to a remote theme server? if(substr($theme['imgdir'], 0, 7) == "http://") { // If a language directory for the current language exists within the theme - we use it if(!empty($mybb-&gt;user['language'])) { $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb-&gt;user['language']; } else { // Check if a custom language directory exists for this theme if(!empty($mybb-&gt;settings['bblanguage'])) { $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb-&gt;settings['bblanguage']; } // Otherwise, the image language directory is the same as the language directory for the theme else { $theme['imglangdir'] = $theme['imgdir']; } } } else { if(!@is_dir($theme['imgdir'])) { $theme['imgdir'] = "images"; } // If a language directory for the current language exists within the theme - we use it if(!empty($mybb-&gt;user['language']) &amp;&amp; is_dir($theme['imgdir'].'/'.$mybb-&gt;user['language'])) { $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb-&gt;user['language']; } else { // Check if a custom language directory exists for this theme if(is_dir($theme['imgdir'].'/'.$mybb-&gt;settings['bblanguage'])) { $theme['imglangdir'] = $theme['imgdir'].'/'.$mybb-&gt;settings['bblanguage']; } // Otherwise, the image language directory is the same as the language directory for the theme else { $theme['imglangdir'] = $theme['imgdir']; } } } // Theme logo - is it a relative URL to the forum root? Append bburl if(!preg_match("#^(\.\.?(/|$)|([a-z0-9]+)://)#i", $theme['logo']) &amp;&amp; substr($theme['logo'], 0, 1) != "/") { $theme['logo'] = $mybb-&gt;settings['bburl']."/".$theme['logo']; } // Load Main Templates and Cached Templates if(isset($templatelist)) { $templatelist .= ','; } $templatelist .= "css,headerinclude,header,footer,gobutton,htmldoctype,header_welcomeblock_member,header_welcomeblock_guest,header_welcomeblock_member_admin,global_pm_alert,global_unreadreports,"; $templatelist .= ",global_pending_joinrequests,nav,nav_sep,nav_bit,nav_sep_active,nav_bit_active,footer_languageselect,header_welcomeblock_member_moderator,redirect,error"; $templates-&gt;cache($db-&gt;escape_string($templatelist)); // Set the current date and time now $datenow = my_date($mybb-&gt;settings['dateformat'], TIME_NOW, '', false); $timenow = my_date($mybb-&gt;settings['timeformat'], TIME_NOW); $lang-&gt;welcome_current_time = $lang-&gt;sprintf($lang-&gt;welcome_current_time, $datenow.', '.$timenow); // Format the last visit date of this user appropriately if(isset($mybb-&gt;user['lastvisit'])) { $lastvisit = my_date($mybb-&gt;settings['dateformat'], $mybb-&gt;user['lastvisit']) . ', ' . my_date($mybb-&gt;settings['timeformat'], $mybb-&gt;user['lastvisit']); } // Otherwise, they've never visited before else { $lastvisit = $lang-&gt;lastvisit_never; } // If the board is closed and we have an Administrator, show board closed warning $bbclosedwarning = ''; if($mybb-&gt;settings['boardclosed'] == 1 &amp;&amp; $mybb-&gt;usergroup['cancp'] == 1) { eval("\$bbclosedwarning = \"".$templates-&gt;get("global_boardclosed_warning")."\";"); } // Prepare the main templates for use unset($admincplink); // Load appropriate welcome block for the current logged in user if($mybb-&gt;user['uid'] != 0) { // User can access the admin cp and we're not hiding admin cp links, fetch it if($mybb-&gt;usergroup['cancp'] == 1 &amp;&amp; $mybb-&gt;config['hide_admin_links'] != 1) { eval("\$admincplink = \"".$templates-&gt;get("header_welcomeblock_member_admin")."\";"); } if($mybb-&gt;usergroup['canmodcp'] == 1) { eval("\$modcplink = \"".$templates-&gt;get("header_welcomeblock_member_moderator")."\";"); } // Format the welcome back message $lang-&gt;welcome_back = $lang-&gt;sprintf($lang-&gt;welcome_back, $mybb-&gt;user['username'], $lastvisit); // Tell the user their PM usage $lang-&gt;welcome_pms_usage = $lang-&gt;sprintf($lang-&gt;welcome_pms_usage, my_number_format($mybb-&gt;user['pms_unread']), my_number_format($mybb-&gt;user['pms_total'])); eval("\$welcomeblock = \"".$templates-&gt;get("header_welcomeblock_member")."\";"); } // Otherwise, we have a guest else { eval("\$welcomeblock = \"".$templates-&gt;get("header_welcomeblock_guest")."\";"); } $pending_joinrequests = ''; // Read the group leaders cache $groupleaders = $cache-&gt;read("groupleaders"); if($mybb-&gt;user['uid'] != 0 &amp;&amp; is_array($groupleaders) &amp;&amp; array_key_exists($mybb-&gt;user['uid'], $groupleaders)) { $groupleader = $groupleaders[$mybb-&gt;user['uid']]; $gids = ""; foreach($groupleader as $user) { if($user['canmanagerequests'] != 1) { continue; } $gids .= ",{$user['gid']}"; } $query = $db-&gt;simple_select("joinrequests", "COUNT(uid) as total", "gid IN (0{$gids})"); $total_joinrequests = $db-&gt;fetch_field($query, "total"); $pending_joinrequests = ""; if($total_joinrequests &gt; 0) { if($total_joinrequests == 1) { $lang-&gt;pending_joinrequests = $lang-&gt;pending_joinrequest; } else { $lang-&gt;pending_joinrequests = $lang-&gt;sprintf($lang-&gt;pending_joinrequests, $total_joinrequests); } eval("\$pending_joinrequests = \"".$templates-&gt;get("global_pending_joinrequests")."\";"); } } $unreadreports = ''; // This user is a moderator, super moderator or administrator if($mybb-&gt;usergroup['cancp'] == 1 || $mybb-&gt;user['ismoderator'] &amp;&amp; $mybb-&gt;usergroup['canmodcp']) { // Read the reported posts cache $reported = $cache-&gt;read("reportedposts"); // 0 or more reported posts currently exist if($reported['unread'] &gt; 0) { if($reported['unread'] == 1) { $lang-&gt;unread_reports = $lang-&gt;unread_report; } else { $lang-&gt;unread_reports = $lang-&gt;sprintf($lang-&gt;unread_reports, $reported['unread']); } eval("\$unreadreports = \"".$templates-&gt;get("global_unreadreports")."\";"); } } // Got a character set? if($lang-&gt;settings['charset']) { $charset = $lang-&gt;settings['charset']; } // If not, revert to UTF-8 else { $charset = "UTF-8"; } // Is this user apart of a banned group? $bannedwarning = ''; if($mybb-&gt;usergroup['isbannedgroup'] == 1) { // Fetch details on their ban $query = $db-&gt;simple_select("banned", "*", "uid='{$mybb-&gt;user['uid']}'", array('limit' =&gt; 1)); $ban = $db-&gt;fetch_array($query); if($ban['uid']) { // Format their ban lift date and reason appropriately if($ban['lifted'] &gt; 0) { $banlift = my_date($mybb-&gt;settings['dateformat'], $ban['lifted']) . ", " . my_date($mybb-&gt;settings['timeformat'], $ban['lifted']); } else { $banlift = $lang-&gt;banned_lifted_never; } $reason = htmlspecialchars_uni($ban['reason']); } if(empty($reason)) { $reason = $lang-&gt;unknown; } if(empty($banlift)) { $banlift = $lang-&gt;unknown; } // Display a nice warning to the user eval("\$bannedwarning = \"".$templates-&gt;get("global_bannedwarning")."\";"); } $lang-&gt;ajax_loading = str_replace("'", "\\'", $lang-&gt;ajax_loading); // Check if this user has a new private message. if($mybb-&gt;user['pmnotice'] == 2 &amp;&amp; $mybb-&gt;user['pms_unread'] &gt; 0 &amp;&amp; $mybb-&gt;settings['enablepms'] != 0 &amp;&amp; $mybb-&gt;usergroup['canusepms'] != 0 &amp;&amp; $mybb-&gt;usergroup['canview'] != 0 &amp;&amp; ($current_page != "private.php" || $mybb-&gt;input['action'] != "read")) { $query = $db-&gt;query(" SELECT pm.subject, pm.pmid, fu.username AS fromusername, fu.uid AS fromuid FROM ".TABLE_PREFIX."privatemessages pm LEFT JOIN ".TABLE_PREFIX."users fu ON (fu.uid=pm.fromid) WHERE pm.folder='1' AND pm.uid='{$mybb-&gt;user['uid']}' AND pm.status='0' ORDER BY pm.dateline DESC LIMIT 1 "); $pm = $db-&gt;fetch_array($query); if($pm['fromuid'] == 0) { $pm['fromusername'] = $lang-&gt;mybb_engine; $user_text = $pm['fromusername']; } else { $user_text = build_profile_link($pm['fromusername'], $pm['fromuid']); } if($mybb-&gt;user['pms_unread'] == 1) { $privatemessage_text = $lang-&gt;sprintf($lang-&gt;newpm_notice_one, $user_text, $pm['pmid'], htmlspecialchars_uni($pm['subject'])); } else { $privatemessage_text = $lang-&gt;sprintf($lang-&gt;newpm_notice_multiple, $mybb-&gt;user['pms_unread'], $user_text, $pm['pmid'], htmlspecialchars_uni($pm['subject'])); } eval("\$pm_notice = \"".$templates-&gt;get("global_pm_alert")."\";"); } // Set up some of the default templates eval("\$headerinclude = \"".$templates-&gt;get("headerinclude")."\";"); eval("\$gobutton = \"".$templates-&gt;get("gobutton")."\";"); eval("\$htmldoctype = \"".$templates-&gt;get("htmldoctype", 1, 0)."\";"); eval("\$header = \"".$templates-&gt;get("header")."\";"); $copy_year = my_date("Y", TIME_NOW); // Are we showing version numbers in the footer? if($mybb-&gt;settings['showvernum'] == 1) { $mybbversion = ' '.$mybb-&gt;version; } else { $mybbversion = ''; } // Check to see if we have any tasks to run $task_cache = $cache-&gt;read("tasks"); if(!$task_cache['nextrun']) { $task_cache['nextrun'] = TIME_NOW; } if($task_cache['nextrun'] &lt;= TIME_NOW) { $task_image = "&lt;img src=\"{$mybb-&gt;settings['bburl']}/task.php\" border=\"0\" width=\"1\" height=\"1\" alt=\"\" /&gt;"; } else { $task_image = ''; } // Are we showing the quick language selection box? $lang_select = ''; if($mybb-&gt;settings['showlanguageselect'] != 0) { $languages = $lang-&gt;get_languages(); foreach($languages as $key =&gt; $language) { $language = htmlspecialchars_uni($language); // Current language matches if($lang-&gt;language == $key) { $lang_options .= "&lt;option value=\"{$key}\" selected=\"selected\"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$language}&lt;/option&gt;\n"; } else { $lang_options .= "&lt;option value=\"{$key}\"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{$language}&lt;/option&gt;\n"; } } $lang_redirect_url = get_current_location(true, 'language'); eval("\$lang_select = \"".$templates-&gt;get("footer_languageselect")."\";"); } // DST Auto detection enabled? if($mybb-&gt;user['uid'] &gt; 0 &amp;&amp; $mybb-&gt;user['dstcorrection'] == 2) { $auto_dst_detection = "&lt;script type=\"text/javascript\"&gt;if(MyBB) { Event.observe(window, 'load', function() { MyBB.detectDSTChange('".($mybb-&gt;user['timezone']+$mybb-&gt;user['dst'])."'); }); }&lt;/script&gt;\n"; } eval("\$footer = \"".$templates-&gt;get("footer")."\";"); // Add our main parts to the navigation $navbits = array(); $navbits[0]['name'] = $mybb-&gt;settings['bbname_orig']; $navbits[0]['url'] = $mybb-&gt;settings['bburl']."/index.php"; // Set the link to the archive. $archive_url = $mybb-&gt;settings['bburl']."/archive/index.php"; // Check banned ip addresses if(is_banned_ip($session-&gt;ipaddress, true)) { if ($mybb-&gt;user['uid']) { $db-&gt;delete_query("sessions", "ip='".$db-&gt;escape_string($session-&gt;ipaddress)."' OR uid='{$mybb-&gt;user['uid']}'"); } else { $db-&gt;delete_query("sessions", "ip='".$db-&gt;escape_string($session-&gt;ipaddress)."'"); } error($lang-&gt;error_banned); } $closed_bypass = array( "member.php" =&gt; array( "login", "do_login", "logout", ), "captcha.php", ); // If the board is closed, the user is not an administrator and they're not trying to login, show the board closed message if($mybb-&gt;settings['boardclosed'] == 1 &amp;&amp; $mybb-&gt;usergroup['cancp'] != 1 &amp;&amp; !in_array($current_page, $closed_bypass) &amp;&amp; (!is_array($closed_bypass[$current_page]) || !in_array($mybb-&gt;input['action'], $closed_bypass[$current_page]))) { // Show error $lang-&gt;error_boardclosed .= "&lt;blockquote&gt;{$mybb-&gt;settings['boardclosed_reason']}&lt;/blockquote&gt;"; error($lang-&gt;error_boardclosed); exit; } // Load Limiting if($mybb-&gt;usergroup['cancp'] != 1 &amp;&amp; $mybb-&gt;settings['load'] &gt; 0 &amp;&amp; ($load = get_server_load()) &amp;&amp; $load != $lang-&gt;unknown &amp;&amp; $load &gt; $mybb-&gt;settings['load']) { // User is not an administrator and the load limit is higher than the limit, show an error error($lang-&gt;error_loadlimit); } // If there is a valid referrer in the URL, cookie it if(!$mybb-&gt;user['uid'] &amp;&amp; $mybb-&gt;settings['usereferrals'] == 1 &amp;&amp; (isset($mybb-&gt;input['referrer']) || isset($mybb-&gt;input['referrername']))) { if(isset($mybb-&gt;input['referrername'])) { $condition = "username='".$db-&gt;escape_string($mybb-&gt;input['referrername'])."'"; } else { $condition = "uid='".intval($mybb-&gt;input['referrer'])."'"; } $query = $db-&gt;simple_select("users", "uid", $condition, array('limit' =&gt; 1)); $referrer = $db-&gt;fetch_array($query); if($referrer['uid']) { my_setcookie("mybb[referrer]", $referrer['uid']); } } if($mybb-&gt;usergroup['canview'] != 1) { // Check pages allowable even when not allowed to view board if(defined("ALLOWABLE_PAGE")) { if(is_string(ALLOWABLE_PAGE)) { $allowable_actions = explode(',', ALLOWABLE_PAGE); if(!in_array($mybb-&gt;input['action'], $allowable_actions)) { error_no_permission(); } unset($allowable_actions); } else if(ALLOWABLE_PAGE !== 1) { error_no_permission(); } } else { error_no_permission(); } } // work out which items the user has collapsed $colcookie = $mybb-&gt;cookies['collapsed']; // set up collapsable items (to automatically show them us expanded) if($colcookie) { $col = explode("|", $colcookie); if(!is_array($col)) { $col[0] = $colcookie; // only one item } unset($collapsed); foreach($col as $key =&gt; $val) { $ex = $val."_e"; $co = $val."_c"; $collapsed[$co] = "display: show;"; $collapsed[$ex] = "display: none;"; $collapsedimg[$val] = "_collapsed"; } } // Run hooks for end of global.php $plugins-&gt;run_hooks("global_end"); $globaltime = $maintimer-&gt;getTime(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload