예제 #1
0
 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;
         }
     }
 }
예제 #2
0
<?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);
예제 #3
0
파일: Tag.php 프로젝트: r0stig/Photo-Travel
 /**
  * @method GET
  */
 function getTags()
 {
     return json_encode(DBAL::getInstance()->getTopTags());
 }
예제 #4
0
 /**
  * @method GET
  */
 function getUsers()
 {
     return json_encode(DBAL::getInstance()->getUsers());
 }
예제 #5
0
 /**
  * @method GET
  * @param int $user_id
  */
 function listPictures($tags)
 {
     return json_encode(DBAL::getInstance()->getPicturesByTags($tags));
 }