예제 #1
0
파일: session.php 프로젝트: nickavv/iSENSE
 function start()
 {
     global $db;
     if (isset($_COOKIE['isense_login'])) {
         $session_token = $_COOKIE['isense_login'];
         $uid = getUserIdFromSessionToken($session_token);
         if ($uid) {
             $this->token = $session_token;
             $this->userid = $uid;
             $details = getUserDetails($this->userid);
             $this->username = $details['email'];
             $this->type = $details['administrator'];
             $this->first_name = $details['firstname'];
             $this->last_name = $details['lastname'];
         }
     }
 }
예제 #2
0
파일: api.php 프로젝트: nickavv/iSENSE
 } else {
     require_once LIB_DIR . 'S3.php';
     $s3 = new S3(AWS_ACCESS_KEY, AWS_SECRET_KEY);
     $url = "http://s3.amazonaws.com/" . AWS_IMG_BUCKET;
     $target_path = '/tmp/';
     $target_path = $target_path . basename($_FILES['image']['name']);
     // Mime Type Check
     $mime = mime_content_type($_FILES['image']['tmp_name']);
     $accepted_mimes = array('image/jpeg', 'image/gif', 'image/png');
     if (!in_array($mime, $accepted_mimes)) {
         $data = array("msg" => "The image type you attempted to upload is not supported");
         $status = 552;
         unlink($_FILES['image']['tmp_name']);
     } else {
         if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
             $uid = getUserIdFromSessionToken($session_key);
             $ext = substr($target_path, strpos($target_path, ".") + 1);
             $ext = str_replace(".", "", $ext);
             $name = $sid . '_' . $uid . '_' . time() . '_1.' . $ext;
             $s3->putObjectFile($target_path, AWS_IMG_BUCKET, $name, S3::ACL_PUBLIC_READ);
             $provider_url = $url . '/' . $name;
             createImageItemSes($session->userid, $eid, $sid, $img_name, $img_desc, 'Amazon S3', $name, $provider_url, AWS_IMG_BUCKET, 1);
             $data = array("msg" => "Image upload successful!");
             $status = 200;
         } else {
             unlink($_FILES['image']['tmp_name']);
             $data = array("msg" => "There was an error uploading your image");
             $status = 553;
         }
     }
 }