首页 > 解决方案 > VIVVO Lib 框架问题

问题描述

我们的网站使用 VIVVO 开源库。它以前工作。现在它不适用于 PHP 7 以上版本

我想修复以下错误

PHP 解析错误:语法错误,第 80 行 /home/indiaforum/public_html/lib/vivvo/framework/full_page_cache.functions.php 中的意外“新”(T_NEW)

错误第 80 行:$box_template = &new template($sm, $template);

full_page_cache.functions.php 完整代码在这里

      <?php
 /* =============================================================================
  * $Revision: 3409 $
  * $Date: 2009-01-30 12:55:32 +0100 (Fri, 30 Jan 2009) $
  *
  * Vivvo CMS 4.1
  * Copyright 2005-07 SpoonLabs d.o.o.
  * http://www.spoonlabs.com, All Rights Reserved
  *
  * Warning: This program is protected by copyright law. Unauthorized
  * reproduction or distribution of this program, or any portion of it, may
  * result in severe civil and criminal penalties, and will be prosecuted to the
  * maximum extent possible under the law. For more information about this
  * script or other scripts see http://www.spoonlabs.com
  * ============================================================================
  */
 
 if (!defined('VIVVO_COOKIE_DOMAIN')){
 
     if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $_SERVER['SERVER_NAME'])){
         define ('VIVVO_COOKIE_DOMAIN', $_SERVER['SERVER_NAME']);
     }else if (preg_match('/^www\./', $_SERVER['SERVER_NAME'])){
         define ('VIVVO_COOKIE_DOMAIN', '.' . preg_replace('/^www\./','', $_SERVER['SERVER_NAME']));
     }else if (strpos($_SERVER['SERVER_NAME'], '.') === false){
         define ('VIVVO_COOKIE_DOMAIN', '');
     }else{
         define ('VIVVO_COOKIE_DOMAIN', '.' . $_SERVER['SERVER_NAME']);
     }
 }
 
    function full_page_cache_load(){
        $connection = @mysql_connect(VIVVO_DB_HOST, VIVVO_DB_USER, VIVVO_DB_PASSWORD) or die("Can't connect! ".mysql_error());
        if (!mysql_select_db(VIVVO_DB_DATABASE, $connection)) die ("Error while connection to database. ".mysql_error());
 
        $res = mysql_query('SELECT * FROM ' . VIVVO_DB_PREFIX . 'Configuration WHERE variable_name = \'VIVVO_CACHE_ENABLE\'');
        while ($row = mysql_fetch_assoc($res)){
            @define ($row['variable_name'], $row['variable_value']);
        }
 
         $kill_cache = isset($_GET['kill_cache']);
         if (!$kill_cache && isset($_COOKIE['kill_cache']) && $_COOKIE['kill_cache'] == '1'){
             $kill_cache = true;
             setcookie("kill_cache", false, 1, '/',  VIVVO_COOKIE_DOMAIN);
         }
 
        if ((VIVVO_CACHE_ENABLE > 1) && !$kill_cache && !isset($_REQUEST['template_output']) && !isset($_REQUEST['action']) && !isset($_REQUEST['search_options']) && !preg_match('/\?print$/', $_SERVER['REQUEST_URI'])){
            $res = mysql_query('SELECT * FROM ' . VIVVO_DB_PREFIX . 'CacheData WHERE url = \'' . md5(CACHE_URL) . '\'');
            while ($row = mysql_fetch_assoc($res)){
                if ($row['body']){
                    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
                    //echo 'Cached';
                    $output = $row['body'];
                    //<!--NoCache box/login.tpl-->
                    if (VIVVO_CACHE_ENABLE == 2){
                        preg_match_all('/<!--NoCache ([a-zA-Z0-9_\/\.]+)-->/', $output, $arr);
                        $uncached_boxes = array_unique($arr[1]);
 
                    }
                    if (empty($uncached_boxes)){
                        $output = str_replace('$generation_time$', '0s', $row['body']);
                        echo $output;
                        exit;
                    }
                }
            }
        }
        $result = array($output, $uncached_boxes);
        return $result;
    }
 
    function full_page_cache_replace_boxes(&$sm, $uncached_boxes){
        if ((VIVVO_CACHE_ENABLE == 2) && !empty($uncached_boxes)){
            $output = $sm->output;
            $template =& $sm->get_template();
            $box_output = array();
            foreach ($uncached_boxes as $box_key => $box){
                $sm->debug_push("Full page cache:", 'Render ' . $box);
                $template_file = preg_replace('/[^a-zA-Z0-9\_\-\/\.]/', '', $box);
                if (file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . $template_file)){
                    $box_template =& new template($sm, $template);
                    $box_template->set_template_file(VIVVO_TEMPLATE_DIR . $template_file);
                    $output = preg_replace ('/<!--NoCache ' . preg_quote($box, '/') . '-->.*<!--NoCache-->/sU', $box_template->get_output(), $output);
                }
                //echo  '/<!--NoCache ' . preg_quote($box, '/') . '-->.*<!--NoCache-->/s';
                //$output = preg_replace ('/<!--NoCache ' . preg_quote($box, '/') . '-->.*<!--NoCache-->/s', '', $output);
            }
            if (defined('VIVVO_DEBUG_MODE')){
                $output = str_replace('</body>', $sm->format_debug_output(), $output);
            }
            echo $output;
            exit;
        }
    }
 
    function full_page_cache_save(&$sm, $output){
        if ((VIVVO_CACHE_ENABLE > 1) && isset($_GET['kill_cache'])){
            if ($sm->user && $sm->user->is_admin()){
                $sm->drop_db_cache();
            }
        }
        if ((VIVVO_CACHE_ENABLE > 1) && !isset($_REQUEST['action']) && !isset($_REQUEST['template_output']) && !isset($_REQUEST['search_options']) && !preg_match('/\?print$/', $_SERVER['REQUEST_URI'])){
            $sm->save_db_cache($output);
        }
    }
 ?>

标签: phpmysql

解决方案


推荐阅读