Encyclopedia_hack for php nuke 6.9

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Encyclopedia_hack for php nuke 6.9
Cyperangel
CZ Newbie
Cyperangel has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Feb 06, 2004
0.00 posts per day
Posts: 13
Points: 2,904
   
Hello all.

I have downloaded a encyclopedia hack, so that my users can add terms to the encyclopedia as well as me..

All is fine and dandy, except that i am now getting a PHP error in my admin section, just above my "waiting content" block.

The error is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/web/gb0432/test/includes/sql_layer.php on line 238

The basics of the hack is that users in the encyclopedia can add a term, and then i as administrator should be able to approve and make public that term..

So far, its possible to add a term. But alas, i cant approve them as admin, since it never shows up in my admin part. All i get is that stupid error. If anybody feels like helping me, i will gladly supply any and all information you ask for, as I need this hack quite a lot.

Pretty pretty please, with sugar on top

Regards
Cyperangel
[ Register or login to view links on this board. ]

PS, sorry bout my bad syntax and typoes... I drive at english hehe



Back to top Reply with quote
#2   re: Encyclopedia_hack for php nuke 6.9
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.71 posts per day
Posts: 5530
Points: 481,695
   
This error is generally caused by trying to query something from the database that isn't there
Here's how to debug from NC to find out a more detailed message:

Open sql_layer.php go to line 300 and change:

case "MySQL":
$row = mysql_fetch_row($res);
return $row;
break;;



TO:

case "MySQL":
if ($row = mysql_fetch_row($res)) {
return $row;
} else {
print (mysql_error());
}
break;;



Upload the changed file, go back to your site and in the error message you should now see a better error report and then repost here


taut


Back to top Reply with quote
#3   re: Encyclopedia_hack for php nuke 6.9
Cyperangel
CZ Newbie
Cyperangel has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Feb 06, 2004
0.00 posts per day
Posts: 13
Points: 2,904
   
See, that is the fun part. Ive opened every single file, that even remotely had anything to do with that name, and the closest match i could find to the code u said i should look for, was this:

case "MySQL":
        $dbi=@mysql_connect($host, $user, $password);
   mysql_select_db($db);
        return $dbi;
    break;;



And this one:

function sql_logout($id)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $dbi=@mysql_close($id);
        return $dbi;
    break;;


And a few other things, that alrhough they got the case myssql start, dont have the rest of the lines matching....

IVe attached the sgl_layer file, i hope that that makes a bit more sense icon_smile.gif


Attached Files
sql_layer.txt (14.17 KB, Downloaded: 5234 Time(s))


Back to top Reply with quote
#4   re: Encyclopedia_hack for php nuke 6.9
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.71 posts per day
Posts: 5530
Points: 481,695
   
I checked out your attached file and I don't know why it looks so different than mine and what's on the fix. Here's mine...try and upload it and see if that fixes your problem:

<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* postgres fix by Rubén Campos - Oscar Silla                         */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (eregi("sql_layer.php",$_SERVER['PHP_SELF'])) {
    Header("Location: ../index.php");
    die();
}

/* $dbtype = "MySQL"; */
/* $dbtype = "mSQL"; */
/* $dbtype = "postgres"; */
/* $dbtype = "postgres_local";// When postmaster start without "-i" option. */
/* $dbtype = "ODBC"; */
/* $dbtype = "ODBC_Adabas"; */
/* $dbtype = "Interbase"; */
/* $dbtype = "Sybase"; */

/*
* sql_connect($host, $user, $password, $db)
* returns the connection ID
*/


class ResultSet {
   var $result;
   var $total_rows;
   var $fetched_rows;

   function set_result( $res ) {
      $this->result = $res;
   }

   function get_result() {
      return $this->result;
   }

   function set_total_rows( $rows ) {
      $this->total_rows = $rows;
   }

   function get_total_rows() {
      return $this->total_rows;
   }

   function set_fetched_rows( $rows ) {
      $this->fetched_rows = $rows;
   }

   function get_fetched_rows() {
      return $this->fetched_rows;
   }

   function increment_fetched_rows() {
      $this->fetched_rows = $this->fetched_rows + 1;
   }
}



function sql_connect($host, $user, $password, $db)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $dbi=@mysql_connect($host, $user, $password);
   mysql_select_db($db);
        return $dbi;
    break;;

    case "mSQL":
         $dbi=msql_connect($host);
    msql_select_db($db);
    return $dbi;
    break;;


    case "postgres":
         $dbi=@pg_connect("host=$host user=$user password=$password port=5432 dbname=$db");
         return $dbi;
    break;;

    case "postgres_local":
         $dbi=@pg_connect("user=$user password=$password dbname=$db");
         return $dbi;
    break;;

    case "ODBC":
         $dbi=@odbc_connect($db,$user,$password);
         return $dbi;
    break;;

    case "ODBC_Adabas":
         $dbi=@odbc_connect($host.":".$db,$user,$password);
    return $dbi;
    break;;

    case "Interbase":
         $dbi=@ibase_connect($host.":".$db,$user,$password);
         return $dbi;
    break;;

    case "Sybase":
        $dbi=@sybase_connect($host, $user, $password);
       sybase_select_db($db,$dbi);
   return $dbi;
    break;;

    default:
    break;;
    }

}

function sql_logout($id)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $dbi=@mysql_close($id);
        return $dbi;
    break;;

    case "mSQL":
         $dbi=@msql_close($id);
         return $dbi;
    break;;

    case "postgres":
    case "postgres_local":
         $dbi=@pg_close($id);
         return $dbi;
    break;;
 
    case "ODBC":
    case "ODBC_Adabas":
         $dbi=@odbc_close($id);
         return $dbi; 
    break;;

    case "Interbase":
         $dbi=@ibase_close($id);
         return $dbi;
    break;;

    case "Sybase":
        $dbi=@sybase_close($id);
        return $dbi;
    break;;

    default:
    break;;
    }
}


/*
* sql_query($query, $id)
* executes an SQL statement, returns a result identifier
*/

function sql_query($query, $id)
{

global $dbtype;
global $sql_debug;
$sql_debug = 0;
if($sql_debug) echo "SQL query: ".str_replace(",",", ",$query)."<BR>";
switch ($dbtype) {

    case "MySQL":
        $res=@mysql_query($query, $id);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $res;
    break;;

    case "mSQL":
        $res=@msql_query($query, $id);
        return $res;
    break;;

    case "postgres":
    case "postgres_local":
   $res=pg_exec($id,$query);
   $result_set = new ResultSet;
   $result_set->set_result( $res );
   $result_set->set_total_rows( sql_num_rows( $result_set ) );
   $result_set->set_fetched_rows( 0 );
        return $result_set;
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $res=@odbc_exec($id,$query);
        return $res;
    break;;

    case "Interbase":
        $res=@ibase_query($id,$query);
        return $res;
    break;;

    case "Sybase":
        $res=@sybase_query($query, $id);
        return $res;
    break;;

    default:
    break;;

    }
}

/*
* sql_num_rows($res)
* given a result identifier, returns the number of affected rows
*/

function sql_num_rows($res)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $rows=mysql_num_rows($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $rows;
    break;;

    case "mSQL": 
        $rows=msql_num_rows($res);
        return $rows;
    break;;

    case "postgres":
    case "postgres_local":
        $rows=pg_numrows( $res->get_result() );
        return $rows;
    break;;
       
    case "ODBC":
    case "ODBC_Adabas":
        $rows=odbc_num_rows($res);
        return $rows;
    break;;
       
    case "Interbase":
   echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
        return $rows;
    break;;

    case "Sybase":
        $rows=sybase_num_rows($res);
        return $rows;
    break;;

    default:
    break;;
    }
}

/*
* sql_fetch_row(&$res,$row)
* given a result identifier, returns an array with the resulting row
* Needs also a row number for compatibility with postgres
*/

function sql_fetch_row(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $row = mysql_fetch_row($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

    case "mSQL":
        $row = msql_fetch_row($res);
        return $row;
    break;;

    case "postgres":
    case "postgres_local":
   if ( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = pg_fetch_row($res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      return $row;
   } else {
      return false;
   }
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $row = array();
        $cols = odbc_fetch_into($res, $nr, $row);
        return $row;
    break;;

    case "Interbase":
        $row = ibase_fetch_row($res);
        return $row;
    break;;

    case "Sybase":
        $row = sybase_fetch_row($res);
        return $row;
    break;;

    default:
    break;;
    }
}

/*
* sql_fetch_array($res,$row)
* given a result identifier, returns an associative array
* with the resulting row using field names as keys.
* Needs also a row number for compatibility with postgres.
*/

function sql_fetch_array(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype)
    {
    case "MySQL":
        $row = array();
        $row = mysql_fetch_array($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

    case "mSQL":
        $row = array();
        $row = msql_fetch_array($res);
        return $row;
    break;;

    case "postgres":
    case "postgres_local":
   if( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = array();
      $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      return $row;
   } else {
      return false;
   }
    break;;

/*
* ODBC doesn't have a native _fetch_array(), so we have to
* use a trick. Beware: this might cause HUGE loads!
*/

    case "ODBC":
        $row = array();
        $result = array();
        $result = odbc_fetch_row($res, $nr);
   $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
        for($count=1; $count < $nf+1; $count++)
   {
            $field_name = odbc_field_name($res, $count);
            $field_value = odbc_result($res, $field_name);
            $row[$field_name] = $field_value;
        }
        return $row;
    break;;

    case "ODBC_Adabas":
        $row = array();
        $result = array();
        $result = odbc_fetch_row($res, $nr);

        $nf = count($result)+2; /* Field numbering starts at 1 */
   for($count=1; $count < $nf; $count++) {
       $field_name = odbc_field_name($res, $count);
       $field_value = odbc_result($res, $field_name);
       $row[$field_name] = $field_value;
   }
        return $row;
    break;;

    case "Interbase":
   $orow=ibase_fetch_object($res);
   $row=get_object_vars($orow);
        return $row;
    break;;

    case "Sybase":
        $row = sybase_fetch_array($res);
        return $row;
    break;;

    }
}

function sql_fetch_object(&$res, $nr=0)
{
global $dbtype;
switch ($dbtype)
    {
    case "MySQL":
        $row = mysql_fetch_object($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
   if($row) return $row;
   else return false;
    break;;

    case "mSQL":
        $row = msql_fetch_object($res);
   if($row) return $row;
   else return false;
    break;;

    case "postgres":
    case "postgres_local":
   if( $res->get_total_rows() > $res->get_fetched_rows() ) {
      $row = pg_fetch_object( $res->get_result(), $res->get_fetched_rows() );
      $res->increment_fetched_rows();
      if($row) return $row;
      else return false;
   } else {
      return false;
   }
    break;;

    case "ODBC":
        $result = odbc_fetch_row($res, $nr);
   if(!$result) return false;
   $nf = odbc_num_fields($res); /* Field numbering starts at 1 */
        for($count=1; $count < $nf+1; $count++)
   {
            $field_name = odbc_field_name($res, $count);
            $field_value = odbc_result($res, $field_name);
            $row->$field_name = $field_value;
        }
        return $row;
    break;;

    case "ODBC_Adabas":
        $result = odbc_fetch_row($res, $nr);
   if(!$result) return false;

        $nf = count($result)+2; /* Field numbering starts at 1 */
   for($count=1; $count < $nf; $count++) {
       $field_name = odbc_field_name($res, $count);
       $field_value = odbc_result($res, $field_name);
       $row->$field_name = $field_value;
   }
        return $row;
    break;;

    case "Interbase":
        $orow = ibase_fetch_object($res);
   if($orow)
   {
       $arow=get_object_vars($orow);
       while(list($name,$key)=each($arow))
       {
      $name=strtolower($name);
      $row->$name=$key;
       }
           return $row;
   }else return false;
    break;;

    case "Sybase":
        $row = sybase_fetch_object($res);
        return $row;
    break;;

    }
}

/*** Function Free Result for function free the memory ***/
function sql_free_result($res) {
global $dbtype;
switch ($dbtype) {

    case "MySQL":
        $row = mysql_free_result($res);
        if (mysql_errno()) { echo mysql_error()."<br>"; }
        return $row;
    break;;

      case "mSQL":
        $row = msql_free_result($res);
        return $row;
    break;;


       case "postgres":
    case "postgres_local":
        $rows=pg_FreeResult( $res->get_result() );
        return $rows;
    break;;

    case "ODBC":
    case "ODBC_Adabas":
        $rows=odbc_free_result($res);
        return $rows;
    break;;

    case "Interbase":
   echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
        return $rows;
    break;;

    case "Sybase":
        $rows=sybase_free_result($res);
        return $rows;
    break;;
   }
}

?>



make sure to keep a backup of your file. If after overwriting your file with mine and the problem persists, then try the fix with my file.


taut


Back to top Reply with quote
#5   re: Encyclopedia_hack for php nuke 6.9
Cyperangel
CZ Newbie
Cyperangel has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Feb 06, 2004
0.00 posts per day
Posts: 13
Points: 2,904
   
Lol. I tried cutting and pasting your code into a new file, and uploaded that to my site....

WHen i did a reload this is the result:

Parse error: parse error in /home/web/gb0432/test/includes/sql_layer.php on line 36

Fatal error: Call to undefined function: sql_connect() in /home/web/gb0432/test/mainfile.php on line 81



That was all there was on the page.. no phpnuke, nuffing....

So im guessing my old file was a tad more stable, even if i get that error, and cant use my encyclopedia as i want it to... icon_cry.gif


Back to top Reply with quote
#6   re: Encyclopedia_hack for php nuke 6.9
Cyperangel
CZ Newbie
Cyperangel has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Feb 06, 2004
0.00 posts per day
Posts: 13
Points: 2,904
   
BTW, just checked my posts, and i can see i havent written which verson of PHP nuke i got. I am running 6.9

Could that ahve anything to do with it?



Back to top Reply with quote
#7   re: Encyclopedia_hack for php nuke 6.9
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.71 posts per day
Posts: 5530
Points: 481,695
   
actually you mentioned the nuke version in your title as 6.9 which my test site is as well.

I'll ask Telli to take a look at this when he gets back on. I don;t know why your file is different than mine or even in the fix.

oh and when you got this hack, did you check to make sure it was compatible with 6.9?


taut



Back to top Reply with quote
#8   re: Encyclopedia_hack for php nuke 6.9
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.71 posts per day
Posts: 5530
Points: 481,695
   
btw, can you add a link to where you got that hack so I can check it please


taut



Back to top Reply with quote
#9   re: Encyclopedia_hack for php nuke 6.9
Cyperangel
CZ Newbie
Cyperangel has been a member for over 20 year's 20 Year Member
Status: Offline
Joined: Feb 06, 2004
0.00 posts per day
Posts: 13
Points: 2,904
   
K, i got both a 6.0 version, and a 7.0 version, and to the best of my untrained eyes, they look 100% the same....

So i figured, if one was compatible with 6.0, and the other one, which was just like it was for 7.0, why shouldnt they work for 6.9 as well

(yes, im a n00b).

Anyways, here are the links:

[ Register or login to view links on this board.]

[ Register or login to view links on this board.]


Also, ive installed a few modules, i dont know if one of em might have changed my sql layer file that much... Ill scrounge up a list of what ive installed. One of the things is the HPMPEXP mod from this site.

One is 3 modules used for dark Age of Camelot, for getting in touch with server stats, news and guild listings, as well as the 4nCalendar module and block. Ill check them all to see if one of them required me to up a different SQL layer file.



Back to top Reply with quote
#10   re: Encyclopedia_hack for php nuke 6.9
Taut
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif california.gif
Occupation: Entrepreneur
Gender: Female
Fav. Sports Team: SF Giants
Status: Offline
Joined: May 27, 2003
0.71 posts per day
Posts: 5530
Points: 481,695
   
ver7.0 is different than ver6.9. You're better off uploading 6.0 and make sure to change all the instances you can find of:

uname ... change that to username

also, there should have been a sql file that needed ot be uploaded to make the necessary tables. did you install that as well? the 7.0 version is looking for the points system which 6.9 does not have and was only added in the 7.0 version

try using the 6.0 and please let us know what happens


taut



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum