function findNewestFileById($path, $id, $notfound = "") { return findNewestFile(applyIdToPath($path, $id) . "-*", $notfound); }
$changesExt["useSignature"] = $_POST["useSignature"]; addModeratorLog($useData["useid"], "[b]Changed user signature[/b]"); } if (isset($_POST["deleteAvatar"])) { $filename = applyIdToPath("files/avatars/", $useData["useid"]) . "-" . $useData["useAvatarDate"] . "." . $useData["useAvatarExt"]; if (file_exists($filename)) { unlink($filename); } $changes["useAvatarWidth"] = 0; $changes["useAvatarHeight"] = 0; $changes["useAvatarExt"] = "---"; $changes["useAvatarDate"] = 0; addModeratorLog($useData["useid"], "[b]Deleted user avatar[/b]"); } if (isset($_POST["deleteID"])) { $filename = findNewestFile(applyIdToPath("files/ids/", $useData["useid"]) . "-*", ""); if ($filename != "") { unlink($filename); } addModeratorLog($useData["useid"], "[b]Deleted user ID[/b]"); } if (isset($_POST["deleteTheme"])) { include_once INCLUDES . "customthemes.php"; removeCustomTheme($useData["useid"], false); addModeratorLog($useData["useid"], "[b]Removed custom theme[/b]"); } //Only admin can change user class if (isAdmin()) { $changesExt["useIsRetired"] = isset($_POST["useIsRetired"]) ? 1 : 0; $changesExt["useIsHelpdesk"] = isset($_POST["useIsHelpdesk"]) ? 1 : 0; $changesExt["useIsModerator"] = isset($_POST["useIsModerator"]) ? 1 : 0;
if ($rowData = mysql_fetch_assoc($_tmpResult)) { $_tmpfn = findNewestFile(applyIdToPath("files/themes/", $rowData["objCreator"]) . "/style-*.css"); if ($_tmpfn != "") { $_customTheme = $_tmpfn; } if ($rowData["objForClub"] > 0) { $_tmpfn = findNewestFile(applyIdToPath("files/clubthemes/", $rowData["objForClub"]) . "/style-*.css"); if ($_tmpfn != "") { $_customTheme = $_tmpfn; } } } } if (in_array($_cmd[0], $_clubPages)) { // We're viewing a page that belongs to a certain club. $_tmpfn = findNewestFile(applyIdToPath("files/clubthemes/", intval($_cmd[1])) . "/style-*.css"); if ($_tmpfn != "") { $_customTheme = $_tmpfn; } } } if ($_customTheme != "") { echo "\t"; ?> <link href="<?php echo urlf() . $_customTheme; ?> " rel="alternate stylesheet" title="(custom)" type="text/css" media="screen, projection" /><?php echo "\n"; } }
$featImageName2 = ""; $featChanged = true; $_auth["useFeaturedObj"] = 0; } mysql_free_result($objResult); // Make thumbnails for ID & Featured work. foreach (array(array("name" => "", "path" => "files/ids/", "res" => $_config["idResolution"], "allowSWF" => true, "imgname" => $idImageName, "imgname2" => ""), array("name" => "useFeaturedObj", "path" => "files/features/", "res" => $_config["featureResolution"], "allowSWF" => false, "imgname" => $featImageName, "imgname2" => $featImageName2)) as $item) { if ($item["name"] == "useFeaturedObj" && !$featChanged) { continue; // Item did not change. } if ($item["name"] == "" && $idError == _UPL_NO_FILE && !isset($_POST["removeId"])) { continue; // Item did not change. } $fileName = applyIdToPath($item["path"], $_auth["useid"]); $oldFiles = glob($fileName . "-*", GLOB_NOESCAPE); if (is_array($oldFiles) && count($oldFiles) > 0) { foreach ($oldFiles as $oldFile) { unlink($oldFile); // Delete old files } } if ($item["imgname"] == "" || !file_exists($item["imgname"])) { continue; } if ($item["name"] == "" && isset($_POST["removeId"])) { // Just remove - do not upload a new image continue; } $imageInfo = getimagesize($item["imgname"]);
function eraseSubmission($objid, $isExtras = false, $checkSMod = true) { if ($checkSMod && !atLeastSModerator()) { return; } $_objects = $isExtras ? "`extras`" : "`objects`"; $_objExtData = $isExtras ? "`extExtData`" : "`objExtData`"; // Delete comments eraseComments($isExtras ? "ext" : "obj", $objid); // Erase object-related files if (!$isExtras) { $oldFiles = glob(applyIdToPath("files/data/", $objid) . "-*", GLOB_NOESCAPE); if (is_array($oldFiles) && count($oldFiles) > 0) { foreach ($oldFiles as $oldFile) { unlink($oldFile); // Delete old files } } $oldFiles = glob(applyIdToPath("files/thumbs/", $objid) . "-*", GLOB_NOESCAPE); if (is_array($oldFiles) && count($oldFiles) > 0) { foreach ($oldFiles as $oldFile) { unlink($oldFile); // Delete old files } } } // Delete object sql_query("DELETE FROM {$_objects} WHERE `objid` = '{$objid}'"); sql_query("DELETE FROM {$_objExtData} WHERE `objEid` = '{$objid}'"); if (!$isExtras) { sql_query("DELETE FROM `favourites` WHERE `favObj` = '{$objid}'"); sql_query("DELETE FROM `objKeywords` WHERE `objKobject` = '{$objid}'"); sql_query("DELETE FROM `searchcache` WHERE `seaObject` = '{$objid}'"); } }
} mysql_free_result($objResult); // Make thumbnails for ID & Featured work. foreach (array(array("name" => "", "path" => "files/clubids/", "res" => $_config["idResolution"], "allowSWF" => true, "imgname" => $idImageName, "imgname2" => ""), array("name" => "cluFeaturedObj", "path" => "files/clubfeatures/", "res" => $_config["featureResolution"], "allowSWF" => false, "imgname" => $featImageName, "imgname2" => $featImageName2)) as $item) { if ($item["name"] == "cluFeaturedObj" && !$featChanged && !isset($_POST["removeFeature"])) { continue; // Item did not change. } if ($item["name"] == "" && $idError == _UPL_NO_FILE && !isset($_POST["removeId"])) { continue; // Item did not change. } if ($item["name"] == "cluFeaturedObj") { $fileName = applyIdToPath($item["path"], $cluData["cluFeaturedObj"]); } else { $fileName = applyIdToPath($item["path"], $cluData["cluid"]); } if ($item["imgname"] == "" || !file_exists($item["imgname"])) { continue; } $imageInfo = getimagesize($item["imgname"]); if ($item["allowSWF"] && ($imageInfo[2] == 4 || $imageInfo[2] == 13)) { $useSWF = true; $newName = $fileName . "-" . time() . ".swf"; } else { $useSWF = false; $newName = $fileName . "-" . time() . ".jpg"; } $oldFiles = glob($fileName . "-*", GLOB_NOESCAPE); if (is_array($oldFiles) && count($oldFiles) > 0) { foreach ($oldFiles as $oldFile) {
?> </div> </div> <?php } } $result = sql_query("SELECT * FROM `objects` WHERE `objid` = '" . $cluData["cluFeaturedObj"] . "' AND `objDeleted` = '0' AND `objPending` = '0' {$whereMature} LIMIT 1"); if ($objData = mysql_fetch_assoc($result)) { ?> <div class="sep caption"><?php echo _FEATURE; ?> :</div> <div class="container2 a_center"> <?php if ($filename = findNewestFile(applyIdToPath("files/clubfeatures/", $cluData["cluFeaturedObj"]) . "-*", "")) { $objTitle = formatText($objData["objTitle"]) . ' <br />' . sprintf(_BY, getUserLink($objData["objCreator"])); echo '<div><a href="' . url("view/" . $objData["objid"]) . '">' . '<img alt="' . _ALT_IMAGE . '" class="thumb' . ($objData["objMature"] ? " mature" : "") . '" title="' . strip_tags(formatText($objData["objTitle"])) . '" src="' . urlf() . $filename . '" /></a></div>' . '<div class="sep">' . $objTitle . '</div>' . '<div class="hline"> </div>' . '<div class="sep a_left">' . formatText($cluData["cluFeaturedDesc"]) . '</div>'; } ?> </div> <?php } ?> <?php ob_start(); ?> <div class="sep container2 a_center"> <div> <form action="<?php
?> <?php } else { $galleryNavs = ""; } $cols = 0; if (!isset($maxcols)) { $maxcols = 4; } $imagesToGo = $limit; foreach ($gallery as $objData) { $anchor = url("view/" . $objData["objid"]); if ($objData["objThumbDefault"]) { $src = url() . "images/litthumb.png"; } else { $src = url() . applyIdToPath("files/thumbs/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objRevisionDate"]) . ".jpg"; } $useResult = mysql_query("SELECT `useUsername` FROM `users` WHERE `useid` = '" . $objData["objCreator"] . "' LIMIT 1") or trigger_error(_ERR_MYSQL); $useData = mysql_fetch_assoc($useResult); $objTitle = htmlspecialchars($objData["objTitle"]); if ($_cmd[0] != "gallery" && $_cmd[0] != "galleryclubs") { $objTitle .= '<br /> ' . sprintf(_BY, getUserLink($objData["objCreator"])); } if ($_cmd[0] == "galleryclubs" || $_cmd[0] == "gallery" && $objData["objForClub"] > 0) { $result = mysql_query("SELECT `cluName` FROM `clubs` WHERE `cluid` = '" . $objData["objForClub"] . "'"); if (mysql_num_rows($result)) { $club = '<a href="' . url("club/" . $objData["objForClub"]) . '">' . mysql_result($result, 0) . '</a>'; $objTitle .= '<br /> in ' . $club; // TODO: i18n "in %s" } }
function getCustomThemePath($useid, $isClub) { return applyIdToPath("files/" . ($isClub ? "club" : "") . "themes/", $useid) . "/"; }
} // Upload icon. include_once INCLUDES . "files.php"; $iconError = checkUploadedFile("folIcon"); if (!$iconError) { if (filesize($_FILES["folIcon"]["tmp_name"]) > $_config["maxIconSize"]) { $iconError = sprintf(_SET_ICON_SIZE_EXCEEDED, $_config["maxIconSize"]); } else { // Check avatar image size/type. $iconInfo = getimagesize($_FILES["folIcon"]["tmp_name"]); list($iconWidth, $iconHeight) = preg_split('/x/', $_config["iconResolution"]); if ($iconInfo[0] != $iconWidth || $iconInfo[1] != $iconHeight || $iconInfo[2] != 1 && $iconInfo[2] != 2 && $iconInfo[2] != 3) { $iconError = sprintf(_SET_ICON_TOO_LARGE, $_config["iconResolution"]); } else { // Upload folder icon to /files/foldericons/#/#####/ $iconFilename = applyIdToPath("files/foldericons/", $folid); $oldFiles = glob($iconFilename . "-*", GLOB_NOESCAPE); if (is_array($oldFiles) && count($oldFiles) > 0) { foreach ($oldFiles as $oldFile) { unlink($oldFile); // Delete old files } } uploadFile("folIcon", $iconFilename . '-' . time(), $extension); } } } if ($iconError != "" && $iconError != _UPL_NO_FILE) { if ($_cmd[1] == "new") { sql_query("DELETE FROM `folders`" . dbWhere(array("folid" => $folid))); }
</div> </div> <?php } $result = sql_query("SELECT * FROM `objects` " . "WHERE `objid` = '" . $useData["useFeaturedObj"] . "' " . "AND `objDeleted` = '0' AND `objPending` = '0' {$whereMature} LIMIT 1"); if ($objData = mysql_fetch_assoc($result)) { ?> <div class="caption"> <?php echo _FEATURE; ?> : </div> <div class="container2 a_center mar_bottom"> <?php if ($filename = findNewestFile(applyIdToPath("files/features/", $useData["useid"]) . "-*", "")) { echo '<div><a href="' . url("view/" . $objData["objid"]) . '">' . '<img alt="' . strip_tags(formatText($objData["objTitle"])) . '" class="thumb' . ($objData["objMature"] ? " mature" : "") . '" title="' . strip_tags(formatText($objData["objTitle"])) . '" src="' . urlf() . $filename . '" /></a></div>' . '<div class="sep">' . formatText($objData["objTitle"]) . '</div>'; } ?> </div> <?php } ob_start(); $select = "SELECT `objects`.* FROM `objects` LEFT JOIN `clubs` ON(`objForClub` = `cluid`) "; $where = "(`objForClub` = '0' OR `cluIsProject` = '0') " . "AND `objPending` = '0' AND `objDeleted` = '0' " . "AND `objCreator` = '" . $useData["useid"] . "' {$whereMature}"; $limit = 8; unset($order); $more = url("gallery/" . strtolower($useData["useUsername"])); include INCLUDES . "mod_minigallery.php"; $objContents = ob_get_contents(); ob_end_clean();
function addRequestDetail($helpdeskItem, $detailPostVar, $detailFileVar, $detailPrivacy) { global $_auth; $detailText = isset($_POST[$detailPostVar]) ? trim($_POST[$detailPostVar]) : ""; $fileName = ""; $fileNameOrig = ""; include_once INCLUDES . "files.php"; $uploadError = checkUploadedFile($detailFileVar); if ($uploadError != _UPL_NO_FILE && $uploadError != "") { return $uploadError; } if ($uploadError == "") { $fileNameOrig = $_FILES[$detailFileVar]["name"]; $fileName = applyIdToPath("files/helpdesk/", $helpdeskItem); $fileName .= "-" . substr(sha1(mt_rand() * (microtime() * 0.001)), 1, 16); uploadFile($detailFileVar, $fileName, $extension); $fileName .= "." . $extension; if ($detailText == "") { $detailText = "There is no text message in this detail."; } } if ($detailText != "") { sql_values(array("hddItem" => $helpdeskItem, "hddSubmitDate!" => "NOW()", "hddPrivacy" => $detailPrivacy, "hddCreator" => $_auth["useid"], "hddMessage" => $detailText, "hddAttachment" => $fileName, "hddAttachOrigName" => $fileNameOrig)); sql_insert("helpdeskDetails"); } return ""; }
if ($togo < 0) { break; } $microId = generateId(); $thumbId = generateId(); $u = getUserData($objData["objCreator"]); $objTitle = formatText($objData["objTitle"]) . ' <br />'; if ($objData["objCollab"] > 0) { $objTitle .= sprintf(_BY_AND, getUserLink($u["useid"]), getUserLink($objData["objCollab"])); } else { $objTitle .= sprintf(_BY, getUserLink($u["useid"])); } if ($objData["objThumbDefault"]) { $src = urlf() . "images/litthumb.png"; } else { $src = urlf() . applyIdToPath("files/thumbs/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . ".jpg"; } $url = url("view/" . $objData["objid"]); if ($limit > 1) { echo '<span id="' . $microId . '" ' . "onmouseover=\"open_tab(this,'{$tabsId}','{$thumbId}')\">" . '<a href="' . $url . '">' . '<img alt="' . _ALT_THUMB . '" class="microthumb' . ($objData["objMature"] ? " mature" : "") . ($objData["objPending"] ? " pending" : "") . ($objData["objDeleted"] ? " deleted" : "") . '" src="' . $src . '" title="' . strip_tags($objTitle) . '" />' . '</a></span>' . "\n"; } $bigList .= '<div ' . ($first ? "" : 'style="display: none" ') . 'id="' . $thumbId . '">' . '<table align="center" border="0" cellpadding="0" cellspacing="0"><tr><td class="a_center v_middle pad_top" style="height: ' . $tableHeight . 'px">' . '<div style="width: ' . $tableWidth . 'px">' . '<a href="' . $url . '">' . '<img alt="' . strip_tags($objTitle) . '" class="thumb' . ($objData["objMature"] ? " mature" : "") . ($objData["objPending"] ? " pending" : "") . ($objData["objDeleted"] ? " deleted" : "") . '" src="' . $src . '" title="' . strip_tags($objTitle) . '" />' . '</a></div></td></tr></table>' . "\n" . '<table border="0" cellpadding="0" cellspacing="0" class="wide" style="height: 40px"><tr><td class="a_center v_middle">' . '<div>' . $objTitle . '</div>' . "\n" . '</td></tr></table></div>' . "\n"; if ($first) { $first = false; $firstMicroId = $microId; $firstThumbId = $thumbId; } $objectCount++; } if (isset($more) && count($objList) > $limit) { ?>
function oekakiViewAnimation($object) { $appletWidth = 740; $appletHeight = 550; $imageURL = ""; $query = "SELECT `objid`,`objSubmitDate`,`objLastEdit`,`objExtension`,`objImageWidth`,`objImageHeight`,`objFilename` FROM `objects`,`objExtData` WHERE `objEid` = `objid` AND `objid` = '" . intval($object) . "' AND `objAniType` <> 'no'" . (atLeastModerator() ? "" : " AND `objPending` = '0' AND `objDeleted` = '0'") . " LIMIT 1"; $result = sql_query($query); if (!($objData = mysql_fetch_assoc($result))) { redirect(url("notfound")); return; // cannot edit this submission } $imageURL = applyIdToPath("files/data/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . "." . $objData["objExtension"]; $editor = 0; switch ($objData["objFilename"]) { case "/oekaki/" . OEK_SHI: $editor = OEK_SHI; break; case "/oekaki/" . OEK_SHIPRO: $editor = OEK_SHIPRO; break; case "/oekaki/" . OEK_PAINTBBS: $editor = OEK_PAINTBBS; break; case "/oekaki/" . OEK_OEKAKIBBS: $editor = OEK_OEKAKIBBS; break; } switch ($editor) { case OEK_SHI: case OEK_SHIPRO: $appletArchive = url() . "scripts/oekaki/shipainter/PCHViewer.jar"; $appletCode = "pch2.PCHViewer"; $appletParams = array("speed" => 2, "image_width" => $objData["objImageWidth"], "image_height" => $objData["objImageHeight"], "pch_file" => preg_replace('/png$/', 'pch', urlf() . $imageURL), "res.zip" => "../scripts/oekaki/shipainter/res.zip", "tt.zip" => "../scripts/oekaki/shipainter/tt.zip", "run" => "true", "buffer_progress" => "true", "buffer_canvas" => "true", "color_icon" => "#eeeeee", "color_bar" => "#dddddd", "color_bar_select" => "#ffffff", "color_back" => "#eeeeee", "layer_count" => 5, "layer_max" => 8, "layer_last" => 2, "quality" => 1); break; case OEK_PAINTBBS: $appletArchive = url() . "scripts/oekaki/shipainter/PCHViewer.jar"; $appletCode = "pch.PCHViewer"; $appletParams = array("speed" => 2, "image_width" => $objData["objImageWidth"], "image_height" => $objData["objImageHeight"], "pch_file" => preg_replace('/png$/', 'pch', urlf() . $imageURL), "run" => "true", "buffer_progress" => "true", "buffer_canvas" => "true", "color_icon" => "#eeeeee", "color_bar" => "#dddddd", "color_bar_select" => "#ffffff", "color_back" => "#eeeeee"); break; case OEK_OEKAKIBBS: $appletArchive = url() . "scripts/oekaki/shipainter/oekakibbs.jar"; $appletCode = "a.p"; $appletParams = array("popup" => 0, "anime" => 2, "readanm" => preg_replace('/png$/', 'oeb', basename($imageURL)), "readanmpath" => urlf() . dirname($imageURL) . "/", "picw" => $objData["objImageWidth"], "pich" => $objData["objImageHeight"], "baseC" => "888888", "brightC" => "aaaaaa", "darkC" => "666666", "backC" => "000000", "buffer_canvas" => "true"); break; default: notice(_OEKAKI_UNKNOWN_EDITOR); return; } $params = ""; foreach ($appletParams as $name => $value) { $params .= '<param name="' . $name . '" value="' . htmlspecialchars(strval($value)) . '" />' . "\n\t\t"; } // Changed from embedded objects (which caused a "you need this plugin" message) // to browser detection ?> <div align="center"> <?php if (ereg("MSIE", $_SERVER["HTTP_USER_AGENT"]) && !ereg("Opera", $_SERVER["HTTP_USER_AGENT"])) { ?> <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=1,5,0,4" width="<?php echo $appletWidth; ?> " height="<?php echo $appletHeight; ?> " > <param name="code" value="<?php echo $appletCode; ?> " /> <param name="archive" value="<?php echo $appletArchive; ?> " /> <?php echo $params; ?> </object> <?php } else { ?> <object type="application/x-java-applet" classid="java:<?php echo $appletCode; ?> .class" archive="<?php echo $appletArchive; ?> " width="<?php echo $appletWidth; ?> " height="<?php echo $appletHeight; ?> "> <?php echo $params; ?> <?php echo sprintf(_OEKAKI_NO_JAVA, 'http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=jre-1.5.0_04-oth-JPR&SiteId=JSC&TransactionId=noreg'); ?> </object> <?php } ?> <form action="<?php echo url("view/" . $object); ?> " method="get"> <div class="sep"> <button type="submit" class="submit"> <?php echo getIMG(url() . "images/emoticons/nav-prev.png"); ?> <?php echo _RETURN; ?> </button> </div> </form> </div> <?php }
if (!file_exists($imageFilename)) { continue; } $imageFileSize = filesize($imageFilename); $size = getimagesize($imageFilename); $imageWidth = $size[0]; $imageHeight = $size[1]; $imageNonResizeable = true; if ($size[2] == 2 || $size[2] == 3) { $imageNonResizeable = false; } $previewWidth = 0; $previewHeight = 0; if ($imageWidth > 0 && $imageHeight > 0 && !$imageNonResizeable) { $newRevisionDate = preg_replace('/[^0-9]/', "", $objData["objLastEdit"]); $previewFilename = applyIdToPath("files/preview/", $objid) . "-" . $newRevisionDate . ".jpg"; $coeff = sqrt($_config["previewMaxArea"] / ($imageWidth * $imageHeight)); // Require significant size reduction, so that images wouldn't become // very blurry with just an unnoticeable size change. if ($coeff > 0.9) { $coeff = 1.0; } $previewMaxWidth = round($imageWidth * $coeff); $previewMaxHeight = round($imageHeight * $coeff); thumbifyImage($imageFilename, $previewFilename, $previewMaxWidth, $previewMaxHeight, 86); if (file_exists($previewFilename)) { $size = getimagesize($previewFilename); $previewWidth = $size[0]; $previewHeight = $size[1]; // In case we've accidentally generated a larger file of the same // resolution, throw it away (why would we need a preview file that
} $fn2main .= " - " . trim(substr($objData["objTitle"], 0, 40)); $filename2 = $isExtras ? "" : ($_mod_rewrite ? htmlspecialchars("/" . preg_replace('/[^\\w\\s\'\\-\\!\\(\\)\\[\\]\\&]/', "", $fn2main) . "." . $objData["objExtension"]) : ""); // Gather submission's parameters. $src = $isExtras ? $objData["objImageURL"] : urlf() . $filename . $filename2; $src_orig = $src; // will be used when the user clicks on the image $title = formatText($objData["objTitle"]); $width = $objData["objImageWidth"]; $height = $objData["objImageHeight"]; $containsAnimation = $isExtras ? false : $objData["objAniType"] != "no"; if ($isPreview) { if ($isExtras) { $src = $objData["objPreviewURL"]; } else { $filename = applyIdToPath("files/preview/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . ".jpg"; $src = urlf() . $filename . $filename2; } $width = $objData["objPreviewWidth"]; $height = $objData["objPreviewHeight"]; $objData["objExtension"] = "jpg"; } if ($isExtras) { $objData["objExtension"] = substr($src, strlen($src) - 3); } if ($isPreview && isLoggedIn()) { // Supermoderator or admin can Reset edits. $urlHighQuality = url("view/" . ($isExtras ? "e" : "") . $objid, array("quality" => "high")); $script = "var el = get_by_id( 'idPreviewImage' ); " . "if( !el ) return false; " . "el.style.width = '" . $objData["objImageWidth"] . "px'; " . "el.style.height = '" . $objData["objImageHeight"] . "px'; " . "el.src = '" . str_replace("'", "\\'", $src_orig) . "'; " . "make_invisible( 'idViewInHQButton' ); " . "return false;"; ?> <div class="mar_right mar_bottom button smalltext" id="idViewInHQButton"
</div> </div> </td></tr></table> <?php if ($objData["objExtension"] == "txt") { ?> <div class="caption"><?php echo _TEXT; ?> :</div> <?php iefixStart(); if (isset($_POST["textfile"])) { $commentDefault = $_POST["textfile"]; } else { $filename = applyIdToPath("files/data/", $objData["objid"]) . "-" . preg_replace('/[^0-9]/', "", $objData["objLastEdit"]) . "." . $objData["objExtension"]; if (file_exists($filename)) { $commentDefault = trim(implode("", file($filename))); } else { $commentDefault = ""; } } $commentName = "textfile"; $commentRows = 16; $commentNoOptions = true; include INCLUDES . "mod_comment.php"; ?> <div class="clear"> </div> <?php iefixEnd(); } else {
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> <?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"> </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"> </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"> </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"> </div> <?php }