Z powodu braku funduszy na serwer CT, strona została czasowo zamknieta.
Jeżel do 29.06.2009 nie uzbieramy brakujacej kwoty strona zostanie zamknięta do odwołania.
ZAPRASZAMY DO DOTACJI
"); parked(); $action = htmlspecialchars(trim($_GET["action"])); $forums = mysql_query("select id from forums"); while ($forum = mysql_fetch_assoc($forums)) { $postcount = 0; $topiccount = 0; $topics = mysql_query("select id from topics where forumid=$forum[id]"); while ($topic = mysql_fetch_assoc($topics)) { $res = mysql_query("select count(*) from posts where topicid=$topic[id]"); $arr = mysql_fetch_row($res); $postcount += $arr[0]; ++$topiccount; } mysql_query("update forums set postcount=$postcount, topiccount=$topiccount where id=$forum[id]"); } function catch_up() { global $CURUSER; $userid = $CURUSER["id"]; $res = mysql_query("SELECT id, lastpost FROM topics") or sqlerr(__FILE__, __LINE__); while ($arr = mysql_fetch_assoc($res)) { $topicid = $arr["id"]; $postid = $arr["lastpost"]; $r = mysql_query("SELECT id,lastpostread FROM readposts WHERE userid=$userid and topicid=$topicid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($r) == 0) mysql_query("INSERT INTO readposts (userid, topicid, lastpostread) VALUES($userid, $topicid, $postid)") or sqlerr(__FILE__, __LINE__); else { $a = mysql_fetch_assoc($r); if ($a["lastpostread"] < $postid) mysql_query("UPDATE readposts SET lastpostread=$postid WHERE id=" . $a["id"]) or sqlerr(__FILE__, __LINE__); } } } //-------- Returns the minimum read/write class levels of a forum function get_forum_access_levels($forumid) { $res = mysql_query("SELECT minclassread, minclasswrite, minclasscreate FROM forums WHERE id=".mysql_real_escape_string($forumid)) or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) return false; $arr = mysql_fetch_assoc($res); return array("read" => $arr["minclassread"], "write" => $arr["minclasswrite"], "create" => $arr["minclasscreate"]); } //-------- Returns the forum ID of a topic, or false on error function get_topic_forum($topicid) { $res = mysql_query("SELECT forumid FROM topics WHERE id=".mysql_real_escape_string($topicid)) or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) return false; $arr = mysql_fetch_row($res); return $arr[0]; } //-------- Returns the ID of the last post of a forum function update_topic_last_post($topicid) { $res = mysql_query("SELECT id FROM posts WHERE topicid=".mysql_real_escape_string($topicid)." ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res) or die("No post found"); $postid = $arr[0]; mysql_query("UPDATE topics SET lastpost=$postid WHERE id=".mysql_real_escape_string($topicid)) or sqlerr(__FILE__, __LINE__); } function get_forum_last_post($forumid) { $res = mysql_query("SELECT lastpost FROM topics WHERE forumid=".mysql_real_escape_string($forumid)." ORDER BY lastpost DESC LIMIT 1") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); $postid = $arr[0]; if ($postid) return $postid; else return 0; } //-------- Inserts a quick jump menu function insert_quick_jump_menu($currentforum = 0) { print("

\n"); print("\n"); print("IdĽ do: "); print("\n"); print("\n"); print("
\n

"); } //-------- Inserts a compose frame function insert_compose_frame($id, $newtopic = true, $quote = false) { global $maxsubjectlength, $CURUSER; $forumclassres = mysql_query("SELECT f.minclassread FROM forums f LEFT JOIN topics t ON f.id = t.forumid WHERE t.id=".sqlesc($id)) or sqlerr(__FILE__, __LINE__); $forumclassarr = mysql_fetch_assoc($forumclassres); if (get_user_class() < $forumclassarr[minclassread]) { stdmsg("Błąd","Nie masz uprawnień by to oglądać"); die; } if ($newtopic) { $res = mysql_query("SELECT name FROM forums WHERE id=".mysql_real_escape_string($id)) or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or die("Bad forum id"); $forumname = $arr["name"]; print("

Nowy temat w $forumname forum

\n"); } else { $res = mysql_query("SELECT * FROM topics WHERE id=$id") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or stderr("Błąd forum", "Nic tutaj nie ma."); $subject = $arr["subject"]; print("

OdpowiedĽ do tematu: $subject

"); } begin_frame("", true); print("
\n"); if ($newtopic) print("\n"); else print("\n"); begin_table(); if ($newtopic) print("Temat" . "\n"); if ($quote) { $postid = $_GET["postid"]; if (!is_valid_id($postid)) die; $res = mysql_query("SELECT posts.*, users.username FROM posts LEFT JOIN users ON posts.userid = users.id WHERE posts.id=$postid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) stderr("Error", "No post with ID $postid."); $arr = mysql_fetch_assoc($res); } print("Tresć"); textbbcode("compose","body",($quote?(("[quote=".htmlspecialchars($arr["username"])."]".htmlspecialchars(unesc($arr["body"]))."[/quote]")):"")); print("\n"); print(" \n"); end_table(); print("
\n"); print("

Tagi | Emotikony

\n"); end_frame(); //------ Get 10 last posts if this is a reply if (!$newtopic) { $postres = mysql_query("SELECT * FROM posts WHERE topicid=".mysql_real_escape_string($id)." ORDER BY id DESC LIMIT 10") or sqlerr(__FILE__, __LINE__); begin_frame("10 ostatnich postów, w odwrotnej kolejności"); while ($post = mysql_fetch_assoc($postres)) { //-- Get poster details $userres = mysql_query("SELECT * FROM users WHERE id=" . $post["userid"] . " LIMIT 1") or sqlerr(__FILE__, __LINE__); $user = mysql_fetch_assoc($userres); $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($user["avatar"]) : ""); // $avatar = $user["avatar"]; if (!$avatar) $avatar = "/pic/default_avatar.gif"; print("

#" . $post["id"] . " napisał(a) " . $user["username"] . " dnia " . $post["added"] . " GMT

"); begin_table(true); print("" . ($avatar ? "" : ""). "" . format_comment($post["body"]) . "\n"); end_table(); } end_frame(); } insert_quick_jump_menu(); } //-------- Global variables $maxsubjectlength = 40; $postsperpage = $CURUSER["postsperpage"]; if (!$postsperpage) $postsperpage = 25; //-------- Action: New Forum if ($action == "newforum") { if (get_user_class() < UC_MODERATOR) { die("wypierdalaj np ;p"); } stdhead("Nowe forum"); begin_main_frame(); begin_frame("Nowe forum", "center"); /* Default user class allowed to view/post in forums. Can be an integer, but using the form UC_CLASS is recommended, where CLASS can be anything defined in /include/globals.php */ $defaultminclassread=0; $defaultminclasswrite=UC_USER; $defaultminclasscreate=UC_USER; print("
\n"); begin_table(); print("Nazwa Forum" . "\n". "Opis Forum" . "\n". " Minimum Wymagana ranga do podglądu
\n Minimum Wymagana ranga do pisania
\n Minimum Wymagana ranga do założenia tematu \n". "\n"); end_table(); print("
\n"); end_frame(); end_main_frame(); stdfoot(); die; } //-------- Action: Edit Forum if ($action == "editforumct1911") { if (get_user_class() < UC_MODERATOR) { die("wypierdalaj np ;p"); } //stderr("Forum Error", "Not yet implemented."); stdhead("Edytuj forum"); begin_main_frame(); begin_frame("Edytuj Forum", "center"); $forumid = 0 + $_GET["forumid"]; $res = mysql_query("SELECT * FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); $forum = mysql_fetch_assoc($res); print("
\n"); begin_table(); print("Nazwa forum" . "\n". "Description" . "\n". " Minimum Wymagana ranga do oglądania
\n Minimum Wymagana ranga do odpisania
\n Minimum Wymagana ranga do założenia nowego tematu \n". "\n"); end_table(); print("
\n"); end_frame(); end_main_frame(); stdfoot(); die; } //-------- Action: Create Forum if ($action == "createforum") { $name = $_POST["name"]; $description = $_POST["description"]; $minclassread = 0 + $_POST["readclass"]; $minclasswrite = 0 + $_POST["writeclass"]; $minclasscreate = 0 + $_POST["createclass"]; if(!$name) stderr("Error", "You must specify a name for the forum."); if(!$description) stderr("Error", "You must provide a description for the forum."); $name = sqlesc($name); $description = sqlesc($description); mysql_query("INSERT INTO forums (name, description, minclassread, minclasswrite, minclasscreate) ". "VALUES($name, $description, $minclassread, $minclasswrite, $minclasscreate)") or sqlerr(__FILE__, __LINE__); $forumid = mysql_insert_id() or stderr("Error", "No forum ID returned"); header("Location: $BASEURL/forums.php"); } //-------- Action: Update Forum if ($action == "updateforum") { $forumid = $_GET["forumid"]; $name = $_POST["name"]; $description = $_POST["description"]; $minclassread = 0 + $_POST["readclass"]; $minclasswrite = 0 + $_POST["writeclass"]; $minclasscreate = 0 + $_POST["createclass"]; if(!$forumid) stderr("Error", "Forum ID not found."); if(!$name) stderr("Error", "You must specify a name for the forum."); if(!$description) stderr("Error", "You must provide a description for the forum."); $name = sqlesc($name); $description = sqlesc($description); mysql_query("UPDATE forums SET ". "name=$name, ". "description=$description, ". "minclassread=$minclassread, ". "minclasswrite=$minclasswrite, ". "minclasscreate=$minclasscreate ". "WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); header("Location: $BASEURL/forums.php"); } //-------- Action: Delete Forum if ($action == "deleteforum") { if (get_user_class() < UC_MODERATOR) { die("wypierdalaj np ;p"); } $forumid = $_GET["forumid"]; $confirmed = 0 + $_GET["confirmed"]; if(!$forumid) stderr("Error", "Forum ID not found."); if(!$confirmed) { $rf = mysql_query("SELECT name FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); $forum = mysql_fetch_assoc($rf); $rt = mysql_query("SELECT id FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__); $topics = mysql_num_rows($rt); $posts = 0; while($topic = mysql_fetch_assoc($rt)) { $rp = mysql_query("SELECT * FROM posts WHERE topicid=$topic[id]") or sqlerr(__FILE__, __LINE__); $posts += mysql_num_rows($rp); } stdhead("Delete forum"); begin_main_frame(); begin_frame("** WARNING! **"); print("Skasuj forum ID $forumid ($forum[name]) usuniesz $posts postów in $topics tematów. ". "[Akceptuj] ". "[Anuluj]"); end_frame(); end_main_frame(); stdfoot(); die; } if ($CURUSER['class']>=UC_ADMINISTRATOR) { $rt = mysql_query("SELECT id FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__); while($topic = mysql_fetch_assoc($rt)) mysql_query("DELETE FROM posts WHERE topicid=$topic[id]") or sqlerr(__FILE__, __LINE__); mysql_query("DELETE FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__); mysql_query("DELETE FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); header("Location: $BASEURL/forums.php"); } else stderr("Error", "You are not authorised to perform this action!"); die; } //-------- Action: New topic if ($action == "newtopic") { $forumid = $_GET["forumid"]; if (!is_valid_id($forumid)) die; stdhead("New topic"); begin_main_frame(); insert_compose_frame($forumid); end_main_frame(); stdfoot(); die; } //-------- Action: Post if ($action == "post") { $forumid = 0 + $_POST["forumid"]; $topicid = 0 + $_POST["topicid"]; if (!is_valid_id($forumid) && !is_valid_id($topicid)) stderr("Error", "Bad forum or topic ID."); $newtopic = $forumid > 0; $subject = $_POST["subject"]; if ($newtopic) { $subject = trim($subject); if (!$subject) stderr("Błąd", "Najpiew musisz wpisać Temat"); if (strlen($subject) > $maxsubjectlength) stderr("Error", "Subject is limited to $maxsubjectlength characters."); } else $forumid = get_topic_forum($topicid) or die("Bad topic ID"); //------ Make sure sure user has write access in forum $arr = get_forum_access_levels($forumid) or die("Bad forum ID"); if (get_user_class() < $arr["write"] || ($newtopic && get_user_class() < $arr["create"])) stderr("Error", "Permission denied."); $body = trim($_POST["body"]); if ($body == "") stderr("Błąd", "Muisz najpierw wpisać tekst."); $userid = $CURUSER["id"]; if ($newtopic) { //---- Create topic $subject = sqlesc($subject); mysql_query("INSERT INTO topics (userid, forumid, subject) VALUES($userid, $forumid, $subject)") or sqlerr(__FILE__, __LINE__); $topicid = mysql_insert_id() or stderr("Error", "No topic ID returned"); } else { //---- Make sure topic exists and is unlocked $res = mysql_query("SELECT * FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or die("Topic id n/a"); if ($arr["locked"] == 'yes' && get_user_class() < UC_MODERATOR) stderr("Error", "This topic is locked."); //---- Get forum ID $forumid = $arr["forumid"]; } //------ Insert post $added = "'" . get_date_time() . "'"; $body = sqlesc($body); mysql_query("INSERT INTO posts (topicid, userid, added, body) " . "VALUES($topicid, $userid, $added, $body)") or sqlerr(__FILE__, __LINE__); $postid = mysql_insert_id() or die("Post id n/a"); //------ Update topic last post update_topic_last_post($topicid); //------ All done, redirect user to the post $headerstr = "Location: $BASEURL/forums.php?action=viewtopic&topicid=$topicid&page=last"; if ($newtopic) header($headerstr); else header("$headerstr#$postid"); die; } //-------- Action: View topic if ($action == "viewtopic") { $topicid = $_GET["topicid"]; $page = $_GET["page"]; if (!is_valid_id($topicid)) die; $userid = $CURUSER["id"]; //------ Get topic info $res = mysql_query("SELECT * FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or stderr("Forum error", "Topic not found"); $locked = ($arr["locked"] == 'yes'); $subject = $arr["subject"]; $sticky = $arr["sticky"] == "yes"; $forumid = $arr["forumid"]; //------ Update hits column mysql_query("UPDATE topics SET views = views + 1 WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); //------ Get forum $res = mysql_query("SELECT * FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or die("Forum = NULL"); $forum = $arr["name"]; if ($CURUSER["class"] < $arr["minclassread"]) stderr("Error", "You are not permitted to view this topic."); //------ Get post count $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); $postcount = $arr[0]; //------ Make page menu $pagemenu = "

\n"; $perpage = $postsperpage; $pages = ceil($postcount / $perpage); if ($page[0] == "p") { $findpost = substr($page, 1); $res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid ORDER BY added") or sqlerr(__FILE__, __LINE__); $i = 1; while ($arr = mysql_fetch_row($res)) { if ($arr[0] == $findpost) break; ++$i; } $page = ceil($i / $perpage); } if ($page == "last") $page = $pages; else { if($page < 1) $page = 1; elseif ($page > $pages) $page = $pages; } $offset = $page * $perpage - $perpage; for ($i = 1; $i <= $pages; ++$i) { if ($i == $page) $pagemenu .= "$i\n"; else $pagemenu .= "$i\n"; } if ($page == 1) $pagemenu .= "
<< Poprzednia"; else $pagemenu .= "
<< Poprzednia"; $pagemenu .= "      "; if ($page == $pages) $pagemenu .= "Następna >>

\n"; else $pagemenu .= "Następna >>

\n"; //------ Get posts $res = mysql_query("SELECT * FROM posts WHERE topicid=$topicid ORDER BY id LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__); stdhead("View topic"); print("

$forum > $subject

\n"); print($pagemenu); //------ Print table begin_main_frame(); begin_frame(); $pc = mysql_num_rows($res); $pn = 0; $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=" . $CURUSER["id"] . " AND topicid=$topicid") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); $lpr = $a[0]; if (!$lpr) mysql_query("INSERT INTO readposts (userid, topicid) VALUES($userid, $topicid)") or sqlerr(__FILE__, __LINE__); while ($arr = mysql_fetch_assoc($res)) { ++$pn; $postid = $arr["id"]; $posterid = $arr["userid"]; $added = $arr["added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " temu)"; //---- Get poster details $res2 = mysql_query("SELECT username,class,avatar,donor,dj_ct, liga, zaklady, karty, title,enabled,warned,signature,uploaded,downloaded FROM users WHERE id=$posterid") or sqlerr(__FILE__, __LINE__); $arr2 = mysql_fetch_assoc($res2); $signature = $arr2[signature]; $signature = ($CURUSER["signatures"] == "yes" ? htmlspecialchars($arr2["signature"]) : ""); $postername = $arr2["username"]; if ($postername == "") { $by = "nieznany[$posterid]"; $avatar = ""; } else { // if ($arr2["enabled"] == "yes") $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars($arr2["avatar"]) : ""); // else // $avatar = "/pic/disabled_avatar.gif"; $title = format_comment($arr2["title"]); if (!$title) $title = get_user_class_name($arr2["class"]); //Sort shit out if ($arr2["downloaded"] > 0) { $ratio = number_format($arr2["uploaded"] / $arr2["downloaded"], 3); $ratio = "$ratio"; } else if ($arr2["uploaded"] > 0) $ratio = "Inf."; else $ratio = "---"; $uploaded = mksize($arr2["uploaded"]); $downloaded = mksize($arr2["downloaded"]); //add popup to display echo ("
 Pobrał: $downloaded
 Wysłał: $uploaded
 Ratio: $ratio
\n"); // end add popup to display $by = "$postername" . ($arr2["donor"] == "yes" ? "Donor" : "") . ($arr2["enabled"] == "no" ? "\"This" : ($arr2["warned"] == "yes" ? "\"Warned\"" : "")). ($arr2["dj_ct"] == "yes" ? "\"DJ\"" : "") . ($arr2["liga"] == "yes" ? "\"PUCHAR" : "") . ($arr2["zaklady"] == "yes" ? "\"PUCHAR" : "") . ($arr2["karty"] == "yes" ? "\"PUCHAR" : "") ." $title"; } if (!$avatar) $avatar = "/pic/default_avatar.gif"; print("\n"); if ($pn == $pc) { print("\n"); if ($postid > $lpr) mysql_query("UPDATE readposts SET lastpostread=$postid WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__); } print("

"); print("
#$postid napisał(a) $by dnia $added"); if (!$locked || get_user_class() >= UC_MODERATOR) print(" - [Cytuj]"); if (($CURUSER["id"] == $posterid && !$locked) || get_user_class() >= UC_MODERATOR) print(" - [Edytuj]"); if (get_user_class() >= UC_MODERATOR) print(" - [Usuń]"); print(" - [Raportuj]"); print("Top

\n"); begin_table(true); $body = "".format_comment($arr["body"]).""; if (is_valid_id($arr['editedby'])) { $res2 = mysql_query("SELECT username FROM users WHERE id=$arr[editedby]"); if (mysql_num_rows($res2) == 1) { $arr2 = mysql_fetch_assoc($res2); $body .= "

Ostatnio edytowany przez $arr2[username] dnia $arr[editedat] GMT

\n"; } } if ($signature) $body .= "


____________________
" . format_comment($signature) . "

"; ""; print("" . ($avatar ? "" : ""). "$body\n"); end_table(); } //------ Mod options if (get_user_class() >= UC_MODERATOR) { attach_frame(); $res = mysql_query("SELECT id,name,minclasswrite FROM forums ORDER BY name") or sqlerr(__FILE__, __LINE__); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print(""); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print(""); print("\n"); print("\n"); print("\n"); print("\n"); print(""); print("\n"); print("\n"); print("\n"); print("\n"); print("
Przyklejony: Tak Nie\n"); print("
Zamknij: Tak Nie\n"); print("
Zmień nazwe tematu:\n"); print("
Przenieś temat do: 
Usuń temat\n"); print("
\n"); print("\n"); print("\n"); print("\n"); print("Jestem pewien\n"); print("\n"); print("
\n"); print("
\n"); } end_frame(); end_main_frame(); print($pagemenu); if ($locked && get_user_class() < UC_MODERATOR) print("

This topic is locked; no new posts are allowed.

\n"); else { $arr = get_forum_access_levels($forumid) or die; if (get_user_class() < $arr["write"]) print("

You are not permitted to post in this forum.

\n"); else $maypost = true; } //------ "View unread" / "Add reply" buttons print("

\n"); print("\n"); if ($maypost) { print("\n"); } print("
\n"); print("\n"); print("\n"); print("
\n"); print("\n"); print("\n"); print("\n"); print("

\n"); //------ Forum quick jump drop-down insert_quick_jump_menu($forumid); stdfoot(); die; } //-------- Action: Quote if ($action == "quotepost") { $topicid = $_GET["topicid"]; if (!is_valid_id($topicid)) stderr("Error", "Invalid category ID, We logged this action"); stdhead("Cytuj post"); begin_main_frame(); insert_compose_frame($topicid, false, true); end_main_frame(); stdfoot(); die; } //-------- Action: Reply if ($action == "reply") { $topicid = $_GET["topicid"]; if (!is_valid_id($topicid)) die; stdhead("Post reply"); begin_main_frame(); insert_compose_frame($topicid, false); end_main_frame(); stdfoot(); die; } //-------- Action: Move topic if ($action == "movetopic") { $forumid = $_POST["forumid"]; $topicid = $_GET["topicid"]; if (!is_valid_id($forumid) || !is_valid_id($topicid) || get_user_class() < UC_MODERATOR) die; // Make sure topic and forum is valid $res = @mysql_query("SELECT minclasswrite FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) stderr("Error", "Forum not found."); $arr = mysql_fetch_row($res); if (get_user_class() < $arr[0]) die; $res = @mysql_query("SELECT subject,forumid FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) stderr("Error", "Topic not found."); $arr = mysql_fetch_assoc($res); if ($arr["forumid"] != $forumid) @mysql_query("UPDATE topics SET forumid=$forumid WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); // Redirect to forum page header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid"); die; } //-------- Action: Delete topic if ($action == "deletetopic") { $topicid = $_GET["topicid"]; $forumid = $_GET["forumid"]; if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR) die; $sure = $_GET["sure"]; if (!$sure) { stderr("Usuń temat", "Jesteś pewien że chcesz usunąć ten temat? Kliknij\n" . "tutaj aby potwierdzić."); } mysql_query("DELETE FROM topics WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); mysql_query("DELETE FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__); header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid"); die; } //-------- Action: Edit post if ($action == "editpost") { $postid = $_GET["postid"]; if (!is_valid_id($postid)) die; $res = mysql_query("SELECT * FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) != 1) stderr("Error", "No post with ID $postid."); $arr = mysql_fetch_assoc($res); $res2 = mysql_query("SELECT locked FROM topics WHERE id = " . $arr["topicid"]) or sqlerr(__FILE__, __LINE__); $arr2 = mysql_fetch_assoc($res2); if (mysql_num_rows($res) != 1) stderr("Error", "No topic associated with post ID $postid."); $locked = ($arr2["locked"] == 'yes'); if (($CURUSER["id"] != $arr["userid"] || $locked) && get_user_class() < UC_MODERATOR) stderr("Error", "Denied!"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $body = $_POST['body']; if ($body == "") stderr("Błąd", "Treść nie może byc pusta!"); $body = sqlesc($body); $editedat = sqlesc(get_date_time()); mysql_query("UPDATE posts SET body=$body, editedat=$editedat, editedby=$CURUSER[id] WHERE id=$postid") or sqlerr(__FILE__, __LINE__); $returnto = $_POST["returnto"]; if ($returnto != "") { $returnto .= "&page=p$postid#$postid"; header("Location: $returnto"); } else stderr("Success", "Post was edited successfully."); } stdhead(); print("

Edytuj post

\n"); print("
\n"); print("\n"); print("

\n"); print("\n"); print("\n"); print("
Treść"); textbbcode("edit","body",htmlspecialchars(unesc($arr["body"]))); print("
\n"); print("

\n"); stdfoot(); die; } //-------- Action: Delete post if ($action == "deletepost") { $postid = $_GET["postid"]; $sure = $_GET["sure"]; if (get_user_class() < UC_MODERATOR || !is_valid_id($postid)) die; //------- Get topic id $res = mysql_query("SELECT topicid FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res) or stderr("Error", "Post not found"); $topicid = $arr[0]; //------- We can not delete the post if it is the only one of the topic $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); if ($arr[0] < 2) stderr("Error", "Jeżeli usuniesz ten post, skasowany zostanie cały temat. Jeśli chcesz\n" . "usunąć ten temat kliknij.\n"); //------- Get the id of the last post before the one we're deleting $res = mysql_query("SELECT id FROM posts WHERE topicid=$topicid AND id < $postid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) == 0) $redirtopost = ""; else { $arr = mysql_fetch_row($res); $redirtopost = "&page=p$arr[0]#$arr[0]"; } //------- Make sure we know what we do :-) if (!$sure) { stderr("Usuń post", "Czy napewno chcesz skasować ten post? Kliknij\n" . "tutaj aby potwierdzić."); } //------- Delete post mysql_query("DELETE FROM posts WHERE id=$postid") or sqlerr(__FILE__, __LINE__); //------- Update topic update_topic_last_post($topicid); header("Location: $BASEURL/forums.php?action=viewtopic&topicid=$topicid$redirtopost"); die; } //-------- Action: Lock topic if ($action == "locktopic") { $forumid = $_GET["forumid"]; $topicid = $_GET["topicid"]; $page = $_GET["page"]; if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR) die; mysql_query("UPDATE topics SET locked='yes' WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid&page=$page"); die; } //-------- Action: Unlock topic if ($action == "unlocktopic") { $forumid = $_GET["forumid"]; $topicid = $_GET["topicid"]; $page = $_GET["page"]; if (!is_valid_id($topicid) || get_user_class() < UC_MODERATOR) die; mysql_query("UPDATE topics SET locked='no' WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); header("Location: $BASEURL/forums.php?action=viewforum&forumid=$forumid&page=$page"); die; } //-------- Action: Set locked on/off if ($action == "setlocked") { $topicid = 0 + $_POST["topicid"]; if (!$topicid || get_user_class() < UC_MODERATOR) die; $locked = sqlesc($_POST["locked"]); mysql_query("UPDATE topics SET locked=$locked WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); header("Location: $_POST[returnto]"); die; } //-------- Action: Set sticky on/off if ($action == "setsticky") { $topicid = 0 + $_POST["topicid"]; if (!$topicid || get_user_class() < UC_MODERATOR) die; $sticky = sqlesc($_POST["sticky"]); mysql_query("UPDATE topics SET sticky=$sticky WHERE id=$topicid") or sqlerr(__FILE__, __LINE__); header("Location: $_POST[returnto]"); die; } //-------- Action: Rename topic if ($action == 'renametopic') { if (get_user_class() < UC_MODERATOR) die; $topicid = $_POST['topicid']; if (!is_valid_id($topicid)) die; $subject = $_POST['subject']; if ($subject == '') stderr('Error', 'You must enter a new title!'); $subject = sqlesc($subject); mysql_query("UPDATE topics SET subject=$subject WHERE id=$topicid") or sqlerr(); $returnto = $_POST['returnto']; if ($returnto) header("Location: $returnto"); die; } //-------- Action: View forum if ($action == "viewforum") { $forumid = $_GET["forumid"]; if (!is_valid_id($forumid)) die; $page = $_GET["page"]; $userid = $CURUSER["id"]; //------ Get forum name $res = mysql_query("SELECT name, minclassread FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res) or die; $forumname = $arr["name"]; if (get_user_class() < $arr["minclassread"]) die("Not permitted"); //------ Page links //------ Get topic count $perpage = $CURUSER["topicsperpage"]; if (!$perpage) $perpage = 20; $res = mysql_query("SELECT COUNT(*) FROM topics WHERE forumid=$forumid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); $num = $arr[0]; if ($page == 0) $page = 1; $first = ($page * $perpage) - $perpage + 1; $last = $first + $perpage - 1; if ($last > $num) $last = $num; $pages = floor($num / $perpage); if ($perpage * $pages < $num) ++$pages; //------ Build menu $menu = "

\n"; $lastspace = false; for ($i = 1; $i <= $pages; ++$i) { if ($i == $page) $menu .= "$i\n"; elseif ($i > 3 && ($i < $pages - 2) && ($page - $i > 3 || $i - $page > 3)) { if ($lastspace) continue; $menu .= "... \n"; $lastspace = true; } else { $menu .= "$i\n"; $lastspace = false; } if ($i < $pages) $menu .= "|\n"; } $menu .= "
\n"; if ($page == 1) $menu .= "<< Poprzednia"; else $menu .= "<< Poprzednia"; $menu .= "      "; if ($last == $num) $menu .= "Następna >>"; else $menu .= "Następna >>"; $menu .= "

\n"; $offset = $first - 1; //------ Get topics data $topicsres = mysql_query("SELECT * FROM topics WHERE forumid=$forumid ORDER BY sticky, lastpost DESC LIMIT $offset,$perpage") or stderr("SQL Error", mysql_error()); stdhead("Forum"); $numtopics = mysql_num_rows($topicsres); print("

$forumname

\n"); if ($numtopics > 0) { print($menu); print(""); print("\n" . "\n"); print("\n"); while ($topicarr = mysql_fetch_assoc($topicsres)) { $topicid = $topicarr["id"]; $topic_userid = $topicarr["userid"]; $topic_views = $topicarr["views"]; $views = number_format($topic_views); $locked = $topicarr["locked"] == "yes"; $sticky = $topicarr["sticky"] == "yes"; //---- Get reply count $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); $posts = $arr[0]; $replies = max(0, $posts - 1); $tpages = floor($posts / $postsperpage); if ($tpages * $postsperpage != $posts) ++$tpages; if ($tpages > 1) { $topicpages = " ("; for ($i = 1; $i <= $tpages; ++$i) $topicpages .= " $i"; $topicpages .= ")"; } else $topicpages = ""; //---- Get userID and date of last post $res = mysql_query("SELECT * FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_assoc($res); $lppostid = 0 + $arr["id"]; $lpuserid = 0 + $arr["userid"]; $lpadded = "" . $arr["added"] . ""; //------ Get name of last poster $res = mysql_query("SELECT * FROM users WHERE id=$lpuserid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) == 1) { $arr = mysql_fetch_assoc($res); $lpusername = "$arr[username]"; } else $lpusername = "unknown[$topic_userid]"; //------ Get author $res = mysql_query("SELECT username FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) == 1) { $arr = mysql_fetch_assoc($res); $lpauthor = "$arr[username]"; } else $lpauthor = "unknown[$topic_userid]"; //---- Print row $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); $new = !$a || $lppostid > $a[0]; $topicpic = ($locked ? ($new ? "lockednew" : "locked") : ($new ? "unlockednew" : "unlocked")); $subject = ($sticky ? "Przyklejony: " : "") . "" . encodehtml($topicarr["subject"]) . "$topicpages"; print("\n" . "\n" . "\n"); print("\n"); } // while print("
TematOdp.Wyśw.AutorOstatni post
" . "
" . "\n" . "$subject
$replies$views$lpauthor$lpadded
przez $lpusername
\n"); print($menu); } // if else print("

Brak tematów

\n"); print("

\n"); print("\n"); print("\n"); print("
Nowe posty" . "Zablokowany temat

\n"); $arr = get_forum_access_levels($forumid) or die; $maypost = get_user_class() >= $arr["write"] && get_user_class() >= $arr["create"]; if (!$maypost) print("

You are not permitted to start new topics in this forum.

\n"); print("

\n"); print("\n"); if ($maypost) print("\n"); print("

\n"); insert_quick_jump_menu($forumid); stdfoot(); die; } //-------- Action: View unread posts if ($action == "viewunread") { $userid = $CURUSER['id']; $maxresults = 25; $res = mysql_query("SELECT id, forumid, subject, lastpost FROM topics ORDER BY lastpost") or sqlerr(__FILE__, __LINE__); stdhead(); print("

Nieprzeczytane tematy lub posty

\n"); $n = 0; $uc = get_user_class(); while ($arr = mysql_fetch_assoc($res)) { $topicid = $arr['id']; $forumid = $arr['forumid']; //---- Check if post is read $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); if ($a && $a[0] == $arr['lastpost']) continue; //---- Check access & get forum name $r = mysql_query("SELECT name, minclassread FROM forums WHERE id=$forumid") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_assoc($r); if ($uc < $a['minclassread']) continue; ++$n; if ($n > $maxresults) break; $forumname = $a['name']; if ($n == 1) { print("\n"); print("\n"); } print("\n"); } if ($n > 0) { print("
TematForum
" . "" . "" . htmlspecialchars($arr["subject"]) . "
$forumname
\n"); if ($n > $maxresults) print("

More than $maxresults items found, displaying first $maxresults.

\n"); print("

Zaznacz jako przeczytane

\n"); } else print("Brak nieprzeczytanych postów lub tematów"); stdfoot(); die; } if ($action == "search") { stdhead("Forum Search"); print("

Szukaj na forum

\n"); $keywords = htmlspecialchars(trim($_GET["keywords"])); if ($keywords != "") { $perpage = 50; $page = max(1, 0 + $_GET["page"]); $ekeywords = sqlesc($keywords); print("

Szukaj słowa \"" . htmlspecialchars($keywords) . "\"

\n"); $res = mysql_query("SELECT COUNT(*) FROM posts WHERE MATCH (body) AGAINST ($ekeywords)") or sqlerr(__FILE__, __LINE__); $arr = mysql_fetch_row($res); $hits = 0 + $arr[0]; if ($hits == 0) print("

Przepraszamy, nic tutaj nie ma!

"); else { $pages = 0 + ceil($hits / $perpage); if ($page > $pages) $page = $pages; for ($i = 1; $i <= $pages; ++$i) if ($page == $i) $pagemenu1 .= "$i\n"; else $pagemenu1 .= "$i\n"; if ($page == 1) $pagemenu2 = "<< Poprzednia\n"; else $pagemenu2 = "<< Poprzednia\n"; $pagemenu2 .= "      \n"; if ($page == $pages) $pagemenu2 .= "Następna >>\n"; else $pagemenu2 .= "Następna >>\n"; $offset = ($page * $perpage) - $perpage; $res = mysql_query("SELECT id, topicid,userid,added FROM posts WHERE MATCH (body) AGAINST ($ekeywords) LIMIT $offset,$perpage") or sqlerr(__FILE__, __LINE__); $num = mysql_num_rows($res); print("

$pagemenu1
$pagemenu2

"); print("\n"); print("\n"); for ($i = 0; $i < $num; ++$i) { $post = mysql_fetch_assoc($res); $res2 = mysql_query("SELECT forumid, subject FROM topics WHERE id=$post[topicid]") or sqlerr(__FILE__, __LINE__); $topic = mysql_fetch_assoc($res2); $res2 = mysql_query("SELECT name,minclassread FROM forums WHERE id=$topic[forumid]") or sqlerr(__FILE__, __LINE__); $forum = mysql_fetch_assoc($res2); if ($forum["name"] == "" || $forum["minclassread"] > $CURUSER["class"]) { --$hits; continue; } $res2 = mysql_query("SELECT username FROM users WHERE id=$post[userid]") or sqlerr(__FILE__, __LINE__); $user = mysql_fetch_assoc($res2); if ($user["username"] == "") $user["username"] = "[$post[userid]]"; print("\n"); } print("
PostTematForumnapisany przez
$post[id]" . htmlspecialchars($topic["subject"]) . "" . htmlspecialchars($forum["name"]) . "$user[username]
at $post[added]
\n"); print("

$pagemenu2
$pagemenu1

"); print("

Znaleziono $hits post" . ($hits != 1 ? "y" : "") . ".

"); print("

Szukaj dalej

\n"); } } print("
\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
Słowa kluczowe
\n" . "Wpisz jedno lub więcej słów.
Słowa bardzo popularne oraz posiadające mniej niż 3 znaki będą ignorowane.
\n
\n"); stdfoot(); die; } //-------- Handle unknown action if ($action != "") stderr("Forum Error", "Unknown action '$action'."); //-------- Default action: View forums if (isset($_GET["catchup"])) catch_up(); //-------- Get forums $forums_res = mysql_query("SELECT * FROM forums ORDER BY sort, name") or sqlerr(__FILE__, __LINE__); stdhead("Fora"); print("

FORUM

\n"); print("

"); print("\n"); print("" . "" . "\n"); while ($forums_arr = mysql_fetch_assoc($forums_res)) { if (get_user_class() < $forums_arr["minclassread"]) continue; $forumid = $forums_arr["id"]; $forumname = htmlspecialchars($forums_arr["name"]); $forumdescription = htmlspecialchars($forums_arr["description"]); $topiccount = number_format($forums_arr["topiccount"]); $postcount = number_format($forums_arr["postcount"]); /* while ($topicids_arr = mysql_fetch_assoc($topicids_res)) { $topicid = $topicids_arr['id']; $postcount_res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__); $postcount_arr = mysql_fetch_row($postcount_res); $postcount += $postcount_arr[0]; } $postcount = number_format($postcount); */ // Find last post ID $lastpostid = get_forum_last_post($forumid); // Get last post info $post_res = mysql_query("SELECT added,topicid,userid FROM posts WHERE id=$lastpostid") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($post_res) == 1) { $post_arr = mysql_fetch_assoc($post_res) or die("Bad forum last_post"); $lastposterid = $post_arr["userid"]; $lastpostdate = $post_arr["added"]; $lasttopicid = $post_arr["topicid"]; $user_res = mysql_query("SELECT username FROM users WHERE id=$lastposterid") or sqlerr(__FILE__, __LINE__); $user_arr = mysql_fetch_assoc($user_res); $lastposter = htmlspecialchars($user_arr['username']); $topic_res = mysql_query("SELECT subject FROM topics WHERE id=$lasttopicid") or sqlerr(__FILE__, __LINE__); $topic_arr = mysql_fetch_assoc($topic_res); $lasttopic = htmlspecialchars($topic_arr['subject']); $lastpost = "$lastpostdate
" . "przez $lastposter
" . "w $lasttopic
"; $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$CURUSER[id] AND topicid=$lasttopicid") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); if ($a && $a[0] >= $lastpostid) $img = "unlocked"; else $img = "unlockednew"; } else { $lastpost = "N/A"; $img = "unlocked"; } print("" . "\n"); } print("
www.central-torrent.euTematyPostyOstatni post
$forumname\n" . ($CURUSER['class']>=UC_ADMINISTRATOR ? " ". "[Edytuj] ". "[Usuń]" : ""). "
\n$forumdescription
$topiccount$postcount$lastpost
\n"); stdfoot(); ?>