Esempio n. 1
0
function listFile($path)
{
    global $config;
    $filetype = getFileType($path);
    if ($filetype == 'text') {
        $text = file_get_contents($config['files'] . $path);
    } else {
        if ($filetype == 'opendocument.text') {
            require "ophir.php";
            $OPHIR_CONF["header"] = 1;
            $OPHIR_CONF["quote"] = 1;
            $OPHIR_CONF["list"] = 1;
            $OPHIR_CONF["table"] = 1;
            $OPHIR_CONF["footnote"] = 1;
            $OPHIR_CONF["link"] = 1;
            $OPHIR_CONF["image"] = 1;
            $OPHIR_CONF["note"] = 1;
            $OPHIR_CONF["annotation"] = 1;
            $text = odt2html($config['files'] . $path);
        } else {
            $text = '';
        }
    }
    return array('type' => 'file', 'filetype' => $filetype, 'mimetype' => system_extension_mime_type($path), 'name' => basename($path), 'path' => $path, 'text' => $text);
}
Esempio n. 2
0
function display_company_image_from_string($company_name, $row_number, $extra = "")
{
    $data = json_decode(query_an_image($company_name . " " . $extra));
    $img_urls = array();
    $img_names = array();
    foreach ($data->responseData->results as $result) {
        $img_urls[] = $result->url;
        $img_names[] = "/var/www/html/parse-data-dot-com/images/{$row_number}";
        $results[] = array('url' => $result->url, 'alt' => $result->title);
        $url = $result->url;
        $ftype = getFileType($url);
        #echo $ftype;
        $img = "/var/www/html/parse-data-dot-com/images/{$row_number}.{$ftype}";
        echo $url;
        #echo $img;
        if (strpos($url, "https") < 0) {
            //using asfiletype=png
            continue 2;
        } else {
            try {
                return $url;
            } catch (Exception $e) {
                echo "Caught exceptiom : {$e}";
                continue;
            }
        }
    }
    #var_dump($url);
    #var_dump($img);
    return $data;
}
Esempio n. 3
0
 /**
  * Initialize the upload class
  * @param string $upload The key value of the $_FILES superglobal to use
  */
 private function _initialize($upload)
 {
     $this->_uploadedFile = $upload['name'];
     $this->_tempName = $upload['tmp_name'];
     $this->_fileSize = $upload['size'];
     $this->_extension = getFileExtension($this->_uploadedFile);
     $this->_mimeType = getFileType($this->_tempName);
 }
Esempio n. 4
0
/**
 * Handle and read uploaded file
 * @param array - fileArray from form
 * @param array - postArray from form
 */
function handleUpload($_FILES, $_POST)
{
    require_once "JotForm.php";
    $path = mktime() . '_' . $_FILES['file']['name'];
    $key = $_POST['APIkey'];
    $form = $_POST['formID'];
    $jot = new JotForm($key);
    $error = "";
    if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
        $fileType = getFileType($path);
        $columns = array();
        if ($fileType == 'csv') {
            if (($handle = fopen($path, "r")) !== FALSE) {
                if (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    foreach ($data as $title) {
                        array_push($columns, $title);
                    }
                }
                $error = 'File must contain at least two rows - the first represents the field titles';
                while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    $error = '';
                    $result = $jot->createFormSubmissions($form, writeData($data, $columns));
                }
                fclose($handle);
            } else {
                $error = 'Could not open file';
            }
        } else {
            require_once 'Excel/reader.php';
            $excel = new Spreadsheet_Excel_Reader();
            $excel->read($path);
            if ($excel->sheets[0]['numRows'] > 1) {
                for ($i = 1; $i <= $excel->sheets[0]['numCols']; $i++) {
                    $title = $excel->sheets[0]['cells'][1][$i];
                    array_push($columns, $title);
                }
                for ($i = 2; $i <= $excel->sheets[0]['numRows']; $i++) {
                    $data = array();
                    for ($j = 1; $j <= $excel->sheets[0]['numCols']; $j++) {
                        array_push($data, $excel->sheets[0]['cells'][$i][$j]);
                    }
                    $jot->createFormSubmissions($form, writeData($data, $columns));
                }
            } else {
                $error = 'File must contain at least two rows - the first represents the field titles';
            }
        }
    } else {
        $error = 'No File Found';
    }
    if (strlen($error) > 0) {
        return $error;
    } else {
        return 'none';
    }
}
Esempio n. 5
0
function generate_name($data)
{
    $fileType = getFileType($data);
    $base = "temp";
    if (isset($_POST["guid"])) {
        $base = $_POST["guid"];
    }
    $date = new DateTime();
    $timestamp = $date->getTimestamp();
    return $base . "-" . $timestamp . $fileType;
}
Esempio n. 6
0
function get_company_image_from_string($company_name, $row_number, $extra = "")
{
    $data = json_decode(query_an_image($company_name . $extra));
    var_dump($data);
    $img_urls = array();
    $img_names = array();
    foreach ($data->responseData->results as $result) {
        $img_urls[] = $result->url;
        $img_names[] = "C:/git-lyris/parse-data-dot-com/images/{$row_number}";
        $results[] = array('url' => $result->url, 'alt' => $result->title);
        $url = $result->url;
        $ftype = getFileType($url);
        #echo $ftype;
        $img = "C:/git-lyris/parse-data-dot-com/images/{$row_number}.{$ftype}";
        echo $url;
        #echo $img;
        if (strpos($url, "https") < 0) {
            //using asfiletype=png
            continue 2;
        } else {
            try {
                echo "<-downloading..\n";
                if (file_put_contents($img, file_get_contents($url))) {
                    break;
                } else {
                    echo "notif file put??";
                    continue;
                }
            } catch (Exception $e) {
                echo "Caught exceptiom : {$e}";
                continue;
            }
        }
    }
    #var_dump($url);
    #var_dump($img);
    return $data;
}
Esempio n. 7
0
/** 파일 체크
 * @class file
 * @param
		-dir: 업로드할 디렉토리
		-target: $_FILES 중에서 하나만 지정한 key값
		-size: 최대용량 제한
		-width: 이미지 너비 제한
		-height: 이미지 높이 제한
		-filename: 파일이름 강제로 지정하기
		-is_overwrite: 같은 파일명이 있으면 덮어 씌움
		-is_download: 다운로드만 받을 수 있도록 파일명을 조절
		-is_exists: 같은 파일명이 있으면 중지
		-is_image: 이미지 파일만 허용
		-is_none: 파일 없음을 허용
 */
function chkFile($param = '')
{
    global $mini, $_FILES;
    iss($param);
    $param = param($param);
    iss($param['dir']);
    iss($param['target']);
    iss($param['size']);
    iss($param['width']);
    iss($param['height']);
    iss($param['filename']);
    iss($param['is_overwrite']);
    iss($param['is_download']);
    iss($param['is_exists']);
    iss($param['is_image']);
    iss($param['is_none']);
    if (!is_array($_FILES) && !$param['is_none']) {
        __error("업로드된 파일이 없습니다");
    }
    if (count($_FILES) < 1) {
        __error("업로드된 파일이 없거나, 용량을 초과 했습니다.");
    }
    if (!$param['dir']) {
        __error("업로드 디렉토리가 지정되지 않았습니다");
    }
    if (!empty($param['dir']) && !preg_match("/(\\/|\\\\)\$/", $param['dir'])) {
        $param['dir'] .= "/";
    }
    // 업로드 디렉토리 생성
    if (!is_dir($param['dir'])) {
        if (!@mkdir($param['dir'], 0707)) {
            __error("[{$param['dir']}] 업로드 디렉토리를 생성할 수 없습니다.");
        }
    }
    $limitsize = getByte(get_cfg_var("upload_max_filesize"), 'decode');
    $param['size'] = $param['size'] && $limitsize > $param['size'] ? $param['size'] : $limitsize;
    foreach ($_FILES as $key => $val) {
        iss($val['is_image']);
        //// 타겟 체크
        if ($param['target'] && $param['target'] != $key) {
            continue;
        }
        //// 파일 없음 체크
        if (!$val['name']) {
            if ($param['is_none']) {
                continue;
            } else {
                __error("[{$key}] 파일명이 없습니다");
            }
        } else {
            $filename = $filename_org = $val['name'];
            $tmp_filename = str($val['name'], 'encode', 1);
        }
        //// 기본 error 체크
        if (!empty($val['error'])) {
            switch ($val['error']) {
                // 스킵
                case 'UPLOAD_ERR_OK':
                case 0:
                case 'UPLOAD_ERR_NO_FILE':
                case 4:
                    break;
                case 'UPLOAD_ERR_INI_SIZE':
                case 1:
                    __error("[{$tmp_filename}] 파일 용량이 " . ini_get("upload_max_filesize") . "를 초과할 수 없습니다.\\n(php.ini, upload_max_filesize 설정에서 변경가능)");
                case 'UPLOAD_ERR_FORM_SIZE':
                case 2:
                    __error("[{$tmp_filename}] 파일 용량이 초과 되었습니다.\\n(해당 Form 의 MAX_FILE_SIZE 설정에서 변경 가능합니다)");
                case 'UPLOAD_ERR_PARTIAL':
                case 3:
                    __error("[{$tmp_filename}] 업로드된 파일이 올바르지 않습니다");
                case 'UPLOAD_ERR_NO_TMP_DIR':
                case 6:
                    __error("임시 폴더가 없어 파일을 업로드 할 수 없습니다. 서버 관리자에게 문의해 주세요.\\n(설정된 임시 폴더는 " . ini_get("upload_tmp_dir") . " 입니다)");
                case 'UPLOAD_ERR_CANT_WRITE':
                case 7:
                    __error("디스크에 쓰기를 실패 했습니다. 서버 관리자에게 문의해 주세요");
            }
        }
        //// 파일명 체크
        if ($param['filename']) {
            $filename = $param['filename'];
        }
        $filename = str_replace(array("|", "'", "\"", "\\"), "", $filename);
        $filename = trim($filename);
        //// 확장자 체크
        $val['ext'] = strtolower(substr(strrchr($filename, "."), 1));
        //// 이미지 관련 체크
        $is_image = getimagesize($val['tmp_name']);
        if (!empty($is_image) && is_array($is_image)) {
            $val['is_image'] = 1;
            $val['width'] = $is_image[0];
            $val['height'] = $is_image[1];
        } else {
            $val['is_image'] = 0;
        }
        //// 파일타입
        $val['type'] = getFileType($val['ext']);
        if ($val['type'] == 'image' && empty($val['is_image'])) {
            __error("[{$tmp_filename}] 이미지 파일이 아닙니다");
        }
        if (!$val['is_image'] && $param['is_image']) {
            __error("[{$tmp_filename}] 이미지 파일만 허용합니다");
        }
        if ($val['is_image']) {
            if ($param['width'] && $param['width'] < $val['width']) {
                __error("[{$tmp_filename}] 이미지 너비가 {$param['width']}px 를 초과 했습니다. (현재 {$val['width']}px)");
            }
            if ($param['height'] && $param['height'] < $val['height']) {
                __error("[{$tmp_filename}] 이미지 높이가 {$param['height']}px 를 초과 했습니다. (현재 {$val['height']}px)");
            }
        }
        //// 한글제거
        if (strCut($filename, 0, 'multi')) {
            $filename = urlencode($filename);
        }
        //// 기호제거
        $filename = preg_replace("/[^0-9a-z_\\-\\.]/i", "", $filename);
        //// 파일명 변경
        if ($param['is_download']) {
            $filename = str_replace(".", "_", $filename);
            $filename .= ".mb";
        }
        //// 중복 체크
        if (file_exists($param['dir'] . $filename) && !$param['is_overwrite']) {
            if ($param['is_exists']) {
                __error("[{$tmp_filename}] 중복된 파일명입니다.");
            }
            $a = 0;
            $tmp2_filename = $filename;
            while (file_exists($param['dir'] . $tmp2_filename)) {
                $a++;
                if (strpos($filename, ".") !== false) {
                    $tmp2_filename = preg_replace("/(\\.?[^\\.]+)\$/is", $a . "\\1", $filename);
                } else {
                    $tmp2_filename = $filename . $a;
                }
            }
            $filename = $tmp2_filename;
        }
        //// 내용 중복
        if (!empty($val['size']) && !empty($mini['board']['use_file_unique']) && !empty($mini['board']['no'])) {
            if (sql("SELECT COUNT(*) FROM {$mini['name']['file']} WHERE id={$mini['board']['no']} and hash='" . str(getHash($val), 'encode', 1) . "'")) {
                __error("[{$tmp_filename}] 이미 같은 파일이 있습니다");
            }
        }
        //// 용량 체크
        if ($param['size'] && $param['size'] < $val['size']) {
            __error("[{$tmp_filename}] 파일 용량이 " . number_format($param['size']) . " bytes를 초과할 수 없습니다\\n(현재 {$val['size']}bytes)");
        }
        if ($val['size'] <= 0) {
            __error("[{$tmp_filename}] 파일 용량은 0 byte 이상이어야 합니다");
        }
        //// 변수 입력
        $val['path'] = $param['dir'] . $filename;
        $val['path_only'] = $param['dir'];
        $val['name_insert'] = $filename;
        $_FILES[$key] = $val;
    }
}
Esempio n. 8
0
function checkFileExists($type, $file_name, $folder_path)
{
    $ftp_rawlist = getFtpRawList($folder_path);
    if (is_array($ftp_rawlist)) {
        $fileNameAr = array();
        $count = 0;
        // Go through array of files/folders
        foreach ($ftp_rawlist as $ff) {
            $count++;
            // Lin
            if ($_SESSION["win_lin"] == "lin") {
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 9);
                $perms = $ff[0];
                $file = $ff[8];
                if ($file != "." && $file != "..") {
                    if ($type == "f" && getFileType($perms) == "f") {
                        $fileNameAr[] = $file;
                    }
                    if ($type == "d" && getFileType($perms) == "d") {
                        $fileNameAr[] = $file;
                    }
                }
            }
            // Mac
            if ($_SESSION["win_lin"] == "mac") {
                if ($count == 1) {
                    continue;
                }
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 9);
                $perms = $ff[0];
                $file = $ff[8];
                if ($file != "." && $file != "..") {
                    if ($type == "f" && getFileType($perms) == "f") {
                        $fileNameAr[] = $file;
                    }
                    if ($type == "d" && getFileType($perms) == "d") {
                        $fileNameAr[] = $file;
                    }
                }
            }
            // Win
            if ($_SESSION["win_lin"] == "win") {
                // Split up array into values
                $ff = preg_split("/[\\s]+/", $ff, 4);
                $size = $ff[2];
                $file = $ff[3];
                if ($size == "<DIR>") {
                    $size = "d";
                }
                if ($type == "d" && $size == "d") {
                    $fileNameAr[] = $file;
                }
                if ($type == "f" && $size != "d") {
                    $fileNameAr[] = $file;
                }
            }
        }
        // Check if file is in array
        if (in_array($file_name, $fileNameAr)) {
            return 1;
        }
    } else {
        return 0;
    }
}
Esempio n. 9
0
 function imgupload()
 {
     //首先获取上传的总文件数目!
     $imgcount = count($_FILES["files"]["name"]);
     //定义返回的数组
     $backArr = array();
     //根据数量逐个遍历文件
     for ($i = 0; $i <= $imgcount - 1; $i++) {
         $msg = "";
         if ($_FILES['files']['error'][$i] != UPLOAD_ERR_OK) {
             switch ($_FILES['files']['error']) {
                 case UPLOAD_ERR_INI_SIZE:
                     //其值为 1,上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值
                     $msg = "文件超大!错误代码1";
                     break;
                 case UPLOAD_ERR_FORM_SIZE:
                     //其值为 2,上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值
                     $msg = "文件超大!错误代码2";
                     break;
                 case UPLOAD_ERR_PARTIAL:
                     //其值为 3,文件只有部分被上传
                     $msg = "文件未上传完毕!错误代码3";
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     //其值为 4,没有文件被上传
                     $msg = "没有文件被上传!请检查!错误代码4";
                     break;
                 case UPLOAD_ERR_NO_TMP_DIR:
                     //其值为 6,找不到临时文件夹
                     $msg = "服务端错误!未找到临时文件夹!错误代码5";
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     //其值为 7,文件写入失败
                     $msg = "文件写入失败!错误代码6";
                     break;
                 case UPLOAD_ERR_EXTENSION:
                     //其他异常
                     $msg = "未知错误!请联系软件人员!错误代码7";
                     break;
             }
         }
         if ($msg == "") {
             //图片正常接收 将文件发送到文件夹并且改名
             /*getimagesize方法返回一个数组,
               $width : 索引 0 包含图像宽度的像素值,
               $height : 索引 1 包含图像高度的像素值,
               $type : 索引 2 是图像类型的标记:
               1 = GIF,2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP,
               7 = TIFF(intel byte order),8 = TIFF(motorola byte order),
               9 = JPC,10 = JP2,11 = JPX,12 = JB2,13 = SWC,14 = IFF,15 = WBMP,16 = XBM,
               $attr : 索引 3 是文本字符串,内容为“height="yyy" width="xxx"”,可直接用于 IMG 标记
               */
             list($width, $height, $type, $attr) = getimagesize($_FILES['files']['tmp_name'][$i]);
             //imagecreatefromgXXX方法从一个url路径中创建一个新的图片
             switch ($type) {
                 case IMAGETYPE_GIF:
                     $image = imagecreatefromgif($_FILES['files']['tmp_name'][$i]);
                     $ext = '.gif';
                     break;
                 case IMAGETYPE_JPEG:
                     $image = imagecreatefromjpeg($_FILES['files']['tmp_name'][$i]);
                     $ext = '.jpg';
                     break;
                 case IMAGETYPE_PNG:
                     $image = imagecreatefrompng($_FILES['files']['tmp_name'][$i]);
                     $ext = '.png';
                     break;
                 default:
                     $msg = "所发送的文件并非为需要接收的格式!请检查!错误代码8!";
             }
             //有url指定的图片创建图片并保存到指定目录
             $imagename = uniqid() . "." . getFileType($_FILES['files']['name'][$i]);
             imagegif($image, $this->_imgdir . '/' . $imagename);
             //销毁由url生成的图片
             imagedestroy($image);
         } else {
             $imagename = $_FILES['files']['name'][$i];
         }
         $backArr[$i] = array("msg" => "{$msg}", "imagename" => "{$imagename}");
     }
     return $backArr;
 }
Esempio n. 10
0
function deleteFile($d, $del = true)
{
    $size = 0;
    $t = getFileType($d);
    if ($t == 't') {
        // For time lapse try to delete all from this batch
        $files = findLapseFiles($d);
        foreach ($files as $file) {
            $size += filesize_n($file);
            if ($del) {
                if (!unlink($file)) {
                    $debugString .= "F ";
                }
            }
        }
    } else {
        $tFile = dataFilename($d);
        if (file_exists(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}")) {
            $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}");
            if ($del) {
                unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}");
            }
        }
        if ($t == 'v' && file_exists(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat")) {
            $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat");
            if ($del) {
                unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$tFile}.dat");
            }
        }
    }
    $size += filesize_n(LBASE_DIR . '/' . MEDIA_PATH . "/{$d}");
    if ($del) {
        unlink(LBASE_DIR . '/' . MEDIA_PATH . "/{$d}");
    }
    return $size / 1024;
}
Esempio n. 11
0
			<?php 
    $dirs = opendir($idir);
    ?>
			<?php 
    while (false !== ($f = readdir($dirs))) {
        ?>
			<?php 
        if (!is_file($idir . $f)) {
            continue;
        }
        ?>
			<?php 
        $fext = getExt($f);
        ?>
			<?php 
        $ftype = getFileType($fext);
        ?>
			

				<div class="imgbox" title="<?php 
        echo $f;
        ?>
">
					<div class="delbox"><a href="<?php 
        echo $g['s'];
        ?>
/?r=<?php 
        echo $r;
        ?>
&amp;m=<?php 
        echo $module;
Esempio n. 12
0
function drawFile($f, $ts, $sel)
{
    $fType = getFileType($f);
    $rFile = dataFilename($f);
    $fNumber = getFileIndex($f);
    $lapseCount = "";
    switch ($fType) {
        case 'v':
            $fIcon = 'video.png';
            break;
        case 't':
            $fIcon = 'timelapse.png';
            $lapseCount = '(' . count(findLapseFiles($f)) . ')';
            break;
        case 'i':
            $fIcon = 'image.png';
            break;
        default:
            $fIcon = 'image.png';
            break;
    }
    $duration = '';
    if (file_exists(MEDIA_PATH . "/{$rFile}")) {
        $fsz = round(filesize(MEDIA_PATH . "/{$rFile}") / 1024);
        $fModTime = filemtime(MEDIA_PATH . "/{$rFile}");
        if ($fType == 'v') {
            $duration = $fModTime - filemtime(MEDIA_PATH . "/{$f}") . 's';
        }
    } else {
        $fsz = 0;
        $fModTime = filemtime(MEDIA_PATH . "/{$f}");
    }
    $fDate = @date('Y-m-d', $fModTime);
    $fTime = @date('H:i:s', $fModTime);
    $fWidth = max($ts + 4, 140);
    echo "<fieldset class='fileicon' style='width:" . $fWidth . "px;'>";
    echo "<legend class='fileicon'>";
    echo "<button type='submit' name='delete1' value='{$f}' class='fileicondelete' style='background-image:url(delete.png);\n'></button>";
    echo "&nbsp;&nbsp;{$fNumber}&nbsp;";
    echo "<img src='{$fIcon}' style='width:24px'/>";
    echo "<input type='checkbox' name='check_list[]' {$sel} value='{$f}' style='float:right;'/>";
    echo "</legend>";
    if ($fsz > 0) {
        echo "{$fsz} Kb {$lapseCount} {$duration}";
    } else {
        echo 'Busy';
    }
    echo "<br>{$fDate}<br>{$fTime}<br>";
    if ($fsz > 0) {
        echo "<a title='{$rFile}' href='preview.php?preview={$f}'>";
    }
    echo "<img src='" . MEDIA_PATH . "/{$f}' style='width:" . $ts . "px'/>";
    if ($fsz > 0) {
        echo "</a>";
    }
    echo "</fieldset> ";
}
Esempio n. 13
0
            $fSize = @filesize($entry);
            $f["size"] = $fSize;
            $f["fullSize"] = number_format($fSize, 0, ".", ",");
            $f["niceSize"] = nicesize($fSize);
            $pi = pathinfo($entry);
            $f["type"] = $pi["extension"];
            $f["link"] = myEncode($path, $entry);
            if (in_array("cvsversion", $displayColumns)) {
                $f["cvsversion"] = getVersion($entry);
            }
        }
    }
    if (!$f["isBack"]) {
        $f["displayName"] = htmlentities(iTrunc($f["name"], $truncateLength));
    }
    $f["filetype"] = getFileType($f);
    $f["icon"] = getIcon($f["filetype"]);
    if ($useAutoThumbnails && $f["filetype"] == "image") {
        $f["thumbnail"] = "<a href=\"" . urldecode($f["link"]) . "\"><img src=\"" . $PHP_SELF . "?thumbnail=" . urlencode($path . $f["name"]) . "\" style=\"text-align: left;\" alt=\"\"/></a>";
    }
    $files[] = $f;
}
usort($files, "myCompare");
$pagingInEffect = $usePaging > 0 && count($files) > $usePaging;
if ($usePaging > 0) {
    $pageStart = $_GET["start"];
    if ($pageStart == "" || $pageStart < 0 || $pageStart > count($files)) {
        $pageStart = 0;
    }
    $pagingActualPage = floor($pageStart / $usePaging);
    $pagingNumberOfPages = ceil(count($files) / $usePaging);
Esempio n. 14
0
function getThumbnails()
{
    global $sortOrder;
    global $showTypes;
    global $timeFilter, $timeFilterMax;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    $nowTime = time();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            if ($timeFilter == 1) {
                $include = true;
            } else {
                $timeD = $nowTime - filemtime(MEDIA_PATH . "/{$file}");
                if ($timeFilter == $timeFilterMax) {
                    $include = $timeD >= 86400 * ($timeFilter - 1);
                } else {
                    $include = $timeD >= 86400 * ($timeFilter - 2) && $timeD < ($timeFilter - 1) * 86400;
                }
            }
            if ($include) {
                $fType = getFileType($file);
                if ($showTypes == '1') {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '2' && ($fType == 'i' || $fType == 't')) {
                    $thumbnails[] = $file;
                } elseif ($showTypes == '3' && $fType == 'v') {
                    $thumbnails[] = $file;
                }
            }
        }
    }
    return $thumbnails;
}
Esempio n. 15
0
function openFile()
{
    global $sage_data_dir;
    $filename = $_REQUEST["filename"];
    if ($path = "") {
        return false;
    }
    $fspath = $sage_data_dir . $_SESSION["path"] . "/" . $filename;
    if (!file_exists($fspath)) {
        return false;
    }
    $filesize = filesize($fspath);
    $mime = getFileType($fspath);
    header("Content-Type: {$mime}");
    header("Content-Disposition: attachment; filename={$filename}");
    //header("Content-Length: $filesize ");
    readfile($fspath);
}
Esempio n. 16
0
<?php

$target_dir = "media/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$file_type = getFileType($_FILES["file"]["name"]);
//Only mp3 and ogg file supported
if ($file_type != "mp3" && $file_type != "ogg") {
    echo "Sorry, only MP3 & OGG files are allowed.";
    return;
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    return;
}
// Try to upload to server
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
    $response = "The file has been uploaded.";
    echo $response;
    return;
} else {
    $response = "Sorry, there was an error uploading your file.";
    echo $response;
    return;
}
function getFileType($file)
{
    $path_chunks = explode("/", $file);
    $thefile = $path_chunks[count($path_chunks) - 1];
    $dotpos = strrpos($thefile, ".");
    return strtolower(substr($thefile, $dotpos + 1));
Esempio n. 17
0
function putFile2AmazonS3($fileName, $path)
{
    $key = "AKIAJ2DAWLHW6BGOQUTA";
    $secret = "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";
    $s3 = new S3($key, $secret);
    //$bucket = "slot-saga";
    $bucket = "res.enjoygameinc.com";
    $url = $fileName;
    $contentType = getFileType($fileName);
    if ($s3->putObjectFile($path, $bucket, $url, S3::ACL_PUBLIC_READ, array(), $contentType)) {
        return true;
    }
    return false;
}
Esempio n. 18
0
         getLink('', '', _LANG('a5001', 'mediaset'), '');
     }
     if (!$FTP_CRESULT) {
         getLink('', '', _LANG('a5001', 'mediaset'), '');
     }
     if ($d['mediaset']['ftp_pasv']) {
         ftp_pasv($FTP_CONNECT, true);
     }
     ftp_chdir($FTP_CONNECT, $d['mediaset']['ftp_folder']);
 }
 for ($i = 0; $i < $upfileNum; $i++) {
     $name = strtolower($_FILES['upfiles']['name'][$i]);
     $size = $_FILES['upfiles']['size'][$i];
     $fileExt = getExt($name);
     $fileExt = $fileExt == 'jpeg' ? 'jpg' : $fileExt;
     $type = getFileType($fileExt);
     $tmpname = md5($name) . substr($date['totime'], 8, 14);
     $tmpname = $type == 5 ? $tmpname . '.' . $fileExt : $tmpname;
     $hidden = $type == 5 ? 1 : 0;
     if ($fileExt != 'mp4') {
         continue;
     }
     if ($fserver) {
         for ($j = 1; $j < 4; $j++) {
             ftp_mkdir($FTP_CONNECT, $d['mediaset']['ftp_folder'] . str_replace('./files/', '', ${'savePath' . $j}));
         }
         ftp_put($FTP_CONNECT, $d['mediaset']['ftp_folder'] . $folder . '/' . $tmpname, $_FILES['upfiles']['tmp_name'][$i], FTP_BINARY);
     } else {
         for ($j = 1; $j < 4; $j++) {
             if (!is_dir(${'savePath' . $j})) {
                 mkdir(${'savePath' . $j}, 0707);
Esempio n. 19
0
             mkdir(${'savePath' . $i}, 0707);
             @chmod(${'savePath' . $i}, 0707);
         }
     }
 }
 for ($i = 0; $i < $num_upfile + $num_photo; $i++) {
     if (!$_FILES['upfile']['tmp_name'][$i]) {
         continue;
     }
     $width = 0;
     $height = 0;
     $up_name = strtolower($_FILES['upfile']['name'][$i]);
     $up_size = $_FILES['upfile']['size'][$i];
     $up_fileExt = getExt($up_name);
     $up_fileExt = $up_fileExt == 'jpeg' ? 'jpg' : $up_fileExt;
     $up_type = getFileType($up_fileExt);
     $up_tmpname = md5($up_name) . substr($date['totime'], 8, 14);
     $up_tmpname = $up_type == 2 ? $up_tmpname . '.' . $up_fileExt : $up_tmpname;
     $up_mingid = getDbCnt($table['s_upload'], 'min(gid)', '');
     $up_gid = $up_mingid ? $up_mingid - 1 : 100000000;
     $up_saveFile = $savePath3 . '/' . $up_tmpname;
     $up_hidden = $up_type == 2 ? 1 : 0;
     if ($fserver) {
         if ($up_type == 2) {
             $up_thumbname = md5($up_tmpname);
             $up_thumbFile = $g['path_tmp'] . 'backup/' . $up_thumbname;
             ResizeWidth($_FILES['upfile']['tmp_name'][$i], $up_thumbFile, 150);
             $IM = getimagesize($_FILES['upfile']['tmp_name'][$i]);
             $width = $IM[0];
             $height = $IM[1];
             ftp_put($FTP_CONNECT, $d['upload']['ftp_folder'] . $up_folder . '/' . $up_thumbname, $up_thumbFile, FTP_BINARY);
Esempio n. 20
0
 $subpath = $settingInfo['attachDir'] == "1" ? date("Ym") . "/" : "";
 $path = "../attachments/" . $subpath;
 $fileName = $_FILES["attfile"]["name"];
 $fileSize = $_FILES["attfile"]["size"];
 $updateStyle = $_FILES["attfile"]["type"];
 $info = $fileName . " (" . formatFileSize($fileSize) . ")";
 $attdesc = trim($_POST['attdesc']);
 //可以为空
 $attachment = upload_file($attachment_file, $fileName, $path);
 if ($attachment == "") {
     print_message($strAttachmentsError);
     $action = "";
 } else {
     $value = $subpath . $attachment;
     $basefile = "../attachments/" . $value;
     $fileType = getFileType($fileName);
     if ($imageAtt = getimagesize($path . $attachment)) {
         $fileWidth = $imageAtt[0];
         $fileHeight = $imageAtt[1];
     } else {
         $fileWidth = 0;
         $fileHeight = 0;
     }
     // 判断是否为图片格式
     if ($fileType == 'gif' || $fileType == 'jpg' || $fileType == 'jpeg' || $fileType == 'png') {
         // 判断是否使用缩略图
         if ($settingInfo['genThumb'] == "1") {
             $tsize = explode('x', strtolower($settingInfo['thumbSize']));
             if ($fileWidth > $tsize[0] || $fileHeight > $tsize[1]) {
                 $attach_thumb = array('filepath' => "../attachments/" . $value, 'filename' => $attachment, 'extension' => $fileType, 'thumbswidth' => $tsize[0], 'thumbsheight' => $tsize[1]);
                 $thumb_data = generate_thumbnail($attach_thumb);
function purgeFiles()
{
    global $schedulePars;
    $videoHours = $schedulePars[SCHEDULE_PURGEVIDEOHOURS];
    $imageHours = $schedulePars[SCHEDULE_PURGEIMAGEHOURS];
    $lapseHours = $schedulePars[SCHEDULE_PURGELAPSEHOURS];
    $purgeCount = 0;
    if ($videoHours > 0 || $imageHours > 0 || $lapseHours > 0) {
        $files = scandir(BASE_DIR . '/' . MEDIA_PATH);
        $currentHours = time() / 3600;
        foreach ($files as $file) {
            if ($file != '.' && $file != '..' && isThumbnail($file)) {
                $fType = getFileType($file);
                $purgeHours = 0;
                switch ($fType) {
                    case 'i':
                        $purgeHours = $imageHours;
                        break;
                    case 't':
                        $purgeHours = $lapseHours;
                        break;
                    case 'v':
                        $purgeHours = $videoHours;
                        break;
                }
                if ($purgeHours > 0) {
                    $fModHours = filemtime(BASE_DIR . '/' . MEDIA_PATH . "/{$file}") / 3600;
                    if ($fModHours > 0 && $currentHours - $fModHours > $purgeHours) {
                        deleteFile($file);
                        $purgeCount++;
                    }
                }
            }
        }
    }
    if ($schedulePars[SCHEDULE_PURGESPACEMODE] > 0) {
        $totalSize = disk_total_space(BASE_DIR . '/' . MEDIA_PATH) / 1024;
        //KB
        $level = str_replace(array('%', 'G', 'B', 'g', 'b'), '', $schedulePars[SCHEDULE_PURGESPACELEVEL]);
        switch ($schedulePars[SCHEDULE_PURGESPACEMODE]) {
            case 1:
            case 2:
                $level = min(max($schedulePars[SCHEDULE_PURGESPACELEVEL], 3), 97) * $totalSize / 100;
                break;
            case 3:
            case 4:
                $level = $level * 1048576.0;
                break;
        }
        switch ($schedulePars[SCHEDULE_PURGESPACEMODE]) {
            case 1:
                //Free Space
            //Free Space
            case 3:
                $currentAvailable = disk_free_space(BASE_DIR . '/' . MEDIA_PATH) / 1024;
                //KB
                //writeLog(" free space purge total $totalSize current: $currentAvailable target: $level");
                if ($currentAvailable < $level) {
                    $pFiles = getSortedFiles(false);
                    //files in latest to earliest order
                    while ($currentAvailable < $level && count($pFiles) > 0) {
                        $currentAvailable += deleteFile(array_pop($pFiles));
                        $purgeCount++;
                    }
                }
                //writeLog("Finished. Current now: $currentAvailable");
                break;
            case 2:
                // Max usage
            // Max usage
            case 4:
                $pFiles = getSortedFiles(false);
                //files in latest to earliest order
                //writeLog(" Max space purge max: $level");
                foreach ($pFiles as $pFile) {
                    $del = $level <= 0;
                    $level -= deleteFile($pFile, $del);
                    if ($del) {
                        $purgeCount++;
                    }
                }
                break;
        }
    }
    if ($purgeCount > 0) {
        writeLog("Purged {$purgeCount} Files");
    }
}
Esempio n. 22
0
     print $_lang[CatNewSiteSuccess] . "<br><br>";
     $sub2 = 'list';
 } else {
     if ($sub == 'edit2') {
         if ($id) {
             @mysql_query("update catalog set title='{$title}',url='{$url}',opisanie='{$opisanie}' where id='{$id}' and uid='" . $_SESSION["userId"] . "'") or die("File: " . __FILE__ . "<BR>Line: " . __LINE__ . "<BR>MySQL Error: " . mysql_error());
             print $_lang[CatSiteEditSuccess] . "<br><br>";
             $sub2 = 'list';
         } else {
             print $_lang[ErrorBadId] . "<br><br>";
             $sub2 = 'list';
         }
     }
 }
 if ($catalogImageEnable and $id and $_FILES['userfile']['name'] != '' and $_FILES['userfile']['type'] != '' and $_FILES['userfile']['tmp_name'] != '') {
     $type = getFileType($_FILES['userfile']['tmp_name']);
     if ($type == "image/jpeg" or $type == "image/gif" or $type == "image/png") {
         $ext = mb_split('/', $type);
         $ext = $ext[1];
         $file = "./_rootimages/banners/cat_" . $_SESSION["userId"] . "_" . $id . ".";
         @unlink($file . "gif");
         @unlink($file . "jpg");
         @unlink($file . "png");
         if (move_uploaded_file($_FILES['userfile']['tmp_name'], $file . $ext)) {
             @chmod($file . $ext, 0777);
         } else {
             print $_lang["CatSiteImageCantMove"] . "<br><BR>";
         }
     } else {
         print $_lang["CatSiteImageWrongType"] . "<br><BR>";
     }
@(require "flowcms/lib/editor/editor/filemanager/connectors/php/config.php");
init_adodb();
global $cfg, $db;
$tbl_attachment = $cfg['tbl_attachment'];
extract($_GET);
extract($_POST);
$sql = "select id,formername,filename,mime,dt,cache from {$tbl_attachment} order by id desc";
$rs = $db->Execute($sql);
echo "start";
while ($arr = $rs->FetchRow($rs)) {
    $arr['cache'] = 0;
    if ($arr['cache'] == 0) {
        $dt = $arr['dt'];
        $file_dir = $cfg['AttachmentDir'] . date("Y-m", strtotime($attachment['dt'])) . "/";
        if (!file_exists(Server_MapPath($file_dir . $arr['filename']))) {
            $file_dir = getFileType($arr['mime']) . date("Y-m", strtotime($arr['dt'])) . "/";
        }
        if (!file_exists(Server_MapPath($file_dir . $arr['filename']))) {
            $file_dir = $cfg['_AttachmentDir'] . date("Y-m", strtotime($arr['dt'])) . "/";
        }
        if (file_exists(Server_MapPath($file_dir . $arr['filename']))) {
            $file_name = $arr['filename'];
            $path = Server_MapPath($file_dir . $file_name);
            $file = fopen($path, "r");
            $filesize = filesize($path);
            $concent = addslashes(fread($file, $filesize));
            fclose($file);
            $id = $arr['id'];
            echo $id . "#<br>";
            flush();
            $sql = "update {$tbl_attachment} set cache = 1,size = {$filesize} where id = {$id}";
Esempio n. 24
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
    // ------------------------
    // Set the state2 variable depending on the file extension !!!!!
    // ------------------------
    if (getFileType($net2ftp_globals["entry"]) == "IMAGE") {
        $filetype = "image";
    } elseif ($filename_extension == "swf") {
        $filetype = "flash";
    } else {
        $filetype = "text";
    }
    // Form name, back and forward buttons
    $formname = "ViewForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Next screen
    $nextscreen = 2;
    // -------------------------------------------------------------------------
    // Text
    // -------------------------------------------------------------------------
    if ($filetype == "text") {
        // Title
        $title = __("View file %1\$s", $net2ftp_globals["entry"]);
        // ------------------------
        // luminous_text
        // ------------------------
        setStatus(2, 10, __("Reading the file"));
        $luminous_text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // ------------------------
        // luminous_language
        // ------------------------
        $luminous_language = "";
        $list_language_extensions = array('html' => array('html', 'htm'), 'javascript' => array('js'), 'css' => array('css'), 'php' => array('php', 'php5', 'phtml', 'phps'), 'perl' => array('pl', 'pm', 'cgi'), 'sql' => array('sql'), 'java' => array('java'), 'ada' => array('a', 'ada', 'adb', 'ads'), 'as' => array('as'), 'asp' => array('asp'), 'cpp' => array('cpp'), 'csharp' => array('csharp'), 'diff' => array('diff'), 'go' => array('go'), 'latex' => array('latex'), 'matlab' => array('matlab'), 'python' => array('py'), 'rails' => array('rails'), 'ruby' => array('ruby'), 'sql' => array('sql'), 'vb' => array('bas'), 'vim' => array('vim'), 'xml' => array('xml'));
        while (list($language, $extensions) = each($list_language_extensions)) {
            if (in_array($filename_extension, $extensions)) {
                $luminous_language = $language;
                break;
            }
        }
        // ------------------------
        // Call luminous
        // ------------------------
        setStatus(4, 10, __("Parsing the file"));
        $luminous_text = luminous::highlight($luminous_language, $luminous_text, FALSE);
    } elseif ($filetype == "image") {
        $title = __("View image %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $image_url = printPHP_SELF("view");
        $image_alt = __("Image") . $net2ftp_globals["entry"];
    } elseif ($filetype == "flash") {
        $title = __("View Macromedia ShockWave Flash movie %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $flash_url = printPHP_SELF("view");
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
Esempio n. 25
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    $filename_extension = get_filename_extension($net2ftp_globals["entry"]);
    // ------------------------
    // Set the state2 variable depending on the file extension !!!!!
    // ------------------------
    if (getFileType($net2ftp_globals["entry"]) == "IMAGE") {
        $filetype = "image";
    } elseif ($filename_extension == "swf") {
        $filetype = "flash";
    } else {
        $filetype = "text";
    }
    // Form name, back and forward buttons
    $formname = "ViewForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Next screen
    $nextscreen = 2;
    // -------------------------------------------------------------------------
    // Text
    // -------------------------------------------------------------------------
    if ($filetype == "text") {
        // Title
        $title = __("View file %1\$s", $net2ftp_globals["entry"]);
        // ------------------------
        // geshi_text
        // ------------------------
        setStatus(2, 10, __("Reading the file"));
        $geshi_text = ftp_readfile("", $net2ftp_globals["directory"], $net2ftp_globals["entry"]);
        if ($net2ftp_result["success"] == false) {
            return false;
        }
        // ------------------------
        // geshi_language
        // ------------------------
        $geshi_language = "";
        $list_language_extensions = array('html4strict' => array('html', 'htm'), 'javascript' => array('js'), 'css' => array('css'), 'php' => array('php', 'php5', 'phtml', 'phps'), 'perl' => array('pl', 'pm', 'cgi'), 'sql' => array('sql'), 'java' => array('java'), 'actionscript' => array('as'), 'ada' => array('a', 'ada', 'adb', 'ads'), 'apache' => array('conf'), 'asm' => array('ash', 'asm'), 'asp' => array('asp'), 'bash' => array('sh'), 'c' => array('c', 'h'), 'c_mac' => array('c'), 'caddcl' => array(), 'cadlisp' => array(), 'cpp' => array('cpp'), 'csharp' => array(), 'd' => array(''), 'delphi' => array('dpk'), 'diff' => array(''), 'email' => array('eml', 'mbox'), 'lisp' => array('lisp'), 'lua' => array('lua'), 'matlab' => array(), 'mpasm' => array(), 'nsis' => array(), 'objc' => array(), 'oobas' => array(), 'oracle8' => array(), 'pascal' => array('pas'), 'python' => array('py'), 'qbasic' => array('bi'), 'smarty' => array('tpl'), 'vb' => array('bas'), 'vbnet' => array(), 'vhdl' => array(), 'visualfoxpro' => array(), 'xml' => array('xml'));
        while (list($language, $extensions) = each($list_language_extensions)) {
            if (in_array($filename_extension, $extensions)) {
                $geshi_language = $language;
                break;
            }
        }
        // ------------------------
        // geshi_path
        // ------------------------
        $geshi_path = NET2FTP_APPLICATION_ROOTDIR . "/plugins/geshi/geshi/";
        // ------------------------
        // Call geshi
        // ------------------------
        setStatus(4, 10, __("Parsing the file"));
        $geshi = new GeSHi($geshi_text, $geshi_language, $geshi_path);
        $geshi->set_encoding(__("iso-8859-1"));
        $geshi->set_header_type(GESHI_HEADER_PRE);
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
        //		$geshi->enable_classes();
        $geshi->set_overall_style('border: 2px solid #d0d0d0; background-color: #f6f6f6; color: #000066; padding: 10px;', true);
        $geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
        $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
        $geshi->set_tab_width(4);
        $geshi_text = $geshi->parse_code();
    } elseif ($filetype == "image") {
        $title = __("View image %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $image_url = printPHP_SELF("view");
        $image_alt = __("Image") . $net2ftp_globals["entry"];
    } elseif ($filetype == "flash") {
        $title = __("View Macromedia ShockWave Flash movie %1\$s", htmlEncode2($net2ftp_globals["entry"]));
        $flash_url = printPHP_SELF("view");
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
Esempio n. 26
0
 if ($action == "edit" && $_GET['file_id'] != "") {
     //修改文件名。
     $title = "{$strAttachmentsTitleEdit}";
     $file_id = $_GET['file_id'];
     $file_title = getFieldValue($DBPrefix . "attachments", "where name like '%" . $file_id . "'", "attTitle");
     if ($file_title != "") {
         $file_title = substr($file_title, 0, strrpos($file_title, "."));
     }
     include "attachments_edit.inc.php";
 } else {
     //查找和浏览
     $title = "{$strAttachmentsTitle}";
     $handle = opendir("{$basedir}");
     while ($file = readdir($handle)) {
         if (is_file($basedir . $file)) {
             $filetype = getFileType($file);
             if ($seektype != "") {
                 if (strpos(";{$seektype}", $filetype) > 0) {
                     $filelist[] = $file;
                 }
             } else {
                 if ($seekname != "") {
                     if (strpos(";{$file}", $seekname) > 0) {
                         $filelist[] = $file;
                     }
                 } else {
                     $filelist[] = $file;
                 }
             }
         }
         if (is_dir($basedir . $file) && $file != "." && $file != "..") {
function browseFolder($folder, $mode)
{
    // Scan the target directory
    $directory = JAPPIX_BASE . '/store/' . $folder;
    $scan = scandir($directory);
    $scan = array_diff($scan, array('.', '..', '.svn', 'index.html'));
    $keep_get = keepGet('(s|b|k)', false);
    // Odd/even marker
    $marker = 'odd';
    // Not in the root folder: show previous link
    if (strpos($folder, '/') != false) {
        // Filter the folder name
        $previous_folder = substr($folder, 0, strrpos($folder, '/'));
        echo '<div class="one-browse previous manager-images"><a href="./?b=' . $mode . '&s=' . urlencode($previous_folder) . $keep_get . '">' . T_("Previous") . '</a></div>';
    }
    // Empty or non-existing directory?
    if (!count($scan) || !is_dir($directory)) {
        echo '<div class="one-browse ' . $marker . ' alert manager-images">' . T_("The folder is empty.") . '</div>';
        return false;
    }
    // Echo the browsing HTML code
    foreach ($scan as $current) {
        // Generate the item path$directory
        $path = $directory . '/' . $current;
        $file = $folder . '/' . $current;
        // Directory?
        if (is_dir($path)) {
            $type = 'folder';
            $href = './?b=' . $mode . '&s=' . urlencode($file) . $keep_get;
            $target = '';
        } else {
            $type = getFileType(getFileExt($path));
            $href = $path;
            $target = ' target="_blank"';
        }
        echo '<div class="one-browse ' . $marker . ' ' . $type . ' manager-images"><a href="' . $href . '"' . $target . '>' . htmlspecialchars($current) . '</a><input type="checkbox" name="element_' . md5($file) . '" value="' . htmlspecialchars($file) . '" /></div>';
        // Change the marker
        if ($marker == 'odd') {
            $marker = 'even';
        } else {
            $marker = 'odd';
        }
    }
    return true;
}
Esempio n. 28
0
function getContentType($entry)
{
    // --------------------
    // Content-type, for a complete list, see http://www.isi.edu/in-notes/iana/assignments/media-types/media-types
    // Content-disposition: attachment. See http://www.w3.org/Protocols/HTTP/Issues/content-disposition.txt
    // --------------------
    // Default values
    $fileType = getFileType($entry);
    $content_type = "application/octet-stream";
    if (get_filename_extension($entry) == "swf") {
        $content_type = "application/x-shockwave-flash";
    } elseif ($fileType == "TEXT") {
        $content_type = "text/plain";
    } elseif ($fileType == "IMAGE") {
        if (strpos($entry, ".jpg") !== false) {
            $content_type = "image/jpeg";
        } elseif (strpos($entry, ".png") !== false) {
            $content_type = "image/png";
        } elseif (strpos($entry, ".gif") !== false) {
            $content_type = "image/gif";
        }
    } elseif ($fileType == "ARCHIVE") {
        if (strpos($entry, ".zip") !== false) {
            $content_type = "application/zip";
        }
    } elseif ($fileType == "OFFICE") {
        if (strpos($entry, ".doc") !== false) {
            $content_type = "application/msword";
        } elseif (strpos($entry, ".xls") !== false) {
            $content_type = "application/vnd.ms-excel";
        } elseif (strpos($entry, ".ppt") !== false) {
            $content_type = "application/vnd.ms-powerpoint";
        } elseif (strpos($entry, ".mpp") !== false) {
            $content_type = "application/vnd.ms-project";
        }
    }
    return $content_type;
}
Esempio n. 29
0
     // Calculate margin
     if ($config['thumbnail.height'] - $imageSize['height'] > 0) {
         $fileItem['margin'] = ($config['thumbnail.height'] - $imageSize['height']) / 2;
     }
 } else {
     $fileItem['width'] = $config['thumbnail.width'];
     $fileItem['height'] = $config['thumbnail.height'];
 }
 $fileItem['name'] = basename($file->getAbsolutePath());
 $fileItem['path'] = $file->getAbsolutePath();
 $fileItem['modificationdate'] = date($config['filesystem.datefmt'], $file->lastModified());
 $fileItem['even'] = $even;
 $fileItem['hasReadAccess'] = $file->canRead() && checkBool($config["filesystem.readable"]) ? "true" : "false";
 $fileItem['hasWriteAccess'] = $file->canWrite() && checkBool($config["filesystem.writable"]) ? "true" : "false";
 // File info
 $fileType = getFileType($file->getAbsolutePath());
 $fileItem['icon'] = $fileType['icon'];
 $fileItem['type'] = $fileType['type'];
 $fileItem['ext'] = $fileType['ext'];
 $fileItem['editable'] = $isGD && ($fileType['ext'] == "gif" || $fileType['ext'] == "jpg" || $fileType['ext'] == "jpeg" || $fileType['ext'] == "png");
 // Preview path
 $wwwroot = removeTrailingSlash(toUnixPath(getWWWRoot($config)));
 $urlprefix = removeTrailingSlash(toUnixPath($config['preview.urlprefix']));
 $urlsuffix = toUnixPath($config['preview.urlsuffix']);
 $fileItem['previewurl'] = "";
 $pos = strpos($filepath, $wwwroot);
 if ($pos !== false && $pos == 0) {
     $fileItem['previewurl'] = $urlprefix . substr($filepath, strlen($wwwroot)) . $urlsuffix;
 } else {
     $fileItem['previewurl'] = "ERROR IN PATH";
 }
Esempio n. 30
0
function getThumbnails()
{
    global $sortOrder;
    global $showTypes;
    $files = scandir(MEDIA_PATH, $sortOrder - 1);
    $thumbnails = array();
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && isThumbnail($file)) {
            $fType = getFileType($file);
            if ($showTypes == '1') {
                $thumbnails[] = $file;
            } elseif ($showTypes == '2' && ($fType == 'i' || $fType == 't')) {
                $thumbnails[] = $file;
            } elseif ($showTypes == '3' && $fType == 'v') {
                $thumbnails[] = $file;
            }
        }
    }
    return $thumbnails;
}