public function get_item_url($params, $com)
 {
     static $cimgs;
     static $csets;
     $params = urldecode($params);
     parse_str($params);
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gstag.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
     if (isset($set) && $set > 0) {
         if (isset($csets[$set])) {
             $ret = $csets[$set]->url() . '#comment-' . $com->id();
             return $ret;
         }
         $sobj = new GSSet($set);
         if ($sobj->isNew()) {
             return '';
         }
         $ret = $sobj->url() . '#comment-' . $com->id();
         $csets[$set] = $sobj;
         return $ret;
     } elseif (isset($image) && $image > 0) {
         if (isset($cimgs[$image])) {
             $ret = $cimgs[$image]->permalink() . '#comment-' . $com->id();
             return $ret;
         }
         $img = new GSImage($image);
         if ($img->isNew()) {
             return '';
         }
         $ret = $img->permalink() . '#comment-' . $com->id();
         $cimgs[$image] = $img;
         return $ret;
     }
 }
 public function get_item($params, $com, $url = false)
 {
     static $cimgs;
     static $csets;
     $params = urldecode($params);
     parse_str($params);
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gstag.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php';
     if (isset($set) && $set > 0) {
         if (isset($csets[$set])) {
             $ret = '<a href="' . $csets[$set]->url() . '#comment-' . $com->id() . '">' . $csets[$set]->title() . '</a>';
             return $ret;
         }
         $sobj = new GSSet($set);
         if ($sobj->isNew()) {
             return __('Unknow element', 'galleries');
         }
         $ret = '<a href="' . $sobj->url() . '#comment-' . $com->id() . '">' . $sobj->title() . '</a>';
         $csets[$set] = $sobj;
         return $ret;
     } elseif (isset($image) && $image > 0) {
         if (isset($cimgs[$image])) {
             $ret = '<a href="' . $cimgs[$image]->permalink() . '#comment-' . $com->id() . '">' . $cresources[$res]->getVar('title') . '</a>';
             return $ret;
         }
         $img = new GSImage($image);
         if ($img->isNew()) {
             return __('Unknow element', 'docs');
         }
         $ret = '<a href="' . $img->permalink() . '#comment-' . $com->id() . '">' . $img->title(true) . '</a>';
         $cimgs[$image] = $img;
         return $ret;
     }
 }
Example #3
0
/**
* @desc Busca la posición exacta de una etiqueta
*/
function browsePic()
{
    global $usr, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $pag, $set, $browse;
    $mc =& $xoopsModuleConfig;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRUSR);
        die;
    }
    $image = new GSImage($browse);
    if ($image->isNew()) {
        redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRIMG);
        die;
    }
    if (isset($set)) {
        $set = new GSSet($set);
        if ($set->isNew()) {
            redirect_header(XOOPS_URL . '/modules/galleries', 0, _MS_GS_ERRSET);
            die;
        }
    }
    $page = GSFunctions::pageFromPic($image, $user, $set > 0 ? $set : 0);
    header('location: ' . $user->userURL() . 'pag/' . $page);
}
Example #4
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");
}
Example #5
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 #6
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");
}
Example #7
0
/**
*  @desc Elimina una imagen de favoritos
**/
function deleteBookMarks()
{
    global $xoopsUser, $xoopsModuleConfig;
    $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $mc =& $xoopsModuleConfig;
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/bookmarks/pag/' . $page . '/' : '?cp=bookmarks&amp;pag=' . $page);
    //Verificamos si nos proporcionaron al menos un imagen para eliminar
    if (!is_array($ids)) {
        redirect_header($link, 2, __('You must select one picture at least!', 'galleries'));
        die;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $db = Database::getInstance();
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen sea válida
        if ($k <= 0) {
            $errors .= sprintf(__('ID %u is not valid!', 'galleries'), $k);
            continue;
        }
        //Verificamos si la imagen existe
        $img = new GSImage($k);
        if ($img->isNew()) {
            $errors .= sprintf(__('Image with id %u is not valid!', 'galleries'), $k);
            continue;
        }
        $sql = "DELETE FROM " . $db->prefix('gs_favourites') . " WHERE id_image='" . $k . "' AND uid='" . $xoopsUser->uid() . "'";
        $result = $db->queryF($sql);
        if (!$result) {
            $errors .= sprintf(__('Favorite picture "%s" could not be deleted!', 'galleries'), $img->title());
        }
    }
    if ($errors != '') {
        redirect_header($link, 2, __('Errors ocurred while trying to delete favorites!', 'galleries') . $errors);
        die;
    } else {
        redirect_header($link, 1, __('Favorites deleted successfully!', 'galleries'));
        die;
    }
}
Example #8
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;
    }
}
 /**
  * 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;
 }
Example #10
0
$tpl->assign('last_images', GSFunctions::process_image_data($result));
// Álbumes Recientes
$result = $db->query("SELECT * FROM " . $db->prefix("gs_sets") . " WHERE public='2' ORDER BY date DESC LIMIT 0," . ($mc['sets_num'] > 0 ? $mc['sets_num'] : 5));
while ($row = $db->fetchArray($result)) {
    $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();
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';
}
Example #12
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;
}
Example #13
0
/**
* @desc Publica o no publica las imágenes especificadas
**/
function publicImages($pub = 0)
{
    $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 una imagen
    if (!is_array($ids)) {
        redirectMsg('./images.php?' . $ruta, __('No images has been selected!', 'galleries'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la imagen es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Image ID "%s" is 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;
        }
        $img->setPublic($pub);
        if (!$img->save()) {
            $errors .= sprintf(__('Image could not be updated!', 'galleries'), $k);
        }
    }
    if ($erros != '') {
        redirectMsg('./images.php?' . $ruta, __('Errors ocurred while trying to update images!') . $errors, 1);
        die;
    } else {
        redirectMsg('./images.php?' . $ruta, __('Images updated successfully!', 'galleries'), 0);
        die;
    }
}
Example #14
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;
}
Example #15
0
 $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);
             $img->setSetFormat(1, 1);
         }
         $imgs .= '<img src="' . $urlimg . '" alt="' . $set->title() . '" /> ';
     }
     $imgs .= '</a>';
     $desc = $imgs . '<br />';
     $desc .= sprintf(__('By: <strong>%s</strong>', 'galleries'), $set->uname());
     $item = array();
     $item['title'] = $set->title();
     $item['link'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id());
Example #16
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 #17
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 #18
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 #19
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;
}
Example #20
0
/**
* @desc Almacena las imágenes en la base de datos y en el disco duro
*/
function saveImages()
{
    global $db, $xoopsOption, $xoopsUser, $mc, $tpl, $xmh, $xoopsModuleConfig, $util;
    $mc =& $xoopsModuleConfig;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    //Verificamos si el usuario se encuentra registrado
    $user = new GSUser($xoopsUser->uname());
    if ($user->isNew()) {
        //Insertamos información del usuario
        $user->setUid($xoopsUser->uid());
        $user->setUname($xoopsUser->uname());
        $user->setQuota($mc['quota'] * 1024 * 1024);
        $user->setDate(time());
        if (!$user->save()) {
            redirect_header('./submit.php', 1, __('Sorry, an error ocurred while trying to register your permissions on database. Try again later!', 'galleries'));
            die;
        }
    }
    @mkdir($mc['storedir'] . "/" . $user->uname());
    @mkdir($mc['storedir'] . "/" . $user->uname() . "/ths");
    @mkdir($mc['storedir'] . "/" . $user->uname() . "/formats");
    $mc['saveoriginal'] ? @mkdir($mc['storedir'] . "/originals") : '';
    // Insertamos las etiquetas
    $tgs = explode(" ", $tags);
    /**
     * @desc Almacena los ids de las etiquetas que se asignarán a la imagen
     */
    $ret = array();
    foreach ($tgs as $k) {
        $k = trim($k);
        $kf = TextCleaner::getInstance()->sweetstring($k);
        if ($kf == '') {
            continue;
        }
        // Comprobamos que la palabra tenga la longitud permitida
        if (strlen($kf) < $mc['min_tag'] || strlen($kf) > $mc['max_tag']) {
            continue;
        }
        // Creamos la etiqueta
        $tag = new GSTag($k);
        if (!$tag->isNew()) {
            // Si ya existe nos saltamos
            $ret[] = $tag->id();
            continue;
        }
        $tag->setTag($k);
        $tag->setVar('nameid', $kf);
        if ($tag->save()) {
            $ret[] = $tag->id();
        }
    }
    $errors = '';
    $k = 1;
    include_once RMCPATH . '/class/uploader.php';
    $up = new RMFileUploader(true);
    $folder = $mc['storedir'] . "/" . $xoopsUser->uname();
    $folderths = $mc['storedir'] . "/" . $xoopsUser->uname() . "/ths";
    foreach ($_FILES['images']['name'] as $k => $v) {
        if ($v == '') {
            continue;
        }
        $img = new GSImage();
        $img->setOwner($xoopsUser->uid());
        $img->setPublic($privacy);
        $img->setCreated(time());
        //Imagen
        $filename = '';
        $up = new RMFileUploader($folder, $mc['size_image'] * 1024, array('jpg', 'png', 'gif'));
        if ($up->fetchMedia('images', $k)) {
            if (!$up->upload()) {
                $errors .= $up->getErrors();
                continue;
            }
            $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;
            }
        }
        //Fin de Imagen
        $img->setImage($filename);
        if ($up->getErrors() == '') {
            if (!$img->save()) {
                $errors .= sprintf(__('Picture %s could not be uploaded!', 'galleries'), $v) . " (" . $img->errors() . ")";
            } else {
                $user->addPic();
                if ($ret) {
                    $img->setTags($ret);
                }
            }
        } else {
            $errors .= $up->getErrors();
        }
        ++$k;
    }
    if ($errors != '') {
        redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images' : '?cp=images'), 2, __('Errors ocurred while trying to upload images!', 'galleries') . $errors);
        die;
    } else {
        redirect_header(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images' : '?cp=images'), 2, __('Pictures stored successfully!', 'galleries'));
        die;
    }
}