Exemple #1
0
<?php

require_once 'includes/config.php';
require_once 'database/db.php';
require_once 'classes/log.php';
require_once 'classes/event.php';
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
require_once 'twig/twig.php';
require_once 'header.php';
require_once 'functions/authenticate.php';
if (key_exists('action', $_GET)) {
    if ($_GET['action'] == 'logout') {
        event::fire('USER_LOGOUT');
        $auth->logout();
        // this can definitely be improved. header() causes stuff to break
        echo '<meta http-equiv="refresh" content="0;url=index.php" />';
        die;
    }
}
if ($auth->isLoggedIn()) {
    header("Location: profile.php");
    die;
}
$template = $twig->loadTemplate('login.html');
$msg = isset($msg) ? $msg : '';
$dest = $_SESSION['destination'];
echo $template->render(array('msg' => $msg, 'dest' => $dest));
//require_once('footer.php');
$db->close();
Exemple #2
0
 if (empty($userid)) {
     event::fire('HAX_CONFIRMATION_USERID');
     $code = $_POST['code'];
     $userid = intval($_POST['userid']);
     $msg = 'The User Identifcation code is empty, did you tamper with the URL?';
     return;
 }
 if (!preg_match('/^[a-fA-F0-9]+$/', $code)) {
     event::fire('HAX_CONFIRMATION_CODE');
     $code = $_POST['code'];
     $userid = intval($_POST['userid']);
     $msg = 'The confirmation code is borked, did you tamper with the URL?';
     return;
 }
 if (strlen($code) < 32) {
     event::fire('HAX_CONFIRMATION_CODE');
     $code = $_POST['code'];
     $userid = intval($_POST['userid']);
     $msg = 'The confirmation code is borked, did you tamper with the URL?';
     return;
 }
 if ($password != $cpassword) {
     $msg = 'The passwords you entered do not match.';
     $code = $_POST['code'];
     $userid = intval($_POST['userid']);
     return;
 }
 if ($auth->checkCode($userid, $code)) {
     $isConfirmed = 1;
     $auth->resetPassword($userid, $password);
     return;
Exemple #3
0
    $id = $_GET['friendid'];
    $userid = $_GET['userid'];
    $conf = $friends->verifyFriend($userid, $id);
    if ($conf < 0) {
        $msg = 'Failed to verify this friendship.';
        return;
    }
    if (empty($conf)) {
        event::fire('USER_CONFIRM_FRIEND');
        $msg = "You are now friends with this person. View their <a href='profile.php?userid=" . $id . "'>profile</a>.";
    } else {
        $msg = $conf;
    }
    return $msg;
}
if ($action == "ignoreFriend") {
    $id = $_GET['friendid'];
    $userid = $_GET['userid'];
    $conf = $friends->ignoreFriend($userid, $id);
    if ($conf < 0) {
        $msg = 'Failed to ignore this friendship.';
        return;
    }
    if ($conf == 1) {
        event::fire('USER_IGNORE_FRIEND');
        $msg = "You have now ignored this friendship.";
    } else {
        $msg = $conf;
    }
    return $msg;
}
Exemple #4
0
        $msg = 'You can\'t just leave your comment empty, nobody can read it.';
        return;
    }
    if (strlen($content) <= 3) {
        $msg = 'Your comment should ideally be over 4 characters long...';
        return;
    }
    /* is this hack... shit? */
    if (empty($table)) {
        $msg = 'You need to include the table';
        return;
    }
    switch ($table) {
        case 1:
            $table = tbl_blog;
            break;
        case 2:
            $table = tbl_goals;
            break;
    }
    event::register('COMMENT_POST', function ($args = array()) {
        /*
        	We want to give a badge to every user who posts heaps...
        */
    });
    $add = $comments->add($userid, $pageid, $table, $content);
    if (!empty($add)) {
        event::fire('COMMENT_POST');
        $msg = 'Thank you for adding your comment ' . $_SESSION['username'];
    }
}
Exemple #5
0
<?php

require_once 'classes/achievements.php';
require_once 'classes/todo.php';
$achievement = new Achievements();
$todo = new Todo();
if (isset($_GET['action'])) {
    $data["goal_id"] = $_POST['goal_id'];
    $data["user_id"] = (int) $_SESSION['userid'];
    $data["comments"] = $_POST['comments'];
    $data["location"] = $_POST['location'];
    $data["date"] = time();
    $id = $achievement->add($data);
    $todo->remove($data["goal_id"], $_SESSION["userid"]);
    $msg = "Achievement Successfully Achieved!";
    echo "Achievement Successfully Achieved!";
    event::fire('USER_GOAL_COMPLETION');
}
Exemple #6
0
$todo = new Todo();
if ($_GET['action'] == 'addGoal') {
    $id = (int) $_GET['id'];
    $userid = $_SESSION['userid'];
    $add = $todo->add($id, $userid);
    if ($add < 0) {
        $msg = 'Failed to add goal to your TODO list';
        return;
    }
    if (empty($add)) {
        event::fire('USER_NEW_GOAL');
        $msg = "Added successfully. <a href='todo.php'>View your list</a>";
    } else {
        $msg = $add;
    }
    return $msg;
} else {
    if ($_GET['action'] == 'remGoal') {
        $id = (int) $_GET['id'];
        $userid = $_SESSION['userid'];
        $remove = $todo->remove($id, $userid);
        if (!empty($remove)) {
            $msg = 'Failed to remove goal from your TODO list';
            return;
        }
        if (empty($add)) {
            event::fire('USER_REMOVE_GOAL');
            $msg = 'Goal removed successfully.';
        }
    }
}
Exemple #7
0
<?php

require_once '../classes/event.php';
require_once '../classes/log.php';
// register the new event and do what needs to be done
event::register('USER_REGISTRATION', function ($args = array()) {
    // do whatever you want here
});
// initiate the event
event::fire('USER_REGISTRATION');
Exemple #8
0
    header("Location: login.php");
    die;
}
if (isset($_GET['userid'])) {
    $userid = intval($_GET['userid']);
} else {
    $userid = $_SESSION['userid'];
}
if ($userid != $_SESSION['userid']) {
    $isViewing = true;
    $isFriend = $friends->checkIsFriend($userid, $_SESSION['userid']);
}
$achievements = $achievement->getAchievements($userid);
$allFriends = $friends->getFriends($userid);
$profileArr = $profile->get($userid);
$activities = $profile->getActivities($userid);
$latestStatus = $profile->getLatestStatus($userid);
$requests = $friends->getFriendRequests($userid);
if ($_GET['action'] == 'modify') {
    if ($isViewing) {
        event::fire('HACK_PROFILE_EDIT');
        header("Location: profile.php");
    }
    $template = $twig->loadTemplate('profile_edit.html');
} elseif (empty($profileArr['first_name'])) {
    header("Location: profile.php?action=modify");
} else {
    $template = $twig->loadTemplate('profile.html');
}
echo $template->render(array('msg' => $msg, 'profile' => $profileArr, 'achievements' => $achievements, 'friends' => $allFriends, 'isFriend' => $isFriend, 'activities' => $activities, 'isViewing' => $isViewing, 'isEditing' => $isEditing, 'latestStatus' => $latestStatus, 'avatar' => get_gravatar($profileArr['email']), 'requests' => $requests));
$db->close();
Exemple #9
0
<?php

require_once 'event.class.php';
// dummy user data entered on registration
$userInfo = array('id' => '1', 'username' => 'kingy', 'password' => '12345');
// register the new event and do what needs to be done
event::register('USER_REGISTRATION', function ($args = array()) {
    /* do whatever you want here
     * insert new registration log for $userInfo[id] etc
     */
});
// initiate the event
event::fire('USER_REGISTRATION', $userInfo);