function getFiles(){ $dirname = 'uploads/'; $dir = 'uploads/*'; $files = array(); $finfo = finfo_open(FILEINFO_MIME_TYPE); foreach (glob($dir) as $file){ $t = date("M j, Y g:i a", filemtime($file)); $m = finfo_file($finfo, $file); $m = getMime($m); $s = filesize($file); $n = basename($file); $href = "$dirname$n"; echo $s; $files[] = array("href"=>$href,"name"=>$n, "size"=>$s, "mime"=>$m, "time"=>$t); } return $files; }
function getFiles(){ $dirname = 'uploads/'; $dir = 'uploads/*'; $files = array(); $finfo = finfo_open(FILEINFO_MIME_TYPE); foreach (glob($dir) as $file){ $n = basename($file); // chmod( $dirname . $n, 0777); $t = date("M j, Y g:i a", filemtime($file)); $m = finfo_file($finfo, $file); $m = getMime($m); $s = filesize($file); $href = "$dirname$n"; $thisFile = new FileU($n, $s, $m, $t, $href); $files[] = clone $thisFile; } return $files; }
/** * Pass only images to the uploaded file list. * Caution, action performs at the calling time. * * @param null * @return UploadedFiles object * @see onlyCompressed */ function onlyImages() { foreach ($this->http_files as $k => $v) { $mime = isset($this->cached_mimes[$k]) ? $this->cached_mimes[$k] : ($this->cached_mimes[$k] = getMime($v['tmp_name'])); if (($pos = strpos($mime, "image")) === false || $pos != 0) { $this->http_error_files[$k][] = array('image', $v['name']); } } return $this; }
function cropImage($imgPath, $coordX, $coordY, $coordW, $coordH, $text = NULL) { $data = getMime($imgPath); $src_img = $data[0]; $mime = $data[1]; $img_width_new = 700; $img_height_new = 350; $new_image = ImageCreateTrueColor($img_width_new, $img_height_new); imagecopyresampled($new_image, $src_img, 0, 0, $coordX, $coordY, $coordW, $coordH, $img_width_new, $img_height_new); // New save location // code to write text to image $black = imagecolorallocate($new_image, 0, 0, 0); $white = imagecolorallocate($new_image, 255, 255, 255); $font = 'arial.ttf'; $bbox = imagettfbbox(16, 0, $font, $text); $x = $bbox[2] + 20; imagefilledrectangle($new_image, 5, 5, $x, 40, $black); // Add some shadow to the text imagettftext($new_image, 16, 0, 11, 31, $black, $font, $text); // Add the text imagettftext($new_image, 16, 0, 10, 30, $white, $font, $text); $new_file_path = $_SESSION['rootDir'] . '/images/slideShow/' . basename($imgPath); return create_image($new_image, $new_file_path, $mime, basename($imgPath), 'slide'); }
function stream() { $_REQUEST->setType('action', 'string'); $mime = getMime($this->path); while (ob_get_level() > 0) { ob_end_clean(); } //ob_start('contentSize'); //ob_start('ob_gzhandler'); $last_modified_time = filemtime($this->path); $etag = md5_file($this->path); $length = $filesize = filesize($this->path); $offset = 0; if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { header('HTTP/1.1 304 Not Modified'); exit; } if (isset($_SERVER['HTTP_RANGE'])) { // if the HTTP_RANGE header is set we're dealing with partial content // Only supports a single range right now. // http://stackoverflow.com/questions/157318/resumable-downloads-when-using-php-to-send-the-file preg_match('/bytes=(\\d+)-(\\d+)?/', $_SERVER['HTTP_RANGE'], $range); $offset = min(intval($range[1]), $filesize - 1); // offset starts at 0, hence filesize-1 if (@intval($range[2]) > 0) { $length = min(intval($range[2]), $filesize); } $length -= $offset; header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $filesize); } header('Etag: "' . $etag . '"'); header('Content-Length: ' . $length); header('Content-Disposition: ' . ($_REQUEST['action'] === 'download' ? 'attachment; ' : '') . 'filename="' . pathinfo($this->path, PATHINFO_BASENAME) . '"'); header('Content-Transfer-Encoding: binary'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $last_modified_time) . ' GMT'); header('Content-Type: ' . $mime); if ($_REQUEST['action'] == 'download') { header('Content-Type: application/force-download', false); header('Content-Type: application/download', false); header('Content-Description: File Transfer'); } header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2 * 24 * 3600) . ' GMT'); header('Cache-Control: private, max-age=172801, must-revalidate'); #header('Cache-Control: no-cache'); header('Pragma: cache'); $fp = fopen($this->path, 'rb'); if ($fp === false) { die; } // error!! FIXME fseek($fp, $offset); print fread($fp, $length); fclose($fp); exit; }
<div class="row"> <?php if (!isset($_GET["file"])) { echo "Please choose a file you want to view!"; } else { ?> <section class="panel"> <header class="panel-heading"> <?php echo $_GET["file"]; ?> </header> <div class="panel-body"><video src="<?php echo data_uri("files/" . $_GET["file"], getMime($_GET["file"])); ?> " class="img-responsive" /> </div></section> <?php } ?> </div><!--/.row--> <div class="widget-foot"> <!-- Footer goes here --> </div>
function printMime($what, $listline) { // -------------- // Prints the Mime icon // -------------- $mime = getMime($listline); if ($what == "icon") { echo $mime["mime_icon"]; } elseif ($what == "type") { echo $mime["mime_type"]; } }
<?php function getMime($ext) { $types = ['woff' => 'application/x-font-woff', 'woff2' => 'application/x-font-woff2', 'eot' => 'application/vnd.ms-fontobject', 'svg' => 'image/svg+xml', 'ttf' => 'application/x-font-ttf']; if (isset($types[$ext])) { return $types[$ext]; } } if (PHP_SAPI == 'cli-server') { $file = __DIR__ . $_SERVER['REQUEST_URI']; $path = pathinfo($_SERVER['SCRIPT_FILENAME']); $mime = getMime($path['extension']); if ($mime) { header('Content-type: ' . $mime); readfile($_SERVER['SCRIPT_FILENAME']); } elseif (is_file($file)) { return false; } } require __DIR__ . '/../vendor/autoload.php'; // Instantiate the app $settings = (require __DIR__ . '/../src/settings.php'); $app = new \Slim\App($settings); // Set up dependencies require __DIR__ . '/../src/dependencies.php'; // Register middleware require __DIR__ . '/../src/middleware.php'; // Register routes require __DIR__ . '/../src/routes.php'; // Run app
function createThumbnail($imgPath) { $data = getMime($imgPath); $src_img = $data[0]; $mime = $data[1]; $img_width = imageSX($src_img); $img_height = imageSY($src_img); $new_size = ($img_width + $img_height) / ($img_width * ($img_height / 200)); $img_width_new = $img_width * $new_size; $img_height_new = $img_height * $new_size; $new_image = ImageCreateTrueColor($img_width_new, $img_height_new); $background = imagecolorallocate($new_image, 0, 0, 0); imagecolortransparent($new_image, $background); imagealphablending($new_image, false); imagesavealpha($new_image, true); imagecopyresampled($new_image, $src_img, 0, 0, 0, 0, $img_width_new, $img_height_new, $img_width, $img_height); // New save location $new_file_path = $_SESSION['rootDir'] . '/images/thumb/' . basename($imgPath); return create_image($new_image, $new_file_path, $mime, basename($imgPath)); }
function sortContent() { extract(getExtJSParams()); $rootFolder = "/"; $oPMFolder = new AppFolder(); global $RBAC; $user = ($RBAC->userCanAccess('PM_ALLCASES') == 1)? '' : $_SESSION['USER_LOGGED']; $totalItems = 0; $totalFolders = 0; $totalDocuments = 0; if (!(isset($_POST['sendWhat']))) { $_POST['sendWhat'] = "both"; } if (isset($_POST['renderTree'])) { $limit = 1000000; } $direction = "DESC"; if (isset($_POST['dir'])) { $direction = $_POST['dir']; } if (($_POST['sendWhat'] == "dirs") || ($_POST['sendWhat'] == "both")) { $folderListObj = $oPMFolder->getFolderList( ($_POST["node"] != "root")? (($_POST["node"] == "NA")? "" : $_POST["node"]) : $rootFolder, $limit, $start, $direction, (isset($_POST["sort"]))? $_POST["sort"]:"appDocCreateDate", $search ); $folderList=$folderListObj['folders']; $totalFolders=$folderListObj['totalFoldersCount']; $totalItems+=count($folderList); } if (($_POST['sendWhat'] == "files") || ($_POST['sendWhat'] == "both")) { global $RBAC; $user = ($RBAC->userCanAccess('PM_ALLCASES') == 1)? '' : $_SESSION['USER_LOGGED']; $folderContentObj = $oPMFolder->getDirectoryContentSortedBy( ($_POST["node"] != "root")? (($_POST["node"] == "NA")? "" : $_POST["node"]) : $rootFolder, array(), null, null, $limit, $start, $user, true, $direction, (isset($_POST["sort"]))? $_POST["sort"]:"appDocCreateDate", $search ); $folderContent = $folderContentObj['documents']; $totalDocuments = $folderContentObj['totalDocumentsCount']; $totalItems += count($folderContent); } $processListTree = array(); $tempTree = array(); if (isset($folderList) && sizeof($folderList)>0) { //$tempTree=array(); foreach ($folderList as $key => $obj) { //$tempTree ['all-obj'] = $obj; $tempTree ['text'] = $obj['FOLDER_NAME']; $tempTree ['id'] = $obj['FOLDER_UID']; $tempTree ['folderID'] = $obj['FOLDER_UID']; $tempTree ['cls'] = 'folder'; $tempTree ['draggable'] = true; $tempTree ['name'] = $obj['FOLDER_NAME']; $tempTree ['type'] = "Directory"; $tempTree ['is_file'] = false; $tempTree ['appDocCreateDate'] = $obj['FOLDER_CREATE_DATE']; $tempTree ['qtip'] ='<strong>Directory: </strong>'.$obj['FOLDER_NAME']. '<br /><strong>Create Date:</strong> '.$obj['FOLDER_CREATE_DATE'].''; $tempTree ['is_writable'] =true; $tempTree ['is_chmodable'] =true; $tempTree ['is_readable'] =true; $tempTree ['is_deletable'] =true; if ((isset($_POST['option']) )&& ($_POST['option'] == "gridDocuments")) { $tempTree ['icon'] = "/images/documents/extension/folder.png"; } $processListTree [] = $tempTree; $tempTree=array(); } } else { if ($_POST ['node'] == '/') { } } if (isset($folderContent)) { foreach ($folderContent as $key => $obj) { $mimeInformation = getMime($obj["APP_DOC_FILENAME"]); $tempTree["text"] = $obj["APP_DOC_FILENAME"]; $tempTree["name"] = $obj["APP_DOC_FILENAME"]; $tempTree["type"] = $mimeInformation["description"]; $tempTree["icon"] = $mimeInformation["icon"]; $tempTree ['appdocid'] = $obj['APP_DOC_UID']; $tempTree ['id'] = $obj['APP_DOC_UID_VERSION']; $tempTree ['cls'] = 'file'; //$tempTree ['draggable'] = true; $tempTree ['leaf'] = true; $tempTree ['is_file'] = true; //if ((isset($_POST['option']))&&($_POST['option']=="gridDocuments")) { //} $tempTree ['docVersion'] = $obj['DOC_VERSION']; $tempTree ['appUid'] = $obj['APP_UID']; $tempTree ['usrUid'] = $obj['USR_UID']; $tempTree ['appDocType'] = ucfirst(strtolower($obj['APP_DOC_TYPE'])); $tempTree ['appDocCreateDate'] = $obj['APP_DOC_CREATE_DATE']; $tempTree ['appDocPlugin'] = $obj['APP_DOC_PLUGIN']; $tempTree ['appDocTags'] = $obj['APP_DOC_TAGS']; $tempTree ['appDocTitle'] = $obj['APP_DOC_TITLE']; $tempTree ['appDocComment'] = $tempTree ['qtip'] = $obj['APP_DOC_COMMENT']; $tempTree ['appDocFileName'] = $obj['APP_DOC_FILENAME']; if (isset($obj['APP_NUMBER'])) { $tempTree ['appLabel'] = sprintf("%s '%s' (%s)",$obj['APP_NUMBER'],$obj['APP_TITLE'],$obj['STATUS']); } else { $tempTree ['appLabel'] = "No case related"; } $tempTree ['proTitle'] = $obj['PRO_TITLE']; $tempTree ['appDocVersionable'] = 0; if (isset($obj['OUT_DOC_VERSIONING'])) { $tempTree ['appDocVersionable'] = $obj['OUT_DOC_VERSIONING']; } elseif (isset($obj['INP_DOC_VERSIONING'])) { $tempTree ['appDocVersionable'] = $obj['INP_DOC_VERSIONING']; } if (isset($obj['USR_LASTNAME']) && isset($obj['USR_LASTNAME'])) { $tempTree ['owner'] = $obj['USR_USERNAME']; $tempTree ['owner_firstname'] = $obj['USR_FIRSTNAME']; $tempTree ['owner_lastname'] = $obj['USR_LASTNAME']; } else { $tempTree ['owner'] = $obj['USR_USERNAME']; $tempTree ['owner_firstname'] = ""; $tempTree ['owner_lastname'] = ""; } $tempTree ['deletelabel'] = $obj['DELETE_LABEL']; if ((isset($obj['DOWNLOAD_LABEL'])) && ($obj['DOWNLOAD_LABEL']!="")) { $labelgen=strtoupper(str_replace(".","",$obj['DOWNLOAD_LABEL'])); $tempTree ['downloadLabel'.$labelgen] = $obj['DOWNLOAD_LABEL']; $tempTree ['downloadLink'.$labelgen] = $obj['DOWNLOAD_LINK']; } $tempTree ['downloadLabel'] = $obj['DOWNLOAD_LABEL']; $tempTree ['downloadLink'] = $obj['DOWNLOAD_LINK']; if ((isset($obj['DOWNLOAD_LABEL1'])) && ($obj['DOWNLOAD_LABEL1']!="")) { $labelgen=strtoupper(str_replace(".","",$obj['DOWNLOAD_LABEL1'])); $tempTree ['downloadLabel'.$labelgen] = $obj['DOWNLOAD_LABEL1']; $tempTree ['downloadLink'.$labelgen] = $obj['DOWNLOAD_LINK1']; } $tempTree ['downloadLabel1'] = $obj['DOWNLOAD_LABEL1']; $tempTree ['downloadLink1'] = $obj['DOWNLOAD_LINK1']; $tempTree ['appDocUidVersion'] = $obj['APP_DOC_UID_VERSION']; $tempTree ['is_readable'] = true; $tempTree ['is_file'] = true; $tempTree["outDocGenerate"] = ""; if (isset($obj["OUT_DOC_GENERATE"])) { switch ($obj["OUT_DOC_GENERATE"]) { case "PDF": case "DOC": $mimeInformation = getMime($obj["APP_DOC_FILENAME"] . "." . strtolower($obj["OUT_DOC_GENERATE"])); $tempTree["text"] = $obj["APP_DOC_FILENAME"] . "." . strtolower($obj["OUT_DOC_GENERATE"]); $tempTree["name"] = $obj["APP_DOC_FILENAME"] . "." . strtolower($obj["OUT_DOC_GENERATE"]); $tempTree["type"] = $mimeInformation["description"]; $tempTree["icon"] = $mimeInformation["icon"]; $tempTree["appDocFileName"] = $tempTree["name"]; $tempTree["downloadLabel"] = $tempTree["downloadLabel" . $obj["OUT_DOC_GENERATE"]]; $tempTree["downloadLink"] = $tempTree["downloadLink" . $obj["OUT_DOC_GENERATE"]]; $tempTree["id"] = $tempTree["id"] . "_" . $obj["OUT_DOC_GENERATE"]; $processListTree[] = $tempTree; break; case "BOTH": $strExpander = null; $mimeInformation = getMime($obj["APP_DOC_FILENAME"] . ".pdf"); $strExpander = $strExpander . "<a href=\"javascript:;\" onclick=\"openActionDialog(this, 'download', 'pdf'); return false;\" style=\"color: #000000; text-decoration: none;\"><img src=\"/images/documents/extension/pdf.png\" style=\"margin-left: 25px; border: 0;\" alt=\"\" /> <b>" . $obj["APP_DOC_FILENAME"] . ".pdf</b> (" . $mimeInformation["description"] . ")</a>"; $strExpander = $strExpander . "<br />"; $mimeInformation = getMime($obj["APP_DOC_FILENAME"] . ".doc"); $strExpander = $strExpander . "<a href=\"javascript:;\" onclick=\"openActionDialog(this, 'download', 'doc'); return false;\" style=\"color: #000000; text-decoration: none;\"><img src=\"/images/documents/extension/doc.png\" style=\"margin-left: 25px; border: 0;\" alt=\"\" /> <b>" . $obj["APP_DOC_FILENAME"] . ".doc</b> (" . $mimeInformation["description"] . ")</a>"; $tempTree["outDocGenerate"] = $strExpander; $tempTree["text"] = $obj["APP_DOC_FILENAME"]; $tempTree["name"] = $obj["APP_DOC_FILENAME"]; $tempTree["type"] = ""; $tempTree["icon"] = "/images/documents/extension/document.png"; $tempTree["appDocFileName"] = $tempTree["name"]; //$tempTree["downloadLabel"] = $obj["DOWNLOAD_LABEL"]; //$tempTree["downloadLink"] = $obj["DOWNLOAD_LINK"]; $tempTree["id"] = $tempTree["id"] . "_" . $obj["OUT_DOC_GENERATE"]; $processListTree[] = $tempTree; break; //case "NOFILE": // break; } } else { if ($obj["APP_DOC_TYPE"] == "OUTPUT" && $tempTree["type"] == G::LoadTranslation("MIME_DES_FILE") && preg_match("/^.+&ext=(.+)&.+$/", $tempTree["downloadLink"], $arrayMatch) ) { $ext = $arrayMatch[1]; $mimeInformation = getMime($obj["APP_DOC_FILENAME"] . ".$ext"); $tempTree["text"] = $obj["APP_DOC_FILENAME"] . ".$ext"; $tempTree["name"] = $obj["APP_DOC_FILENAME"] . ".$ext"; $tempTree["type"] = $mimeInformation["description"]; $tempTree["icon"] = $mimeInformation["icon"]; } $processListTree[] = $tempTree; } $tempTree = array(); } } if ((isset($_POST['option'])) && ($_POST['option'] == "gridDocuments")) { $processListTreeTemp["totalCount"] = $totalFolders + $totalDocuments; $processListTreeTemp['msg']='correct reload'; $processListTreeTemp['items']=$processListTree; $processListTree = $processListTreeTemp; } echo G::json_encode($processListTree); }
function expandNode() { extract(getExtJSParams()); require_once "classes/model/AppFolder.php"; $oPMFolder = new AppFolder(); $rootFolder = "/"; if ($_POST['node'] == "") { $_POST['node'] = "/"; } if ($_POST['node'] == "root") { $_POST['node'] = "/"; } if (!isset($_POST['sendWhat'])) { $_POST['sendWhat'] = "both"; } if (isset($_POST['renderTree'])) { $limit = 1000000; } $totalItems = 0; $totalFolders = 0; $totalDocuments = 0; if ($_POST['sendWhat'] == "dirs" || $_POST['sendWhat'] == "both") { $folderListObj = $oPMFolder->getFolderList($_POST["node"] != "root" ? $_POST["node"] == "NA" ? "" : $_POST["node"] : $rootFolder, $limit, $start); $folderList = $folderListObj['folders']; $totalFolders = $folderListObj['totalFoldersCount']; $totalItems += count($folderList); } if ($_POST['sendWhat'] == "files" || $_POST['sendWhat'] == "both") { global $RBAC; $user = $RBAC->userCanAccess('PM_ALLCASES') == 1 ? '' : $_SESSION['USER_LOGGED']; $folderContentObj = $oPMFolder->getFolderContent($_POST["node"] != "root" ? $_POST["node"] == "NA" ? "" : $_POST["node"] : $rootFolder, array(), null, null, $limit, $start, $user, true); $folderContent = $folderContentObj['documents']; $totalDocuments = $folderContentObj['totalDocumentsCount']; $totalItems += count($folderContent); } $processListTree = array(); $tempTree = array(); if (isset($folderList) && sizeof($folderList) > 0) { //$tempTree=array(); foreach ($folderList as $key => $obj) { //$tempTree ['all-obj'] = $obj; $tempTree['text'] = $obj['FOLDER_NAME']; $tempTree['id'] = $obj['FOLDER_UID']; $tempTree['folderID'] = $obj['FOLDER_UID']; $tempTree['cls'] = 'folder'; $tempTree['draggable'] = true; $tempTree['name'] = $obj['FOLDER_NAME']; $tempTree['type'] = "Directory"; $tempTree['is_file'] = false; $tempTree['appDocCreateDate'] = $obj['FOLDER_CREATE_DATE']; $tempTree['qtip'] = '<strong>Directory: </strong>' . $obj['FOLDER_NAME'] . '<br /><strong>Create Date:</strong> ' . $obj['FOLDER_CREATE_DATE'] . ''; $tempTree['is_writable'] = true; $tempTree['is_chmodable'] = true; $tempTree['is_readable'] = true; $tempTree['is_deletable'] = true; if (isset($_POST['option']) && $_POST['option'] == "gridDocuments") { $tempTree['icon'] = "/images/documents/extension/folder.png"; } //$tempTree ['leaf'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = false; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ $processListTree[] = $tempTree; $tempTree = array(); } /*if ($_POST ['node'] == '/') { $notInFolderLabel = G::LoadTranslation ('ID_NOT_IN_FOLDER'); $tempTree ['text'] = $notInFolderLabel; $tempTree ['id'] = "NA"; $tempTree ['folderID'] = "NA"; $tempTree ['cls'] = 'folder'; $tempTree ['draggable' ] = true; $tempTree ['name'] = $notInFolderLabel; $tempTree ['type'] = "Directory"; $tempTree ['is_file'] = false; $tempTree ['qtip'] ='<strong>Directory: </strong>'.$notInFolderLabel.'<br /><i>Unfiled Files</i> '; $tempTree ['is_writable'] =true; $tempTree ['is_chmodable'] =true; $tempTree ['is_readable'] =true; $tempTree ['is_deletable'] =true; if ((isset($_POST['option']))&&($_POST['option']=="gridDocuments")) { $tempTree ['icon'] = "/images/documents/extension/bz2.png"; }*/ //$tempTree ['leaf'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = false; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ /*$processListTree [] = $tempTree; $tempTree=array(); }*/ } else { if ($_POST['node'] == '/') { //$tempTree=array(); //$processListTree [] = array(); } } if (isset($folderContent)) { foreach ($folderContent as $key => $obj) { $tempTree['text'] = $obj['APP_DOC_FILENAME']; $tempTree['name'] = $obj['APP_DOC_FILENAME']; $mimeInformation = getMime($obj['APP_DOC_FILENAME']); $tempTree['type'] = $mimeInformation['description']; $tempTree['icon'] = $mimeInformation['icon']; if (isset($obj['OUT_DOC_GENERATE'])) { if ($obj['OUT_DOC_GENERATE'] == "BOTH") { $arrayType = array("PDF", "DOC"); } else { $arrayType = array($obj['OUT_DOC_GENERATE']); } foreach ($arrayType as $keyType => $fileType) { $tempTree['text' . $fileType] = $obj['APP_DOC_FILENAME'] . "." . strtolower($fileType); $tempTree['name' . $fileType] = $obj['APP_DOC_FILENAME'] . "." . strtolower($fileType); $mimeInformation = getMime($obj['APP_DOC_FILENAME'] . "." . strtolower($fileType)); $tempTree['type' . $fileType] = $mimeInformation['description']; $tempTree['icon' . $fileType] = $mimeInformation['icon']; } } $tempTree['appdocid'] = $obj['APP_DOC_UID']; $tempTree['id'] = $obj['APP_DOC_UID_VERSION']; $tempTree['cls'] = 'file'; //$tempTree ['draggable'] = true; $tempTree['leaf'] = true; $tempTree['is_file'] = true; //if ((isset($_POST['option']))&&($_POST['option']=="gridDocuments")) { //} $tempTree['docVersion'] = $obj['DOC_VERSION']; $tempTree['appUid'] = $obj['APP_UID']; $tempTree['usrUid'] = $obj['USR_UID']; $tempTree['appDocType'] = ucfirst(strtolower($obj['APP_DOC_TYPE'])); $tempTree['appDocCreateDate'] = $obj['APP_DOC_CREATE_DATE']; $tempTree['appDocPlugin'] = $obj['APP_DOC_PLUGIN']; $tempTree['appDocTags'] = $obj['APP_DOC_TAGS']; $tempTree['appDocTitle'] = $obj['APP_DOC_TITLE']; $tempTree['appDocComment'] = $tempTree['qtip'] = $obj['APP_DOC_COMMENT']; $tempTree['appDocFileName'] = $obj['APP_DOC_FILENAME']; if (isset($obj['APP_NUMBER'])) { $tempTree['appLabel'] = sprintf("%s '%s' (%s)", $obj['APP_NUMBER'], $obj['APP_TITLE'], $obj['STATUS']); } else { $tempTree['appLabel'] = "No case related"; } $tempTree['proTitle'] = $obj['PRO_TITLE']; $tempTree['appDocVersionable'] = 0; if (isset($obj['OUT_DOC_VERSIONING'])) { $tempTree['appDocVersionable'] = $obj['OUT_DOC_VERSIONING']; } elseif (isset($obj['INP_DOC_VERSIONING'])) { $tempTree['appDocVersionable'] = $obj['INP_DOC_VERSIONING']; } if (isset($obj['USR_LASTNAME']) && isset($obj['USR_LASTNAME'])) { $tempTree['owner'] = $obj['USR_USERNAME']; $tempTree['owner_firstname'] = $obj['USR_FIRSTNAME']; $tempTree['owner_lastname'] = $obj['USR_LASTNAME']; } else { $tempTree['owner'] = $obj['USR_USERNAME']; $tempTree['owner_firstname'] = ""; $tempTree['owner_lastname'] = ""; } $tempTree['deletelabel'] = $obj['DELETE_LABEL']; if (isset($obj['DOWNLOAD_LABEL']) && $obj['DOWNLOAD_LABEL'] != "") { $labelgen = strtoupper(str_replace(".", "", $obj['DOWNLOAD_LABEL'])); $tempTree['downloadLabel' . $labelgen] = $obj['DOWNLOAD_LABEL']; $tempTree['downloadLink' . $labelgen] = $obj['DOWNLOAD_LINK']; } $tempTree['downloadLabel'] = $obj['DOWNLOAD_LABEL']; $tempTree['downloadLink'] = $obj['DOWNLOAD_LINK']; if (isset($obj['DOWNLOAD_LABEL1']) && $obj['DOWNLOAD_LABEL1'] != "") { $labelgen = strtoupper(str_replace(".", "", $obj['DOWNLOAD_LABEL1'])); $tempTree['downloadLabel' . $labelgen] = $obj['DOWNLOAD_LABEL1']; $tempTree['downloadLink' . $labelgen] = $obj['DOWNLOAD_LINK1']; } $tempTree['downloadLabel1'] = $obj['DOWNLOAD_LABEL1']; $tempTree['downloadLink1'] = $obj['DOWNLOAD_LINK1']; $tempTree['appDocUidVersion'] = $obj['APP_DOC_UID_VERSION']; $tempTree['is_readable'] = true; $tempTree['is_file'] = true; //$tempTree ['optionType'] = "category"; //$tempTree['allowDrop']=false; //$tempTree ['singleClickExpand'] = true; /* if ($key != "No Category") { $tempTree ['expanded'] = true; } else { //$tempTree ['expanded'] = false; $tempTree ['expanded'] = true; } */ if (isset($obj['OUT_DOC_GENERATE'])) { foreach ($arrayType as $keyType => $fileType) { $tempTree['text'] = $tempTree['text' . $fileType]; $tempTree['name'] = $tempTree['name' . $fileType]; $tempTree['type'] = $tempTree['type' . $fileType]; $tempTree['icon'] = $tempTree['icon' . $fileType]; $tempTree['appDocFileName'] = $tempTree['name' . $fileType]; $tempTree['downloadLabel'] = $tempTree['downloadLabel' . $fileType]; $tempTree['downloadLink'] = $tempTree['downloadLink' . $fileType]; $tempTree['id'] = $tempTree['id'] . "_" . $fileType; $processListTree[] = $tempTree; } } else { $processListTree[] = $tempTree; } $tempTree = array(); } } if (isset($_POST['option']) && $_POST['option'] == "gridDocuments") { $processListTreeTemp["totalCount"] = $totalFolders + $totalDocuments; $processListTreeTemp['msg'] = 'correct reload'; $processListTreeTemp['items'] = $processListTree; $processListTree = $processListTreeTemp; } echo G::json_encode($processListTree); }
public function inlineAdd($path) { if (!is_file($path) || !is_readable($path)) { $this->errMsg('invalidFile', $path); return false; } $filename = basename($path); $this->attachmentName[] = $filename; $this->attachmentType[] = getMime($path); $this->attachmentPath[] = $path; $this->attachSize += filesize($path); $this->attachDispos[] = "inline"; if ($this->attachSize >= max(sizeFromString(ini_get("memory_limit")), 4 * 1048576)) { $this->memoryLimit = true; } }
$json = array(); } $groups = array(); $error = false; $ts3 = TeamSpeak3::factory("serverquery://" . QUERYUSER . ":" . QUERYPASS . "@" . IP . ":" . QUERYPORT . "/?server_port=" . SERVERPORT . "&nickname=" . urlencode('Icon Sync')); foreach ($ts3->serverGroupList() as $sg) { if ($sg['iconid']) { try { $groups[$sg['sgid']] = $sg->iconDownload(); } catch (TeamSpeak3_Exception $e) { } } } foreach ($groups as $sgid => $binary) { if (!empty($binary)) { $type = getMime($binary); if ($type != 'application/octet-stream') { file_put_contents('icons/' . $sgid . '.' . $type, $binary); $json[$sgid] = 'icons/' . $sgid . '.' . $type; } } } file_put_contents('config/icons.json', json_encode($json)); } catch (Exception $e) { echo json_encode(FALSE); $error = true; } if (!$error) { echo json_encode(TRUE); } } else {
public function getMime($file = null) { return getMime($file); }
} return ''; } function getMime($ext) { include 'boot/mime_types.php'; if (!array_key_exists($ext, $mimeTypes)) { $mime = 'application/octet-stream'; } else { $mime = $mimeTypes[$ext]; } return $mime; } $url = str_replace('/public', '', query_path()); $ext = getExt($url); $mime = getMime($ext); function getFile($url) { $hostDir = BuCore::fstab('staticHostDir') . '/' . HTTP_HOST; $prjDir = BuCore::fstab('staticPrj'); $coreDir = BuCore::fstab('staticCore'); foreach (array($hostDir, $prjDir, $coreDir) as $v) { if (file_exists($v . $url)) { return $v . $url; } } } $file = getFile($url); if ($file) { $fp = fopen($file, 'rb'); header("Content-Type: " . $mime);
function sendMail($mailto, $subject, &$mail, $mailfrom = "", $header = "", $isHTML = true, $attach = "") { # mailto = destination mail, accepts extended version (name <mail>) and comma delimited list # subject = subject line # mail = template with the fill mail >>>OBJECT<<< # mailfrom = "from" mail # header (optional) = headers, you might or might not fill a Content-Type # isHTML = if true, adds proper Content-Type # attach = filename for attachment $subject = str_replace("\n", "", $subject); // bye exploit $subject = str_replace("\r", "", $subject); // bye exploit if (preg_match('!\\S!u', $subject) !== 0) { $subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; } if ($mailfrom == "" && strpos($mailto, ",") === false) { $mailfrom = $mailto; } // no mailfrom, use mailti if ($header != "" && $header[strlen($header) - 1] != "\n") { $header .= "\n"; } // add \n at the end of the last line of pre-defined header $mailfrom = str_replace("\n", "", $mailfrom); // bye exploit if (strpos(strtoupper($header), "RETURN-PATH:") === false && isMail($mailfrom, true)) { // no R-P, add if possible $header .= "Return-path: {$mailfrom}\n"; } if (strpos(strtoupper($header), "REPLY-TO:") === false && isMail($mailfrom, true)) { // no R-T, add if possible $header .= "Reply-To: {$mailfrom}\n"; } if (strpos(strtoupper($header), "FROM:") === false && isMail($mailfrom, true)) { // no FROM, add if possible $header .= "From: {$mailfrom}\n"; } if ($isHTML || $attach != "") { // HTML mode with attachment $isHTML = true; $bound = "--=XYZ_" . md5(date("dmYis")) . "_ZYX"; $bnext = "--=NextPart_XYZ_" . md5(date("dm")) . ".E0_PART"; $header .= "Content-Type:multipart/" . ($attach != "" ? "mixed" : "alternative") . "; boundary=\"{$bound}\"\n"; } else { // not HTML nor with attachment $header .= "Content-Type:text/plain; charset=utf-8\n"; } $header .= "MIME-Version: 1.0\n"; $header .= "x-mailer: PresciaMailer\n"; $mail->assign("IP", CONS_IP); $mail->assign("HOUR", date("H:i")); $mail->assign("DATA", date("d/m/Y")); $mail->assign("DATE", date("m/d/Y")); $corpo = $mail->techo(); if ($attach != "" && is_file($attach)) { // deal with attachment //Open file and convert to base64 $fOpen = fopen($attach, "rb"); $fAtach = fread($fOpen, filesize($attach)); $ext = explode(".", $attach); $ext = array_pop($ext); $fAtach = base64_encode($fAtach); fclose($fOpen); $fAtach = chunk_split($fAtach); $corpoplain = preg_replace("/( ){2,}/", " ", cleanHTML($corpo)); // Add multipart message $sBody = "This is a multipart MIME message.\n\n"; $sBody .= "--{$bound}\n"; $sBody .= "Content-Type: multipart/alternative; boundary=\"{$bnext}\"\n\n\n"; $sBody .= "--{$bnext}\n" . "Content-Type: text/plain; charset=utf-8\n\n" . $corpoplain . "\n\n" . "--{$bnext}\n"; $sBody .= "Content-Type:text/html; charset=utf-8\n\n"; $sBody .= "{$corpo} \n\n"; $sBody .= "--{$bnext}--\n\n"; $sBody .= "--{$bound}\n"; $fname = explode("/", str_replace("\\", "/", $attach)); $sBody .= "Content-Disposition: attachment; filename=" . array_pop($fname) . "\n"; if (!function_exists("getMime")) { include_once CONS_PATH_INCLUDE . "getMime.php"; } $sBody .= "Content-Type: " . getMime($ext) . "\n"; $sBody .= "Content-Transfer-Encoding: base64\n\n{$fAtach}\n"; $sBody .= "--{$bound}--\n\n"; } else { if ($isHTML) { $corpoplain = preg_replace("/( ){2,}/", " ", stripHTML($corpo)); $sBody = "This is a multipart MIME message.\n\n"; $sBody .= "--{$bound}\n" . "Content-Type: text/plain; charset=utf-8\n\n" . $corpoplain . "\n\n" . "--{$bound}\n" . "Content-Type: text/html; charset=utf-8\n\n" . $corpo . "\n\n" . "--{$bound}--\n"; } else { $sBody = $corpo; } } if (substr($subject, 0, 3) == "NS:") { $sBody .= chr(0); } // Newsletter character flag if (preg_match('@^([^<]*)<([^>]*)>(.?)$@i', $mailfrom, $matches) == 1) { $mailfrom = $matches[2]; } // removes expanded mail mode $ok = false; // will return false ONLY if ALL submissions fail $mailto = explode(",", $mailto); foreach ($mailto as $mt) { $mt = trim($mt); // Subject: =?UTF-8?B?".base64_encode($subject)."?= if (!@mail($mt, $subject, $sBody, $header, '-f' . $mailfrom)) { $ok = @mail($mt, $subject, $sBody, $header, '-r' . $mailfrom) || $ok; } else { $ok = true; } } return $ok; }
function sort_list($list) { // -------------- // This function sorts the list of directories and files // Written by Slynderdale // -------------- // ------------------------------------------------------------------------- // Global variables and settings // ------------------------------------------------------------------------- global $net2ftp_globals; // ------------------------------------------------------------------------- // If the list is empty, return immediately // ------------------------------------------------------------------------- if ($net2ftp_globals["sort"] == "" || is_array($list) == false || sizeof($list) <= 1) { return $list; } // ------------------------------------------------------------------------- // Default values // ------------------------------------------------------------------------- // Sort flags if ($net2ftp_globals["sort"] == "size") { $sortflag = SORT_NUMERIC; } else { $sortflag = SORT_REGULAR; } // Sort ascending or descending if ($net2ftp_globals["sortorder"] == "ascending") { $sortfunction = "asort"; } else { $sortfunction = "arsort"; } // ------------------------------------------------------------------------- // Create a temporary array $temp which contains only the key $i and the value based on which the sorting is done // ------------------------------------------------------------------------- // ------------------------------------ // Sorting according to name, size, owner, group, permissions // ------------------------------------ if ($net2ftp_globals["sort"] != "mtime" && $net2ftp_globals["sort"] != "type") { for ($i = 1; $i <= sizeof($list); $i++) { $temp[$i] = strtolower($list[$i][$net2ftp_globals["sort"]]); } } elseif ($net2ftp_globals["sort"] == "mtime") { for ($i = 1; $i <= sizeof($list); $i++) { // Some FTP servers return the date and time in a non-standard format // For example: "Apr 06 12:57". Transform this to "06 April 2005 12:57" if (preg_match("/([a-zA-Z]{3})[ ]+([0-9]{1,2})[ ]+([0-9]{1,2}:[0-9]{2})/", $list[$i]["mtime"], $regs) == true) { $month = $regs[1]; $day = $regs[2]; $hour = $regs[3]; $year = date("Y"); if ($month == "Jan") { $month = "January"; } elseif ($month == "Feb") { $month = "February"; } elseif ($month == "Mar") { $month = "March"; } elseif ($month == "Apr") { $month = "April"; } elseif ($month == "May") { $month = "May"; } elseif ($month == "Jun") { $month = "June"; } elseif ($month == "Jul") { $month = "July"; } elseif ($month == "Aug") { $month = "August"; } elseif ($month == "Sep") { $month = "September"; } elseif ($month == "Oct") { $month = "October"; } elseif ($month == "Nov") { $month = "November"; } elseif ($month == "Dec") { $month = "December"; } $mtime_correct = "{$day} {$month} {$year} {$hour}"; $temp[$i] = strtotime($mtime_correct); } else { $temp[$i] = strtotime($list[$i]["mtime"]); } } // end for } elseif ($net2ftp_globals["sort"] == "type") { for ($i = 1; $i <= sizeof($list); $i++) { $mime = getMime($list[$i]); $temp[$i] = $mime["mime_type"]; } // end for } // ------------------------------------------------------------------------- // Execute the sorting on the $temp array // ------------------------------------------------------------------------- $sortfunction($temp, $sortflag); // ------------------------------------------------------------------------- // Fill the $return array // ------------------------------------------------------------------------- $i = 1; while (list($tname, $tvalue) = each($temp)) { $return[$i] = $list[$tname]; $i++; } // ------------------------------------------------------------------------- // Return the result // ------------------------------------------------------------------------- return $return; }
function file2base64($value) { if (is_dir($value)) { return false; } else { $mime = getMime($value); $fd = fopen($value, 'rb'); $size = filesize($value); fclose($fd); $result['base64'] = base64_encode(file_get_contents($value)); $result['mime'] = $mime; $result['name'] = basename($value); $result['size'] = $size; return $result; } }