diff --git a/e107_handlers/db_debug_class.php b/e107_handlers/db_debug_class.php index c2a2217f4..587c4d1c9 100644 --- a/e107_handlers/db_debug_class.php +++ b/e107_handlers/db_debug_class.php @@ -448,7 +448,7 @@ class e107_db_debug { $tMarker['Memory Used'] = "".$tMarker['Memory Used'].""; } - // $aSum['Memory'] += $tMem; + $aSum['Memory'] = $tMem; if($tMarker['What'] == 'Stop') { @@ -511,7 +511,9 @@ class e107_db_debug { " . $aSum['DB Time'] . " " . $aSum['DB Count'] . " " . number_format($aSum['Memory'] / 1024, 1) . " - " . $tMarker['OB Lev'] . " + " . number_format($aSum['Memory'] / 1024, 1) . " + + " . $tMarker['OB Lev'] . " "; diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 3f3f8698b..90e5ad8ac 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -3665,13 +3665,17 @@ class e_parser /** * Take a file-path and convert it to a download link. - * @todo * @param $text * @return string */ public function toFile($text, $parm=array()) { - $link = e_HTTP."request.php?".str_replace('{e_MEDIA_FILE}', '',$text); + $srch = array( + '{e_MEDIA_FILE}' => 'e_MEDIA_FILE/', + '{e_PLUGIN}' => 'e_PLUGIN/' + ); + + $link = e_HTTP."request.php?file=". str_replace(array_keys($srch), $srch,$text); if(!empty($parm['raw'])) { diff --git a/request.php b/request.php index ae4382727..7acb9a38f 100644 --- a/request.php +++ b/request.php @@ -28,17 +28,34 @@ if (!e_QUERY || isset($_POST['userlogin'])) // Media-Manager direct file download. -if(vartrue($_GET['file']) && is_numeric($_GET['file'])) // eg. request.php?file=1 +if(!empty($_GET['file'])) // eg. request.php?file=1 { + if(is_numeric($_GET['file'])) + { + $query = "media_id= ".intval($_GET['file']); + } + else // @see $tp->toFile() + { + $srch = array( + '{e_MEDIA_FILE}' => 'e_MEDIA_FILE/', + '{e_PLUGIN}' => 'e_PLUGIN/' + ); + + $fileName = str_replace($srch,array_keys($srch),$_GET['file']); + + $query = "media_url= \"".e107::getParser()->filter($fileName)."\""; + + } + $sql = e107::getDb(); - if ($sql->select('core_media', 'media_url', "media_id= ".intval($_GET['file'])." AND media_userclass IN (".USERCLASS_LIST.") LIMIT 1 ")) + if ($sql->select('core_media', 'media_url', $query . " AND media_userclass IN (".USERCLASS_LIST.") LIMIT 1 ")) { $row = $sql->fetch(); // $file = $tp->replaceConstants($row['media_url'],'rel'); e107::getFile()->send($row['media_url']); } } -else //BC Legacy Support. (Downloads Plugin) +elseif(e107::isInstalled('download')) //BC Legacy Support. (Downloads Plugin) { e107::getRedirect()->redirect(e_PLUGIN."download/request.php?".e_QUERY); }