summaryrefslogtreecommitdiff
path: root/public/app
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 01:55:12 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 01:55:12 +0300
commit6e749800d8a9f6b77bf50be92a70b7916c2804f3 (patch)
tree3d6ba2eb67fa11f228b756e0f84ef8ecb3f6ff34 /public/app
parent546daa78721e6abdbc89afcecc158118c2239865 (diff)
downloadclassroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.tar.gz
classroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.tar.bz2
classroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.zip
hotfixes and optimizations
Diffstat (limited to 'public/app')
-rw-r--r--public/app/controllers/Auth.php1
-rw-r--r--public/app/controllers/admin/Course_admin.php6
-rw-r--r--public/app/controllers/cms/Course.php8
-rw-r--r--public/app/routes/frontend.php1
-rw-r--r--public/app/views/error/404.php24
5 files changed, 37 insertions, 3 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php
index 32ff07a..4a6b9ed 100644
--- a/public/app/controllers/Auth.php
+++ b/public/app/controllers/Auth.php
@@ -227,6 +227,7 @@ class Auth {
unset($_COOKIE['cluser']);
setcookie('cluser', '', -1, '/');
return true;
+
} else {
return false;
}
diff --git a/public/app/controllers/admin/Course_admin.php b/public/app/controllers/admin/Course_admin.php
index f68ead2..fcf38c9 100644
--- a/public/app/controllers/admin/Course_admin.php
+++ b/public/app/controllers/admin/Course_admin.php
@@ -174,6 +174,9 @@ class Course_admin {
// set lesson's media files; NOTE: lesson_media table
// ERROR: self::create_medias_for_lesson($post['media'], $id, $post['privilege_id']);
self::create_medias_for_lesson($post['media'], $id);
+
+ // recache media
+ Cache_service::files_attributes(PROXY_IGNORE_CACHE);
}
return true;
@@ -229,6 +232,9 @@ class Course_admin {
// update lesson's media files
// ERROR: self::create_medias_for_lesson($post['media'], $post['id'], $post['privilege_id']);
self::create_medias_for_lesson($post['media'], $post['id']);
+
+ // recache media
+ Cache_service::files_attributes(PROXY_IGNORE_CACHE);
}
return true;
diff --git a/public/app/controllers/cms/Course.php b/public/app/controllers/cms/Course.php
index c795ab9..47eac5f 100644
--- a/public/app/controllers/cms/Course.php
+++ b/public/app/controllers/cms/Course.php
@@ -68,6 +68,12 @@ class Course {
Render::file($real_path, $media_type);
}
+ } else {
+ Render::view('error/404', [
+ 'error_code' => 403,
+ 'moto' => 'Forbidden',
+ 'message' => ''
+ ]);
}
}
@@ -85,7 +91,9 @@ class Course {
$medias = Cache_service::files_attributes();
foreach($medias as $key => $medi) {
+
if ($medi['path'] == $path) {
+
return $medi;
}
}
diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php
index 601641f..be06b1c 100644
--- a/public/app/routes/frontend.php
+++ b/public/app/routes/frontend.php
@@ -45,7 +45,6 @@ Route::add('/page/([0-9]*)', // request lesson by lesson-id
function($id) { Course::page($id); }
);
-
Route::add('/serve/file/([0-9a-zA-Z-_\.\/]*)', // serve file by path
function ($path) { Course::serve_file($path); } // (also ?type= is sent)
);
diff --git a/public/app/views/error/404.php b/public/app/views/error/404.php
index 4bbf083..a085830 100644
--- a/public/app/views/error/404.php
+++ b/public/app/views/error/404.php
@@ -1,3 +1,23 @@
+<?php
+/** general error page
+ *
+ * defaults to 404 error but can be used for any other error code
+ *
+ * imported variables:
+ *
+ * optional @var $error_code (int) : error code
+ * optional @var $moto (string) : super-mini description text
+ * optional @var $message (string)
+ *
+ */
+
+ if (!isset($error_code)) { // if error code not set
+ $error_code = 404; // set default (404)
+ }
+
+ http_response_code(403);
+
+?>
<!DOCTYPE html>
<html lang="en">
<head>
@@ -32,8 +52,8 @@
<body>
<div class='container'>
<div class='content'>
- <h3>4O4</h3>
- Not found<br />
+ <h3><?=$error_code?></h3>
+ <?= $moto ?? 'Not found' ?><br />
<!--
<br />