что уж там конкретно менять я не помню..
<?php
/******************************************************************************
*
* EASY 2 GALLERY BY Cx2 <[email protected]>
* VERSION 1.3
*
******************************************************************************/
require './assets/modules/easy2/config.easy2gallery.php';
// GALLERY ID
$gid = (!empty($gid) && is_numeric($gid)) ? $gid : 1;
$gid = (!empty($_GET['gid']) && is_numeric($_GET['gid'])) ? (int) $_GET['gid'] : $gid;
// WIDTH
$w = (!empty($w) && is_numeric($w)) ? (int) $w : $e2g['w'];
// HEIGHT
$h = (!empty($h) && is_numeric($h)) ? (int) $h : $e2g['h'];
// JPEG QUALITY
$thq = (!empty($thq) && $thq<=100 && $thq>=0) ? (int) $thq : $e2g['thq'];
// NAME LENGHT
$name_len = (!empty($name_len) && is_numeric($name_len)) ? (int) $name_len : $e2g['name_len'];
// DIRECTORY NAME LENGHT
$cat_name_len = (!empty($cat_name_len) && is_numeric($cat_name_len)) ? (int) $cat_name_len : $e2g['cat_name_len'];
// COLLS
$colls = (!empty($colls) && is_numeric($colls)) ? (int) $colls : $e2g['colls'];
// LIMIT
$limit = (!empty($limit) && is_numeric($limit)) ? (int) $limit : $e2g['limit'];
// GLIB
$glib = (!empty($glib)) ? $glib : $e2g['glib'];
// COMMENTS
$ecm = (!empty($ecm) && is_numeric($ecm)) ? $ecm : $e2g['ecm'];
// COMMENTS LIMIT
$ecl = (!empty($ecl) && is_numeric($ecl)) ? (int) $ecl : $e2g['ecl'];
// PAGE NUMBER
$gpn = (!empty($_GET['gpn']) && is_numeric($_GET['gpn'])) ? (int) $_GET['gpn'] : 0;
// ORDER BY
$orderby = (!empty($orderby)) ? $orderby : $e2g['orderby'];
$orderby = preg_replace('/[^_a-z]/i', '', $orderby);
// ORDER
$order = (!empty($order)) ? $order : $e2g['order'];
$order = preg_replace('/[^a-z]/i', '', $order);
// GALLERY CSS
$css = (!empty($css)) ? str_replace('../', '', $css) : $e2g['css'];
// GALLERY TEMPLATE
$tpl = (!empty($tpl)) ? str_replace('../', '', $tpl) : $e2g['tpl'];
// DIR TEMPLATE
$dir_tpl = (!empty($dir_tpl)) ? str_replace('../', '', $dir_tpl) : $e2g['dir_tpl'];
// THUMB TEMPLATE
$thumb_tpl = (!empty($thumb_tpl)) ? str_replace('../', '', $thumb_tpl) : $e2g['thumb_tpl'];
// THUMB RAND TEMPLATE
$rand_tpl = (!empty($rand_tpl)) ? str_replace('../', '', $rand_tpl) : $e2g['rand_tpl'];
// COMMENTS TEMPLATE
// $comments_tpl = (!empty($comments_tpl)) ? str_replace('../', '', $comments_tpl) : $e2g['comments_tpl'];
// CODE
if ($orderby == 'random' && $limit == 1) {
// ?????? ?????? RAND
if (file_exists($rand_tpl)) {
$rand_tpl = file_get_contents($rand_tpl);
} elseif (!empty($modx->chunkCache[$rand_tpl])) {
$rand_tpl = $modx->chunkCache[$rand_tpl];
} else {
return 'Template not found!';
}
$res = mysql_query('SELECT * FROM '.$modx->db->config['table_prefix'].'easy2_files '
. 'WHERE status = 1 ORDER BY RAND() LIMIT 1');
$l = mysql_fetch_array($res, MYSQL_ASSOC);
$pos = strrpos($l['filename'], '.');
$ext = substr($l['filename'], $pos);
$l['title'] = $l['name'];
if (strlen($l['name']) > $name_len) $l['name'] = substr($l['name'], 0, $name_len-2).'...';
elseif ($l['name'] == '') $l['name'] = ' ';
$l['w'] = $w;
$l['h'] = $h;
$path = get_path($l['dir_id']);
if (count($path) > 1) {
unset($path[1]);
$path = implode('/', array_keys($path)).'/';
} else {
$path = '';
}
$l['src'] = get_thumb($e2g['dir'], $path.'/'.$l['id'].$ext, $w, $h, $thq);
return filler($rand_tpl, $l);
}
$_e2g = array('content'=>'','pages'=>'','parent_id'=>0,'back'=>'');
$path = get_path($gid);
$_e2g['cat_name'] = end($path);
if (count($path) > 1) {
end($path);
prev($path);
$_e2g['parent_id'] = key($path);
$_e2g['parent_name'] = $path[$_e2g['parent_id']];
unset($path[1]);
$path = implode('/', array_keys($path)).'/';
} else {
$path = '';
}
// FOR comments
$_SESSION['manager_language'] = $modx->config['manager_language'];
// CSS ??????? ?????? ???????
if (file_exists($css)) {
$css = file_get_contents($css);
} elseif (!empty($modx->chunkCache[$css])) {
$css = $modx->chunkCache[$css];
}
if ($glib == 'highslide') {
$modx->regClientStartupScript('libs/highslide/highslide-with-gallery.js', 0);
$modx->regClientStartupScript('<script type="text/javascript">
hs.graphicsDir = "libs/highslide/graphics/";
hs.align = "center";
hs.transitions = ["expand", "crossfade"];
hs.outlineType = "glossy-dark";
hs.fadeInOut = true;
//hs.dimmingOpacity = 0.75;
// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
//slideshowGroup: group1,
interval: 5000,
repeat: false,
useControls: true,
fixedControls: true,
overlayOptions: {
opacity: .75,
position: "top center",
hideOnMouseOut: true
}
});
</script>
<style type="text/css">
<!--
'.file_get_contents('./libs/highslide/highslide.css').'
'.$css.'
-->
</style>
', 1);
}
$i = 0;
// SUBDIRS & THUMBS FOR SUBDIRS
$res = mysql_query('SELECT A.*, F.* '
. 'FROM '.$modx->db->config['table_prefix'].'easy2_dirs A, '
. $modx->db->config['table_prefix'].'easy2_dirs B, '
. $modx->db->config['table_prefix'].'easy2_files F '
. 'WHERE B.cat_id='.$gid.' '
. 'AND A.cat_left >= B.cat_left '
. 'AND A.cat_right <= B.cat_right '
. 'AND A.cat_level = B.cat_level + 1 '
. 'AND A.cat_visible = 1 '
. 'AND F.dir_id = A.cat_id '
. 'GROUP BY A.cat_id '
. 'ORDER BY A.cat_name');
$_e2g['content'] = '<table class="e2g"><tr>';
// ?????? ??????????
if (file_exists($dir_tpl)) {
$dir_tpl = file_get_contents($dir_tpl);
} elseif (!empty($modx->chunkCache[$dir_tpl])) {
$dir_tpl = $modx->chunkCache[$dir_tpl];
} else {
return 'Directory template not found!';
}
while ($l = mysql_fetch_array($res, MYSQL_ASSOC)) {
if ($i % $colls == 0) $_e2g['content'] .= '</tr><tr>';
$pos = strrpos($l['filename'], '.');
$ext = substr($l['filename'], $pos);
$l['title'] = $l['cat_name'];
if (strlen($l['cat_name']) > $cat_name_len) $l['cat_name'] = substr($l['cat_name'], 0, $cat_name_len-1).'...';
elseif ($l['cat_name'] == '') $l['cat_name'] = ' ';
$l['w'] = $w;
$l['h'] = $h;
$l['src'] = get_thumb($e2g['dir'], $path.$l['cat_id'].'/'.$l['id'].$ext, $w, $h, $thq);
$_e2g['content'] .= '<td>'.filler($dir_tpl, $l).'</td>';
$i++;
}
$_e2g['content'] .= '</tr></table>';
// THUMBS FOR CURRENT DIR
$res = mysql_query('SELECT * FROM '.$modx->db->config['table_prefix'].'easy2_files '
. 'WHERE dir_id='.$gid.' '
. 'AND status = 1 '
. 'ORDER BY '. ( $orderby == 'random' ? 'RAND() ' : $orderby.' '.$order.' ')
. 'LIMIT '.($gpn * $limit).', '.$limit);
$i = 0;
$_e2g['content'] .= '<table class="e2g"><tr>';
// ?????? ??????
if (file_exists($thumb_tpl)) {
$thumb_tpl = file_get_contents($thumb_tpl);
} elseif (!empty($modx->chunkCache[$thumb_tpl])) {
$thumb_tpl = $modx->chunkCache[$thumb_tpl];
} else {
return 'Thumbnail template not found!';
}
while ($l = mysql_fetch_array($res, MYSQL_ASSOC)) {
if ($i % $colls == 0) $_e2g['content'] .= '</tr><tr>';
$pos = strrpos($l['filename'], '.');
$ext = substr($l['filename'], $pos);
$l['title'] = $l['name'];
if (strlen($l['name']) > $name_len) $l['name'] = substr($l['name'], 0, $name_len-2).'...';
elseif ($l['name'] == '') $l['name'] = ' ';
$l['w'] = $w;
$l['h'] = $h;
$l['src'] = get_thumb($e2g['dir'], $path.$l['id'].$ext, $w, $h, $thq);
if ($e2g['ecm'] == 1) {
$l['com'] = 'e2gcom'.($l['comments']==0?0:1);
$l['comments'] = '<a href="assets/modules/easy2/comments.easy2gallery.php?id='.$l['id'].'" onclick="return hs.htmlExpand(this, { objectType: \'iframe\'} )">'.$l['comments'].'</a>';
} else {
$l['comments'] = '';
$l['com'] = 'not_display';
}
$_e2g['content'] .= '<td>'.filler($thumb_tpl, $l).'</td>';
$i++;
}
$_e2g['content'] .= '</tr></table>';
// ?????? ?? ????????
$res = mysql_query('SELECT COUNT(*) FROM '.$modx->db->config['table_prefix'].'easy2_files WHERE dir_id='.$gid);
list($cnt) = mysql_fetch_row($res);
if ($cnt > $limit) {
$_e2g['pages'] = '<div class="e2gpnums">';
$i = 0;
while ($i*$limit < $cnt) {
if ($i == $gpn) $_e2g['pages'] .= '<b>'.($i+1).'</b> ';
else $_e2g['pages'] .= '<a href="[~[*id*]~]&gid='.$gid.'&gpn='.$i.'">'.($i+1).'</a> ';
$i++;
}
$_e2g['pages'] .= '</div>';
}
// {title} $modx->documentObject['pagetitle'];
// ?????? ??????????? ? ???????????? ??????????
if ($_e2g['parent_id'] > 0) {
$_e2g['back'] = '<p class="e2gback">‹‹ <a href="[~[*id*]~]&gid='.$_e2g['parent_id'].'">'.$_e2g['parent_name'].'</a></p>';
}
// ?????? ???????
if (file_exists($tpl)) {
$tpl = file_get_contents($tpl);
} elseif (!empty($modx->chunkCache[$tpl])) {
$tpl = $modx->chunkCache[$tpl];
} else {
return 'Gallery template not found!';
}
return filler($tpl, $_e2g);
function get_thumb ($gdir, $path, $w = 150, $h = 150, $thq=80, $resize_type = 'inner') {
global $modx;
if (empty($path)) return false;
$thumb_path = '_thumbnails/'.substr($path, 0, strrpos($path, '.')).'_'.$w.'x'.$h.'.jpg';
if (!file_exists($gdir.$thumb_path) && file_exists($gdir.$path)) {
$i = getimagesize($gdir.$path);
if ($i[2] == 1) $im = imagecreatefromgif ($gdir.$path);
elseif ($i[2] == 2) $im = imagecreatefromjpeg ($gdir.$path);
elseif ($i[2] == 3) $im = imagecreatefrompng ($gdir.$path);
else return false;
if ($i[0]/$w > 2 || $i[1]/$h > 2) {
$tmp_w = $w*2;
$tmp_h = round($i[1] * ($tmp_w/$i[0]));
$temp = imagecreatetruecolor ($tmp_w, $tmp_h);
imagecopyresized ($temp, $im, 0, 0, 0, 0, $tmp_w, $tmp_h, $i[0], $i[1]);
$i[0] = $tmp_w;
$i[1] = $tmp_h;
imagedestroy($im);
$im = $temp;
}
if ($resize_type == 'inner') {
// 'inner' - ???????? ??? ??????? ?? ????????
// ????????
$x = $y = 0;
// ??????? ?????????? ????????
$w2 = $w;
$h2 = $h;
if ($i[0] > $i[1]) {
$w2 = round($i[0] * $h / $i[1]);
if ($w2 > $w) $x = ($w2 - $w)/2 * (-1);
} else {
$h2 = round($i[1] * $w / $i[0]);
if ($h2 > $h) $y = ($h2 - $h)/2 * (-1);
}
$pic = imagecreatetruecolor($w, $h);
$bgc = imagecolorallocate($pic, 255, 255, 255);
imagefill($pic, 0, 0, $bgc);
imagecopyresampled($pic, $im, $x, $y, 0, 0, $w2, $h2, $i[0], $i[1]);
} else {
// 'resize' - ??????????????? ????????? ??????? ??? ??????? ?? ????????
if ($i[0] > $i[1]) $h = round($i[1] * $w / $i[0]);
else $w = round($i[0] * $h / $i[1]);
$pic = imagecreatetruecolor($w, $h);
$bgc = imagecolorallocate($pic, 255, 255, 255);
imagefill($pic, 0, 0, $bgc);
imagecopyresampled($pic, $im, 0, 0, 0, 0, $w, $h, $i[0], $i[1]);
}
// ???????? ???????????
$dirs = explode('/', $path);
$npath = $gdir.'_thumbnails';
for ($c = 0; $c < count($dirs) - 1; $c++) {
$npath .= '/'.$dirs[$c];
if (is_dir($npath)) continue;
if(!mkdir($npath)) return false;
@chmod($npath, octdec($modx->config['new_folder_permissions']));
}
imagejpeg($pic, $gdir.$thumb_path, $thq);
@chmod($gdir.$thumb_path, octdec($modx->config['new_file_permissions']));
imagedestroy($pic);
imagedestroy($im);
}
return $gdir.$thumb_path;
}
function get_path ($id) {
global $modx;
$result = array();
$res = mysql_query('SELECT A.cat_id, A.cat_name FROM '.$modx->db->config['table_prefix'].'easy2_dirs A, '.$modx->db->config['table_prefix'].'easy2_dirs B WHERE B.cat_id='.$id.' AND B.cat_left BETWEEN A.cat_left AND A.cat_right ORDER BY A.cat_left');
while ($l = mysql_fetch_row($res)) {
$result[$l[0]] = $l[1];
}
if (empty($result)) return null;
return $result;
}
function filler ($tpl, $data, $prefix = '[+easy2:', $suffix = '+]') {
foreach($data as $k => $v) {
$tpl = str_replace($prefix.(string)$k.$suffix, (string)$v, $tpl);
}
return $tpl;
}
?>.e2gtitle {font:bold 14px Tahoma; display:none}
.e2gback {font:bold 10px Tahoma; display:none}
.e2g {font:11px Tahoma; margin-left:0px}
.e2g td {vertical-align:bottom;text-align:center;padding:7px}
.e2g th {font-weight:normal;height:13px}
.e2g a {color:#808080;text-decoration:none}
.e2gcom0, .e2gcom1 {font:10px Tahoma;float:right; width:13px;}
.e2gcom0 {background: url(assets/modules/easy2/icons/bg_com0.gif) no-repeat top right;}
.e2gcom1 {background: url(assets/modules/easy2/icons/bg_com1.gif) no-repeat top right;}
.e2gcom0 a {color:#808080;text-decoration:none}
.e2gcom1 a {color:#FF8040;text-decoration:none}
.e2gpnums {font:12px Verdana; color:gray; margin-top:20px;text-align:center;}
.e2gpnums a {background:#F4F4F4;border:1px solid #E8E8E8;color:gray}
.e2gpnums a:hover {background:#B3EC6C;border:1px solid #83D71C;color:white;text-decoration:none}
.e2gpnums a, .e2gpnums b {padding:3px 6px;}
.not_display {display:none}
.boxcontent {padding:1px 5px;}
.boxcontent img {margin-bottom:3px; border:1px solid white}
.thumb .b2, .thumb .b3, .thumb .b4, .thumb .b4b, .thumb .b3b, .thumb .b2b, .thumb .boxcontent { background:#F5F5F5;}
.dir .b2, .dir .b3, .dir .b4, .dir .b4b, .dir .b3b, .dir .b2b, .dir .boxcontent { background:#FFF0CC;}
.b1, .b2, .b3, .b4, .b1b, .b2b, .b3b, .b4b { display:block; overflow:hidden; font-size:1px; }
.b1, .b2, .b3, .b1b, .b2b, .b3b { height:1px; }
.b2, .b3, .b4, .b4b, .b3b, .b2b, .boxcontent { border-left:1px solid #E0E0E0; border-right:1px solid #E0E0E0; display:block; }
.b1, .b1b { margin:0 5px; background:#E0E0E0; }
.b3, .b3b { margin:0 2px; }
.b4, .b4b { height:2px; margin:0 1px; }
.dir .b2, .dir .b3, .dir .b4, .dir .b4b, .dir .b3b, .dir .b2b, .dir .boxcontent { border-left:1px solid #FFD2A6; border-right:1px solid #FFD2A6; display:block; }
.dir .b1, .dir .b1b { margin:0 5px; background:#FFD2A6; }
.b2, .b2b, .dir .b2, .dir .b2b { margin:0 3px; border-width:0 2px; }
.boxcontent div b a { color:#333 }
.boxcontent div b a:hover { color:#999 }