Esempio n. 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;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
}
 /**
  * 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;
 }
Esempio n. 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;
}
Esempio n. 6
0
     $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':
     $rss_channel['title'] = $xoopsModule->name();
     $rss_channel['link'] = GSFunctions::get_url();
     $rss_channel['description'] = __('These are the recent albums created on our galleries.', 'galleries');
Esempio n. 7
0
/**
* @desc Mostramos el contenido de un Álbum
*/
function showSetContent()
{
    global $usr, $db, $xoopsModule, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $xoopsOption, $tpl, $page;
    global $pag, $set;
    $mc =& $xoopsModuleConfig;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified users does not exists!', 'galleries'));
        die;
    }
    $set = new GSSet($set);
    if ($set->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified album does not exists!', 'galleries'));
        die;
    }
    //Verificamos la privacidad del album
    if (!$set->ispublic()) {
        if (!$xoopsUser || $xoopsUser->uid() != $set->owner()) {
            redirect_header(GSFunctions::get_url(), 1, __('You can not view this private album!', 'galleries'));
            die;
        }
    } else {
        if (!$xoopsUser && $set->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
            redirect_header(GSFunctions::get_url(), 1, sprintf(__('You must be a friend of %s in order to see this album!', 'galleries'), $user->uname()));
            die;
        }
    }
    //Incrementamos el número de hits del album
    if (!isset($_SESSION['vsets'])) {
        $set->addHit();
        $_SESSION['vsets'] = array($set->id());
    } elseif (!in_array($set->id(), $_SESSION['vsets'])) {
        $set->addHit();
        $_SESSION['vsets'][] = $set->id();
    }
    $xoopsOption['template_main'] = $mc['set_format_mode'] ? 'gs_setpics.html' : 'gs_userpics.html';
    $xoopsOption['module_subpage'] = 'userset';
    include 'header.php';
    GSFunctions::makeHeader();
    // Información del Usuario
    $tpl->assign('lang_picsof', sprintf(__('Pictures in %s'), $set->title()));
    $tpl->assign('user', array('id' => $user->uid(), 'uname' => $user->uname(), 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $user->userVar('email'), 0, $user->userVar('user_avatar')), 'link' => $user->userURL()));
    $tpl->assign('set', array('title' => $set->title(), 'description' => $set->getVar('description', 's')));
    // Lenguaje
    $tpl->assign('lang_bmark', __('Favorites', 'galleries'));
    $tpl->assign('lang_pics', __('Pictures', 'galleries'));
    $tpl->assign('sets_link', GSFunctions::get_url() . ($mc['urlmode'] ? "explore/sets/usr/" . $user->uname() . '/' : "?explore=sets&amp;usr="******"explore/tags/usr/" . $user->uname() . '/' : "?explore=tags&amp;usr="******"cp/bookmarks/" : "?cp=bookmarks"));
    $tpl->assign('xoops_pagetitle', sprintf(__('Pictures in %s'), $set->title()) . ' &raquo; ' . $mc['section_title']);
    $tpl->assign('lang_numpics', sprintf(__('Pictures: %s', 'galleries'), $set->pics()));
    $tpl->assign('lang_numviews', sprintf(__('Hits: %s'), $set->hits()));
    global $xoTheme;
    if ($set->getVar('description') != '') {
        $xoTheme->addMeta('meta', 'description', TextCleaner::clean_disabled_tags($set->getVar('description')));
    }
    //Verificamos la privacidad de las imágenes
    if ($xoopsUser && $xoopsUser->uid() == $user->uid()) {
        $public = '';
    } else {
        if ($xoopsUser && $user->isFriend($xoopsUser->uid())) {
            $public = " AND public<>0";
        } else {
            $public = "AND public='2'";
        }
    }
    $tbl1 = $db->prefix("gs_images");
    $tbl2 = $db->prefix("gs_setsimages");
    $sql = "SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "'";
    $page = $page > 0 ? $page : 1;
    /**
     * @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 = $format[3];
        $cols = $format[4];
        @($showdesc = $format[5]);
        // Imágenes Grandes
        $format = $mc['setbig_format_values'];
        $bcrop = $format[0];
        $bwidth = $format[1];
        $bheight = $format[2];
        $blimit = $format[3];
        $bcols = $format[4];
        @($bshowdesc = $format[5]);
        // Medidas
        $tpl->assign('big_width', $bwidth + 15);
    } else {
        $limit = $mc['limit_pics'];
        $cols = $mc['cols_pics'];
        $showdesc = 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) {
        $pactual = $tpages;
        $start = ($tpages - 1) * $limit;
    }
    $urlnav = '';
    if ($tpages > 1) {
        $urlnav .= $mc['urlmode'] ? 'usr/' . $user->uname() . '/set/' . $set->id() : '?usr='******'&amp;set=' . $set->id();
        $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('upNavPage', $nav->render(false));
    }
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    $tpl->assign('lang_showing', sprintf(__('Showing pictures %u to %u out of %u.', 'galleries'), $start + 1, $showmax, $num));
    $tpl->assign('limit', $limit);
    $tpl->assign('pag', $pactual);
    //Fin de barra de navegación
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= " ORDER BY a.id_image ASC, a.modified DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        $imglink = $user->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $img->id() . '&amp;set=' . $set->id());
        $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/set_' : 'ths/') . $img->image();
        // Conversion de los formatos
        if (!$img->setFormat() && $mc['set_format_mode']) {
            GSFunctions::resizeImage($crop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/set_' . $img->image(), $width, $height);
            $img->setSetFormat(1, 1);
        }
        $tpl->append('images', array('id' => $img->id(), 'title' => $img->title(), 'thumbnail' => $imgfile, 'link' => $imglink, 'bigimage' => $user->filesURL() . '/' . $img->image()));
    }
    // Imagen grande del album
    $sql = "SELECT * FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image {$public} AND owner='" . $user->uid() . "' \n\t\t\tORDER BY a.id_image DESC LIMIT 0,{$blimit}";
    $result = $db->query($sql);
    $bi = 0;
    $tf = new RMTimeFormatter(0, __('%m%/%d%/%Y% %h%:%i%', 'galleries'));
    // cremos la imagen grande para los albumes
    while ($row = $db->fetchArray($result)) {
        $img = new GSImage();
        $img->assignVars($row);
        if ($mc['set_format_mode'] && !$img->bigSetFormat()) {
            GSFunctions::resizeImage($bcrop, $user->filesPath() . '/' . $img->image(), $user->filesPath() . '/formats/bigset_' . $img->image(), $bwidth, $bheight);
            $img->setBigSetFormat(1, 1);
        }
        if ($mc['set_format_mode']) {
            list($ancho, $altura, $tipo, $atr) = getimagesize($user->filesPath() . '/formats/bigset_' . $img->image());
            $tpl->assign('big_width', $ancho);
        }
        $imglink = $user->userURL() . 'img/' . $img->id() . '/set/' . $set->id() . '/';
        // ASignamos las imagenes grandes para los albumes
        $imgfile = $user->filesURL() . '/' . ($mc['set_format_mode'] ? 'formats/bigset_' : 'ths/') . $img->image();
        if ($bi == 0) {
            $tpl->assign('lang_updated', sprintf(__('Updated on %s', 'galleries'), $tf->format($img->created())));
        }
        $tpl->append('bigs', array('id' => $img->id(), 'title' => $img->title(), 'image' => $imgfile, 'link' => $imglink));
    }
    RMFunctions::get_comments('galleries', 'set=' . $set->id());
    // Comments form
    RMFunctions::comments_form('galleries', 'set=' . $set->id(), 'module', GS_PATH . '/class/galleriescontroller.php');
    // Datos para el formato
    $tpl->assign('max_cols', $cols);
    include 'footer.php';
}
Esempio n. 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");
}
Esempio n. 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");
}
Esempio n. 10
0
/**
* @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;
    }
}
Esempio n. 11
0
    $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);
    }
    $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');
Esempio n. 12
0
/**
* @desc Elimina la(s) imagen(es) especificada(s)
**/
function deleteImages()
{
    global $xoopsSecurity, $xoopsModule, $db;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $ok = isset($_POST['ok']) ? $_POST['ok'] : 0;
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $owner = isset($_REQUEST['owner']) ? intval($_REQUEST['owner']) : '';
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0;
    $ruta = "page={$page}&limit={$limit}&search={$search}&owner={$owner}&sort={$sort}&mode={$mode}";
    //Verificamos si nos proporcionaron al menos un imagen para eliminar
    if (!is_array($ids)) {
        redirectMsg('./images.php?' . $ruta, __('No images has been selected!', 'galleries'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./images.php?' . $ruta, __('Session token expired!', 'galleries'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Image ID "%s" not valid', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Image "%s" does not exists!', 'galleries'), $k);
            continue;
        }
        $sets = $img->sets();
        if (!$img->delete()) {
            $errors .= sprintf(__('Image "%s" could not be deleted!', 'galleries'), $k);
        } else {
            //Decrementamos el número de imágenes de los albumes
            foreach ($sets as $k => $set) {
                $set->quitPic($img->id());
            }
        }
    }
    if ($erros != '') {
        redirectMsg('./images.php?' . $ruta, __('Errors ocurred while trying to delete images', 'galleries') . $errors, 1);
        die;
    } else {
        redirectMsg('./images.php?' . $ruta, __('Images deleted successfully!', 'galleries'), 0);
        die;
    }
}
Esempio n. 13
0
function saveBulkImages()
{
    $mc = RMUtilities::module_config('galleries');
    XoopsLogger::getInstance()->activated = false;
    XoopsLogger::getInstance()->renderingEnabled = false;
    set_time_limit(0);
    $security = TextCleaner::getInstance()->decrypt(rmc_server_var($_POST, 'rmsecurity', 0), true);
    $data = explode("|", $security);
    $xoopsUser = new XoopsUser($data[1]);
    if (!isset($data[1]) || $data[1] != XOOPS_URL . '/modules/galleries/admin/images.php') {
        send_error(__('You are not allowed to do this action', 'galleries'));
    }
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = "page={$page}&search={$search}&owner={$uid}&sort={$sort}&mode={$mode}";
    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()) {
            send_error(__('User owner could not be created!', 'galleries') . "<br />" . $user->errors());
            die;
        } else {
            mkdir($mc['storedir'] . "/" . $user->uname());
            mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
            mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
        }
    } else {
        @mkdir($mc['storedir'] . "/" . $user->uname());
        @mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
        @mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
    }
    // Insertamos las etiquetas
    $tgs = explode(",", $tags);
    /**
     * @desc Almacena los ids de las etiquetas que se asignarán a la imágen
     */
    $ret = array();
    foreach ($tgs as $k) {
        $k = trim($k);
        if ($k == '') {
            continue;
        }
        // Comprobamos que la palabra tenga la longitud permitida
        if (strlen($k) < $mc['min_tag'] || strlen($k) > $mc['max_tag']) {
            continue;
        }
        // Creamos la etiqueta
        $tag = new GSTag(TextCleaner::getInstance()->sweetstring($k));
        if (!$tag->isNew()) {
            // Si ya existe nos saltamos
            $ret[] = $tag->id();
            continue;
        }
        $tag->setTag($k);
        if ($tag->save()) {
            $ret[] = $tag->id();
        }
    }
    $errors = '';
    $k = 1;
    include_once RMCPATH . '/class/uploader.php';
    $updir = $mc['storedir'] . "/" . $xu->uname();
    $upths = $mc['storedir'] . "/" . $xu->uname() . "/ths";
    // Cargamos la imágen
    if (!file_exists($updir)) {
        mkdir($updir, 511);
    }
    if (!file_exists($upths)) {
        mkdir($upths, 511);
    }
    $uploader = new RMFileUploader($updir, $mc['size_image'] * 1024, array('gif', 'jpg', 'jpeg', 'png'));
    $err = array();
    if (!$uploader->fetchMedia('Filedata')) {
        send_error($uploader->getErrors());
    }
    if (!$uploader->upload()) {
        send_error($uploader->getErrors());
    }
    // Insertamos el archivo en la base de datos
    $img = new GSImage();
    $img->setTitle($uploader->savedFileName);
    $img->setOwner($uid);
    $img->setPublic(2);
    $img->setCreated(time());
    $img->setImage($uploader->getSavedFileName());
    if (!$img->save()) {
        unlink($uploader->savedDestination);
        send_error(__('File could not be inserted to database!', 'galleries'));
    }
    $user->addPic();
    $img->setTags($ret);
    //Albumes
    $sets = explode(",", $sets);
    if (!empty($sets)) {
        foreach ($sets as $k => $v) {
            $album = new GSSet($v);
            $album->addPic($img->id());
        }
    }
    $ret['message'] = '1';
    $ret['id'] = $img->id();
    echo json_encode($ret);
    die;
}
Esempio n. 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;
    }
}