Ejemplo n.º 1
0
if (!isset($_GET["popup"])) {
    ?>
	<div class="container2" style="padding: 2px">
	<div class="container">
	<?php 
}
if ($isCollabs) {
    $cond1 = "`watType` = 'use' AND `objCollab` <> '0' AND `watCreator` IN(`objCollab`, `objCreator`)";
} elseif ($isClubs) {
    $cond1 = "`watType` = 'clu' AND `watCreator` = `objForClub` AND `objCreator` <> '{$creator}'";
} else {
    $cond1 = "`watType` = 'use' AND `watCreator` = `objCreator` AND `objCollab` = '0'";
}
$where = "`watUser` = '{$creator}' AND {$cond1} " . "AND `objDeleted` = '0' AND `objPending` = '0'";
applyObjFilters($where);
if ($artistId > 0) {
    if ($isCollabs) {
        $where = "({$where}) AND `objCollab` = '{$artistId}'";
    } elseif ($isClubs) {
        $where = "({$where}) AND `objForClub` = '{$artistId}'";
    } elseif ($isExtras) {
        $where = "({$where}) AND `objCreator` = '{$artistId}'";
    } else {
        $where = "({$where}) AND `objCreator` = '{$artistId}'";
    }
}
if (!$showAll) {
    $where = "({$where}) AND `updObj` IS NOT NULL";
}
$sql = "SELECT DISTINCT {$_objects}.*, `updObj` FROM `watches`, {$_objects} " . "LEFT JOIN `updates` ON( `updType` = '" . ($cleType == "obj" ? updTypeArt : updTypeArtExtra) . "' AND `updObj` = `objid` AND `updCreator` = '{$creator}' ) " . "WHERE {$where} " . "ORDER BY `objLastEdit` DESC LIMIT {$offset}, {$limit}";
Ejemplo n.º 2
0
function getObjectThumb($objid = 0, $size = 30, $isExtras = false)
{
    global $_auth;
    $objid = intval($objid);
    $where = "`objid` = '{$objid}'";
    if (!atLeastHelpdesk()) {
        $where = "({$where}) AND `objDeleted` = '0' AND `objPending` = '0'";
    }
    applyObjFilters($where);
    $result = sql_query("SELECT * FROM `" . ($isExtras ? "extras" : "objects") . "` WHERE {$where} LIMIT 1");
    // check if the object exists - Why did this say club before?
    if (!($objData = mysql_fetch_assoc($result))) {
        // no?
        return getIMG(urlf() . "images/nothumb.gif", 'alt="[' . _BBCODE_THUMB . '=' . $objid . ']" title="' . sprintf(_UNKNOWN_SUBMISSION, $objid) . '" class="microthumb"');
    }
    if (!isLoggedIn()) {
        $sql = "SELECT `useGuestAccess` FROM `useExtData`" . dbWhere(array("useEid" => $objData["objCreator"]));
        $result = sql_query($sql);
        if (!mysql_result($result, 0)) {
            return getIMG(urlf() . "images/nothumb.gif", 'alt="[' . _BBCODE_THUMB . '=' . $objid . ']" title="' . sprintf(_UNKNOWN_SUBMISSION, $objid) . '" class="microthumb"');
        }
    }
    // found the object
    if (!$isExtras && $objData["objThumbDefault"]) {
        $filename = "images/litthumb.png";
    } else {
        $filename = $isExtras ? "" : findNewestFileById("files/thumbs/", $objid, "images/nothumb.gif");
    }
    $width = round($objData["objThumbWidth"] * $size / 100);
    $height = round($objData["objThumbHeight"] * $size / 100);
    $objTitle = htmlspecialchars($objData["objTitle"]) . ' <br /> ';
    if ($objData["objCollab"] > 0) {
        $objTitle .= sprintf(_BY_AND, getUserLink($objData["objCreator"]), getUserLink($objData["objCollab"]));
    } else {
        $objTitle .= sprintf(_BY, getUserLink($objData["objCreator"]));
    }
    $src = $isExtras ? $objData["objThumbURL"] : urlf() . $filename;
    if ($size < 100) {
        makeFloatingThumb(strip_tags($objTitle), $src, $objData["objThumbWidth"], $objData["objThumbHeight"], $objData["objMature"], true, $onmouseover, $onmouseout);
    } else {
        $onmouseover = "";
        $onmouseout = "";
    }
    $str = '<a href="' . url("view/" . ($isExtras ? "e" : "") . $objData["objid"]) . '">' . getIMG($src, 'alt="[' . _BBCODE_THUMB . '=' . $objid . ']" class="microthumb' . ($objData["objMature"] ? " mature" : "") . '" ' . 'style="width: ' . $width . 'px; height: ' . $height . 'px" ' . 'onmouseover="' . $onmouseover . '" onmouseout="' . $onmouseout . '" ' . 'title="' . strip_tags($objTitle) . '"', true) . '</a> ';
    return $str;
}
Ejemplo n.º 3
0
function recountUpdates($type, $user)
{
    global $_auth;
    switch ($type) {
        case updTypeMessageFav:
            $result = sql_query("SELECT COUNT(*) FROM `updates` " . "WHERE `updType` = '" . updTypeMessageFav . "' " . "AND `updCreator` = '" . intval($user) . "'");
            $updField = "useUpdFav";
            break;
        case updTypeMessageWatch:
        case updTypeMessageClub:
        case updTypeMessageAbuse:
        case updTypeMessageDeleted:
        case updTypeMessageRestored:
        case updTypeMessageClubMember:
        case updTypeMessageClubDeclined:
        case updTypeMessageClubRefused:
        case updTypeMessageWatchClub:
        case updTypeMessageHelpUpdate:
        case updTypeMessageHelpResolved:
            $types = array(updTypeMessageWatch, updTypeMessageClub, updTypeMessageAbuse, updTypeMessageDeleted, updTypeMessageRestored, updTypeMessageClubMember, updTypeMessageClubDeclined, updTypeMessageClubRefused, updTypeMessageWatchClub, updTypeMessageHelpUpdate, updTypeMessageHelpResolved);
            $result = sql_query("SELECT COUNT(*) FROM `updates` " . "WHERE `updType` IN('" . implode("','", $types) . "') " . "AND `updCreator` = '" . intval($user) . "'");
            $updField = "useUpdWat";
            break;
        case updTypeArt:
            $where = "`objid` = `updObj` " . "AND `objDeleted` = '0' AND `objPending` = '0' " . "AND `updCreator` = '" . intval($user) . "'";
            applyObjFilters($where, $user);
            $result = sql_query("SELECT COUNT(*) FROM `updatesArt`,`objects` " . "WHERE " . $where);
            $updField = "useUpdObj";
            break;
        case updTypeArtExtra:
            $where = "`updType` = '" . updTypeArtExtra . "' AND `objid` = `updObj` " . "AND `objDeleted` = '0' AND `objPending` = '0' " . "AND `updCreator` = '" . intval($user) . "'";
            applyObjFilters($where, $user);
            $result = sql_query("SELECT COUNT(*) FROM `updates`,`extras` " . "WHERE " . $where);
            $updField = "useUpdExt";
            break;
        case updTypeJournal:
        case updTypeJournalPoll:
        case updTypeAnnouncement:
            $types = array(updTypeJournal, updTypeJournalPoll, updTypeAnnouncement);
            $result = sql_query("SELECT COUNT(*) FROM `updates` " . "WHERE `updType` IN('" . implode("','", $types) . "') " . "AND `updCreator` = '" . intval($user) . "'");
            $updField = "useUpdJou";
            break;
        case updTypeComment:
            $result = sql_query("SELECT COUNT(*) FROM `updates` " . "WHERE `updType` = '" . updTypeComment . "' " . "AND `updCreator` = '" . intval($user) . "'");
            $updField = "useUpdCom";
            break;
        case updTypePM:
            include_once INCLUDES . "comments.php";
            $result = sql_query("SELECT COUNT(*) FROM `updates` " . "WHERE `updType` = '" . updTypePM . "' " . "AND `updCreator` = '" . intval($user) . "'");
            $updField = "useUpdPms";
            break;
        default:
            return;
    }
    $updCount = mysql_result($result, 0);
    sql_query("UPDATE `useExtData` SET `{$updField}` = '{$updCount}' " . "WHERE `useEid` = '" . intval($user) . "' LIMIT 1");
    if ($user == $_auth["useid"]) {
        $_auth[$updField] = $updCount;
        // Immediate effect.
    }
}
Ejemplo n.º 4
0
<?php 
echo iefixStart();
?>
<div class="header f_left"><?php 
echo _PROFILE;
?>
</div>
<div class="header f_right a_right"><?php 
echo isset($_GET["replied"]) ? _COMMENTS : _LEAVE_COMMENT;
?>
</div>
<div class="clear">&nbsp;</div>
<?php 
echo iefixEnd();
$whereMature = "1";
applyObjFilters($whereMature);
$whereMature = "AND " . $whereMature;
?>
<div class="leftside">
	<?php 
$ID = "";
$filename = findNewestFile(applyIdToPath("files/clubids/", $cluData["cluid"]) . "-*", "");
if ($filename != "") {
    if (preg_match('/\\.swf$/', $filename)) {
        list($maxWidth, $maxHeight) = preg_split('/x/', $_config["idResolution"]);
        $ID = '<div class="a_center mar_bottom">' . getSWF($filename, 1.0, $maxWidth, $maxHeight) . '</div>';
    } else {
        $ID = '<div class="a_center mar_bottom"><img src="' . urlf() . $filename . '" /></div>';
    }
}
if ($ID != "" || trim($cluData["cluProfile"]) != "") {
Ejemplo n.º 5
0
function showPrevNext($cl, $cluVar)
{
    global $_objects, $isExtras, $objData, $useData;
    if ($cl == 1 && $objData[$cluVar] == 0) {
        return;
    }
    if ($cl == 1 && $isExtras) {
        return;
    }
    $prevId = 0;
    $nextId = 0;
    if ($cl == 1) {
        // Navigate inside this club/project.
        $select = "SELECT `objid`,`objTitle` FROM {$_objects},`clubObjects`";
        $where = "`cloObject` = `objid` AND `cloClub` = '" . $objData[$cluVar] . "'";
        $browseURL = url("clubgallery/" . $objData[$cluVar]);
    } else {
        // Navigate inside the artist's gallery (this also includes
        // submissions posted to clubs).
        $select = "SELECT `objid`,`objTitle` FROM {$_objects}";
        $where = "`objCreator` = '" . $objData["objCreator"] . "'";
        $browseURL = url(($isExtras ? "extras/" : "gallery/") . strtolower($useData["useUsername"]));
    }
    // Make sure deleted and pending submissions don't display.
    $where = "({$where}) AND `objDeleted` = '0' AND `objPending` = '0'";
    // Make sure mature submissions don't display if the user has chosen
    // not to view them.
    applyObjFilters($where);
    // To find the next submission, sort all submissions that were
    // posted after the current submission by submission dates
    // in the ascending order and then get the very first one.
    $result = sql_query("{$select} WHERE {$where} " . "AND `objSubmitDate` > '" . $objData["objSubmitDate"] . "' " . "ORDER BY `objSubmitDate` LIMIT 1");
    if ($rowData = mysql_fetch_row($result)) {
        $nextId = $rowData[0];
    }
    // To find the previous submission, sort all submissions that were
    // posted before the current submission by submission dates
    // in the descending order and then get the very first one.
    $result = sql_query("{$select} WHERE {$where} " . "AND `objSubmitDate` < '" . $objData["objSubmitDate"] . "' " . "ORDER BY `objSubmitDate` DESC LIMIT 1");
    if ($rowData = mysql_fetch_row($result)) {
        $prevId = $rowData[0];
    }
    // Display navigation buttons (Prev, Browse, Next).
    ?>
			<div class="mar_top mar_bottom smalltext">
				<?php 
    if ($prevId > 0) {
        echo getObjectThumb($prevId, 30, $isExtras) . getIMG(url() . "images/emoticons/nav-prev.png") . " " . _PAGE_PREVIOUS;
    }
    ?>
				&nbsp; &nbsp;
				<a class="disable_wrapping" href="<?php 
    echo $browseURL;
    ?>
">
					<?php 
    echo $cl == 0 ? $isExtras ? _EXTRA_BROWSE : _BROWSE_GALLERY : _BROWSE_CLUB;
    ?>
</a>
				&nbsp; &nbsp;
				<?php 
    if ($nextId > 0) {
        echo _PAGE_NEXT . " " . getIMG(url() . "images/emoticons/nav-next.png") . getObjectThumb($nextId, 30, $isExtras);
    }
    ?>
			</div>
			<?php 
}
Ejemplo n.º 6
0
function putSidebarRandom()
{
    global $_auth, $_config;
    iefixStart();
    $needRefresh = false;
    $objid = 0;
    $rndResult = sql_query("SELECT * FROM `randomObjects`" . dbWhere(array("rndFilterPtn" => $_auth["useObjFilters"])) . "LIMIT 1");
    if ($rndData = mysql_fetch_assoc($rndResult)) {
        if (time() > $rndData["rndTimeout"]) {
            $needRefresh = true;
            // Random object has timed-out
        } else {
            $objid = $rndData["rndObject"];
        }
    } else {
        $needRefresh = true;
    }
    mysql_free_result($rndResult);
    if ($needRefresh) {
        $count = mysql_result(sql_query("SELECT MAX(`objid`) FROM `objects`"), 0);
        $where = "`objPending` = '0' AND `objDeleted` = '0'";
        applyObjFilters($where);
        // We would give it 5 chances to pick a random submission :)
        // Actually there's a 99.999% possibility it would pick the good
        // one at first try.
        $objid = 0;
        for ($i = 1; $i <= 5; $i++) {
            $id = mt_rand(1, $count);
            $_tmpResult = sql_query("SELECT `objid` FROM `objects` " . "WHERE ({$where}) AND `objid` = '{$id}' LIMIT 1");
            if (mysql_num_rows($_tmpResult) > 0) {
                $objid = $id;
                break;
            }
        }
        $timeout = time() + 60;
        // Will expire in 1 minute
        sql_query("LOCK TABLES `randomObjects` WRITE");
        //sql_query( "BEGIN" );
        sql_query("DELETE FROM `randomObjects`" . dbWhere(array("rndFilterPtn" => $_auth["useObjFilters"])));
        sql_query("INSERT INTO `randomObjects`" . dbValues(array("rndFilterPtn" => $_auth["useObjFilters"], "rndObject" => $objid, "rndTimeout" => $timeout)));
        sql_query("UNLOCK TABLES");
        //sql_query( "COMMIT" );
    }
    // Show the thumbnail of that `objid`.
    $select = "SELECT * FROM `objects`";
    $where = "`objid` = '{$objid}'";
    $limit = 1;
    unset($order);
    include INCLUDES . "mod_minigallery.php";
    iefixEnd();
}
Ejemplo n.º 7
0
function showThumbnails($params)
{
    global $_config, $_cmd, $_auth;
    if (!isset($params["quickSearch"])) {
        $params["quickSearch"] = false;
    }
    if (!isset($params["isFavorites"])) {
        $params["isFavorites"] = false;
    }
    if (!isset($params["showDeleted"])) {
        $params["showDeleted"] = false;
    }
    if (!isset($params["countDisabled"])) {
        $params["countDisabled"] = false;
    }
    if (!isset($params["select"])) {
        $params["select"] = "SELECT * FROM `objects`";
    }
    if (!isset($params["where"])) {
        $params["where"] = "1";
    }
    if (!isset($params["having"])) {
        $params["having"] = "";
    }
    if (!isset($params["maxcols"])) {
        $params["maxcols"] = 4;
    }
    if (!isset($params["isExtras"])) {
        $params["isExtras"] = false;
    }
    if (!isset($params["disableFiltering"])) {
        $params["disableFiltering"] = false;
    }
    if (!isset($params["onDisplayFiltering"])) {
        $params["onDisplayFiltering"] = false;
    }
    if (!isset($params["sortById"])) {
        $params["sortById"] = "";
    }
    //if( !isset( $params[ "noMostFaved" ]))
    $params["noMostFaved"] = false;
    if (!isLoggedIn()) {
        if ($params["where"] == "1") {
            $params["where"] = "`objGuestAccess` = '1'";
        } else {
            $params["where"] = "(" . $params["where"] . ") AND `objGuestAccess` = '1'";
        }
    }
    // Define the sorting method. There are 5 sorting methods:
    //
    // 0 - newest first
    // 1 - oldest first
    // 2 - most viewed
    // 3 - most faved
    // 4 - random
    // 5 - relevant
    if (isset($params["order"])) {
        $order = $params["order"];
    } else {
        if ($_cmd[0] == "search") {
            $order = isset($_GET["order"]) ? intval($_GET["order"]) : (isset($_COOKIE["yGalOrder"]) ? intval($_COOKIE["yGalOrder"]) : 0);
        } else {
            $order = isset($_GET["order"]) ? intval($_GET["order"]) : (isset($_COOKIE["yGalOrderSearch"]) ? intval($_COOKIE["yGalOrderSearch"]) : 0);
        }
    }
    if ($params["noMostFaved"] && ($order == 2 || $order == 3)) {
        $order = 0;
    }
    if ($params["isExtras"] && $order == 2) {
        $order = 0;
    }
    // Disable sorting by favs and views for the searching engine because it's too slow :(
    if ($_cmd[0] == "search" && $order != 0 && $order != 1) {
        $order = 0;
    }
    $order1 = $order;
    // Disable sorting by popularity for favourites because it's too slow :(
    if ($_cmd[0] == "favourites" && $order1 != 0 && $order1 != 1) {
        $order1 = 0;
    }
    switch ($order1) {
        case 1:
            if ($params["sortById"]) {
                $orderString = "ORDER BY " . $params["sortById"];
            } else {
                $orderString = $params["isFavorites"] ? "ORDER BY `favSubmitDate`" : "ORDER BY `objSubmitDate`";
            }
            break;
        case 2:
            $orderString = "ORDER BY `objPopularity` DESC";
            /*
            $params[ "select" ] = str_replace(
            	"FROM `objects`",
            	"FROM `objects` USE INDEX(`objPopularity`)",
            	$params[ "select" ]);
            */
            break;
        default:
            if ($params["sortById"]) {
                $orderString = "ORDER BY " . $params["sortById"] . " DESC";
            } else {
                $orderString = $params["isFavorites"] ? "ORDER BY `favSubmitDate` DESC" : "ORDER BY `objSubmitDate` DESC";
            }
    }
    // Define the amount of thumbnails to show. The default value is 12.
    if (isset($params["limit"])) {
        $limit = $params["limit"];
    } else {
        $limit = isset($_GET["limit"]) ? intval($_GET["limit"]) : (isset($_COOKIE["yGalLimit"]) ? intval($_COOKIE["yGalLimit"]) : 12);
        if ($limit != 8 && $limit != 12 && $limit != 24 && $limit != 48) {
            $limit = 12;
        }
    }
    // All pages except the front page "remember" the new
    // sorting/limiting settings.
    if ($_cmd[0] != "") {
        if (!$params["noMostFaved"]) {
            if ($_cmd[0] == "search") {
                setcookie("yGalOrder", $order, strtotime("+9 years"), "/", "." . $_config["galRoot"]);
            } else {
                setcookie("yGalOrderSearch", $order, strtotime("+9 years"), "/", "." . $_config["galRoot"]);
            }
        }
        setcookie("yGalLimit", $limit, strtotime("+1 month"), "/", "." . $_config["galRoot"]);
    }
    // Define the current offset.
    $offset = isset($_GET["offset"]) ? intval($_GET["offset"]) : 0;
    if ($offset < 0) {
        $offset = 0;
    }
    if (!$params["disableFiltering"]) {
        // If the user isn't mature, hide mature submissions.
        applyObjFilters($params["where"]);
        if (isset($params["folderWhere"])) {
            applyObjFilters($params["folderWhere"]);
        }
        if (isset($params["folderCalcWhere"])) {
            applyObjFilters($params["folderCalcWhere"]);
        }
        if (!$params["showDeleted"]) {
            $params["where"] = "(" . $params["where"] . ") " . "AND `objDeleted` = '0' AND `objPending` = '0'";
            if (isset($params["folderWhere"])) {
                $params["folderWhere"] = "(" . $params["folderWhere"] . ") " . "AND `objDeleted` = '0' AND `objPending` = '0'";
            }
            if (isset($params["folderCalcWhere"])) {
                $params["folderCalcWhere"] = "(" . $params["folderCalcWhere"] . ") " . "AND `objDeleted` = '0' AND `objPending` = '0'";
            }
        }
    }
    $totalFolders = 0;
    $gallery = array();
    if (isset($params["folderParent"])) {
        $gallery[-1] = -1;
        $limit--;
    }
    if (isset($params["folderSelect"])) {
        $query = $params["folderSelect"] . " WHERE " . $params["folderWhere"] . " GROUP BY `folid` ORDER BY `folName` LIMIT {$offset}, {$limit}";
        $result = sql_query($query);
        while ($folData = mysql_fetch_assoc($result)) {
            $gallery[-$folData["folid"]] = $folData;
        }
        $query = $params["folderSelect"] . " WHERE " . $params["folderWhere"] . " GROUP BY `folid`";
        $result = sql_query($query);
        $totalFolders = mysql_num_rows($result);
        $offset -= $totalFolders;
    }
    // Query all the currently visible thumbnails and store the data in the
    // $gallery array.
    if ($params["countDisabled"]) {
        $selectCmd = $params["select"];
    } else {
        $selectCmd = preg_replace('/^SELECT/', "SELECT SQL_CALC_FOUND_ROWS", $params["select"]);
    }
    $tmpOffset = $offset < 0 ? 0 : $offset;
    $tmpLimit = $offset < 0 ? $limit + $offset : $limit;
    $limit1 = $limit;
    if ($params["countDisabled"]) {
        $limit1++;
    }
    $query = "{$selectCmd} WHERE " . $params["where"] . " " . $params["having"] . " {$orderString} LIMIT {$tmpOffset}, {$limit1}";
    /*
    if( $_auth[ "useid" ] == 7 )
    {
    	echo $query;
    }
    */
    $result = sql_query($query);
    while ($objData = mysql_fetch_assoc($result)) {
        $gallery[$objData["objid"]] = $objData;
    }
    // Calculate the total amount of submissions that's possible to browse
    // through with the current options.
    if ($params["countDisabled"]) {
        $totalCount = $offset + $limit;
        if (count($gallery) > $limit) {
            $totalCount++;
        }
    } else {
        $result = sql_query("SELECT FOUND_ROWS()");
        $totalCount = $totalFolders + mysql_result($result, 0);
    }
    // Generate the navigation bar.
    if ($_cmd[0] == "") {
        $galleryNavs = "";
    } else {
        iefixStart();
        ob_start();
        $tmpOffset = isset($_GET["offset"]) ? intval($_GET["offset"]) : 0;
        navControls($tmpOffset, $limit, $totalCount);
        ?>
		<div class="a_center">
			<?php 
        if ($params["quickSearch"]) {
            ?>
				<form action="<?php 
            echo url("search");
            ?>
" method="get">
				<?php 
            foreach ($_GET as $key => $value) {
                if ($key != "keywordList" && $key != "offset") {
                    echo '<input name="' . htmlspecialchars($key) . '" type="hidden" value="' . htmlspecialchars($value) . '" />';
                }
            }
            ?>
				<select name="keywordList" onchange="this.form.submit();">
				<option value=""></option>
				<option value=""><?php 
            echo _SEARCH;
            ?>
</option>
				<?php 
            // By default, select the first root keyword group.
            $result = sql_query("SELECT `keyid` FROM `keywords` " . "WHERE `keySubcat` = '0' ORDER BY `keyWord` LIMIT 1");
            if (mysql_num_rows($result)) {
                $mainSubcat = mysql_result($result, 0);
            } else {
                $mainSubcat = 0;
            }
            if (isset($_GET["keywordList"])) {
                // If it's already a search request then see what keyword groups are
                // involved in the search and allow selection of siblings inside
                // those groups.
                $list = preg_split('/\\s/', $_GET["keywordList"], -1, PREG_SPLIT_NO_EMPTY);
            } else {
                $list = array($mainSubcat);
            }
            $first1 = true;
            $where1 = "`keyid` IN(";
            foreach ($list as $keyid) {
                $keyid = intval($keyid);
                if ($keyid == 0) {
                    continue;
                }
                $result = sql_query("SELECT `keySubcat` FROM `keywords` " . "WHERE `keyid` = '{$keyid}' LIMIT 1");
                if (mysql_num_rows($result) > 0) {
                    $keySubcat = mysql_result($result, 0);
                    $where1 .= ($first1 ? "" : ",") . "'{$keySubcat}'";
                    $first1 = false;
                }
            }
            if ($mainSubcat > 0) {
                $where1 .= ($first1 ? "" : ",") . "'{$mainSubcat}'";
            }
            $where1 .= ")";
            $limit1 = 5;
            $result = sql_query("SELECT `keyid`,`keyWord` FROM `keywords` " . "WHERE {$where1} ORDER BY `keyWord` LIMIT {$limit1}");
            while ($keyData = mysql_fetch_assoc($result)) {
                $keyData["keyWord"] = trim(preg_replace('/^.*\\|/', "", $keyData["keyWord"]));
                if (preg_match('/\\@$/', $keyData["keyWord"])) {
                    continue;
                }
                ?>
					<optgroup label="<?php 
                echo $keyData["keyWord"];
                ?>
">
					<?php 
                $result2 = sql_query("SELECT * FROM `keywords` " . "WHERE `keySubcat` = '" . $keyData["keyid"] . "' ORDER BY `keyWord`");
                while ($rowData = mysql_fetch_assoc($result2)) {
                    $rowData["keyWord"] = trim(preg_replace('/^.*\\|/', "", $rowData["keyWord"]));
                    if (preg_match('/\\@$/', $rowData["keyWord"])) {
                        continue;
                    }
                    ?>
						<option <?php 
                    echo isset($_GET["keywordList"]) && $_GET["keywordList"] == $rowData["keyid"] ? 'selected="selected"' : "";
                    ?>
							value="<?php 
                    echo $rowData["keyid"];
                    ?>
"><?php 
                    echo htmlspecialchars($rowData["keyWord"]);
                    ?>
</option>
						<?php 
                }
                ?>
					</optgroup>
					<?php 
            }
            ?>
				</select>
				</form>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
				<?php 
        }
        ?>
			<form action="<?php 
        echo url(".");
        ?>
" method="get">
			<?php 
        foreach ($_GET as $key => $value) {
            if ($key != "order" && $key != "limit" && $key != "offset") {
                echo '<input name="' . htmlspecialchars($key) . '" type="hidden" value="' . htmlspecialchars($value) . '" />';
            }
        }
        ?>
			<select name="order">
				<option <?php 
        echo $order == 0 ? 'selected="selected"' : "";
        ?>
 value="0"><?php 
        echo _NEWEST_FIRST;
        ?>
</option>
				<option <?php 
        echo $order == 1 ? 'selected="selected"' : "";
        ?>
 value="1"><?php 
        echo _OLDEST_FIRST;
        ?>
</option>
				<?php 
        if ($_cmd[0] != "search" && $_cmd[0] != "favourites") {
            if (!$params["noMostFaved"]) {
                if (!$params["isExtras"]) {
                    ?>
							<option <?php 
                    echo $order == 2 ? 'selected="selected"' : "";
                    ?>
 value="2"><?php 
                    echo _CLUB_POPULAR;
                    ?>
</option>
							<?php 
                }
                /*
                ?>
                <option <?= $order == 3 ? 'selected="selected"' : "" ?> value="3"><?=_MOST_VIEWED ?></option>
                <?
                */
            }
            /*
            ?>
            <!--<option <?= $order == 4 ? 'selected="selected"' : "" ?> value="4"><?=_RANDOM ?></option>-->
            <?
            
            if( $_cmd[ 0 ] == "search" )
            {
            	?>
            	<option <?= $order == 5 ? 'selected="selected"' : "" ?> value="5"><?=_SEARCH_RELEVANT ?></option>
            	<?
            }
            */
        }
        ?>
			</select>
			<?php 
        $tmpLimit = $limit;
        if (isset($params["folderParent"])) {
            $tmpLimit++;
        }
        ?>
			<select name="limit">
				<option <?php 
        echo $tmpLimit == 8 ? 'selected="selected"' : "";
        ?>
 value="8"><?php 
        echo fuzzy_number(8);
        ?>
</option>
				<option <?php 
        echo $tmpLimit == 12 ? 'selected="selected"' : "";
        ?>
 value="12"><?php 
        echo fuzzy_number(12);
        ?>
</option>
				<option <?php 
        echo $tmpLimit == 24 ? 'selected="selected"' : "";
        ?>
 value="24"><?php 
        echo fuzzy_number(24);
        ?>
</option>
				<option <?php 
        echo $tmpLimit == 48 ? 'selected="selected"' : "";
        ?>
 value="48"><?php 
        echo fuzzy_number(48);
        ?>
</option>
			</select>

			<input class="submit" type="submit" value="<?php 
        echo _UPDATE;
        ?>
"
				style="vertical-align: middle" />

			</form>
		</div>
		<?php 
        $galleryNavs = ob_get_contents();
        ob_end_flush();
        ?>
		<div class="hline">&nbsp;</div>
		<?php 
        iefixEnd();
    }
    $cols = 0;
    $imagesToGo = $limit;
    if (isset($params["folderParent"])) {
        $imagesToGo++;
    }
    $useids = array();
    foreach ($gallery as $objData) {
        if (isset($objData["objCreator"])) {
            $useids[] = $objData["objCreator"];
        }
    }
    prefetchUserData(array_unique($useids));
    if ($params["onDisplayFiltering"]) {
        // Prepare user filters array (used below).
        $useFilters = preg_split('/[^0-9]/', $_auth["useObjFilters"], 63, PREG_SPLIT_NO_EMPTY);
    }
    foreach ($gallery as $objid => $objData) {
        if ($objid < 0) {
            // Show a folder icon.
            ?>
			<div class="gallery_col">
				<div class="a_center padded mar_bottom<?php 
            echo $cols < 3 ? " mar_right" : "";
            ?>
">
					<?php 
            if (isset($params["folderParent"])) {
                $url = url(($params["isExtras"] ? "extras" : "gallery") . "/" . strtolower($params["folderParent"]["useUsername"]));
                ?>
						<div style="padding-top: 35px;">
							<a href="<?php 
                echo $url;
                ?>
">
								<?php 
                echo getIMG(urlf() . "images/folder_up.png");
                ?>
<br />
								<b><?php 
                echo _SET_FOLDER_BACK;
                ?>
</b>
							</a>
						</div>
						<?php 
            } else {
                $url = url(($params["isExtras"] ? "extras" : "gallery") . "/" . strtolower($params["folderCreator"]["useUsername"]) . "/" . $objData["folIdent"]);
                ?>
						<div style="background: url(<?php 
                echo urlf() . "images/folder.png";
                ?>
) center top no-repeat; height: 140px;">
							<div style="padding-top: 35px">
								<a href="<?php 
                echo $url;
                ?>
"><?php 
                echo getFolderIcon($objData["folid"]);
                ?>
</a>
							</div>
						</div>
						<div>
							<b><a href="<?php 
                echo $url;
                ?>
"><?php 
                echo formatText($objData["folName"], false, true);
                ?>
</a></b>
						</div>
						<?php 
                if (isset($params["folderCalcWhere"])) {
                    $query = $params["folderCalc"] . " WHERE " . $params["folderCalcWhere"] . " AND `objFolder` = '" . $objData["folid"] . "'";
                    $result = sql_query($query);
                    echo "( " . fuzzy_number(mysql_result($result, 0)) . " )";
                }
            }
            ?>
				</div>
			</div>
			<?php 
        } else {
            // Show a thumbnail.
            if ($params["onDisplayFiltering"]) {
                // Check objDeleted, objPending, objMature manually.
                if ($objData["objDeleted"] || $objData["objPending"]) {
                    continue;
                    // Don't show deleted/pending
                }
                if (count($useFilters) > 0) {
                    $objFilters = preg_split('/[^0-9]/', $objData["objMature"], 63, PREG_SPLIT_NO_EMPTY);
                    $isFiltered = false;
                    foreach ($objFilters as $filter) {
                        if (in_array($filter, $useFilters)) {
                            $isFiltered = true;
                            break;
                        }
                    }
                    if ($isFiltered) {
                        continue;
                        // Don't show filtered objects
                    }
                }
            }
            $anchor = url("view/" . ($params["isExtras"] ? "e" : "") . $objData["objid"]);
            if ($params["isExtras"]) {
                $src = $objData["objThumbURL"];
            } elseif ($objData["objThumbDefault"]) {
                $src = urlf() . "images/litthumb.png";
            } else {
                $src = urlf() . applyIdToPath("files/thumbs/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . ".jpg";
            }
            $objTitle = formatText($objData["objTitle"]);
            // Do not display "by <artist_name>" in /gallery and /galleryclubs.
            if ($_cmd[0] != "gallery" && $_cmd[0] != "galleryclubs" && $_cmd[0] != "extras") {
                $objTitle .= "<br /> ";
                if ($objData["objCollab"] > 0) {
                    $objTitle .= sprintf(_BY_AND, getUserLink($objData["objCreator"]), getUserLink($objData["objCollab"]));
                } else {
                    $objTitle .= sprintf(_BY, getUserLink($objData["objCreator"]));
                }
            } else {
                if ($objData["objCollab"] > 0) {
                    $objTitle .= " <br />" . sprintf(_BY_COLLAB_WITH, getUserLink($objData["objCollab"]));
                }
            }
            if ($objData["objForUser"] > 0 && $_cmd[0] != "gifts") {
                $objTitle .= " <br />" . sprintf(_FOR, getUserLink($objData["objForUser"]));
            }
            // Display "in <club_name>" in /gallery and /galleryclubs if the
            // work is submitted to a club.
            if ($_cmd[0] == "galleryclubs" || $_cmd[0] == "gallery" && $objData["objForClub"] > 0) {
                $result = sql_query("SELECT `cluName` FROM `clubs` " . "WHERE `cluid` = '" . $objData["objForClub"] . "'");
                if (mysql_num_rows($result) > 0) {
                    $club = '<a href="' . url("club/" . $objData["objForClub"]) . '">' . mysql_result($result, 0) . '</a>';
                    $objTitle .= '<br /> ' . sprintf(_IN, $club);
                }
            }
            ?>
			<div class="gallery_col">
				<div class="a_center padded mar_bottom<?php 
            echo $cols < 3 ? " mar_right" : "";
            ?>
">
					<a href="<?php 
            echo $anchor;
            ?>
">
						<?php 
            echo getIMG($src, 'alt="' . strip_tags($objTitle) . '" class="thumb' . ($objData["objMature"] && isLoggedIn() ? " mature" : "") . ($objData["objPending"] ? " pending" : "") . ($objData["objDeleted"] ? " deleted" : "") . '" width="' . $objData["objThumbWidth"] . '" height="' . $objData["objThumbHeight"] . '" title="' . strip_tags($objTitle) . '"');
            ?>
</a>
					<div><?php 
            echo $objTitle;
            ?>
</div>
				</div>
			</div>
			<?php 
        }
        $cols++;
        if ($cols >= $params["maxcols"]) {
            $cols = 0;
            ?>
			<div class="clear">&nbsp;</div>
			<?php 
        }
        $imagesToGo--;
        if ($imagesToGo <= 0) {
            break;
        }
    }
    if (count($gallery) == 0) {
        ?>
		<div><?php 
        echo _NO_SUBMISSIONS;
        ?>
</div>
		<?php 
    }
    if ($_cmd[0] != "" || $params["limit"] == 12) {
        ?>
		<div class="hline">&nbsp;</div>
		<?php 
    }
    // On the front page also show the "More >" link which leads to the
    // global gallery browsing.
    if ($_cmd[0] == "" && $params["limit"] == 12) {
        ?>
		<div class="a_right mar_bottom mar_right">
			<a class="disable_wrapping smalltext" href="<?php 
        echo url("browse");
        ?>
">
			<?php 
        echo _MORE;
        ?>
			<?php 
        echo getIMG(url() . "images/emoticons/nav-next.png");
        ?>
			</a>
		</div>
		<?php 
    }
    echo $galleryNavs;
    ?>
	<div class="clear">&nbsp;</div>
	<?php 
}