<?php // configuration require "../includes/config.php"; verify_access(); if (!isset($_GET["soc"])) { redirect("home.php"); } // assoc array containing name, creator, date created, and description $soc = get_society($_GET["soc"]); if (!$soc) { apologize("Nothing here!"); } log_soc_activity($soc["soc_id"]); $title = $soc["soc_name"]; $status = soc_rel($soc); if (isset($_GET["saction"])) { if (strcasecmp($_GET["saction"], "sub") == 0 && !$status["sub"]) { sub_soc($soc); } elseif (strcasecmp($_GET["saction"], "unsub") == 0 && $status["sub"]) { unsub_soc($soc); } $status = soc_rel($soc); }
/** Mod functions */ function has_mod_access($soc, $uid = null) { isset($uid) || ($uid = $_SESSION["user"]["user_id"]); $status = soc_rel($soc, $uid); return $status["mod"] || $status["admin"]; }
<?php require "soc_common.php"; if (isset($_GET["pid"])) { // fetch post $post = get_post($_GET["pid"]); if (!$post || $post["status"] == "DELETED") { apologize("Nothing here!"); } if ($post["soc_id"] != $soc["soc_id"]) { redirect("post.php?pid=" . $_GET["pid"] . "&soc=" . get_society_by_id($post["soc_id"])["soc_name"]); } // register post view register_post_view($post["post_id"]); if (isset($_GET["paction"])) { if (strcasecmp($_GET["paction"], "sub")) { post_sub($post["post_id"]); } elseif (strcasecmp($_GET["paction"], "unsub")) { post_unsub($post["post_id"]); } } // fetch comments $comms = get_comments($post); render_mult(["soc_common.php", "post.php"], ["title" => $post["title"] . " - " . $soc["soc_name"], "post" => $post, "soc" => $soc, "status" => soc_rel($soc), "psub" => post_rel($post["post_id"]), "comms" => $comms]); } else { redirect("soc.php?soc=" . $soc["soc_name"]); }
function am_banned_soc($s) { $rel = soc_rel($s); return $rel["banned"]; }
function del_mod($uname, $s, $comment = null) { if (!($u = get_user($uname))) { apologize("Invalid username."); } if (is_banned($u)) { apologize("User is banned from the site."); } $ustatus = soc_rel($s, $u["user_id"]); if (!$ustatus["mod"]) { apologize("User is not a moderator of " . $s["soc_name"] . "."); } if (!am_mod($s) || $ustatus["creator"] && $u["user_id"] == $_SESSION["user_id"]) { apologize("Access Denied."); } return tquery("\t\n\t\t\t\t\t\tdelete from soc_mods\n\t\t\t\t\t\twhere user_id = ?\n\t\t\t\t\t\tand soc_id = ?;\n\t\t\t\t\t\t\n\t\t\t\t\t\tinsert into user_control_mod_log(user_id, mod_id, soc_id, action, comment)\n\t\t\t\t\t\tvalues(?, ?, ?, ?, ?);", [$u["user_id"], $s["soc_id"]], [$u["user_id"], $_SESSION["user"]["user_id"], $s["soc_id"], "DEMOD", $comment]); }