Beispiel #1
0
function &gs_rssshow($limit)
{
    global $util, $mc;
    $db =& Database::getInstance();
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    foreach ($_GET as $k => $v) {
        ${$k} = $v;
    }
    $feed = array();
    // Información General
    $items = array();
    $mc =& $util->moduleConfig('galleries');
    if ($show == 'imgs') {
        $feed['title'] = htmlspecialchars(_MI_GS_RSSNAME);
        $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/photos/' : 'explore.php?by=explore/photos'));
        $feed['description'] = htmlspecialchars(_MI_GS_RSSIMGS_DESC);
        $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE public='2' ORDER BY created DESC LIMIT 0,15";
        $result = $db->query($sql);
        $users = array();
        while ($row = $db->fetchArray($result)) {
            $pic = new GSImage();
            $pic->assignVars($row);
            if (!isset($users[$pic->owner()])) {
                $users[$pic->owner()] = new GSUser($pic->owner(), 1);
            }
            $user =& $users[$pic->owner()];
            $rtn = array();
            $rtn['title'] = htmlspecialchars($pic->title());
            $rtn['link'] = $user->userURL() . 'img/' . $pic->id() . '/';
            $rtn['description'] = htmlspecialchars('<img src="' . $user->filesURL() . '/ths/' . $pic->image() . '" alt="" /><br />' . sprintf(_MI_GS_RSSIMGDESC, $pic->desc(), formatTimestamp($pic->created(), 'string'), $user->uname(), $pic->views()));
            $rtn['date'] = formatTimestamp($pic->created());
            $items[] = $rtn;
        }
    } elseif ($show == 'sets') {
        $feed['title'] = htmlspecialchars(_MI_GS_RSSSETS);
        $feed['link'] = htmlspecialchars(XOOPS_URL . '/modules/galleries/' . ($mc['urlmode'] ? 'explore/sets/' : 'explore.php?by=explore/sets'));
        $feed['description'] = htmlspecialchars(_MI_GS_RSSSETS_DESC);
        $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0,15";
        $result = $db->query($sql);
        $users = array();
        while ($row = $db->fetchArray($result)) {
            $set = new GSSet();
            $set->assignVars($row);
            if (!isset($users[$set->owner()])) {
                $users[$set->owner()] = new GSUser($set->owner(), 1);
            }
            $user =& $users[$set->owner()];
            $rtn = array();
            $rtn['title'] = htmlspecialchars($set->title());
            $rtn['link'] = $user->userURL() . 'set/' . $set->id() . '/';
            $rtn['description'] = htmlspecialchars(sprintf(_MI_GS_RSSSETDESC, $user->uname(), formatTimestamp($set->date(), 'string'), $set->pics()));
            $rtn['date'] = formatTimestamp($set->date());
            $items[] = $rtn;
        }
    }
    $ret = array('feed' => $feed, 'items' => $items);
    return $ret;
}
Beispiel #2
0
function gs_photos_show($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    $options[0] <= 0 ? 4 : $options[0];
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("gs_images");
    $order = $options[1] == '0' ? "created DESC" : ($options[1] == '1' ? 'RAND()' : 'views DESC');
    $sql .= " ORDER BY {$order} LIMIT 0,{$options['0']}";
    $result = $db->query($sql);
    $mc =& RMUtilities::module_config('galleries');
    $block = array();
    $tf = new RMTimeFormatter(0, '%T% %d%, %Y%');
    while ($row = $db->fetchArray($result)) {
        $pic = new GSImage();
        $pic->assignVars($row);
        if (!isset($users[$pic->owner()])) {
            $users[$pic->owner()] = new GSUser($pic->owner(), 1);
        }
        $user =& $users[$pic->owner()];
        $rtn = array();
        if ($options[3]) {
            $rtn['title'] = $pic->title();
        }
        $rtn['created'] = $tf->format($pic->created());
        $rtn['views'] = $pic->views();
        $rtn['by'] = sprintf(__('by %s', 'galleries'), '<a href="' . $user->userURL() . '">' . $user->uname() . '</a>');
        $rtn['link'] = $user->userURL() . ($mc['urlmode'] ? 'img/' . $pic->id() . '/' : '&amp;img=' . $pic->id());
        $rtn['file'] = $user->filesURL() . '/ths/' . $pic->image();
        $block['pics'][] = $rtn;
    }
    RMTemplate::get()->add_xoops_style('blocks.css', 'galleries');
    RMTemplate::get()->add_local_script('blocks.js', 'galleries');
    $block['item_width'] = $options[2];
    return $block;
}
Beispiel #3
0
/**
* @desc Realiza una búsqueda en el módulo desde EXM
*/
function gsSearch($queryarray, $andor, $limit, $offset, $userid)
{
    global $db, $myts;
    include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsimage.class.php";
    include_once XOOPS_ROOT_PATH . "/modules/galleries/class/gsuser.class.php";
    $mc = RMUtilities::get()->module_config('galleries');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT DISTINCT c.* FROM " . $db->prefix('gs_tags') . " a INNER JOIN " . $db->prefix('gs_tagsimages') . " b INNER JOIN ";
    $sql .= $db->prefix('gs_images') . " c ON (";
    $sql .= "a.id_tag=b.id_tag AND b.id_image=c.id_image AND c.public=2 AND (";
    $sql1 = '';
    foreach ($queryarray as $k) {
        $sql1 .= ($sql1 == '' ? "" : "{$andor}") . " (a.tag LIKE '%{$k}%' OR c.title LIKE '%{$k}%') ";
    }
    $sql1 .= "))";
    $sql1 .= " ORDER BY c.created DESC LIMIT {$offset}, {$limit}";
    $result = $db->queryF($sql . $sql1);
    $ret = array();
    $users = array();
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        $rtn = array();
        $rtn['image'] = 'images/images.png';
        $link = $mc['urlmode'] ? "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id() : "user.php?id=" . "usr/" . $users[$img->owner()]->uname() . "/img/" . $img->id();
        $rtn['title'] = $img->title();
        $rtn['time'] = $img->created();
        $rtn['uid'] = $img->owner();
        $rtn['desc'] = $img->desc();
        $rtn['link'] = $link;
        $ret[] = $rtn;
    }
    return $ret;
}
 /**
  * Get image data
  */
 public function process_image_data($result)
 {
     $mc = RMUtilities::module_config('galleries');
     $users = array();
     $ret = array();
     $tf = new RMTimeFormatter(0, "%M%/%d%/%Y%");
     $db = Database::getInstance();
     $i = 0;
     while ($row = $db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($row);
         if (!isset($users[$img->owner()])) {
             $users[$img->owner()] = new GSUser($img->owner(), 1);
         }
         $imglink = $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id());
         $ret[$i] = array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'thumbuser' => $users[$img->owner()]->filesURL() . '/' . ($mc['user_format_mode'] ? 'formats/user_' : 'ths/') . $img->image(), 'thumbsrh' => $users[$img->owner()]->filesURL() . '/' . ($mc['search_format_mode'] ? 'formats/srh_' : 'ths/') . $img->image(), 'image' => $users[$img->owner()]->filesURL() . '/' . $img->image(), 'by' => sprintf(__('by %s', 'galleries'), '<a href="' . $users[$img->owner()]->userUrl() . '">' . $users[$img->owner()]->uname() . '</a>'), 'link' => $imglink, 'created' => $tf->format($img->created()), 'public' => $img->isPublic(), 'desc' => $img->desc());
         // Format resize
         if (!$img->userFormat() && $mc['user_format_mode']) {
             $format = $mc['user_format_values'];
             GSFunctions::resizeImage($format[0], $users[$img->owner()]->filesPath() . '/' . $img->image(), $users[$img->owner()]->filesPath() . '/formats/user_' . $img->image(), $format[1], $format[2]);
             $img->setUserFormat(1, 1);
         }
         if (!$img->searchFormat() && $mc['search_format_mode']) {
             $format = $mc['search_format_values'];
             GSFunctions::resizeImage($format[0], $users[$img->owner()]->filesPath() . '/' . $img->image(), $users[$img->owner()]->filesPath() . '/formats/srh_' . $img->image(), $format[1], $format[2]);
             $img->setSearchFormat(1, 1);
         }
         if ($mc['search_format_mode']) {
             $ret[$i]['viewmore'] = sprintf(__('Ver <a href="%s">más fotos</a>.', 'galleries'), $users[$img->owner()]->userURL());
             $ret[$i]['avatar'] = RMEvents::get()->run_event('rmcommon.get.avatar', $users[$img->owner()]->userVar('email'), 0, $users[$img->owner()]->userVar('user_avatar'));
             $tags = $img->tags(true);
             $tagurl = self::get_url() . ($mc['urlmode'] ? 'explore/tags/tag/' : '?explore=tags&amp;tag=');
             $strtag = '';
             foreach ($tags as $tag) {
                 $strtag .= $strtag == '' ? "<a href=\"{$tagurl}" . $tag->getVar('nameid') . "\">" . $tag->tag() . "</a>" : ", <a href=\"{$tagurl}" . $tag->getVar('nameid') . "\">" . $tag->tag() . "</a>";
             }
             $ret[$i]['tags'] = $strtag;
         }
         $i++;
     }
     RMTemplate::get()->add_local_script('photos.js', 'galleries');
     if (!$mc['quickview']) {
         return $ret;
     }
     if (RMFunctions::plugin_installed('lightbox')) {
         RMLightbox::get()->add_element('.pic_qview a');
         RMLightbox::get()->render();
     }
     return $ret;
 }
Beispiel #5
0
function send_sets()
{
    global $xoopsLogger, $xoopsModuleConfig;
    $xoopsLogger->renderingEnabled = false;
    error_reporting(0);
    $xoopsLogger->activated = false;
    $mc =& $xoopsModuleConfig;
    $db = Database::getInstance();
    $limit = rmc_server_var($_GET, 'limit', 5);
    // recent pictures
    $sql = "SELECT * FROM " . $db->prefix("gs_sets") . " ORDER BY `date` DESC LIMIT 0,{$limit}";
    $result = $db->query($sql);
    $sets = array();
    $users = array();
    while ($row = $db->fetchArray($result)) {
        $set = new GSSet();
        $set->assignVars($row);
        $pics = $set->getPics('RAND()');
        $img = new GSImage($pics[0]);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        if ($img->isNew()) {
            $image = array('title' => __('Empty album', 'galleries'), 'link' => '', 'thumbnail' => GS_URL . '/images/empty.jpg');
        } else {
            $image = array('title' => $img->title(), 'link' => $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id()), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image());
        }
        $sets[] = array('title' => $set->title(), 'link' => $set->url(), 'image' => $image);
    }
    ob_start();
    ?>
    <?php 
    foreach ($sets as $set) {
        ?>
    <a href="<?php 
        echo $set['link'];
        ?>
" target="_blank" title="<?php 
        echo $set['title'];
        ?>
"><img src="<?php 
        echo $set['image']['thumbnail'];
        ?>
" alt="<?php 
        echo $set['title'];
        ?>
" /></a>
    <?php 
    }
    ?>
    <?php 
    $recents = ob_get_clean();
    echo $recents;
    die;
}
Beispiel #6
0
     $result = $db->query($sql);
     $rss_channel['title'] = $xoopsModule->name();
     $rss_channel['link'] = GSFunctions::get_url();
     $rss_channel['description'] = __('These are the recent pictures published on our galleries.', 'galleries');
     $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
     $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['category'] = __('Pictures', 'galleries');
     $rss_channel['generator'] = 'MyGalleries 3';
     $rss_channel['language'] = RMCLANG;
     $users = array();
     $rss_items = array();
     while ($row = $db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($row);
         if (!isset($users[$img->owner()])) {
             $users[$img->owner()] = new GSUser($img->owner(), 1);
         }
         $imglink = $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&amp;img=' . $img->id());
         $desc = '<a href="' . $imglink . '"><img src="' . $users[$img->owner()]->filesURL() . '/ths/' . $img->image() . '" alt="' . $img->title() . '" /></a><br />' . ($img->desc() != '' ? $img->desc() . '<br />' : '');
         $desc .= sprintf(__('By: <strong>%s</strong>', 'galleries'), $users[$img->owner()]->uname());
         $item = array();
         $item['title'] = $img->title();
         $item['link'] = $imglink;
         $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($desc, ENT_QUOTES));
         $item['pubdate'] = formatTimestamp($img->created(), 'rss');
         $item['guid'] = $imglink;
         $rss_items[] = $item;
     }
     break;
 case 'albums':
Beispiel #7
0
/**
* @desc Mostramos los detalles de una imágen
*/
function showImageDetails()
{
    global $usr, $set, $img, $db, $xoopsModule, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $xoopsOption, $tpl;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified user does not exists!', 'galleries'));
        die;
    }
    $image = new GSImage($img);
    if ($image->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified image does not exists!', 'galleries'));
        die;
    }
    $user = new GSUser($image->owner(), 1);
    //Verificamos la privacidad de la imagen
    if (!$image->isPublic()) {
        //Privada, Verificamos si el usuario es el dueño de la imagen
        if (!$xoopsUser || $xoopsUser->uid() != $image->owner()) {
            redirect_header(GSFunctions::get_url(), 1, __('You can not view this image!', 'galleries'));
            die;
        }
    } else {
        if ($image->isPublic() == 1) {
            //Privada y amigos
            if (!$xoopsUser || $xoopsUser->uid() != $image->owner()) {
                //Verificamos si es un amigo
                if (!$xoopsUser || !$user->isFriend($xoopsUser->uid())) {
                    redirect_header(GSFunctions::get_url(), 1, __('You are not authorized to view this image!', 'galleries'));
                    die;
                }
            }
        }
    }
    //Incrementamos las vistas de la imagen
    $image->addViews();
    if (isset($set)) {
        $set = new GSSet($set);
        if ($set->isNew()) {
            redirect_header(GSFunctions::get_url(), 0, __('Specified album does not exists!', 'galleries'));
            die;
        }
    }
    if ($image->desc() != '') {
        global $xoTheme;
        $xoTheme->addMeta('meta', 'description', $image->desc());
    }
    $xoopsOption['template_main'] = 'gs_imgdetails.html';
    $xoopsOption['module_subpage'] = 'picsdetails';
    include 'header.php';
    GSFunctions::makeHeader();
    $tpl->assign('user', array('id' => $user->id(), 'uname' => $user->uname(), 'link' => $user->userURL(), 'avatar' => $user->userVar('user_avatar') != '' ? XOOPS_URL . '/uploads/avatars/' . $user->userVar('user_avatar') : GS_URL . '/images/avatar.png'));
    $tpl->assign('user_link', $user->userURL());
    $tpl->assign('lang_alsobelong', __('Also belongs to:', 'galleries'));
    $tpl->assign('lang_postcards', __('Send postcard', 'galleries'));
    $tpl->assign('lang_bookmark', __('+ Bookmark', 'galleries'));
    $tpl->assign('lang_photos', __('Pictures', 'galleries'));
    $tpl->assign('lang_toset', __('+ to Album', 'galleries'));
    $tpl->assign('lang_lastpic', __('This is the last picture', 'galleries'));
    $tpl->assign('lang_firstpic', __('This is the first picture', 'galleries'));
    $tpl->assign('toset_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/toset/ids/' . $image->id() . '/referer/' . base64_encode(RMFunctions::current_url()) . '/' : '?cp=toset&amp;ids=' . $image->id() . '&amp;referer=' . base64_encode(RMFunctions::current_url())));
    $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/edit/id/' . $image->id() . '/referer/' . base64_encode(RMFunctions::current_url()) . '/' : '?cp=edit&amp;id=' . $image->id() . '&amp;referer=' . base64_encode(RMFunctions::current_url())));
    $tpl->assign('bookmark_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/bookmarks/add/' . $image->id() . '/referer/' . base64_encode($_SERVER['REQUEST_URI']) : '?cpanel=bookmarks&amp;add=' . $image->id() . '&amp;referer=' . base64_encode($_SERVER['REQUEST_URI'])));
    $tpl->assign('postcard_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/new/img/' . $image->id() . '/' : '?postcard=new&amp;img=' . $image->id()));
    $tpl->assign('delete_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/delete/referer/' . base64_encode(RMFunctions::current_url()) . '/ids/' : '?cpanel=delete&amp;referer=' . base64_encode(RMFunctions::current_url()) . '&amp;ids='));
    $tpl->assign('lang_confirmdel', sprintf(__('Dow you really want to delete this picture?\\n(%s)', 'galleries'), $image->title()));
    if ($xoopsUser && $xoopsUser->uid() == $image->owner()) {
        $tpl->assign('lang_edit', __('Edit', 'galleries'));
        $tpl->assign('lang_delete', __('Delete', 'galleries'));
        $tpl->assign('isowner', 1);
    }
    $tpl->assign('postcards', $mc['postcards']);
    $data = getimagesize($user->filesURL() . '/' . $image->image());
    $tpl->assign('image', array('title' => $image->title(), 'id' => $image->id(), 'file' => $user->filesURL() . '/' . $image->image(), 'desc' => $image->desc(), 'width' => $data[0] + 2, 'height' => $data[1] + 2));
    unset($data);
    //Verificamos si el usuario es dueño o amigo
    if ($xoopsUser && $xoopsUser->uid() == $user->uid()) {
        $public = '';
    } else {
        if ($xoopsUser && $user->isFriend($xoopsUser->uid())) {
            $public = " AND public<>'0'";
        } else {
            $public = " AND public='2'";
        }
    }
    // Imágenes anterior y siguiente
    if (!isset($set)) {
        // Navigation as images
        if ($xoopsModuleConfig['navimages']) {
            $limit_n = $xoopsModuleConfig['navimages_num'];
            $limit_p = $xoopsModuleConfig['navimages_num'];
            // Count images
            $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image>'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image ASC LIMIT 0," . $xoopsModuleConfig['navimages_num'];
            $resultn = $db->query($sql);
            if ($db->getRowsNum($resultn) < $xoopsModuleConfig['navimages_num']) {
                $limit_p = $limit_p + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultn));
            }
            $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image<'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image DESC, created DESC LIMIT 0," . $limit_p;
            $resultp = $db->query($sql);
            if ($db->getRowsNum($resultp) < $xoopsModuleConfig['navimages_num']) {
                $limit_n = $limit_n + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultp));
            }
            if ($limit_n > $db->getRowsNum($resultn) && $limit_p == $xoopsModuleConfig['navimages_num']) {
                $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image>'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image ASC LIMIT 0," . $limit_n;
                $resultn = $db->query($sql);
            }
            // Previous Images
            while ($row = $db->fetchArray($resultp)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $previous_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/' : '&amp;img=' . $pn->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
            // Next Images
            while ($row = $db->fetchArray($resultn)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $next_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/' : '&amp;img=' . $pn->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
        }
        $tpl->assign('prevnext_title', sprintf(__('Pictures of %s'), $user->uname()));
        $tpl->assign('xoops_pagetitle', $image->title() . ' &raquo; ' . sprintf(__('Pictures of %s'), $user->uname()) . ' &raquo; ' . $xoopsModuleConfig['section_title']);
        $tpl->assign('title_link', $user->userURL());
        $result = $db->query("SELECT COUNT(*) FROM " . $db->prefix("gs_images") . " WHERE owner='" . $user->uid() . "' {$public}");
        list($num) = $db->fetchRow($result);
        $tpl->assign('pics_count', $num);
        // Tambien pertenece
        $tbl1 = $db->prefix("gs_sets");
        $tbl2 = $db->prefix("gs_setsimages");
        $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_image='" . $image->id() . "' AND a.id_set=b.id_set";
        $result = $db->query($sql);
        while ($row = $db->fetchArray($result)) {
            $oset = new GSSet();
            $oset->assignVars($row);
            //Verificamos la privacidad del album
            if (!$oset->ispublic()) {
                if (!$xoopsUser) {
                    continue;
                }
                if ($xoopsUser->uid() != $oset->owner()) {
                    continue;
                }
            } else {
                if (!$xoopsUser && $oset->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
                    continue;
                }
            }
            $tpl->append('sets', array('id' => $oset->id(), 'title' => $oset->title(), 'link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'set/' . $oset->id() . '/' : '&amp;set=' . $oset->id())));
        }
    } else {
        // Imágen Siguiente
        $tbl1 = $db->prefix("gs_images");
        $tbl2 = $db->prefix("gs_setsimages");
        // Navigation as images
        if ($xoopsModuleConfig['navimages']) {
            $limit_n = $xoopsModuleConfig['navimages_num'];
            $limit_p = $xoopsModuleConfig['navimages_num'];
            // Count images
            $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image>'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image ASC LIMIT 0," . $xoopsModuleConfig['navimages_num'];
            $resultn = $db->query($sql);
            if ($db->getRowsNum($resultn) < $xoopsModuleConfig['navimages_num']) {
                $limit_p = $limit_p + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultn));
            }
            $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image<'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image DESC LIMIT 0,{$limit_p}";
            $resultp = $db->query($sql);
            if ($db->getRowsNum($resultp) < $xoopsModuleConfig['navimages_num']) {
                $limit_n = $limit_n + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultp));
            }
            if ($limit_n > $db->getRowsNum($resultn) && $limit_p == $xoopsModuleConfig['navimages_num']) {
                $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image>'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image ASC LIMIT 0," . $limit_n;
                $resultn = $db->query($sql);
            }
            // Previous Images
            while ($row = $db->fetchArray($resultp)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $previous_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $pn->id() . '&amp;set=' . $set->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
            // Next Images
            while ($row = $db->fetchArray($resultn)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $next_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $pn->id() . '&amp;set=' . $set->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
        }
        $tpl->assign('prevnext_title', sprintf(__('Pictures in %s', 'galleries'), $set->title()));
        $tpl->assign('xoops_pagetitle', $image->title() . ' &raquo; ' . sprintf(__('Pictures in %s'), $set->title()) . ' &raquo; ' . $xoopsModuleConfig['section_title']);
        $tpl->assign('title_link', $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id()));
        $result = $db->query("SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.owner='" . $user->uid() . "' {$public}");
        list($num) = $db->fetchRow($result);
        $tpl->assign('pics_count', $num);
        // Tambien pertenece
        $tbl1 = $db->prefix("gs_sets");
        $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set<>'" . $set->id() . "' AND b.id_image='" . $image->id() . "' AND a.id_set=b.id_set";
        $result = $db->query($sql);
        $tpl->append('sets', array('id' => 0, 'title' => sprintf(__('Galleries of %s', 'galleries'), $user->uname()), 'link' => $user->userURL()));
        while ($row = $db->fetchArray($result)) {
            $oset = new GSSet();
            $oset->assignVars($row);
            //Verificamos la privacidad del album
            if (!$oset->ispublic()) {
                if (!$xoopsUser) {
                    continue;
                }
                if ($xoopsUser->uid() != $oset->owner()) {
                    continue;
                }
            } else {
                if (!$xoopsUser && $oset->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
                    continue;
                }
            }
            $tpl->append('sets', array('id' => $oset->id(), 'title' => $oset->title(), 'link' => $user->userURL() . 'set/' . $oset->id(), '/'));
        }
    }
    if (!empty($previous_images)) {
        $tpl->assign('prev', $previous_images[0]);
        $tpl->assign('previous_images', array_reverse($previous_images));
    } else {
        $tpl->assign('is_first', 1);
    }
    if (!empty($next_images)) {
        $tpl->assign('next', $next_images[0]);
        $tpl->assign('next_images', $next_images);
    } else {
        $tpl->assign('is_last', 1);
    }
    $tpl->assign('current_image', array('title' => $image->title(), 'file' => $user->filesURL() . '/ths/' . $image->image()));
    // Etiquetas
    $tags = $image->tags(true, '*');
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/tags/tag/' : "?explore=tags&amp;tag=");
    foreach ($tags as $tag) {
        $tpl->append('tags', array('id' => $tag->id(), 'tag' => $tag->tag(), 'link' => $link . $tag->getVar('nameid')));
    }
    // Comentarios
    $tpl->assign('users_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'usr/' : '?usr='******'galleries', 'image=' . $image->id());
    // Comments form
    RMFunctions::comments_form('galleries', 'image=' . $image->id(), 'module', GS_PATH . '/class/galleriescontroller.php');
    include 'footer.php';
}
Beispiel #8
0
/**
* @desc Visualiza la postal
**/
function viewPostcard()
{
    global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsModuleConfig, $mc, $xoopsUser, $id;
    include_once XOOPS_ROOT_PATH . '/class/template.php';
    $tpl = new XoopsTpl();
    $mc =& $xoopsModuleConfig;
    if (!$xoopsUser) {
        redirect_header(XOOPS_URL . '/user.php#register', 1, _MS_GS_ERRUSR);
        die;
    }
    //Verificamos si la postal existe
    $post = new GSPostcard($id);
    if ($post->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRPOSTEXIST);
        die;
    }
    $img = new GSImage($post->image());
    if ($img->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRIMG);
        die;
    }
    $user = new GSUser($img->owner(), 1);
    $file = $user->filesPath() . '/' . $img->image();
    list($ancho, $alto) = getimagesize($file);
    $tpl->assign('gs_url', XOOPS_URL . '/modules/galleries');
    $tpl->assign('img', array('id' => $img->id(), 'width' => $ancho, 'height' => $alto, 'url' => $user->filesURL() . '/' . $img->image(), 'link' => $user->userURL() . 'img/' . $img->id() . '/'));
    $tpl->assign('title', $post->title());
    $tpl->assign('message', $post->message());
    $tpl->assign('lang_says', sprintf(_MS_GS_SAYS, $post->name()));
    $tpl->assign('xoops_pagetitle', sprintf(_MS_GS_PTITLE, $post->title()) . ' &raquo; ' . $mc['section_title']);
    $tpl->assign('lang_see', _MS_GS_SEE);
    $tpl->assign('user_link', $user->userURL() . 'browse/' . $img->id() . '/');
    $tpl->assign('lang_seeuser', _MS_GS_SEEUSER);
    $tpl->assign('preview', 0);
    RMTemplate::get()->add_xoops_style('postcard.css', 'galleries');
    //Actualizar datos de postal
    $post->setViewed(1);
    $post->save();
    echo $tpl->fetch("db:gs_postcard.html");
}
Beispiel #9
0
/**
* @desc Visualiza la postal
**/
function viewPostcard()
{
    global $tpl, $xoopsModule, $xoopsModuleConfig, $xoopsModuleConfig, $mc, $xoopsUser, $id;
    include_once XOOPS_ROOT_PATH . '/class/template.php';
    $tpl = new XoopsTpl();
    $mc =& $xoopsModuleConfig;
    //Verificamos si la postal existe
    $post = new GSPostcard($id);
    if ($post->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, __('Specified E_Card does not exists!', 'galleries'));
        die;
    }
    $img = new GSImage($post->image());
    if ($img->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries/', 1, __('Sorry, there are some problems with this e-card!', 'galleries'));
        die;
    }
    $user = new GSUser($img->owner(), 1);
    $file = $user->filesPath() . '/' . $img->image();
    list($ancho, $alto) = getimagesize($file);
    $tpl->assign('gs_url', XOOPS_URL . '/modules/galleries');
    $tpl->assign('img', array('id' => $img->id(), 'width' => $ancho, 'height' => $alto, 'url' => $user->filesURL() . '/' . $img->image(), 'link' => $user->userURL() . 'img/' . $img->id() . '/'));
    $tpl->assign('title', $post->title());
    $tpl->assign('message', $post->message());
    $tpl->assign('lang_says', sprintf(__('%s says:'), $post->name()));
    $tpl->assign('xoops_pagetitle', sprintf(__('%s, E-Card', 'galleries'), $post->title()) . ' &raquo; ' . $mc['section_title']);
    $tpl->assign('lang_see', __('View Picture', 'galleries'));
    $tpl->assign('user_link', $user->userURL() . 'browse/' . $img->id() . '/');
    $tpl->assign('lang_seeuser', __('View User Pictures', 'galleries'));
    $tpl->assign('preview', 0);
    RMTemplate::get()->add_xoops_style('postcard.css', 'galleries');
    //Actualizar datos de postal
    $post->setViewed(1);
    $post->save();
    echo $tpl->fetch("db:gs_postcard.html");
}
/**
* @desc Marca Imagen como favorita
**/
function addBookMarks()
{
    global $xoopsUser, $add, $xoopsModuleConfig, $referer;
    $mc =& $xoopsModuleConfig;
    $referer = base64_decode($referer);
    if (!$referer) {
        $referer = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/bookmarks/' : '?cp=bookmarks');
    }
    //Verificamos que la imagen sea válida
    if ($add <= 0) {
        redirect_header($referer, 1, __('Image id is not valid!', 'galleries'));
        die;
    }
    //Verificamos que la imagen exista
    $img = new GSImage($add);
    if ($img->isNew()) {
        redirect_header($referer, 1, __('Specified image does not exists!', 'galleries'));
        die;
    }
    //Verificamos que la imagen sea pública o de amigos
    if ($img->isPublic() == 0) {
        redirect_header($referer, 1, __('You don\'t have authorization to view this picture!', 'galleries'));
        die;
    }
    $user = new GSUser($img->owner(), 1);
    //Verificamos si el usuario es amigo del dueño de la imagen
    if ($img->isPublic() == 1) {
        if (!$user->isFriend($xoopsUser->uid())) {
            redirect_header($referer, 1, __('You must be a friend of this user in order to view this picture!', 'galleries'));
            die;
        }
    }
    $db = Database::getInstance();
    //Verificamos si la imagen se encuentra ya registrada en favoritos
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_favourites') . " WHERE uid='" . $xoopsUser->uid() . "' AND id_image='" . $img->id() . "'";
    list($num) = $db->fetchRow($db->query($sql));
    if ($num > 0) {
        redirect_header($referer, 1, __('This picture already is in your favorites', 'galleries'));
        die;
    }
    //Agregamos la imagen a favoritos
    $sql = "INSERT INTO " . $db->prefix('gs_favourites') . " (`uid`,`id_image`) VALUES ('" . $xoopsUser->uid() . "','" . $img->id() . "')";
    $result = $db->queryF($sql);
    if (!$result) {
        redirect_header($referer, 1, __('Picture could not be added to your favorites!', 'galleries'));
        die;
    } else {
        redirect_header($referer, 1, __('Picture added to your favorites successfully!', 'galleries'));
        die;
    }
}
Beispiel #11
0
    $set = new GSSet();
    $set->assignVars($row);
    $pics = $set->getPics('RAND()');
    $imgs = @array_slice($pics, 0, $xoopsModuleConfig['sets_num_images']);
    if (!isset($users[$set->owner()])) {
        $users[$set->owner()] = new GSUser($set->owner(), 1);
    }
    $images = array();
    if (!empty($imgs)) {
        // Obtenemos las primeras 4 imágenes
        foreach ($imgs as $k) {
            $img = new GSImage($k);
            if ($img->isPublic() != 2) {
                continue;
            }
            if (!isset($users[$img->owner()])) {
                $users[$img->owner()] = new GSUser($img->owner(), 1);
            }
            $imglink = $users[$img->owner()]->userURL() . 'img/' . $img->id() . '/';
            $images[] = array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'image' => $users[$img->owner()]->filesURL() . '/' . $img->image(), 'by' => sprintf(__('by %s', 'galleries'), '<a href="' . $users[$img->owner()]->userUrl() . '">' . $users[$img->owner()]->uname() . '</a>'), 'link' => $imglink);
        }
    }
    $tpl->append('sets', array('id' => $set->id(), 'title' => $set->title(), 'images' => $images, 'link' => $users[$set->owner()]->userUrl() . ($mc['urlmode'] ? 'set/' . $set->id() : '&amp;set=' . $set->id()), 'date' => formatTimestamp($set->date(), 'c'), 'by' => '<a href="' . $users[$set->owner()]->userUrl() . '">' . $users[$set->owner()]->uname() . '</a>', 'picsnum' => count($pics)));
}
$result = $db->query("SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT {$mc['sets_num']}," . ($mc['sets_num'] > 0 ? $mc['sets_num'] : 5));
while ($row = $db->fetchArray($result)) {
    $set = new GSSet();
    $set->assignVars($row);
    if (!isset($users[$set->owner()])) {
        $users[$set->owner()] = new GSUser($set->owner(), 1);
    }
Beispiel #12
0
/**
* @desc almacena la información de la imagen
**/
function saveImages($edit = 0)
{
    global $mc, $xoopsSecurity, $db, $xoopsUser, $db;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = "page={$page}&limit={$limit}&search={$search}&owner={$owner}&sort={$sort}&mode={$mode}";
    if (!$xoopsSecurity->check()) {
        redirectMsg('./images.php?' . $ruta, __('Session token expired!', 'galleries'), 1);
        die;
    }
    if ($edit) {
        //Verificamos si la imagen es válida
        if ($id <= 0) {
            redirectMsg('./images.php?op=edit&id=' . $id . '&' . $ruta, __('Image ID not valid!', 'galleries'), 1);
            die;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($id);
        if ($img->isNew()) {
            redirectMsg('./images.php?op=edit&id=' . $id . '&' . $ruta, __('Specified image does not exists!', 'galleries'), 1);
            die;
        }
    } else {
        $img = new GSImage();
    }
    $img->setTitle($title);
    $img->setDesc($desc);
    $img->isNew() ? $img->setCreated(time()) : $img->setModified(time());
    if (!$edit) {
        $img->setOwner($uid);
    }
    $img->setPublic($public);
    //Insertamos las etiquetas
    $tgs = array();
    $tags = explode(",", $tags);
    foreach ($tags as $k) {
        $k = trim($k);
        if (!$k) {
            continue;
        }
        if (strlen($k) < $mc['min_tag'] || strlen($k) > $mc['max_tag']) {
            continue;
        }
        $tag = new GSTag($k);
        if (!$tag->isNew()) {
            $tgs[] = $tag->id();
            continue;
        }
        $tag->setTag(strtolower($k));
        if ($tag->save()) {
            $tgs[] = $tag->id();
        }
    }
    if (!$edit) {
        if ($xoopsUser->uid() == $uid) {
            $xu =& $xoopsUser;
        } else {
            $xu = new XoopsUser($uid);
        }
        //Verificamos si el usuario se encuentra registrado
        $user = new GSUser($xu->uname());
        if ($user->isNew()) {
            //Insertamos información del usuario
            $user->setUid($uid);
            $user->setUname($xu->uname());
            $user->setQuota($mc['quota'] * 1024 * 1024);
            $user->setDate(time());
            if (!$user->save()) {
                redirectMsg('./images.php?op=' . ($edit ? 'edit&id=' . $id : 'new') . '&' . $ruta, __('New user owner could not be saved!', 'galleries'), 1);
                die;
            } else {
                mkdir($mc['storedir'] . "/" . $user->uname());
                mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
                mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
            }
        }
    } else {
        $user = new GSUser($img->owner(), 1);
    }
    //Imagen
    include_once RMCPATH . '/class/uploader.php';
    $folder = $mc['storedir'] . "/" . $user->uname();
    $folderths = $mc['storedir'] . "/" . $user->uname() . "/ths";
    $up = new RMFileUploader($folder, $mc['size_image'] * 1024, array('jpg', 'png', 'gif'));
    if ($edit) {
        $filename = $img->image();
    } else {
        $filename = '';
    }
    if ($up->fetchMedia('image')) {
        if (!$up->upload()) {
            redirectMsg('./images.php?op=' . ($edit ? 'edit&id=' . $id : 'new') . '&' . $ruta, $up->getErrors(), 1);
            die;
        }
        if ($edit && $img->image() != '') {
            @unlink($mc['storedir'] . "/" . $user->uname() . "/" . $img->image());
            @unlink($mc['storedir'] . "/" . $user->uname() . "/ths/" . $img->image());
            @unlink($mc['storedir'] . "/originals/" . $img->image());
        }
        $filename = $up->getSavedFileName();
        $fullpath = $up->getSavedDestination();
        $thSize = $mc['image_ths'];
        $imgSize = $mc['image'];
        if ($thSize[0] <= 0) {
            $thSize[0] = 100;
        }
        if (!isset($thSize[1]) || $thSize[1] <= 0) {
            $thSize[1] = $thSize[0];
        }
        if ($imgSize[0] <= 0) {
            $imgSize[0] = 500;
        }
        if (!isset($imgSize[1]) || $imgSize[1] <= 0) {
            $imgSize[1] = $imgSize[0];
        }
        // Almacenamos la imágen original
        if ($mc['saveoriginal']) {
            copy($fullpath, $mc['storedir'] . '/originals/' . $filename);
        }
        // Redimensionamos la imagen
        $redim = new RMImageResizer($fullpath, $fullpath);
        switch ($mc['redim_image']) {
            case 0:
                //Recortar miniatura
                $redim->resizeWidth($imgSize[0]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeAndCrop($thSize[0], $thSize[1]);
                break;
            case 1:
                //Recortar imagen grande
                $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeWidth($thSize[0]);
                break;
            case 2:
                //Recortar ambas
                $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeAndCrop($thSize[0], $thSize[1]);
                break;
            case 3:
                //Redimensionar
                $redim->resizeWidth($imgSize[0]);
                $redim->setTargetFile($folderths . "/{$filename}");
                $redim->resizeWidth($thSize[0]);
                break;
        }
    } else {
        echo $up->getErrors();
    }
    //Fin de Imagen
    $img->setImage($filename);
    $db = Database::getInstance();
    $new = $img->isNew();
    if (!$img->save()) {
        redirectMsg('./images.php?op=' . ($edit ? 'edit&id=' . $id : 'new') . '&' . $ruta, __('Errors ocurred while trying to save image.', 'galleries') . $img->errors(), 1);
        die;
    } else {
        $user->addPic();
        $img->setTags($tgs);
        $sets = '';
        $tbl1 = $db->prefix("gs_sets");
        $tbl2 = $db->prefix("gs_setsimages");
        foreach ($albums as $k => $v) {
            // Si el album existe no incrementamos el numero de imagenes
            $sets .= $sets == '' ? "{$tbl2}.id_set<>'{$v}'" : " AND {$tbl2}.id_set<>'{$v}'";
            if ($img->inSet($v)) {
                continue;
            }
            $album = new GSSet($v);
            $album->addPic($img->id());
        }
        // Actualizamos los valores de los ignorados
        $sql = "UPDATE {$tbl1}, {$tbl2} SET {$tbl1}.pics={$tbl1}.pics-1 WHERE ({$tbl2}.id_image='" . $img->id() . "'" . ($sets != '' ? ' AND ' . $sets : '') . ") AND {$tbl1}.id_set={$tbl2}.id_set";
        $db->queryF($sql);
        $sets = str_replace($tbl2 . '.', '', $sets);
        $sql = "DELETE FROM " . $db->prefix("gs_setsimages") . " WHERE id_image='" . $img->id() . "' " . ($sets != '' ? " AND ({$sets})" : '');
        $db->queryF($sql);
        redirectMsg('./images.php?' . $ruta, __('Database updated successfully!', 'galleries'), 0);
        die;
    }
}
Beispiel #13
0
/**
* Resize images
*/
function gs_resize_images()
{
    global $xoopsUser, $xoopsLogger, $xoopsSecurity;
    set_time_limit(0);
    $mc = RMUtilities::module_config('galleries');
    $params = rmc_server_var($_GET, 'data', '');
    $id = rmc_server_var($_GET, 'img', 0);
    if ($params == '') {
        send_error(__('Unauthorized!', 'galleries'));
    }
    if ($id <= 0) {
        send_error(__('Invalid image!', 'galleries'));
    }
    $params = TextCleaner::decrypt($params);
    $data = explode('|', $params);
    if ($data[0] != $xoopsUser->uid()) {
        send_error(__('Unauthorized!', 'galleries'));
    }
    if ($data[1] != GS_URL . '/admin/images.php') {
        send_error(__('Unauthorized!', 'galleries'));
    }
    if (!$xoopsSecurity->check(false, $data[2])) {
        send_error(__('Unauthorized!', 'galleries'));
    }
    $image = new GSImage($id);
    if ($image->isNew()) {
        send_error(__('Image not found!', 'galleries'));
    }
    $thSize = $mc['image_ths'];
    $imgSize = $mc['image'];
    if ($thSize[0] <= 0) {
        $thSize[0] = 100;
    }
    if (!isset($thSize[1]) || $thSize[1] <= 0) {
        $thSize[1] = $thSize[0];
    }
    if ($imgSize[0] <= 0) {
        $imgSize[0] = 500;
    }
    if (!isset($imgSize[1]) || $imgSize[1] <= 0) {
        $imgSize[1] = $imgSize[0];
    }
    $xu = new GSUser($image->owner(), 1);
    $updir = rtrim($mc['storedir'], '/') . "/" . $xu->uname();
    $upurl = str_replace(XOOPS_ROOT_PATH, XOOPS_URL, $updir);
    $upths = rtrim($mc['storedir'], '/') . "/" . $xu->uname() . "/ths";
    $width = 0;
    $tfile = '';
    // Almacenamos la imágen original
    if ($mc['saveoriginal']) {
        copy($updir . '/' . $image->image(), $mc['storedir'] . '/originals/' . $image->image());
    }
    $fd = pathinfo($updir . '/' . $image->image());
    $filename = $image->image();
    $redim = new RMImageResizer($updir . '/' . $image->image(), $updir . '/' . $image->image());
    switch ($mc['redim_image']) {
        case 0:
            //Recortar miniatura
            $redim->resizeWidth($imgSize[0]);
            $redim->setTargetFile($upths . "/{$filename}");
            $redim->resizeAndCrop($thSize[0], $thSize[1]);
            break;
        case 1:
            //Recortar imagen grande
            $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
            $redim->setTargetFile($upths . "/" . $image->image());
            $redim->resizeWidth($thSize[0]);
            break;
        case 2:
            //Recortar ambas
            $redim->resizeWidthOrHeight($imgSize[0], $imgSize[1]);
            $redim->setTargetFile($upths . "/{$filename}");
            $redim->resizeAndCrop($thSize[0], $thSize[1]);
            break;
        case 3:
            //Redimensionar
            $redim->resizeWidth($imgSize[0]);
            $redim->setTargetFile($upths . "/{$filename}");
            $redim->resizeWidth($thSize[0]);
            break;
    }
    $tfile = $upurl . '/ths/' . $image->image();
    $ret['message'] = sprintf(__('%s done!', 'galleries'), $image->image());
    $ret['done'] = 1;
    $ret['file'] = $tfile;
    $ret['title'] = $image->image();
    echo json_encode($ret);
    die;
}
Beispiel #14
0
/**
* @desc Almacena la asignación de albumes a las imágenes
**/
function saveSets()
{
    global $db, $xoopsUser, $xoopsConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Picture with id %u is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Picture with id %u does not exists!', 'galleries'), $k);
            continue;
        }
        if ($img->owner() != $xoopsUser->uid()) {
            $errors = sprintf(__('You don\'t have authorization!', 'galleries'), $k);
            continue;
        }
        $db = XoopsDatabaseFactory::getDatabaseConnection();
        $sets = '';
        $tbl1 = $db->prefix("gs_sets");
        $tbl2 = $db->prefix("gs_setsimages");
        foreach ($albums as $k => $v) {
            // Si el album existe no incrementamos el numero de imagenes
            if ($img->inSet($v)) {
                continue;
            }
            $album = new GSSet($v);
            $album->addPic($img->id());
        }
        // Actualizamos los valores de los ignorados
        $sql = "UPDATE {$tbl1}, {$tbl2} SET {$tbl1}.pics={$tbl1}.pics-1 WHERE ({$tbl2}.id_image='" . $img->id() . "'" . ($sets != '' ? ' AND ' . $sets : '') . ") AND {$tbl1}.id_set={$tbl2}.id_set";
        $db->queryF($sql);
    }
    if (!$referer) {
        $referer = GSFunctions::get_url();
    }
    if ($errors != '') {
        redirect_header($referer, 2, __('Errors ocurred while trying to update picture!', 'galleries') . $errors);
        die;
    } else {
        redirect_header($referer, 2, __('Pictures updated successfully!', 'galleries'));
        die;
    }
}