Example #1
0
 /**
  * register-funktio rekisteröi käyttäjän
  */
 public function register($username, $password, $password2)
 {
     if ($password != $password2 || strlen($password) < 6) {
         return "Rekisteröinti epäonnistui.Syy: Salasanat eivät täsmää tai salasanasi on alle 6 merkkiä";
     } else {
         if (User::username_exists($username) || strlen($username) < 4) {
             return "Rekisteröinti epäonnistui.Syy: Käyttäjänimi on jo käytössä tai käyttäjänimesi on alle 4 merkkiä.";
         } else {
             $statement = DB::connection()->prepare("INSERT INTO kayttaja(kayttajanimi,salasana,kayttajataso) VALUES(:username,:password,1)");
             $statement->execute(array('username' => $username, 'password' => $password));
             return "Rekisteröinti onnistui";
         }
     }
 }
Example #2
0
<?php

require_once "../initialize.php";
$message = "";
if (isset($_POST['object'])) {
    if ($_POST['object'] == "user") {
        $username = $_POST["username"];
        $password = $_POST["password"];
        if (!User::username_exists($username)) {
            $object = new User();
            $object->username = $_POST["username"];
            $object->password = $_POST["password"];
            $object->create();
            $message = "success";
        } else {
            $message = "The username " . $username . " already exists. Please use a different one.";
        }
    } else {
        $message = "Object Specified Does Not Exists";
    }
} else {
    $message = "No Create Object Specified";
}
echo $message;
Example #3
0
<?php

require_once "header.php";
if ($session->is_logged_in()) {
    header("location: index.php?negative");
}
$pathinfo = pathinfo($_SERVER["PHP_SELF"]);
$basename = $pathinfo["basename"];
$currentFile = str_replace(".php", "", $basename);
if (isset($_POST['registration_submit'])) {
    $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    if ($resp->is_valid) {
        if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != "" && $_POST['password'] != "") {
            $username_exists = User::username_exists($_POST['username']);
            $email_exists = false;
            if (isset($_POST['email']) && $_POST['email'] != "") {
                $email_exists = User::email_exists($_POST['email']);
            }
            if ($username_exists) {
                $sound = "negative";
                $message .= "Sorry, the username: <i><b>" . $_POST['username'] . '</b></i> is already taken. Please choose a different one.<br />';
            }
            if ($email_exists) {
                $sound = "negative";
                $message .= "Sorry, the email: <i><b>" . $_POST['email'] . '</b></i> is already registered.';
            }
            if ($message == "") {
                $user = new User();
                $user->username = $_POST['username'];
                $user->password = $_POST['password'];
                $user->email = $_POST['email'];
Example #4
0
<?php

require_once "../includes/initialize.php";
global $session;
$result = "all fields are required";
if (!empty($_GET['group_id']) && !empty($_GET['name']) && !empty($_GET['username']) && !empty($_GET['password']) && !empty($_GET['email'])) {
    $user = new User();
    $user->name = htmlentities(trim($_GET['name']));
    $user->group_id = htmlentities(trim($_GET['group_id']));
    $user->username = htmlentities(trim($_GET['username']));
    $user->password = htmlentities(trim($_GET['password']));
    $user->email = htmlentities(trim($_GET['email']));
    $user->access_token = md5($user->username);
    $user->picture = "default.png";
    $user->level = 2;
    $user->access = 1;
    if (Group::group_exists($user->group_id)) {
        if (User::username_exists($user->username, $user->group_id)) {
            $result = "Username: "******" already exists";
        } else {
            $user->create();
            $session->login($user);
            $result = "success";
        }
    } else {
        $result = "the group you are trying to register does not exist";
    }
}
echo $result;
Example #5
0
<?php

require_once "../../includes/initialize.php";
$config = array();
$config['appId'] = APP_ID;
$config['secret'] = APP_SECRET;
$facebook = new Facebook($config);
$fb_user = $facebook->api('/me', 'GET');
if (User::get_by_oauthid($fb_user['id']) != null) {
    header("location: ../../registration.php?fbtaken=Facebook Username: "******"<br/>Facebook ID: " . $fb_user['id']);
} else {
    $username_exists = User::username_exists($fb_user['username']);
    $email_exists = false;
    if (isset($fb_user['email']) && $fb_user['email'] != "") {
        $email_exists = User::email_exists($fb_user['email']);
    }
    if ($username_exists) {
        $message .= "Sorry, the username: <i><b>" . $fb_user['username'] . '</b></i> is already taken. Please choose a different one.<br />';
    }
    if ($email_exists) {
        $message .= "Sorry, the email: <i><b>" . $fb_user['email'] . '</b></i> is already registered.';
    }
    if ($message == "") {
        $generatePassword = generatePassword();
        $user = new User();
        $user->username = $fb_user['username'];
        $user->password = $generatePassword;
        $user->email = $fb_user['email'];
        $user->name = $fb_user['name'];
        $user->volume = 4;
        $user->control = 4;
<?php

require_once "../includes/initialize.php";
// require key and id parameter.
if (empty($_POST['username']) || empty($_POST['key']) || empty($_POST['password'])) {
    sendResponse(400, "Invalid request. Please provide \"key\" and \"username\" and \"password\" parameters.");
} else {
    if ($_POST['key'] != API_KEY) {
        sendResponse(403, "Invalid API key.");
    } else {
        $user = User::authenticate($_POST['username'], $_POST['password']);
        if ($user) {
            sendResponse(200, json_encode($user->export()));
        } else {
            if (User::username_exists($_POST['username'])) {
                $response = array("message" => "Sorry, this password is incorrect.");
            } else {
                $response = array("message" => "Sorry, this username does not exist.");
            }
            sendResponse(200, json_encode($response));
        }
    }
}
Example #7
0
 $object->fbcomments = $_POST["fbcomments"];
 $object->enabled = $_POST['enabled'];
 $file = new File($_FILES['picture']);
 if ($file->valid) {
     $object->picture = $file->data;
 } else {
     $object->picture = base64_decode($object->picture);
 }
 $file = new File($_FILES['cover']);
 if ($file->valid) {
     $object->cover = $file->data;
 } else {
     $object->cover = base64_decode($object->cover);
 }
 if ($_POST["username"] != $object->username) {
     if (!User::username_exists($_POST["username"])) {
         $object->update();
         $log = new Log($session->user_id, $clientip, "WEB", "UPDATED USER: "******"success";
     } else {
         $log = new Log($session->user_id, $clientip, "WEB", "UPDATE USER ALREADY TAKEN");
         $log->create();
         $message = "Username:"******"username"] . " already taken.";
     }
 } else {
     $object->update();
     $log = new Log($session->user_id, $clientip, "WEB", "UPDATED USER: "******"success";
 }
 $group_name_valid = false;
 $group = new Group();
 $group->name = preg_replace('/\\s+/', '', strtolower(htmlentities($_POST['group_create_name'])));
 $user = new User();
 $user->username = htmlentities(trim($_POST['group_create_username']));
 $user->password = htmlentities(trim($_POST['group_create_password']));
 $user->email = htmlentities(trim($_POST['group_create_email']));
 $user->access_token = md5($user->username);
 $user->level = 1;
 $user->access = 1;
 if (Group::group_exists($group->name)) {
     $response = "Group: " . $group->name . " already exists!";
 } else {
     $group_name_valid = true;
 }
 if (User::username_exists($user->username)) {
     $response = "Username:"******" already exists!";
 } else {
     $username_valid = true;
 }
 if ($username_valid && $group_name_valid) {
     $group->create();
     $user->group_id = Group::getLastID();
     $user->create();
     $folder_path = "groups/" . $group->name . "/";
     if (!mkdir($folder_path, 0700)) {
         die("Folder" . $group->name . " already exists!");
     } else {
         mkdir($folder_path . "files", 0700);
         mkdir($folder_path . "files/users", 0700);
         mkdir($folder_path . "files/questions", 0700);