Тема: Еще одна ошибка

Исходный код

<?php
/*********************/
/*                   */
/*  Version : 5.1.0  */
/*  Author  : RM     */
/*  Comment : 071223 */
/*                   */
/*********************/

class exteriormember
{

    var $MOD_NAME = "Member_";
    var $PROGRAM_FILE = "";
    var $PROGRAM_TBL = "";
    var $db;
    var $db1;
    var $MOD_CFG = array( );
    var $HW_MOD_DIR = "";
    var $DESCR = "";
    var $ACTIVE_URL = "";
    var $LOGOUT_URL = "";
    var $IS_DEMO = 0;
    var $GET_LOGOUT_VARS = "";
    var $ADD_LOGOUT_URL = "";
    var $VERSIONS = array( );
    var $ver_msg = "Warning: software version %s was not tested with this module";
    var $err_msg = "";

    function exteriormember( $mod_name, $program_file = "", $program_tbl = "", $active_url = "", $logout_url = "", $is_demo = 0, $versions = array( ) )
    {
        $this->MOD_NAME .= $mod_name;
        $info = explode( ":", $program_file );
        if ( 1 < count( $info ) )
        {
            array_shift( $info );
            $this->DESCR = implode( ":", $info );
        }
        else
        {
            $this->PROGRAM_FILE = $program_file;
            $this->PROGRAM_TBL = $program_tbl;
        }
        $this->db =& $GLOBALS['db'];
        $this->ACTIVE_URL = $active_url;
        $this->LOGOUT_URL = $logout_url;
        $this->IS_DEMO = $is_demo;
        $this->HW_MOD_DIR = SITE_PATH."modules/".$this->MOD_NAME."/";
        $this->VERSIONS = $versions;
    }

    function info( &$A_MOD, &$A_CFG )
    {
        $A_MOD = array(
            "dir" => $this->MOD_NAME,
            "descr" => $this->DESCR
        );
        $a_v = array(
            "TPREF" => "bb_",
            "PURL" => "forum/",
            "PDIR" => str_replace( "\\", "/", $_SERVER['DOCUMENT_ROOT'] )."/forum/",
            "EN_OTHER_DB" => 0,
            "DB_SERVER" => "localhost",
            "DB_NAME" => "",
            "DB_USER" => "",
            "DB_PWD" => "",
            "custom_cfg" => ""
        );
        foreach ( $a_v as $k => $v )
        {
            $A_CFG[$k] = $A_CFG[$k] != "" ? $A_CFG[$k] : $v;
        }
    }

    function setupvalidate( )
    {
        $err_msg = "";
        if ( !$_POST['PURL'] )
        {
            do
            {
                do
                {
                    $err_msg = "Program URL is required";
                    if ( $_POST['PURL'] )
                    {
                        break;
                        if ( $_POST['PURL'] )
                        {
                            break;
                        }
                    }
                    else
                    {
                        $fname = str_replace( "\\", "/", $_SERVER['DOCUMENT_ROOT'] )."/".$_POST['PURL'].$this->PROGRAM_FILE;
                        $fp = @fopen( $fname, "r" );
                        if ( !$fp )
                        {
                            $err_msg = "Incorrect program relative URL: ".$_POST['PURL'];
                        }
                        if ( $err_msg )
                        {
                            break;
                        }
                    }
                    if ( !$_POST['PDIR'] )
                    {
                        $err_msg = "Program dir is required";
                    }
                    else
                    {
                        if ( !is_file( $_POST['PDIR'].$this->PROGRAM_FILE ) )
                        {
                            $err_msg = "Incorrect program directory";
                        }
                        else
                        {
                            if ( $_POST['EN_OTHER_DB'] )
                            {
                                if ( version_compare( PHP_VERSION, "4.2" ) < 0 )
                                {
                                    $err_msg = "\"Use separate DB\" option requires PHP 4.2 or later version. Your have PHP ".PHP_VERSION." installed";
                                }
                                else if ( $link_id = @mysql_connect( $_POST['DB_SERVER'], $_POST['DB_USER'], $_POST['DB_PWD'], true ) )
                                {
                                    if ( @mysql_select_db( $_POST['DB_NAME'], $link_id ) )
                                    {
                                        $db1 =& new database( );
                                        $db1->connect( $_POST['DB_SERVER'], $_POST['DB_USER'], $_POST['DB_PWD'], $_POST['DB_NAME'], true );
                                    }
                                    else
                                    {
                                        $err_msg = "Database select failed: ".htmlspecialchars( $_POST['DB_NAME'], ENT_QUOTES, $CHARSET );
                                    }
                                }
                                else
                                {
                                    $err_msg = "Database connection failed, please verify connection details: server, user and password";
                                }
                            }
                            if ( $err_msg )
                            {
                                break;
                            }
                            else
                            {
                                if ( $_POST['EN_OTHER_DB'] )
                                {
                                    $sdb =& $db1;
                                }
                                else
                                {
                                    $sdb = $this->db;
                                }
                                $a_v = $sdb->getcol( "SHOW tables" );
                                if ( in_array( $_POST['TPREF'].$this->PROGRAM_TBL, $a_v ) )
                                {
                                    break;
                                }
                                $err_msg = "Incorrect tables prefix. Table \"".htmlspecialchars( $_POST['TPREF'], ENT_QUOTES, $CHARSET ).$this->PROGRAM_TBL."\" was not found in the database".( $_POST['EN_OTHER_DB'] ? " \"".htmlspecialchars( $_POST['DB_NAME'], ENT_QUOTES, $CHARSET )."\"" : "" );
                            }
                        }
                    }
                } while ( 0 );
                if ( $err_msg || $this->versioncompatible( ) )
                {
                    break;
                }
                $err_msg = sprintf( $this->ver_msg, $ver = $this->version( ) );
            } while ( 0 );
            return $err_msg;
        }

    function admin( )
    {
        $o_name = "\$O_".strtoupper( str_replace( "Member_", "", $this->MOD_NAME ) );
        $hw_admin = "function ".$this->MOD_NAME."_main() {echo ShowModSetupPage(TPL_PATH.'admin/u_setup.htm');}";
        $hw_admin .= "function ".$this->MOD_NAME."_SetupValidate(){global \$err_msg,".$o_name.";\$err_msg = ".$o_name."->SetupValidate();return \$err_msg;}";
        eval( $hw_admin );
    }

    function eventhandler( )
    {
        if ( $_GET['p'] == "login" )
        {
            global $O_HW;
            $this->MOD_CFG = $O_HW->getmodoptions( $this->MOD_NAME );
            if ( is_dir( $_SERVER['DOCUMENT_ROOT']."/".$this->MOD_CFG['PURL'] ) )
            {
                $v['i_url'] = "http://".$_SERVER['HTTP_HOST']."/".$this->MOD_CFG['PURL'];
                $v1 = $this->db->one_assoc( "SELECT username, pwd FROM ".TBL_USER." WHERE id=\"".( integer )hwsessiongetvar( "userid" )."\"" );
                $v['login'] = $v1['username'];
                $v['pwd'] = $v1['pwd'];
                $v = array(
                    "login_frm" => evaladvtpl( $this->HW_MOD_DIR."tpl/login_frm.htm", $v )
                );
                evaladvtpl( TPL_PATH."admin/u_auto_login.htm", $v, 1 );
                exit( );
            }
            $this->jsalert( "Incorrect program URL!" );
            exit( );
        }
        if ( $_GET['p'] == "logout" )
        {
            global $O_HW;
            $this->MOD_CFG = $O_HW->getmodoptions( $this->MOD_NAME );
            if ( is_dir( $_SERVER['DOCUMENT_ROOT']."/".$this->MOD_CFG['PURL'] ) )
            {
                $v['i_url'] = "http://".$_SERVER['HTTP_HOST']."/".$this->MOD_CFG['PURL'];
                if ( $this->ADD_LOGOUT_VARS )
                {
                    eval( $this->ADD_LOGOUT_VARS );
                }
                $v = array(
                    "logout_url" => evalbuffer( $this->MOD_CFG['LOGOUT_URL'], $v )
                );
                evaladvtpl( TPL_PATH."admin/u_auto_logout.htm", $v, 1 );
                exit( );
            }
            $this->jsalert( "Incorrect program URL!" );
            exit( );
        }
        if ( $_GET['demo_mode'] == 1 && $this->IS_DEMO )
        {
            echo " <a href='http://www.esvon.com/pg/products/p_classifieds/'><font size=1 color=red face=\"Verdana\">The "".$this->MOD_NAME."" module is in the demo mode</font></a>";
            exit( );
        }
        $o_name = str_replace( "MEMBER_", "", "\$O_".strtoupper( $this->MOD_NAME ) );
        if ( hwmodgetstate( $this->MOD_NAME ) != "A" )
        {
            return;
        }
        $hw_event = "function ".$this->MOD_NAME."_Event(\$event,&\$args){global ".$o_name.";".$o_name."->EventInit(\$event);switch(\$event){case 'onUserAdd': case 'onUserUpdate': ".$o_name."->AddUpdate(\$event,\$args); break;case 'onUserDelete': ".$o_name."->UserDelete(\$args); break;case 'onUserLoginRedirect': ".$o_name."->LoginRedirect(\$args); break;case 'onUserLogout': ".$o_name."->UserLogout(\$args); break;case 'onUserAuthenticate': ".$o_name."->UserAuthenticate(\$args); break;case 'onModuleActivate': ".$o_name."->ModuleActivate(\$args); break;default: ".$o_name."->CustomEvent(\$event,\$args);}}";
        eval( $hw_event );
    }
 
    function customevent( $event, &$args )
    {
    }

    function moduleactivate( &$args )
    {
        if ( $this->err_msg )
        {
            $args['ERR_MSG'] = $this->MOD_NAME.": ".$this->err_msg;
        }
    }

    function eventinit( $event = "" )
    {
        global $O_HW;
        if ( isset( $this->MOD_CFG, $this->db1 ) )
        {
            return;
        }
        $this->MOD_CFG = $O_HW->getmodoptions( $this->MOD_NAME );
        if ( $_SERVER['REQUEST_METHOD'] == "POST" && strpos( $_SERVER['REQUEST_URI'], "admin/modules.php?mod=Member_" ) !== false )
        {
            $this->MOD_CFG = $_POST;
        }
        $a_events = array( "onUserAdd", "onUserUpdate", "onUserDelete", "onUserLoginRedirect", "onUserLogout", "init" );
        if ( !in_array( $event, $a_events ) )
        {
            return;
        }
        $err_msg = "";
        if ( $this->MOD_CFG['EN_OTHER_DB'] )
        {
            if ( version_compare( PHP_VERSION, "4.2" ) < 0 )
            {
                $err_msg = "PHP version should be higher for me";
            }
            else if ( $link_id = @mysql_connect( $this->MOD_CFG['DB_SERVER'], $this->MOD_CFG['DB_USER'], $this->MOD_CFG['DB_PWD'], true ) )
            {
                if ( @mysql_select_db( $this->MOD_CFG['DB_NAME'], $link_id ) )
                {
                    $this->db1 =& new database( );
                    $this->db1->connect( $this->MOD_CFG['DB_SERVER'], $this->MOD_CFG['DB_USER'], $this->MOD_CFG['DB_PWD'], $this->MOD_CFG['DB_NAME'], true );
                }
                else
                {
                    $err_msg = "Incorrect DB name";
                }
            }
            else
            {
                $err_msg = "Incorrect DB connection settings";
            }
            if ( !$err_msg )
            {
                break;
            }
            else
            {
                $this->jsalert( $err_msg, false );
                if ( $event == "onUserAdd" )
                {
                    exit( );
                }
            }
        }
        else
        {
            do
            {
                $this->db1 = $this->db;
            } while ( 0 );
            $a_events = array( "onUserAdd", "onUserUpdate", "onUserDelete" );
            if ( $this->GET_LOGOUT_VARS )
            {
                $a_events[] = "onUserLogout";
            }
            if ( in_array( $event, $a_events ) )
            {
                $this->db1->ERR_EXIT = false;
                $this->db1->query( "SELECT COUNT(*) FROM ".$this->MOD_CFG['TPREF'].$this->PROGRAM_TBL );
                if ( $this->db1->ERR_MSG )
                {
                    $this->jsalert( "Incorrect tables prefix", false );
                    $this->db1->ERR_MSG = "";
                    if ( $event == "onUserAdd" )
                    {
                        exit( );
                    }
                }
                else
                {
                    $this->db1->ERR_EXIT = true;
                }
            }
            if ( !$this->versioncompatible( ) )
            {
                $this->jsalert( sprintf( $this->ver_msg, $ver = $this->version( ) ) );
            }
        }
    }

    function addupdate( $event, &$args )
    {
    }

    function userdelete( $event, &$args )
    {
    }

    function userauthenticate( &$args )
    {
        $args1 = array(
            "EMAIL" => $args['U_DATA']['email'],
            "USERNAME" => $args['U_DATA']['username'],
            "PWD" => $args['U_DATA']['pwd']
        );
        $this->eventinit( "onUserAdd" );
        $this->addupdate( "onUserAdd", $args1 );
    }

    function loginredirect( &$args )
    {
        $args['rows'] .= $this->IS_DEMO ? ", 1, 30" : ", 1";
        $v['mod_num'] = $args['mod_num'] + 1;
        $v['MOD_URL'] = SITE_URL."modules/".$this->MOD_NAME."/";
        $args['frames'] .= "<frame name=\"fr_dest".$v['mod_num']."\" src=\"".$v['MOD_URL']."hw_event.php?p=login\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" noresize=1>\n";
        if ( $this->IS_DEMO )
        {
            $args['frames'] .= "<frame name=\"fr_demo".$v['mod_num']."\" src=\"{$v['MOD_URL']}hw_event.php?demo_mode=1\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" noresize=1>";
        }
        ++$args['mod_num'];
        $args['a_url'] .= $v['i_url'].urlencode( $this->ACTIVE_URL."|" );
    }

    function userlogout( &$args )
    {
        $args['rows'] .= $this->IS_DEMO ? ", 1, 30" : ", 1";
        $v['mod_num'] = $args['mod_num'] + 1;
        $v['MOD_URL'] = SITE_URL."modules/".$this->MOD_NAME."/";
        if ( $this->GET_LOGOUT_VARS )
        {
            eval( $this->GET_LOGOUT_VARS );
        }
        $args['frames'] .= "<frame name=\"fr_dest".$v['mod_num']."\" src=\"".$v['MOD_URL']."hw_event.php?p=logout";
        if ( $this->ADD_LOGOUT_URL )
        {
            eval( $this->ADD_LOGOUT_URL );
        }
        $args['frames'] .= "\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" noresize=1>";
        if ( $this->IS_DEMO )
        {
            $args['frames'] .= "<frame name=\"fr_demo".$v['mod_num']."\" src=\"{$v['MOD_URL']}hw_event.php?demo_mode=1\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\" noresize=1>";
        }
        ++$args['mod_num'];
        $args['a_url'] .= $v['i_url'].urlencode( $this->LOGOUT_URL."|" );
    }

    function jsalert( $msg, $wrap = true )
    {
        $this->err_msg = $msg;
        if ( $wrap )
        {
            echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r\n                     <html>\r\n                     <head>\r\n                       <title>".$this->MOD_NAME.": {$msg}</title>\r\n                     </head>\r\n                     <body>";
        }
        echo "<center><font color=red><b>".$this->MOD_NAME.":</b> {$msg}</font></center>\r\n                     <script language=\"JavaScript\">\r\n                     //<!--\r\n                       alert(\"{$this->MOD_NAME}: ".addslashes( $msg )."\");\r\n                     //-->\r\n                     </script>";
        if ( $wrap )
        {
            echo "</body>\r\n                     </html>";
        }
    }

    function version( )
    {
    }

    function versioncompatible( )
    {
        $ver = $this->version( );
        $ok = false;
        foreach ( $this->VERSIONS as $v )
        {
            if ( !( strpos( $ver, $v ) === 0 ) )
            {
                continue;
            }
            $ok = true;
            break;
        }
        return $ok;
    }

}
  }
?>

Запускаю - ошибка

Fatal error: Call to undefined method vbulletin3member::eventinit() in Y:\home\localhost\www\mysite\modules\Member_vBulletin3\hw_event.php on line 440

В скрипте определяется eventinit() где? и в чем ошибка?

2

Re: Еще одна ошибка

pellets-wood сказал:

и в чем ошибка?

Не знаю.

3

Re: Еще одна ошибка

С чего начинать ее поиск?

4

Re: Еще одна ошибка

pellets-wood
Поищите класс vbulletin3member и наличие функции eventinit() в нем.