Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is this possible?

    Ok I am moving away from nuke and building my own site but was wondering if this was possible. I still have my nuke database and have this "block" and was wondering how I would still be able to include this in my new index.php if I wanted to.

    I was looking for any insight or tutorials that would explain how I would maybe do this. I have tried different things but really am out on a limb.

    I am looking to query the information in the database for this block.

    I have the language folder moved and thats not giving me an error but this is, line 34- "Fatal error: Call to a member function on a non-object in..."

    PHP Code:
            $username $cookie[1];

    LINE 34 STARTS HERE--->        $db->sql_query("CREATE TABLE IF NOT EXISTS " $prefix "_lastseen (id INT (15) not null AUTO_INCREMENT, username TEXT not null, date INT(15) not null, ip CHAR(50), PRIMARY KEY (id), UNIQUE (id))"); 
    Here is the nuke block:
    PHP Code:
    <?

    // Michael Yarbrough
    // opedog@comediccadavers.com
    // http://www.comediccadavers.com/

    // PHP-Nuke 5.1 Blocks version by Thiago Campos aka Mr. Hemp (mrhemp@amigoz.org)

    // Updated to work with PHP-Nuke 6.0 and the phpBB2 forum port by
    // Tom Nitzschner (tom@toms-home.com)
    // http://bbtonuke.sourceforge.net (http://www.toms-home.com)
    //
    // As always, make a backup before messing with anything. All code
    // release by me is considered sample code only. It may be fully
    // functual, but you use it at your own risk, if you break it,
    // you get to fix it too. No waranty is given or implied.
    //
    // Please change your prefix to suit your database.
    // Set $numusers to the count of people you want listed +1
    //

    global $cookie$prefix$currentlang$username$numusers$db;
    $numusers 20;

    if(
    file_exists("language/lastseen/lastseen-$currentlang.php")) {
        include(
    "language/lastseen/lastseen-$currentlang.php");
    }
    else {
        include(
    "language/lastseen/lastseen-english.php");
    }

            
    $username $cookie[1];

            
    $db->sql_query("CREATE TABLE IF NOT EXISTS " $prefix "_lastseen (id INT (15) not null AUTO_INCREMENT, username TEXT not null, date INT(15) not null, ip CHAR(50), PRIMARY KEY (id), UNIQUE (id))");

            if (isset(
    $username)) {
                    
    $ip getenv("REMOTE_HOST");
                    if (empty(
    $ip)) {
                            
    $ip getenv("REMOTE_ADDR");
                    }

                    
    $result $db->sql_query("SELECT * FROM " $prefix "_lastseen WHERE username = \"$username\"");
                    if (
    $db->sql_numrows($result) > 0) {
                            
    $db->sql_query("UPDATE " $prefix "_lastseen SET date = " time() . " WHERE username = \"$username\"");
                    } else {
                            
    $db->sql_query("INSERT INTO " $prefix "_lastseen VALUES (\"\", \"$username\", ".time().", \"".$ip."\")");
                    }
            }
            
    $content "";
            
    $result $db->sql_query("SELECT username, date FROM " $prefix "_lastseen ORDER BY date DESC limit $numusers");
            while (list(
    $uname$date) = $db->sql_fetchrow($result)) {
                    if (
    $uname != $username) {
                            
    $realtime time() - $date;
                            
    $dont false;

                            
    // how many days ago?
                            
    if ($realtime >= (60*60*24*2)) { // if it's been more than 2 days
                                    
    $days floor($realtime / (60*60*24));
                                    
    $dont true;
                            } else if (
    $realtime >= (60*60*24)) { // if it's been less than 2 days
                                    
    $days 1;
                                    
    $realtime -= (60*60*24);
                            }

                            if (!
    $dont) {
                                    
    // how many hours ago?
                                    
    if ($realtime >= (60*60)) {
                                            
    //$content .= " ($realtime) ";
                                            
    $hours floor($realtime / (60*60));
                                            
    $realtime -= (60*60*$hours);
                                    }

                                    
    // how many minutes ago?
                                    
    if ($realtime >= 60) {
                                            
    $mins floor($realtime 60);
                                            
    $realtime -= (60*$mins);
                                    }

                                    
    // just a little precation, although I don't *think* mins will ever be 60...
                                    
    if ($mins == 60) {
                                            
    $mins 0;
                                            
    $hours += 1;
                                    }
                            }
                
    $myresult $db->sql_query("select user_id from " $prefix "_users where (username='$uname')");
                    list(
    $uid) = $db->sql_fetchrow($myresult);
                            
    $content .= "<font class=tiny><a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=".$uid."\">".UsernameColor($uname)."</a>:";
                            if (
    $dont) {
                                    
    $content .= " ".$days." "._LASTSEENDAYS."";
                            } else {
                                    if (
    $days 0) {
                                            
    $content .= " ".$days." "._LASTSEENDAY."".(($hours == && $mins == 0)?(""):(","));
                                    }
                                    if (
    $hours 0) {
                                            
    $content .= " ".$hours." ".(($hours 1)?(""._LASTSEENHOURS.""):(""._LASTSEENHOUR."")).(($mins == 0)?(""):(","));
                                    }
                                    if (
    $mins 0) {
                                            
    $content .= " ".$mins." ".(($mins 1)?(""._LASTSEENMINUTES.""):(""._LASTSEENMINUTE.""))."";
                                    }  else { 
    // less than a minute :)
                                            
    $content .= " ".$realtime." "._LASTSEENSECONDS."";
                                    }
                            }

                            
    $content .= " "._LASTSEENAGO."</font><br>";

                            
    $days 0;
                            
    $hours 0;
                            
    $mins 0;
                            
    $dont false;
                    }
            }

            
    $content .= "";
            


    ?>
    Thanks for any help. I just figured if the database is still there then I could use some of it if I wanted to.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Pure speculation... but that statement it's crashing on is the first database call, so I'd look into your connection to the database (or lack thereof).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •