コード例 #1
0
ファイル: IWMainOffice.php プロジェクト: AxelPanda/ibos
 private function getDocFile($var)
 {
     if ($var["isNew"]) {
         $typeId = AttachUtil::attachType($var["param"]["filetype"], "id");
         $map = array(self::DOC_WORD => array("fileName" => $var["lang"]["New doc"] . ".doc", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_EXCEL => array("fileName" => $var["lang"]["New excel"] . ".xls", "fileUrl" => self::OFFICE_PATH . "new.doc", "typeId" => self::DOC_WORD), self::DOC_PPT => array("fileName" => $var["lang"]["New ppt"] . ".ppt", "fileUrl" => self::OFFICE_PATH . "new.ppt", "typeId" => self::DOC_WORD));
         return $map[$typeId];
     } else {
         return array("typeId" => AttachUtil::attachType(StringUtil::getFileExt($var["attach"]["attachment"]), "id"), "fileName" => $var["attach"]["filename"], "fileUrl" => FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $var["attach"]["attachment"]));
     }
 }
コード例 #2
0
ファイル: CommonAttach.php プロジェクト: AxelPanda/ibos
 public function upload()
 {
     $uid = intval(EnvUtil::getRequest("uid"));
     $this->upload->save();
     $attach = $this->upload->getAttach();
     $attachment = $attach["type"] . "/" . $attach["attachment"];
     $data = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "attachment" => $attachment, "isimage" => $attach["isimage"], "uid" => $uid);
     $aid = Attachment::model()->add(array("uid" => $uid, "tableid" => 127), true);
     $data["aid"] = $aid;
     AttachmentUnused::model()->add($data);
     $file["icon"] = AttachUtil::attachType(StringUtil::getFileExt($attach["name"]));
     $file["aid"] = $aid;
     $file["name"] = $attach["name"];
     $file["url"] = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attachment);
     if (!empty($file) && is_array($file)) {
         return CJSON::encode($file);
     } else {
         return CJSON::encode(array("aid" => 0, "url" => 0, "name" => 0));
     }
 }
コード例 #3
0
ファイル: WebMailUtil.php プロジェクト: AxelPanda/ibos
 public static function getBody($id, &$conn, &$obj, $header)
 {
     $structure_str = $obj->fetchStructureString($conn, "INBOX", $id);
     $structure = EmailMimeUtil::getRawStructureArray($structure_str);
     $num_parts = EmailMimeUtil::getNumParts($structure);
     $parent_type = EmailMimeUtil::getPartTypeCode($structure);
     if ($parent_type == 1 && $num_parts == 1) {
         $part = 1;
         $num_parts = EmailMimeUtil::getNumParts($structure, $part);
         $parent_type = EmailMimeUtil::getPartTypeCode($structure, $part);
     } else {
         $part = null;
     }
     $body = array();
     $attach = "";
     if (0 < $num_parts) {
         $attach .= "<table width=100%>\n";
         for ($i = 1; $i <= $num_parts; $i++) {
             if ($parent_type == 1) {
                 $code = $part . (empty($part) ? "" : ".") . $i;
             } elseif ($parent_type == 2) {
                 $code = $part . (empty($part) ? "" : ".") . $i;
             }
             $type = EmailMimeUtil::getPartTypeCode($structure, $code);
             $name = EmailMimeUtil::getPartName($structure, $code);
             if (is_string($name) && !empty($name)) {
                 $name = htmlspecialchars(EmailLangUtil::langDecodeSubject($name, CHARSET));
                 $fileExt = StringUtil::getFileExt($name);
                 $fileType = AttachUtil::attachType($fileExt);
             } else {
                 $fileType = AttachUtil::attachType(1);
             }
             $typestring = EmailMimeUtil::getPartTypeString($structure, $code);
             list($dummy, $subtype) = explode("/", $typestring);
             $bytes = EmailMimeUtil::getPartSize($structure, $code);
             $disposition = EmailMimeUtil::getPartDisposition($structure, $code);
             if ($type == 1 || $type == 2 || $type == 3 && strcasecmp($subtype, "ms-tnef") == 0) {
                 continue;
             } else {
                 $href = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => "INBOX", "id" => $id, "part" => $code));
             }
             $attach .= "<tr><td align=\"center\"><img src=\"{$fileType}\" border=0></td>";
             $attach .= "<td><a href=\"" . $href . "\" " . ($type == 1 || $type == 2 || $type == 3 && strcasecmp($subtype, "ms-tnef") == 0 ? "" : "target=_blank") . ">";
             $attach .= "<span class=\"small\">" . $name . "</span></a>";
             if (0 < $bytes) {
                 $attach .= "<td>[" . ConvertUtil::sizeCount($bytes) . "]</td>\n";
             }
             if (is_string($typestring)) {
                 $attach .= "<td>" . htmlspecialchars($typestring) . "</td>\n";
             }
             $attach .= "\n</tr>\n";
         }
         $attach .= "</table>\n";
     }
     $typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
     list($dummy, $subType) = explode("/", EmailMimeUtil::getPartTypeString($structure, $part));
     if ($typeCode == 3 && strcasecmp($subType, "ms-tnef") == 0) {
         $type = $dummy;
     } elseif ($typeCode == 0) {
         $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
         if (empty($part) && !empty($header->ctype) && strcmp($typeString, $header->ctype) != 0) {
             $typeString = $header->ctype;
         }
         list($type, $subType) = explode("/", $typeString);
         $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
     } else {
         if ($typeCode == 1 && empty($part) && $structure[0][0] == "message") {
             $part = "1.1";
             $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
             list($type, $subType) = explode("/", $typeString);
             $typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
             $disposition = EmailMimeUtil::getPartDisposition($structure, $part);
             $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
         } else {
             if ($typeCode == 1 || $typeCode == 2) {
                 $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
                 list($type, $subType) = explode("/", $typeString);
                 $mode = 0;
                 $subtypes = array("mixed" => 1, "signed" => 1, "related" => 1, "array" => 2, "alternative" => 2);
                 $subType = strtolower($subType);
                 if (0 < $subtypes[$subType]) {
                     $mode = $subtypes[$subType];
                 } elseif (strcasecmp($subType, "rfc822") == 0) {
                     $temp_num = EmailMimeUtil::getNumParts($structure, $part);
                     if (0 < $temp_num) {
                         $mode = 2;
                     }
                 } elseif (strcasecmp($subType, "encrypted") == 0) {
                     $encrypted_type = EmailMimeUtil::getPartTypeString($structure, $part . ".1");
                     if (stristr($encrypted_type, "pgp-encrypted") !== false) {
                         $mode = -1;
                     }
                 }
                 if ($mode == -1) {
                     $part = $part . (empty($part) ? "" : ".") . "2";
                     $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
                     list($type, $subType) = explode("/", $typeString);
                     $typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
                     $disposition = EmailMimeUtil::getPartDisposition($structure, $part);
                     $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
                 } elseif (0 < $mode) {
                     $originalPart = $part;
                     for ($i = 1; $i <= $num_parts; $i++) {
                         $part = $originalPart . (empty($originalPart) ? "" : ".") . $i;
                         $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
                         list($type, $subType) = explode("/", $typeString);
                         $typeCode = EmailMimeUtil::getPartTypeCode($structure, $part);
                         $disposition = EmailMimeUtil::getPartDisposition($structure, $part);
                         if (strcasecmp($disposition, "attachment") != 0) {
                             if ($mode == 1 && $typeCode == 0) {
                                 $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
                             } elseif ($mode == 2) {
                                 $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
                             } else {
                                 if ($typeCode == 5 && strcasecmp($disposition, "inline") == 0) {
                                     $href = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => "INBOX", "id" => $id, "part" => $part));
                                     $body[] = "<img src='{$href}'>";
                                 } elseif ($typeCode == 1) {
                                     $part = EmailMimeUtil::getFirstTextPart($structure, $part);
                                     $next_part = EmailMimeUtil::getNextPart($part);
                                     $next_type = EmailMimeUtil::getPartTypeString($structure, $next_part);
                                     if (stristr($next_type, "html") !== false) {
                                         $part = $next_part;
                                     }
                                     $i++;
                                     $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
                                 }
                             }
                         } elseif ($typeCode == 5) {
                             $href = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => "INBOX", "id" => $id, "part" => $part));
                             $body[] = "<img src='{$href}'>";
                         }
                     }
                 } else {
                     if (strcasecmp($subType, "rfc822") != 0) {
                         $part = EmailMimeUtil::getFirstTextPart($structure, "");
                         $next_part = EmailMimeUtil::getNextPart($part);
                         $next_type = EmailMimeUtil::getPartTypeString($structure, $next_part);
                         if (stristr($next_type, "html") !== false) {
                             $typeString = "text/html";
                             $type = "text";
                             $subType = "html";
                             $part = $next_part;
                         }
                     }
                     $body[] = self::fetchBody($obj, $conn, "INBOX", $id, $structure, $part);
                 }
             } else {
                 $type = EmailMimeUtil::getPartTypeCode($structure, $part);
                 $partName = EmailMimeUtil::getPartName($structure, $part);
                 $typeString = EmailMimeUtil::getPartTypeString($structure, $part);
                 $bytes = EmailMimeUtil::getPartSize($structure, $part);
                 $disposition = EmailMimeUtil::getPartDisposition($structure, $part);
                 $name = EmailLangUtil::langDecodeSubject($partName, CHARSET);
                 $fileExt = StringUtil::getFileExt($name);
                 $fileType = AttachUtil::attachType($fileExt);
                 $size = ConvertUtil::sizeCount($bytes);
                 $href = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => "INBOX", "id" => $id, "part" => $part));
                 //$body[] = "\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align=\"center\">\r\n\t\t\t\t\t\t\t\t<a href=\"$href\" target=\"_blank\"><img src=\"$fileType\" border=0 /><br/>$name<br/>[$size]<br/></a>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table><br/>";
                 $body[] = '<table>
                     <tr>
                         <td align="center">
                             <a href="$href" target="_blank"><img src="' . $fileType . '" border=0 /><br/>' . $name . '<br/>[' . $size . ']<br/></a>
                         </td>
                     </tr>
                 </table><br/>';
             }
         }
     }
     $body[] = $attach;
     return $body;
 }
コード例 #4
0
ファイル: ICFlowFormViewer.php プロジェクト: AxelPanda/ibos
 protected function parseMarcroAttach($runID, $attachmentID, $showImg = true)
 {
     $attachDir = Ibos::app()->setting->get("setting/attachdir");
     $attach = AttachmentN::model()->fetch("rid:" . $runID, $attachmentID);
     if ($attach["isimage"] && $showImg) {
         $imgAttr = FileUtil::imageSize($attachDir . $attach["attachment"]);
         $attachLink = "<img src=\"{$attachDir}" . $attach["attachment"] . "\" {$imgAttr['3']} alt=\"{$attach["filename"]}\">";
         return $attachLink;
     }
     if ($this->flow->isFixed() && (StringUtil::findIn($this->process->attachpriv, "4") || !$this->process->attachpriv)) {
         $down = 1;
     } else {
         $down = 0;
     }
     if ($down) {
         $attachstr = AttachUtil::getAttachStr($attachmentID);
         $url = Ibos::app()->urlManager->createUrl("main/attach/download", array("id" => $attachstr));
         $link = "<a target=\"_blank\" class=\"xi2\" href=\"{$url}\">{$attach["filename"]}</a>";
     } else {
         $link = "<a class=\"xi2\" href=\"#\">{$attach["filename"]}</a>";
     }
     $type = StringUtil::getFileExt($attach["attach"]);
     $path = AttachUtil::attachType($type);
     $attachLink = "<span><img src=\"{$path}\">{$link}</span>";
     return $attachLink;
 }