public function eventRmcommonGetFeedsList($feeds) { load_mod_locale('galleries'); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php'; $module = RMFunctions::load_module('galleries'); $config = RMUtilities::module_config('galleries'); $data = array('title' => $module->name(), 'url' => GSFunctions::get_url(), 'module' => 'galleries'); $options[] = array('title' => __('All Recent Pictures', 'galleries'), 'params' => 'show=pictures', 'description' => __('Show all recent pictures', 'galleries')); $options[] = array('title' => __('All Recent Albums', 'galleries'), 'params' => 'show=albums', 'description' => __('Show all recent albums', 'galleries')); $feed = array('data' => $data, 'options' => $options); $feeds[] = $feed; return $feeds; }
function createLinks() { global $tpl, $xoopsModuleConfig, $xmh, $xoopsUser; $mc =& $xoopsModuleConfig; $tpl->assign('link_bookmarks', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/bookmarks/" : "?cp=bookmarks")); $tpl->assign('lang_favourites', __('Favorites', 'galleries')); $tpl->assign('user', 0); $users = GSFunctions::getAllowedUsers(); if (in_array($xoopsUser->uid(), $users)) { $tpl->assign('link_friends', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/friends/" : "?cp=friends")); $tpl->assign('link_photos', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/images/" : "?cp=images")); $tpl->assign('link_sets', GSFunctions::get_url() . ($mc['urlmode'] ? "cp/sets/" : "?cp=sets")); $tpl->assign('lang_friends', __('Friends', 'galleries')); $tpl->assign('lang_msets', __('My Albums', 'galleries')); $tpl->assign('lang_mpics', __('My Images', 'galleries')); $tpl->assign('user', 1); } }
/** * @desc Visualiza todas las postales existentes **/ function showPostCards() { global $xoopsModule, $tpl, $xoopsModuleConfig, $xoopsSecurity; $mc =& $xoopsModuleConfig; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $limit = $limit <= 0 ? 15 : $limit; $db = XoopsDatabaseFactory::getDatabaseConnection(); //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_postcards'); list($num) = $db->fetchRow($db->query($sql)); 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("postcards.php?page={PAGE_NUM}&limit={$limit}"); //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_postcards'); $sql .= " LIMIT {$start},{$limit}"; $result = $db->query($sql); $posts = array(); $tf = new RMTimeFormatter(0, __('%M% %d%, %Y% - %h%:%i%:%s%', 'galleries')); while ($rows = $db->fetchArray($result)) { $post = new GSPostcard(); $post->assignVars($rows); $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&id=' . $post->code()); $posts[] = array('id' => $post->id(), 'title' => $post->title(), 'date' => $tf->format($post->date()), 'toname' => $post->toName(), 'name' => $post->email(), 'view' => $post->viewed(), 'link' => $link); } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('E-cards', 'galleries')); xoops_cp_header(); RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-postcards&', 'galleries'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected e-cards?', 'galleries') . "';\n</script>"); include RMTemplate::get()->get_template('admin/gs_postcards.php', 'module', 'galleries'); xoops_cp_footer(); }
/** * @desc Crea el encabezado de la sección frontal */ public function makeHeader() { global $xoopsModuleConfig, $tpl, $xoopsUser; $mc =& $xoopsModuleConfig; $tpl->assign('gs_title', $mc['section_title']); $tpl->assign('lang_home', __('Home', 'galleries')); $tpl->assign('lang_tags', __('Tags', 'galleries')); $tpl->assign('lang_sets', __('Albums', 'galleries')); $tpl->assign('lang_hphotos', __('Photos', 'galleries')); $tpl->assign('gs_tagslink', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/tags/' : 'explore.php?explore=tags')); $tpl->assign('gs_setslink', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/sets/' : 'explore.php?explore=sets')); $tpl->assign('gs_photoslink', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/photos/' : 'explore.php?explore=photos')); $tpl->assign('gs_searchlink', GSFunctions::get_url() . ($mc['urlmode'] ? 'search/' : '?search=1')); $tpl->assign('lang_search', __('Search', 'galleries')); if ($xoopsUser && in_array($xoopsUser->uid(), GSFunctions::getAllowedUsers())) { $tpl->assign('lang_myphotos', __('My Photos', 'galleries')); $tpl->assign('gs_myphotoslink', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images/' : '?cp=images')); } if (GSFunctions::canSubmit($xoopsUser)) { $tpl->assign('can_submit', 1); $tpl->assign('lang_sendpics', __('Upload Photos', 'galleries')); $tpl->assign('gs_sendlink', GSFunctions::get_url() . ($mc['urlmode'] ? 'submit/' : 'submit.php')); } }
} $imglink = $users[$img->owner()]->userURL() . ($mc['urlmode'] ? 'img/' . $img->id() . '/' : '&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'); $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";
/** * @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&usr="******"explore/tags/usr/" . $user->uname() . '/' : "?explore=tags&usr="******"cp/bookmarks/" : "?cp=bookmarks")); $tpl->assign('xoops_pagetitle', sprintf(__('Pictures in %s'), $set->title()) . ' » ' . $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='******'&set=' . $set->id(); $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? '/pag/{PAGE_NUM}/' : '&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() . '/' : '&img=' . $img->id() . '&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'; }
/** * @desc Envia la postal */ function sendPostcard() { global $tpl, $xoopsModule, $xoopsModuleConfig, $rmc_config, $mc, $xoopsUser, $xoopsConfig, $util; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsUser) { redirect_header(XOOPS_URL . '/user.php#register', 1, _MS_GS_ERRUSR); die; } $img = new GSImage($img); if ($img->isNew()) { redirect_header(XOOPS_URL . '/modules/galleries/', 1, _MS_GS_ERRIMG); die; } // Recaptcha check if (!RMEvents::get()->run_event('rmcommon.captcha.check', true)) { redirect_header(GSFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'postcard/new/img/' . $img->id() . '/' : '?postcard=new&img=' . $img->id()), 1, __('Please check the security words and write it correctly!', 'contact')); die; } $post = new GSPostcard(); $post->setTitle($title); $post->setMessage($msg); $post->setDate(time()); $post->setToName($tname); $post->setToEmail($tmail); $post->setImage($img->id()); $post->setName($fname); $post->setEmail($fmail); $post->setUid($uid); $post->setIp($_SERVER['REMOTE_ADDR']); $post->setViewed(0); //Generamos el código de la postal $post->setCode(RMUtilities::randomString(10, 1, false, 1, 1)); if (!$post->save()) { redirect_header(base64_decode($return), 2, __('Unable to send e-card. Please try again!', 'galleries')); die; } $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); $ectpl = is_file(XOOPS_ROOT_PATH . '/modules/galleries/lang/' . 'postcard-' . $rmc_config['language'] . '.tpl') ? $rmc_config['language'] . '.tpl' : 'postcard-en_US.tpl'; $xoopsMailer->setTemplate($ectpl); $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); $xoopsMailer->assign('SITEURL', XOOPS_URL . "/"); $xoopsMailer->assign('FNAME', $fname); $xoopsMailer->assign('FMAIL', $fmail); $xoopsMailer->assign('TNAME', $tname); $xoopsMailer->assign('MODULE_LINK', GSfunctions::get_url()); $xoopsMailer->assign('POSTAL_LINK', GSfunctions::get_url() . ($mc['urlmode'] ? 'postcard/view/id/' . $post->code() . '/' : '?postcard=view&id=' . $post->code())); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/galleries/lang/"); $xoopsMailer->setFromEmail($fmail); $xoopsMailer->setFromName($fname); $xoopsMailer->setToEmails($tmail); $xoopsMailer->setSubject(sprintf(_MS_GS_SUBJECT, $tname)); if (!$xoopsMailer->send(true)) { redirect_header(base64_decode($return), 2, $xoopsMailer->getErrors()); } else { redirect_header($user->userURL() . 'img/' . $img->id() . '/', 1, __('E-card sent successfully!', 'galleries')); } }
/** * @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&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; } }
/** * @desc Obtiene la URL al usuario * @return string */ public function userURL() { global $xoopsModule, $xoopsModuleConfig; if ($this->_url != '') { return $this->_url; } if (isset($xoopsModule) && $xoopsModule->dirname() == 'galleries') { $mc =& $xoopsModuleConfig; } else { $mc =& RMUtilities::get()->module_config('galleries'); } $url = GSFunctions::get_url(); $url .= $mc['urlmode'] ? 'usr/' . $this->uname() . "/" : "?usr=" . $this->uname(); $this->_url = $url; return $url; }
/** * @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; } }
$xoopsOption['module_subpage'] = 'index'; include 'header.php'; GSFunctions::makeHeader(); $tpl->assign('lang_lastphotos', __('Recent Photos', 'galleries')); $tpl->assign('last_sets', __('Recent Albums', 'galleries')); $tpl->assign('lang_created', __('Created on:', 'galleries')); $tpl->assign('lang_by', __('Created by:', 'galleries')); $tpl->assign('lang_pics', __('Photos:', 'galleries')); $tpl->assign('lang_other', __('Other Albums', 'galleries')); $tpl->assign('lang_view', __('View Photos', 'galleries')); $tpl->assign('lang_moresets', __('More albums', 'galleries')); $tpl->assign('explore_sets_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/sets/' : '?explore=sets')); $tpl->assign('lang_setbrowse', __('Browse albums', 'galleries')); $tpl->assign('explore_imgs_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/photos/' : '?explore=photos')); $tpl->assign('lang_imgbrowse', __('Browse photos', 'galleries')); $tpl->assign('explore_tags_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/tags/' : '?explore=tags')); $tpl->assign('lang_tagbrowse', __('Browse tags', 'galleries')); // ültimas Fotos $mc['last_num'] = $mc['last_num'] <= 0 ? 10 : $mc['last_num']; $result = $db->query("SELECT * FROM " . $db->prefix("gs_images") . " WHERE public=2 ORDER BY created DESC LIMIT 0,{$mc['last_num']}"); $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); }
$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) { $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url($mc['urlmode'] ? GSFunctions::get_url() . '/search/' . $search . '/pag/{PAGE_NUM}/' : '?search=' . $search . '&pag={PAGE_NUM}'); $tpl->assign('searchNavPage', $nav->render(false)); } $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; $tpl->assign('lang_showing', sprintf(__('Showing pictures %u to %u from %u'), $start + 1, $showmax, $num)); $tpl->assign('limit', $limit); $tpl->assign('pag', $pactual); //Fin de barra de navegación $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 ($words as $k) { if (strlen($k) <= 2) { continue;
/** * @desc Elimina de la base de datos la información del album especificado **/ function deleteSets() { global $util, $xoopsModule, $db, $xoopsModuleConfig, $page; $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; $mc =& $xoopsModuleConfig; $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/' . $pag . '/' : '?cp=sets&pag=' . $pag); //Verificamos si nos proporcionaron al menos un imagen para eliminar if (!is_array($ids)) { redirect_header($link, 2, __('You must selecte one album at least!', 'galleries')); die; } $errors = ''; foreach ($ids as $k) { //Verificamos si el album es válido if ($k <= 0) { $errors .= sprintf(__('Album id %u is not valid!', 'galleries'), $k); continue; } //Verificamos si el album existe $set = new GSSet($k); if ($set->isNew()) { $errors .= sprintf(__('Album with id %u does not exists!', 'galleries'), $k); continue; } if (!$set->delete()) { $errors .= sprintf(__('Album "%s" could not be deleted!', 'galleries'), $set->title()); } } if ($errors != '') { redirect_header($link, 2, __('Errors ocurred while trying to delete albums', 'galleries') . '<br />' . $errors); die; } else { redirect_header($link, 1, __('Abums deleted successfully!', 'galleries')); die; } }
/** * @desc Visualiza todas las imágenes de la etiqueta especificada **/ function imgsTag() { global $tpl, $xoopsOption, $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $db, $page, $tag, $usr, $hits; $xoopsOption['template_main'] = 'gs_imagestag.html'; $xoopsOption['module_subpage'] = 'exploretags'; include 'header.php'; $mc =& $xoopsModuleConfig; GSFunctions::makeHeader(); //Verificamos si la etiqueta existe $tag = new GSTag($tag); if ($tag->isNew()) { redirect_header(GSFunctions::get_url(), 1, __('Specified tag does not exists!', 'galleries')); die; } //Incrementamos el número de hits de la etiqueta if (!isset($_SESSION['vtags'])) { $tag->addHit(); $_SESSION['vtags'] = array($tag->id()); } elseif (!in_array($tag->id(), $_SESSION['vtags'])) { $tag->addHit(); $_SESSION['vtags'][] = $tag->id(); } //Verificamos si el usuario existe if (isset($usr)) { $user = new GSUser($usr); if ($user->isNew()) { redirect_header(GSFunctions::get_url(), 1, __('Specified user does not exists!', 'galleries')); die; } $users[$user->uid()] = $user; } //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_tagsimages') . " a INNER JOIN " . $db->prefix('gs_images'); $sql .= " b ON (a.id_tag=" . $tag->id() . " AND a.id_image=b.id_image AND b.public=2"; $sql .= $usr ? " AND b.owner=" . $user->uid() . ") " : ")"; $limit = $xoopsModuleConfig['num_imgstags']; 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/tags/tag/' . $tag->getVar('nameid') . '/'; $urlnav .= $usr ? 'usr/' . $user->uname() . '/' : ''; } else { $urlnav = '?xplore=tags&tag=' . $tag->getVar('nameid'); $urlnav .= $usr ? '&usr='******''; } $nav = new RMPageNav($num, $limit, $pactual, 5); $nav->target_url(GSFunctions::get_url() . $urlnav . ($mc['urlmode'] ? 'pag/{PAGE_NUM}/' : '&pag={PAGE_NUM}')); $tpl->assign('tagsNavPage', $nav->render(false)); } $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; $tpl->assign('lang_showing', sprintf(__('Showing photos %u to %u from %u.', 'galleries'), $start + 1, $showmax, $num)); $tpl->assign('limit', $limit); $tpl->assign('pag', $pactual); //Fin de barra de navegación //Obtenemos las imágenes pertenecientes a la etiqueta $sql = "SELECT b.* FROM " . $db->prefix('gs_tagsimages') . " a INNER JOIN " . $db->prefix('gs_images'); $sql .= " b ON (a.id_tag=" . $tag->id() . " AND a.id_image=b.id_image AND b.public=2"; $sql .= $usr ? " AND b.owner=" . $user->uid() . ") " : ")"; $sql .= " GROUP BY b.id_image"; $sql .= " ORDER BY `created` DESC LIMIT {$start}, {$limit}"; $result = $db->query($sql); $tpl->assign('images', GSFunctions::process_image_data($result)); $tpl->assign('lang_picstag', $usr ? sprintf(__('%s: tagged as %s', 'galleries'), $user->uname(), $tag->tag()) : sprintf(__('Images tagged as "%s"', 'galleries'), $tag->tag())); $tpl->assign('tagname', $tag->tag()); $tpl->assign('usr', $usr); if ($usr) { $tpl->assign('pics_link', GS_URL . '/' . ($mc['urlmode'] ? "usr/" . $user->uname() : "user.php?id=usr/" . $user->uname() . "/")); $tpl->assign('tags_link', GS_URL . '/' . ($mc['urlmode'] ? "explore/tags/usr/" . $user->uname() . "/" : "explore.php?by=explore/tags/usr/" . $user->uname() . "/")); $tpl->assign('sets_link', GS_URL . '/' . ($mc['urlmode'] ? "explore/sets/usr/" . $user->uname() . "/" : "explore.php?by=explore/sets/usr/" . $user->uname() . "/")); $tpl->assign('bmark_link', GS_URL . '/' . ($mc['urlmode'] ? "cpanel/booksmarks/" : "cpanel.php?s=cpanel/bookmarks")); } include 'footer.php'; }
public function url() { global $mc; $url = GSFunctions::get_url(); $url .= $mc['urlmode'] ? "postcard/" . $this->id() . '/' : 'postcard.php?id=' . $this->id(); return $url; }
public function url() { global $xoopsModule, $xoopsModuleConfig; if (isset($xoopsModule) && $xoopsModule->dirname() == 'galleries') { $mc =& $xoopsModuleConfig; } else { $mc = RMUtilities::module_config('galleries'); } $url = GSFunctions::get_url(); $url .= $mc['urlmode'] ? 'usr/' . $this->uname() . "/set/" . $this->id() . '/' : "?usr="******"&set=" . $this->id(); return $url; }
/** * @desc Elimina de la base de datos los amigos especificados **/ function deleteFriends() { global $xoopsModuleConfig, $db, $xoopsUser, $page, $id; $mc =& $xoopsModuleConfig; $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/friends/pag/' . $page . '/' : 'cp=friends&pag=' . $page); //Verificamos si nos proporcionaron al menos un amigo para eliminar if ($id <= 0) { redirect_header($link, 2, __('Specified id for friend is not valid!', 'galleries')); die; } //Verificamos si el amigo existe $exu = new XoopsUser($id); if ($exu->isNew()) { redirect_header($link, 2, __('Specified user does not exists!', 'galleries')); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); //Verificamos si se trata de un amigo $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='******'"; list($num) = $db->fetchRow($db->query($sql)); if ($num <= 0) { redirect_header($link, 2, __('Specified user is not yoru friend!', 'galleries')); die; } $sql = "DELETE FROM " . $db->prefix('gs_friends') . " WHERE uid='" . $id . "' AND gsuser='******'"; $result = $db->queryF($sql); if (!$result) { redirect_header($link, 2, __('Friend could not be deleted!', 'galleries')); die; } else { redirect_header($link, 1, __('Friend deleted successfully!', 'galleries')); die; } }
/** * @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; } }