public function getMemoryMarkerUsage($format = true) { $usage = (int) memory_get_usage() - $this->memoryUsage; if ($format) { return ConvertUtil::sizeCount($usage); } return $usage; }
public static function getTableStatus($tableName, $formatSize = true) { $status = Ibos::app()->db->createCommand()->setText("SHOW TABLE STATUS LIKE '{{" . str_replace("_", "\\_", $tableName) . "}}'")->queryRow(); if ($formatSize) { $status["Data_length"] = ConvertUtil::sizeCount($status["Data_length"]); $status["Index_length"] = ConvertUtil::sizeCount($status["Index_length"]); } return $status; }
public function actionIndex() { $uid = $this->uid; $total = 0; $folders = $this->folders; foreach ($folders as &$folder) { $size = EmailFolder::model()->getFolderSize($uid, $folder["fid"]); $folder["size"] = ConvertUtil::sizeCount($size); $total += $size; } $inbox = EmailFolder::model()->getSysFolderSize($uid, "inbox"); $web = EmailFolder::model()->getSysFolderSize($uid, "web"); $sent = EmailFolder::model()->getSysFolderSize($uid, "send"); $deleted = EmailFolder::model()->getSysFolderSize($uid, "del"); $userSize = EmailUtil::getUserSize($uid); $data = array("folders" => $folders, "inbox" => ConvertUtil::sizeCount($inbox), "web" => ConvertUtil::sizeCount($web), "sent" => ConvertUtil::sizeCount($sent), "deleted" => ConvertUtil::sizeCount($deleted), "userSize" => $userSize, "total" => ConvertUtil::sizeCount(array_sum(array($total, $inbox, $web, $sent, $deleted)))); $this->setPageTitle(Ibos::lang("Folder setting")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Email center"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Folder setting")))); $this->render("index", $data); }
public function actionIndex() { $systemInfo = EnvUtil::getSystemInfo(); $databaseSize = DatabaseUtil::getDatabaseSize(); list($dataSize, $dataUnit) = explode(" ", $databaseSize); $appClosed = Setting::model()->fetchSettingValueByKey("appclosed"); $newVersion = Ibos::app()->setting->get("newversion"); $getSecurityUrl = Ibos::app()->urlManager->createUrl("dashboard/index/getsecurity"); $mainModule = Module::model()->fetchByPk("main"); $authkey = Ibos::app()->setting->get("config/security/authkey"); $unit = Setting::model()->fetchSettingValueByKey("unit"); $license = Setting::model()->fetchSettingValueByKey("license"); $licenseUrl = $this->getLicenseUrl(unserialize($unit), $authkey); if (isset($_GET["attachsize"])) { $attachSize = Attachment::model()->getTotalFilesize(); $attachSize = is_numeric($attachSize) ? ConvertUtil::sizeCount($attachSize) : Ibos::lang("Unknow"); } else { $attachSize = ""; } $data = array("sys" => $systemInfo, "dataSize" => $dataSize, "dataUnit" => $dataUnit, "appClosed" => $appClosed, "newVersion" => $newVersion, "getSecurityUrl" => $getSecurityUrl, "installDate" => $mainModule["installdate"], "authkey" => $authkey, "license" => unserialize($license), "licenseUrl" => $licenseUrl, "attachSize" => $attachSize); $this->render("index", $data); }
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; }
public static function getAttach($aid, $down = true, $officeDown = true, $edit = false, $delete = false, $getRealAddress = false) { $attach = array(); if (!empty($aid)) { $data = self::getAttachData($aid); } $urlManager = Ibos::app()->urlManager; foreach ($data as $id => &$val) { $val["date"] = ConvertUtil::formatDate($val["dateline"], "u"); $val["filetype"] = StringUtil::getFileExt($val["filename"]); $val["filesize"] = ConvertUtil::sizeCount($val["filesize"]); if ($getRealAddress) { $val["attachment"] = FileUtil::getAttachUrl() . "/" . $val["attachment"]; } $val["filename"] = trim($val["filename"]); $val["delete"] = $delete; $val["down"] = $down; $val["down_office"] = $officeDown; $val["edit"] = $edit; $val["iconsmall"] = self::attachType($val["filetype"], "smallicon"); $val["iconbig"] = self::attachType($val["filetype"], "bigicon"); $idString = self::getAttachStr($id, $val["tableid"]); $val["openurl"] = $urlManager->createUrl("main/attach/open", array("id" => $idString)); if ($val["down"]) { $val["downurl"] = $urlManager->createUrl("main/attach/download", array("id" => $idString)); } $inOfficeRange = in_array(self::attachType($val["filetype"], "id"), range(3, 5)); if ($inOfficeRange && $val["down_office"]) { $val["officereadurl"] = "http://view.officeapps.live.com/op/view.aspx?src=" . urlencode(Ibos::app()->setting->get("siteurl") . FileUtil::getAttachUrl() . "/" . $val["attachment"]); } if ($inOfficeRange && $val["edit"]) { $val["officeediturl"] = $urlManager->createUrl("main/attach/office", array("id" => self::getAttachStr($aid, $val["tableid"], array("filetype" => $val["filetype"], "op" => "edit")))); } } return $data; }
public function actionIndex() { $operation = EnvUtil::getRequest("op"); switch ($operation) { case "thumbpreview": case "waterpreview": $temp = Ibos::engine()->IO()->file()->getTempPath() . "/watermark_temp.jpg"; if (LOCAL) { if (is_file($temp)) { @unlink($temp); } } $quality = EnvUtil::getRequest("quality"); $source = PATH_ROOT . "/static/image/watermark_preview.jpg"; if ($operation == "waterpreview") { $trans = EnvUtil::getRequest("trans"); $type = EnvUtil::getRequest("type"); $val = EnvUtil::getRequest("val"); $pos = EnvUtil::getRequest("pos"); if ($type == "image") { $sInfo = ImageUtil::getImageInfo($source); $wInfo = ImageUtil::getImageInfo($val); if ($sInfo["width"] < $wInfo["width"] || $sInfo["height"] < $wInfo["height"]) { Ibos::import("ext.ThinkImage.ThinkImage", true); $imgObj = new ThinkImage(THINKIMAGE_GD); $imgObj->open($val)->thumb(260, 77, 1)->save($val); } ImageUtil::water($source, $val, $temp, $pos, $trans, $quality); } else { $hexColor = EnvUtil::getRequest("textcolor"); $size = EnvUtil::getRequest("size"); $fontPath = EnvUtil::getRequest("fontpath"); $rgb = ConvertUtil::hexColorToRGB($hexColor); ImageUtil::waterMarkString($val, $size, $source, $temp, $pos, $quality, $rgb, self::TTF_FONT_PATH . $fontPath); } $image = $temp; } if (!LOCAL) { if (Ibos::engine()->IO()->file()->createFile($temp, file_get_contents($image))) { $image = FileUtil::fileName($temp); } } $data = array("image" => $image, "sourceSize" => ConvertUtil::sizeCount(FileUtil::fileSize($source)), "thumbSize" => ConvertUtil::sizeCount(FileUtil::fileSize($image)), "ratio" => sprintf("%2.1f", FileUtil::fileSize($image) / FileUtil::fileSize($source) * 100) . "%"); $this->render("imagePreview", $data); exit; break; case "upload": return $this->imgUpload("watermark", true); break; } $formSubmit = EnvUtil::submitCheck("uploadSubmit"); $uploadKeys = "attachdir,attachurl,thumbquality,attachsize,filetype"; $waterMarkkeys = "watermarkminwidth,watermarkminheight,watermarktype,watermarkposition,watermarktrans,watermarkquality,watermarkimg,watermarkstatus,watermarktext,watermarkfontpath"; if ($formSubmit) { $keys = $uploadKeys . "," . $waterMarkkeys; $keyField = explode(",", $keys); foreach ($_POST as $key => $value) { if (in_array($key, $keyField)) { Setting::model()->updateSettingValueByKey($key, $value); } elseif ($key == "watermarkstatus") { Setting::model()->updateSettingValueByKey("watermarkstatus", 0); } } CacheUtil::update(array("setting")); $this->success(Ibos::lang("Save succeed", "message")); } else { $upload = Setting::model()->fetchSettingValueByKeys($uploadKeys); $waterMark = Setting::model()->fetchSettingValueByKeys($waterMarkkeys); $fontPath = DashboardUtil::getFontPathlist(self::TTF_FONT_PATH); $data = array("upload" => $upload, "waterMark" => $waterMark, "fontPath" => $fontPath); $this->render("index", $data); } }
echo ConvertUtil::sizeCount($value['Data_length'] + $value['Index_length']); ?> </td> </tr> <?php } ?> </tbody> <tfoot> <tr> <td colspan="8"> <?php if ($totalSize > 0) { ?> <?php echo $lang['Size'] . ':' . ConvertUtil::sizeCount($totalSize); ?> <?php } else { ?> <?php echo $lang['No need to optimize']; ?> <?php } ?> </td> </tr> </tfoot> </table> </div>
<a href="<?php echo $value['filename']; ?> "><?php echo substr(strrchr($value['filename'], "/"), 1); ?> </a> </td> <td></td> <td><?php echo is_int($value['dateline']) ? date('Y-m-d H:i', $value['dateline']) : $lang['Unknown']; ?> </td> <td>ZIP</td> <td><?php echo ConvertUtil::sizeCount($value['size']); ?> </td> <td><?php echo $value['type']; ?> </td> <td></td> <td> <a href="javascript:void(0);" data-act="decompress" data-id="<?php echo $value['filename']; ?> " class="btn btn-small"><?php echo $lang['Decompress']; ?> </a>