Ejemplo n.º 1
0
    ?>
					- <?php 
    echo getUserLink($modData["adcCreator"]);
    ?>
:
					<?php 
    echo formatText($modData["adcText"]);
    ?>
				</div>
				<?php 
}
mysql_free_result($modResult);
?>
			<div class="sep a_center">
				<?php 
iefixStart();
$commentName = "modMessage";
$commentNoOptions = true;
$commentRows = 8;
include INCLUDES . "mod_comment.php";
iefixEnd();
?>
			</div>
			<div class="sep a_center">
				<input class="submit" type="submit" name="submitLog" value="Add Message" />
			</div>
		</form>
		<?php 
echo iefixEnd();
?>
	</div>
Ejemplo n.º 2
0
<div class="header">
	<div class="header_title">
		<?php 
echo _DONATIONS;
?>
		<div class="subheader"><?php 
echo sprintf(_DONATION_SUBTITLE, $_config["galName"]);
?>
</div>
	</div>
</div>

<div class="container">

<?php 
echo iefixStart();
?>
<div class="header f_left"><?php 
echo _DONATION_ONETIME;
?>
</div>
<div class="header f_right a_right"><?php 
echo _DONATION_SUBSCRIBE;
?>
</div>
<div class="clear">&nbsp;</div>
<?php 
echo iefixEnd();
?>

<div class="leftside">
Ejemplo n.º 3
0
function showKeywordSubcatEdit($keywords, $listId, $parentId = 0, $parentKeyName = "", $parentLastKeyName = "")
{
    global $requiredTabs, $firstKeywordId;
    $noSubcats = true;
    foreach ($keywords as $keyData) {
        if (isset($keyData["subcats"])) {
            $noSubcats = false;
            break;
        }
    }
    if ($parentId == 0) {
        ?>
		<div class="clear">&nbsp;</div>
		<div class="sep notsowide mar_left mar_bottom">
			Add more keyword groups to the Root separated by&nbsp;;
			<br />
			<input class="notsowide" name="addKeywordsUnder<?php 
        echo $parentId;
        ?>
" type="text" />
		</div>
		<?php 
    }
    foreach ($keywords as $keyData) {
        $tabid = generateId("kwcache_tab");
        $keyName = "&bull; " . $parentKeyName . $keyData["keyWord"];
        $nonSelectable = preg_match('/\\@$/', $keyData["keyWord"]);
        $keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
        ?>
		<div class="f_left">
			<div class="tab normaltext" id="<?php 
        echo $tabid;
        ?>
"
				onclick="open_tab(this,'keywords_<?php 
        echo $parentId;
        ?>
','keywordTab_<?php 
        echo $keyData["keyid"];
        ?>
')">

				<a href="<?php 
        echo url("keywords", array("delete" => $keyData["keyid"]));
        ?>
">
					<?php 
        echo getIMG(url() . "images/emoticons/keydelete.gif", 'alt="del" title="' . _KEYWORDS_DELETE . '" ' . 'onmouseout="this.style.background=\'none\'" ' . 'onmouseover="this.style.background=\'#fff\'"');
        ?>
				</a>
				<a href="<?php 
        echo url("keywords", array("edit" => $keyData["keyid"]));
        ?>
">
					<?php 
        echo getIMG(url() . "images/emoticons/keyedit.gif", 'alt="edit" title="' . _KEYWORDS_EDIT . '" ' . 'onmouseout="this.style.background=\'none\'" ' . 'onmouseover="this.style.background=\'#fff\'"');
        ?>
				</a>
				<?php 
        echo htmlspecialchars($keyData["keyWord"]);
        if ($nonSelectable) {
            echo "@";
        }
        ?>
			</div>
		</div>
		<?php 
    }
    ?>
	<div class="clear">&nbsp;</div>
	<?php 
    foreach ($keywords as $keyData) {
        $keyData["keyWord"] = preg_replace('/\\@$/', "", $keyData["keyWord"]);
        unset($requiredTabs[$keyData["keyid"]]);
        ?>
		<div style="display: none" id="keywordTab_<?php 
        echo $keyData["keyid"];
        ?>
">
			<?php 
        iefixStart();
        ?>
			<div class="hline">&nbsp;</div>
			<div class="hline">&nbsp;</div>
			<div class="sep notsowide_fix mar_left mar_bottom">
				Add more keywords to the group
				<b><?php 
        echo $parentKeyName . htmlspecialchars($keyData["keyWord"]);
        ?>
</b>
				separated by&nbsp;;
				<br />
				<input class="notsowide_fix" name="addKeywordsUnder<?php 
        echo $keyData["keyid"];
        ?>
" type="text" />
			</div>
			<div class="clear">&nbsp;</div>
			<?php 
        iefixEnd();
        ?>
			<?php 
        if (isset($keyData["subcats"])) {
            iefixStart();
            showKeywordSubcatEdit($keyData["subcats"], $listId, $keyData["keyid"], $parentKeyName . htmlspecialchars($keyData["keyWord"]) . " &ndash; ", $parentId != 0 ? htmlspecialchars($keyData["keyWord"]) : "");
            iefixEnd();
        }
        ?>
			<div class="clear">&nbsp;</div>
		</div>
		<?php 
    }
}
Ejemplo n.º 4
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.º 5
0
function showComment($comData, $level, $showParent = false, $markAsReadId = '', $commentCountId = '', $markAsReadId2 = '')
{
    global $_config, $_signatureCache, $_auth, $_cmd, $_currentPageURL;
    // _HACKFIX - facsimilnym 2011-09-05
    // Workaround for the "blank" useDateFormat that ~140,000 users have.
    // Setting it up here, since there's like 5 code paths.
    if (!isset($_auth["useDateFormat"]) || $_auth["useDateFormat"] == "") {
        $_auth["useDateFormat"] = "Y-m-d \\@ g:i A";
    }
    if (isset($comData["pmsid"])) {
        $comData["comid"] = $comData["pmsid"];
        $comData["comCreator"] = $comData["pmsCreator"];
        $comData["comNoEmoticons"] = $comData["pmsNoEmoticons"];
        $comData["comNoSig"] = $comData["pmsNoSig"];
        $comData["comNoBBCode"] = $comData["pmsNoBBCode"];
        $comData["comSubject"] = $comData["pmsTitle"];
        $comData["comSubjectDateHide"] = true;
        $comData["comComment"] = $comData["pmsComment"];
        $comData["comObj"] = $comData["pmsObj"];
        $comData["comObjType"] = "pms";
        $comData["comSubmitDate"] = $comData["pmsSubmitDate"];
        $comData["comSubmitIp"] = $comData["pmsSubmitIp"];
        $comData["comLastEdit"] = $comData["pmsLastEdit"];
        $comData["comEditIp"] = $comData["pmsEditIp"];
        $comData["comTotalEdits"] = $comData["pmsTotalEdits"];
        $comData["comPmUser"] = $comData["pmsPmUser"];
    }
    if (isTwit($comData["comCreator"])) {
        return;
    }
    if (!isLoggedIn()) {
        $result = sql_query("SELECT `useGuestAccess` FROM `useExtData`" . dbWhere(array("useEid" => $comData["comCreator"])));
        if (!mysql_result($result, 0)) {
            return;
        }
    }
    $commentID = "yg-cmt" . $comData["comid"];
    $instantReplyOuterId = $commentID . "InstantReplyOuter";
    $instantReplyId = $commentID . "InstantReplyId";
    if (!isset($comData["comNoEmoticons"])) {
        $comData["comNoEmoticons"] = false;
    }
    if (!isset($comData["comNoSig"])) {
        $comData["comNoSig"] = false;
    }
    if (!isset($comData["comNoBBCode"])) {
        $comData["comNoBBCode"] = false;
    }
    if (isset($comData["pmsid"])) {
        if ($comData["comCreator"] != $_auth["useid"] && $comData["comPmUser"] != $_auth["useid"]) {
            echo '<div class="container2">' . _PM_NO_ACCESS . '</div>';
            return;
        }
    }
    $levellim = $level < 8 ? $level : 8;
    for ($i = 0; $i <= $levellim; $i++) {
        ?>
		<div class="<?php 
        echo $i == $levellim ? "pad_top" : "";
        echo $level > 0 && $i < $levellim ? "cmt_border_left" : "";
        ?>
">
		<?php 
    }
    //	if($_cmd[0] != "comment")
    echo '<a name="comment' . $comData["comid"] . '"></a>';
    //	echo '<div'.($markAsReadId != "" ? ' id="'.$markAsReadId.'"' : "" ).'>'; // Comment outer
    //	echo '<div'.($markAsReadId != "" ? ' id="'.$markAsReadId.'_"' : "" ).' class="container2">'; // Comment body
    echo '<div class="container2">';
    // Comment body
    iefixStart();
    // display parent comment
    if ($showParent && isset($comData["comObjType"]) && $comData["comObjType"] == "com") {
        $result = sql_query("SELECT * FROM `comments` WHERE `comid` = '" . $comData["comObj"] . "' LIMIT 1");
        if ($parData = mysql_fetch_assoc($result)) {
            ?>
			<div class="caption reminder_cap">
				<?php 
            echo sprintf(_WROTE, getUserLink($parData["comCreator"]));
            ?>
:
			</div>
			<div class="reminder">
				<?php 
            echo formatText($parData["comComment"], $parData["comNoEmoticons"], $parData["comNoBBCode"]);
            ?>
			</div>
			<?php 
        }
    } elseif ($showParent && isset($comData["pmsid"])) {
        $result = sql_query("SELECT * FROM `pms` WHERE `pmsid` = '" . $comData["comObj"] . "' LIMIT 1");
        if ($parData = mysql_fetch_assoc($result)) {
            if ($parData["pmsCreator"] == $_auth["useid"] || $parData["pmsPmUser"] == $_auth["useid"]) {
                ?>
				<div class="caption reminder_cap">
					<?php 
                echo sprintf(_WROTE, getUserLink($parData["pmsCreator"]));
                ?>
:
				</div>
				<div class="reminder">
					<?php 
                echo formatText($parData["pmsComment"], $parData["pmsNoEmoticons"], $parData["pmsNoBBCode"]);
                ?>
				</div>
				<?php 
            }
        }
    }
    if ($comData["comCreator"] != 0) {
        ?>
		<div class="f_right mar_left a_center" style="position: relative; top: -3px; left: 3px">
			<?php 
        echo getUserAvatar("", $comData["comCreator"], true);
        ?>
		</div>
		<?php 
    }
    if (isset($comData["comSubject"])) {
        if (!isset($comData["comSubjectDateHide"])) {
            ?>
<div class="smalltext mar_bottom"><?php 
            // Show IPs to moderators+ (as an acronym).
            if (atLeastModerator() && isset($comData["comSubmitIp"]) && isset($comData["comEditIp"])) {
                ?>
				<acronym style="cursor: help" title="Submitted from <?php 
                echo getDotDecIp($comData["comSubmitIp"]);
                ?>
, last edited from <?php 
                echo getDotDecIp($comData["comEditIp"]);
                ?>
">
				<?php 
            }
            printf(_COMMENT_POSTED_ON, gmdate($_auth["useDateFormat"], applyTimezone(strtotime($comData["comSubmitDate"]))));
            // Close the acronym opened above.
            if (atLeastModerator() && isset($comData["comSubmitIp"]) && isset($comData["comEditIp"])) {
                ?>
				</acronym>
				<?php 
            }
            ?>
</div><?php 
        }
        ?>
		<div class="largetext mar_bottom"><b><?php 
        echo formatText($comData["comSubject"], false, true);
        ?>
</b></div>
		<?php 
    }
    ?>
	<div class="commentData">
		<?php 
    $allowImages = isset($comData["comAllowImages"]) && $comData["comAllowImages"];
    echo formatText($comData["comComment"], $comData["comNoEmoticons"], $comData["comNoBBCode"], $allowImages);
    ?>
	</div>
	<?php 
    if (!$comData["comNoSig"] && $_cmd[0] != "updates") {
        if (!isset($_signatureCache[$comData["comCreator"]])) {
            $result = sql_query("SELECT `useSignature` FROM `useExtData` WHERE `useEid` = '" . $comData["comCreator"] . "' LIMIT 1");
            if (mysql_num_rows($result)) {
                $_signatureCache[$comData["comCreator"]] = mysql_result($result, 0);
            } else {
                $_signatureCache[$comData["comCreator"]] = "";
            }
        }
        if ($_signatureCache[$comData["comCreator"]] != "") {
            ?>
			<div class="hline" style="margin-right: 60px;">&nbsp;</div>
			<div class="smalltext">
			<?php 
            echo formatText($_signatureCache[$comData["comCreator"]]);
            ?>
			</div>
			<?php 
        }
    }
    ?>
	<div class="clear">&nbsp;</div>
	<?php 
    if (isset($comData["newid"])) {
        // News page.
        $result = sql_query("SELECT COUNT(*) FROM `comments` " . "WHERE `comObjType` = 'new' AND `comObj` = '" . $comData["newid"] . "'");
        $newsCount = mysql_result($result, 0);
        $newsURL = url("news/" . $comData["newid"]);
        ?>
		<div class="sep">
			<a href="<?php 
        echo $newsURL;
        ?>
">
			<span class="button smalltext" style="float: right"
				onclick="document.location='<?php 
        echo $newsURL;
        ?>
';"><?php 
        echo _COMMENTS;
        ?>
				<?php 
        if (!$_auth["useStatsHide"]) {
            echo "(" . fuzzy_number($newsCount) . ")";
        }
        ?>
			</span></a>
		</div>
		<?php 
    }
    if ($comData["comid"]) {
        ?>
		<div class="sep commentActions">
			<?php 
        getCommentParent($comData, $parentURL, $parentType, $parentTitle, false);
        getCommentParent($comData, $rootURL, $rootType, $rootTitle, true);
        $replyURL = url("comment/" . $comData["comid"] . ($_config["checkSubmitDate"] ? "/" . preg_replace('/[^0-9]/', "", $comData["comSubmitDate"]) : ''));
        $replyCommentId = $commentID . "ReplyCommentId";
        $replyButtonId = $commentID . "ReplyButtonId";
        $replyScript = "var elin = get_by_id( '" . $instantReplyId . "' );" . "var elb = get_by_id( '" . $replyButtonId . "' );" . "if( !elb ) return false;" . "if( elb.innerHTML == '" . _CANCEL . "' ) {" . "  reset_focus(); " . "  collapseAnim( '{$instantReplyOuterId}', -30, 0, '' ); " . "  elb.innerHTML = '" . _REPLY . "';" . "  return false;" . "}" . "_IR = { " . "commentId: '" . $replyCommentId . "'," . "commentName: 'comment'," . "commentDefault: ''," . "commentWide: true," . "commentRows: 7," . "commentNoBBCode: " . (isLoggedIn() && $_auth["useNoBBCode"] ? "true" : "false") . "," . "commentNoEmoticons: " . (isLoggedIn() && $_auth["useNoEmoticons"] ? "true" : "false") . "," . "commentNoOptions: false," . "commentNoSig: " . (isLoggedIn() && $_auth["useNoSig"] ? "true" : "false") . "," . "emoticonPopupURL: '" . url("emoticons", array("popup" => "yes", "comment" => $replyCommentId)) . "'," . "previewURL: '" . url("preview", array("popup" => "yes")) . "'" . "};" . "var ht = showReplyForm( '" . $replyURL . "', '" . $_currentPageURL . "' );" . "elin.innerHTML = ht;" . "collapseAnim( '{$instantReplyOuterId}', 30, 0, 'set_focus( \\'' + _IR.commentId + '\\' );' ); " . "elb.innerHTML = '" . _CANCEL . "';" . "return false;";
        if (!isset($comData["pmsid"]) && $replyURL != url(".") && $_cmd[0] != "editcomment") {
            ?>
				<span class="button smalltext" style="float: right"
					id="<?php 
            echo $replyButtonId;
            ?>
" onclick="<?php 
            echo $replyScript;
            ?>
">
					<?php 
            echo _REPLY;
            ?>
				</span>
				<?php 
        }
        if ($_cmd[0] == "comment" && $rootURL != url(".") && $level == 0) {
            ?>
				<a href="<?php 
            echo $rootURL;
            ?>
" title="<?php 
            echo htmlspecialchars($rootTitle);
            ?>
">
				<span class="button smalltext" style="float: right"
					onclick="document.location='<?php 
            echo $rootURL;
            ?>
';">
					<?php 
            echo _ROOT;
            ?>
 (<?php 
            echo $rootType;
            ?>
)
				</span></a>
				<?php 
        }
        if ($_cmd[0] == "comment" && $parentURL != url(".") && $level == 0 && $parentURL != $rootURL) {
            ?>
				<a href="<?php 
            echo $parentURL;
            ?>
" title="<?php 
            echo htmlspecialchars($parentTitle);
            ?>
">
				<span class="button smalltext" style="float: right"
					onclick="document.location='<?php 
            echo $parentURL;
            ?>
';">
					<?php 
            echo _PARENT;
            ?>
 (<?php 
            echo $parentType;
            ?>
)
				</span></a>
				<?php 
        }
        if ($_cmd[0] == "updates") {
            $comid = $comData["comid"];
            $script = "add_operation( 'm{$comid}' );\n" . "\$('{$markAsReadId}').hide(); " . ($markAsReadId2 != "" ? "if() \$('{$markAsReadId2}').hide(); " : "") . "var elb = \$( '{$replyButtonId}' );" . "if( !elb ) return false;" . "if( elb.innerHTML == '" . _CANCEL . "' ) {" . "  reset_focus(); " . "  collapseAnim( '{$instantReplyOuterId}', -30, 0, '' ); " . "  elb.innerHTML = '" . _REPLY . "';" . "  return false;" . "}" . "comment_count--; " . "\$('_updCmtCnt').innerHTML = fuzzy_number( comment_count ); " . "\$('_globCmtCnt').innerHTML = fuzzy_number( comment_count );";
            ?>
				<div id="<?php 
            echo $id1 = $commentID . "Updates1";
            ?>
" class="button smalltext" style="display: none; float: right"
					onclick="<?php 
            echo $script;
            ?>
"><?php 
            echo _MARK_AS_READ;
            ?>
: <span class="error"><?php 
            echo _CLICK_TO_CONFIRM;
            ?>
</span></div>
				<div id="<?php 
            echo $id2 = $commentID . "Updates2";
            ?>
" class="button smalltext" style="float: right"
					onclick="$('<?php 
            echo $id1;
            ?>
').show(); $('<?php 
            echo $id2;
            ?>
').hide();"><?php 
            echo _MARK_AS_READ;
            ?>
</div>
				<?php 
        }
        if ((atLeastSModerator() || $comData["comCreator"] == $_auth["useid"]) && $_cmd[0] != "editcomment" && $_cmd[0] != "updates") {
            $editURL = isset($comData["pmsid"]) ? url("editpm/" . $comData["pmsid"]) : url("editcomment/" . $comData["comid"]);
            ?>
				<a href="<?php 
            echo $editURL;
            ?>
">
				<span class="button smalltext" style="float: right"
					onclick="document.location='<?php 
            echo $editURL;
            ?>
';">
					<?php 
            echo _EDIT;
            ?>
				</span></a>
				<?php 
        }
        ?>
			<div class="f_left mar_top smalltext">
				<?php 
        // Show IPs to moderators+ (as an acronym).
        if (atLeastModerator()) {
            ?>
					<acronym style="cursor: help" title="Submitted from <?php 
            echo getDotDecIp($comData["comSubmitIp"]);
            ?>
, last edited from <?php 
            echo getDotDecIp($comData["comEditIp"]);
            ?>
">
					<?php 
        }
        if (!isset($comData["pmsid"])) {
            ?>
					<a class="originalUrl" href="<?php 
            echo $replyURL;
            ?>
">#</a>
					<?php 
        }
        printf(_COMMENT_POSTED_ON, gmdate($_auth["useDateFormat"], applyTimezone(strtotime($comData["comSubmitDate"]))));
        if (isset($comData["comTotalEdits"]) && $comData["comTotalEdits"] > 0) {
            echo "<br />" . sprintf(_COMMENT_EDITED, $comData["comTotalEdits"], gmdate($_auth["useDateFormat"], applyTimezone(strtotime($comData["comLastEdit"]))));
        }
        // Close the acronym opened above.
        if (atLeastModerator()) {
            ?>
					</acronym>
					<?php 
        }
        ?>
			</div>
		</div>
		<?php 
    }
    ?>
	<div class="clear">&nbsp;</div>
	<?php 
    iefixEnd();
    echo '</div>';
    // Comment body
    //echo '</div>'; // Comment outer
    ?>
	<table cellspacing="0" cellpadding="0" width="100%"><tr><td>
	<div id="<?php 
    echo $instantReplyOuterId;
    ?>
" style="display: none">
		<div class="cmt_border_left" style="padding: 4px; padding-right: 0;" id="<?php 
    echo $instantReplyOuterId;
    ?>
_">
			<div class="caption smalltext"><?php 
    echo _REPLY;
    ?>
:</div>
			<div style="padding: 1px; padding-bottom: 5px" id="<?php 
    echo $instantReplyId;
    ?>
"><br /></div>
		</div>
	</div>
	</td></tr></table>
	<?php 
    for ($i = 0; $i <= $levellim; $i++) {
        echo "</div>";
    }
}
Ejemplo n.º 6
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 
}