From 1c300bb49b1139f25bd0b66f2a2cd36c49c013b5 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind1991@gmail.com>
Date: Mon, 18 Apr 2011 14:04:55 +0200
Subject: [PATCH] make error 404 template usable as stand alone php file

---
 plugins/publiclink/get.php |  7 +++++++
 templates/404.php          | 10 ++++++++++
 2 files changed, 17 insertions(+)

diff --git a/plugins/publiclink/get.php b/plugins/publiclink/get.php
index fb8a13b541..41b10484f9 100644
--- a/plugins/publiclink/get.php
+++ b/plugins/publiclink/get.php
@@ -19,6 +19,13 @@ if($path!==false){
 		$subPath='';
 	}
 	$path.=$subPath;
+	if(!OC_FILESYSTEM::file_exists($path)){
+		header("HTTP/1.0 404 Not Found");
+		$tmpl = new OC_TEMPLATE( '', '404', 'guest' );
+		$tmpl->assign('file',$subPath);
+		$tmpl->printPage();
+		exit;
+	}
 	if(OC_FILESYSTEM::is_dir($path)){
 		$files = array();
 		$rootLength=strlen($root);
diff --git a/templates/404.php b/templates/404.php
index 7696d16f8e..8909db29a4 100644
--- a/templates/404.php
+++ b/templates/404.php
@@ -1,3 +1,13 @@
+<?php
+if(!isset($_)){//also provide standalone error page
+	require_once '../lib/base.php';
+	require( 'template.php' );
+	
+	$tmpl = new OC_TEMPLATE( '', '404', 'guest' );
+	$tmpl->printPage();
+	exit;
+}
+?>
 <div id="login">
 	<img src="<?php echo image_path("", "weather-clear.png"); ?>" alt="ownCloud" />
 	<ul>
-- 
GitLab