From 221af3a2e035bd6689294509feb52f286d3bd5be Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 18:00:00 +0200 Subject: database connection and documentation API --- html/app/models/Jorge.php | 33 +++++++++++++++------------- html/app/models/Validate_model.php | 27 ----------------------- html/app/models/cms/Media_model.php | 36 +++++++++++++++++++++++++++++++ html/app/models/user/Validate_model.php | 27 +++++++++++++++++++++++ html/app/views/error/404.php | 38 +++++++++++++++++++++++++++++++++ html/app/views/error/general.php | 38 +++++++++++++++++++++++++++++++++ 6 files changed, 157 insertions(+), 42 deletions(-) delete mode 100644 html/app/models/Validate_model.php create mode 100644 html/app/models/user/Validate_model.php create mode 100644 html/app/views/error/404.php create mode 100644 html/app/views/error/general.php diff --git a/html/app/models/Jorge.php b/html/app/models/Jorge.php index 011b8c0..5d79007 100644 --- a/html/app/models/Jorge.php +++ b/html/app/models/Jorge.php @@ -43,21 +43,23 @@ class Jorge // define relations $this->tables['relate'] = [ - 'products' => [ - 'brands' => 'products.BrandID = brands.ID', - 'products_to_product_categories' => 'products.ID = products_to_product_categories.SimpleProductID', - 'products_to_images' => 'products.ID = products_to_images.SimpleProductID', - 'prices' => 'products.SKU = prices.SKU' + 'lesson' => [ + 'course' => 'course.id = lesson.course_id', + 'lesson_media' => 'lesson_media.lesson_id = lesson.id', + 'lesson_privilege' => 'lesson_privilege.lesson_id = lesson.id' ], - 'products_to_product_categories' => [ - 'product_categories' => 'product_categories.ID = products_to_product_categories.ProductCategoryID' + 'page' => [ + 'page_media' => 'page_media.page_id = page.id' ], - 'products_to_images' => [ - 'products' => 'products_to_images.SimpleProductID = products.ID', - 'assets' => 'products_to_images.ImageID = assets.ID' - ] + 'user' => [ + 'user_privilege' => 'user_privilege.user_id = user.id' + ], + + 'privilege' => [ + 'user_privilege' => 'user_privilege.privilege_id = privilege.id' + ], ]; @@ -113,7 +115,7 @@ class Jorge private function extractTableFields() { // words used by SQL that can not be field names - $nonFields = ['PRIMARY', 'KEY', '(', ')']; // reduced list (used on CREATE) + $nonFields = ['PRIMARY', 'KEY', '(', ')', 'CONSTRAINT', 'UNIQUE']; // reduced list (used on CREATE) foreach( $this->tables['create'] as $table => $sqlCreate ) { @@ -130,10 +132,11 @@ class Jorge // remove 1st+last parentesis $mainDefinitions = substr($match[0][0], 1, -1); - // replace comma (,) on decimal definitions - // example: 'decimal(18, 2)' turns to 'decimal(18: 2)' + // replace comma (,) on sub-parenthesis + // ex: 'decimal(18, 2)' turns to 'decimal(18: 2)' + // or: 'PRIMARY KEY (id1, id2)' turns to 'PRIMARY KEY (id1: id2)' $sentences = preg_replace( - '/\\(([0-9]*)[ ,]([0-9 ]*)\\)/', + '/\\(([0-9a-zA-Z_`]*)[ ,]([0-9a-zA-Z_` ]*)\\)/', '($1:$2)', $mainDefinitions, -1 diff --git a/html/app/models/Validate_model.php b/html/app/models/Validate_model.php deleted file mode 100644 index ec60d72..0000000 --- a/html/app/models/Validate_model.php +++ /dev/null @@ -1,27 +0,0 @@ -, rights =>, path => ] + + // validate ticket + // ValidateAccess::for($ticket) + + // serve + // header("Content-type: type"); + // passthru('cat $media_path'); + + + return Registry::use('database')->query( + "SELECT * FROM pages + WHERE FullFriendlyUrl = :url AND IsActive = 1", + [ ':url' => $url ] + )->getFirst(); + } + +} + + + +// check: +// https://stackoverflow.com/questions/1353850/serve-image-with-php-script-vs-direct-loading-an-image \ No newline at end of file diff --git a/html/app/models/user/Validate_model.php b/html/app/models/user/Validate_model.php new file mode 100644 index 0000000..ec60d72 --- /dev/null +++ b/html/app/models/user/Validate_model.php @@ -0,0 +1,27 @@ + + + + + 404: Not Found + + + +
+
+

4O4

+ NOT FOUND
+ — +
+ +
+
+ + diff --git a/html/app/views/error/general.php b/html/app/views/error/general.php new file mode 100644 index 0000000..1c3c6ae --- /dev/null +++ b/html/app/views/error/general.php @@ -0,0 +1,38 @@ + + + + + 404: Not Found + + + +
+
+

Error

+ Oops!
+ — +
+ +
+
+ + -- cgit v1.2.3