MyBB Community Forums

Full Version: Need some help reinstalling/repairing a running forum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Dear all,
I run an upgraded 1.6.2 mybb forum at http://www.linguisten.de
Unfortunately, over the time some older plugins and template changes accumulated in a few dysfunctional things like e.g. a broken stats page (http://www.linguisten.de/stats.php).

I tried searching this board and the wiki, but either I was too stupid to find the right guide or there isn't any. What I would like to do is the following:

  1. Backup all user, config and forum data, excluding info on plugins and themes/templates
  2. Do a clean reinstall the forum
  3. Insert the backups
  4. Install one or two new themes and language packs
  5. Install only those plugins (again) I really need

I feel I don't really now ho to do steps 1-3, and would appreciate a step-by-step guid or someone's hands-on help in this matter; actually, I am willing to pay fr that, if necessary.

thx
jan
You don't need to do anything like reinstalling, you just have some errors in templates, the stats template, and a template added by a plugin. Messing about with backups etc usually isn't necessary.
Well, I've been trying for weeks to clear up that mess. The plugin in question cannot be uninstalled because it wants to delete a table that does not exist any more, and the templates are ok, i hecked the diff to a clean new install.
Well there will be something in there that's causing this error, it wouldn't give an error like this for no reason. Post your stats template here and I'll find it for you.

What's the name of the table it's trying to create??
This is the template

<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->board_stats}</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->board_stats}</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>{$lang->totals}</strong></td>
<td class="tcat" width="50%"><strong>{$lang->averages}</strong></td>
</tr>
<tr>
<td class="trow1" valign="top">
{$lang->posts} <strong>$stats['numposts']}</strong><br />
{$lang->threads} <strong>$stats['numthreads']}</strong><br />
{$lang->members} <strong>{$stats['numusers']}</strong>
</td>
<td class="trow1" rowspan="3" valign="top">
{$lang->ppd} <strong>{$postsperday}</strong><br />
{$lang->tpd} <strong>{$threadsperday}</strong><br />
{$lang->mpd} <strong>{$membersperday}</strong><br />
{$lang->ppm} <strong>{$postspermember}</strong><br />
{$lang->rpt} <strong>{$repliesperthread}</strong>
</td>
</tr>
<tr>
<td class="tcat" valign="top"><strong>{$lang->general}</strong></td>
</tr>
<tr>
<td class="trow1">
{$lang->newest_member} {$stats['newest_user']}<br />
{$lang->members_posted} <strong>{$havepostedpercent}</strong><br />
{$lang->todays_top_poster}<br />
{$lang->popular_forum}
</td>
</tr>
</table>


<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->most_popular}</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>{$lang->most_replied_threads}</strong></td>
<td class="tcat" width="50%"><strong>{$lang->most_viewed_threads}</strong></td>
</tr>
<tr>
<td class="trow1" valign="top">{$mostreplies}</td>
<td class="trow1" valign="top">{$mostviews}</td>
</tr>
</table>
{$footer}
</body>
</html>


The (nonexistent) table is "prostats" from this old plugin:
<?php
/******************************************************************************
 *                                                                            *
 * SuperStats - Super Statistics for MyBB - Version 0.45                      *
 *                                                                            * 
 * Copyright © 2008 Das-Computer-Board.de, All Rights Reserved                *
 *                                                                            *
 * Website: http://das-computer-board.de/                                     *
 * License: http://creativecommons.org/licenses/by-nc-nd/3.0/                 *
 *                                                                            * 
 ******************************************************************************
 *                                                                            *
 * This file safes SuperStats data in the database                            *
 *                                                                            *
 ******************************************************************************/ 
 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("global_end", "SuperStats_parse"); //Hook global.php for Statistics
$plugins->add_hook("pre_output_page", "SuperStats_show"); //Pre output parsing for Statistics

//Information about PlugIn
function SuperStats_info()
{
	return array(
		"name"			=> "SuperStats", 
		"description"	=> "Super Statistics for MyBB",
		"website"		=> "http://das-computer-board.de/",
		"author"		=> "Das-Computer-Board.de",
		"authorsite"	=> "http://das-computer-board.de/",
		"version"		=> "0.45",
		"guid" 			=> "29f1d3d1fe8327579697fa5f927fefe7",
		"compatibility" => "14*"
	);
}

//PlugIn-Installation
function SuperStats_install()
{
	global $db; //Use global $db variable
	$db->query("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."prostats (
		ip varchar(50) NOT NULL ,
		uid int( 10 ) NOT NULL ,
		time bigint(30) NOT NULL,
		url text NOT NULL,
		browser text NOT NULL ,
		browser_version text NOT NULL ,
		os text NOT NULL ,
		country varchar(3) NOT NULL ,
		referer text NOT NULL
		) TYPE = MYISAM ;"
	); //Create SuperStats-table
}

//Get if SuperStats is installed
function SuperStats_is_installed()
{
	global $db; //Use global $db variable
	if($db->table_exists("prostats")) //if SuperStats-table exist...
  {
 		return true; //...SuperStats is installed...
  }
  return false; //...if not its not
}
function SuperStats_uninstall()
{
	global $db; //Use global $db variable
	$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."prostats;"); //delete SuperStats-table
}

//function for Safari-Browser
function SuperStats_getsafariversionbybuilt($buildid) {
    $build_version = array(
        //ggf noch fuer safari 3.0.x < 3.0.4
        '523'=>'3.0.4',
        '412.5'=>'2.0.1',
        '412'=>'2.0',
        '416'=>'2.0.2',
        '417'=>'2.0.3',
        '419'=>'2.0.4',
        '100.1'=>'1.1.1',
        '100'=>'1.1',
        '125.7'=>'1.2.2',
        '125.8'=>'1.2.2',
        '125.9'=>'1.2.3',
        '125.11'=>'1.2.4',
        '125.12'=>'1.2.4',
        '312.6'=>'1.3.2',
        '312.5'=>'1.3.2',
        '312.3.1'=>'1.3.1',
        '312.3'=>'1.3.1',
        '312'=>'1.3',
        '85.5'=>'1.0',
        '85.7'=>'1.0.2',
        '85.8.1'=>'1.0.3',
        '85.8'=>'1.0.3'
        );
    foreach($build_version as $build=>$version) {
        if(strlen($build) > 3) {
            if($buildid == $build) {
                return $version;
            }
        } else {
            if(substr($buildid, 0, 3) == $build) {
                return $version;
            }
        }
    }
}  

//function to get information about user agent (browser, os)
function SuperStats_userinfo() {
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    $browser = "Unbekannt";
    $os    = "Unbekannt";
    $version = "Unbekannt";
    
    if(preg_match("~Windows~si", $user_agent)) { // Windows
        if(preg_match("~Windows NT 6.0~si", $user_agent)) { // Windows Vista
            $os = "Windows Vista";
        }
        if(preg_match("~Windows NT 5.1~si", $user_agent)) { // Windows XP
            $os    = "Windows XP";
        }
        if(preg_match("~Windows NT 5.0~si", $user_agent)) { // Windows 2000
            $os    = "Windows 2000";
        }
        if(preg_match("~Windows 98~si", $user_agent) || preg_match("~Win98~si", $user_agent)) { // Windows 98
            $os    = "Windows 98";
        }
        if(preg_match("~Windows 95~si", $user_agent) || preg_match("~Win95~si", $user_agent)) { // Windows 95
            $os    = "Windows 95";
        }
        if(preg_match("~Windows ME~si", $user_agent) || preg_match("~Win95~si", $user_agent)) { // Windows ME
            $os    = "Windows ME";
        }
    }
    if(preg_match("~Linux~si", $user_agent)) { // Linux
        $os = "Linux";
    }
    if(preg_match("~OS\/2~si", $user_agent)) { // OS/2
        $os = "OS/2";
    }
    if(preg_match("~Macintosh~si", $user_agent) || preg_match("~Mac_PowerPC~si", $user_agent)) {  // Mac
        $os = "Mac OS X";
    }
    if(preg_match("~SunOS~si", $user_agent) || preg_match("~Solaris~si", $user_agent)) { // SunOS
        $os = "SunOS, Solaris";    
    }
    
    if(preg_match("~Mozilla~si", $user_agent)) { // Mozilla Browser (falls genauere Analyse des Browsers fehlschlaegt)
        $browser = "Mozilla";
    }
    
    if(preg_match("~Gecko~si", $user_agent)) { // Gecko Browser (falls genauere Analyse des Browsers fehlschlaegt)
        $browser = "Gecko";
    }
    
    if(str_replace("Firefox","xxx",$user_agent) != $user_agent) { // Firefox Browser
        $browser = "Firefox";
        $pos     = strpos($user_agent, "Firefox/");
        $version = trim(substr($user_agent, $pos+8));
    }
    if(preg_match("~SeaMonkey~si", $user_agent)) { // SeaMonkey
        $browser = "SeaMonkey";
        $pos     = strpos($user_agent, "SeaMonkey/");
        $version = trim(substr($user_agent, $pos+10));
    }
    if(preg_match("~Epiphany~si", $user_agent)) { // Epiphany
        $browser = "Epiphany";
        $pos     = strpos($user_agent, "Epiphany/");
        $version = trim(preg_replace("~\((.*?)\)~si", "", substr($user_agent, $pos+9)));
    }
    if(preg_match("~Galeon~si", $user_agent)) { // Epiphanyvorgaenger Galeon
        $browser = "Galeon";
        $pos     = strpos($user_agent, "(");
        $version = trim(substr($user_agent, 19, $pos-19));
    }
    if(preg_match("~Camino~si", $user_agent)) { // Camino
        $browser = "Camino";
        $pos     = strpos($user_agent, "Camino/");
        $version = trim(preg_replace("~\((.*?)\)~si", "", substr($user_agent, $pos+7)));
    }
    if(preg_match("~Opera~si", $user_agent)) { // Opera
        $browser = "Opera";
        $pos     = strpos($user_agent, "Opera");
        if($pos    == 0) {
            $version = substr($user_agent, 6, 4);
        } else {
            $pos    = strpos($user_agent, "Opera");
            $version= trim(preg_replace("~\[(.*?)\]~si", "", substr($user_agent, $pos+6)));
        }
    }
    if(preg_match("~MSIE~si", $user_agent)) { // Internet Explorer
        $browser = "Internet Explorer";
        $version = explode(";", $user_agent);
        $version = substr($version[1], 6);
    }
    if(preg_match("~Safari~si", $user_agent)) { // Safari Browser
        $browser = "Safari";
        $pos     = strpos($user_agent, "Safari/");
        $build     = trim(substr($user_agent, $pos+7));
        $version = SuperStats_getsafariversionbybuilt( $build );
    }
    if(preg_match("~Konqueror~si", $user_agent)) { // Konqueror Browser
        $browser = "Konqueror";
        $version = explode(";", $user_agent);
        $version = explode("/", $version[1]);
        $version = $version[1];
    }
    if(preg_match("~Netscape~si", $user_agent)) { // Netscape
        $browser = "Netscape";
        $version = explode("/", $user_agent);
        $version = trim(preg_replace("~\((.*?)\)~si", "", $version[3]));
    }
    
    return array('browser'=>$browser, 'version'=>$version, 'os'=>$os);
}

//function to parse if user goes on forum
function SuperStats_parse()
{
global $db, $mybb; //Use global variables (database,mybb)

$ip = $db->escape_string(getenv("REMOTE_ADDR")); //Get IP
$uid = $mybb->user['uid']; //Get UID
$time = time(); //Get Current Timestamp
$usrinfo = SuperStats_userinfo(); //Get User agent info
$url = $db->escape_string($_SERVER['REQUEST_URI']); //Get Requested URL
$browser = $db->escape_string($usrinfo['browser']); //Get Browser
$browser_version = $db->escape_string($usrinfo['version']); //Get Browser-version
$os = $db->escape_string($usrinfo['os']); //Get OS 
$host = gethostbyaddr($ip); //Get Hostname 
$hostarr = explode(".",$host);
$country_id = count($hostarr)-1;
$country = $db->escape_string($hostarr[$country_id]); //Get User-Country
$ref =$db->escape_string(getenv("HTTP_REFERER")); //Get Referer

$sql = "INSERT INTO `".TABLE_PREFIX."prostats` VALUES ('$ip', '$uid', '$time', '$url', '$browser', '$browser_version', '$os', '$country', '$ref');";
$db->query($sql); //Insert informations
if ($uid != 0) 
{
//update lastonline if needed (fixes also bug in mybb)
$query = $db->query("
		UPDATE ".TABLE_PREFIX."users 
		SET lastactive=$time
		WHERE uid = $uid
	");
}
}

function SuperStats_show($page)
{
  global $mybb;
  $sessionx = $mybb->session;
  if($sessionx->is_spider)
  {
  global $db;
  $add = ' Using SuperStats made by <a href="http://das-computer-board.de/">Das Computer Board</a> - <a href="http://das-computer-board.de/forum.html">Computer Forum</a>, <a href="http://das-computer-board.de/Tutorials.html">Computer Tutorials</a>, <a href="http://das-computer-board.de/blog/">Computer Blog</a>, <a href="http://das-computer-board.de/irc.html">Computer Chat</a>, <a href="http://das-computer-board.de/tools.html">Computer Tools</a>, <a href="http://das-computer-board.de/Photoshop-Tutorials.html">Photoshop Tutorials</a>, <a href="http://das-computer-board.de/PageRank-Checker-seo-tool.html">PageRank Checker</a>, <a href="http://das-computer-board.de/Website-Spider-PageRank-Checker-seo-tool.html">Website Spider PageRank Checker</a>, <a href="http://das-computer-board.de/Anonymitaets-Check-internet-tool.html">Anonymit&auml;ts Check</a>, <a href="http://das-computer-board.de/desktop/">Online Desktop</a> ';
	$page = str_replace("</body>", "$add</body>", $page);
	}
	return $page;
}

?>
Problems in the template:

$stats['numposts']} should be {$stats['numposts']}
$stats['numthreads']} should be {$stats['numthreads']}

I don't know why it's saying that table doesn't exist though as the query will only delete it if it exists... but, if you edit the file and remove:

$db->query("DROP TABLE IF EXISTS ".TABLE_PREFIX."prostats;"); //delete SuperStats-table

then it won't try and drop it. Make sure you edit the file in a text editor other than notepad.
(2011-02-27, 09:07 PM)MattRogowski Wrote: [ -> ]$stats['numposts']} should be {$stats['numposts']}
$stats['numthreads']} should be {$stats['numthreads']}
Yes. And then I get this result: https://www.linguisten.de/stats.php - see attached screenshot.


Quote:Make sure you edit the file in a text editor other than notepad.
i used vi. ok. uninstall worked. but the stats page is still messed up as above.
the correct numbers for the stats appear in the acp, however.
Go to ACP > Tools & Maintenance > Cache Manager > stats > Rebuild Cache.
Tried that. It doesn't change anything. If they were messy in the cache, the stats figures wouldn't appear correctly in the acp index page.
Go to ACP > Tools & Maintenance > File Verification > run this, does it say any files have changed?? I can't see how every value in the $stats array is being turned into a <, doesn't make any sense.
Pages: 1 2 3