예제 #1
0
 private static function fetchBody($obj, $conn, $folder, $id, $structure, $part)
 {
     $body = $obj->fetchPartBody($conn, $folder, $id, $part);
     $encoding = EmailMimeUtil::getPartEncodingCode($structure, $part);
     if ($encoding == 3) {
         $body = base64_decode($body);
     } elseif ($encoding == 4) {
         $body = quoted_printable_decode($body);
     }
     $charset = EmailMimeUtil::getPartCharset($structure, $part);
     if (empty($charset)) {
         $part_header = $obj->fetchPartHeader($conn, $folder, $id, $part);
         $pattern = "/charset=[\"]?([a-zA-Z0-9_-]+)[\"]?/";
         preg_match($pattern, $part_header, $matches);
         if (count($matches) == 2) {
             $charset = $matches[1];
         }
     }
     if (strcasecmp($charset, "utf-8") == 0) {
         $is_unicode = true;
     } elseif (preg_match("/#[0-9]{5};/", $body)) {
         $is_unicode = false;
     } else {
         $is_unicode = false;
     }
     if (!$is_unicode) {
         $body = ConvertUtil::iIconv($body, "gb2312");
     }
     $url = Yii::app()->urlManager->createUrl("email/web/show", array("webid" => self::$_web["webid"], "folder" => $folder, "id" => $id, "cid" => ""));
     $body = preg_replace("/src=(\")?cid:/i", "src=\"{$url}", $body);
     return $body;
 }
예제 #2
0
 public static function exportSms($id)
 {
     $ids = is_array($id) ? $id : explode(",", $id);
     header("Content-Type:application/vnd.ms-excel");
     $fileName = ConvertUtil::iIconv(Ibos::lang("SMS export name", "dashboard.default", array("{date}" => date("Ymd"))), CHARSET, "gbk");
     header("Content-Disposition: attachment;filename={$fileName}.csv");
     header("Cache-Control: max-age = 0");
     $head = array("ID", Ibos::lang("Sender", "dashboard.default"), Ibos::lang("Recipient", "dashboard.default"), Ibos::lang("Membership module", "dashboard.default"), Ibos::lang("Recipient phone number", "dashboard.default"), Ibos::lang("Content", "dashboard.default"), Ibos::lang("Result", "dashboard.default"), Ibos::lang("Send time", "dashboard.default"));
     foreach ($head as &$header) {
         $header = ConvertUtil::iIconv($header, CHARSET, "gbk");
     }
     $fp = fopen("php://output", "a");
     fputcsv($fp, $head);
     $cnt = 0;
     $limit = 100;
     $system = Ibos::lang("System", "dashboard.default");
     foreach (NotifySms::model()->fetchAll(sprintf("FIND_IN_SET(id,'%s')", implode(",", $ids))) as $row) {
         if ($limit == $cnt) {
             ob_flush();
             flush();
             $cnt = 0;
         }
         $data = array($row["id"], ConvertUtil::iIconv($row["uid"] == 0 ? $system : User::model()->fetchRealnameByUid($row["uid"]), CHARSET, "gbk"), ConvertUtil::iIconv(User::model()->fetchRealnameByUid($row["touid"]), CHARSET, "gbk"), $row["module"], $row["mobile"], ConvertUtil::iIconv($row["content"], CHARSET, "gbk"), ConvertUtil::iIconv($row["return"], CHARSET, "gbk"), date("Y-m-d H:i:s", $row["ctime"]));
         fputcsv($fp, $data);
     }
     exit;
 }
예제 #3
0
 public static function export($idstr)
 {
     $idArr = is_array($idstr) ? $idstr : explode(",", $idstr);
     if (1 < count($idArr)) {
         $zip = new Zip();
         $exportFileName = Ibos::lang("Form export file pack", "workflow.default", array("{date}" => date("Y-m-d")));
         $zipFileName = FileUtil::getTempPath() . "/" . TIMESTAMP . ".zip";
         foreach ($idArr as $id) {
             $form = self::handleExportSingleForm($id);
             $zip->addFile($form["content"], sprintf("%s.html", ConvertUtil::iIconv($form["title"], CHARSET, "gbk")));
         }
         $fp = fopen($zipFileName, "w");
         if (@fwrite($fp, $zip->file()) !== false) {
             header("Cache-control: private");
             header("Content-type: application/octet-stream");
             header("Accept-Ranges: bytes");
             header("Content-Length: " . sprintf("%u", FileUtil::fileSize($zipFileName)));
             header("Content-Disposition: attachment; filename=" . $exportFileName . ".zip");
             readfile($zipFileName);
             exit;
         }
     } else {
         $id = implode(",", $idArr);
         $form = self::handleExportSingleForm($id);
         ob_end_clean();
         header("Cache-control: private");
         header("Content-type: text/plain");
         header("Accept-Ranges: bytes");
         header("Accept-Length: " . strlen($form["content"]));
         header("Content-Disposition: attachment; filename=" . $form["title"] . ".html");
         echo $form["content"];
     }
 }
예제 #4
0
 public function handleCreditRule($event)
 {
     $rules = array();
     $records = CreditRule::model()->fetchAll();
     if (!empty($records)) {
         foreach ($records as $rule) {
             $rule["rulenameuni"] = urlencode(ConvertUtil::iIconv($rule["rulename"], CHARSET, "UTF-8", true));
             $rules[$rule["action"]] = $rule;
         }
     }
     Syscache::model()->modify("creditrule", $rules);
 }
예제 #5
0
 public static function langDecodeMimeString($str)
 {
     $a = explode("?", $str);
     $count = count($a);
     if (3 <= $count) {
         $rest = "";
         for ($i = 2; $i < $count; $i++) {
             $rest .= $a[$i];
         }
         if ($a[1] == "B" || $a[1] == "b") {
             $rest = base64_decode($rest);
             $rest = ConvertUtil::iIconv($rest, $a[0]);
             return $rest;
         } else {
             if ($a[1] == "Q" || $a[1] == "q") {
                 $rest = str_replace("_", " ", $rest);
                 return quoted_printable_decode($rest);
             }
         }
     } else {
         return $str;
     }
 }
예제 #6
0
 private function refactor(&$items, $config, &$max, &$elements)
 {
     foreach ($items as $item) {
         if ($item->hasAttribute("data-type")) {
             $icType = strtolower($item->getAttribute("data-type"));
             if (isset($config[$icType])) {
                 $tag = $item->children(0);
                 if ($tag) {
                     $tagName = $tag->nodeName();
                     $id = intval($item->getAttribute("data-id"));
                     if (!$id) {
                         $itemId = $max + 1;
                         $eName = "data_" . $itemId;
                         $item->setAttribute("data-id", $itemId);
                         foreach ($item->children() as $child) {
                             if (strcasecmp($child->nodeName(), "img") !== 0) {
                                 $child->setAttribute("name", $eName);
                             }
                         }
                     } else {
                         $eName = "data_" . $id;
                         $itemId = $id;
                     }
                     $elements[$eName]["itemid"] = $itemId;
                     $elements[$eName]["tag"] = $tagName;
                     $elementAttrs = $item->getAllAttributes();
                     $content = $item->outertext();
                     foreach ($elementAttrs as $name => $val) {
                         $pattern = "/" . $name . "\\s?=\\s?(\\\"|\\')?" . preg_quote($val, "/") . "(\\\"|\\')?/i";
                         $replacement = $name . "=\"" . $val . "\"";
                         $string = ConvertUtil::iIconv($content, CHARSET, "UTF-8");
                         $content = ConvertUtil::iIconv(preg_replace($pattern, $replacement, $string), "UTF-8", CHARSET);
                         $attrName = strtolower($name);
                         if (in_array($attrName, $this->getSafeItemAttributes())) {
                             $elements[$eName][$attrName] = $val;
                         }
                     }
                     $elements[$eName]["content"] = $item->innertext();
                     $max = $max < $itemId ? $itemId : $max;
                     $item->outertext = "{" . $eName . "}";
                 }
             }
         }
     }
 }
예제 #7
0
파일: ICIMRtx.php 프로젝트: AxelPanda/ibos
 private function makeOrgstructXml()
 {
     $deptArr = DepartmentUtil::loadDepartment();
     $unit = Ibos::app()->setting->get("setting/unit");
     $str = "<?xml version=\"1.0\" encoding=\"gb2312\" ?>";
     $str .= "<enterprise name=\"" . $unit["fullname"] . "\" postcode=\"" . $unit["zipcode"] . "\" address=\"" . $unit["address"] . "\" phone=\"" . $unit["phone"] . "\" email=\"" . $unit["adminemail"] . "\">";
     $str .= "<departments>";
     $str .= $this->getDeptree($deptArr);
     $str .= "</departments>";
     $str .= "</enterprise>";
     $file = "userdata.xml";
     $fp = @fopen($file, "wb");
     if ($fp) {
         $str = ConvertUtil::iIconv($str, CHARSET, "gbk");
         file_put_contents($file, $str);
         if (0 < filesize($file)) {
             return true;
         }
     }
     return false;
 }
예제 #8
0
 public static function exportExcel($id)
 {
     $data = Email::model()->fetchById($id);
     if ($data) {
         $users = UserUtil::loadUser();
         header("Cache-control: private");
         header("Content-type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename=" . ConvertUtil::iIconv($data["subject"], CHARSET, "GBK") . "(" . date("Y-m-d") . ").xls");
         //$html = "            <html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n\t\txmlns:x=\"urn:schemas-microsoft-com:office:excel\"\r\n\t\txmlns=\"http://www.w3.org/TR/REC-html40\">\r\n\t\t<head>\r\n\t\t<title></title>\r\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t</head>\r\n\t\t<body topmargin=\"5\">\r\n\t\t <table border=\"1\" cellspacing=\"1\" width=\"95%\" class=\"small\" cellpadding=\"3\">\r\n\t\t\t<tr style=\"BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;\">\r\n\t\t\t  <td align=\"center\">收件人:</td>\r\n\t\t\t  <td align=\"center\">发件人:</td>\r\n\t\t\t  <td align=\"center\">抄送:</td>\r\n\t\t\t  <td align=\"center\">重要性:</td>\r\n\t\t\t  <td align=\"center\">标题:</td>\r\n\t\t\t  <td align=\"center\">发送时间:</td>\r\n\t\t\t  <td align=\"center\">内容:</td>\r\n\t\t\t  <td align=\"center\">附件名称:</td>\r\n\t\t\t</tr>      ";
         $html = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
     xmlns:x="urn:schemas-microsoft-com:office:excel"
     xmlns="http://www.w3.org/TR/REC-html40">
     <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     </head>
     <body topmargin="5">
      <table border="1" cellspacing="1" width="95%" class="small" cellpadding="3">
         <tr style="BACKGROUND: #D3E5FA; color: #000000; font-weight: bold;">
           <td align="center">收件人:</td>
           <td align="center">发件人:</td>
           <td align="center">抄送:</td>
           <td align="center">重要性:</td>
           <td align="center">标题:</td>
           <td align="center">发送时间:</td>
           <td align="center">内容:</td>
           <td align="center">附件名称:</td>
         </tr>';
         $data["toname"] = self::joinStringByArray($data["toids"], $users, "realname", ";");
         $data["content"] = str_replace("  ", "&nbsp;&nbsp;", $data["content"]);
         $data["content"] = str_replace("\n", "<br>", $data["content"]);
         $data["fromname"] = isset($users[$data["fromid"]]) ? $users[$data["fromid"]]["realname"] : "";
         $data["copytoname"] = self::joinStringByArray($data["copytoids"], $users, "realname", ";");
         $important_desc = "";
         if ($data["important"] == "0") {
             $important_desc = "";
         } elseif ($data["important"] == "1") {
             $important_desc = "<font color=\"#ff6600\">一般邮件</font>";
         } elseif ($data["important"] == "2") {
             $important_desc = "<font color=\"#FF0000\">重要邮件</font>";
         }
         $attachmentname = "";
         if ($data["attachmentid"] !== "") {
             $tempdata = AttachUtil::getAttach($data["attachmentid"]);
             foreach ($tempdata as $value) {
                 $attachmentname .= $value["filename"] . "; ";
             }
         }
         $data["sendtime"] = ConvertUtil::formatDate($data["sendtime"]);
         //$html .= "\r\n                <tr>\r\n                    <td nowrap align=\"center\">" . $data["toname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $data["fromname"] . "</td>\r\n                    <td>" . $data["copytoname"] . "</td>\r\n                    <td nowrap align=\"center\">" . $important_desc . "</td>\r\n                    <td nowrap>" . $data["subject"] . "</td>\r\n                    <td nowrap align=\"center\" x:str=\"" . $data["sendtime"] . "\">" . $data["sendtime"] . "</td>\r\n                    <td>" . $data["content"] . "</td>\r\n                    <td>" . $attachmentname . "</td>\r\n                </tr>\r\n            </table>";
         $html .= '<tr>
                     <td nowrap align="center">' . $data["toname"] . '</td>
                     <td nowrap align="center">' . $data["fromname"] . '</td>
                     <td>' . $data["copytoname"] . '</td>
                     <td nowrap align="center">' . $important_desc . '</td>
                     <td nowrap>' . $data["subject"] . '</td>
                     <td nowrap align="center" x:str="' . $data["sendtime"] . '">' . $data["sendtime"] . '</td>
                     <td>' . $data["content"] . '</td>
                     <td>' . $attachmentname . '</td>
                 </tr></table>';
         echo $html;
     }
 }