Ejemplo n.º 1
0
echo '<h2>Register</h2>';
if ($recaptcha_use) {
    require_once 'sp-includes/recaptchalib.php';
}
if (isset($_POST['submit'])) {
    $error = false;
    // error check: recaptcha
    if ($recaptcha_use) {
        $resp = recaptcha_check_answer($recaptcha_key_private, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
        if (!$resp->is_valid) {
            $recaptcha_error = $resp->error;
            $error = true;
        }
    }
    // error check: existing username
    $usercheck = db_query_single("SELECT username FROM users WHERE username='******'uname']) . "'");
    if ($usercheck) {
        $errors_user[] = 'Your desired username has already been taken, please pick another username.';
        $error = true;
    }
    // error check: no characters
    if (!hascharacters($_POST['uname'])) {
        $errors_user[] = 'Your desired username cannot be exclusively spaces or blank, please pick another username.';
        $error = true;
    } elseif (strlen($_POST['uname']) < 3) {
        $errors_user[] = 'Your desired username is too short, please pick a longer username.';
        $error = true;
    } elseif (strlen($_POST['uname']) > 24) {
        $errors_user[] = 'Your desired username is too long, please pick a shorter username.';
        $error = true;
    }
Ejemplo n.º 2
0
 function resetEvent()
 {
     $db = Database::getConnection();
     db_query_single("DELETE FROM standings WHERE event = ?", "s", $this->name);
     db_query_single("DELETE FROM matches WHERE subevent = ? OR subevent = ?", "ss", $this->mainid, $this->finalid);
     db_query_single("UPDATE entries SET medal = 'dot' WHERE event = ?", "s", $this->name);
     $this->current_round = 0;
     $this->active = 0;
     $this->save();
 }
Ejemplo n.º 3
0
 public function nextEvent()
 {
     $result = db_query_single("SELECT events.name FROM events JOIN series ON series.name = events.series WHERE series.name = ? AND events.start > NOW() ORDER BY events.start LIMIT 1", "s", $this->name);
     if ($result) {
         return new Event($result);
     } else {
         return null;
     }
 }
Ejemplo n.º 4
0
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
include 'sp-core.php';
if (isset($_GET['id']) && $_GET['id'] != $_SESSION['uid']) {
    if (is_numeric($_GET['id'])) {
        if ($users->client->is_admin) {
            $id = $_GET['id'];
        } else {
            $id = false;
        }
    }
} else {
    $id = $_SESSION['uid'];
}
$profile = db_query_single("SELECT users.*, groups.name AS group_name FROM users LEFT JOIN groups ON groups.id = users.group WHERE users.id = '{$id}'");
// bad id? non-admin? don't go through! oh, and make sure the profile exists!
if ($id && $profile) {
    $page->setType('account');
    $page->setTitle($profile['username'] . '\'s account');
    $subpage = $_GET['p'];
    ?>

<div class="imgtitle imgtitle-32">
	<img class="image" src="<?php 
    echo $location['images'];
    ?>
/titles/account.png" alt="" />
	<img src="<?php 
    echo getav($id);
    ?>
Ejemplo n.º 5
0
 function __construct()
 {
     // whether the client is logged in
     $this->is_logged = false;
     $sessionactive = !empty($_SESSION['username']) && !empty($_SESSION['password']) && !empty($_SESSION['uid']);
     if (!empty($_COOKIE['mt_username']) && !empty($_COOKIE['mt_password'])) {
         if (!$sessionactive) {
             $_SESSION['username'] = $_COOKIE['mt_username'];
             $_SESSION['password'] = $_COOKIE['mt_password'];
             $_SESSION['uid'] = $_COOKIE['mt_uid'];
             $sessionactive = true;
         }
     }
     if ($sessionactive) {
         // okay, session active, but are they a valid user?
         if (!$this->is_user($_SESSION['username'], $_SESSION['password'], true)) {
             unset($_SESSION['username']);
             unset($_SESSION['password']);
             unset($_SESSION['uid']);
         } else {
             $this->is_logged = true;
         }
     }
     // so if we're logged in, grab our info!
     if ($this->is_logged) {
         parent::__construct($_SESSION['uid']);
     }
     // whether the client is an admin
     $this->is_admin = false;
     if (isset($_SESSION['username'])) {
         $info = db_query_single("SELECT global_admin FROM groups WHERE id = '{$this->info['group']}'", "Checking whether the client is an administrator");
         if ($info[0]) {
             $this->is_admin = true;
         }
     }
 }
Ejemplo n.º 6
0
function ticket_comment_delete($comment)
{
    $success = true;
    $error = '';
    if (is_numeric($comment)) {
        // find the ticket the comment falls under
        $arr = db_query_single("SELECT issue FROM comments WHERE id='{$comment}'");
        $ticket = $arr[0];
        // delete the ticket
        db_query("DELETE FROM comments WHERE id='{$comment}'") or $error = 'The comment could\'nt be deleted... it\'s most likely it already has been.';
        // if the ticket's already been deleted we definitely do not want to mess with the ticket again
        if ($error == '') {
            // update the count
            db_query("UPDATE issues SET num_comments=num_comments-1 WHERE id='{$ticket}'") or $error = 'Couldn\'t update the ticket (comment count)... has the ticket been deleted?';
            if ($error == '') {
                // get the newest ticket that hasn't been killed off
                $newquery = db_query("SELECT when_posted FROM comments WHERE issue='{$ticket}' ORDER BY when_posted DESC LIMIT 1");
                // is there one?
                if (mysql_num_rows($newquery)) {
                    $newqueryarr = mysql_fetch_array($newquery);
                    $newtime = $newqueryarr[0];
                } else {
                    $newquery2 = db_query("SELECT when_opened FROM issues WHERE id='{$ticket}'") or $error = 'Couldn\'t update the ticket (non-existent)... has the ticket been deleted?';
                    $newquery2arr = mysql_fetch_array($newquery2);
                    $newtime = $newquery2arr[0];
                }
                // and finally, update the ticket!
                if ($error == '') {
                    db_query("UPDATE issues SET when_updated='{$newtime}' WHERE id='{$ticket}'") or $error = 'Couldn\'t update the ticket (last update time)... has the ticket been deleted?';
                }
            }
        }
    } else {
        $success = false;
    }
    if ($error != '') {
        $success = false;
    }
    // return
    return array('success' => $success, 'message' => $error);
}
Ejemplo n.º 7
0
/**
 * @version 0.1
 * @since 0.1
 */
function getissnm($id)
{
    $q = db_query_single("SELECT name FROM issues WHERE id = {$id}", "Retrieving info for issue id {$id} from database");
    return $q[0];
}