public static function validateUser($email, $password) { $user = DBAL::getInstance()->getUserByEmail($email); if (count($user) == 0) { // Throw UserNotFoundException return false; } else { if (sha1($user['salt'] . $password) == $user['password']) { Authentication::setSession($user['id']); return true; } else { return false; } } }
<?php require_once '../class/DBAL.php'; require_once '../class/ImageInfo.php'; $db = DBAL::getInstance(); $user_id = 1; // This should be replaced with some sort of authentication service if (isset($_FILES) && !empty($_FILES) && isset($_GET) && !empty($_GET)) { $thumbnails = array(); $filename = $user_id . "_" . rand(0, 10000); $phy_path = dirname(__FILE__) . "\\..\\upload\\"; $uri_path = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER["REQUEST_URI"]) . '/../upload/'; $tmp_file = $_FILES["file"]["tmp_name"]; $org_file = $phy_path . $filename . ".jpg"; move_uploaded_file($tmp_file, $org_file); $info = ImageInfo::getImageInfo($org_file); $latitude = $info['lat']; $longitude = $info['lng']; $photo_shot = $info['photo_shot']; $description = $_GET['description']; $tags = explode(',', $_GET['tags']); if (!empty($latitude)) { // Create three pictures, 2 thumbnails and one main // Dimensions // Small: 160x120 // Medium: 260x180 // Large: 640x480 array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_small.jpg", 160, 120), 'uri_path' => $uri_path . $filename . "_small.jpg", 'type' => 0)); array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_medium.jpg", 260, 180), 'uri_path' => $uri_path . $filename . "_medium.jpg", 'type' => 1)); array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_large.jpg", 640, 480), 'uri_path' => $uri_path . $filename . "_large.jpg", 'type' => 2)); $db->insertPicture($user_id, $phy_path . $filename . ".jpg", $uri_path . $filename . ".jpg", $latitude, $longitude, $photo_shot, $description, $tags, $thumbnails);
/** * @method GET */ function getTags() { return json_encode(DBAL::getInstance()->getTopTags()); }
/** * @method GET */ function getUsers() { return json_encode(DBAL::getInstance()->getUsers()); }
/** * @method GET * @param int $user_id */ function listPictures($tags) { return json_encode(DBAL::getInstance()->getPicturesByTags($tags)); }