PHP Nuke Installation Help

Discussion in 'PHP' started by Superior, Jun 20, 2007.

  1. #1
    Hello,

    i am installing PHP Nuke at www.netfunclub.com but getting this error.
    
    Fatal error: Call to undefined function: sql_connect() in /hsphere/local/home/superior/netfunclub.com/mainfile.php on line 230
    HTML:
    here is the mainfile.php
    From line 1 to line 500
    please help me ASAP.

    Thanks

    <?php
    
    /************************************************************************/
    /* PHP-NUKE: Advanced Content Management System                         */
    /* ============================================                         */
    /*                                                                      */
    /* Copyright (c) 2005 by Francisco Burzi                                */
    /* http://phpnuke.org                                                   */
    /*                                                                      */
    /* 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.       */
    /************************************************************************/
    
    // End the transaction
    if(!defined('END_TRANSACTION')) {
      define('END_TRANSACTION', 2);
    }
    
    // Get php version
    $phpver = phpversion();
    
    // convert superglobals if php is lower then 4.1.0
    if ($phpver < '4.1.0') {
      $_GET = $HTTP_GET_VARS;
      $_POST = $HTTP_POST_VARS;
      $_SERVER = $HTTP_SERVER_VARS;
      $_FILES = $HTTP_POST_FILES;
      $_ENV = $HTTP_ENV_VARS;
      if($_SERVER['REQUEST_METHOD'] == "POST") {
        $_REQUEST = $_POST;
      } elseif($_SERVER['REQUEST_METHOD'] == "GET") {
        $_REQUEST = $_GET;
      }
      if(isset($HTTP_COOKIE_VARS)) {
        $_COOKIE = $HTTP_COOKIE_VARS;
      }
      if(isset($HTTP_SESSION_VARS)) {
        $_SESSION = $HTTP_SESSION_VARS;
      }
    }
    
    // override old superglobals if php is higher then 4.1.0
    if($phpver >= '4.1.0') {
      $HTTP_GET_VARS = $_GET;
      $HTTP_POST_VARS = $_POST;
      $HTTP_SERVER_VARS = $_SERVER;
      $HTTP_POST_FILES = $_FILES;
      $HTTP_ENV_VARS = $_ENV;
      $PHP_SELF = $_SERVER['PHP_SELF'];
      if(isset($_SESSION)) {
        $HTTP_SESSION_VARS = $_SESSION;
      }
      if(isset($_COOKIE)) {
        $HTTP_COOKIE_VARS= $_COOKIE;
      }
    }
    
    // After doing those superglobals we can now use one
    // and check if this file isnt being accessed directly
    if (stristr(htmlentities($_SERVER['PHP_SELF']), "mainfile.php")) {
        header("Location: index.php");
        exit();
    }
    
    if (!function_exists("floatval")) {
        function floatval($inputval) {
            return (float)$inputval;
        }
    }
    if ($phpver >= '4.0.4pl1' && isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'],'compatible')) {
      if (extension_loaded('zlib')) {
        @ob_end_clean();
        ob_start('ob_gzhandler');
      }
    } elseif ($phpver > '4.0' && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
      if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
        if (extension_loaded('zlib')) {
          $do_gzip_compress = true;
          ob_start(array('ob_gzhandler',5));
          ob_implicit_flush(0);
          if (ereg("MSIE", $_SERVER['HTTP_USER_AGENT'])) {
          header('Content-Encoding: gzip');
          }
        }
      }
    }
    
    if (!ini_get('register_globals')) {
      @import_request_variables("GPC", "");
    }
    
    //Union Tap
    //Copyright Zhen-Xjell 2004 http://nukecops.com
    //Beta 3 Code to prevent UNION SQL Injections
    unset($matches);
    unset($loc);
    if(isset($_SERVER['QUERY_STRING'])) {
      if (preg_match("/([OdWo5NIbpuU4V2iJT0n]{5}) /", rawurldecode($loc=$_SERVER['QUERY_STRING']), $matches)) {
        die('Illegal Operation');
      }
    }
    
    // This block of code makes sure $admin and $user are COOKIES
    if((isset($admin) && $admin != $_COOKIE['admin']) OR (isset($user) && $user != $_COOKIE['user'])) {
      die("Illegal Operation");
    }
    
    // We want to use the function stripos,
    // but thats only available since PHP5.
    // So we cloned the function...
    if(!function_exists('stripos')) {
      function stripos_clone($haystack, $needle, $offset=0) {
        return strpos(strtoupper($haystack), strtoupper($needle), $offset);
      }
    } else {
    // But when this is PHP5, we use the original function	
      function stripos_clone($haystack, $needle, $offset=0) {
        return stripos($haystack, $needle, $offset=0);
      }
    }
    
    // Additional security (Union, CLike, XSS)
    if(isset($_SERVER['QUERY_STRING']) && (!stripos_clone($_SERVER['QUERY_STRING'], "ad_click"))) {
    	$queryString = $_SERVER['QUERY_STRING'];
        if (stripos_clone($queryString,'%20union%20') OR stripos_clone($queryString,'/*') OR stripos_clone($queryString,'*/union/*') OR stripos_clone($queryString,'c2nyaxb0') OR stripos_clone($queryString,'+union+') OR (stripos_clone($queryString,'cmd=') AND !stripos_clone($queryString,'&cmd')) OR (stripos_clone($queryString,'exec') AND !stripos_clone($queryString,'execu')) OR stripos_clone($queryString,'concat')) {
        	die('Illegal Operation');
        }
    }
    
    $postString = "";
    foreach ($_POST as $postkey => $postvalue) {
        if ($postString > "") {
         $postString .= "&".$postkey."=".$postvalue;
        } else {
         $postString .= $postkey."=".$postvalue;
        }
    }
    str_replace("%09", "%20", $postString);
    $postString_64 = base64_decode($postString);
    
    if (stripos_clone($postString,'%20union%20') OR stripos_clone($postString,'*/union/*') OR stripos_clone($postString,' union ') OR stripos_clone($postString_64,'%20union%20') OR stripos_clone($postString_64,'*/union/*') OR stripos_clone($postString_64,' union ') OR stripos_clone($postString_64,'+union+')) {
    header("Location: index.php");
    die();
    }
    
    if(isset($admin))
    {
    	$admin = base64_decode($admin);
    	$admin = addslashes($admin);
    	$admin = base64_encode($admin);
    }
    
    if(isset($user))
    {
    	$user = base64_decode($user);
    	$user = addslashes($user);
    	$user = base64_encode($user);
    }
    
    // Die message for not allowed HTML tags
    $htmltags = "<center><img src=\"images/logo.gif\"><br><br><b>";
    $htmltags .= "The html tags you attempted to use are not allowed</b><br><br>";
    $htmltags .= "[ <a href=\"javascript:history.go(-1)\"><b>Go Back</b></a> ]";
    
    // Die message for empty HTTP_REFERER
    $posttags = "<b>Warning:</b> your browser doesn't send the HTTP_REFERER header to the website.<br>";
    $posttags .= "This can be caused due to your browser, using a proxy server or your firewall.<br>";
    $posttags .= "Please change browser or turn off the use of a proxy<br>";
    $posttags .= "or turn off the 'Deny servers to trace web browsing' in your firewall<br>";
    $posttags .= "and you shouldn't have problems when sending a POST on this website.";
    
    if (!defined('ADMIN_FILE')) {
      foreach ($_GET as $sec_key => $secvalue) {
        if ((eregi("<[^>]*script*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*object*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*iframe*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*applet*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*meta*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*style*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*form*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*img*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||
    	(eregi("<[^>]*body*\"?[^>]*>", $secvalue)) ||
    	(eregi("\([^>]*\"?[^)]*\)", $secvalue)) ||
    	(eregi("\"", $secvalue)) ||
    	(eregi("forum_admin", $sec_key)) ||
    	(eregi("inside_mod", $sec_key))) {
            die ($htmltags);
         }
      }
    
      foreach ($_POST as $secvalue) {
        if ((eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) || (eregi("<[^>]script*\"?[^>]*>", $secvalue)) || (eregi("<[^>]*body*\"?[^>]*>", $secvalue)) || (eregi("<[^>]style*\"?[^>]*>", $secvalue))) {
          die ($htmltags);
        }
      }
    }
    
    // Posting from other servers in not allowed
    // Fix by Quake
    // Bug found by PeNdEjO
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
      if (isset($_SERVER['HTTP_REFERER'])) {
        if (!stripos_clone($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
            die('Posting from another server not allowed!');
        }
      } else {
        die($posttags);
      }
    }
    
    // Define the INCLUDE PATH
    if(defined('FORUM_ADMIN')) {
    	define('INCLUDE_PATH', '../../../');
    } elseif(defined('INSIDE_MOD')) {
    	define('INCLUDE_PATH', '../../');
    } else {
    	define('INCLUDE_PATH', './');
    }
    
    // Include the required files
    @require_once(INCLUDE_PATH."config.php");
    @require_once(INCLUDE_PATH."db/db.php");
    
    /* FOLLOWING TWO LINES ARE DEPRECATED BUT ARE HERE FOR OLD MODULES COMPATIBILITY */
    /* PLEASE START USING THE NEW SQL ABSTRACTION LAYER. SEE MODULES DOC FOR DETAILS */
    @require_once(INCLUDE_PATH."includes/sql_layer.php");
    $dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
    
    @require_once(INCLUDE_PATH."includes/ipban.php");
    if (file_exists(INCLUDE_PATH."includes/custom_files/custom_mainfile.php")) {
    	@include_once(INCLUDE_PATH."includes/custom_files/custom_mainfile.php");
    }
    
    if (!defined('FORUM_ADMIN')) {
    	if(empty($admin_file)) {
        	die ("You must set a value for admin_file in config.php");
    	} elseif (!empty($admin_file) && !file_exists(INCLUDE_PATH.$admin_file.".php")) {
        	die ("The admin_file you defined in config.php does not exist");
    	}
    }
    
    // Error reporting, to be set in config.php
    if($display_errors) {
      ini_set('display_errors', 1);
      error_reporting(E_ALL^E_NOTICE);
    } else {
      ini_set('display_errors', 0);
      error_reporting(0);
    }
    
    define('NUKE_FILE', true);
    
    $result = $db->sql_query("SELECT * FROM ".$prefix."_config");
    $row = $db->sql_fetchrow($result);
    $sitename = filter($row['sitename'], "nohtml");
    $nukeurl = filter($row['nukeurl'], "nohtml");
    $site_logo = filter($row['site_logo'], "nohtml");
    $slogan = filter($row['slogan'], "nohtml");
    $startdate = filter($row['startdate'], "nohtml");
    $adminmail = filter($row['adminmail'], "nohtml");
    $anonpost = intval($row['anonpost']);
    $Default_Theme = filter($row['Default_Theme'], "nohtml");
    $foot1 = filter($row['foot1']);
    $foot2 = filter($row['foot2']);
    $foot3 = filteR($row['foot3']);
    $commentlimit = intval($row['commentlimit']);
    $anonymous = filter($row['anonymous'], "nohtml");
    $minpass = intval($row['minpass']);
    $pollcomm = intval($row['pollcomm']);
    $articlecomm = intval($row['articlecomm']);
    $broadcast_msg = intval($row['broadcast_msg']);
    $my_headlines = intval($row['my_headlines']);
    $top = intval($row['top']);
    $storyhome = intval($row['storyhome']);
    $user_news = intval($row['user_news']);
    $oldnum = intval($row['oldnum']);
    $ultramode = intval($row['ultramode']);
    $banners = intval($row['banners']);
    $backend_title = filter($row['backend_title'], "nohtml");
    $backend_language = filter($row['backend_language'], "nohtml");
    $language = filter($row['language'], "nohtml");
    $locale = filter($row['locale'], "nohtml");
    $multilingual = intval($row['multilingual']);
    $useflags = intval($row['useflags']);
    $notify = intval($row['notify']);
    $notify_email = filter($row['notify_email'], "nohtml");
    $notify_subject = filter($row['notify_subject'], "nohtml");
    $notify_message = filter($row['notify_message'], "nohtml");
    $notify_from = filter($row['notify_from'], "nohtml");
    $moderate = intval($row['moderate']);
    $admingraphic = intval($row['admingraphic']);
    $httpref = intval($row['httpref']);
    $httprefmax = intval($row['httprefmax']);
    $CensorMode = intval($row['CensorMode']);
    $CensorReplace = filter($row['CensorReplace'], "nohtml");
    $copyright = filter($row['copyright']);
    $Version_Num = filter($row['Version_Num'], "nohtml");
    $domain = eregi_replace("http://", "", $nukeurl);
    $tipath = "images/topics/";
    $mtime = microtime();
    $mtime = explode(" ",$mtime);
    $mtime = $mtime[1] + $mtime[0];
    $start_time = $mtime;
    
    if (!defined('FORUM_ADMIN')) {
    	if (isset($newlang) AND !stripos_clone($newlang,".")) {
    		if (file_exists("language/lang-".$newlang.".php")) {
    			setcookie("lang",$newlang,time()+31536000);
    			include_once("language/lang-".$newlang.".php");
    			$currentlang = $newlang;
    		} else {
    			setcookie("lang",$language,time()+31536000);
    			include_once("language/lang-".$language.".php");
    			$currentlang = $language;
    		}
    	} elseif (isset($lang)) {
    		include_once("language/lang-".$lang.".php");
    		$currentlang = $lang;
    	} else {
    		setcookie("lang",$language,time()+31536000);
    		include_once("language/lang-".$language.".php");
    		$currentlang = $language;
    	}
    }
    
    function makePass() {
    	$cons = "bcdfghjklmnpqrstvwxyz";
    	$vocs = "aeiou";
    	for ($x=0; $x < 6; $x++) {
    		mt_srand ((double) microtime() * 1000000);
    		$con[$x] = substr($cons, mt_rand(0, strlen($cons)-1), 1);
    		$voc[$x] = substr($vocs, mt_rand(0, strlen($vocs)-1), 1);
    	}
    	mt_srand((double)microtime()*1000000);
    	$num1 = mt_rand(0, 9);
    	$num2 = mt_rand(0, 9);
    	$makepass = $con[0] . $voc[0] .$con[2] . $num1 . $num2 . $con[3] . $voc[3] . $con[4];
    	return($makepass);
    }
    
    function get_lang($module) {
    	global $currentlang, $language;
    	if (file_exists("modules/$module/language/lang-".$currentlang.".php")) {
    		if ($module == "admin") {
    			include_once("admin/language/lang-".$currentlang.".php");
    		} else {
    			include_once("modules/$module/language/lang-".$currentlang.".php");
    		}
    	} else {
    		if ($module != "Forums") {
    			if ($module == "admin") {
    				include_once("admin/language/lang-".$currentlang.".php");
    			} else {
    				include_once("modules/$module/language/lang-".$language.".php");
    			}
    		}
    	}
    }
    
    function is_admin($admin) {
        if (!$admin) { return 0; }
        if (isset($adminSave)) return $adminSave;
        if (!is_array($admin)) {
            $admin = base64_decode($admin);
            $admin = addslashes($admin);
            $admin = explode(":", $admin);
        }
        $aid = $admin[0];
        $pwd = $admin[1];
        $aid = substr(addslashes($aid), 0, 25);
        if (!empty($aid) && !empty($pwd)) {
            global $prefix, $db;
            $sql = "SELECT pwd FROM ".$prefix."_authors WHERE aid='$aid'";
            $result = $db->sql_query($sql);
            $pass = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($pass[0] == $pwd && !empty($pass[0])) {
                static $adminSave;
            	return $adminSave = 1;
            }
        }
        static $adminSave;
        return $adminSave = 0;
    }
    
    function is_user($user) {
        if (!$user) { return 0; }
        if (isset($userSave)) return $userSave;
        if (!is_array($user)) {
            $user = base64_decode($user);
            $user = addslashes($user);
            $user = explode(":", $user);
        }
        $uid = $user[0];
        $pwd = $user[2];
        $uid = intval($uid);
        if (!empty($uid) AND !empty($pwd)) {
            global $db, $user_prefix;
            $sql = "SELECT user_password FROM ".$user_prefix."_users WHERE user_id='$uid'";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($row[0] == $pwd && !empty($row[0])) {
                static $userSave;
            	return $userSave = 1;
            }
        }
        static $userSave;
        return $userSave = 0;
    }
    
    function is_group($user, $name) {
              global $prefix, $db, $user_prefix, $cookie, $user;
         if (is_user($user)) {
              if(!is_array($user)) {
              $cookie = cookiedecode($user);
              $uid = intval($cookie[0]);
              } else {
              $uid = intval($user[0]);
              }
              $result = $db->sql_query("SELECT points FROM ".$user_prefix."_users WHERE user_id='$uid'");
              list($points) = $db->sql_fetchrow($result);
              $points = intval($points);
              $db->sql_freeresult($result);
              $result2 = $db->sql_query("SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'");
              list($mod_group) = $db->sql_fetchrow($result2);
              $mod_group = intval($mod_group);
              $db->sql_freeresult($result2);
              $result3 = $db->sql_query("SELECT points FROM ".$prefix."_groups WHERE id='$mod_group'");
              list($rpoints) = $db->sql_fetchrow($result3);
              $grp = intval($rpoints);
              $db->sql_freeresult($result3);
              if (($points >= 0 AND $points >= $grp) OR $mod_group == 0) {
            	return 1;
              }
         }
         return 0;
    }
    
    function update_points($id) {
      global $user_prefix, $prefix, $db, $user;
      if (is_user($user)) {
        if(!is_array($user)) {
          $cookie = cookiedecode($user);
          $username = trim($cookie[1]);
        } else {
          $username = trim($user[1]);
        }
        if ($db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_groups")) > '0') {
          $id = intval($id);
          $result = $db->sql_query("SELECT points FROM ".$prefix."_groups_points WHERE id='$id'");
          list($points) = $db->sql_fetchrow($result);
          $db->sql_freeresult($result);
          $rpoints = intval($points);
          $db->sql_query("UPDATE ".$user_prefix."_users SET points=points+".$rpoints." WHERE username='$username'");
        }
      }
    }
    
    function title($text) {
    	OpenTable();
    	echo "<center><span class=\"title\"><strong>$text</strong></span></center>";
    	CloseTable();
    	echo "<br>";
    }
    
    function is_active($module) {
        global $prefix, $db;
        static $save;
        if (is_array($save)) {
            if (isset($save[$module])) return ($save[$module]);
            return 0;
        }
        $sql = "SELECT title FROM ".$prefix."_modules WHERE active=1";
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $save[$row[0]] = 1;
        }
        $db->sql_freeresult($result);
        if (isset($save[$module])) return ($save[$module]);
        return 0;
    }
    
    function render_blocks($side, $blockfile, $title, $content, $bid, $url) {
    	if(!defined('BLOCK_FILE')) {
    	  define('BLOCK_FILE', true);
    	}
    	if (empty($url)) {
    		if (empty($blockfile)) {
    			if ($side == "c") {
    				themecenterbox($title, $content);
    			} elseif ($side == "d") {
    				themecenterbox($title, $content);
    			} else {
    				themesidebox($title, $content);
    			}
    		} else {
    PHP:

     
    Superior, Jun 20, 2007 IP
  2. Superior

    Superior Well-Known Member

    Messages:
    488
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    i just change sql_connect to mysql_connect
    this error was fixed but i got another error which u will see when u open www.netfunclub.com
     
    Superior, Jun 20, 2007 IP