From 5d58099e8e5419aa40df7f461f002df5bfcfde5d Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sun, 9 Jul 2006 10:46:14 +0000 Subject: [PATCH] Can use a user-defined array instead of _GET git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@67 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- Changelog | 4 ++++ banana/NetNNTP.inc.php | 2 +- banana/banana.inc.php.in | 37 +++++++++++++++++++++++++------------ banana/misc.inc.php | 3 ++- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index 1a53c55..3c5ac82 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +Sun, 09 Jul 2006 Florent Bruneau + + * Can use a user-defined Array instead of $_GET + Sat, 08 Jul 2006 Florent Bruneau * Automatically set fup for crossposts diff --git a/banana/NetNNTP.inc.php b/banana/NetNNTP.inc.php index 45af23f..f15b6b1 100644 --- a/banana/NetNNTP.inc.php +++ b/banana/NetNNTP.inc.php @@ -46,7 +46,7 @@ class nntp $result = $this->gline(); $this->posting = ($result{0}=="200"); } - if ($result{0}=="2" && $url['user'] && $url['user']!='anonymous') { + if ($result{0}=="2" && isset($url['user']) && $url['user'] != 'anonymous') { return $this->authinfo($url['user'], $url['pass']); } return ($result{0}=="2"); diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 1ee9609..cfc5be9 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -82,6 +82,8 @@ class Banana var $post; var $spool; + var $get; + function Banana() { $this->_require('NetNNTP'); @@ -92,24 +94,35 @@ class Banana } } - function run($class = 'Banana') + /** Run Banana + * @param STRING class Name of the class to use + * @param ARRAY myget If defined is used instead of get + */ + function run($class = 'Banana', $myget = null) { global $banana; Banana::_require('misc'); $banana = new $class(); + if (is_null($myget)) { + $banana->get = $_GET; + } else { + $banana->get = $myget; + } + + if (!$banana->nntp) { return '

'._b_('Impossible de contacter le serveur').'

'; } - $group = empty($_GET['group']) ? null : strtolower($_GET['group']); - $artid = empty($_GET['artid']) ? null : strtolower($_GET['artid']); - $partid = !isset($_GET['part']) ? -1 : $_GET['part']; + $group = empty($banana->get['group']) ? null : strtolower($banana->get['group']); + $artid = empty($banana->get['artid']) ? null : strtolower($banana->get['artid']); + $partid = !isset($banana->get['part']) ? -1 : $banana->get['part']; $banana->state = Array ('group' => $group, 'artid' => $artid); if (is_null($group)) { - if (isset($_GET['subscribe'])) { + if (isset($banana->get['subscribe'])) { return $banana->action_listSubs(); } elseif (isset($_POST['subscribe'])) { $banana->action_saveSubs(); @@ -119,10 +132,10 @@ class Banana } elseif (is_null($artid)) { if (isset($_POST['action']) && $_POST['action'] == 'new') { return $banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1); - } elseif (isset($_GET['action']) && $_GET['action'] == 'new') { + } elseif (isset($banana->get['action']) && $banana->get['action'] == 'new') { return $banana->action_newFup($group); } else { - return $banana->action_showThread($group, isset($_GET['first']) ? intval($_GET['first']) : 1); + return $banana->action_showThread($group, isset($banana->get['first']) ? intval($banana->get['first']) : 1); } } else { @@ -132,8 +145,8 @@ class Banana $res = ''; } - if (isset($_GET['action'])) { - switch ($_GET['action']) { + if (isset($banana->get['action'])) { + switch ($banana->get['action']) { case 'cancel': $res .= $banana->action_showArticle($group, $artid, $partid); if ($banana->post->checkcancel()) { @@ -154,12 +167,12 @@ class Banana } } - if (isset($_GET['pj'])) { + if (isset($banana->get['pj'])) { $action = false; - if (isset($_GET['action']) && $_GET['action'] == 'view') { + if (isset($banana->get['action']) && $banana->get['action'] == 'view') { $action = true; } - $att = $banana->action_getAttachment($group, $artid, $_GET['pj'], $action); + $att = $banana->action_getAttachment($group, $artid, $banana->get['pj'], $action); if ($att != "") { return $res.$att; } diff --git a/banana/misc.inc.php b/banana/misc.inc.php index fb55a9f..150af47 100644 --- a/banana/misc.inc.php +++ b/banana/misc.inc.php @@ -85,7 +85,8 @@ function makeHREF($params, $text = null) if (is_null($text)) { $text = $link; } - if ($params['action'] == 'view') { + $target = null; + if (isset($params['action']) && $params['action'] == 'view') { $target = ' target="_blank"'; } return '' . $text . ''; -- 2.1.4