Location: PHPKode > projects > EverQuest Roster/Gallery > html/includes/write_zone.php
<?
        function add_zone($vars) {
                global $SESSION;

                if ($SESSION["level"] != ADMIN) {
                        $err = ERR_NOT_ENOUGH_ACCESS;
                } elseif (!trim($vars["zname"])) {
                        $err = "Zone name can not be blank.";
                } else {
                        $query  = "select zid";
                        $query .= "  from zones";
                        $query .= " where zname = '" . trim($vars["zname"]) . "'";

                        query_db($query, $check);

                        if ($check["zid"]) {
                                $err = "That zone name already exists";
                        } else {
                               $query  = "insert into zones (zid, zname, descrip)";
                               $query .= "values (0, '" . addslashes(trim($vars["zname"])) . "', '" . addslashes(trim($vars["descrip"])) . "')";

                               update_db($query);
                        }
                }

                return $err;
        }

        function del_zone($id) {
                global $SESSION;

                if ($SESSION["level"] != ADMIN) {
                        $err = ERR_NOT_ENOUGH_ACCESS;
                } elseif (!$id) {
                        $err = ERR_ID_BLANK;
                } elseif (eregi("[^[:digit:]]", $id)) {
                        $err = ERR_ID_INVALID;
                } else {
                        $query  = "select zid";
                        $query .= "  from zones";
                        $query .= " where zid = $id";

                        query_db($query, $check);

                        if (!$check["zid"]) {
                                $err = ERR_ID_NOT_EXIST;
                        } else {
                                $query  = "delete";
                                $query .= "  from zones";
                                $query .= " where zid = $id";

                                update_db($query);

                                $query  = "delete";
                                $query .= "  from events";
                                $query .= " where zone = $id";

                                update_db($query);
                        }
                }

                return $err;
        }

        function edit_zone($id, $vars) {
                global $SESSION;

                if ($SESSION["level"] != ADMIN) {
                        $err = ERR_NOT_ENOUGH_ACCESS;
                } else {
                        $temp = array_keys($vars);
                        $err = "";
                        $query = "";

                        if (!trim($vars["zname"])) {
                                $err = "The zone name field cannot be blank.";
                        } elseif (!trim($vars["descrip"])) {
                                $err = "The zone description field cannot be blank.";
                        }

                        if (!$err) {
                                $query  = "update zones";
                                $query .= "   set zname = '" . $vars["zname"] . "', ";
                                $query .= "       descrip = '" . addslashes(trim($vars["descrip"])) . "'";
                                $query .= " where zid = $id";

                                update_db($query);

                        }
                }


                return $err;
        }

?>
Return current item: EverQuest Roster/Gallery