微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

升级PHP脚本

如何解决升级PHP脚本

我使用vBulletin论坛软件(旧的3.x版本)只是我偏爱的论坛软件。尽管vBulletin 3已更新为至少支持PHP 7.1,但为它开发的许多产品却过时了。

我正在尝试学习如何升级这些产品,虽然我对PHP有所了解,但并不如我所愿。例如,我在学习过程中做了一些事情。我下载了vBulletin 3的旧版本,然后下载了新版本,然后比较文件以查看它们进行了哪些类型的更改。不过,这对学习并没有真正的帮助。 (为什么要进行这些更改,这些更改是什么意思?)我在新文件中记录了我注意到的更改,这是我一直在更改的示例。

Find:

datamanager(

function vB_DataManager

function delete()

=&

split(

$groupis = $_GET['groupis'];

split

parent::

ereg


Replace:

datamanager_init(

function __construct

function delete($doquery = true)

=

preg_split(

$groupis = intval($_GET['groupis']);

explode

parent::__construct

preg_match

我保留查找列表并替换列表,以便各行与需要替换的内容匹配。

我要更新的最新产品包含多个文件,我知道要替换但不在列表中的一件事是'&$'(但并非总是...?从我阅读的内容来看,什么时候是是替换它们的权利?)这只是我正在处理的大约5个文件,目前可以运行(这里和那里都有错误),但是我不知道从哪里开始实际更新此文件以使其更有效。 。 (已删除了一些用于字符数限制的功能

class vbma
{
    var $vbulletin;
    var $fields = array(//Array of commonly used filed names,Also alows intergration
        'custnum' => 'custnum',//Key (short name) => Value (database table name)
        'mpassword' => 'ma_password','info' => 'ma_info'
    );
    var $currency_sym;
    var $vbphrase;
    var $addons = array();
    function vbma($vbulletin,$vbphrase)
    {
        $this->vbulletin = $vbulletin;
        $this->vbphrase = $vbphrase;
        foreach (glob("includes/class_vbma*.PHP") as $addon)
        {
            if ($addon == 'includes/class_vbma.PHP')
            {
                continue;
            }
            require_once (DIR . '/' . $addon);
            $addon = basename(substr($addon,19,strlen($addon)),'.PHP');
            $name = 'vbma_' . $addon;
            $this->$addon = new $name($this);
            $this->addons["$addon"] = $addon;
        }
    }

    function init($permissions)
    {
        $vbphrase = $this->vbphrase;
        $this->canViewMemArea($permissions);
        if ($this->vbulletin->options['memarea_enabled'] == 0 and !($this->vbulletin->
            userinfo['permissions']['adminpermissions'] & $this->vbulletin->
            bf_ugp_adminpermissions['cancontrolpanel']))
        {
            eval(standard_error($this->vbulletin->options['memarea_offmessage']));
        } elseif ($this->vbulletin->options['memarea_enabled'] == 0 and $this->vbulletin->
        userinfo['permissions']['adminpermissions'] & $this->vbulletin->
            bf_ugp_adminpermissions['cancontrolpanel'])
        {
            $oringle = $vbphrase['alert_board_off'];
            $vbphrase['alert_board_off'] = $this->vbphrase['memarea_off'];
            eval('$GLOBALS[navbar] .= "' . fetch_template('board_inactive_warning') . '";');
        }

        foreach ($this->addons as $addon)
        {
            if (method_exists($this->$addon,'init'))
            {
                $this->$addon->init();
            }
        }
        $maxlength = TIMENow - (60 * 60 * 24 * 3);
        $GLOBALS['ma_session'] = $this->vbulletin->db->query_first("SELECT * FROM " .
            TABLE_PREFIX . "ma_session WHERE userid = '" . $this->vbulletin->userinfo['userid'] .
            "' AND dateline > '" . $maxlength . "'");
        $GLOBALS['curr'] = $this->getCurrency();
        $this->currency_sym = $GLOBALS['currency_sym'] = $this->vbulletin->options['memarea_curr_code'];

    }

    function checkCustomerInfo($customernum,$password)
    {
        $fcust = $this->fields['custnum'];
        $fpass = $this->fields['mpassword'];
        if ($this->vbulletin->userinfo["$fcust"] == $customernum and $this->vbulletin->
            userinfo["$fpass"] == $password)
        {
            return true;
        }
        return false;
    }

    function startSession($userid)
    {
        $this->vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX .
            "ma_session (`userid`,`dateline`) VALUES (
            '" . $this->vbulletin->db->escape_string($this->vbulletin->userinfo['userid']) .
            "','" . TIMENow . "'
        )");
    }

    function getCurrency()
    {
        $curr_a = array('$' => 'USD',$this->vbphrase['memarea_currency_eur'] => 'EUR',$this->vbphrase['memarea_currency_pound'] => 'GBP',$this->vbphrase['memarea_currency_nis'] =>
            'NIS');
        return $curr_a[$this->vbulletin->options['memarea_curr_code']];
    }

    function getPaypalAddress($license)
    {
        $paypal = $license['paypal'];
        if (empty($paypal) or $paypal == '0')
        {
            $paypal = $this->vbulletin->options['memarea_paypal_email'];
        }
        return $paypal;
    }

    function getLicense($licenseid,$checkpermission = true,$getproduct = true,$productfields =
        'products.id as proid,products.title as protitle',$throwerror = true,$getExpireDate = true,$showExpiredErrors = false,$showSusErrors = false)
    {
        if ($getproduct)
        {
            $license = $this->vbulletin->db->query_first("SELECT licenses.*,$productfields FROM " .
                TABLE_PREFIX . "ma_licenses as licenses 
                LEFT JOIN " . TABLE_PREFIX .
                "ma_products as products ON (products.id = licenses.productid)
                WHERE licenses.id = '" . $licenseid . "'");
        }
        else
        {
            $license = $this->vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX .
                "ma_licenses WHERE id = '" . $licenseid . "'");
        }
        if ($throwerror and empty($license))
        {
            eval(standard_error(fetch_error('license_not_found')));
        }
        if ($checkpermission and $this->vbulletin->userinfo['userid'] !== $license['userid'])
        {
            print_no_permission();
        }
        if ($getExpireDate)
        {
            $license['expiredate'] = $this->getLicenseExpireDate($license);
        }
        if ($showExpiredErrors and $this->isExpired($license))
        {
            eval(standard_error(fetch_error('memarea_license_expired')));
        }
        if ($showSusErrors and $this->isSuspended($license))
        {
            eval(standard_error(fetch_error('memarea_suspended_license')));
        }
        return $license;
    }

    function isExpired($license)
    {
        if (intval($license['status']) == 0 or ($license['expire'] !== '0' and (($license['dateline'] +
            $license['expire']) <= TIMENow)))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    function isSuspended($license)
    {
        if (intval($license['status']) == 1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    function getLicenseExpireDate($license)
    {
        if ($license['expire'] == '0')
        {
            return $this->vbphrase['memarea_lifetime'];
        }
        else
        {
            return vbdate($this->vbulletin->options['dateformat'],($license['dateline'] + $license['expire']));
        }
    }

    function sendCustomerInfo($userid,$username,$email,$num,$pass)
    {
        if ($this->vbulletin->options['memarea_notification_type'] == 0 or $this->
            vbulletin->options['memarea_notification_type'] == 2)
        {
            vbmail($email,$this->vbphrase['memarea_email_subject'],construct_phrase($this->
                vbphrase['memarea_email_message'],$pass));
        }
        if ($this->vbulletin->options['memarea_notification_type'] == 1 or $this->
            vbulletin->options['memarea_notification_type'] == 2)
        {
            $pmdm = datamanager_init('PM',$this->vbulletin,ERRTYPE_ARRAY);
            $pmdm->set('fromuserid',$this->vbulletin->options['memarea_botuser']);
            $fuserinfo = $this->vbulletin->db->query_first("SELECT username FROM " .
                TABLE_PREFIX . "user WHERE userid = '" . $this->vbulletin->options['memarea_botuser'] .
                "'");
            $pmdm->set('fromusername',$fuserinfo['username']);
            $pmdm->set('title',$this->vbphrase['memarea_email_subject']);
            $pmdm->set('message',construct_phrase($this->vbphrase['memarea_email_message'],$pass));
            $botpermissions = array();
            $botpermissions['adminpermissions'] = 2;
            $pmdm->set_recipients($username,$botpermissions);
            $pmdm->set('dateline',TIMENow);
            $pmdm->pre_save();
            if (count($pmdm->errors) == 0)
            {
                $pmdm->save();
            }
            else
            {
                var_dump($pmdm->errors);
            }
        }
    }

    function setCustomerNumber($ma_info,$usergroup = '',$usevb = true,$userinfo = '')
    {
        if ($usevb == false)
        {
            $this->vbulletin->userinfo = $userinfo;
        }
        $fcust = $this->fields['custnum'];
        $fpass = $this->fields['mpassword'];
        $finfo = $this->fields['info'];
        $userdm = datamanager_init('User',ERRTYPE_ARRAY);
        $userinfo = fetch_userinfo($this->vbulletin->userinfo['userid']);
        $userdm->set_existing($userinfo);
        if (!$this->vbulletin->userinfo["$fcust"] and !$this->vbulletin->userinfo["$fpass"])
        {
            $rand = rand($this->vbulletin->options['memarea_numstart'],$this->vbulletin->
                options['memarea_numend']);
            $num = $this->vbulletin->options['custnum_prefix'] . substr(md5($rand),$this->
                vbulletin->options['memarea_custnumleng'] - strlen($this->vbulletin->options['custnum_prefix']));
            $userdm->set($fcust,$num);
            $pass = substr(md5(time() . $num . $rand . rand(0,2000)),$this->vbulletin->
                options['memarea_custnumleng']);
            $userdm->set($fpass,$pass);
            $this->sendCustomerInfo($this->vbulletin->userinfo['userid'],$this->vbulletin->
                userinfo['username'],$this->vbulletin->userinfo['email'],$pass);
        }
        if ($usergroup or $usergroup !== '' or $usergroup !== '0')
        {
            if ($usergroup != $this->vbulletin->userinfo['usergroupid'])
            {
            $ma_info['oldgroup'] = $this->vbulletin->userinfo['usergroupid'];
            $userdm->set('usergroupid',$usergroup);
            }
        }
        if ($ma_info)
        {
            $ma_info = serialize($ma_info);
            $userdm->set($finfo,$ma_info);
        }

        $userdm->pre_save();
        if (count($userdm->errors) == 0)
        {
            $userdm->save();
            return true;
        }
        else
        {
            var_dump($userdm->errors);
            return false;
        }
    }

    function checkProductPermissions($product)
    {
        $perm = unserialize($product['permissions']);
        return in_array($this->vbulletin->userinfo['usergroupid'],$perm);
    }

    function buildInfovalues()
    {
        $values = array();
        if (is_array($this->vbulletin->userinfo['ma_info']))
        {
            foreach ($this->vbulletin->userinfo['ma_info'] as $key => $value)
            {
                if (!$this->vbulletin->GPC["$key"])
                {
                    $values["$key"] = $value;
                }
            }
        }
        return $values;
    }

    function canViewMemArea($permissions)
    {
        if (!($permissions['memarea_permissions'] & $this->vbulletin->bf_ugp['memarea_permissions']['memarea_active']))
        {
            print_no_permission();
        }
    }

    function buildInfoArray()
    {
        return array('fullname' => $this->vbulletin->GPC['fullname'],'address_1' => $this->
            vbulletin->GPC['address_1'],'address_2' => $this->vbulletin->GPC['address_2'],'address_city' => $this->vbulletin->GPC['address_city'],'address_state' => $this->
            vbulletin->GPC['address_state'],'address_zip' => $this->vbulletin->GPC['address_zip'],'country' => $this->vbulletin->GPC['country'],'phone' => $this->vbulletin->GPC['phone'],'company' => $this->vbulletin->GPC['company']);
    }

    function insertPurchaseInfo($ids,$information,$userid = 'usevb')
    {
        if ($userid == 'usevb')
        {
            $userid = $this->vbulletin->userinfo['userid'];
        }
        $this->vbulletin->db->query_write("INSERT INTO " . TABLE_PREFIX .
            "ma_purchases (`userid`,`dateline`,`order`,`info`) VALUES (
            '" . $userid . "','" . TIMENow . "','" . $this->vbulletin->db->escape_string(serialize($ids)) . "','" . $this->vbulletin->db->escape_string(serialize($information)) . "'
        )");
        return $this->vbulletin->db->insert_id();
    }

    function buildCartRow($page,$action,$title,$price,$id = 0,$multi = false)
    {
        $currency_sym = $this->currency_sym;
        $product = array('title' => $title,'price' => $price);
        if ($page == 'billing')
        {
            $delname = 'del_item[' . $id . ']';
            eval('$return = "' . fetch_template('memarea_billingdetailsbit') . '";');
        }
        else
        {
            $_REQUEST['do'] = 'paymentdetails';
            eval('$return = "' . fetch_template('memarea_billingdetailsbit') . '";');
            $_REQUEST['do'] = $action;
        }
        return $return;
    }

    function sendOutNewSaleEmail()
    {
        if (!empty($this->vbulletin->options['memarea_email_new_sale']))
        {
            foreach (explode(",",$this->vbulletin->options['memarea_email_new_sale']) as $userid)
            {
                $userinfo = fetch_userinfo($userid);
                vbmail($userinfo['email'],construct_phrase($this->vbphrase['memarea_new_sale'],$this->vbulletin->options['bbtitle']),construct_phrase($this->vbphrase['memarea_new_sale_body'],$userinfo['username'],$this->vbulletin->options['bbtitle']));
                unset($userinfo);
            }
        }
    }

    function checkDetailsFields($requested,$errormessage)
    {
        if (empty($this->vbulletin->GPC['fullname']) or empty($this->vbulletin->GPC['address_1']) or
            empty($this->vbulletin->GPC['address_city']) or empty($this->vbulletin->GPC['address_zip']) or
            empty($this->vbulletin->GPC['country']) or empty($this->vbulletin->GPC['phone']))
        {
            //$GLOBALS['error'] = $errormessage;
            eval(standard_error($errormessage));
            //$this->handleRequest($requested);
            return false;
        }
        return true;
    }

    function handleRequest($do)
    {
        $method = 'handleRequest' . $do;
        if (method_exists($this,$method))
        {
            $this->{$method}();
        }
        foreach ($this->addons as $addon)
        {
            if (method_exists($this->{$addon},$method))
            {
                $this->{$addon}->{$method}();
            }
        }
    }

    function handleRequestgivelicense()
    {
        $vbphrase = $this->vbphrase;
        $GLOBALS['id'] = $this->vbulletin->input->clean_gpc('r','id',TYPE_UINT);
        $GLOBALS['license'] = $this->getLicense($GLOBALS['id'],true,false,'',false);
        $GLOBALS['templatename'] = 'memarea_givelicense';
    }

    function handleRequestdogivelicense()
    {
        $vbphrase = $this->vbphrase;
        $id = $this->vbulletin->input->clean_gpc('r','licenseid',TYPE_UINT);
        $username = $this->vbulletin->input->clean_gpc('r','usernames',TYPE_STR);
        $userinfo = $this->vbulletin->db->query_first("SELECT userid FROM " .
            TABLE_PREFIX . "user WHERE username = '" . $username . "'");
        if (empty($userinfo))
        {
            $GLOBALS['message'] = $vbphrase['memarea_givelicense_not_found'];
            $this->handleRequestgivelicense();
        }
        else
        { //User exists
            $license = $this->getLicense($id,false);
            $licensedm = datamanager_init('License',ERRTYPE_ARRAY);
            $licensedm->set_existing($license);
            $licensedm->setr('userid',$userinfo['userid']);
            $licensedm->save();
            eval(standard_error($vbphrase['memarea_gave_license']));
        }
    }

    function handleRequestmembersarea()
    {
        $vbphrase = $this->vbphrase;
        $licensesq = $this->vbulletin->db->query_read("SELECT licenses.*,licenses.title as sitetitle,products.title as title,products.licenseleng as expire FROM " .
            TABLE_PREFIX . "ma_licenses as licenses 
            LEFT JOIN " . TABLE_PREFIX .
            "ma_products as products ON (products.id = licenses.productid)
            WHERE licenses.userid = '" . $this->vbulletin->userinfo['userid'] . "'");
        $licenses = '';
        while ($license = $this->vbulletin->db->fetch_array($licensesq))
        {
            if (empty($license['sitetitle']))
            {
                $license['sitetitle'] = substr($license['url'],7);
            }
            $license['expiredate'] = $this->getLicenseExpireDate($license);
            eval('$licenses .= "' . fetch_template('memarea_clientsbit') . '";');
        }
        if ($this->addons['helpdesk'])
        {
            $GLOBALS['tickets'] = $this->helpdesk->getTicketsBitMem();
        }
        $GLOBALS['licenses'] = $licenses;
        $GLOBALS['templatename'] = 'memarea_clients';
    }

    function handleRequestlogout()
    {
        $this->vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX .
            "ma_session WHERE userid = '" . $this->vbulletin->userinfo['userid'] . "'");
        eval(standard_error($this->vbphrase['memarea_loggedout']));
    }

    function handleRequestlogin()
    {
        $this->vbulletin->input->clean_array_gpc('p',array('customernumber' => TYPE_STR,'password' => TYPE_STR));
        if ($this->checkCustomerInfo($this->vbulletin->GPC['customernumber'],$this->
            vbulletin->GPC['password']))
        {
            $this->startSession($this->vbulletin->userinfo['userid']);
            $this->handleRequest('membersarea');
            $GLOBALS['bypass'] = true;
        }
        else
        {
            $this->handleRequest('membersarea');
            $GLOBALS['errormessage'] = $this->vbphrase['memarea_bad_login'];
        }
    }

    function handleRequestresend_details()
    {
        $num = $this->vbulletin->userinfo['custnum'];
        $pass = $this->vbulletin->userinfo['ma_password'];
        $this->sendCustomerInfo($this->vbulletin->userinfo['userid'],$this->vbulletin->
            userinfo['username'],$pass);
        eval(standard_error($this->vbphrase['memarea_details_sent']));
    }

    function handleRequestlicence()
    {
        $GLOBALS['templatename'] = 'memarea_licence';
    }

    function handleRequestdetails()
    {
        $GLOBALS['values'] = $this->buildInfovalues();
        $GLOBALS['templatename'] = 'memarea_details';
    }

    function handleRequestsave_details()
    {
        $this->vbulletin->input->clean_array_gpc('p',array('fullname' => TYPE_STR,'address_1' => TYPE_STR,'address_2' => TYPE_STR,'address_city' => TYPE_STR,'address_state' => TYPE_STR,'address_zip' => TYPE_STR,'country' => TYPE_STR,'phone' => TYPE_STR,'company' => TYPE_STR));
        if ($this->checkDetailsFields('details',$this->vbphrase['memarea_required_fields']))
        {
            $information = $this->buildInfoArray();
            $this->vbulletin->userinfo['ma_info'] = $information;
            $this->vbulletin->userinfo['usergroupid'] = $usergrpid;
            if ($this->setCustomerNumber($information,$usergrpid))
            {
                $this->vbulletin->url = 'members.PHP?do=details';
                eval(print_standard_redirect($this->vbphrase['memarea_saved_details'],true));
            }
        }
    }

    function handleRequestproducts()
    {
        global $stylevar;
        $vbphrase = $this->vbphrase;
        $products = $this->vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX .
            "ma_products");
        $pros = '';
        $haspro = ($this->addons['pro'] == 'pro');
        $currency_sym = $this->currency_sym;
        while ($product = $this->vbulletin->db->fetch_array($products))
        {
            if ($this->checkProductPermissions($product))
            {
                $file = DIR . '/images/productthumbs/' . basename('thumbnail_product_' . $product['id'] .
                    $product['thumbnail_ext']);
                $show['prodthumb'] = false;
                if (file_exists($file))
                {
                    $filename = 'images/productthumbs/' . basename('thumbnail_product_' . $product['id'] .
                        $product['thumbnail_ext']);
                    $show['prodthumb'] = true;
                }
                $product['description'] = fetch_trimmed_title($product['description'],$this->
                    vbulletin->options['memarea_description_length']);
                eval('$pros .= "' . fetch_template('memarea_productsbit') . '";');
            }
        }
        $GLOBALS['pros'] = $pros;
        $GLOBALS['templatename'] = 'memarea_products';
    }
}

我要求您提供任何需要更新的内容,为什么需要更新,为什么需要对此进行更改的帮助。我可以用于更新需要更新的较旧产品的任何资源,以及此问题上的其他任何技巧。谢谢您的时间。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。