Example #1
0
 /**
  * @covers Respect\Validation\Rules\Uploaded::validate
  */
 public function testShouldValidateObjects()
 {
     $GLOBALS['is_uploaded_file'] = true;
     $rule = new Uploaded();
     $object = new \SplFileInfo('/path/of/an/uploaded/file');
     $this->assertTrue($rule->validate($object));
 }
Example #2
0
 public static function getPicStat($delivery_id)
 {
     $pic_count = 0;
     $sign_count = 0;
     $app = 'app v 1.0';
     $pics_db = Uploaded::where('parent_id', '=', $delivery_id)->get();
     if ($pics_db) {
         if (count($pics_db->toArray()) > 0) {
             $app = 'app v 2.0';
         }
         foreach ($pics_db as $pic) {
             if (intval($pic->is_signature) == 1) {
                 $sign_count++;
             } else {
                 $pic_count++;
             }
         }
     }
     if ($pic_count == 0 && $sign_count == 0) {
         $existingpic = glob(Config::get('jayon.picture_path') . $delivery_id . '*.jpg');
         foreach ($existingpic as $pic) {
             if (preg_match('/_sign.jpg$/', $pic)) {
                 $sign_count++;
             } else {
                 $pic_count++;
             }
         }
     }
     return array('pic' => $pic_count, 'sign' => $sign_count, 'app' => $app);
 }
Example #3
0
 public static function getPictures($_id)
 {
     $files = Uploaded::where('parent_id', $_id)->where('parent_class', 'user')->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
     $pics = array();
     if ($files) {
         foreach ($files as $file) {
             $s = new stdClass();
             foreach (Config::get('picture.sizes') as $key => $value) {
                 $s->{$key . '_url'} = $file->{$key . '_url'};
             }
             $s->url = $file->url;
             $pics[] = $s;
         }
     }
     return $pics;
 }
Example #4
0
 /**
  * Creates individual Entry objects of the appropriate type and
  * stores them in the $_entry array based upon DOM data.
  *
  * @param DOMNode $child The DOMNode to process
  */
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('media') . ':' . 'content':
             $content = new MediaContent();
             $content->transferFromDOM($child);
             $this->_content[] = $content;
             break;
         case $this->lookupNamespace('media') . ':' . 'rating':
             $mediarating = new MediaRating();
             $mediarating->transferFromDOM($child);
             $this->_mediarating = $mediarating;
             break;
         case $this->lookupNamespace('media') . ':' . 'credit':
             $mediacredit = new MediaCredit();
             $mediacredit->transferFromDOM($child);
             $this->_mediacredit = $mediacredit;
             break;
         case $this->lookupNamespace('yt') . ':' . 'duration':
             $duration = new Duration();
             $duration->transferFromDOM($child);
             $this->_duration = $duration;
             break;
         case $this->lookupNamespace('yt') . ':' . 'private':
             $private = new PrivateExtension();
             $private->transferFromDOM($child);
             $this->_private = $private;
             break;
         case $this->lookupNamespace('yt') . ':' . 'videoid':
             $videoid = new VideoId();
             $videoid->transferFromDOM($child);
             $this->_videoid = $videoid;
             break;
         case $this->lookupNamespace('yt') . ':' . 'uploaded':
             $uploaded = new Uploaded();
             $uploaded->transferFromDOM($child);
             $this->_uploaded = $uploaded;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postFiles()
 {
     $key = Input::get('key');
     $user = \Apiauth::user($key);
     $parent_id = Input::get('parid');
     $parent_class = Input::get('parclass');
     $image_id = Input::get('img');
     $ns = Input::get('ns');
     $rstring = str_random(15);
     $result = '';
     $destinationPath = realpath('storage/media') . '/' . $rstring;
     if (isset($_FILES['file'])) {
         $file = $_FILES['file'];
         $filename = $file['name'];
         $filemime = $file['type'];
         $filesize = $file['size'];
         $extension = '.jpg';
         //if you need extension of the file
         $tmp_name = $file['tmp_name'];
         $filename = str_replace(\Config::get('kickstart.invalidchars'), '-', $filename);
         //$uploadSuccess = $file->move($destinationPath, $filename);
         @move_uploaded_file($tmp_name, $destinationPath . '/' . $filename);
         $is_image = true;
         $is_audio = false;
         $is_video = false;
         $is_pdf = false;
         $is_doc = false;
         $is_image = $this->isImage($filemime);
         $is_audio = $this->isAudio($filemime);
         $is_video = $this->isVideo($filemime);
         $is_pdf = $this->isPdf($filemime);
         if (!($is_image || $is_audio || $is_video || $is_pdf)) {
             $is_doc = true;
         } else {
             $is_doc = false;
         }
         if ($is_image) {
             $ps = \Config::get('picture.sizes');
             $thumbnail = \Image::make($destinationPath . '/' . $filename)->fit($ps['thumbnail']['width'], $ps['thumbnail']['height'])->save($destinationPath . '/th_' . $filename);
             $medium = \Image::make($destinationPath . '/' . $filename)->fit($ps['medium']['width'], $ps['medium']['height'])->save($destinationPath . '/med_' . $filename);
             $large = \Image::make($destinationPath . '/' . $filename)->fit($ps['large']['width'], $ps['large']['height'])->save($destinationPath . '/lrg_' . $filename);
             $full = \Image::make($destinationPath . '/' . $filename)->save($destinationPath . '/full_' . $filename);
             $image_size_array = array('thumbnail_url' => \URL::to('storage/media/' . $rstring . '/' . $ps['thumbnail']['prefix'] . $filename), 'large_url' => \URL::to('storage/media/' . $rstring . '/' . $ps['large']['prefix'] . $filename), 'medium_url' => \URL::to('storage/media/' . $rstring . '/' . $ps['medium']['prefix'] . $filename), 'full_url' => \URL::to('storage/media/' . $rstring . '/' . $ps['full']['prefix'] . $filename));
         } else {
             if ($is_audio) {
                 $thumbnail_url = \URL::to('images/audio.png');
             } elseif ($is_video) {
                 $thumbnail_url = \URL::to('images/video.png');
             } else {
                 $thumbnail_url = \URL::to('images/media.png');
             }
             $image_size_array = array('thumbnail_url' => $thumbnail_url, 'large_url' => '', 'medium_url' => '', 'full_url' => '');
         }
         $item = array('ns' => $ns, 'parent_id' => $parent_id, 'parent_class' => $parent_class, 'url' => \URL::to('storage/media/' . $rstring . '/' . $filename), 'temp_dir' => $destinationPath, 'file_id' => $rstring, 'is_image' => $is_image, 'is_audio' => $is_audio, 'is_video' => $is_video, 'is_pdf' => $is_pdf, 'is_doc' => $is_doc, 'name' => $filename, 'type' => $filemime, 'size' => $filesize, 'deleted' => 0, 'createdDate' => new \MongoDate(), 'lastUpdate' => new \MongoDate());
         foreach ($image_size_array as $k => $v) {
             $item[$k] = $v;
         }
         $item['_id'] = new \MongoId($image_id);
         $im = \Uploaded::find($image_id);
         if ($im) {
         } else {
             \Uploaded::insertGetId($item);
         }
         $actor = $user->fullname . ' : ' . $user->email;
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'upload image'));
         return \Response::json(array('status' => 'OK', 'timestamp' => time(), 'message' => $image_id));
     }
     $actor = $user->fullname . ' : ' . $user->email;
     \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'upload image failed'));
     return \Response::json(array('status' => 'ERR:NOFILE', 'timestamp' => time(), 'message' => $image_id));
 }
Example #6
0
//
// Push to NCDS
//
require_once 'uploaded.class.php';
require_once 'KLogger.php';
$backup_location = "physics@ncds1:/disk1/physics_backup";
$log = new KLogger("log.txt", KLogger::DEBUG);
if (isset($_REQUEST['path']) && !empty($_REQUEST['path'])) {
    // prepare destination name
    $dstpath = str_replace('/', '@', $_REQUEST['path']);
    if (substr($dstpath, -1) != "@") {
        $dstpath = $dstpath . "@";
    }
    $dstpath = $dstpath . $fileName;
    $log->LogInfo("Upload: {$filePath} -> {$dstpath}");
    $file = new Uploaded($filePath);
    $fileid = $file->uploadToNCDS($dstpath);
    $log->LogInfo("Uploaded to NCDS Path: {$dstpath} FileID: {$fileid}");
    if ($file->makeBackup($dstpath, $backup_location)) {
        $log->LogInfo("Backup Successful: {$dstpath} Location: {$backup_location}");
    } else {
        $log->LogError("Backup Error: {$dstpath} Location: {$backup_location}");
    }
    if ($fileid) {
        $file->saveMappingToDb();
        $log->LogInfo("Mapping Saved: {$dstpath} FileId: {$fileid}");
    }
    // remove tmp
    unlink($filePath);
} else {
    die('{"jsonrpc" : "2.0", "error" : {"code": 300, "message": "Failed to get destination path."}, "id" : "id"}');
<?php

error_reporting(E_ALL & ~E_NOTICE);
set_time_limit(0);
session_start();
if (!file_exists("./inc/config.inc.php")) {
    die("Config file missing! Aborting.");
}
$startzeit = explode(" ", microtime());
$startzeit = $startzeit[0] + $startzeit[1];
require_once "./inc/functions.php";
$up = new Uploaded();
$login = true;
if (!$up->login($user["user"], $user["pass"])) {
    $login = false;
}
$info = $up->get_account_info();
$premium = true;
if ($info["acc_status"] != "premium") {
    $premium = false;
}
$download = 0;
$error = null;
if (isset($_POST["submit"]) && !empty($_POST["file"])) {
    $fileList = $_POST["file"];
    $fileListArray = explode(PHP_EOL, $fileList);
    $dlFiles = array();
    foreach ($fileListArray as $file) {
        $file = trim($file);
        preg_match('/(http:\\/\\/ul\\.\\S+\\/\\S+)\\//', $file, $hits);
        if ($hits[1]) {
 /**
  * Läd eine Datei auf Uploaded.net hoch
  * 
  * @param string $file Pfad zur Datei z.B. C:\text.txt oder /home/text.txt
  * 
  * @return bool|array false = Upload fehlgeschlagen | array = ['id', 'editKey']
  */
 public function upload($file, $opt = null)
 {
     if (false === ($rf = realpath($file))) {
         $this->set_last_error(UP_ERR_PATH, "ungültiger Pfad");
         return false;
     }
     $options = null;
     if ($opt != null && is_array($opt)) {
         if (isset($opt[UP_PROGRESS_HANDLER])) {
             $options = array();
             $options[CURLOPT_NOPROGRESS] = false;
             $options[CURLOPT_PROGRESSFUNCTION] = $opt[UP_PROGRESS_HANDLER];
         }
     }
     $key = Uploaded::generate();
     $postdata = array('Filename' => basename($rf), 'Upload' => 'Submit Query', 'Filedata' => '@' . $rf);
     $res = $this->get_curl($this->get_upload_server() . 'upload?admincode=' . $key . $this->auth_str, $postdata, true, false, $options);
     if ($res === false) {
         $this->set_last_error(UP_ERR_INTERNAL, "interner Fehler");
         return false;
     }
     if (strpos($res, ',') === false) {
         $this->set_last_error(UP_ERR_LOGIN, 'Logindaten sind falsch: "anonymous fileuploads are forbidden."');
         return false;
     }
     return array('id' => strpos($res, ',') ? substr($res, 0, strpos($res, ',')) : $res, 'editKey' => $key);
 }
Example #9
0
                $detailview = 'wupload.detail';
            }
            try {
                $thumb = View::make($detailview)->with('filedata', $fd)->render();
            } catch (Exception $e) {
            }
            if ($fd['ns'] == $ns) {
                print $thumb;
            }
        }
    }
}
// display re-populated data from error form
if ($showold && isset($allin['parent_id'])) {
    //print_r($allin);
    $files = Uploaded::where('parent_id', $allin['parent_id'])->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
    $ns = isset($allin[$element_id . '_ns']) ? $allin[$element_id . '_ns'] : '';
    if (count($files->toArray()) > 0) {
        foreach ($files->toArray() as $fd) {
            //print_r($fd);
            if ($prefix != '') {
                $detailview = $prefix . '.wdetail';
            } else {
                $detailview = 'wupload.detail';
            }
            try {
                $thumb = View::make($detailview)->with('filedata', $fd)->render();
                if ($fd['ns'] == $ns) {
                    print $thumb;
                }
            } catch (Exception $e) {
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postMeta()
 {
     $key = \Input::get('key');
     //$user = \Apiauth::user($key);
     $user = \Device::where('key', '=', $key)->first();
     if (!$user) {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'device not found, upload image meta failed'));
         return \Response::json(array('status' => 'ERR:NODEVICE', 'timestamp' => time(), 'message' => 'Device Unregistered'));
     }
     $json = \Input::all();
     $batch = \Input::get('batch');
     $result = array();
     foreach ($json as $j) {
         //$j['mtimestamp'] = new \MongoDate(time());
         if (is_array($j)) {
             $blog = new \Imagemeta();
             foreach ($j as $k => $v) {
                 $blog->{$k} = $v;
             }
             $blog->mtimestamp = new \MongoDate(time());
             $r = $blog->save();
             $upl = \Uploaded::where('_id', '=', new \MongoId($blog->extId))->first();
             if ($upl) {
                 $upl->is_signature = $blog->isSignature;
                 $upl->latitude = $blog->latitude;
                 $upl->longitude = $blog->longitude;
                 $upl->delivery_id = $blog->parentId;
                 $upl->photo_time = $blog->photoTime;
                 $upl->save();
             }
             if ($r) {
                 $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['extId']);
             } else {
                 $result[] = array('status' => 'NOK', 'timestamp' => time(), 'message' => 'insertion failed');
             }
         }
     }
     //print_r($result);
     //die();
     $actor = $user->identifier . ' : ' . $user->devname;
     \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'sync scan log'));
     return Response::json($result);
 }
 public function picList($data)
 {
     $data = $data->toArray();
     if ($data['logistic_type'] == 'internal') {
         $pics = Uploaded::where('parent_id', '=', $data['delivery_id'])->get();
     } else {
         $maxdate = Threeplpictures::where('awb', '=', $data['awb'])->max('ts');
         $pics = Threeplpictures::where('awb', '=', $data['awb'])->where('ts', '=', $maxdate)->get();
     }
     $glinks = '';
     $thumbnail_url = '';
     if ($pics) {
         if (count($pics) > 0) {
             foreach ($pics as $g) {
                 if ($data['logistic_type'] == 'internal') {
                     $thumbnail_url = $g->thumbnail_url;
                     $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->name . '" value="' . $g->full_url . '" />';
                 } else {
                     $thumbnail_url = $g->thumbnail;
                     $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->consignee_olshop_cust . '" value="' . $g->pictures . '" />';
                 }
             }
             $display = HTML::image($thumbnail_url . '?' . time(), $thumbnail_url, array('class' => 'thumbnail img-polaroid', 'style' => 'cursor:pointer;', 'id' => $data['_id'])) . $glinks;
             return $display;
         } else {
             return 'No Picture';
         }
     } else {
         return 'No Picture';
     }
 }
 public function postAvatar()
 {
     $files = Input::file('files');
     $parent_id = Input::get('parid');
     $parent_class = Input::get('parclass');
     $ns = Input::get('ns');
     $file = $files[0];
     $rstring = str_random(15);
     $destinationPath = realpath('storage/media') . '/' . $rstring;
     $filename = $file->getClientOriginalName();
     $filemime = $file->getMimeType();
     $filesize = $file->getSize();
     $extension = $file->getClientOriginalExtension();
     //if you need extension of the file
     $filename = str_replace(Config::get('kickstart.invalidchars'), '-', $filename);
     $uploadSuccess = $file->move($destinationPath, $filename);
     $is_image = $this->isImage($filemime);
     $is_audio = $this->isAudio($filemime);
     $is_video = $this->isVideo($filemime);
     $is_pdf = $this->isPdf($filemime);
     if (!($is_image || $is_audio || $is_video || $is_pdf)) {
         $is_doc = true;
     } else {
         $is_doc = false;
     }
     if ($is_image) {
         $ps = Config::get('picture.sizes');
         $thumbnail = Image::make($destinationPath . '/' . $filename)->fit($ps['thumbnail']['width'], $ps['thumbnail']['height'])->save($destinationPath . '/th_' . $filename);
         $medium = Image::make($destinationPath . '/' . $filename)->fit($ps['medium']['width'], $ps['medium']['height'])->save($destinationPath . '/med_' . $filename);
         $large = Image::make($destinationPath . '/' . $filename)->fit($ps['large']['width'], $ps['large']['height'])->save($destinationPath . '/lrg_' . $filename);
         $full = Image::make($destinationPath . '/' . $filename)->save($destinationPath . '/full_' . $filename);
         $image_size_array = array('thumbnail_url' => URL::to('storage/media/' . $rstring . '/' . $ps['thumbnail']['prefix'] . $filename), 'large_url' => URL::to('storage/media/' . $rstring . '/' . $ps['large']['prefix'] . $filename), 'medium_url' => URL::to('storage/media/' . $rstring . '/' . $ps['medium']['prefix'] . $filename), 'full_url' => URL::to('storage/media/' . $rstring . '/' . $ps['full']['prefix'] . $filename));
     } else {
         if ($is_audio) {
             $thumbnail_url = URL::to('images/audio.png');
         } elseif ($is_video) {
             $thumbnail_url = URL::to('images/video.png');
         } else {
             $thumbnail_url = URL::to('images/media.png');
         }
         $image_size_array = array('thumbnail_url' => $thumbnail_url, 'large_url' => '', 'medium_url' => '', 'full_url' => '');
     }
     $fileitems = array();
     if ($uploadSuccess) {
         $item = array('ns' => $ns, 'parent_id' => $parent_id, 'parent_class' => $parent_class, 'url' => URL::to('storage/media/' . $rstring . '/' . $filename), 'temp_dir' => $destinationPath, 'file_id' => $rstring, 'is_image' => $is_image, 'is_audio' => $is_audio, 'is_video' => $is_video, 'is_pdf' => $is_pdf, 'is_doc' => $is_doc, 'name' => $filename, 'type' => $filemime, 'size' => $filesize, 'deleted' => 0, 'createdDate' => new MongoDate(), 'lastUpdate' => new MongoDate());
         foreach ($image_size_array as $k => $v) {
             $item[$k] = $v;
         }
         Uploaded::insert($item);
         $fileitems[] = $item;
         //$fileitems[] = $rstring.'/'.$filename;
     }
     $files = Uploaded::where('parent_id', $parent_id)->where('parent_class', $parent_class)->where('ns', $ns)->where('deleted', 0)->orderBy('createdDate', 'desc')->get();
     $prefix = $parent_class;
     $thumbs = '';
     if (count($files->toArray()) > 0) {
         foreach ($files->toArray() as $fd) {
             //print_r($fd);
             if ($prefix != '') {
                 $detailview = $prefix . '.wdetail';
             } else {
                 $detailview = 'wupload.detail';
             }
             $thumb = View::make($detailview)->with('filedata', $fd)->render();
             $thumbs .= $thumb;
         }
     }
     $thumbs = base64_encode($thumbs);
     return Response::JSON(array('status' => 'OK', 'message' => '', 'file' => $fileitems, 'thumbs' => $thumbs));
 }
Example #13
0
 public function picListInternal($data)
 {
     $data = $data->toArray();
     $pics = Uploaded::where('parent_id', '=', $data['delivery_id'])->get();
     $glinks = '';
     $thumbnail_url = '';
     if ($pics) {
         if (count($pics) > 0) {
             $display = '<ul class="pic_list">';
             foreach ($pics as $g) {
                 $thumbnail_url = $g->thumbnail_url;
                 $display .= '<li>';
                 $display .= HTML::image($thumbnail_url . '?' . time(), $thumbnail_url, array('class' => 'thumbnail img-polaroid', 'style' => 'cursor:pointer;', 'id' => $data['_id']));
                 $display .= '</li>';
                 $glinks .= '<input type="hidden" class="g_' . $data['_id'] . '" data-caption="' . $g->name . '" value="' . $g->full_url . '" />';
             }
             //$display = HTML::image($thumbnail_url.'?'.time(), $thumbnail_url, array('class'=>'thumbnail img-polaroid','style'=>'cursor:pointer;','id' => $data['_id'])).$glinks;
             $display .= '</ul>';
             $display .= $glinks;
             return $display;
         } else {
             return 'No Picture';
         }
     } else {
         return 'No Picture';
     }
 }
Example #14
0
 /**
  * @param string $mediaId
  * @param string $thumbnailId
  */
 public function __construct($mediaId, $thumbnailId)
 {
     parent::__construct($mediaId);
     $this->thumbnailID = $thumbnailId;
 }
Example #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $key = Input::get('key');
     $json = Input::all();
     //print_r($json);
     /*
                         ->join('members as m','d.merchant_id=m.id','left')
                         ->where('assignment_date',$indate)
                         ->where('device_id',$dev->id)
                         ->and_()
                         ->group_start()
                             ->where('status',$this->config->item('trans_status_admin_courierassigned'))
                             ->or_()
                             ->group_start()
                                 ->where('status',$this->config->item('trans_status_new'))
                                 ->where('pending_count >', 0)
                             ->group_end()
                         ->group_end()
     */
     if (is_null($key) || $key == '') {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'empty key'));
         return \Response::json(array('status' => 'ERR:EMPTYKEY', 'timestamp' => time(), 'message' => 'Empty Key'));
     }
     $app = \Application::where('key', '=', $key)->first();
     if ($app) {
         $model = new \Shipment();
         $merchant_id = $app->merchant_id;
         $result = array();
         foreach ($json as $j) {
             if (is_array($j)) {
                 $model = $model->orWhere(function ($q) use($j, $key) {
                     $awb = $j['awb'];
                     $q->where('delivery_id', '=', trim($awb))->where('application_key', '=', trim($key));
                     //->whereNotNull('delivery_id');
                 });
             }
         }
         $awbs = $model->get();
         if ($awbs) {
             foreach ($awbs as $awb) {
                 $pod = array();
                 $pictures = \Uploaded::where('parent_id', '=', $awb->delivery_id)->get();
                 if ($pictures) {
                     foreach ($pictures as $pic) {
                         $p = new \stdClass();
                         $p->thumbnail = $pic->thumbnail_url;
                         $p->pictures = $pic->large_url;
                         $p->is_signature = $pic->is_signature;
                         $pod[] = $p;
                     }
                 }
                 $result[] = array('awb' => $awb->delivery_id, 'timestamp' => date('Y-m-d H:i:s', time()), 'pending' => $awb->pending_count, 'district' => $awb->buyerdeliveryzone, 'status' => $awb->status, 'pickup_time' => $awb->pickuptime, 'delivery_time' => $awb->deliverytime, 'pod' => $pod, 'note' => $awb->delivery_note);
             }
         }
         //print_r($result);
         //die();
         $actor = $app->key . ' : ' . $app->merchant_id;
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'awb search with array'));
         return Response::json($result);
     } else {
         $actor = 'no id : no name';
         \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'account not found'));
         return \Response::json(array('status' => 'ERR:INVALIDACC', 'timestamp' => time(), 'message' => 'Invalid Account'));
     }
 }