Esempio n. 1
0
 public function actionAddEvent()
 {
     $data = $_POST;
     $model = new Event();
     $model->u_id = $data['uid'];
     $model->lat = $data['lat'];
     $model->lng = $data['lng'];
     $model->address = $data['address'];
     $model->message = $data['message'];
     $model->status = 0;
     if ($model->save()) {
         $e_id = $model->primaryKey;
         $model = new EventMedia();
         foreach (explode(",", $data['files'], -1) as $id) {
             $model->updateByPk($id, array("e_id" => $e_id));
         }
         $tids = explode(",", $data['tid']);
         foreach ($tids as $tid) {
             $model = new EventType();
             $model->event = $e_id;
             $model->node = $tid;
             $model->save();
         }
         echo 1;
     } else {
         echo 0;
     }
 }
Esempio n. 2
0
 public function actionUpload()
 {
     $tempFolder = Yii::getPathOfAlias('webroot') . Yii::app()->params['upload_path'];
     mkdir($tempFolder, 0777, TRUE);
     mkdir($tempFolder . 'chunks', 0777, TRUE);
     Yii::import("ext.EFineUploader.qqFileUploader");
     $uploader = new qqFileUploader();
     $uploader->allowedExtensions = Yii::app()->params['upload_ext'];
     $uploader->sizeLimit = $this->MAX_UPLOAD_SIZE;
     //maximum file size in bytes
     $uploader->chunksFolder = $tempFolder . 'chunks';
     $result = $uploader->handleUpload($tempFolder);
     $result['filename'] = $uploader->getUploadName();
     $savedfile = $result['filename'];
     $result['folder'] = $webFolder;
     $uploadedFile = $tempFolder . $result['filename'];
     $uploaded = 1;
     header("Content-Type: text/plain");
     //echo Yii::getPathOfAlias('webroot').Yii::app()->params['upload_path'];
     if ($uploaded) {
         $video = new EventMedia();
         $video->e_id = 0;
         $video->path = Yii::app()->params['upload_path'] . $savedfile;
         if (strstr(mime_content_type(Yii::getPathOfAlias('webroot') . $video->path), "video")) {
             $video->type = $this->LOCALVID;
             $video->name = "Local Video";
         } elseif (strstr(mime_content_type(Yii::getPathOfAlias('webroot') . $video->path), "image")) {
             $video->type = $this->IMAGE;
             $video->name = "Local Image";
             //resize image
             $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot') . $video->path);
             $image->quality(6);
             $fname = $video->path;
             if ($image->__get("width") > 3200) {
                 $pfile = dirname($fname) . "/big." . basename($fname);
                 $image->resize(3200);
                 $image->save(Yii::getPathOfAlias('webroot') . $pfile);
             } else {
                 $pfile = dirname($fname) . "/big." . basename($fname);
                 $image->save(Yii::getPathOfAlias('webroot') . $pfile);
             }
             $pfile = dirname($fname) . "/medium." . basename($fname);
             $image->resize(800);
             $image->save(Yii::getPathOfAlias('webroot') . $pfile);
             $pfile = dirname($fname) . "/small." . basename($fname);
             $image->resize(400);
             $image->save(Yii::getPathOfAlias('webroot') . $pfile);
         }
         if ($video->save()) {
             $result['id'] = $video->primaryKey;
             $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
             echo $result;
         }
     }
     Yii::app()->end();
 }