diff --git a/base/config.base.php b/base/config.base.php
index feec79c..601dc23 100755
--- a/base/config.base.php
+++ b/base/config.base.php
@@ -1,18 +1,18 @@
setVersion(1.0);
$config->setDatabase([
- DatabaseHandler::DB_TYPE => 'mysql', //please change only if you know what you're doing! this can break a lot.
- DatabaseHandler::DB_HOST => '127.0.0.1',
- DatabaseHandler::DB_PORT => '3306', //default port is 3306
- DatabaseHandler::DB_USER => 'venom',
- DatabaseHandler::DB_PASSWORD => 'venomPassword',
- DatabaseHandler::DB_DB => 'venomCMS',
- DatabaseHandler::DB_EXTRA => '' // need to start with ';'
+ Database::DB_TYPE => 'mysql', //please change only if you know what you're doing! this can break a lot.
+ Database::DB_HOST => '127.0.0.1',
+ Database::DB_PORT => '3306', //default port is 3306
+ Database::DB_USER => 'venom',
+ Database::DB_PASSWORD => 'venomPassword',
+ Database::DB_DB => 'venomCMS',
+ Database::DB_EXTRA => '' // need to start with ';'
]);
/**
diff --git a/base/lang.base.php b/base/lang.base.php
old mode 100644
new mode 100755
diff --git a/base/module.base.php b/base/module.base.php
index e51a2b3..815fd85 100755
--- a/base/module.base.php
+++ b/base/module.base.php
@@ -1,9 +1,4 @@
need to have the Module Class at parent with the init function ;)
-$modules = [];
-
-// register controllers that can handle templates ;) need to have a render function for this
-$controllers = [
- 'test' => \Controllers\TestController::class,
-];
\ No newline at end of file
+//register modules -> only apply Module Path! like Meta now the ModuleLoader search for /modules/Meta/module.php!
+$modules = [];
\ No newline at end of file
diff --git a/base/router.base.php b/base/router.base.php
old mode 100644
new mode 100755
index 008287d..10e33d3
--- a/base/router.base.php
+++ b/base/router.base.php
@@ -11,19 +11,5 @@ if (!isset($venom)) {
exit(1);
}
-$router = new Router('defaultRouter', 1.0, 'api/');
-$router->addRoutes([
- '/test' => [
- 'cl' => Route::class,
- 'roles' => ['ROLE_GUEST'],
- 'routes' => [
- '*' => [
- "GET" => 'getAll'
- ],
- '1' => [
- "GET" => 'getAll'
- ]
- ]
- ],
-]);
-$venom->addRouter('defaultRouter', $router);
\ No newline at end of file
+$router = new Router(Router::DEFAULT_ROUTER, 1.0, 'api/');
+$venom->addRouter($router);
\ No newline at end of file
diff --git a/conf/.gitkeep b/conf/.gitkeep
old mode 100644
new mode 100755
diff --git a/install/db.sql b/install/db.sql
index 9c4be2b..8617f21 100755
--- a/install/db.sql
+++ b/install/db.sql
@@ -38,23 +38,23 @@ create table if not exists data
create table if not exists users
(
- id int(255) auto_increment not null unique primary key,
- username varchar(255) not null unique,
- firstname varchar(255) not null,
- lastname varchar(255) not null,
- email varchar(255) not null,
- password varchar(255) not null,
- token varchar(255) not null,
- salt varchar(255) not null,
- roles text default 'ROLE_GUEST' not null,
- isActive tinyint(1) default 1 null
+ id int(255) auto_increment not null unique primary key,
+ username varchar(255) not null unique,
+ firstname varchar(255) not null,
+ lastname varchar(255) not null,
+ email varchar(255) not null,
+ password varchar(255) not null,
+ token varchar(255) not null,
+ salt varchar(255) not null,
+ roleId text default '0' not null,
+ isActive tinyint(1) default 1 null
)
comment 'User File';
create table if not exists roles
(
id int(255) auto_increment not null unique primary key,
- name varchar(255) not null unique,
+ name varchar(255) not null unique,
content JSON not null,
isActive tinyint(1) default 1 null
)
\ No newline at end of file
diff --git a/lang/example.php b/lang/example.php
old mode 100644
new mode 100755
diff --git a/public/.htaccess b/public/.htaccess
old mode 100644
new mode 100755
diff --git a/public/content/.gitkeep b/public/content/.gitkeep
old mode 100644
new mode 100755
diff --git a/public/theme/admin/css/admin-panel.css b/public/theme/admin/css/admin-panel.css
old mode 100644
new mode 100755
diff --git a/public/theme/admin/css/login.css b/public/theme/admin/css/login.css
old mode 100644
new mode 100755
diff --git a/public/theme/admin/css/style.css b/public/theme/admin/css/style.css
old mode 100644
new mode 100755
diff --git a/public/theme/admin/icon-sprite.svg b/public/theme/admin/icon-sprite.svg
old mode 100644
new mode 100755
diff --git a/public/theme/admin/images/logo.svg b/public/theme/admin/images/logo.svg
old mode 100644
new mode 100755
diff --git a/public/theme/admin/js/components.js b/public/theme/admin/js/components.js
old mode 100644
new mode 100755
diff --git a/public/theme/admin/js/components.min.js b/public/theme/admin/js/components.min.js
old mode 100644
new mode 100755
diff --git a/public/theme/admin/js/scripts.js b/public/theme/admin/js/scripts.js
old mode 100644
new mode 100755
diff --git a/public/theme/admin/js/scripts.min.js b/public/theme/admin/js/scripts.min.js
old mode 100644
new mode 100755
diff --git a/public/theme/default/css/test.css b/public/theme/default/css/test.css
old mode 100644
new mode 100755
diff --git a/public/theme/default/js/test.js b/public/theme/default/js/test.js
old mode 100644
new mode 100755
diff --git a/src/Venom/Admin/AdminController.php b/src/Venom/Admin/AdminController.php
old mode 100644
new mode 100755
index 839a0a1..57e90e2
--- a/src/Venom/Admin/AdminController.php
+++ b/src/Venom/Admin/AdminController.php
@@ -4,12 +4,12 @@
namespace Venom\Admin;
+use Venom\Entities\RoleEntity;
use Venom\Helper\URLHelper;
+use Venom\Security\Security;
use Venom\Views\Asset;
use Venom\Views\RenderController;
use Venom\Views\VenomRenderer;
-use Venom\Models\User;
-use \Venom\Security\Security;
class AdminController implements RenderController
@@ -29,7 +29,7 @@ class AdminController implements RenderController
$this->tpl = 'async';
}
- $isLogin = Security::get()->hasRole(User::ADMIN_ROLE);
+ $isLogin = Security::get()->hasPermission("admin", RoleEntity::TYPE_READ);
$renderer->addVar('isLoggedIn', $isLogin);
if (!$isLogin) {
Asset::get()->addCSS('login', 'login.css');
diff --git a/src/Venom/Admin/AdminModulesLoader.php b/src/Venom/Admin/AdminModulesLoader.php
deleted file mode 100644
index 38e687a..0000000
--- a/src/Venom/Admin/AdminModulesLoader.php
+++ /dev/null
@@ -1,26 +0,0 @@
- MetaDataModule::class,
- 'pages' => PageModule::class,
- 'role' => RoleModule::class,
- 'seoUrl' => SeoUrlModule::class,
- 'users' => UserModule::class,
- 'venomStatus' => VenomStatusModule::class,
- ];
- }
-}
\ No newline at end of file
diff --git a/src/Venom/Admin/AdminRouterInit.php b/src/Venom/Admin/AdminRouterInit.php
old mode 100644
new mode 100755
index 7a8ce90..e183a9b
--- a/src/Venom/Admin/AdminRouterInit.php
+++ b/src/Venom/Admin/AdminRouterInit.php
@@ -6,6 +6,7 @@ namespace Venom\Admin;
use Venom\Admin\Routes\LoginRoute;
use Venom\Admin\Routes\TemplateLoader;
+use Venom\Routing\Route;
use Venom\Routing\Router;
use Venom\Venom;
@@ -19,27 +20,19 @@ class AdminRouterInit
public static function getRoutes(): array
{
return [
- '/login' => [
- 'cl' => LoginRoute::class,
- 'roles' => ['ROLE_GUEST'],
- 'routes' => [
- '*' => [
- "POST" => 'login'
- ],
- '1' => [
- "GET" => 'handle'
- ]
+ '/login' => new Route(LoginRoute::class, [
+ '*' => [
+ "POST" => 'login'
+ ],
+ '1' => [
+ "GET" => 'handle'
]
- ],
- '/templateLoader' => [
- 'cl' => TemplateLoader::class,
- 'roles' => ['ROLE_GUEST'],
- 'routes' => [
- '*' => [
- "GET" => 'handle'
- ]
- ]
- ]
+ ]),
+ '/templateLoader' => new Route(TemplateLoader::class, [
+ '*' => [
+ "GET" => 'handle'
+ ],
+ ]),
];
}
}
\ No newline at end of file
diff --git a/src/Venom/Admin/Routes/LoginRoute.php b/src/Venom/Admin/Routes/LoginRoute.php
old mode 100644
new mode 100755
index ef4c9ce..c3ebc2f
--- a/src/Venom/Admin/Routes/LoginRoute.php
+++ b/src/Venom/Admin/Routes/LoginRoute.php
@@ -4,11 +4,9 @@
namespace Venom\Admin\Routes;
-use Venom\Core\ArgumentHandler;
-use Venom\Routing\Route;
use Venom\Security\Security;
-class LoginRoute implements Route
+class LoginRoute
{
public function login(): bool
diff --git a/src/Venom/Admin/Routes/TemplateLoader.php b/src/Venom/Admin/Routes/TemplateLoader.php
old mode 100644
new mode 100755
index d0a331d..187665a
--- a/src/Venom/Admin/Routes/TemplateLoader.php
+++ b/src/Venom/Admin/Routes/TemplateLoader.php
@@ -6,9 +6,8 @@ namespace Venom\Admin\Routes;
use Venom\Core\ArgumentHandler;
use Venom\Core\Config;
use Venom\Helper\TemplateUtil;
-use Venom\Routing\Route;
-class TemplateLoader implements Route
+class TemplateLoader
{
public function handle(): bool
{
diff --git a/src/Venom/Controller/SeoController.php b/src/Venom/Controller/SeoController.php
old mode 100644
new mode 100755
index 307279f..c9a8275
--- a/src/Venom/Controller/SeoController.php
+++ b/src/Venom/Controller/SeoController.php
@@ -6,7 +6,7 @@ namespace Venom\Controller;
use Venom\Core\ArgumentHandler;
use Venom\Core\Config;
-use Venom\Core\DatabaseHandler;
+use Venom\Core\Database\DatabaseHandler;
use Venom\Helper\ErrorHandler;
use Venom\Helper\URLHelper;
diff --git a/src/Venom/Core/Config.php b/src/Venom/Core/Config.php
old mode 100644
new mode 100755
index fc48444..3468b8e
--- a/src/Venom/Core/Config.php
+++ b/src/Venom/Core/Config.php
@@ -2,7 +2,8 @@
namespace Venom\Core;
-use Venom\Models\ConfigObject;
+use Venom\Core\Database\DatabaseHandler;
+use Venom\Entities\ConfigObject;
class Config
{
diff --git a/src/Venom/Core/Database/Database.php b/src/Venom/Core/Database/Database.php
new file mode 100755
index 0000000..05ff4c0
--- /dev/null
+++ b/src/Venom/Core/Database/Database.php
@@ -0,0 +1,102 @@
+db != null) {
+ return;
+ }
+ $dsn = '%s:host=%s;dbname=%s;port=%s';
+ $connectString = sprintf($dsn, $data[self::DB_TYPE], $data[self::DB_HOST], $data[self::DB_DB], $data[self::DB_PORT] . $data[self::DB_EXTRA]);
+ try {
+ $this->db = new PDO($connectString, $data[self::DB_USER], $data[self::DB_PASSWORD]);
+ } catch (PDOException $e) {
+ trigger_error($e->getMessage());
+ die($e->getCode());
+ }
+ }
+
+ public function getOne(string|EasyQuery $query, array $args = []): ?DatabaseObject
+ {
+ $sql = $query;
+ if ($query instanceof EasyQuery) {
+ $sql = $query->getQuery();
+ $args = $query->getArgs();
+ }
+ $data = $this->getAll($sql, $args);
+ if (count($data) > 0) {
+ return $data[0];
+ }
+ return null;
+ }
+
+ public function getAll(string|EasyQuery $query, array $args = []): array
+ {
+ $sql = $query;
+ if ($query instanceof EasyQuery) {
+ $sql = $query->getQuery();
+ $args = $query->getArgs();
+ }
+ $stmt = $this->db->prepare($sql);
+ $stmt->setFetchMode(PDO::FETCH_CLASS, DatabaseObject::class);
+ $stmt->execute($args);
+ return $stmt->fetchAll();
+ }
+
+ public function execute(string|EasyQuery $query, array $args = []): bool
+ {
+ $sql = $query;
+ if ($query instanceof EasyQuery) {
+ $sql = $query->getQuery();
+ $args = $query->getArgs();
+ }
+ $stmt = $this->db->prepare($sql);
+ return $stmt->execute($args);
+ }
+
+ public function createStatement($query): bool|PDOStatement
+ {
+ $stmt = $this->db->prepare($query);
+ $stmt->setFetchMode(PDO::FETCH_CLASS, DatabaseObject::class); // set to default fetch-mode :D
+ return $stmt;
+ }
+
+ public function setClass($stmt, $class)
+ {
+ $stmt->setFetchMode(PDO::FETCH_CLASS, $class);
+ }
+
+ public function start()
+ {
+ $this->db->beginTransaction();
+ }
+
+ public function commit()
+ {
+ $this->db->commit();
+ }
+
+ public function rollBack()
+ {
+ $this->db->rollBack();
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/Database/DatabaseHandler.php b/src/Venom/Core/Database/DatabaseHandler.php
new file mode 100755
index 0000000..943f7fe
--- /dev/null
+++ b/src/Venom/Core/Database/DatabaseHandler.php
@@ -0,0 +1,38 @@
+db = new Database();
+ }
+
+ public static function get(): Database
+ {
+ return self::getInstance()->db;
+ }
+
+ public static function getInstance(): DatabaseHandler
+ {
+ if (self::$instance === null) {
+ self::$instance = new DatabaseHandler();
+ }
+ return self::$instance;
+ }
+
+ public static function getEntityManager($entityClass): EntityManager
+ {
+ $instance = self::getInstance();
+ // i dont make sure this class exist because the user should do this ;)
+ if (!isset($instance->cache[$entityClass])) {
+ $instance->cache[$entityClass] = new EntityManager($entityClass, self::get());
+ }
+ return $instance->cache[$entityClass];
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/Database/EasyQuery.php b/src/Venom/Core/Database/EasyQuery.php
new file mode 100755
index 0000000..2e25efc
--- /dev/null
+++ b/src/Venom/Core/Database/EasyQuery.php
@@ -0,0 +1,220 @@
+whereStmt = $statement;
+ return $this;
+ }
+
+ public function setHaving(string $statement): static
+ {
+ $this->havingStmt = $statement;
+ return $this;
+ }
+
+ public function setLimit(int $limit): static
+ {
+ $this->limit = $limit;
+ return $this;
+ }
+
+ public function setOffset(int $offset): static
+ {
+ $this->offset = $offset;
+ return $this;
+ }
+
+ public function addField($field, $as = ""): static
+ {
+ if ($as !== "") {
+ $field .= " AS " . $as;
+ }
+ $this->fields[] = $field;
+ return $this;
+ }
+
+ public function addFields(array $fields): static
+ {
+ foreach ($fields as $field) {
+ $this->fields[] = $field;
+ }
+ return $this;
+ }
+
+ public function where($key, $value, $type = "AND"): static
+ {
+ $this->where[] = [$key, $type];
+ $this->args[":" . $key] = $value;
+ return $this;
+ }
+
+ public function having($key, $value, $type = "AND"): static
+ {
+ $this->having[] = [$key, $type];
+ $this->args[":" . $key] = $value;
+ return $this;
+ }
+
+ public function orderBy(string $key, int $mode = self::ORDER_ASC): static
+ {
+ $this->order[] = $mode === self::ORDER_DESC ? $key . " DESC" : $key;
+ return $this;
+ }
+
+ public function groupBy(string $key): static
+ {
+ $this->groupBy[] = $key;
+ return $this;
+ }
+
+ public function setArg($key, $value): static
+ {
+ $this->args[":" . $key] = $value;
+ return $this;
+ }
+
+ // returns a Query
+
+ public function addArgAndField($key, $value): static
+ {
+ $this->args[":" . $key] = $value;
+ $this->fields[] = $key;
+ return $this;
+ }
+
+ public function buildSelect(): static
+ {
+ // we build an easyQuery Builder that can very easy stuff
+ $query = self::createSelect($this->fields, $this->tableName);
+ if (count($this->where) > 0) {
+ $this->whereStmt = $this->parseStmt($this->where, $this->whereStmt);
+ }
+ if (count($this->having) > 0) {
+ $this->havingStmt = $this->parseStmt($this->having, $this->havingStmt);
+ }
+ if ($this->whereStmt !== "") {
+ $query .= " WHERE " . $this->whereStmt;
+ }
+ if (count($this->groupBy)) {
+ $query .= " GROUP BY " . implode(", ", $this->groupBy);
+ }
+ if ($this->havingStmt !== "") {
+ $query .= " HAVING " . $this->havingStmt;
+ }
+ if (count($this->order)) {
+ $query .= " ORDER BY " . implode(", ", $this->order);
+ }
+ if ($this->offset > 0) {
+ $query .= " OFFSET " . $this->offset;
+ }
+ if ($this->limit > 0) {
+ $query .= " LIMIT " . $this->limit;
+ }
+ $this->query = $query;
+ return $this;
+ }
+
+ public function buildInsertQuery(): static
+ {
+ $query = "INSERT INTO " . $this->tableName;
+ $joinedFields = implode(", ", $this->fields);
+ $values = implode(", ", array_keys($this->args));
+ $query .= "(" . $joinedFields . ") VALUES (" . $values . ")";
+ $this->query = $query;
+ return $this;
+ }
+
+ public function buildUpdateQuery(): static
+ {
+ $query = "UPDATE " . $this->tableName . " SET ";
+ $setFields = [];
+ foreach ($this->fields as $field) {
+ $setFields[] = $field . " = :" . $field;
+ }
+ $query .= implode(", ", $setFields);
+ if (count($this->where) > 0) {
+ $this->whereStmt = $this->parseStmt($this->where, $this->whereStmt);
+ }
+ if ($this->whereStmt !== "") {
+ $query .= " WHERE " . $this->whereStmt;
+ }
+ $this->query = $query;
+ return $this;
+ }
+
+ public function buildDeleteQuery(): static
+ {
+ $query = "DELETE FROM " . $this->tableName;
+ if (count($this->where) > 0) {
+ $this->whereStmt = $this->parseStmt($this->where, $this->whereStmt);
+ }
+ if ($this->whereStmt !== "") {
+ $query .= " WHERE " . $this->whereStmt;
+ }
+ $this->query = $query;
+ return $this;
+ }
+
+ public function getQuery(): string
+ {
+ return $this->query;
+ }
+
+ public function getArgs(): array
+ {
+ return $this->args;
+ }
+
+ public function getFields(): array
+ {
+ return $this->fields;
+ }
+
+ private function parseStmt($items, $default = ""): string
+ {
+ $query = $default;
+ foreach ($items as $item) {
+ if ($query !== "") {
+ $query .= " " . $item[1] . " ";
+ }
+ if ($item[1] === self::WHERE_NOT && $query === "") {
+ $query .= "NOT ";
+ }
+ $query .= $item[0] . " = :" . $item[0];
+ }
+ return $query;
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/Database/Entity.php b/src/Venom/Core/Database/Entity.php
new file mode 100755
index 0000000..30c1bde
--- /dev/null
+++ b/src/Venom/Core/Database/Entity.php
@@ -0,0 +1,127 @@
+fields !== null) {
+ return $this->fields;
+ }
+ $localBlacklist = array_merge(["primaryKey", "tableName", "loadedFields", "blackList", "fields"], $this->blackList);
+ $allLoaded = in_array("*", $this->loadedFields);
+ $vars = get_object_vars($this);
+ foreach ($vars as $key => $var) {
+ if (in_array($key, $localBlacklist)) {
+ unset($vars[$key]);
+ }
+ }
+ if (!$allLoaded) {
+ foreach ($vars as $key => $var) {
+ if (!in_array($var, $this->loadedFields)) {
+ unset($vars[$key]);
+ }
+ }
+ }
+ unset($vars[$this->primaryKey]);
+ $this->fields = $vars;
+ return $this->fields;
+ }
+
+ public function save(): bool
+ {
+ $this->preSave();
+ $primaryKey = $this->primaryKey;
+ $fields = $this->removeEmptyFields($this->getFieldsToWrite());
+ $query = new EasyQuery(static::$tableName);
+ foreach ($fields as $key => $field) {
+ $query->addArgAndField($key, $field);
+ }
+ if ($this->$primaryKey === "") {
+ $query->buildInsertQuery();
+ } else {
+ $query->where($primaryKey, $this->$primaryKey)->buildUpdateQuery();
+ }
+ return DatabaseHandler::get()->execute($query);
+ }
+
+ public function load($fields = ['*'], ?EasyQuery $query = null): static
+ {
+ if ($query === null) {
+ $primaryKey = $this->primaryKey;
+ $query = new EasyQuery(static::$tableName, $fields);
+ $query->where($primaryKey, $this->$primaryKey)->setLimit(1)->buildSelect();
+
+ } else {
+ $query->setLimit(1)->buildSelect();
+ }
+
+ $item = DatabaseHandler::get()->getOne($query);
+ if ($item === null) {
+ return $this;
+ }
+ $lazy = $item->getData();
+ $this->id = $item->id;
+ foreach ($lazy as $key => $item) {
+ $this->$key = $item;
+ }
+ $this->fields = null;
+ $this->loadedFields = array_merge($this->loadedFields, $query->getFields());
+ $this->postLoad();
+ return $this;
+ }
+
+ public function __set($name, $value)
+ {
+ // Implement your own if you want to override this behaviour!
+ throw new RuntimeException("Write to Property: $name that is not Available in the Entity!");
+ }
+
+ public function delete()
+ {
+ $key = $this->primaryKey;
+ $query = new EasyQuery(self::$tableName);
+ $query->setArg($this->primaryKey, $this->$key)->buildDeleteQuery();
+ DatabaseHandler::get()->execute($query->getQuery(), $query->getArgs());
+ }
+
+ public function jsonSerialize(): array
+ {
+ return $this->getFieldsToWrite();
+ }
+
+ public function preSave()
+ {
+ }
+
+ public function postLoad()
+ {
+ }
+
+ private function removeEmptyFields(array $vars): array
+ {
+ foreach ($vars as $name => $item) {
+ if (empty($item) && $name != $this->primaryKey) {
+ unset($vars[$name]);
+ }
+ }
+ return $vars;
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/Database/EntityManager.php b/src/Venom/Core/Database/EntityManager.php
new file mode 100755
index 0000000..24d6d4f
--- /dev/null
+++ b/src/Venom/Core/Database/EntityManager.php
@@ -0,0 +1,127 @@
+classType;
+ $this->entities[] = $ent;
+ return $ent;
+ }
+
+ public function addEntity(Entity $entity)
+ {
+ $this->entities[] = $entity;
+ }
+
+ public function removeEntity(Entity $entity)
+ {
+ foreach ($this->entities as $key => $item) {
+ if ($entity === $item) {
+ unset($this->entities[$key]);
+ break;
+ }
+ }
+ }
+
+ public function findBy($key, $value): ?Entity
+ {
+ foreach ($this->entities as $entity) {
+ if ($entity->$key === $value) {
+ return $entity;
+ }
+ }
+ return null;
+ }
+
+ public function saveAll()
+ {
+ if (count($this->entities) === 0) {
+ return;
+ }
+ try {
+ $this->db->start();
+ foreach ($this->entities as $entity) {
+ $entity->save();
+ }
+ $this->db->commit();
+ } catch (Exception $ex) {
+ trigger_error($ex->getMessage());
+ $this->db->rollBack();
+ }
+ }
+
+ public function deleteEntities()
+ {
+ try {
+ $this->db->start();
+ foreach ($this->entities as $entity) {
+ $entity->delete();
+ }
+ $this->db->commit();
+ } catch (Exception $ex) {
+ trigger_error($ex->getMessage());
+ $this->db->rollBack();
+ }
+ }
+
+ public function clearAll()
+ {
+ $this->entities = [];
+ }
+
+ public function load(string|EasyQuery $query, $args = [], array $fields = ["*"])
+ {
+ $sql = $query;
+ if ($query instanceof EasyQuery) {
+ $query->buildSelect();
+ $sql = $query->getQuery();
+ $args = $query->getArgs();
+ $fields = $query->getFields();
+ }
+ $stmt = $this->db->createStatement($sql);
+ $this->db->setClass($stmt, $this->classType);
+ if ($stmt->execute($args)) {
+ /** @var Entity[] $all */
+ $all = $stmt->fetchAll();
+ foreach ($all as $item) {
+ $item->loadedFields = $fields;
+ $item->postLoad();
+ $this->addEntity($item);
+ }
+ }
+ }
+
+ public function execute($query): bool
+ {
+ return $this->db->execute($query);
+ }
+
+ public function getAll(): array
+ {
+ return $this->entities;
+ }
+
+ private function addEntities(array $entities)
+ {
+ foreach ($entities as $entity) {
+ $this->entities[] = $entity;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/DatabaseHandler.php b/src/Venom/Core/DatabaseHandler.php
deleted file mode 100755
index cf16f58..0000000
--- a/src/Venom/Core/DatabaseHandler.php
+++ /dev/null
@@ -1,92 +0,0 @@
-db != null) {
- return;
- }
- $dsn = '%s:host=%s;dbname=%s;port=%s';
- $connectString = sprintf($dsn, $data[self::DB_TYPE], $data[self::DB_HOST], $data[self::DB_DB], $data[self::DB_PORT] . $data[self::DB_EXTRA]);
- try {
- $this->db = new PDO($connectString, $data[self::DB_USER], $data[self::DB_PASSWORD]);
- } catch (PDOException $e) {
- trigger_error($e->getMessage());
- die($e->getCode());
- }
- }
-
- public function getOne(string $query, array $args = []): ?DatabaseObject
- {
- $data = $this->getAll($query, $args);
- if (count($data) > 0) {
- return $data[0];
- }
- return null;
- }
-
- public function getAll(string $query, array $args = []): array
- {
- $stmt = $this->db->prepare($query);
- $stmt->setFetchMode(PDO::FETCH_CLASS, DatabaseObject::class);
- $stmt->execute($args);
- return $stmt->fetchAll();
- }
-
- public function execute(string $query, array $args = []): bool
- {
- $stmt = $this->db->prepare($query);
- return $stmt->execute($args);
- }
-
- // Returns a Select like this: SELECT id, name, ... FROM table || do what you want
- public static function createEasySelect(array $fields, string $table): string
- {
- return "SELECT " . implode(",", $fields) . " FROM " . $table;
- }
-
- public static function getUpdateString(array $data, string $table, string $where): array
- {
- $string = [];
- $save = [];
- foreach ($data as $key => $value) {
- $k = ":" . strtolower($key);
- $string[] = $key . "= " . $k;
- $save[$k] = $value;
- }
- return ["UPDATE " . $table . " SET " . implode(",", $string) . " " . $where, $save];
- }
-}
\ No newline at end of file
diff --git a/src/Venom/Core/Language.php b/src/Venom/Core/Language.php
old mode 100644
new mode 100755
index edcb0ba..3ab30e2
--- a/src/Venom/Core/Language.php
+++ b/src/Venom/Core/Language.php
@@ -5,7 +5,8 @@ namespace Venom\Core;
use RuntimeException;
-use Venom\Models\DatabaseObject;
+use Venom\Core\Database\DatabaseHandler;
+use Venom\Entities\DatabaseObject;
class Language
{
@@ -20,7 +21,7 @@ class Language
public function initLang()
{
- $lang = ArgumentHandler::get()->getItem("lang", $this->defaultLang->shortTag);
+ $lang = ArgumentHandler::get()->getItem("lang", $this->defaultLang->shortTag ?? 'de');
//check if language exists
$data = DatabaseHandler::get()->getOne("select id from language where shortTag = :shortTag", [
':shortTag' => $lang
diff --git a/src/Venom/Core/Module.php b/src/Venom/Core/Module.php
old mode 100644
new mode 100755
index 821bd0a..f050e89
--- a/src/Venom/Core/Module.php
+++ b/src/Venom/Core/Module.php
@@ -3,18 +3,17 @@
namespace Venom\Core;
-
-use Venom\Venom;
-
interface Module
{
const NAME = "name";
const AUTHOR = "author";
const SECURE = "secure";
const ROUTE = "routes";
+ const ADMIN_ROUTE = "adminRoutes";
const DESC = "description";
-
- public function register(Venom $venom): bool;
-
- public function init(): void;
+ const TEMPLATES = "templates";
+ const ADMIN_TEMPLATES = "adminTemplates";
+ const CONTROLLER = "controllers";
+ const TEMPLATE_PATH = "tplPath";
+ const ACTIVE = "isActive";
}
\ No newline at end of file
diff --git a/src/Venom/Core/ModuleLoader.php b/src/Venom/Core/ModuleLoader.php
new file mode 100755
index 0000000..bf2fbc2
--- /dev/null
+++ b/src/Venom/Core/ModuleLoader.php
@@ -0,0 +1,72 @@
+isAdmin();
+ if ($isAdmin) {
+ self::registerRoutes($module,
+ $venom,
+ $module[Module::ADMIN_ROUTE],
+ $venom->getRouter(Router::ADMIN_ROUTER)
+ );
+ TemplateUtil::getInstance()->addTemplates($module[Module::ADMIN_TEMPLATES], $module[Module::TEMPLATE_PATH]);
+ } else {
+ self::registerRoutes($module,
+ $venom,
+ $module[Module::ROUTE],
+ $venom->getRouter(Router::DEFAULT_ROUTER)
+ );
+ TemplateUtil::getInstance()->addTemplates($module[Module::TEMPLATES], $module[Module::TEMPLATE_PATH]);
+ }
+ $venom->addControllers($module[Module::CONTROLLER]);
+ return true;
+ }
+
+ public static function registerRoutes(array $module, Venom $venom, array $routes, Router $router)
+ {
+ foreach ($routes as $key => $route) {
+ /** @var Route $route */
+ $route->module = $module[Module::NAME];
+ $route->isSecure = $module[Module::SECURE];
+ $route->venom = $venom;
+ $router->addRoute($key, $route);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Core/Registry.php b/src/Venom/Core/Registry.php
old mode 100644
new mode 100755
diff --git a/src/Venom/Core/Setup.php b/src/Venom/Core/Setup.php
old mode 100644
new mode 100755
index c35d1a1..20fde4a
--- a/src/Venom/Core/Setup.php
+++ b/src/Venom/Core/Setup.php
@@ -39,9 +39,6 @@ class Setup
if (isset($modules)) {
$venom->initModules($modules);
}
- if (isset($controllers)) {
- $venom->initControllers($controllers);
- }
}
public static function loadRouters(Venom $venom): void
diff --git a/src/Venom/Models/ConfigObject.php b/src/Venom/Entities/ConfigObject.php
old mode 100644
new mode 100755
similarity index 85%
rename from src/Venom/Models/ConfigObject.php
rename to src/Venom/Entities/ConfigObject.php
index 931ce4e..24388c3
--- a/src/Venom/Models/ConfigObject.php
+++ b/src/Venom/Entities/ConfigObject.php
@@ -1,10 +1,12 @@
id, $obj->value
* also the option to print it in csv format ; as delimiter
* @package Venom\Database
*/
-class DatabaseObject implements JsonSerializable
+class DatabaseObject extends Entity
{
private array $data = [];
@@ -48,9 +47,4 @@ class DatabaseObject implements JsonSerializable
{
return $this->data;
}
-
- public function jsonSerialize(): array
- {
- return $this->data;
- }
}
\ No newline at end of file
diff --git a/src/Venom/Entities/RoleEntity.php b/src/Venom/Entities/RoleEntity.php
new file mode 100755
index 0000000..670e8a3
--- /dev/null
+++ b/src/Venom/Entities/RoleEntity.php
@@ -0,0 +1,59 @@
+id === -1) {
+ return true;
+ }
+ if ($type === self::TYPE_NO) {
+ return true;
+ }
+ if (!isset($this->roles[$module]) && $type) {
+ return false;
+ }
+ $mod = $this->roles[$module];
+ return $mod["type"] === $type;
+ }
+
+
+ public function postLoad()
+ {
+ if (!empty($this->content)) {
+ $this->roles = json_decode($this->content);
+ }
+ }
+
+ public function preSave()
+ {
+ $this->content = json_encode($this->roles);
+ }
+
+ public function load($fields = ['*'], ?EasyQuery $query = null): static
+ {
+ if ($this->id === -1 || $this->id === 0) {
+ return $this;
+ }
+ return parent::load($fields, $query);
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/Venom/Entities/User.php b/src/Venom/Entities/User.php
new file mode 100755
index 0000000..283c376
--- /dev/null
+++ b/src/Venom/Entities/User.php
@@ -0,0 +1,57 @@
+roleEntity === null) {
+ $this->roleEntity = new RoleEntity();
+ $this->roleEntity->id = $this->roleId;
+ $this->roleEntity->load();
+ }
+ return $this->roleEntity->hasPermission($module, $type);
+ }
+
+ public function postLoad()
+ {
+ $this->loaded = true;
+ }
+
+
+ public function isLoaded(): bool
+ {
+ return $this->loaded;
+ }
+
+ public function loadUser()
+ {
+ $eq = new EasyQuery(User::$tableName, ["*"]);
+ $eq->where("username", $this->username)
+ ->where("id", $this->id, EasyQuery::WHERE_OR);
+ $this->load([], $eq);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/Venom/Exceptions/ExceptionHandler.php b/src/Venom/Exceptions/ExceptionHandler.php
old mode 100644
new mode 100755
diff --git a/src/Venom/Helper/AdminHelper.php b/src/Venom/Helper/AdminHelper.php
old mode 100644
new mode 100755
diff --git a/src/Venom/Helper/ErrorHandler.php b/src/Venom/Helper/ErrorHandler.php
index a1b265f..c3d9e68 100755
--- a/src/Venom/Helper/ErrorHandler.php
+++ b/src/Venom/Helper/ErrorHandler.php
@@ -4,7 +4,6 @@
namespace Venom\Helper;
-use http\Exception\RuntimeException;
use Venom\Core\ArgumentHandler;
class ErrorHandler
diff --git a/src/Venom/Helper/MetaGenerator.php b/src/Venom/Helper/MetaGenerator.php
old mode 100644
new mode 100755
index 81020fb..55a4a49
--- a/src/Venom/Helper/MetaGenerator.php
+++ b/src/Venom/Helper/MetaGenerator.php
@@ -36,8 +36,8 @@ class MetaGenerator
public function render(): void
{
- foreach($this->container as $key => $value) {
- echo '';
+ foreach ($this->container as $key => $value) {
+ echo '';
}
}
}
\ No newline at end of file
diff --git a/src/Venom/Helper/TemplateUtil.php b/src/Venom/Helper/TemplateUtil.php
old mode 100644
new mode 100755
index 9bfcb07..283e9a5
--- a/src/Venom/Helper/TemplateUtil.php
+++ b/src/Venom/Helper/TemplateUtil.php
@@ -11,6 +11,7 @@ class TemplateUtil
private static ?TemplateUtil $instance = null;
private string $baseTemplate;
private string $templateDir;
+ private array $templates = [];
private function __construct()
{
@@ -44,15 +45,31 @@ class TemplateUtil
return $this->baseTemplate;
}
- public static function includeTemplate($template, $suffix = '.php')
+ public function addTemplates($templates, string $basePath)
{
- $dir = self::getInstance()->getDir();
- $template .= $suffix;
- if (file_exists($dir . $template)) {
+ foreach ($templates as $key => $template) {
+ $this->templates[$key] = $basePath . $template;
+ }
+ }
+
+ public static function includeTemplate($template, $suffix = '.php'): bool|string
+ {
+ $tx = self::getInstance()->getCache($template);
+ if ($tx === "") {
+ $dir = self::getInstance()->getDir();
+ $tx = $dir . $template;
+ }
+ $tx .= $suffix;
+ if (file_exists($tx)) {
ob_start();
- include_once $dir . $template;
+ include_once $tx;
return ob_get_clean();
}
return '';
}
+
+ private function getCache($template)
+ {
+ return $this->templates[$template] ?? '';
+ }
}
\ No newline at end of file
diff --git a/src/Venom/Helper/URLHelper.php b/src/Venom/Helper/URLHelper.php
old mode 100644
new mode 100755
diff --git a/src/Venom/Models/User.php b/src/Venom/Models/User.php
deleted file mode 100644
index 310692d..0000000
--- a/src/Venom/Models/User.php
+++ /dev/null
@@ -1,129 +0,0 @@
-roles, true);
- }
-
- public function loadUser(): bool
- {
- if (isset($_SESSION['userID']) || $this->username !== 'GUEST') {
- // try to load user from id!
- $user = DatabaseHandler::get()->getOne("SELECT * FROM users WHERE id = :id OR username = :name AND isActive = 1", [
- ':id' => $_SESSION['userID'] ?? -1,
- ':name' => $this->username
- ]);
- if ($user !== null) {
- $this->username = $user->username ?? '';
- $this->email = $user->email ?? '';
- $this->password = $user->password ?? '';
- $this->token = $user->token ?? '';
- $this->salt = $user->salt ?? '';
- $this->id = $user->id ?? '-1';
- $this->roles = explode(',', $user->roles ?? '');
- $this->isLoaded = true;
- return true;
- }
- }
- return false;
- }
-
- public function getUsername(): string
- {
- return $this->username;
- }
-
- public function setUsername(string $username): void
- {
- $this->username = $username;
- }
-
- public function getEmail(): string
- {
- return $this->email;
- }
-
- public function setEmail(string $email): void
- {
- $this->email = $email;
- }
-
- public function getPassword(): string
- {
- return $this->password;
- }
-
- public function setPassword(string $password): void
- {
- $this->password = $password;
- }
-
- public function getSalt(): string
- {
- return $this->salt;
- }
-
- public function setSalt(string $salt): void
- {
- $this->salt = $salt;
- }
-
- public function getToken(): string
- {
- return $this->token;
- }
-
- public function setToken(string $token): void
- {
- $this->token = $token;
- }
-
- public function getRoles(): array
- {
- return $this->roles;
- }
-
- public function setRoles(array $roles): void
- {
- $this->roles = $roles;
- }
-
- public function addRole($value): void
- {
- if (!in_array($value, $this->roles, true)) {
- $this->roles[] = $value;
- }
- }
-
- public function isLoaded(): bool
- {
- return $this->isLoaded;
- }
-
- public function getId(): string
- {
- return $this->id;
- }
-
-}
\ No newline at end of file
diff --git a/src/Venom/Routing/Route.php b/src/Venom/Routing/Route.php
old mode 100644
new mode 100755
index 044551c..9ea357d
--- a/src/Venom/Routing/Route.php
+++ b/src/Venom/Routing/Route.php
@@ -4,7 +4,47 @@
namespace Venom\Routing;
-interface Route
-{
+use RuntimeException;
+use Venom\Entities\RoleEntity;
+use Venom\Security\Security;
+use Venom\Venom;
+class Route
+{
+ const GET = "GET";
+ const POST = "POST";
+ const PUT = "PUT";
+ const DELETE = "DELETE";
+
+ public string $url;
+ public array $routes = [];
+ public int $maxParameters = 0;
+ public string $module = "unknown";
+ public bool $isSecure = false;
+ public Venom $venom;
+
+ public function __construct(public string $controller, array $config)
+ {
+ $count = count($config);
+ if ($count === 0) {
+ throw new RuntimeException("Route: \"$controller\" no valid Routes Found!");
+ }
+ $count -= isset($config["*"]) ? 1 : 0;
+ $this->maxParameters = $count;
+ $this->routes = $config;
+ }
+
+ public function getDefinitions($method, mixed $subRoute): ?array
+ {
+ if ($this->isSecure && !Security::get()->hasPermission($this->module, $method === Route::GET ? RoleEntity::TYPE_READ : RoleEntity::TYPE_WRITE)) {
+ return null;
+ }
+ if (isset($this->routes[$subRoute]) && isset($this->routes[$subRoute][$method])) {
+ return [
+ "cl" => $this->controller,
+ "fnc" => $this->routes[$subRoute][$method]
+ ];
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/Venom/Routing/Router.php b/src/Venom/Routing/Router.php
old mode 100644
new mode 100755
index 698949f..e5ca533
--- a/src/Venom/Routing/Router.php
+++ b/src/Venom/Routing/Router.php
@@ -5,10 +5,7 @@ namespace Venom\Routing;
use Exception;
-use Venom\Core\Config;
use Venom\Exceptions\ExceptionHandler;
-use Venom\Models\User;
-use Venom\Security\Security;
class Router
{
@@ -31,7 +28,7 @@ class Router
$this->routes = array_merge($this->routes, $routes);
}
- public function addRoute(string $path, array $route): void
+ public function addRoute(string $path, Route $route): void
{
$this->routes[$path] = $route;
}
@@ -58,9 +55,9 @@ class Router
return null;
}
- private function removeIfFirst($rawString, $string)
+ private function removeIfFirst($rawString, $string): bool|string
{
- if ($string !== '' && 0 === strpos($rawString, $string)) {
+ if ($string !== '' && str_starts_with($rawString, $string)) {
return substr($rawString, strlen($string));
}
return $rawString;
@@ -68,24 +65,15 @@ class Router
private function getRouteByName($url, $method, $subRoute = '*', $params = []): ?array
{
- if (isset($this->routes[$url])
- && isset($this->routes[$url]['routes'])
- && isset($this->routes[$url]['routes'][$subRoute])
- && isset($this->routes[$url]['routes'][$subRoute][$method])
- ) {
- if ((Config::getInstance()->getSecurity()->useSecurity || $this->id === self::ADMIN_ROUTER)
- && isset($this->routes[$url]['roles'])
- ) {
- $roles = $this->routes[$url]['roles'];
- if (!in_array(User::GUEST_ROLE, $roles, true) && !Security::get()->hasRoles($roles)) {
- return null;
- }
+ if (isset($this->routes[$url])) {
+ /** @var Route $route */
+ $route = $this->routes[$url];
+ $sub = $route->getDefinitions($method, $subRoute);
+ if ($sub === null) {
+ return null;
}
- return [
- 'cl' => $this->routes[$url]['cl'],
- 'fnc' => $this->routes[$url]['routes'][$subRoute][$method],
- 'params' => $params
- ];
+ $sub["params"] = array_reverse($params);
+ return $sub;
}
return null;
}
@@ -128,9 +116,14 @@ class Router
}
}
- private function removeTrailingSlash(string $rawString)
+ private function removeTrailingSlash(string $rawString): bool|string
{
$len = strlen($rawString);
return $rawString[$len - 1] === '/' ? substr($rawString, 0, strlen($rawString) - 1) : $rawString;
}
+
+ public function getId(): string
+ {
+ return $this->id;
+ }
}
\ No newline at end of file
diff --git a/src/Venom/Security/BaseLogin.php b/src/Venom/Security/BaseLogin.php
old mode 100644
new mode 100755
index 5343391..820bb24
--- a/src/Venom/Security/BaseLogin.php
+++ b/src/Venom/Security/BaseLogin.php
@@ -6,8 +6,8 @@ namespace Venom\Security;
use Venom\Core\ArgumentHandler;
use Venom\Core\Config;
+use Venom\Entities\User;
use Venom\Helper\URLHelper;
-use Venom\Models\User;
/**
* Class that Login stupid via Password, Username
@@ -31,7 +31,7 @@ class BaseLogin implements Login
public function redirect(): void
{
$url = ArgumentHandler::get()->getPostItem('REDIRECT_TO', URLHelper::getInstance()->getUrl());
- if($url === 'NO') {
+ if ($url === 'NO') {
echo json_encode(['message' => 'login'], JSON_THROW_ON_ERROR);
} else {
header('Location: ' . $url);
@@ -42,14 +42,14 @@ class BaseLogin implements Login
public function login(): bool
{
$sec = Config::getInstance()->getSecurity();
- $this->user->setUsername(ArgumentHandler::get()->getPostItem('USERNAME'));
+ $this->user->username = (string)ArgumentHandler::get()->getPostItem('USERNAME');
if (!$this->user->loadUser()) {
return false;
}
$secret = $sec->secret ?? 'venom';
- $hashed = hash($sec->algo ?? 'SHA256', ArgumentHandler::get()->getPostItem('PASSWORD') . $secret . $this->user->getSalt());
- if ($this->user->getPassword() === $hashed) {
- $_SESSION['userID'] = $this->user->getId();
+ $hashed = hash($sec->algo ?? 'SHA256', ArgumentHandler::get()->getPostItem('PASSWORD') . $secret . $this->user->salt);
+ if ($this->user->password === $hashed) {
+ $_SESSION['userID'] = $this->user->id;
return true;
}
return false;
diff --git a/src/Venom/Security/Login.php b/src/Venom/Security/Login.php
old mode 100644
new mode 100755
index 51fbd3e..31a655e
--- a/src/Venom/Security/Login.php
+++ b/src/Venom/Security/Login.php
@@ -4,7 +4,7 @@
namespace Venom\Security;
-use Venom\Models\User;
+use Venom\Entities\User;
interface Login
{
diff --git a/src/Venom/Security/Security.php b/src/Venom/Security/Security.php
old mode 100644
new mode 100755
index dcdacab..c5db118
--- a/src/Venom/Security/Security.php
+++ b/src/Venom/Security/Security.php
@@ -3,9 +3,10 @@
namespace Venom\Security;
-use \RuntimeException;
+use RuntimeException;
use Venom\Core\Config;
-use Venom\Models\User;
+use Venom\Entities\RoleEntity;
+use Venom\Entities\User;
class Security
{
@@ -15,7 +16,8 @@ class Security
public function __construct()
{
$this->user = new User();
- $this->user->loadUser();
+ $this->user->id = $_SESSION['userID'] ?? "-1";
+ $this->user->load();
}
public static function get(): Security
@@ -26,19 +28,9 @@ class Security
return self::$instance;
}
- public function hasRole(string $role): bool
+ public function hasPermission(string $module, $type = RoleEntity::TYPE_WRITE): bool
{
- return $this->user->hasRole($role);
- }
-
- public function hasRoles(array $roles): bool
- {
- foreach ($roles as $role) {
- if (!$this->user->hasRole($role)) {
- return false;
- }
- }
- return true;
+ return $this->user->hasPermission($module, $type);
}
public function login(): void
diff --git a/src/Venom/Venom.php b/src/Venom/Venom.php
index cda1587..9cb218e 100755
--- a/src/Venom/Venom.php
+++ b/src/Venom/Venom.php
@@ -5,11 +5,11 @@ namespace Venom;
use Venom\Admin\AdminController;
-use Venom\Admin\AdminModulesLoader;
use Venom\Admin\AdminRouterInit;
use Venom\Core\ArgumentHandler;
use Venom\Core\Config;
use Venom\Core\Module;
+use Venom\Core\ModuleLoader;
use Venom\Core\Registry;
use Venom\Exceptions\ExceptionHandler;
use Venom\Helper\ErrorHandler;
@@ -117,28 +117,32 @@ class Venom
public function initModules(array $modules): void
{
if (Config::getInstance()->isAdmin()) {
- $modules = array_merge(AdminModulesLoader::getModules(), $modules);
+ $modules = array_merge(ModuleLoader::getModules(), $modules);
}
- foreach ($modules as $key => $moduleClass) {
- $module = new $moduleClass;
- if ($module instanceof Module && $module->register($this)) {
- $this->modules[$key] = $module;
- }
+ foreach ($modules as $module) {
+ ModuleLoader::loadModule($module, $this);
}
}
- public function initControllers(array $controllers): void
+ public function addControllers(array $controllers): void
{
- $this->controllers = $controllers;
+ $this->controllers = array_merge($this->controllers, $controllers);
}
- public function addRouter(string $name, Router $router): void
+ public function addRouter(Router $router): void
{
- $this->routers[$name] = $router;
+ $this->routers[$router->getId()] = $router;
}
public function getRouter(string $router): ?Router
{
return $this->routers[$router];
}
+
+ public function registerModule(array $module)
+ {
+ if (ModuleLoader::initModule($module, $this)) {
+ $this->modules[$module[Module::NAME]] = $module;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/Venom/Views/DataLoader.php b/src/Venom/Views/DataLoader.php
index aa49d9f..4d9bea6 100755
--- a/src/Venom/Views/DataLoader.php
+++ b/src/Venom/Views/DataLoader.php
@@ -3,9 +3,9 @@
namespace Venom\Views;
-use \RuntimeException;
+use RuntimeException;
use Venom\Core\DatabaseHandler;
-use Venom\Models\DataModel;
+use Venom\Entities\DataEntity;
class DataLoader
{
@@ -23,7 +23,7 @@ class DataLoader
return self::$instance;
}
- public static function loadById(string $id): ?DataModel
+ public static function loadById(string $id): ?DataEntity
{
if ($id === '') {
throw new RuntimeException('Try to Load empty ID from Database');
@@ -33,14 +33,14 @@ class DataLoader
]);
if ($data !== null) {
- $model = new DataModel($data->identity, $data->datatype, $data->raw, $data->generated);
+ $model = new DataEntity($data->identity, $data->datatype, $data->raw, $data->generated);
$model->setActive(true);
return $model;
}
return null;
}
- public function updateData(DataModel $model): bool
+ public function updateData(DataEntity $model): bool
{
if ($model->getId() === '') {
return $this->insertData($model);
@@ -57,7 +57,7 @@ class DataLoader
);
}
- public function insertData(DataModel $model): bool
+ public function insertData(DataEntity $model): bool
{
$this->validateModel($model);
@@ -73,7 +73,7 @@ class DataLoader
);
}
- private function validateModel(DataModel $model): void
+ private function validateModel(DataEntity $model): void
{
if ($model->getId() === '') {
$model->setId($this->generateID());
diff --git a/src/Venom/Views/RenderController.php b/src/Venom/Views/RenderController.php
old mode 100644
new mode 100755
diff --git a/src/Venom/Views/VenomRenderer.php b/src/Venom/Views/VenomRenderer.php
index 97cedc5..505c246 100755
--- a/src/Venom/Views/VenomRenderer.php
+++ b/src/Venom/Views/VenomRenderer.php
@@ -16,7 +16,7 @@ class VenomRenderer
private ?RenderController $controller;
private ?MetaGenerator $metaGenerator;
private string $templateData = '';
- private array $vars = [];
+ private array $vars = [];
private string $baseTemplate = '';
private string $templateDir = '';
diff --git a/src/modules/.gitkeep b/src/modules/.gitkeep
old mode 100644
new mode 100755
diff --git a/src/modules/Data/Controller/DataController.php b/src/modules/Data/Controller/DataController.php
new file mode 100644
index 0000000..4e57780
--- /dev/null
+++ b/src/modules/Data/Controller/DataController.php
@@ -0,0 +1,13 @@
+registerModule([
+ Module::ACTIVE => true,
+ Module::NAME => 'DataModule',
+ Module::DESC => 'Data Module for Content every',
+ Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
+ Module::SECURE => true,
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/data' => new Route(DataController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ]
+ ])
+ ],
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
+
+ ],
+ Module::ADMIN_TEMPLATES => [
+
+ ],
+ Module::CONTROLLER => [
+
+ ]
+]);
\ No newline at end of file
diff --git a/src/modules/Meta/Controller/MetaAPIController.php b/src/modules/Meta/Controller/MetaAPIController.php
old mode 100644
new mode 100755
index f5b277a..9491a7d
--- a/src/modules/Meta/Controller/MetaAPIController.php
+++ b/src/modules/Meta/Controller/MetaAPIController.php
@@ -16,7 +16,7 @@ class MetaAPIController
public function getById($id)
{
- AdminHelper::sendResponse(MetaController::getById($id));
+ AdminHelper::sendResponse(SeoUrlController::getById($id));
}
public function update($id)
diff --git a/src/modules/Meta/Controller/MetaController.php b/src/modules/Meta/Controller/MetaController.php
old mode 100644
new mode 100755
diff --git a/src/modules/Meta/MetaDataModule.php b/src/modules/Meta/MetaDataModule.php
deleted file mode 100644
index a76ea81..0000000
--- a/src/modules/Meta/MetaDataModule.php
+++ /dev/null
@@ -1,79 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/metaData' => [
- 'cl' => MetaAPIController::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'update',
- "PUT" => 'insert',
- "DELETE" => 'delete'
- ]
- ]
- ]
- ]);
- }
-
- public function get()
- {
- AdminHelper::sendResponse([
- 'metaData' => [
- ['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
- ['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
- ]
- ]);
- }
-
- public function update(): bool
- {
- return false;
- }
-
- public function insert(): bool
- {
- return false;
- }
-
- public function getById($id)
- {
- AdminHelper::sendResponse([
- 'caseName' => 'ROLE_ADMIN',
- 'id' => $id,
- 'name' => 'Admin',
- 'icon' => 'vt-visibility',
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/modules/Meta/module.php b/src/modules/Meta/module.php
old mode 100644
new mode 100755
index bb7230c..85730b6
--- a/src/modules/Meta/module.php
+++ b/src/modules/Meta/module.php
@@ -1,22 +1,41 @@
registerModule([
+ Module::ACTIVE => true,
Module::NAME => 'MetaModule',
Module::DESC => 'Meta Data Module for SEO',
Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
Module::SECURE => true,
- MODULE::ROUTE => [
- '/'
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/metaData' => new Route(MetaAPIController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ],
+ "1" => [
+ Route::GET => 'getById',
+ Route::POST => 'update',
+ Route::PUT => 'insert',
+ Route::DELETE => 'delete'
+ ]
+ ])
],
- MODULE::TEMPLATES => [
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
// Include Templates with shorter names! $render->include("meta_roles")
- 'meta_roles' => 'PATH_TO_TEMPLATE'
+ //'meta_roles' => 'PATH_TO_TEMPLATE_FROM_TEMPLATE_PATH'
],
- MODULE::ADMIN_TEMPLATES => [
+ Module::ADMIN_TEMPLATES => [
//
+ ],
+ Module::CONTROLLER => [
+
]
-];
-$venom = $venom ?? die();
-$venom->registerModule($module);*/
\ No newline at end of file
+]);
\ No newline at end of file
diff --git a/src/modules/PageModule.php b/src/modules/PageModule.php
deleted file mode 100644
index f677fa5..0000000
--- a/src/modules/PageModule.php
+++ /dev/null
@@ -1,85 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/pages' => [
- 'cl' => PageModule::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'update',
- "PUT" => 'insert',
- ]
- ]
- ]
- ]);
- }
-
- public function get()
- {
- AdminHelper::sendResponse([
- 'pages' => [
- ['id' => 1, 'name' => 'Flamingos going wild!', 'icon' => 'vt-edit'],
- ['id' => 2, 'name' => 'Turbinen sind geil.', 'icon' => 'vt-edit'],
- ['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
- ['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
- ['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
- ],
- ]);
- }
-
- public function update(): bool
- {
- return false;
- }
-
- public function insert(): bool
- {
- return false;
- }
-
- public function getById($id)
- {
- AdminHelper::sendResponse([
- 'caseName' => 'ROLE_ADMIN',
- 'id' => $id,
- 'name' => 'Admin',
- 'icon' => 'vt-visibility',
- 'users' => [
- ['value' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
- ['value' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
- ]
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/modules/Role/Controller/RoleController.php b/src/modules/Role/Controller/RoleController.php
new file mode 100644
index 0000000..0890f38
--- /dev/null
+++ b/src/modules/Role/Controller/RoleController.php
@@ -0,0 +1,21 @@
+ [
+ ['id' => 1, 'name' => 'Admin', 'icon' => 'vt-visibility'],
+ ['id' => 2, 'name' => 'Moderator', 'icon' => 'vt-edit'],
+ ['id' => 3, 'name' => 'Gast', 'icon' => 'vt-edit'],
+ ]
+ ]);
+ }
+}
\ No newline at end of file
diff --git a/src/modules/Role/module.php b/src/modules/Role/module.php
new file mode 100755
index 0000000..115fc8c
--- /dev/null
+++ b/src/modules/Role/module.php
@@ -0,0 +1,34 @@
+registerModule([
+ Module::ACTIVE => true,
+ Module::NAME => 'RoleModule',
+ Module::DESC => 'Role Management',
+ Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
+ Module::SECURE => true,
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/roles' => new Route(RoleController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ]
+ ])
+ ],
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
+
+ ],
+ Module::ADMIN_TEMPLATES => [
+
+ ],
+ Module::CONTROLLER => [
+
+ ]
+]);
\ No newline at end of file
diff --git a/src/modules/RoleModule.php b/src/modules/RoleModule.php
deleted file mode 100644
index ffcd389..0000000
--- a/src/modules/RoleModule.php
+++ /dev/null
@@ -1,81 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/roles' => [
- 'cl' => RoleModule::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'update',
- "PUT" => 'insert',
- ]
- ]
- ]
- ]);
- }
-
- public function get()
- {
- //$req = DatabaseHandler::get()->getAll("SELECT * FROM roles");
- AdminHelper::sendResponse([
- 'roles' => [
- ['id' => 1, 'name' => 'Admin', 'icon' => 'vt-visibility'],
- ['id' => 2, 'name' => 'Moderator', 'icon' => 'vt-edit'],
- ['id' => 3, 'name' => 'Gast', 'icon' => 'vt-edit'],
- ]
- ]);
- }
-
- public function update(): bool
- {
- return false;
- }
-
- public function insert(): bool
- {
- return false;
- }
-
- public function getById($id)
- {
- AdminHelper::sendResponse([
- 'caseName' => 'ROLE_ADMIN',
- 'id' => $id,
- 'name' => 'Admin',
- 'icon' => 'vt-visibility'
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/modules/SEO/Controller/SeoUrlController.php b/src/modules/SEO/Controller/SeoUrlController.php
new file mode 100755
index 0000000..eb1c6d8
--- /dev/null
+++ b/src/modules/SEO/Controller/SeoUrlController.php
@@ -0,0 +1,18 @@
+registerModule([
+ Module::ACTIVE => true,
+ Module::NAME => 'SeoModule',
+ Module::DESC => 'SEO Management for beautiful URLs',
+ Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
+ Module::SECURE => true,
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/seoUrl' => new Route(SeoUrlController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ],
+ "1" => [
+ Route::GET => 'getById',
+ Route::POST => 'update',
+ Route::PUT => 'insert',
+ Route::DELETE => 'delete'
+ ]
+ ])
+ ],
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
+
+ ],
+ Module::ADMIN_TEMPLATES => [
+
+ ],
+ Module::CONTROLLER => [
+
+ ]
+]);
\ No newline at end of file
diff --git a/src/modules/SeoUrlModule.php b/src/modules/SeoUrlModule.php
deleted file mode 100644
index f7a5972..0000000
--- a/src/modules/SeoUrlModule.php
+++ /dev/null
@@ -1,81 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/seoUrl' => [
- 'cl' => SeoUrlModule::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'update',
- "PUT" => 'insert',
- ]
- ]
- ]
- ]);
- }
-
- public function get()
- {
- AdminHelper::sendResponse([
- 'pages' => [
- ['id' => 1, 'name' => 'Flamingos going wild!', 'icon' => 'vt-edit'],
- ['id' => 2, 'name' => 'Turbinen sind geil.', 'icon' => 'vt-edit'],
- ['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
- ['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
- ['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
- ]
- ]);
- }
-
- public function update(): bool
- {
- return false;
- }
-
- public function insert(): bool
- {
- return false;
- }
-
- public function getById($id)
- {
- AdminHelper::sendResponse([
- 'caseName' => 'ROLE_ADMIN',
- 'id' => $id,
- 'name' => 'Admin',
- 'icon' => 'vt-visibility',
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/modules/User/Controller/UserAPIController.php b/src/modules/User/Controller/UserAPIController.php
old mode 100644
new mode 100755
index f64b6b4..8addaee
--- a/src/modules/User/Controller/UserAPIController.php
+++ b/src/modules/User/Controller/UserAPIController.php
@@ -4,16 +4,20 @@
namespace Modules\User\Controller;
use Venom\Core\ArgumentHandler;
-use Venom\Core\DatabaseHandler;
+use Venom\Core\Database\EasyQuery;
+use Venom\Core\Database\EntityManager;
+use Venom\Entities\User;
use Venom\Helper\AdminHelper;
class UserAPIController
{
public function get()
{
+ $entityManager = EntityManager::create(User::class);
+ $easyQuery = new EasyQuery(User::$tableName, ["id", "username", "firstname", "lastname", "email", "isActive"]);
+ $entityManager->load($easyQuery);
//['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
- $data = UserController::get(["id", "username", "firstname", "lastname", "email", "isActive"]);
- AdminHelper::sendResponse(["users" => $data]);
+ AdminHelper::sendResponse(["users" => $entityManager->getAll()]);
}
public function getById($id)
@@ -48,12 +52,6 @@ class UserAPIController
public function delete($id)
{
- AdminHelper::sendStatus(DatabaseHandler::get()->execute(
- "DELETE FROM users WHERE id=:id",
- [
- ':id' => $id
- ]
- ));
}
public function create($id)
diff --git a/src/modules/User/Controller/UserController.php b/src/modules/User/Controller/UserController.php
old mode 100644
new mode 100755
index dc7cffb..dba2e69
--- a/src/modules/User/Controller/UserController.php
+++ b/src/modules/User/Controller/UserController.php
@@ -5,7 +5,7 @@ namespace Modules\User\Controller;
use Venom\Core\DatabaseHandler;
-use Venom\Models\DatabaseObject;
+use Venom\Entities\DatabaseObject;
class UserController
{
diff --git a/src/modules/User/UserModule.php b/src/modules/User/UserModule.php
deleted file mode 100644
index 48ebafa..0000000
--- a/src/modules/User/UserModule.php
+++ /dev/null
@@ -1,49 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/users' => [
- 'cl' => UserAPIController::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'insert',
- "PUT" => 'update',
- ]
- ]
- ]
- ]);
- }
-}
\ No newline at end of file
diff --git a/src/modules/User/module.php b/src/modules/User/module.php
new file mode 100755
index 0000000..c060b78
--- /dev/null
+++ b/src/modules/User/module.php
@@ -0,0 +1,42 @@
+registerModule([
+ Module::ACTIVE => true,
+ Module::NAME => 'UserModule',
+ Module::DESC => 'User Management',
+ Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
+ Module::SECURE => true,
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/users' => new Route(UserAPIController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ],
+ "1" => [
+ Route::GET => 'getById',
+ Route::POST => 'insert',
+ Route::PUT => 'update',
+ Route::DELETE => 'delete'
+ ]
+ ]
+ )
+ ],
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
+ ],
+ Module::ADMIN_TEMPLATES => [
+ //
+ ],
+ Module::CONTROLLER => [
+
+ ]
+]);
\ No newline at end of file
diff --git a/src/modules/VenomStatus/Controller/VenomStatusController.php b/src/modules/VenomStatus/Controller/VenomStatusController.php
new file mode 100644
index 0000000..273bb71
--- /dev/null
+++ b/src/modules/VenomStatus/Controller/VenomStatusController.php
@@ -0,0 +1,13 @@
+registerModule([
+ Module::ACTIVE => true,
+ Module::NAME => 'VenomStatusModule',
+ Module::DESC => 'Show Routes and Modules!',
+ Module::AUTHOR => 'VstZ dev',
+ // NEED TO CHECK RIGHTS? :D IF FALSE WRITE IS ALWAYS ALLOWED ALSO READ!
+ Module::SECURE => true,
+ Module::ROUTE => [],
+ Module::ADMIN_ROUTE => [
+ '/venomStatus' => new Route(VenomStatusController::class, [
+ "*" => [
+ Route::GET => 'get'
+ ]
+ ])
+ ],
+ Module::TEMPLATE_PATH => __DIR__ . "/tpl/",
+ Module::TEMPLATES => [
+
+ ],
+ Module::ADMIN_TEMPLATES => [
+
+ ],
+ Module::CONTROLLER => [
+
+ ]
+]);
\ No newline at end of file
diff --git a/src/modules/VenomStatusModule.php b/src/modules/VenomStatusModule.php
deleted file mode 100644
index 4ff9c19..0000000
--- a/src/modules/VenomStatusModule.php
+++ /dev/null
@@ -1,78 +0,0 @@
-isAdmin()) {
- $this->registerAdminRoutes($venom);
- }
- return true;
- }
-
- public function init(): void
- {
- }
-
- private function registerAdminRoutes(Venom $venom)
- {
- $venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
- '/venomStatus' => [
- 'cl' => VenomStatusModule::class,
- 'roles' => ['ROLE_ADMIN'],
- 'routes' => [
- '*' => [
- "GET" => 'get',
- ],
- '1' => [
- "GET" => 'getById',
- "POST" => 'update',
- "PUT" => 'insert',
- ]
- ]
- ]
- ]);
- }
-
- public function get()
- {
- AdminHelper::sendResponse([
- 'users' => [
- ['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
- ['id' => 2, 'name' => 'versustunez', 'icon' => 'vt-edit']
- ]
- ]);
- }
-
- public function update(): bool
- {
- return false;
- }
-
- public function insert(): bool
- {
- return false;
- }
-
- public function getById($id)
- {
- AdminHelper::sendResponse([
- 'caseName' => 'ROLE_ADMIN',
- 'id' => $id,
- 'name' => 'Admin',
- 'icon' => 'vt-visibility',
- ]);
- }
-}
\ No newline at end of file
diff --git a/tpl/.gitkeep b/tpl/.gitkeep
old mode 100644
new mode 100755
diff --git a/tpl/admin/admin-panel.php b/tpl/admin/admin-panel.php
old mode 100644
new mode 100755
diff --git a/tpl/admin/base.php b/tpl/admin/base.php
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/includes/btn.tpl b/tpl/admin/jsTemplates/includes/btn.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/includes/input.tpl b/tpl/admin/jsTemplates/includes/input.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/includes/select.tpl b/tpl/admin/jsTemplates/includes/select.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/includes/svg.tpl b/tpl/admin/jsTemplates/includes/svg.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/includes/switch.tpl b/tpl/admin/jsTemplates/includes/switch.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/metaDataList.tpl b/tpl/admin/jsTemplates/metaDataList.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/overview.tpl b/tpl/admin/jsTemplates/overview.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/pageEdit.tpl b/tpl/admin/jsTemplates/pageEdit.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/pagesList.tpl b/tpl/admin/jsTemplates/pagesList.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/roleEdit.tpl b/tpl/admin/jsTemplates/roleEdit.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/rolesList.tpl b/tpl/admin/jsTemplates/rolesList.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/seoUrlEdit.tpl b/tpl/admin/jsTemplates/seoUrlEdit.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/seoUrlList.tpl b/tpl/admin/jsTemplates/seoUrlList.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/userEdit.tpl b/tpl/admin/jsTemplates/userEdit.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/usersList.tpl b/tpl/admin/jsTemplates/usersList.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/jsTemplates/venomStatus.tpl b/tpl/admin/jsTemplates/venomStatus.tpl
old mode 100644
new mode 100755
diff --git a/tpl/admin/login.php b/tpl/admin/login.php
old mode 100644
new mode 100755
diff --git a/tpl/default/base.php b/tpl/default/base.php
old mode 100644
new mode 100755