вот походу файл от етого:
<?php
// Ice Image Module //
/*
-----------------------------------------------------------------------
| |
| Date: August, 2008 |
| Author: Markus Donhauser, <plasmodino@gmx.net> |
|
http://joomlacode.org/gf/project/ice/ |
| Copyright: copyright (C) 2008 by Markus Donhauser |
| License: GPL |
| Version: 0.5 RC 1 |
| |
-----------------------------------------------------------------------
*/
(defined( '_VALID_MOS' )||defined( '_JEXEC' )) or die( 'Direct Access to this location is not allowed.' );
if (!function_exists('is_search')) {
function is_search(&$query,$returnMedia=16,$lim=100) {
global $icenv;
$medialist = array();
$pols = &new policies();
$limit = $lim*$returnMedia; $page = 0; $nrOfMedia = 0;
do {
$icenv->db->setQuery($query." LIMIT $page,$returnMedia");
$result = $icenv->db->query();
if ($result!==FALSE && mysql_num_rows($result)>0) {
while ($row = mysql_fetch_object($result)) {
if ($nrOfMedia<$returnMedia) {
$pols->loadPolicies($row->uid,$row->imgmembers,array('mview','mremove','mopen'),true);
if ($pols->isAllowed('mview')) {
$medialist[] = array($row->id,$row->catdir,$row->cname,$row->catuid,$row->catmembers,$pols->isAllowed('mopen')); $nrOfMedia++;
}
} else {
while ($row = mysql_fetch_object($result)); // get the remaining rows
return $medialist;
}
}
} else break;
$page += $returnMedia;
}
while (!$limit || $page<=$limit);
return $medialist;
}
function is_makePopupLink($imgid,$abspath) {
global $icenv;
$tag = strtolower(ereg_replace(".*\.([^\.]*)$","\\1",$abspath));
$is_i = $tag=='jpg' || $tag=='jpeg' || $tag=='png' || $tag=='gif';
$size = $is_i?@getimagesize($abspath):false;
if (!$size) $size = array(0,0);
$call = "href=\"javascript:void(0)\" onclick=\"window.open('".$icenv->live."/components/com_ice/view.php?popup=1&Itemid=".$icenv->itemid."&PageNo=0&hit=1&imgid=".$imgid."&q=".$icenv->_name."', '".$imgid."', 'width=";
if ($size[0]<550) {
$call .= "600";
} elseif ($size[0]>$icenv->cfg['maxsize']) {
$call .= $icenv->cfg['maxsize']+50;
} else $call .= $size[0]+40;
$call .= ", height=";
if ($size[1]<650) {
$call .= "650";
} elseif ($size[1]>$icenv->cfg['maxsize']) {
$call .= $icenv->cfg['maxsize']+50;
} else $call .= $size[1]+200;
$call .= ",screenX=40,screenY=40,scrollbars=yes,resizable=yes').focus()\"";
return $call;
}
function is_getViewSize($catdir,$filename) {
global $icenv;
if (fs_file_exists($icenv->abs."/".$icenv->cfg['imagepath'].$catdir."/viewsize/".$filename))
return "viewsize/".$filename;
return $filename;
}
}
// create the ice environment
if (defined('_JEXEC')) {
include(dirname(__FILE__).'/../../components/com_ice/classes/environment.class.php');
} else {
include(dirname(__FILE__).'/../components/com_ice/classes/environment.class.php');
}
if ($icenv->itemid!==0) {
//*********************** Parameters *****************************
$IS_imageID = $params->get('IS_imageID',1);
$IS_type = $params->get('IS_display',0);
$IS_nrOfMedia = $params->get('IS_nrOfMedia',1);
$IS_cat = $params->get('IS_cat','');
$IS_method = $params->get('IS_method',0);
$IS_nostop = $params->get('IS_nostop',0);
$IS_onestop = $params->get('IS_onestop',0);
$IS_space = $params->get('IS_space',0);
$IS_vertSpace = $params->get('IS_vertSpace',0);
$IS_cut = $params->get('IS_cut',0);
$IS_imgPerRow = $params->get('IS_imgPerRow',1);
$IS_width = $params->get('IS_width',160);
$IS_height = $params->get('IS_height',200);
$IS_imgWidth = $params->get('IS_imgWidth',100);
$IS_imgHeight = $params->get('IS_imgHeight',200);
$IS_imgSpace = $params->get('IS_imgSpace',0);
$IS_speed = $params->get('IS_speed',1);
$IS_delay = $params->get('IS_delay',50);
$IS_link = $params->get('IS_link',0);
$IS_showMethod = $params->get('IS_showMethod',0);
$IS_showCat = $params->get('IS_showCat',0);
$IS_showHits = $params->get('IS_showHits',0);
$IS_showDate = $params->get('IS_showDate',0);
$IS_showRating = $params->get('IS_showRating',0);
$IS_showName = $params->get('IS_showName',0);
$IS_showFilename = $params->get('IS_showFilename',0);
$IS_names = explode(',',$params->get('IS_names',0));
//*********************** Parameters *****************************
$alreadyListed = false;
if ($IS_method==6) { // Related Items: On which page are we?
$option = trim(mosGetParam($_REQUEST,'option'));
$task = trim(mosGetParam($_REQUEST,'task'));
$id = intval(mosGetParam($_REQUEST,'id'));
$catid = intval(mosGetParam($_REQUEST,'catid'));
$imgid = intval(mosGetParam($_REQUEST,'imgid'));
$page = trim(mosGetParam($_REQUEST,'page'));
$query = ''; $likes = array(); $ml = array();
if ($option=='com_content' && $task=='view' && $id) {
$query = "SELECT metakey FROM #__content WHERE id='$id'";
} elseif ($option=='com_ice') {
if ($page=='' && $catid!=0) {
$query = "SELECT catkeywords AS metakey FROM #__ice WHERE catid = '".$catid."' LIMIT 1";
} elseif ($page=='view' && $imgid!=0) {
$query = "SELECT imgkeywords AS metakey FROM #__icefiles WHERE imgid = '".$imgid."' LIMIT 1";
}
}
if ($query!='') {
$icenv->db->setQuery($query); $result = $icenv->db->query();
if ($result!==FALSE) {
if ($row = mysql_fetch_object($result)) {
$metakeys = explode(',',$row->metakey);
foreach ($metakeys as $key) {
$key = trim($key);
if ($key) $likes[] = mysql_escape_string($key);
}
}
}
}
if (count($likes)) {
if ($option=='com_ice') {
$icenv->db->setQuery("SELECT id, title FROM #__content WHERE id<>$id AND state=1 AND access <= $my->gid AND "
. "(metakey LIKE '%".implode("%' OR metakey LIKE '%",$likes)."%')");
$result = $icenv->db->query();
if ($result!==FALSE) {
echo "<ul>\n";
while ($row = mysql_fetch_object($result)) {
if ($option=="com_ice") {
$ItemId = $mainframe->getItemid($row->id);
}
$id = $row->id;
$href = $icenv->sefRelToAbs("index.php?option=com_content&task=view&id=$id&Itemid=$ItemId");
echo " <li><a href=\"$href\">$row->title</a></li>\n";
}
echo "</ul>\n";
}
$alreadyListed = true;
} else {
$mediatype = "(img.imgfilename LIKE '%jpg' OR img.imgfilename LIKE '%jpeg' OR img.imgfilename LIKE '%gif' OR img.imgfilename LIKE '%png')";
$mediatype .= " AND (imgkeywords LIKE '%".implode("%' OR imgkeywords LIKE '%",$likes)."%')";
if (!$icenv->ident->_admin) {
$query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') ORDER BY imghits DESC";
} else {
$query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 ORDER BY imghits DESC";
}
$ml = is_search($query,$IS_nrOfMedia,0); // now we have a list of media ids that the user is allowed to view
}
}
} else {
if (!$IS_method) {
srand(microtime()*1000000);
$IS_method = rand(1,5);
$randomMeth = true;
} else $randomMeth = false;
$mediatype = "(img.imgfilename LIKE '%jpg' OR img.imgfilename LIKE '%jpeg' OR img.imgfilename LIKE '%gif' OR img.imgfilename LIKE '%png')";
if ($IS_cat!='') {
$cats = split(',',$IS_cat);
foreach ($cats as $k => $ct) $cats[$k] = (int)$ct;
$mediatype .= ' AND (img.catid = '.join(' OR img.catid = ',$cats).')';
}
$br = 0;
while (true) {
if (!$icenv->ident->_admin) {
switch ($IS_method) {
case 1: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') ORDER BY rand()"; break;
case 2: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND imghits > 0 AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') ORDER BY imghits DESC"; break;
case 3: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') ORDER BY img.imgid DESC"; break;
case 4: $query = "SELECT DISTINCT com.imgid, img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, max(com.cmtid) as maxcmt, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM (#__icefiles AS img, #__ice_comments AS com) LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND com.imgid = img.imgid AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') GROUP BY id ORDER BY maxcmt DESC"; break;
case 5: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, img.votenum, (img.votesum/img.votenum) AS rating, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND img.votesum > 0 AND img.votenum > 0 AND cats.catpassword = '' AND (img.published = 1 OR img.uid = '".$icenv->ident->_id."') ORDER BY rating DESC, img.votenum DESC";
}
} else {
switch ($IS_method) {
case 1: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 ORDER BY rand()"; break;
case 2: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND imghits > 0 ORDER BY imghits DESC"; break;
case 3: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 ORDER BY img.imgid DESC"; break;
case 4: $query = "SELECT DISTINCT com.imgid, img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, max(com.cmtid) as maxcmt, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM (#__icefiles AS img, #__ice_comments AS com) LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND com.imgid = img.imgid GROUP BY id ORDER BY maxcmt DESC"; break;
case 5: $query = "SELECT DISTINCT img.imgid AS id, img.catid AS gallery_id, img.uid AS uid, img.imgmembers AS imgmembers, img.votenum, (img.votesum/img.votenum) AS rating, cats.catdir as catdir, cats.catname as cname, cats.catmembers as catmembers, cats.uid as catuid FROM #__icefiles AS img LEFT JOIN #__ice AS cats ON img.catid = cats.catid WHERE $mediatype AND img.watermark = 0 AND img.votesum > 0 AND img.votenum > 0 ORDER BY rating DESC, img.votenum DESC";
}
}
$ml = is_search($query,$IS_nrOfMedia,0); // now we have a list of media ids that the user is allowed to view
if ($randomMeth && count($ml)==0) {
if ((++$IS_method)>5) $IS_method = 1;
if ((++$br)==5) break;
} else break;
}
}
if (!$alreadyListed && count($ml)) {
echo ' <center>';
if ($IS_showMethod) echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr><td class=\"imagemethod$IS_imageID\"><br /><b>".$IS_names[$IS_method-1]."</b></td></tr></table>\n";
if ($IS_type>1) {
$ctrl = $IS_nostop?" onmouseover='this.stop()' onmouseout='this.start()'":'';
switch ($IS_type) {
case 2: $dir = 'up'; break;
case 3: $dir = 'down'; break;
case 4: $dir = 'left'; break;
case 5: $dir = 'right';
}
echo "<table><tr><td class=\"imagemarquee$IS_imageID\" width=\"$IS_width\">";
if (!$IS_onestop || count($ml)>1) echo " <marquee direction=\"$dir\" height=\"$IS_height\" width=\"$IS_width\" scrollamount=\"$IS_speed\" scrolldelay=\"$IS_delay\" $ctrl>\n";
}
switch ($IS_type) {
case 0: // vertical still
echo "<table border=\"0\" cellspacing=\"$IS_space\" cellpadding=\"0\" style=\"empty-cells:show;\">\n";
break;
case 1: // horizontal still
echo "<table border=\"0\" cellspacing=\"$IS_space\" cellpadding=\"0\" style=\"empty-cells:show;\"><tr valign=\"bottom\">\n";
$col = 0; break;
case 2: // vertical scroll
case 3:
echo "<center><table border=\"0\" cellspacing=\"$IS_space\" cellpadding=\"0\" style=\"empty-cells:show;\">\n";
break;
case 4: // horizontal scroll
case 5:
echo "<center><table border=\"0\" cellspacing=\"$IS_space\" cellpadding=\"0\" style=\"empty-cells:show;\"><tr valign=\"bottom\">\n";
$col = 0; break;
}
$pols = &new policies();
foreach ($ml as $imgid) {
$icenv->db->setQuery("SELECT imgname, imgfilename, xlink, date_format(imgdate, '%d-%m-%y, %H:%i') AS imgdate, imghits, votenum, votesum, catid, imgdescr FROM #__icefiles WHERE imgid = '".$imgid[0]."' LIMIT 1");
$result = $icenv->db->query();
if ($result!==FALSE) {
if ($row = mysql_fetch_object($result)) {
if ($IS_type==1 || $IS_type>3) { // horizontal
if (($col++)>=$IS_imgPerRow) { $col = 1; echo '</tr><tr valign="bottom">'; }
echo "<td align=\"center\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"empty-cells:show;\">";
}
echo "<tr><td height=\"$IS_imgHeight\" class=\"imagethumb$IS_imageID\">\n";
$path = '/'.$icenv->cfg['imagepath'].$imgid[1].'/thumbs/'.$row->imgfilename;
$size = @getimagesize($icenv->abs.$path);
$path = $icenv->live.$path;
if (!$size) $size = array(0,0);
if ($IS_imgWidth && $size[0]>$IS_imgWidth) {
$ratio = (double)$IS_imgWidth/(double)$size[0];
$width = $IS_imgWidth;
$height = (int)((double)$size[1]*$ratio);
} else { $width = $size[0]; $height = $size[1]; }
$call = false;
$pols->loadPolicies($imgid[3],$imgid[4],array('view','remove','create','upload','open'),true);
if ($IS_link) {
if ($imgid[5] && $IS_link!=3) { // $imgid[5] = openable
if ($IS_link==1 || !$icenv->cfg['popUpImages']) { // embed image
$call = "href=\"".$icenv->sefRelToAbs("index.php?option=com_ice&Itemid=".$IS_ItemId."&page=view&catid=".$row->catid."&imgid=".$imgid[0]."&PageNo=0&key=0&hit=1&mode=0")."\"";
} elseif ($IS_link==2) { // popup image
$call = is_makePopupLink($imgid[0],$row->xlink==''?$icenv->abs.'/'.$icenv->cfg['imagepath'].$imgid[1].'/'.is_getViewSize($imgid[1],$row->imgfilename):$row->xlink);
}
} elseif ($IS_link==3) { // jump into gallery
if ($pols->isAllowed('open')) $call = "href=\"".$icenv->sefRelToAbs("index.php?option=com_ice&Itemid=".$IS_ItemId."&catid=".$row->catid."&imgid=".$imgid[0]."&PageNo=0&mode=0")."\"";
}
if ($call)
echo '<a '.$call.'><img hspace="'.$IS_imgSpace.'" vspace="'.$IS_imgSpace.'" src="'.htmlentities($path,ENT_QUOTES,_ICE_ISO).'" border="0" width="'.$width.'" height="'.$height.'" alt="thumb" /></a>';
else echo '<img hspace="'.$IS_imgSpace.'" vspace="'.$IS_imgSpace.'" src="'.htmlentities($path,ENT_QUOTES,_ICE_ISO).'" border="0" width="'.$width.'" height="'.$height.'" alt="thumb" />';
} else echo '<img hspace="'.$IS_imgSpace.'" vspace="'.$IS_imgSpace.'" src="'.htmlentities($path,ENT_QUOTES,_ICE_ISO).'" border="0" width="'.$width.'" height="'.$height.'" alt="thumb" />';
echo "</td></tr><tr><td class=\"imagefooter$IS_imageID\">\n";
$brk = '';
if ($IS_showName) {
echo $brk.htmlentities(($IS_cut&&strlen($row->imgname)>$IS_cut)?substr($row->imgname,0,$IS_cut).'...':$row->imgname,ENT_QUOTES,_ICE_ISO);
$brk = '<br />';
}
if ($IS_showFilename) {
if ($row->xlink=='')
echo $brk.htmlentities(($IS_cut&&strlen($row->imgfilename)>$IS_cut)?substr($row->imgfilename,0,$IS_cut).'...':$row->imgfilename,ENT_QUOTES,_ICE_ISO);
else echo $brk.'External';
$brk = '<br />';
}
if ($IS_showCat==1 || ($IS_showCat==2 && !$pols->isAllowed('open'))) {
echo $brk.htmlentities(($IS_cut&&strlen($imgid[2])>$IS_cut)?substr($imgid[2],0,$IS_cut).'...':$imgid[2],ENT_QUOTES,_ICE_ISO);
$brk = '<br />';
} elseif ($IS_showCat==2) {
$call = "href=\"".$icenv->sefRelToAbs("index.php?option=com_ice&Itemid=".$icenv->itemid."&catid=".$row->catid."&imgid=".$imgid[0]."&PageNo=0&mode=0")."\"";
echo "$brk<a class=\"image$IS_imageID\" ".$call.'>'.htmlentities(($IS_cut&&strlen($imgid[2])>$IS_cut)?substr($imgid[2],0,$IS_cut).'...':$imgid[2],ENT_QUOTES,_ICE_ISO).'</a>';
$brk = '<br />';
}
if ($IS_showDate) { echo $brk.$IS_names[8].$row->imgdate; $brk = '<br />'; }
if ($IS_showHits) { echo $brk.$IS_names[6].$row->imghits; $brk = '<br />'; }
$rt = round($row->votesum/($row->votenum?$row->votenum:1));
if ($IS_showRating && $rt>0) {
echo $brk.$IS_names[7];
echo "<img align=\"top\" src=\"".$icenv->live."/components/com_ice/images/rating/rating".$rt.".gif\" border=\"0\" alt=\"rating\" />";
}
echo "</td></tr>\n";
if ($IS_type==1 || $IS_type>3) {
echo "</table></td>\n"; // horizontal, close column
} elseif ($IS_vertSpace) echo "<tr><td height=\"$IS_vertSpace\"> </td></tr>\n";
}
}
}
switch ($IS_type) {
case 0: // vertical still
echo '</table>'; break;
case 1: // horizontal still
while ($col++<$IS_imgPerRow) echo '<td> </td>';
echo "</tr></table>"; break;
case 2: // vertical scroll
case 3:
if (!$IS_onestop || count($ml)>1)
echo '</table></center></marquee></td></tr></table>';
else
echo '</table></center></td></tr></table>';
break;
case 4: // horizontal scroll
case 5:
while ($col++<$IS_imgPerRow) echo '<td> </td>';
if (!$IS_onestop || count($ml)>1)
echo '</tr></table></center></marquee></td></tr></table>';
else
echo '</tr></table></center></td></tr></table>';
break;
}
echo "</center>\n";
}
} else echo "A menu link to Ice Gallery 0.5 RC 1 is required to use this module.";
?>