Example #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;
}
Example #2
0
/**
* @desc Visualiza todos los albums
**/
function showAlbums()
{
    global $tpl, $xoopsModule, $mc, $xoopsSecurity;
    define('RMSUBLOCATION', 'sets');
    $db = Database::getInstance();
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $limit = 15;
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 1;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $query = "search={$search}&page={$page}&sort={$sort}&mode={$mode}";
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets');
    $sql1 = '';
    $words = array();
    if ($search) {
        //Separamos en palabras
        $words = explode(" ", $search);
        foreach ($words as $k) {
            $k = trim($k);
            if (strlen($k) <= 2) {
                continue;
            }
            $sql1 .= $sql1 == '' ? " WHERE (title LIKE '%{$k}%' OR uname LIKE '%{$k}%')" : " OR (title LIKE '%{$k}%' OR uname LIKE '%{$k}%')";
        }
    }
    list($num) = $db->fetchRow($db->query($sql . $sql1));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("sets.php?page={PAGE_NUM}&sort={$sort}&mode={$mode}&search={$search}");
    //Fin de barra de navegación
    $sql = str_replace('COUNT(*)', '*', $sql);
    $sql2 = $sort ? " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC ") : '';
    $sql2 .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql . $sql1 . $sql2);
    $sets = array();
    while ($rows = $db->fetchArray($result)) {
        foreach ($words as $k) {
            $rows['title'] = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['title']);
            $rows['uname'] = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['uname']);
        }
        $set = new GSSet();
        $set->assignVars($rows);
        $sets[] = array('id' => $set->id(), 'title' => $set->title(), 'owner' => $set->uname(), 'public' => $set->isPublic(), 'date' => formatTimeStamp($set->date(), 'c'), 'pics' => $set->pics(), 'url' => $set->url());
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Albums Management', 'galleries'));
    RMTemplate::get()->assign('xoops_pagetitle', 'Albums Management');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_head("<script type='text/javascript'>\n\n    var delete_warning='" . __('Do you really wish to delete selected albums?', 'galleries') . "';\n\n    var delete_formats='" . __('Do you really wish to delete all images formats for this album?\\nOnly deletes formats for albums, search and others, except normal thumbnails.', 'galleries') . "';\n\n    </script>");
    RMTemplate::get()->add_script('../include/js/gsscripts.php?file=sets');
    $cHead = '<link href="' . XOOPS_URL . '/modules/galleries/styles/admin.css" media="all" rel="stylesheet" type="text/css" />';
    xoops_cp_header($cHead);
    include RMTemplate::get()->get_template('admin/gs_albums.php', 'module', 'galleries');
    xoops_cp_footer();
}
Example #3
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;
}
Example #4
0
 case 'albums':
     $rss_channel['title'] = $xoopsModule->name();
     $rss_channel['link'] = GSFunctions::get_url();
     $rss_channel['description'] = __('These are the recent albums created 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 Albums', 'galleries');
     $rss_channel['generator'] = 'MyGalleries 3';
     $rss_channel['language'] = RMCLANG;
     $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE public='2' ORDER BY `date` DESC LIMIT 0, 10";
     $result = $db->query($sql);
     $users = array();
     while ($rows = $db->fetchArray($result)) {
         $set = new GSSet();
         $set->assignVars($rows);
         //Obtenemos una imagen del album
         $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE";
         $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY RAND() LIMIT 0,4";
         $resimg = $db->query($sql);
         if (!isset($users[$set->owner()])) {
             $users[$set->owner()] = new GSUser($set->owner(), 1);
         }
         $imgs = '<a href="' . $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id()) . '">';
         while ($rowimg = $db->fetchArray($resimg)) {
             $img = new GSImage();
             $img->assignVars($rowimg);
             $urlimg = $users[$set->owner()]->filesURL() . '/' . ($config['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
             // Conversion de los formatos
             if (!$img->setFormat() && $config['set_format_mode']) {
                 GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height);
Example #5
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';
}
 /**
  * @desc Devuelve los albumes a los que pertenece una imágen
  * @param bool $obj Determina si se obtienen los objetos GSSet
  * @return array
  */
 public function sets($obj = true)
 {
     $db =& $this->db;
     if (empty($this->_sets) || $this->_settype != $obj) {
         $this->_sets = array();
         $tbl1 = $db->prefix("gs_sets");
         $tbl2 = $db->prefix("gs_setsimages");
         $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_image='" . $this->id() . "' AND a.id_set=b.id_set";
         $result = $db->query($sql);
         while ($row = $db->fetchArray($result)) {
             if ($obj) {
                 $set = new GSSet();
                 $set->assignVars($row);
                 $this->_sets[] = $set;
             } else {
                 $this->_sets[] = $row;
             }
         }
     }
     return $this->_sets;
 }
Example #7
0
 public function delete()
 {
     //Eliminamos las imágenes
     $sql = "SELECT * FROM " . $this->db->prefix('gs_images') . " WHERE owner='" . $this->uid() . "'";
     $result = $this->db->query($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $img = new GSImage();
         $img->assignVars($rows);
         $img->delete();
     }
     RMUtilities::delete_directory($this->filesPath());
     //Eliminamos los albumes
     $sql = "SELECT * FROM " . $this->db->prefix('gs_sets') . " WHERE owner='" . $this->uid() . "'";
     $result = $this->db->query($sql);
     while ($rows = $this->db->fetchArray($result)) {
         $set = new GSSet();
         $set->assignVars($rows);
         $set->delete();
     }
     return $this->deleteFromTable();
 }
Example #8
0
function gs_sets_show($options)
{
    global $xoopsUser, $xoopsModuleConfig;
    $db = Database::getInstance();
    $wo = '';
    $tsets = $db->prefix("gs_sets");
    $tfriends = $db->prefix("gs_friends");
    $mc = RMUtilities::module_config('galleries');
    $format = $mc['set_format_values'];
    $crop = $format[0];
    // 0 = Redimensionar, 1 = Cortar
    $width = $format[1];
    $height = $format[2];
    if ($xoopsUser) {
        $wo = "{$tsets}.owner='" . $xoopsUser->uid() . "' OR";
    }
    $sql = "SELECT * FROM {$tsets} WHERE owner='1' OR public='2' ORDER BY `date` DESC LIMIT 0,{$options['0']}";
    $result = $db->query($sql);
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsuser.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
    $block = array();
    $users = array();
    $tf = new RMTimeFormatter(0, '%T% %d%, %Y%');
    while ($row = $db->fetchArray($result)) {
        $rtn = array();
        $set = new GSSet();
        $set->assignVars($row);
        if (!isset($users[$set->owner()])) {
            $users[$set->owner()] = new GSUser($set->owner(), 1);
        }
        // Si se ha seleccionado la opción para mostrar imágenes entonces...
        if ($options[1]) {
            //Obtenemos una imagen del album
            $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE";
            $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY b.created DESC LIMIT 0,1";
            $resimg = $db->query($sql);
            if ($db->getRowsNum($resimg) > 0) {
                $rowimg = $db->fetchArray($resimg);
                $img = new GSImage();
                $img->assignVars($rowimg);
                $urlimg = $users[$set->owner()]->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
                // Conversion de los formatos
                if (!$img->setFormat() && $mc['set_format_mode']) {
                    GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height);
                    $img->setSetFormat(1, 1);
                }
            } else {
                $urlimg = '';
            }
            $rtn['img'] = $urlimg;
        }
        $rtn['id'] = $set->id();
        $rtn['title'] = $set->title();
        $rtn['owner'] = $set->owner();
        $rtn['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id());
        if ($options[2]) {
            $rtn['date'] = $tf->format($set->date());
            $rtn['pics'] = $set->pics();
            $rtn['uname'] = $set->uname();
            $rtn['linkuser'] = $users[$set->owner()]->userURL();
        }
        $block['sets'][] = $rtn;
    }
    $block['showimg'] = $options[1];
    $block['showinfo'] = $options[2];
    $block['item_width'] = $options[3];
    RMTemplate::get()->add_xoops_style('blocks.css', 'galleries');
    RMTemplate::get()->add_local_script('blocks.js', 'galleries');
    return $block;
}
Example #9
0
    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);
    }
    $tpl->append('other_sets', array('id' => $set->id(), 'title' => $set->title(), '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)));
}
RMTemplate::get()->add_style('index.css', 'galleries');
include 'footer.php';
Example #10
0
/**
* @desc Visualiza todos los albumes existentes del usuario
**/
function showSets($edit = 0)
{
    global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $page, $xoopsConfig, $id;
    $xoopsOption['template_main'] = 'gs_panel_sets.html';
    include 'header.php';
    $mc =& $xoopsModuleConfig;
    $limit = rmc_server_var($_REQUEST, 'limit', 15);
    GSFunctions::makeHeader();
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? '/cpanel/sets/pag/' . $page : '/cpanel.php?s=cpanel/sets/' . $page);
    if ($edit) {
        //Verificamos que el album sea válido
        if ($id <= 0) {
            redirect_header($link, 1, __('Album ID is not valid!', 'galleries'));
            die;
        }
        //Verificamos que el album exista
        $set = new GSSet($id);
        if ($set->isNew()) {
            redirect_header($link, 1, __('Specified album does not exists!', 'galleries'));
            die;
        }
        $tpl->assign('title', $set->title());
        $tpl->assign('public', $set->isPublic());
        $tpl->assign('edit', $edit);
        $tpl->assign('id', $id);
        $tpl->assign('action_editset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveeditset/pag/' . $page . '/' : '?cp=saveeditset&amp;pag=' . $page));
    }
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'";
    list($num) = $db->fetchRow($db->query($sql));
    $page = $page <= 0 ? 1 : $page;
    list($num) = $db->fetchRow($db->query($sql));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/{PAGE_NUM}/' : '?cp=sets&amp;pag={PAGE_NUM}'));
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'";
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    while ($rows = $db->fetchArray($result)) {
        $set = new GSSet();
        $set->assignVars($rows);
        $tpl->append('sets', array('id' => $set->id(), 'name' => $set->title(), 'owner' => $set->owner(), 'uname' => $set->uname(), 'public' => $set->isPublic(), 'date' => formatTimeStamp($set->date(), 's'), 'pics' => $set->pics(), 'link' => $set->url()));
    }
    $tpl->assign('lang_setexists', __('My Albums', 'galleries'));
    $tpl->assign('lang_id', __('ID', 'galleries'));
    $tpl->assign('lang_name', __('Name', 'galleries'));
    $tpl->assign('lang_date', __('Date', 'galleries'));
    $tpl->assign('lang_public', __('Privacy:', 'galleries'));
    $tpl->assign('lang_options', _OPTIONS);
    $tpl->assign('lang_edit', _EDIT);
    $tpl->assign('lang_del', _DELETE);
    $tpl->assign('lang_confirm', __('Do you really wish to delete specified album?', 'galleries'));
    $tpl->assign('lang_confirms', __('Do you really wish to delete selected albums?', 'galleries'));
    $tpl->assign('lang_newset', __('Add Album', 'galleries'));
    $tpl->assign('lang_editset', __('Edit Album', 'galleries'));
    $tpl->assign('lang_yes', __('Yes', 'galleries'));
    $tpl->assign('lang_no', __('No', 'galleries'));
    $tpl->assign('lang_pics', __('Pictures', 'galleries'));
    $tpl->assign('lang_privateme', __('Private', 'galleries'));
    $tpl->assign('lang_privatef', __('Friends', 'galleries'));
    $tpl->assign('lang_publicset', __('Public', 'galleries'));
    RMTemplate::get()->add_style('panel.css', 'galleries');
    $tpl->assign('action_addset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveset/pag/' . $page . '/' : '?cp=saveset'));
    $tpl->assign('pag', $page);
    $tpl->assign('action_delset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/deleteset/pag/' . $page . '/' : '?cp=deleteset'));
    $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/editset/pag/' . $page . '/id/' : '?cp=editset&amp;pag=' . $page . '&amp;id='));
    createLinks();
    include 'footer.php';
}
Example #11
0
/**
* @desc Visualiza todos los albumes existentes
**/
function sets()
{
    global $tpl, $xoopsOption, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $db, $pag, $usr;
    $mc =& $xoopsModuleConfig;
    $xoopsOption['template_main'] = 'gs_sets.html';
    $xoopsOption['module_subpage'] = 'exploresets';
    include 'header.php';
    //Verificamos si el usuario proporcionado existe
    if ($usr) {
        $owner = new GSUser($usr);
        if ($owner->isNew()) {
            redirect_header(GSFunctions::get_url(), 1, __('Specified user does not exists!', 'galleries'));
            die;
        }
    }
    GSFunctions::makeHeader();
    //Verificamos si el usuario es dueño o amigo
    if ($usr && $xoopsUser) {
        if ($owner->uid() == $xoopsUser->uid()) {
            $public = '';
        } else {
            if ($owner->isFriend($xoopsUser->uid())) {
                $public = " WHERE public<>'0'";
            } else {
                $public = " WHERE public='2'";
            }
        }
    } else {
        $public = " WHERE public='2'";
    }
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets') . " {$public} ";
    $sql .= isset($usr) ? ($public ? " AND " : " WHERE ") . " uname='" . $usr . "'" : '';
    $page = isset($pag) ? $pag : '';
    $limit = $mc['limit_sets'];
    /**
     * @desc Formato para el manejo de las imágenes
     */
    if ($mc['set_format_mode']) {
        $format = $mc['set_format_values'];
        $crop = $format[0];
        // 0 = Redimensionar, 1 = Cortar
        $width = $format[1];
        $height = $format[2];
        $limit = $mc['limit_sets'];
        $cols = $format[4];
        $showdesc = @$format[5];
    } else {
        $limit = $mc['limit_sets'];
        $cols = $mc['cols_sets'];
        $showdesc = 0;
        $width = $mc['image_ths'][0];
    }
    list($num) = $db->fetchRow($db->query($sql));
    if ($page > 0) {
        $page -= 1;
    }
    $start = $page * $limit;
    $tpages = (int) ($num / $limit);
    if ($num % $limit > 0) {
        $tpages++;
    }
    $pactual = $page + 1;
    if ($pactual > $tpages) {
        $rest = $pactual - $tpages;
        $pactual = $pactual - $rest + 1;
        $start = ($pactual - 1) * $limit;
    }
    if ($tpages > 1) {
        if ($mc['urlmode']) {
            $urlnav = 'explore/sets/';
            $urlnav .= isset($usr) ? 'usr/' . $usr . '/' : '';
        } else {
            $urlnav = '?explore=sets';
            $urlnav .= isset($usr) ? '&amp;usr='******'';
        }
        $nav = new RMPageNav($num, $limit, $pactual, 5);
        $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? 'pag/{PAGE_NUM}/' : '&amp;pag={PAGE_NUM}'));
        $tpl->assign('setsNavPage', $nav->render(false));
    }
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    $tpl->assign('lang_showing', sprintf(__('Albums %u to %u from %u', 'galleries'), $start + 1, $showmax, $num));
    $tpl->assign('limit', $limit);
    $tpl->assign('pag', $pactual);
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " {$public}";
    $sql .= isset($usr) ? ($public ? " AND " : " WHERE ") . "uname='" . $usr . "'" : '';
    $sql .= " ORDER BY date desc";
    $sql .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $users = array();
    $tf = new RMTimeFormatter(0, __("%M% %d%, %Y%", 'galleries'));
    while ($rows = $db->fetchArray($result)) {
        $set = new GSSet();
        $set->assignVars($rows);
        //Obtenemos una imagen del album
        $sql = "SELECT b.* FROM " . $db->prefix('gs_setsimages') . " a, " . $db->prefix('gs_images') . " b WHERE";
        $sql .= " a.id_set='" . $set->id() . "' AND b.id_image=a.id_image AND b.public=2 AND b.owner='" . $set->owner() . "' ORDER BY b.created DESC LIMIT 0,1";
        $resimg = $db->query($sql);
        if (!isset($users[$set->owner()])) {
            $users[$set->owner()] = new GSUser($set->owner(), 1);
        }
        if ($db->getRowsNum($resimg) > 0) {
            $rowimg = $db->fetchArray($resimg);
            $img = new GSImage();
            $img->assignVars($rowimg);
            $urlimg = $users[$set->owner()]->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
            // Conversion de los formatos
            if (!$img->setFormat() && $mc['set_format_mode']) {
                GSFunctions::resizeImage($crop, $users[$set->owner()]->filesPath() . '/' . $img->image(), $users[$set->owner()]->filesPath() . '/formats/set_' . $img->image(), $width, $height);
                $img->setSetFormat(1, 1);
            }
        } else {
            $urlimg = '';
        }
        $tpl->append('sets', array('id' => $set->id(), 'title' => $set->title(), 'date' => $tf->format($set->date()), 'owner' => $set->owner(), 'uname' => $set->uname(), 'pics' => $set->pics(), 'img' => $urlimg, 'link' => $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id()), 'linkuser' => $users[$set->owner()]->userURL()));
    }
    $tpl->assign('lang_date', __('Created on:', 'galleries'));
    $tpl->assign('lang_by', __('Owned by:', 'galleries'));
    $tpl->assign('margin', $width + 20);
    $tpl->assign('lang_imgs', __('Images:', 'galleries'));
    $tpl->assign('usr', isset($owner) ? 1 : 0);
    $tpl->assign('lang_setsexist', __('Existing Albums', 'galleries'));
    if (isset($owner)) {
        $tpl->assign('user', array('id' => $owner->uid(), 'uname' => $owner->uname(), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $owner->userVar('email'), 0, $owner->userVar('user_avatar'))));
        $tpl->assign('lang_setsof', sprintf(__('Sets of %s', 'galleries'), $owner->uname()));
        $tpl->assign('pics_link', GSFunctions::get_url() . ($mc['urlmode'] ? "usr/" . $owner->uname() . '/' : "?usr="******"explore/sets/usr/" . $owner->uname() . '/' : "?explore=sets&amp;usr="******"explore/tags/usr/" . $owner->uname() . '/' : "?explore=tags&amp;usr="******"cp/booksmarks/" : "?cp=bookmarks"));
    }
    include 'footer.php';
}