From b4ee6786c6d1f1cb2e63d5e6cb87982a8c723445 Mon Sep 17 00:00:00 2001 From: mcfly Date: Mon, 24 Nov 2008 18:06:03 +0000 Subject: [PATCH] Begin addition of url class and implementation --- class2.php | 16 ++++--- e107_files/shortcode/url.sc | 17 +++++++ e107_handlers/e107Url.php | 66 ++++++++++++++++++++++++++++ e107_handlers/e107_class.php | 33 ++++++++++++-- e107_plugins/pm/pm_shortcodes.php | 13 ++++-- e107_plugins/pm/private_msg_menu.php | 14 +++--- e107_plugins/pm/url/main.php | 15 +++++++ 7 files changed, 155 insertions(+), 19 deletions(-) create mode 100755 e107_files/shortcode/url.sc create mode 100755 e107_handlers/e107Url.php create mode 100755 e107_plugins/pm/url/main.php diff --git a/class2.php b/class2.php index e3cadcc75..d56346f67 100644 --- a/class2.php +++ b/class2.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/class2.php,v $ -| $Revision: 1.70 $ -| $Date: 2008-11-21 11:08:53 $ -| $Author: secretr $ +| $Revision: 1.71 $ +| $Date: 2008-11-24 18:06:03 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ // @@ -177,11 +177,13 @@ if(!isset($ADMIN_DIRECTORY)) } // -// clever stuff that figures out where the paths are on the fly.. no more need fo hard-coded e_HTTP :) +// clever stuff that figures out where the paths are on the fly.. no more need for hard-coded e_HTTP :) // e107_require_once(realpath(dirname(__FILE__).'/'.$HANDLERS_DIRECTORY).'/e107_class.php'); $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY'); -$e107 = new e107($e107_paths, realpath(dirname(__FILE__))); +$e107 = e107::getInstance(); +$e107->_init($e107_paths, realpath(dirname(__FILE__))); +//$e107 = new e107($e107_paths, realpath(dirname(__FILE__))); $inArray = array("'", ";", "/**/", "/UNION/", "/SELECT/", "AS "); if (strpos($_SERVER['PHP_SELF'], "trackback") === false) { @@ -218,8 +220,12 @@ if (preg_match("#\[(.*?)](.*)#", $_SERVER['QUERY_STRING'], $matches)) { // Start the parser; use it to grab the full query string // +e107_require_once(e_HANDLER.'e107Url.php'); +$e107->url = new eURL; + e107_require_once(e_HANDLER.'e_parse_class.php'); $tp = new e_parse; +$e107->tp = &$tp; //define("e_QUERY", $matches[2]); //define("e_QUERY", $_SERVER['QUERY_STRING']); diff --git a/e107_files/shortcode/url.sc b/e107_files/shortcode/url.sc new file mode 100755 index 000000000..02f2cc8f9 --- /dev/null +++ b/e107_files/shortcode/url.sc @@ -0,0 +1,17 @@ +// $Id: url.sc,v 1.1 2008-11-24 18:06:03 mcfly_e107 Exp $ +$e107 = e107::getInstance(); +list($part, $section, $type, $parms) = explode('::', $parm, 4); +if(strpos('=', $parms) !== false) +{ + parse_str($parms, $p); +} +else +{ + $p[$parms] = 1; +} +$e107->url->core = ($part == 'core'); +if($e107->url->createURL($section, $type, $p)) +{ + return $e107->url->link; +} +return 'Failed'; diff --git a/e107_handlers/e107Url.php b/e107_handlers/e107Url.php new file mode 100755 index 000000000..24a063bde --- /dev/null +++ b/e107_handlers/e107Url.php @@ -0,0 +1,66 @@ + 1); + } + $functionName = 'url_'.$section.'_'.$urlType; + if(!function_exists($functionName)) + { + $fileName = ($this->core ? e_FILE."url/custom/base/{$section}/{$urlType}.php" : e_FILE."url/custom/plugins/{$section}/{$urlType}.php"); + if(is_readable($fileName)) + { + include_once($fileName); + } + else + { + $fileName = ($this->core ? e_FILE."url/base/{$section}/{$urlType}.php" : e_PLUGIN."{$section}/url/{$urlType}.php"); + if(is_readable($fileName)) + { + include_once($fileName); + } + else + { + return false; + } + } + if(!function_exists($functionName)) + { + return false; + } + } + + if($this->link = call_user_func($functionName, $urlItems)) + { + return true; + } + + return false; + } + +} diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index e65eadf09..3bb7d5f1f 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ -| $Revision: 1.21 $ -| $Date: 2008-11-23 20:26:23 $ -| $Author: e107steved $ +| $Revision: 1.22 $ +| $Date: 2008-11-24 18:06:03 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -34,6 +34,7 @@ class e107 var $relative_base_path; var $_ip_cache; var $_host_name_cache; + /** * e107 class constructor * @@ -42,12 +43,38 @@ class e107 * @return e107 */ function e107($e107_paths, $e107_root_path) + { + if(!defsettrue('e107_php4_check')) + { + echo ('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use e107::getInstance()'); + exit(); + } + $this->_init($e107_paths, $e107_root_path); + } + + function _init($e107_paths, $e107_root_path) { $this->e107_dirs = $e107_paths; $this->set_paths(); $this->file_path = $this->fix_windows_paths($e107_root_path)."/"; } + /** + * Get instance - php4 singleton implementation + * + * @return singleton object + */ + function &getInstance() + { + static $instance = array();//it's array because of an odd PHP 4 bug + + if(!$instance) + { + define('e107_php4_check', true); + $instance[0] = new e107(); + } + return $instance[0]; + } function set_base_path() { diff --git a/e107_plugins/pm/pm_shortcodes.php b/e107_plugins/pm/pm_shortcodes.php index 3aca32a56..4b46dec82 100755 --- a/e107_plugins/pm/pm_shortcodes.php +++ b/e107_plugins/pm/pm_shortcodes.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $ -| $Revision: 1.5 $ -| $Date: 2007-09-22 17:41:20 $ -| $Author: e107steved $ +| $Revision: 1.6 $ +| $Date: 2008-11-24 18:06:03 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } @@ -350,10 +350,15 @@ if($pm_info['pm_to'] == USERID) SC_END SC_BEGIN SEND_PM_LINK +$e107 = e107::getInstance(); $pm_outbox = pm_getInfo('outbox'); if($pm_outbox['outbox']['filled'] < 100) { - return "".PM_SEND_LINK.""; + $e107->url->core = false; + if($e107->url->createUrl('pm','main','send')) + { + return "".PM_SEND_LINK.""; + } } return ""; SC_END diff --git a/e107_plugins/pm/private_msg_menu.php b/e107_plugins/pm/private_msg_menu.php index 8d8ec9d53..3fd804969 100755 --- a/e107_plugins/pm/private_msg_menu.php +++ b/e107_plugins/pm/private_msg_menu.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $ -| $Revision: 1.3 $ -| $Date: 2008-07-28 20:16:14 $ -| $Author: e107steved $ +| $Revision: 1.4 $ +| $Date: 2008-11-24 18:06:03 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } @@ -47,14 +47,14 @@ $sc_style['NEWPM_ANIMATE']['post'] = ""; if(!isset($pm_menu_template)) { $pm_menu_template = " - ".PM_INBOX_ICON." - ".LAN_PM_25." + ".PM_INBOX_ICON." + ".LAN_PM_25." {NEWPM_ANIMATE}
{INBOX_TOTAL} ".LAN_PM_36.", {INBOX_UNREAD} ".LAN_PM_37." {INBOX_FILLED}
- ".PM_OUTBOX_ICON." - ".LAN_PM_26."
+ ".PM_OUTBOX_ICON." + ".LAN_PM_26."
{OUTBOX_TOTAL} ".LAN_PM_36.", {OUTBOX_UNREAD} ".LAN_PM_37." {OUTBOX_FILLED} {SEND_PM_LINK} "; diff --git a/e107_plugins/pm/url/main.php b/e107_plugins/pm/url/main.php new file mode 100755 index 000000000..0300ad426 --- /dev/null +++ b/e107_plugins/pm/url/main.php @@ -0,0 +1,15 @@ +