From 8796039d0835b9bc51a68e7d46a67673b03be816 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 20 Jan 2014 03:26:15 -0800 Subject: [PATCH] Backward compatibility fixes. --- e107_admin/modcomment.php | 23 ++++- e107_core/shortcodes/single/plugin.php | 43 +++++++++ e107_handlers/xml_class.php | 120 ++++++++++++++++++++++++- 3 files changed, 180 insertions(+), 6 deletions(-) diff --git a/e107_admin/modcomment.php b/e107_admin/modcomment.php index f80456e0b..7ed53b4d9 100644 --- a/e107_admin/modcomment.php +++ b/e107_admin/modcomment.php @@ -2,20 +2,33 @@ /* * e107 website system * - * Copyright (C) 2008-2013 e107 Inc (e107.org) + * Copyright (C) 2008-2014 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - * + * Exists only for BC. */ -// Moc: up for removal? Replaced by /e107_admin/comment.php - require_once("../class2.php"); if (!getperms("B")) { header("location:".e_BASE."index.php"); exit; } + + +$tmp = explode(".", e_QUERY); +$table = $tmp[0]; +$id = intval($tmp[1]); +$editid = intval($tmp[2]); + +$url = e_ADMIN_ABS."comment.php?searchquery=".$id."&filter_options=comment_type__".e107::getComment()->getCommentType($table); + +e107::getRedirect()->go($url); +exit; + + +/* + include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); require_once("auth.php"); @@ -195,5 +208,7 @@ function delete_children($row, $cid) $sql->db_Delete("comments", "comment_id='$cid'"); } } +*/ + ?> \ No newline at end of file diff --git a/e107_core/shortcodes/single/plugin.php b/e107_core/shortcodes/single/plugin.php index 8b904bd77..ac38ef342 100644 --- a/e107_core/shortcodes/single/plugin.php +++ b/e107_core/shortcodes/single/plugin.php @@ -7,8 +7,39 @@ function plugin_shortcode($parm = '') @list($menu,$parms) = explode('|',$parm.'|', 2); + $path = $tp->toDB(dirname($menu)); $name = $tp->toDB(basename($menu)); + + //BC Fix for v2.x + + $changeMenuPaths = array( + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), + array('oldpath' => 'siteinfo_menu', 'newpath' => 'siteinfo', 'menu' => 'latestnews_menu'), + array('oldpath' => 'compliance_menu', 'newpath' => 'siteinfo', 'menu' => 'compliance_menu'), + array('oldpath' => 'powered_by_menu', 'newpath' => 'siteinfo', 'menu' => 'powered_by_menu'), + array('oldpath' => 'sitebutton_menu', 'newpath' => 'siteinfo', 'menu' => 'sitebutton_menu'), + array('oldpath' => 'counter_menu', 'newpath' => 'siteinfo', 'menu' => 'counter_menu'), + array('oldpath' => 'usertheme_menu', 'newpath' => 'user_menu', 'menu' => 'usertheme_menu'), + array('oldpath' => 'userlanguage_menu', 'newpath' => 'user_menu', 'menu' => 'userlanguage_menu'), + array('oldpath' => 'lastseen_menu', 'newpath' => 'online', 'menu' => 'lastseen_menu'), + array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news_menu'), + array('oldpath' => 'other_news_menu', 'newpath' => 'news', 'menu' => 'other_news2_menu') + ); + + foreach($changeMenuPaths as $k=>$v) + { + if($v['oldpath'] == $path && $v['menu'] == $name) + { + $path = $v['newpath']; + continue; + } + } + if($path == '.') { @@ -18,6 +49,18 @@ function plugin_shortcode($parm = '') * @todo check if plugin is installed when installation required */ + + + + + + + + + + + + /** * fixed todo: $mode is provided by the menu itself, return is always true, added optional menu parameters */ diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 1f8929a44..e7a6ceb64 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -17,6 +17,16 @@ if (!defined('e107_INIT')) { exit; } class parseXml extends xmlClass // BC with v1.x { + function __construct() + { + $data = debug_backtrace(true); + $log = e107::getAdminLog(); + $log->addDebug('Deprecated XML Parser Used'); + + $log->addArray($data); + $log->save('DEPRECATED',E_LOG_NOTICE); + + } function setUrl($feed) { @@ -25,9 +35,110 @@ class parseXml extends xmlClass // BC with v1.x function getRemoteXmlFile($address, $timeout = 10) { - return $this->getRemoteFile($address, $timeout); + // $data = $this->getRemoteFile($address, $timeout); + $fl = e107::getFile(); + $data = $fl->getRemoteContent($address); + + $this->xmlLegacyContents = $data; + + return $data; } + function parseXmlContents () + { + $log = e107::getAdminLog(); + + foreach($this -> xmlData as $key => $value) + { + unset($this -> xmlData[$key]); + } + foreach($this -> counterArray as $key => $value) + { + unset($this -> counterArray[$key]); + } + + if(!function_exists('xml_parser_create')) + { + $log->addDebug("No XML source specified")->save('XML',E_LOG_WARNING); + return FALSE; + } + + if(!$this -> xmlLegacyContents) + { + + $log->addDebug("No XML source specified")->save('XML'); + return FALSE; + } + + $this->parser = xml_parser_create(''); + + xml_set_object($this->parser, $this); + xml_set_element_handler($this->parser, 'startElement', 'endElement'); + xml_set_character_data_handler( $this->parser, 'characterData' ); + + $array = explode("\n", $this -> xmlLegacyContents); + + + foreach($array as $data) + { + + if(strlen($data == 4096)) + { + $log->addDebug("The XML cannot be parsed as it is badly formed.")->save('XML'); + return FALSE; + } + + if (!xml_parse($this->parser, $data)) + { + $error = sprintf('XML error: %s at line %d, column %d', xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser),xml_get_current_column_number($this->parser)); + $log->addDebug($error)->save('XML'); + return FALSE; + } + } + xml_parser_free( $this->parser ); + return $this -> xmlData; + } + + + + function startElement ($p, $element, &$attrs) + { + $this -> start_tag = $element; + $this -> current_tag = strtolower($element); + if(!array_key_exists($this -> current_tag, $this -> counterArray)) + { + $this -> counterArray[$this -> current_tag] = 0; + $this -> xmlData[$this -> current_tag][$this -> counterArray[$this -> current_tag]] = ""; + } + } + + function endElement ($p, $element) + { + if($this -> start_tag == $element) + { + $this -> counterArray[$this -> current_tag] ++; + } + } + + function characterData ($p, $data) + { + $data = trim ( chop ( $data )); + $data = preg_replace('/&(?!amp;)/', '&', $data); + if(!array_key_exists($this -> current_tag, $this -> xmlData)) + { + $this -> xmlData [$this -> current_tag] = array(); + } + if(array_key_exists($this -> counterArray[$this -> current_tag], $this -> xmlData [$this -> current_tag])) + { + $this -> xmlData [$this -> current_tag] [$this -> counterArray[$this -> current_tag]] .= $data; + } + else + { + $this -> xmlData [$this -> current_tag] [$this -> counterArray[$this -> current_tag]] = $data; + } + } + + } @@ -304,7 +415,8 @@ class xmlClass if($feed) { $this->_feedUrl = $feed; - } + } + return $this; } /** @@ -318,6 +430,10 @@ class xmlClass */ function getRemoteFile($address, $timeout = 10, $postData=null) { + $debug = debug_backtrace(true); + e107::getAdminLog()->addDebug("Deprecated getRemoteFile() method used. Use e_file::getRemoteContent() instead.")->addArray($debug)->save('DEPRECATED',E_LOG_NOTICE); + + $_file = e107::getFile(); $this->xmlFileContents = $_file->getRemoteContent($address, array('timeout' => $timeout, 'post' => $postData)); $this->error = $_file->error;