diff --git a/README.md b/README.md
index 3eaa156..d031b2f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,19 @@
-# gallery
+### gallery
-Модуль Галерея Только для AVE.CMS ALT
\ No newline at end of file
+## Модуль Галерея v3.26.5
+
+
+### Данный модуль предназначен для создания различных галерей изображений.
+
+ * Gallery + Watermark Внимание! У директорий uploads/gallery/.upload/ и uploads/gallery/.temp/ должны быть права на запись!
+ * Вы можете ограничить количество выводимых изображений, указав после Gallery-ID следующее: -3 (в этом случае количество будет ограничено тремя изображениями на страницу)
+
+### Changelog:
+
+26.12.2019 - версия 3.26.5 - Исправлена ошибка загрузки файлов формата .jpeg
+
+05.09.2019 - версия 3.26.4 - Замена пути загрузки файла browserplus-min.js на локальный.
+
+05.09.2019 - версия 3.26.2 - адаптация для версии ave.cms 3.26
+
+01.05.2014 - версия 3.2.2
\ No newline at end of file
diff --git a/class/gallery.php b/class/gallery.php
new file mode 100644
index 0000000..8f1d7fa
--- /dev/null
+++ b/class/gallery.php
@@ -0,0 +1,1167 @@
+Query("
+ SELECT *
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+
+ $row_gs = $sql->FetchRow();
+
+ $limit = ($row_gs->gallery_image_on_page > 0)
+ ? $row_gs->gallery_image_on_page
+ : $this->_default_limit_images;
+ $limit = empty($lim) ? $limit : $lim;
+ $limit = ($ext != 1) ? $limit : 10000;
+ $start = get_current_page() * $limit - $limit;
+
+ switch ($row_gs->gallery_orderby)
+ {
+ case 'position': $order_by = "image_position ASC"; break;
+ case 'titleasc': $order_by = "image_title ASC"; break;
+ case 'titledesc': $order_by = "image_title DESC"; break;
+ case 'dateasc': $order_by = "image_date ASC"; break;
+ default: $order_by = "image_date DESC"; break;
+ }
+
+ $sql = $AVE_DB->Query("
+ SELECT COUNT(*)
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "' AND image_status = '1'
+ ");
+ $num = $sql->GetCell();
+
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "' AND image_status = '1'
+ ORDER BY " . $order_by . "
+ LIMIT " . $start . "," . $limit . "
+ ");
+
+ $folder = trim(UPLOAD_GALLERY_DIR . '/' . $row_gs->gallery_folder, '/');
+ $size = sprintf($this->_size, $row_gs->gallery_thumb_method, $row_gs->gallery_thumb_width, $row_gs->gallery_thumb_height);
+
+ $search = array('[tag:gal:id]', '[tag:gal:folder]', '[tag:path]','[tag:gal:title]','[tag:gal:description]');
+ $replace = array($row_gs->id, ABS_PATH . $folder . '/', ABS_PATH,$row_gs->gallery_title,$row_gs->gallery_description);
+ $main_template = str_replace($search, $replace, $row_gs->gallery_script);
+
+ // Постраничная навигация
+ if ($num > $limit)
+ {
+ $page_nav = '{t} ';
+ $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav, get_settings('navi_box'));
+ $page_nav = rewrite_link($page_nav);
+ $GLOBALS['page_id'][$_REQUEST['id']]['page']=($GLOBALS['page_id'][$_REQUEST['id']]['page']>ceil($num / $limit) ? $GLOBALS['page_id'][$_REQUEST['id']]['page'] : ceil($num / $limit));
+ }
+ else
+ {
+ $page_nav = '';
+ }
+
+ $rows = array();
+
+ while ($row = $sql->FetchRow())
+ {
+ $row->image_filename = rawurlencode($row->image_filename);
+ $row->image_size = round(filesize(BASE_DIR . '/' . $folder . '/' . $row->image_filename) / 1024, 0);
+ array_push($rows, $row);
+ }
+
+ $images = '';
+ $i = 0;
+ $items_count = count($rows);
+
+ //
+ foreach ($rows as $row)
+ {
+ $i++;
+ $last_item = ($i==$items_count ? true : false);
+ $item_num = $i;
+
+ $search = array(
+ '[tag:img:id]',
+ '[tag:img:original]',
+ '[tag:img:thumbnail]',
+ '[tag:img:title]',
+ '[tag:img:description]',
+ '[tag:img:size]',
+ '[tag:gal:id]',
+ '[tag:gal:folder]',
+ '[tag:path]',
+ '[tag:link]',
+ '[tag:gal:title]'
+ );
+ $replace = array(
+ $row->id,
+ ABS_PATH . $folder . '/' . $row->image_filename,
+ make_thumbnail(array('link' => ABS_PATH . $folder . '/' . $row->image_filename, 'size' => $size)),
+ htmlspecialchars(empty($row->image_title) ? $AVE_Template->get_config_vars('NoTitle') : $row->image_title, ENT_QUOTES),
+ htmlspecialchars(empty($row->image_description) ? $AVE_Template->get_config_vars('NoDescr') : $row->image_description, ENT_QUOTES),
+ $row->image_size,
+ $row_gs->id,
+ ABS_PATH . $folder . '/',
+ ABS_PATH,
+ str_ireplace('"//"','"/"', str_ireplace('///', '/', rewrite_link($row->image_link))),
+ $row_gs->gallery_title
+ );
+
+ $image = str_replace($search, $replace, $row_gs->gallery_image_template);
+ $image = '<'.'?php $item_num='.var_export($item_num,1).'; $last_item='.var_export($last_item,1).'?'.'>'.$image;
+ $image = str_replace('[tag:if_first]', '<'.'?php if(isset($item_num) && ($item_num)===1) { ?'.'>', $image);
+ $image = str_replace('[tag:if_not_first]', '<'.'?php if(isset($item_num) && $item_num!==1) { ?'.'>', $image);
+ $image = str_replace('[tag:if_last]', '<'.'?php if(isset($last_item) && $last_item) { ?'.'>', $image);
+ $image = str_replace('[tag:if_not_last]', '<'.'?php if(isset($item_num) && !$last_item) { ?'.'>', $image);
+ $image = preg_replace('/\[tag:if_every:([0-9-]+)\]/u', '<'.'?php if(isset($item_num) && !('.$i.' % $1)){ '.'?'.'>', $image);
+ $image = preg_replace('/\[tag:if_not_every:([0-9-]+)\]/u', '<'.'?php if(isset($item_num) && ('.$i.' % $1)){ '.'?'.'>', $image);
+ $image = str_replace('[tag:/if]', '<'.'?php } ?'.'>', $image);
+ $image = str_replace('[tag:if:else]', '<'.'?php } else { ?'.'>', $image);
+
+ $images .= eval2var('?>' . $image . '');
+
+ }
+ $main_template = str_replace('[tag:gal:pages]', $page_nav, $main_template);
+
+ $return = str_replace('[tag:gal:content]', $images, $main_template);
+ $return = str_replace('[tag:path]', ABS_PATH, $return);
+ $return = str_replace('[tag:mediapath]', ABS_PATH . 'templates/' . ((defined('THEME_FOLDER') === false) ? DEFAULT_THEME_FOLDER : THEME_FOLDER) . '/', $return);
+
+ echo $return;
+ }
+
+
+ /**
+ * Вывод одиночного изображения
+ *
+ * @param string $tpl_dir - путь к папке с шаблонами модуля
+ * @param int $image_id - идентификатор изображения
+ */
+ function galleryImageShow($tpl_dir, $image_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ image_filename,
+ image_file_ext,
+ image_title,
+ gallery_folder
+ FROM
+ " . PREFIX . "_module_gallery_images AS img
+ LEFT JOIN
+ " . PREFIX . "_module_gallery AS gal
+ ON gal.id = gallery_id
+ WHERE
+ img.id = '" . $image_id . "'
+ ");
+ $row = $sql->FetchRow();
+
+ $folder = trim(UPLOAD_GALLERY_DIR . '/' . $row->gallery_folder, '/');
+// $thumb_dir = trim(THUMBNAIL_DIR . '/' . sprintf($this->_size, $row->gallery_thumb_width), '/');
+ $source = ABS_PATH . $folder . '/' . rawurlencode($row->image_filename);
+
+ switch ($this->_galleryFileTypeGet($row->image_file_ext))
+ {
+ case 'gif':
+ case 'jpg':
+ case 'jpeg':
+ case 'png':
+ list($width, $height) = getimagesize(BASE_DIR . '/' . $folder . '/' . $row->image_filename);
+ $AVE_Template->assign('w', ($width < 350 ? 350 : ($width > 950 ? 950 : $width+8)));
+ $AVE_Template->assign('h', ($height < 350 ? 350 : ($height > 700 ? 700 : $height+85)));
+ $AVE_Template->assign('scrollbars', ($width > 950 || $height > 700 ? 1 : '') );
+ $AVE_Template->assign('source', $source);
+ $AVE_Template->assign('image_title', $row->image_title);
+ break;
+
+ case 'video':
+ $AVE_Template->assign('w', 350);
+ $AVE_Template->assign('notresizable', 1);
+ $AVE_Template->assign('h', 400);
+ $AVE_Template->assign('source', $source);
+ $AVE_Template->assign('mediatype', $this->_galleryMediaTypeGet($row->image_file_ext));
+ break;
+ }
+
+ $AVE_Template->display($tpl_dir . 'image.tpl');
+ }
+
+ /**
+ * ФУНКЦИИ АДМИНИСТРАТИВНОЙ ЧАСТИ
+ */
+
+ /**
+ * Просмотр изображений галереи в админке
+ *
+ * @param string $tpl_dir - путь к папке с шаблонами модуля
+ * @param int $gallery_id - идентификатор галереи
+ */
+ function galleryImageListShow($tpl_dir, $gallery_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ gallery_thumb_width,
+ gallery_thumb_height,
+ gallery_thumb_method,
+ gallery_title,
+ gallery_folder
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row_gs = $sql->FetchRow();
+
+ $folder = trim(UPLOAD_GALLERY_DIR . '/' . $row_gs->gallery_folder, '/');
+ $size = sprintf($this->_size, $row_gs->gallery_thumb_method, $row_gs->gallery_thumb_width, $row_gs->gallery_thumb_height);
+
+ if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save')
+ {
+ if (isset($_POST['del']) && sizeof($_POST['del']) > 0)
+ {
+ while (list($image_id) = each($_POST['del']))
+ {
+ $file = BASE_DIR . '/' . $folder . '/' . $_POST['datei'][$image_id];
+ @unlink($file);
+ @unlink(make_thumbnail(array('link' => $file, 'size' => $size)));
+
+ $AVE_DB->Query("
+ DELETE
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE id = '" . (int)$image_id . "'
+ ");
+ }
+ }
+
+ foreach ($_POST['gimg'] as $image_id)
+ {
+ $AVE_DB->Query("
+ UPDATE " . PREFIX . "_module_gallery_images
+ SET
+ image_title = '" . $_POST['image_title'][$image_id] . "',
+ image_description = '" . $_POST['image_description'][$image_id] . "',
+ image_position = '" . intval($_POST['image_position'][$image_id]) . "',
+ image_link = '" . $_POST['image_link'][$image_id] . "',
+ image_status = '" . ((empty($_POST['image_status'][$image_id]) || empty($_POST['image_status'][$image_id])) ? 0 : 1) . "'
+ WHERE
+ id = '" . (int)$image_id . "'
+ AND
+ gallery_id = '" . $gallery_id . "'
+ ");
+ }
+
+ header('Location:' . get_redirect_link('sub'));
+ exit;
+ }
+
+ $limit = $this->_admin_limit_images;
+ $start = get_current_page() * $limit - $limit;
+
+ $sql = $AVE_DB->Query("
+ SELECT SQL_CALC_FOUND_ROWS *
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "'
+ ORDER BY id DESC
+ LIMIT " . $start . "," . $limit . "
+ ");
+
+ $sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()");
+ $num = $sql_num->GetCell();
+
+ if (!$num)
+ {
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1');
+ exit;
+ }
+
+ $images = array();
+ while ($row = $sql->FetchAssocArray())
+ {
+ $row['image_type'] = $this->_galleryFileTypeGet($row['image_file_ext']);
+ $row['image_author'] = get_username_by_id($row['image_author_id']);
+ $row['image_size'] = @filesize(BASE_DIR . '/' . $folder . '/' . $row['image_filename']);
+ $row['image_size'] = @round($row['image_size'] / 1024, 2);
+ $row['image_filename'] = rawurlencode($row['image_filename']);
+ $row['original'] = ABS_PATH . $folder . '/' . $row['image_filename'];
+ $row['thumbnail'] = make_thumbnail(array('link' => $row['original'], 'size' => $size));
+ array_push($images, $row);
+ }
+
+ if ($num > $limit)
+ {
+ $page_nav = ' {t} ';
+ $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav);
+ }
+ else
+ {
+ $page_nav = '';
+ }
+ $AVE_Template->assign('page_nav', $page_nav);
+ $AVE_Template->assign('gallery_title', $row_gs->gallery_title);
+ $AVE_Template->assign('gallery_thumb_width', $row_gs->gallery_thumb_width);
+ $AVE_Template->assign('images', $images);
+ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gallery_image.tpl'));
+ }
+
+ /**
+ * Загрузка изображений в галерею
+ *
+ * @param string $tpl_dir - путь к папке с шаблонами модуля
+ * @param int $gallery_id - идентификатор галереи
+ */
+ function galleryImageUploadForm($tpl_dir, $gallery_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ gallery_watermark,
+ gallery_thumb_width,
+ gallery_title,
+ gallery_folder
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row = $sql->FetchRow();
+
+ $dst_dir = BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR . '/' . $row->gallery_folder, '/');
+
+ if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save')
+ {
+ $images = array();
+
+ $path = ABS_PATH . trim(UPLOAD_GALLERY_DIR . '/' . $row->gallery_folder, '/');
+ @$size = sprintf($this->_size, $row_gs->gallery_thumb_method, $row_gs->gallery_thumb_width, $row_gs->gallery_thumb_height);
+ @$admin_size = sprintf($this->admin_size, $row_gs->gallery_thumb_method, $row_gs->gallery_thumb_width, $row_gs->gallery_thumb_height);
+
+ if (!empty($_REQUEST['fromfolder']) && $_REQUEST['fromfolder'] == 1)
+ {
+ $src_dir = BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR, '/') . '/.temp/';
+
+ if (! file_exists($src_dir) && ! mkdir($src_dir, 0777, true))
+ {
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1');
+ exit;
+ }
+
+ $htaccess_file = $src_dir . '/' . '.htaccess';
+ if (!file_exists($htaccess_file))
+ {
+ $fp = @fopen($htaccess_file, 'w+');
+ if ($fp)
+ {
+ fputs($fp, 'Deny from all');
+ fclose($fp);
+ }
+ }
+
+ if ($handle = opendir($src_dir . '/'))
+ {
+ while (false !== ($file = readdir($handle)))
+ {
+ if ($file != '.' && $file != '..')
+ {
+ $image_title = mb_substr($file, 0, mb_strrpos($file, '.'));
+ $upload_file_ext = strtolower(mb_substr($file, mb_strrpos($file, '.') + 0));
+ $upload_filename = prepare_fname($image_title) . $upload_file_ext;
+
+ while (file_exists($dst_dir . '/' . $upload_filename))
+ {
+ $upload_filename = $this->_galleryImageRename($upload_filename);
+ }
+
+ if (!empty($upload_filename) && in_array($upload_file_ext, $this->_allowed_type))
+ {
+ @copy($src_dir . '/' . $file, $dst_dir . '/' . $upload_filename);
+ @unlink($src_dir . '/' . $file);
+
+ $oldumask = umask(0);
+ @chmod($dst_dir . '/' . $upload_filename, 0777);
+ umask($oldumask);
+
+ if ($upload_file_ext != 'video')
+ {
+ $this->_galleryImageRebuild($dst_dir, $upload_filename, $row->gallery_watermark);
+ }
+
+ $images[] = make_thumbnail(array('link' => $path . '/' . $upload_filename, 'size' => $size));
+
+ $AVE_DB->Query("
+ INSERT
+ INTO " . PREFIX . "_module_gallery_images
+ SET
+ id = '',
+ gallery_id = '" . $gallery_id . "',
+ image_filename = '" . addslashes($upload_filename) . "',
+ image_author_id = '" . (int)$_SESSION['user_id'] . "',
+ image_title = '" . addslashes($image_title) . "',
+ image_file_ext = '" . addslashes($upload_file_ext) . "',
+ image_description = '',
+ image_date = '" . time() . "'
+ ");
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
+ else if (!empty($_REQUEST['fromuploader']) && $_REQUEST['fromuploader'] == 1)
+ {
+ $src_dir = BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/.uploader/' . $_SESSION['user_id'];
+
+ if (! file_exists($src_dir . '/') && ! mkdir($src_dir . '/', 0777, true))
+ {
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1');
+ exit;
+ }
+
+ $htaccess_file = $src_dir . '/' . '.htaccess';
+
+ if (!file_exists($htaccess_file))
+ {
+ $fp = @fopen($htaccess_file, 'w+');
+ if ($fp)
+ {
+ fputs($fp, 'Deny from all');
+ fclose($fp);
+ }
+ }
+
+ if ($handle = opendir($src_dir . '/'))
+ {
+ while (false !== ($file = readdir($handle)))
+ {
+ if ($file != '.' && $file != '..')
+ {
+ $image_title = mb_substr($file, 0, mb_strrpos($file, '.'));
+ $upload_file_ext = strtolower(mb_substr($file, mb_strrpos($file, '.') + 0));
+ $upload_filename = prepare_fname($image_title) . $upload_file_ext;
+
+ while (file_exists($dst_dir . '/' . $upload_filename))
+ {
+ $upload_filename = $this->_galleryImageRename($upload_filename);
+ }
+
+ if (!empty($upload_filename) && in_array($upload_file_ext, $this->_allowed_type))
+ {
+ @copy($src_dir . '/' . $file, $dst_dir . '/' . $upload_filename);
+ @unlink($src_dir . '/' . $file);
+
+ $oldumask = umask(0);
+ @chmod($dst_dir . '/' . $upload_filename, 0777);
+ umask($oldumask);
+
+ if ($upload_file_ext != 'video')
+ {
+ $this->_galleryImageRebuild($dst_dir, $upload_filename, $row->gallery_watermark);
+ }
+
+ //$images[] = make_thumbnail(array('link' => $path . '/' . $upload_filename, 'size' => $_size));
+ $images[] = make_thumbnail(array('size' => $admin_size, 'link' => $path . '/' . $upload_filename));
+
+ $AVE_DB->Query("
+ INSERT
+ INTO " . PREFIX . "_module_gallery_images
+ SET
+ id = '',
+ gallery_id = '" . $gallery_id . "',
+ image_filename = '" . addslashes($upload_filename) . "',
+ image_author_id = '" . (int)$_SESSION['user_id'] . "',
+ image_title = '" . addslashes($image_title) . "',
+ image_file_ext = '" . addslashes($upload_file_ext) . "',
+ image_description = '',
+ image_date = '" . time() . "'
+ ");
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
+
+ $count_files = sizeof(@$_FILES['file']['tmp_name']);
+ for ($i=0;$i<$count_files;$i++)
+ {
+ //$upload_file_ext = strtolower(substr($_FILES['file']['name'][$i], -4));
+ $upload_file_ext = strtolower(mb_substr($_FILES['file']['name'][$i], mb_strrpos($_FILES['file']['name'][$i], '.') + 0));
+
+ //$upload_filename = prepare_fname(substr($_FILES['file']['name'][$i], 0, -4)) . $upload_file_ext;
+ $upload_filename = prepare_fname(mb_substr($_FILES['file']['name'][$i], 0, mb_strrpos($_FILES['file']['name'][$i], '.'))) . $upload_file_ext;
+
+ if (!empty($upload_filename))
+ {
+ while (file_exists($dst_dir . '/' . $upload_filename))
+ {
+ $upload_filename = $this->_galleryImageRename($upload_filename);
+ }
+
+ if (in_array($upload_file_ext, $this->_allowed_type) )
+ {
+ move_uploaded_file($_FILES['file']['tmp_name'][$i], $dst_dir . '/' . $upload_filename);
+
+ $oldumask = umask(0);
+ @chmod($dst_dir . '/' . $upload_filename, 0777);
+ umask($oldumask);
+
+ if ($upload_file_ext != 'video')
+ {
+ $this->_galleryImageRebuild($dst_dir, $upload_filename, $row->gallery_watermark);
+ }
+
+ //$images[] = make_thumbnail(array('link' => $path . '/' . $upload_filename, 'size' => $size));
+ $images[] = make_thumbnail(array('size' => $admin_size, 'link' => $path . '/' . $upload_filename));
+
+ $AVE_DB->Query("
+ INSERT
+ INTO " . PREFIX . "_module_gallery_images
+ SET
+ id = '',
+ gallery_id = '" . $gallery_id . "',
+ image_filename = '" . addslashes($upload_filename) . "',
+ image_author_id = '" . (int)$_SESSION['user_id'] . "',
+ image_title = '" . (isset($_POST['image_title'][$i]) ? $_POST['image_title'][$i] : '') . "',
+ image_file_ext = '" . addslashes($upload_file_ext) . "',
+ image_description = '" . (isset($_POST['image_description'][$i]) ? $_POST['image_description'][$i] : '') . "',
+ image_date = '" . time() . "'
+ ");
+ }
+ }
+ }
+ $AVE_Template->assign('gallery_title', $row->gallery_title);
+ $AVE_Template->assign('images', $images);
+ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gallery_upload_form_finish.tpl'));
+ }
+ else
+ {
+ if (!is_writable($dst_dir . '/'))
+ {
+ $AVE_Template->assign('not_writeable', 1);
+ $AVE_Template->assign('upload_dir', '/' . trim(UPLOAD_GALLERY_DIR . '/' . $row->gallery_folder, '/') . '/');
+ }
+ $AVE_Template->assign('gallery_title', $row->gallery_title);
+ $AVE_Template->assign('allowed', $this->_allowed_type);
+ $AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=gallery&moduleaction=add&sub=save&id=' . $gallery_id);
+ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gallery_upload_form.tpl'));
+ }
+ }
+
+ /**
+ * Вывод списка галерей
+ *
+ * @param string $tpl_dir - путь к папке с шаблонами модуля
+ */
+ function galleryListShow($tpl_dir)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ if (!empty($_POST['create']))
+ {
+ foreach ($_POST['create'] as $gallery_id)
+ {
+ $this->_galleryImageMove((int)$gallery_id);
+ }
+ }
+
+ $limit = $this->_limit_galleries;
+ $start = get_current_page() * $limit - $limit;
+ $galleries = array();
+
+ $sql = $AVE_DB->Query("
+ SELECT SQL_CALC_FOUND_ROWS
+ gal.*,
+ COUNT(img.id) AS image_count
+ FROM
+ " . PREFIX . "_module_gallery AS gal
+ LEFT JOIN
+ " . PREFIX . "_module_gallery_images AS img
+ ON img.gallery_id = gal.id
+ GROUP BY gal.id
+ ORDER BY gal.gallery_created DESC
+ LIMIT " . $start . "," . $limit . "
+ ");
+
+ $sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()");
+ $num = $sql_num->GetCell();
+
+ while($row = $sql->FetchAssocArray())
+ {
+ $row['username'] = get_username_by_id($row['gallery_author_id']);
+ array_push($galleries, $row);
+ }
+
+ if ($num > $limit)
+ {
+ $page_nav = "
{t} ";
+ $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav);
+ }
+ else
+ {
+ $page_nav = '';
+ }
+ $AVE_Template->assign('page_nav', $page_nav);
+
+ if (!empty($_REQUEST['alert']))
+ {
+ $AVE_Template->assign('alert', htmlspecialchars(stripslashes($_REQUEST['alert'])));
+ }
+ $AVE_Template->assign('galleries', $galleries);
+ $AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=gallery&moduleaction=new&sub=save');
+ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gallery_list.tpl'));
+ }
+
+ /**
+ * Создание галереи
+ *
+ */
+ function galleryNew()
+ {
+ if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save')
+ {
+ global $AVE_DB;
+
+ $cont = true;
+ $alert = '';
+
+ if (empty($_POST['gallery_title']))
+ {
+ $alert = '&alert=empty_gallery_title';
+ $cont = false;
+ }
+ else
+ {
+ $gallery_folder = prepare_fname(stripslashes($_POST['gallery_folder']));
+
+ if (!empty($gallery_folder))
+ {
+ $sql = $AVE_DB->Query("
+ SELECT 1
+ FROM " . PREFIX . "_module_gallery
+ WHERE gallery_folder = '" . $gallery_folder . "'
+ ");
+ $folder_exists = $sql->GetCell();
+
+ if ($folder_exists)
+ {
+ $alert = '&alert=folder_exists';
+ $cont = false;
+
+ }
+ }
+ }
+
+ if ($cont)
+ {
+ $AVE_DB->Query("
+ INSERT
+ INTO " . PREFIX . "_module_gallery
+ SET
+ id = '',
+ gallery_folder = '" . $gallery_folder . "',
+ gallery_title = '" . $_POST['gallery_title'] . "',
+ gallery_description = '" . $_POST['gallery_description'] . "',
+ gallery_author_id = '" . (int)$_SESSION['user_id'] . "',
+ gallery_created = '" . time() . "'
+ ");
+
+ if (!empty($gallery_folder))
+ {
+ $oldumask = umask(0);
+ @mkdir(BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/' . $gallery_folder . '/', 0777);
+ umask($oldumask);
+
+ }
+ }
+
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1' . $alert);
+ exit;
+ }
+ }
+
+ /**
+ * Редактирование галереи
+ *
+ * @param string $tpl_dir - путь к папке с шаблонами модуля
+ * @param int $gallery_id - идентификатор галереи
+ */
+ function galleryEdit($tpl_dir, $gallery_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save')
+ {
+ $old_dir = prepare_fname(stripslashes($_REQUEST['gallery_folder_old']));
+ $new_dir = prepare_fname(stripslashes($_REQUEST['gallery_folder']));
+
+ if ($_REQUEST['gallery_title'] == '')
+ { // не указано имя галереи
+ $AVE_Template->assign('empty_gallery_title', 1);
+ $_REQUEST['gallery_title'] = $_REQUEST['gallery_title_old'];
+ }
+
+ if ($_REQUEST['thumb_width_old'] != $_REQUEST['gallery_thumb_width'])
+ { // изменён размер миниатюр - удаляем миниатюры
+ $folder = BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR . '/' . $old_dir, '/');
+
+ if ($old_dir != '')
+ {
+ rrmdir($folder . '/' . THUMBNAIL_DIR);
+ }
+ else
+ {
+ $sql = $AVE_DB->Query("
+ SELECT gallery_thumb_width,gallery_thumb_method,gallery_thumb_height
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row_gs = $sql->FetchRow();
+
+ $size = sprintf($this->_size, $row_gs->gallery_thumb_method, $row_gs->gallery_thumb_width, $row_gs->gallery_thumb_height);
+
+ $sql = $AVE_DB->Query("
+ SELECT image_filename
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "'
+ ");
+ while ($row = $sql->FetchRow())
+ {
+ @unlink(make_thumbnail(array('link' => $folder . '/' . $row->image_filename, 'size' => $size)));
+ }
+
+ @rmdir($folder . '/' . THUMBNAIL_DIR);
+ }
+ }
+
+ if ($old_dir != $new_dir)
+ { // изменен путь к файлам галереи - перемещаем в новое место
+ $this->_galleryImageMove($gallery_id, $old_dir, $new_dir);
+ }
+
+ $AVE_DB->Query("
+ UPDATE " . PREFIX . "_module_gallery
+ SET
+ gallery_title = '" . $_REQUEST['gallery_title'] . "',
+ gallery_description = '" . $_REQUEST['gallery_description'] . "',
+ gallery_thumb_width = '" . (int)$_REQUEST['gallery_thumb_width'] . "',
+ gallery_thumb_height = '" . (int)$_REQUEST['gallery_thumb_height'] . "',
+ gallery_thumb_method = '" . $_REQUEST['gallery_thumb_method'] . "',
+ gallery_image_on_line = '" . (int)$_REQUEST['gallery_image_on_line'] . "',
+ gallery_image_on_page = '" . (int)$_REQUEST['gallery_image_on_page'] . "',
+ gallery_watermark = '" . $_REQUEST['gallery_watermark'] . "',
+ gallery_folder = '" . $new_dir . "',
+ gallery_orderby = '" . $_REQUEST['gallery_orderby'] . "',
+ gallery_script = '" . $_REQUEST['gallery_script'] . "',
+ gallery_image_template = '" . $_REQUEST['gallery_image_template'] . "'
+ WHERE
+ id = '" . $gallery_id . "'
+ ");
+
+// header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=editgallery&id=' . $gallery_id);
+ header('Location:' . get_redirect_link('sub'));
+ exit;
+ }
+
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row = $sql->FetchAssocArray();
+ $blanc = 'templates/images/blanc.gif';
+
+ $AVE_Template->assign('blank', $blanc);
+ $AVE_Template->assign('gallery', $row);
+ $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_gallery_edit.tpl'));
+ }
+
+ /**
+ * Удаление галереи
+ *
+ * @param int $gallery_id - идентификатор галереи
+ */
+ function galleryDelete($gallery_id)
+ {
+ global $AVE_DB;
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ gallery_folder,
+ gallery_thumb_width
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row = $sql->fetchRow();
+
+ if ($row == false) return;
+
+ if (! empty($row->gallery_folder))
+ {
+ rrmdir(BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/' . $row->gallery_folder . '/');
+ }
+ else
+ {
+ $size = sprintf($this->_size, $row->gallery_thumb_method, $row->gallery_thumb_width, $row->gallery_thumb_height);
+
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "'
+ ");
+ while ($row = $sql->FetchRow())
+ {
+ $file = BASE_DIR . '/' . UPLOAD_GALLERY_DIR . '/' . $row->image_filename;
+ @unlink($file);
+ @unlink(make_thumbnail(array('link' => $file, 'size' => $size)));
+ }
+ }
+ $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_gallery WHERE id = '" . $gallery_id . "'");
+ $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_gallery_images WHERE gallery_id = '" . $gallery_id . "'");
+
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1');
+ exit;
+ }
+
+/**
+ * ВНУТРЕННИЕ МЕТОДЫ
+ */
+
+ /**
+ * тип видео-файла по расширению
+ *
+ * @param string $ext
+ * @return string
+ */
+ function _galleryMediaTypeGet($ext)
+ {
+ switch($ext)
+ {
+ case '.avi':
+ case '.wmv':
+ case '.wmf':
+ case '.mpg': $type = 'avi'; break;
+ case '.mov': $type = 'mov'; break;
+ }
+
+ return $type;
+ }
+
+ /**
+ * тип файла по расширению
+ *
+ * @param string $ext
+ * @return string
+ */
+ function _galleryFileTypeGet($ext)
+ {
+ switch($ext)
+ {
+ case '.avi':
+ case '.mov':
+ case '.wmv':
+ case '.wmf':
+ case '.mpg': $type = 'video'; break;
+ case '.jpg':
+ case '.jpeg':
+ case '.jpe': $type = 'jpg'; break;
+ case '.png': $type = 'png'; break;
+ case '.gif': $type = 'gif'; break;
+ }
+
+ return $type;
+ }
+
+ /**
+ * Формирование уникального имени файла
+ *
+ * @param string $file_name - имя файла
+ * @return string
+ */
+ function _galleryImageRename($file_name)
+ {
+ mt_rand();
+ $pref = rand(1, 999);
+
+ return $pref . '_' . $file_name;
+ }
+
+ /**
+ * Изменение размеров и наложение водяного знака при загрузке изображений
+ *
+ * @param string $dst_dir - путь к папке для загрузки
+ * @param string $upload_filename - имя загружаемого файла
+ * @param string $watermark - водяной знак
+ */
+ function _galleryImageRebuild($dst_dir, $upload_filename, $watermark = '')
+ {
+ global $Image_Toolbox;
+
+ if (!list($width, $height) = @getimagesize($dst_dir . '/' . $upload_filename)) return;
+
+ $need_resize = false;
+ $need_save = false;
+
+ if (isset($_REQUEST['shrink']) && is_numeric($_REQUEST['shrink']) && $_REQUEST['shrink'] < 100)
+ {
+ $width = round($width * $_REQUEST['shrink'] / 100);
+ $height = round($height * $_REQUEST['shrink'] / 100);
+
+ $need_resize = true;
+ }
+
+ if (isset($_REQUEST['maxsize']) && is_numeric($_REQUEST['maxsize']) && $_REQUEST['maxsize'] > 10
+ && max(array($width, $height)) > $_REQUEST['maxsize'])
+ {
+ $width = ($width > $height) ? round($_REQUEST['maxsize']) : 0;
+ $height = ($width > $height) ? 0 : round($_REQUEST['maxsize']);
+
+ $need_resize = true;
+ }
+
+ $Image_Toolbox->newImage($dst_dir . '/' . $upload_filename);
+
+ // Изменяем размер
+ if ($need_resize)
+ {
+ $Image_Toolbox->newOutputSize((int)$width, (int)$height);
+
+ $need_save = true;
+ }
+
+ // Добавляем водяной знак
+ if (!empty($watermark))
+ {
+ if (is_file(BASE_DIR . '/' . $watermark))
+ {
+ $Image_Toolbox->addImage(BASE_DIR . '/' . $watermark);
+ $Image_Toolbox->blend('right -10', 'bottom -10', IMAGE_TOOLBOX_BLEND_COPY, 100);
+ }
+ else
+ {
+ $Image_Toolbox->addText($watermark, BASE_DIR . '/inc/fonts/ft16.ttf', 16, '#709536', 'right -10', 'bottom -10');
+ }
+
+ $need_save = true;
+ }
+
+ if ($need_save) $Image_Toolbox->save($dst_dir . '/' . $upload_filename);
+
+ $oldumask = umask(0);
+ chmod($dst_dir . '/' . $upload_filename, 0777);
+ umask($oldumask);
+ }
+
+ /**
+ * Перемещение изображений галереи
+ *
+ * @param int $gallery_id - идентификатор галереи
+ * @param string $src_dir - директория источник
+ * @param string $dst_dir - директория назначения
+ */
+ function _galleryImageMove($gallery_id, $src_dir = '', $dst_dir = '')
+ {
+ global $AVE_DB;
+
+ $sql = $AVE_DB->Query("
+ SELECT
+ gallery_title,
+ gallery_folder,
+ gallery_thumb_method,
+ gallery_thumb_width,
+ gallery_thumb_height
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row = $sql->FetchRow();
+
+ if ($row == false) return;
+
+ $size = sprintf($this->_size, $row->gallery_thumb_method, $row->gallery_thumb_width, $row->gallery_thumb_height);
+
+ if (empty($src_dir) && empty($dst_dir))
+ {
+ $src_dir = prepare_fname($row->gallery_folder);
+ $dst_dir = $row->gallery_title == '' ? 'gal_' . $gallery_id : prepare_fname($row->gallery_title);
+ }
+ $src_path = rtrim(BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR . '/' . $src_dir, '/')) . '/';
+
+ if (! file_exists($src_path . '/')) return;
+
+ $dst_path = rtrim(BASE_DIR . '/' . trim(UPLOAD_GALLERY_DIR . '/' . $dst_dir, '/')) . '/';
+
+ if ($src_dir != '')
+ {
+ if (rename($src_path, $dst_path))
+ {
+ $AVE_DB->Query("
+ UPDATE " . PREFIX . "_module_gallery
+ SET gallery_folder = '" . addslashes($dst_dir) . "'
+ WHERE id = '" . $gallery_id . "'
+ ");
+
+ return;
+ }
+ }
+
+ if (! file_exists($dst_path . '/') && ! mkdir($dst_path . '/', 0777)) return;
+
+ if (! is_writable($dst_path . '/')) return;
+
+ $AVE_DB->Query("
+ UPDATE " . PREFIX . "_module_gallery
+ SET gallery_folder = '" . addslashes($dst_dir) . "'
+ WHERE id = '" . $gallery_id . "'
+ ");
+
+ $sql = $AVE_DB->Query("
+ SELECT image_filename
+ FROM " . PREFIX . "_module_gallery_images
+ WHERE gallery_id = '" . $gallery_id . "'
+ ");
+ while ($row = $sql->FetchRow())
+ {
+ $file = $src_path . '/' . $row->image_filename;
+ @copy($file, $dst_path . '/' . $row->image_filename);
+
+ $oldumask = umask(0);
+ chmod($dst_path . '/' . $row->image_filename, 0777);
+ umask($oldumask);
+
+ @unlink($file);
+ @unlink(make_thumbnail(array('link' => $file, 'size' => $size)));
+ }
+
+ @rmdir($src_path . '/' . THUMBNAIL_DIR);
+ }
+
+ /**
+ * Метод, предназначенный для создания копии Галереи
+ *
+ * @param int $gallery_id идентификатор Галереи
+ */
+ function galleryCopy($gallery_id)
+ {
+ global $AVE_DB, $AVE_Template;
+
+ // Выполняем запрос к БД на получение информации о копиремой галереи
+ $sql = $AVE_DB->Query("
+ SELECT *
+ FROM " . PREFIX . "_module_gallery
+ WHERE id = '" . $gallery_id . "'
+ ");
+ $row = $sql->fetchRow();
+
+ if ($row === false) return;
+
+ $gallery_title = (empty($_REQUEST['gallery_title'])) ? '' . addslashes($row->gallery_title) . '' : $_REQUEST['gallery_title'];
+
+ // Выполняем запрос к БД на добавление новой галереи на основании полученных ранее данных
+ $AVE_DB->Query("
+ INSERT " . PREFIX . "_module_gallery
+ SET
+ gallery_title = '" . $gallery_title . "',
+ gallery_description = '" . $row->gallery_description . "',
+ gallery_author_id = '" . (int)$_SESSION['user_id'] . "',
+ gallery_created = '" . time() . "',
+ gallery_thumb_width = '" . $row->gallery_thumb_width . "',
+ gallery_thumb_height = '" . $row->gallery_thumb_height . "',
+ gallery_thumb_method = '" . $row->gallery_thumb_method . "',
+ gallery_image_on_line = '" . $row->gallery_image_on_line . "',
+ gallery_image_on_page = '" . $row->gallery_image_on_page . "',
+ gallery_watermark = '" . $row->gallery_watermark . "',
+ gallery_folder = '',
+ gallery_orderby = '" . addslashes($row->gallery_orderby) . "',
+ gallery_script = '" . addslashes($row->gallery_script) . "',
+ gallery_image_template = '" . addslashes($row->gallery_image_template) . "'
+ ");
+
+ // Сохраняем системное сообщение в журнал
+ reportLog($AVE_Template->get_config_vars('GalleryReportCopy') . ' (' . $row->gallery_title . ')');
+
+ // Выполянем переход к списку галерей
+ header('Location:index.php?do=modules&action=modedit&mod=gallery&moduleaction=1&cp=' . SESSION);
+ exit;
+ }
+
+}
+
+?>
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..4ca25aa
--- /dev/null
+++ b/index.php
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/info.php b/info.php
new file mode 100644
index 0000000..88ee959
--- /dev/null
+++ b/info.php
@@ -0,0 +1,20 @@
+ 'gallery',
+ 'ModuleVersion' => '3.26.4',
+ 'ModuleAutor' => 'AVE.cms Team',
+ 'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms',
+ 'ModuleStatus' => 1,
+ 'ModuleIsFunction' => 1,
+ 'ModuleTemplate' => 0,
+ 'ModuleAdminEdit' => 1,
+ 'ModuleFunction' => 'mod_gallery',
+ 'ModuleTag' => '[mod_gallery:XXX-Лимит]',
+ 'ModuleTagLink' => null,
+ 'ModuleAveTag' => '#\\\[mod_gallery:([\\\d-]+)]#',
+ 'ModulePHPTag' => ""
+ );
+?>
\ No newline at end of file
diff --git a/js/browserplus-min.js b/js/browserplus-min.js
new file mode 100644
index 0000000..626f324
--- /dev/null
+++ b/js/browserplus-min.js
@@ -0,0 +1,8 @@
+/*
+ * browserplus.js
+ *
+ * Provides a gateway between user JavaScript and the BrowserPlus platform
+ *
+ * Copyright 2007-2009 Yahoo! Inc. All rights reserved.
+ */
+BrowserPlus=(typeof BrowserPlus!="undefined"&&BrowserPlus)?BrowserPlus:(function(){var P=false;var F="__browserPlusPluginID";var E="uninitialized";var G=[];var D="application/x-yahoo-browserplus_2";var J,K,L,H,A;return{initWhenAvailable:function(R,S){setTimeout(function(){try{navigator.plugins.refresh(false)}catch(T){}BrowserPlus.init(R,function(U){if(U.success){S(U)}else{BrowserPlus.initWhenAvailable(R,S)}})},1000)},clientSystemInfo:function(){return I()},listActiveServices:function(R){if(R==null||R.constructor!=Function){throw new Error("BrowserPlus.services() invoked without required callback parameter.")}return N().EnumerateServices(R)},getPlatformInfo:function(){if(N()===null){throw new Error("BrowserPlus.getPlatformInfo() invoked, but init() has not completed successfully.")}return N().Info()},isServiceLoaded:function(S,R){return((S!=undefined&&BrowserPlus.hasOwnProperty(S))&&(R==undefined||BrowserPlus[S].hasOwnProperty(R)))},describeService:function(S,R){if(R==null||R.constructor!=Function){throw new Error("BrowserPlus.services() invoked without required callback parameter")}if(N()===null){throw new Error("BrowserPlus.describeService() invoked, but init() has not completed successfully.")}return N().DescribeService(S,R)},isServiceActivated:function(S,R){return N().DescribeService(S,(function(){var T=R;return function(U){T(U.success)}})())},isInitialized:function(){return(E==="succeeded")},require:function(S,T){if(T==null||T.constructor!=Function){throw new Error("BrowserPlus.require() invoked without required callback parameter")}var R=function(V){if(V.success){var W=[];for(var U=0;U';document.documentElement.appendChild(S);P=true;return true}function C(){if(N()!=null){return true}try{var R=document.createElement("object");R.id=F;R.type=D;R.style.display="none";document.body.appendChild(R);document.getElementById(F).Ping();P=true;return true}catch(T){try{document.body.removeChild(R)}catch(S){}}return false}function N(){if(P){return document.getElementById(F)}return null}function B(){return(I().browser=="Explorer")}function M(T){T=T.value;var V=T.name;var R=T.versionString;if(!BrowserPlus[V]){BrowserPlus[V]={};BrowserPlus[V].corelet=V;BrowserPlus[V].version=R}if(!BrowserPlus[V][R]){BrowserPlus[V][R]={};BrowserPlus[V][R].corelet=V;BrowserPlus[V][R].version=R}if(V=="core"){BrowserPlus[V].version=R}if(T.functions){for(var S=0;S
\ No newline at end of file
diff --git a/lang/ru.txt b/lang/ru.txt
new file mode 100644
index 0000000..02eb0ac
--- /dev/null
+++ b/lang/ru.txt
@@ -0,0 +1,144 @@
+[name]
+MODULE_NAME = "Галерея"
+MODULE_DESCRIPTION = "Gallery + Watermark Внимание! У директорий uploads/gallery/.upload/ и uploads/gallery/.temp/ должны быть права на запись! Вы можете ограничить количество выводимых изображений, указав после Gallery-ID следующее: -3 (в этом случае количество будет ограничено тремя изображениями на страницу)"
+
+[module]
+NoTitle = "Без названия"
+NoDescr = "Описания нет. Извините."
+MoreImages = "» Ещё изображения... "
+WinClose = "Закрыть окно"
+
+[admin]
+ModName = "Галерея"
+ModTitle = "В данном разделе находится список всех галерей."
+GalleryList = "Список галерей"
+
+MaxImagesPage = "Количество миниатюр на странице"
+Shrink = "Уменьшать изображения"
+To100 = "100%"
+To75 = "до 75% от оригинала"
+To50 = "до 50% от оригинала"
+To25 = "до 25% от оригинала"
+
+
+ModSettingGal = "Общие настройки"
+ModSettingGalT = "В данном разделе приведены общие настройки данной галереи."
+
+Upload = "Добавление изображений"
+UploadProg = "Обработка изображений"
+
+Overview = "Просмотр изображений"
+OverviewT = "В данном разделе приведен список изображений данной галереи."
+
+UploadProgT = "Создаются миниатюры..."
+FilePrev = "Предпросмотр"
+FileTitle = "Название изображения"
+FileDesc = "Описание изображения"
+CheckboxCreate = "Если поставить галочку и нажать кнопку Cоздать папку, то для данной галереи создается своя папка. Все картинки принадлежащие этой галерее переместятся в данную папку."
+Folder = "Папка"
+CreateFolder = "Создать папки"
+GalleryFolder = "Имя папки(латинскими буквами) "
+GalleryFolderP = "Имя папки"
+GalleryFolderDesc = "Если вы хотите удалить персональную папку галереи и перенести все файлы галереи в папку "uploads", то оставьте поле пустым"
+NewGallery = "Добавить новую галерею"
+GalleryTitle = "Название галереи"
+FolderExists = "Такая папка уже существует"
+EmptyGalleryTitle = "Укажите название галереи"
+GalleryDesc = "Описание галереи"
+MaxWidth = "Ширина миниатюр (в пикселях)"
+MaxHeight = "Высота миниатюр (в пикселях)"
+MaxImagesERow = "Количество миниатюр в строке"
+MaxWidthWarn = "Внимание! Изменения размеров, ранее загруженных изображений, выполняется при просмотре изображений галереи в панели администратора!"
+MaxHeightWarn = "Внимание! Изменения размеров, ранее загруженных изображений, выполняется при просмотре изображений галереи в панели администратора!"
+ThumbMethod = "Метод формирования миниатюр"
+Crop = "Crop"
+Resize = "Resize"
+GalleryAuthor = "Автор"
+Gcreated = "Создана"
+IName = "Название изображения"
+ISelect = "Выберите изображение"
+IncImages = "Изображений"
+MarDel = "Отметить для удаления"
+MarAllDel = "Отметить все для удаления"
+MarAct = "Активно"
+MarAllAct = "Отметить все"
+LinknewGal = "Добавить новую галерею"
+ImagesMore = "Загрузить изображения в галерею"
+GalView = "Вернуться к списку галерей"
+CpTag = "Тег в системе"
+AddnewImages = "Добавить изображения"
+EditGallery = "Редактировать галерею"
+DeleteGallery = "Удалить галерею"
+UploadInfo = "Пожалуйста, используйте только следующие типы файлов:"
+DeleteGalleryC = "Вы уверены, что хотите удалить данную галерею?"
+MoreInfos = "Дополнительная информация"
+Filesize = "Размер файла"
+Filename = "Имя файла"
+Uploader = "Опубликовал"
+UploadOn = "Дата загрузки"
+Showdescr = "Показывать описание изображения"
+ShowSize = "Показывать размер изображения"
+ShowHeader = "Показывать название изображения"
+TypeOut = "Тип вывода изображений"
+TypeOut1 = "Только миниатюры"
+TypeOut2 = "PopUp"
+TypeOut3 = "LightBox"
+TypeOut4 = "LightView"
+TypeOut5 = "Sexy Lightbox"
+TypeOut6 = "Highslide"
+TypeOut7 = "Настраиваемый тип"
+ErrorFolderStart = "Ошибка! Директория ""
+ErrorFolderEnd = "" отсутствует или имеет права только для чтения. Необходимо создать дирректорию и/или установить права доступа (Unix: chmod 777) "
+Watermark = "Имя Watermark-файла"
+ButtonSave = "Сохранить"
+ButtonSaveEdit = "Сохранить и продолжить редактировать"
+ButtonAdd = "Добавить"
+DateFormat = "%d-%m-%Y г. в %H:%M"
+Actions = "Действия"
+LoadFromFolder = "Загрузить из папки /temp/"
+Position = "Позиция"
+ImageView = "Просмотр изображений"
+UserProfile = "Учетная запись пользователя"
+MaxSize = "Максимальный размер"
+OrderImage = "Порядок сортировки"
+OrderPosition = "по позиции"
+OrderDateAsc = "по дате"
+OrderDateDesc = "по дате в обратном порядке"
+OrderTitleAsc = "по названию"
+OrderTitleDesc = "по названию в обратном порядке"
+GalleryScripts = "Основной шаблон оформления галереи"
+ImageTpl = "Шаблон вывода изображения"
+GalleryScriptsTag = "Системные теги шаблона скриптов"
+ImageTplTag = "Системные теги шаблона изображения"
+GalleryTagId = "Системный тег идентификатора галереи"
+GalleryTagFolder = "Системный тег имени папки галереи"
+GalleryTagImgId = "Системный тег идентификатора изображения"
+GalleryTagImgTitle = "Системный тег названия изображения"
+GalleryTagImgDesc = "Системный тег описания изображения"
+GalleryTagImgFilename = "Системный тег имени файла изображения"
+GalleryTagImgThumb = "Системный тег миниатюры изображения"
+GalleryTagTitl = "Системный тег названия галереи"
+GalleryTagDesc = "Системный тег описания галереи"
+GalleryTagPath = "Системный тег определяющий корень установки"
+GalleryTagLink = "Ссылка на документ"
+GalleryTags = "HTML tags"
+GalleryIfElse = "Условия"
+GallerySample = "Пример"
+GallerySample1 = "четный"
+GallerySample2 = "нечетный"
+GallerySetParam = "Параметр"
+GallerySetVal = "Значение"
+GalleryTagContent = "Системный тег отвечающий за вывод элементов галереи, указанных в поле «Шаблон вывода изображения»"
+GalleryTagPages = "Системный тег отвечающий за вывод постраничной навигации для галереи (< 1 2 3 >)"
+GalleryTagImgSize = "Системный тег размера файла изображения (Kb)"
+GallerySeppLine = "То, что будет выводится после N миниатюр в строке (см. «Количество миниатюр в строке»)"
+GalleryMediaPath = "Системный тег определяющий путь до папки с шаблономНапример: [tag:mediapath]images/logo.gif"
+GalleryCopy = "Копировать галерею"
+GalleryCopyT = "Пожалуйста, укажите название галереи."
+CopyGallery = "Копировать галерею"
+GallerryNoItems = "В настоящий момент не существует ни одной галереи."
+SavedOk = "Настройки успешно сохранены"
+Or = " или "
+LinkToDoc = "Связать с существующим документом"
+LinkDoc = "Ссылка на документ"
+GalleryReportCopy = "Создал копию галерии"
\ No newline at end of file
diff --git a/module.php b/module.php
new file mode 100644
index 0000000..7ee533b
--- /dev/null
+++ b/module.php
@@ -0,0 +1,112 @@
+config_load($lang_file, 'module');
+
+ $gallery->galleryShow($tpl_dir, $gallery_id, $lim);
+}
+
+if (!defined('ACP') && isset($_REQUEST['module']) && $_REQUEST['module'] == 'gallery')
+{
+ require_once(BASE_DIR . '/modules/gallery/class/gallery.php');
+ $gallery = new Gallery;
+
+ $tpl_dir = BASE_DIR . '/modules/gallery/templates/';
+ $lang_file = BASE_DIR . '/modules/gallery/lang/' . $_SESSION['user_language'] . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'module');
+
+ define('ONLYCONTENT', 1);
+
+ if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'allimages')
+ {
+ $AVE_Template->assign('tpl_dir', BASE_DIR . '/modules/gallery/templates');
+ $AVE_Template->assign('theme_folder', (defined('THEME_FOLDER') ? THEME_FOLDER : DEFAULT_THEME_FOLDER));
+ $gallery->galleryShow($tpl_dir, (int)$_REQUEST['gallery'], '', 1);
+ }
+ else
+ {
+ $gallery->galleryImageShow($tpl_dir, (int)$_REQUEST['image']);
+ }
+}
+
+//=======================================================
+// Действия в админ-панели
+//=======================================================
+if (defined('ACP') && !empty($_REQUEST['moduleaction']))
+{
+ require_once(BASE_DIR . '/modules/gallery/class/gallery.php');
+ $gallery = new Gallery;
+
+ $tpl_dir = BASE_DIR . '/modules/gallery/templates/';
+ $lang_file = BASE_DIR . '/modules/gallery/lang/' . $_SESSION['admin_language'] . '.txt';
+
+ $AVE_Template->config_load($lang_file, 'admin');
+
+ switch($_REQUEST['moduleaction'])
+ {
+ case '1': // Просмотр списка галерей
+ $gallery->galleryListShow($tpl_dir);
+ break;
+
+ case 'add': // Добавить изображения в галерею
+ define('IMAGE_TOOLBOX_DEFAULT_JPEG_QUALITY', 75);
+ include_once(BASE_DIR . '/class/class.thumbnail.php');
+ $Image_Toolbox = new Image_Toolbox;
+ $gallery->galleryImageUploadForm($tpl_dir, intval($_REQUEST['id']));
+ break;
+
+ case 'showimages': // Просмотр изображений галереи
+ $gallery->galleryImageListShow($tpl_dir, intval($_REQUEST['id']));
+ break;
+
+ case 'new': // Создать новую галерею
+ $gallery->galleryNew();
+ break;
+
+ case 'copygallery': // Копирование галереи
+ $gallery->galleryCopy(intval($_REQUEST['id']));
+ break;
+
+ case 'delgallery': // Удаление галереи
+ $gallery->galleryDelete(intval($_REQUEST['id']));
+ break;
+
+ case 'editgallery': // Редактирование галереи
+ $gallery->galleryEdit($tpl_dir, intval($_REQUEST['id']));
+ break;
+
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/sql.php b/sql.php
new file mode 100644
index 0000000..4d7e441
--- /dev/null
+++ b/sql.php
@@ -0,0 +1,106 @@
+
\ No newline at end of file
diff --git a/templates/admin_gallery_edit.tpl b/templates/admin_gallery_edit.tpl
new file mode 100644
index 0000000..ae88ddf
--- /dev/null
+++ b/templates/admin_gallery_edit.tpl
@@ -0,0 +1,401 @@
+
{#ModSettingGal#}
+
+
+
+
+
+
+
+
+
+
+{include file="$codemirror_connect"}
+{include file="$codemirror_editor" conn_id="" textarea_id='gallery_script' ctrls='$("#gallery_form").ajaxSubmit(sett_options);' height=280}
+{include file="$codemirror_editor" conn_id="2" textarea_id='gallery_image_template' ctrls='$("#gallery_form").ajaxSubmit(sett_options);' height=300}
+
+
\ No newline at end of file
diff --git a/templates/admin_gallery_image.tpl b/templates/admin_gallery_image.tpl
new file mode 100644
index 0000000..9c02dd0
--- /dev/null
+++ b/templates/admin_gallery_image.tpl
@@ -0,0 +1,168 @@
+
+
+
{#Overview#}
+
+
+
+
+
+
+
+{if $page_nav}
+
+{/if}
+
+
+
+{if $page_nav}
+
+{/if}
diff --git a/templates/admin_gallery_list.tpl b/templates/admin_gallery_list.tpl
new file mode 100644
index 0000000..54713a8
--- /dev/null
+++ b/templates/admin_gallery_list.tpl
@@ -0,0 +1,204 @@
+
+
{#ModName#}
+
+
+
+
+
+
+
+
+
+
+{if $page_nav}
+
+{/if}
+
+
+
+{if $alert == "folder_exists"}
+
+{/if}
\ No newline at end of file
diff --git a/templates/admin_gallery_upload_form.tpl b/templates/admin_gallery_upload_form.tpl
new file mode 100644
index 0000000..c5fa35c
--- /dev/null
+++ b/templates/admin_gallery_upload_form.tpl
@@ -0,0 +1,129 @@
+ {* *}
+
+
+
+
+
+
+
+
{#Upload#}
+
+
+
+
+
+
+{if $not_writeable == 1}
+
+ {#ErrorFolderStart#}{$upload_dir|escape}{#ErrorFolderEnd#}
+
+{else}
+
+
+
+
+
+
+
+
+
+
+{/if}
\ No newline at end of file
diff --git a/templates/admin_gallery_upload_form_finish.tpl b/templates/admin_gallery_upload_form_finish.tpl
new file mode 100644
index 0000000..7bb6989
--- /dev/null
+++ b/templates/admin_gallery_upload_form_finish.tpl
@@ -0,0 +1,37 @@
+
{#UploadProg#}
+
+
+
+
+
+
+
diff --git a/upload.php b/upload.php
new file mode 100644
index 0000000..36bf65e
--- /dev/null
+++ b/upload.php
@@ -0,0 +1,131 @@
+
\ No newline at end of file