From 925704309e74c550da55f8c333ecfa968d5dc43a Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 5 Apr 2016 10:26:34 -0700 Subject: [PATCH] Fixes #1486 - Download error-page redirect issue. --- e107_handlers/redirection_class.php | 11 ++++++---- .../download/handlers/download_class.php | 15 ++++++++------ e107_plugins/download/request.php | 20 +++++++++++++------ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/e107_handlers/redirection_class.php b/e107_handlers/redirection_class.php index 14bac243a..f626e5cc9 100644 --- a/e107_handlers/redirection_class.php +++ b/e107_handlers/redirection_class.php @@ -372,10 +372,13 @@ class redirection if(defset('e_DEBUG') === 'redirect') { $error = debug_backtrace(); - - e107::getLog()->addDebug("URL: ".$url."\nFile: ".$error[1]['file']."\nLine: ".$error[1]['line']."\nClass: ".$error[1]['class']."\nFunction: ".$error[1]['function']."\n\n"); - e107::getLog()->toFile('redirect.log',true); - echo "debug active"; + + $message = "URL: ".$url."\nFile: ".$error[1]['file']."\nLine: ".$error[1]['line']."\nClass: ".$error[1]['class']."\nFunction: ".$error[1]['function']."\n\n"; + e107::getLog()->addDebug($message, true); + echo "Debug active"; + print_a($message); + echo "Go to : ".$url.""; + e107::getLog()->toFile('redirect.log',true); return; } diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 65aba581f..6ccb5d8c4 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -56,7 +56,7 @@ class download $this->qry['from'] = 0; // v2.x - if(varset($_GET['action'])) + if(!empty($_GET['action'])) { $this->qry['action'] = (string) $_GET['action']; $this->qry['view'] = varset($_GET['view']) ? intval($_GET['view']) : $this->qry['view']; @@ -64,6 +64,11 @@ class download $this->qry['order'] = vartrue($_GET['order']) && in_array("download_".$_GET['order'],$this->orderOptions) ? $_GET['order'] : $this->qry['order']; $this->qry['sort'] = (varset($_GET['sort']) == 'asc') ? "asc" : 'desc'; $this->qry['from'] = vartrue($_GET['from'],0); + + if($this->qry['action'] == 'error') + { + $this->qry['error'] = intval($this->qry['id']); + } } else // v1.x Legacy URL support. { @@ -84,9 +89,7 @@ class download } - - - // v1.x + // v1.x if(varset($_POST['view'])) { $this->qry['view'] = varset($_POST['view']) ? intval($_POST['view']) : 10; @@ -94,7 +97,7 @@ class download $this->qry['sort'] = (strtolower($_POST['sort']) == 'asc') ? "asc" : 'desc'; } - + } @@ -894,7 +897,7 @@ class download $errmsg = LAN_ERROR." ".$this->qry['error']; } - return $ns->tablerender(LAN_ERROR, $header. "
".$errmsg."
". $footer, 'download-error', true); + return $ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, $header. "
".$errmsg."
". $footer, 'download-error', true); } diff --git a/e107_plugins/download/request.php b/e107_plugins/download/request.php index 3968da1c8..50a49acd1 100644 --- a/e107_plugins/download/request.php +++ b/e107_plugins/download/request.php @@ -75,7 +75,10 @@ if(strstr(e_QUERY, "mirror")) header("Location: {$gaddress}"); exit(); } - header("Location: ".e_BASE."download.php?error.{$download_id}.1"); + + $goUrl = e107::getUrl()->create('download/index')."?action=error&id=".$download_id; + e107::redirect($goUrl); + //header("Location: ".e_BASE."download.php?error.{$download_id}.1"); exit; } } @@ -246,12 +249,13 @@ if ($type == "file") (strpos($pref['download_denied'],"signup.php") && USER == TRUE) )) { - header("Location: ".e_BASE."download.php?error.{$id}.1"); + $goUrl = e107::getUrl()->create('download/index')."?action=error&id=".$id; + e107::redirect($goUrl); exit(); } else { - header("Location: ".trim($pref['download_denied'])); + e107::redirect(trim($pref['download_denied'])); exit(); } } @@ -305,7 +309,7 @@ $image = ($table == "upload" ? $upload_ss : $download_image); if (strpos($image, "http") !== FALSE) { - header("Location: {$image}"); + e107::redirect($image); exit(); } else @@ -379,7 +383,9 @@ function check_download_limits() if($row['count'] >= $limits['gen_intdata']) { // Exceeded download count limit - header("Location: ".e_BASE."download.php?error.{$cutoff}.2"); + $goUrl = e107::getUrl()->create('download/index')."?action=error&id=".$cutoff; + e107::redirect($goUrl); + // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); /* require_once(HEADERF); $ns->tablerender(LAN_ERROR, LAN_dl_62); require(FOOTERF); */ @@ -409,7 +415,9 @@ function check_download_limits() if($row['total_bw'] / 1024 > $limit['gen_user_id']) { //Exceed bandwith limit - header("Location: ".e_BASE."download.php?error.{$cutoff}.2"); + $goUrl = e107::getUrl()->create('download/index')."?action=error&id=".$cutoff; + e107::redirect($goUrl); + // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); /* require(HEADERF); $ns->tablerender(LAN_ERROR, LAN_dl_62); require(FOOTERF); */