Exemplo n.º 1
0
 public function __construct($fileArea = "Filedata", $module = "temp")
 {
     $file = $_FILES[$fileArea];
     if ($file["error"]) {
         throw new FileException(Ibos::lang("File is too big", "error"));
     } else {
         $upload = FileUtil::getUpload($file, $module);
         $this->upload = $upload;
     }
 }
Exemplo n.º 2
0
 public function actionUploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $file, "IsSuccess" => true));
     }
 }
Exemplo n.º 3
0
 protected function imgUpload($fileArea, $inajax = false)
 {
     $_FILES[$fileArea]["name"] = StringUtil::iaddSlashes(urldecode($_FILES[$fileArea]["name"]));
     $file = $_FILES[$fileArea];
     $upload = FileUtil::getUpload($file, "dashboard");
     if ($upload->save()) {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         if (!$inajax) {
             return $file;
         } else {
             $this->ajaxReturn(array("url" => $file));
         }
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 public function actionUpload()
 {
     if ($_FILES["avatar"]) {
         $upload = FileUtil::getUpload($_FILES["avatar"]);
         if (!$upload->save()) {
             echo "出错了";
         } else {
             $info = $upload->getAttach();
             $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
             $fileUrl = FileUtil::fileName($file);
             $uid = Yii::app()->user->uid;
             $tempAvatar = $file;
             $avatarPath = "data/avatar/";
             $avatarBig = UserUtil::getAvatar($uid, "big");
             $avatarMiddle = UserUtil::getAvatar($uid, "middle");
             $avatarSmall = UserUtil::getAvatar($uid, "small");
             if (LOCAL) {
                 FileUtil::makeDirs($avatarPath . dirname($avatarBig));
             }
             FileUtil::createFile("data/avatar/" . $avatarBig, "");
             FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
             FileUtil::createFile("data/avatar/" . $avatarSmall, "");
             Yii::import("ext.ThinkImage.ThinkImage", true);
             $imgObj = new ThinkImage(THINKIMAGE_GD);
             $imgTemp = $imgObj->open($tempAvatar);
             $params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
             if ($params["h"] < $params["w"]) {
                 $params["x"] = ($params["w"] - $params["h"]) / 2;
                 $params["w"] = $params["h"];
             } else {
                 $params["y"] = ($params["h"] - $params["w"]) / 2;
                 $params["h"] = $params["w"];
             }
             $imgObj->open($tempAvatar)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($tempAvatar);
             $imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
             $imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
             $imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
         }
     }
 }
Exemplo n.º 5
0
 public function actionPostimg()
 {
     $upload = FileUtil::getUpload($_FILES["pmimage"], "mobile");
     if (!$upload->save()) {
         echo "出错了";
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $filePath = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachdir"];
         $filename = "tumb_" . $info["attachname"];
         if (LOCAL) {
             FileUtil::makeDirs($filePath . dirname($filename));
         }
         FileUtil::createFile($filePath . $filename, "");
         Yii::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgObj->open($fileUrl)->thumb(180, 180, 1)->save($filePath . $filename);
         $content = "<a href='" . $fileUrl . "'><img src='" . $filePath . $filename . "' /></a>";
         $id = intval(isset($_POST["pmid"]) ? $_POST["pmid"] : 0);
         $touid = intval(isset($_POST["pmtouid"]) ? $_POST["touid"] : 0);
         if (!$id && $touid) {
             $data = array("content" => $content, "touid" => $touid, "type" => 1);
             $res = MessageContent::model()->postMessage($data, Yii::app()->user->uid);
             $message = array("listid" => $res, "IsSuccess" => true);
         } else {
             $res = MessageContent::model()->replyMessage($id, $content, Yii::app()->user->uid);
             if ($res) {
                 $message = array("IsSuccess" => true, "data" => Ibos::lang("Private message send success"));
             } else {
                 $message = array("IsSuccess" => false, "data" => Ibos::lang("Private message send fail"));
             }
         }
         $this->ajaxReturn($message, "JSONP");
     }
 }
Exemplo n.º 6
0
 protected function handleImgComponent(&$formData)
 {
     foreach ($GLOBALS["_FILES"] as $key => $value) {
         if (strtolower(substr($key, 0, 5)) == "data_") {
             $formData["{$key}"] = "";
             $old = $_POST["imgid_" . substr($key, 5)];
             if ($value["name"] != "") {
                 if (!empty($old)) {
                     AttachUtil::delAttach($old);
                 }
                 $upload = FileUtil::getUpload($_FILES[$key], "workflow");
                 $upload->save();
                 $attach = $upload->getAttach();
                 $attachment = "workflow/" . $attach["attachment"];
                 $imgData = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "isimage" => $attach["isimage"], "attachment" => $attachment, "uid" => $this->uid);
                 $aid = Attachment::model()->add(array("uid" => $this->uid, "rid" => $this->runid, "tableid" => AttachUtil::getTableId($this->runid)), true);
                 $imgData["aid"] = $aid;
                 $newAttach = AttachmentN::model()->add(sprintf("rid:%d", $this->runid), $imgData, true);
                 $formData["{$key}"] = $newAttach;
             } else {
                 $formData["{$key}"] = $old;
             }
         }
     }
 }
Exemplo n.º 7
0
 public function actionImport()
 {
     if ($this->flowid) {
         if (EnvUtil::submitCheck("typeSubmit")) {
             $userOn = !isset($_POST["useron"]) ? false : true;
             $fileName = $_FILES["import"]["name"];
             if (!stristr($fileName, ".xml")) {
                 $this->ajaxReturn("<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Import xml files only") . "');</script>", "eval");
             } else {
                 $upload = FileUtil::getUpload($_FILES["import"]);
                 $upload->save();
                 $files = $upload->getAttach();
                 $file = $files["target"];
                 WfTypeUtil::import($this->flowid, $file, $userOn);
                 $this->ajaxReturn("<script type='text/javascript'>parent.Ui.tip('" . Ibos::lang("Import success") . "', 'success');parent.Ui.getDialog('import_frame').close();</script>", "eval");
             }
         }
         $lang = Ibos::getLangSources();
         $this->renderPartial("import", array("lang" => $lang, "flowId" => $this->flowid));
     } else {
         $this->ajaxReturn("<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Parameters error", "error") . "');parent.Ui.getDialog('import_frame').close();</script>", "eval");
     }
 }
Exemplo n.º 8
0
 public function actionImport()
 {
     $id = EnvUtil::getRequest("formid");
     $catId = EnvUtil::getRequest("catid");
     if (EnvUtil::submitCheck("formhash")) {
         $fileName = $_FILES["import"]["name"];
         $fileExt = StringUtil::getFileExt($fileName);
         if (!in_array($fileExt, array("txt", "htm", "html"))) {
             echo "<script type='text/javascript'>parent.Ui.alert('" . Ibos::lang("Form import desc") . "');</script>";
         } else {
             $upload = FileUtil::getUpload($_FILES["import"]);
             $upload->save();
             $files = $upload->getAttach();
             $file = $files["target"];
             $inajax = 0;
             if (empty($id)) {
                 $name = strstr($files["name"], ".", true);
                 $inajax = 1;
                 $id = FlowFormType::model()->quickAdd($name, $catId);
             }
             WfFormUtil::import($id, $file);
             $nextOpt = $_POST["nextopt"];
             $exec = "";
             if ($nextOpt == "edit") {
                 $param = sprintf("{'formid':'%d','inajax':%d}", $id, $inajax);
                 $exec = "parent.Wfs.formItem.edit({$param});";
             } elseif ($nextOpt == "design") {
                 $param = sprintf("{'formid':'%d'}", $id);
                 $exec = "parent.Wfs.formItem.design({$param});";
             }
             $this->ajaxReturn("<script type='text/javascript'>parent.Ui.tip('" . Ibos::lang("Import success") . "', 'success');{$exec}parent.Ui.getDialog('d_import_form').close();</script>", "eval");
         }
     }
     $lang = Ibos::getLangSources();
     $this->renderPartial("import", array("lang" => $lang, "id" => $id, "catid" => $catId));
 }
Exemplo n.º 9
0
 public function actionUploadIcon()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "isSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 64 || $tempSize[1] < 64) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Icon size error"), "isSuccess" => false));
         }
         $this->ajaxReturn(array("imgurl" => $fileUrl, "aid" => $fileUrl, "name" => $info["name"], "isSuccess" => true));
     }
 }
Exemplo n.º 10
0
 private function uploadAvatar()
 {
     $upload = FileUtil::getUpload($_FILES["Filedata"]);
     if (!$upload->save()) {
         $this->ajaxReturn(array("msg" => Ibos::lang("Save failed", "message"), "IsSuccess" => false));
     } else {
         $info = $upload->getAttach();
         $file = FileUtil::getAttachUrl() . "/" . $info["type"] . "/" . $info["attachment"];
         $fileUrl = FileUtil::fileName($file);
         $tempSize = FileUtil::imageSize($fileUrl);
         if ($tempSize[0] < 180 || $tempSize[1] < 180) {
             $this->ajaxReturn(array("msg" => Ibos::lang("Avatar size error"), "IsSuccess" => false), "json");
         }
         Ibos::import("ext.ThinkImage.ThinkImage", true);
         $imgObj = new ThinkImage(THINKIMAGE_GD);
         $imgTemp = $imgObj->open($fileUrl);
         $params = array("w" => $imgTemp->width(), "h" => $imgTemp->height(), "x" => "0", "y" => "0");
         if ($params["h"] < $params["w"]) {
             $params["x"] = ($params["w"] - $params["h"]) / 2;
             $params["w"] = $params["h"];
         } else {
             $params["y"] = ($params["h"] - $params["w"]) / 2;
             $params["h"] = $params["w"];
         }
         $imgObj->open($fileUrl)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($fileUrl);
         $this->ajaxReturn(array("data" => $fileUrl, "file" => $fileUrl, "IsSuccess" => true));
     }
 }