diff --git a/inc/modules/galleries/Admin.php b/inc/modules/galleries/Admin.php index 615e5f0..9e003e7 100644 --- a/inc/modules/galleries/Admin.php +++ b/inc/modules/galleries/Admin.php @@ -53,15 +53,16 @@ class Admin extends AdminModule public function anyAdd() { $location = [ADMIN, 'galleries', 'manage']; - + if (!empty($_POST['name'])) { - $name = trim($_POST['name']); + $name = htmlspecialchars(trim($_POST['name']), ENT_NOQUOTES, 'UTF-8'); + if (!$this->db('galleries')->where('slug', createSlug($name))->count()) { $query = $this->db('galleries')->save(['name' => $name, 'slug' => createSlug($name)]); if ($query) { - $id = $this->db()->lastInsertId(); - $dir = $this->_uploads.'/'.$id; + $id = $this->db()->lastInsertId(); + $dir = $this->_uploads.'/'.$id; if (mkdir($dir, 0755, true)) { $this->notify('success', $this->lang('add_gallery_success')); @@ -76,7 +77,7 @@ class Admin extends AdminModule } else { $this->notify('failure', $this->lang('empty_inputs', 'general')); } - + redirect(url($location)); } @@ -142,7 +143,7 @@ class Admin extends AdminModule $this->core->addCSS(url('inc/jscripts/lightbox/lightbox.min.css')); $this->core->addJS(url('inc/jscripts/lightbox/lightbox.min.js')); $this->core->addJS(url('inc/jscripts/are-you-sure.min.js')); - + return $this->draw('edit.html', ['gallery' => $assign]); } @@ -151,13 +152,15 @@ class Admin extends AdminModule */ public function postSaveSettings($id) { - if (checkEmptyFields(['name', 'sort'], $_POST)) { + $formData = htmlspecialchars_array($_POST); + + if (checkEmptyFields(['name', 'sort'], $formData)) { $this->notify('failure', $this->lang('empty_inputs', 'general')); redirect(url([ADMIN, 'galleries', 'edit', $id])); } - $_POST['slug'] = createSlug($_POST['name']); - if ($this->db('galleries')->where($id)->save($_POST)) { + $formData['slug'] = createSlug($formData['name']); + if ($this->db('galleries')->where($id)->save($formData)) { $this->notify('success', $this->lang('save_settings_success')); } @@ -185,8 +188,8 @@ class Admin extends AdminModule */ public function postUpload($id) { - $dir = $this->_uploads.'/'.$id; - $cntr = 0; + $dir = $this->_uploads.'/'.$id; + $cntr = 0; if (!is_uploaded_file($_FILES['files']['tmp_name'][0])) { $this->notify('failure', $this->lang('no_files')); @@ -197,7 +200,7 @@ class Admin extends AdminModule if ($img->load($image)) { $imgName = time().$cntr++; $imgPath = $dir.'/'.$imgName.'.'.$img->getInfos('type'); - $src = []; + $src = []; // oryginal size $img->save($imgPath); @@ -232,6 +235,7 @@ class Admin extends AdminModule public function getDeleteImage($id) { $image = $this->db('galleries_items')->where($id)->oneArray(); + if (!empty($image)) { if ($this->db('galleries_items')->delete($id)) { $images = unserialize($image['src']); diff --git a/inc/modules/galleries/Info.php b/inc/modules/galleries/Info.php index 8b68c4f..96e294e 100644 --- a/inc/modules/galleries/Info.php +++ b/inc/modules/galleries/Info.php @@ -10,13 +10,12 @@ */ return [ - 'name' => $core->lang['galleries']['module_name'], - 'description' => $core->lang['galleries']['module_desc'], - 'author' => 'Sruu.pl', - 'version' => '1.0', - 'compatibility' => '1.3.*', - 'icon' => 'camera', - + 'name' => $core->lang['galleries']['module_name'], + 'description' => $core->lang['galleries']['module_desc'], + 'author' => 'Sruu.pl', + 'version' => '1.1', + 'compatibility' => '1.3.*', + 'icon' => 'camera', 'install' => function () use ($core) { $core->db()->pdo()->exec("CREATE TABLE IF NOT EXISTS `galleries` ( `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, diff --git a/inc/modules/galleries/Site.php b/inc/modules/galleries/Site.php index 8fab6eb..7d39cd4 100644 --- a/inc/modules/galleries/Site.php +++ b/inc/modules/galleries/Site.php @@ -33,7 +33,7 @@ class Site extends SiteModule } else { $items = $this->db('galleries_items')->where('gallery', $gallery['id'])->desc('id')->toArray(); } - + $tempAssign = $gallery; if (count($items)) { @@ -51,6 +51,7 @@ class Site extends SiteModule } } } + $this->tpl->set('gallery', $assign); $this->core->addCSS(url('inc/jscripts/lightbox/lightbox.min.css')); diff --git a/inc/modules/galleries/view/admin/edit.html b/inc/modules/galleries/view/admin/edit.html index 124c55f..d9df1f6 100644 --- a/inc/modules/galleries/view/admin/edit.html +++ b/inc/modules/galleries/view/admin/edit.html @@ -60,7 +60,7 @@

{$lang.galleries.settings}

-
+
diff --git a/inc/modules/galleries/view/admin/manage.html b/inc/modules/galleries/view/admin/manage.html index 4663ef3..b51737d 100644 --- a/inc/modules/galleries/view/admin/manage.html +++ b/inc/modules/galleries/view/admin/manage.html @@ -2,37 +2,37 @@
-

{$lang.general.manage}

-
+

{$lang.general.manage}

+
{if: !empty($galleries)} -
- - - - - - - - - - {loop: $galleries} - - - - - - {/loop} - -
{$lang.general.name}Tag{$lang.general.actions}
{$value.name}{$value.tag} - - - - - - -
-
+
+ + + + + + + + + + {loop: $galleries} + + + + + + {/loop} + +
{$lang.general.name}Tag{$lang.general.actions}
{$value.name}{$value.tag} + + + + + + +
+
{else}

{$lang.general.empty_array}

{/if} @@ -43,15 +43,15 @@
-

{$lang.galleries.add_gallery}

-
+

{$lang.galleries.add_gallery}

+
- -
- - -
- + +
+ + +
+
diff --git a/inc/modules/galleries/view/gallery.html b/inc/modules/galleries/view/gallery.html index 7f0a524..651fdf3 100644 --- a/inc/modules/galleries/view/gallery.html +++ b/inc/modules/galleries/view/gallery.html @@ -21,6 +21,6 @@ \ No newline at end of file