/** * This function deletes all image formats, except thumbnails, for specified albums. * This is useful when you need to regenerate images */ function delete_formats() { global $xoopsModuleConfig; $id = rmc_server_var($_GET, 'id', 0); $page = rmc_server_var($_GET, 'page', 1); if ($id <= 0) { redirectMsg("sets.php?page={$page}", __('Sorry, this is not a valid album!', 'galleries'), 1); die; } $set = new GSSet($id); if ($set->isNew()) { redirectMsg("sets.php?page={$page}", __('Specified Album does not exists!', 'galleries'), 1); die; } $db = Database::getInstance(); $t1 = $db->prefix("gs_images"); $t2 = $db->prefix("gs_setsimages"); $sql = "SELECT a.image FROM {$t1} a, {$t2} b WHERE b.id_set={$id} AND a.id_image=b.id_image"; $result = $db->query($sql); $dir = rtrim($xoopsModuleConfig['storedir'], '/'); if ($set->uname() == '') { $user = new XoopsUser($set->owner()); $uname = $user->uname(); } else { $uname = $set->uname(); } if ($uname == '') { redirectMsg('sets.php?page=' . $page, __('Sorry, we were unable to find the album owner!', 'galleries'), 1); break; } $dir .= '/' . $uname . '/formats'; if (!is_dir($dir)) { redirectMsg('sets.php?page=' . $page, __('There are not image formats for this album.', 'galleries'), 0); die; } while (list($image) = $db->fetchRow($result)) { @unlink($dir . '/bigset_' . $image); @unlink($dir . '/set_' . $image); @unlink($dir . '/user_' . $image); @unlink($dir . '/srh_' . $image); } $pics = $set->getPics(); $sql = "UPDATE {$t1} SET user_format=0, set_format=0, bigset_format=0, search_format=0 WHERE id_image IN (" . implode(",", $pics) . ")"; $db->queryF($sql); redirectMsg('sets.php?page=' . $page, __('Image formats deleted!', 'galleries'), 0); }
//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() . '/' : '&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() . '/' : '&set=' . $set->id()); $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($desc, ENT_QUOTES)); $item['pubdate'] = formatTimestamp($set->date(), 'rss'); $item['guid'] = $users[$set->owner()]->userURL() . ($mc['urlmode'] ? 'set/' . $set->id() . '/' : '&set=' . $set->id()); $rss_items[] = $item; } }
/** * @desc Visualiza todos los albumes existentes del usuario **/ function showSets($edit = 0) { global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $page, $xoopsConfig, $id; $xoopsOption['template_main'] = 'gs_panel_sets.html'; include 'header.php'; $mc =& $xoopsModuleConfig; $limit = rmc_server_var($_REQUEST, 'limit', 15); GSFunctions::makeHeader(); $link = GSFunctions::get_url() . ($mc['urlmode'] ? '/cpanel/sets/pag/' . $page : '/cpanel.php?s=cpanel/sets/' . $page); if ($edit) { //Verificamos que el album sea válido if ($id <= 0) { redirect_header($link, 1, __('Album ID is not valid!', 'galleries')); die; } //Verificamos que el album exista $set = new GSSet($id); if ($set->isNew()) { redirect_header($link, 1, __('Specified album does not exists!', 'galleries')); die; } $tpl->assign('title', $set->title()); $tpl->assign('public', $set->isPublic()); $tpl->assign('edit', $edit); $tpl->assign('id', $id); $tpl->assign('action_editset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveeditset/pag/' . $page . '/' : '?cp=saveeditset&pag=' . $page)); } //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; list($num) = $db->fetchRow($db->query($sql)); $page = $page <= 0 ? 1 : $page; list($num) = $db->fetchRow($db->query($sql)); $start = $num <= 0 ? 0 : ($page - 1) * $limit; $tpages = ceil($num / $limit); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url(GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/sets/pag/{PAGE_NUM}/' : '?cp=sets&pag={PAGE_NUM}')); //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; $sql .= " LIMIT {$start},{$limit}"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $set = new GSSet(); $set->assignVars($rows); $tpl->append('sets', array('id' => $set->id(), 'name' => $set->title(), 'owner' => $set->owner(), 'uname' => $set->uname(), 'public' => $set->isPublic(), 'date' => formatTimeStamp($set->date(), 's'), 'pics' => $set->pics(), 'link' => $set->url())); } $tpl->assign('lang_setexists', __('My Albums', 'galleries')); $tpl->assign('lang_id', __('ID', 'galleries')); $tpl->assign('lang_name', __('Name', 'galleries')); $tpl->assign('lang_date', __('Date', 'galleries')); $tpl->assign('lang_public', __('Privacy:', 'galleries')); $tpl->assign('lang_options', _OPTIONS); $tpl->assign('lang_edit', _EDIT); $tpl->assign('lang_del', _DELETE); $tpl->assign('lang_confirm', __('Do you really wish to delete specified album?', 'galleries')); $tpl->assign('lang_confirms', __('Do you really wish to delete selected albums?', 'galleries')); $tpl->assign('lang_newset', __('Add Album', 'galleries')); $tpl->assign('lang_editset', __('Edit Album', 'galleries')); $tpl->assign('lang_yes', __('Yes', 'galleries')); $tpl->assign('lang_no', __('No', 'galleries')); $tpl->assign('lang_pics', __('Pictures', 'galleries')); $tpl->assign('lang_privateme', __('Private', 'galleries')); $tpl->assign('lang_privatef', __('Friends', 'galleries')); $tpl->assign('lang_publicset', __('Public', 'galleries')); RMTemplate::get()->add_style('panel.css', 'galleries'); $tpl->assign('action_addset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveset/pag/' . $page . '/' : '?cp=saveset')); $tpl->assign('pag', $page); $tpl->assign('action_delset', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/deleteset/pag/' . $page . '/' : '?cp=deleteset')); $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/editset/pag/' . $page . '/id/' : '?cp=editset&pag=' . $page . '&id=')); createLinks(); include 'footer.php'; }
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() . '/' : '&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; }
/** * @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) ? '&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('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() . '/' : '&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&usr="******"explore/tags/usr/" . $owner->uname() . '/' : "?explore=tags&usr="******"cp/booksmarks/" : "?cp=bookmarks")); } include 'footer.php'; }