コード例 #1
0
ファイル: users.php プロジェクト: laiello/bitcero-modules
/**
* @desc Visualiza todos los usuarios existentes
**/
function showUsers()
{
    global $xoopsModule, $db, $tpl, $xoopsSecurity;
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $limit = 15;
    $search = rmc_server_var($_REQUEST, 'search', '');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_users');
    $sql1 = '';
    $search = trim($search);
    if ($search && strlen($search) > 2) {
        $sql1 .= $sql1 == '' ? " WHERE (uname LIKE '%{$search}%')" : " OR (uname LIKE '%{$search}%')";
    }
    list($num) = $db->fetchRow($db->query($sql . $sql1));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("users.php?page={PAGE_NUM}&amp;search={$search}");
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_users');
    $sql2 = " LIMIT {$start},{$limit}";
    $result = $db->query($sql . $sql1 . $sql2);
    while ($rows = $db->fetchArray($result)) {
        $uname = eregi_replace("({$search})", "<span class='searchResalte'>\\1</span>", $rows['uname']);
        $user = new GSUser();
        $user->assignVars($rows);
        $users[] = array('id' => $user->id(), 'uid' => $user->uid(), 'uname' => $uname, 'quota' => RMUtilities::formatBytesSize($user->quota()), 'blocked' => $user->blocked(), 'used' => GSFunctions::makeQuota($user), 'pics' => $user->pics(), 'sets' => $user->sets(), 'date' => formatTimeStamp($user->date(), 'custom'), 'url' => $user->userUrl());
    }
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Users management', 'galleries'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Users management', 'galleries'));
    RMTemplate::get()->add_script('../include/js/gsscripts.php?file=sets&form=frm-users');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected users?', 'galleries') . "';\n</script>");
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/gs_users.php", 'module', 'galleries');
    xoops_cp_footer();
}
コード例 #2
0
ファイル: user.php プロジェクト: laiello/bitcero-modules
/**
* @desc Mostramos los detalles de una imágen
*/
function showImageDetails()
{
    global $usr, $set, $img, $db, $xoopsModule, $mc, $xoopsModuleConfig, $xoopsConfig, $xoopsUser, $xoopsOption, $tpl;
    $user = new GSUser($usr);
    if ($user->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified user does not exists!', 'galleries'));
        die;
    }
    $image = new GSImage($img);
    if ($image->isNew()) {
        redirect_header(GSFunctions::get_url(), 0, __('Specified image does not exists!', 'galleries'));
        die;
    }
    $user = new GSUser($image->owner(), 1);
    //Verificamos la privacidad de la imagen
    if (!$image->isPublic()) {
        //Privada, Verificamos si el usuario es el dueño de la imagen
        if (!$xoopsUser || $xoopsUser->uid() != $image->owner()) {
            redirect_header(GSFunctions::get_url(), 1, __('You can not view this image!', 'galleries'));
            die;
        }
    } else {
        if ($image->isPublic() == 1) {
            //Privada y amigos
            if (!$xoopsUser || $xoopsUser->uid() != $image->owner()) {
                //Verificamos si es un amigo
                if (!$xoopsUser || !$user->isFriend($xoopsUser->uid())) {
                    redirect_header(GSFunctions::get_url(), 1, __('You are not authorized to view this image!', 'galleries'));
                    die;
                }
            }
        }
    }
    //Incrementamos las vistas de la imagen
    $image->addViews();
    if (isset($set)) {
        $set = new GSSet($set);
        if ($set->isNew()) {
            redirect_header(GSFunctions::get_url(), 0, __('Specified album does not exists!', 'galleries'));
            die;
        }
    }
    if ($image->desc() != '') {
        global $xoTheme;
        $xoTheme->addMeta('meta', 'description', $image->desc());
    }
    $xoopsOption['template_main'] = 'gs_imgdetails.html';
    $xoopsOption['module_subpage'] = 'picsdetails';
    include 'header.php';
    GSFunctions::makeHeader();
    $tpl->assign('user', array('id' => $user->id(), 'uname' => $user->uname(), 'link' => $user->userURL(), 'avatar' => $user->userVar('user_avatar') != '' ? XOOPS_URL . '/uploads/avatars/' . $user->userVar('user_avatar') : GS_URL . '/images/avatar.png'));
    $tpl->assign('user_link', $user->userURL());
    $tpl->assign('lang_alsobelong', __('Also belongs to:', 'galleries'));
    $tpl->assign('lang_postcards', __('Send postcard', 'galleries'));
    $tpl->assign('lang_bookmark', __('+ Bookmark', 'galleries'));
    $tpl->assign('lang_photos', __('Pictures', 'galleries'));
    $tpl->assign('lang_toset', __('+ to Album', 'galleries'));
    $tpl->assign('lang_lastpic', __('This is the last picture', 'galleries'));
    $tpl->assign('lang_firstpic', __('This is the first picture', 'galleries'));
    $tpl->assign('toset_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/toset/ids/' . $image->id() . '/referer/' . base64_encode(RMFunctions::current_url()) . '/' : '?cp=toset&amp;ids=' . $image->id() . '&amp;referer=' . base64_encode(RMFunctions::current_url())));
    $tpl->assign('edit_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/edit/id/' . $image->id() . '/referer/' . base64_encode(RMFunctions::current_url()) . '/' : '?cp=edit&amp;id=' . $image->id() . '&amp;referer=' . base64_encode(RMFunctions::current_url())));
    $tpl->assign('bookmark_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/bookmarks/add/' . $image->id() . '/referer/' . base64_encode($_SERVER['REQUEST_URI']) : '?cpanel=bookmarks&amp;add=' . $image->id() . '&amp;referer=' . base64_encode($_SERVER['REQUEST_URI'])));
    $tpl->assign('postcard_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'postcard/new/img/' . $image->id() . '/' : '?postcard=new&amp;img=' . $image->id()));
    $tpl->assign('delete_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/delete/referer/' . base64_encode(RMFunctions::current_url()) . '/ids/' : '?cpanel=delete&amp;referer=' . base64_encode(RMFunctions::current_url()) . '&amp;ids='));
    $tpl->assign('lang_confirmdel', sprintf(__('Dow you really want to delete this picture?\\n(%s)', 'galleries'), $image->title()));
    if ($xoopsUser && $xoopsUser->uid() == $image->owner()) {
        $tpl->assign('lang_edit', __('Edit', 'galleries'));
        $tpl->assign('lang_delete', __('Delete', 'galleries'));
        $tpl->assign('isowner', 1);
    }
    $tpl->assign('postcards', $mc['postcards']);
    $data = getimagesize($user->filesURL() . '/' . $image->image());
    $tpl->assign('image', array('title' => $image->title(), 'id' => $image->id(), 'file' => $user->filesURL() . '/' . $image->image(), 'desc' => $image->desc(), 'width' => $data[0] + 2, 'height' => $data[1] + 2));
    unset($data);
    //Verificamos si el usuario es dueño o amigo
    if ($xoopsUser && $xoopsUser->uid() == $user->uid()) {
        $public = '';
    } else {
        if ($xoopsUser && $user->isFriend($xoopsUser->uid())) {
            $public = " AND public<>'0'";
        } else {
            $public = " AND public='2'";
        }
    }
    // Imágenes anterior y siguiente
    if (!isset($set)) {
        // Navigation as images
        if ($xoopsModuleConfig['navimages']) {
            $limit_n = $xoopsModuleConfig['navimages_num'];
            $limit_p = $xoopsModuleConfig['navimages_num'];
            // Count images
            $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image>'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image ASC LIMIT 0," . $xoopsModuleConfig['navimages_num'];
            $resultn = $db->query($sql);
            if ($db->getRowsNum($resultn) < $xoopsModuleConfig['navimages_num']) {
                $limit_p = $limit_p + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultn));
            }
            $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image<'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image DESC, created DESC LIMIT 0," . $limit_p;
            $resultp = $db->query($sql);
            if ($db->getRowsNum($resultp) < $xoopsModuleConfig['navimages_num']) {
                $limit_n = $limit_n + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultp));
            }
            if ($limit_n > $db->getRowsNum($resultn) && $limit_p == $xoopsModuleConfig['navimages_num']) {
                $sql = "SELECT * FROM " . $db->prefix("gs_images") . " WHERE id_image>'" . $image->id() . "' AND owner='" . $user->uid() . "' {$public} ORDER BY id_image ASC LIMIT 0," . $limit_n;
                $resultn = $db->query($sql);
            }
            // Previous Images
            while ($row = $db->fetchArray($resultp)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $previous_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/' : '&amp;img=' . $pn->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
            // Next Images
            while ($row = $db->fetchArray($resultn)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $next_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/' : '&amp;img=' . $pn->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
        }
        $tpl->assign('prevnext_title', sprintf(__('Pictures of %s'), $user->uname()));
        $tpl->assign('xoops_pagetitle', $image->title() . ' &raquo; ' . sprintf(__('Pictures of %s'), $user->uname()) . ' &raquo; ' . $xoopsModuleConfig['section_title']);
        $tpl->assign('title_link', $user->userURL());
        $result = $db->query("SELECT COUNT(*) FROM " . $db->prefix("gs_images") . " WHERE owner='" . $user->uid() . "' {$public}");
        list($num) = $db->fetchRow($result);
        $tpl->assign('pics_count', $num);
        // Tambien pertenece
        $tbl1 = $db->prefix("gs_sets");
        $tbl2 = $db->prefix("gs_setsimages");
        $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_image='" . $image->id() . "' AND a.id_set=b.id_set";
        $result = $db->query($sql);
        while ($row = $db->fetchArray($result)) {
            $oset = new GSSet();
            $oset->assignVars($row);
            //Verificamos la privacidad del album
            if (!$oset->ispublic()) {
                if (!$xoopsUser) {
                    continue;
                }
                if ($xoopsUser->uid() != $oset->owner()) {
                    continue;
                }
            } else {
                if (!$xoopsUser && $oset->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
                    continue;
                }
            }
            $tpl->append('sets', array('id' => $oset->id(), 'title' => $oset->title(), 'link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'set/' . $oset->id() . '/' : '&amp;set=' . $oset->id())));
        }
    } else {
        // Imágen Siguiente
        $tbl1 = $db->prefix("gs_images");
        $tbl2 = $db->prefix("gs_setsimages");
        // Navigation as images
        if ($xoopsModuleConfig['navimages']) {
            $limit_n = $xoopsModuleConfig['navimages_num'];
            $limit_p = $xoopsModuleConfig['navimages_num'];
            // Count images
            $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image>'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image ASC LIMIT 0," . $xoopsModuleConfig['navimages_num'];
            $resultn = $db->query($sql);
            if ($db->getRowsNum($resultn) < $xoopsModuleConfig['navimages_num']) {
                $limit_p = $limit_p + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultn));
            }
            $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image<'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image DESC LIMIT 0,{$limit_p}";
            $resultp = $db->query($sql);
            if ($db->getRowsNum($resultp) < $xoopsModuleConfig['navimages_num']) {
                $limit_n = $limit_n + ($xoopsModuleConfig['navimages_num'] - $db->getRowsNum($resultp));
            }
            if ($limit_n > $db->getRowsNum($resultn) && $limit_p == $xoopsModuleConfig['navimages_num']) {
                $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.id_image>'" . $image->id() . "' AND a.owner='" . $user->uid() . "' {$public} ORDER BY a.id_image ASC LIMIT 0," . $limit_n;
                $resultn = $db->query($sql);
            }
            // Previous Images
            while ($row = $db->fetchArray($resultp)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $previous_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $pn->id() . '&amp;set=' . $set->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
            // Next Images
            while ($row = $db->fetchArray($resultn)) {
                $pn = new GSImage();
                $pn->assignVars($row);
                $next_images[] = array('link' => $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'img/' . $pn->id() . '/set/' . $set->id() . '/' : '&amp;img=' . $pn->id() . '&amp;set=' . $set->id()), 'id' => $pn->id(), 'title' => $pn->title(), 'file' => $user->filesURL() . '/ths/' . $pn->image());
            }
        }
        $tpl->assign('prevnext_title', sprintf(__('Pictures in %s', 'galleries'), $set->title()));
        $tpl->assign('xoops_pagetitle', $image->title() . ' &raquo; ' . sprintf(__('Pictures in %s'), $set->title()) . ' &raquo; ' . $xoopsModuleConfig['section_title']);
        $tpl->assign('title_link', $user->userURL() . ($xoopsModuleConfig['urlmode'] ? 'set/' . $set->id() . '/' : '&amp;set=' . $set->id()));
        $result = $db->query("SELECT COUNT(*) FROM {$tbl1} a, {$tbl2} b WHERE b.id_set='" . $set->id() . "' AND a.id_image=b.id_image AND a.owner='" . $user->uid() . "' {$public}");
        list($num) = $db->fetchRow($result);
        $tpl->assign('pics_count', $num);
        // Tambien pertenece
        $tbl1 = $db->prefix("gs_sets");
        $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_set<>'" . $set->id() . "' AND b.id_image='" . $image->id() . "' AND a.id_set=b.id_set";
        $result = $db->query($sql);
        $tpl->append('sets', array('id' => 0, 'title' => sprintf(__('Galleries of %s', 'galleries'), $user->uname()), 'link' => $user->userURL()));
        while ($row = $db->fetchArray($result)) {
            $oset = new GSSet();
            $oset->assignVars($row);
            //Verificamos la privacidad del album
            if (!$oset->ispublic()) {
                if (!$xoopsUser) {
                    continue;
                }
                if ($xoopsUser->uid() != $oset->owner()) {
                    continue;
                }
            } else {
                if (!$xoopsUser && $oset->isPublic() == 1 && !$user->isFriend($xoopsUser->uid())) {
                    continue;
                }
            }
            $tpl->append('sets', array('id' => $oset->id(), 'title' => $oset->title(), 'link' => $user->userURL() . 'set/' . $oset->id(), '/'));
        }
    }
    if (!empty($previous_images)) {
        $tpl->assign('prev', $previous_images[0]);
        $tpl->assign('previous_images', array_reverse($previous_images));
    } else {
        $tpl->assign('is_first', 1);
    }
    if (!empty($next_images)) {
        $tpl->assign('next', $next_images[0]);
        $tpl->assign('next_images', $next_images);
    } else {
        $tpl->assign('is_last', 1);
    }
    $tpl->assign('current_image', array('title' => $image->title(), 'file' => $user->filesURL() . '/ths/' . $image->image()));
    // Etiquetas
    $tags = $image->tags(true, '*');
    $link = GSFunctions::get_url() . ($mc['urlmode'] ? 'explore/tags/tag/' : "?explore=tags&amp;tag=");
    foreach ($tags as $tag) {
        $tpl->append('tags', array('id' => $tag->id(), 'tag' => $tag->tag(), 'link' => $link . $tag->getVar('nameid')));
    }
    // Comentarios
    $tpl->assign('users_link', GSFunctions::get_url() . ($mc['urlmode'] ? 'usr/' : '?usr='******'galleries', 'image=' . $image->id());
    // Comments form
    RMFunctions::comments_form('galleries', 'image=' . $image->id(), 'module', GS_PATH . '/class/galleriescontroller.php');
    include 'footer.php';
}