Beispiel #1
0
function thumb($filename, $destination = null, $dst_w = null, $dst_h = null, $isReservedSource = true, $scale = 0.5)
{
    //getimagesize() —— 取得图片的长宽。
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", null, $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    //imagecopyresampled — 重采样拷贝部分图像并调整大小
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, TRUE);
    }
    $dstFilename = $destination = null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
Beispiel #2
0
function readDirR($dir = "./", $base_path = './', $mp = '')
{
    if ($listing = opendir($dir)) {
        $return = array();
        while (($entry = readdir($listing)) !== false) {
            if ($entry != "." && $entry != ".." && substr($entry, 0, 1) != '.') {
                $dir = preg_replace("/^(.*)(\\/)+\$/", "\$1", $dir);
                $item = $dir . "/" . $entry;
                $isfile = is_file($item);
                $dirend = $isfile ? '' : '/';
                $path_to_file = $dir . "/" . $entry . $dirend;
                $path_to_file = str_replace($mp, $base_path, $path_to_file);
                $link = '<a rel="' . getExt($entry) . '" href="' . $path_to_file . '">' . $entry . '</a>';
                if ($isfile && isValidFile($entry)) {
                    $return[] = $link;
                } elseif (is_dir($item)) {
                    $return[$link] = readDirR($item, $base_path, $mp);
                } else {
                }
            } else {
            }
        }
        return $return;
    } else {
        die('Can\'t read directory.');
    }
}
/**
 * 生成缩略图
 * @param string $filename
 * @param string $destination
 * @param int $dst_w
 * @param int $dst_h
 * @param bool $isReservedSource
 * @param number $scale
 * @return string
 */
function thumb($filename, $destination = null, $dst_w, $dst_h = NULL, $isReservedSource = true)
{
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if ($src_w <= $dst_w) {
        $dst_w = $src_w;
        $dst_h = $src_h;
    }
    if (is_null($dst_h)) {
        $dst_h = scaling($src_w, $src_h, $dst_w);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, true);
    }
    $dstFilename = $destination == null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
Beispiel #4
0
function thumb($filename, $destination = null, $dst_w = null, $dst_h = null, $isReservedSource = false, $scale = 0.5)
{
    list($src_w, $src_h, $imagetype) = getimagesize($filename);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($filename);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    //image_50/sdfsdkfjkelwkerjle.jpg
    if ($destination && !file_exists(dirname($destination))) {
        mkdir(dirname($destination), 0777, true);
    }
    $dstFilename = $destination == null ? getUniName() . "." . getExt($filename) : $destination;
    $outFun($dst_image, $dstFilename);
    imagedestroy($src_image);
    imagedestroy($dst_image);
    if (!$isReservedSource) {
        unlink($filename);
    }
    return $dstFilename;
}
 /**
  * Moving file from MASS UPLOAD DIR TO TEMP DIR
  */
 function move_to_temp($file_arr, $file_key)
 {
     $file = $file_arr['file'];
     $mass_file = MASS_UPLOAD_DIR . '/' . $file;
     $temp_file = TEMP_DIR . '/' . $file_key . '.' . getExt($file);
     if (file_exists($mass_file) && is_file($mass_file)) {
         rename($mass_file, $temp_file);
         //copy($mass_file,$temp_file);
         return $file_key . '.' . getExt($file);
     }
     return false;
 }
Beispiel #6
0
function createThumbnail($originImg)
{
    $thumnailExt = getExt($originImg);
    //拡張子によって作り方を変える
    switch ($thumnailExt) {
        case 'jpg':
            $sImg = imagecreatefromjpeg(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'jpeg':
            $sImg = imagecreatefromjpeg(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'png':
            $sImg = imagecreatefrompng(PHOTO_FOLDER . "/" . $originImg);
            break;
        case 'gif':
            $sImg = imagecreatefromgif(PHOTO_FOLDER . "/" . $originImg);
            break;
    }
    //画像の幅と高さを取得する
    $width = imagesx($sImg);
    $height = imagesy($sImg);
    if ($width > $height) {
        $size = $height;
        $x = floor(($width - $height) / 2);
        $y = 0;
        $width = $size;
    } else {
        $side = $width;
        $y = floor(($height - $width) / 2);
        $x = 0;
        $height = $side;
    }
    //サムネイルの大きさを決める
    $thumbnail_width = 200;
    $thumbnail_height = 200;
    $thumbnail = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
    imagecopyresized($thumbnail, $sImg, 0, 0, $x, $y, $thumbnail_width, $thumbnail_height, $width, $height);
    switch ($thumnailExt) {
        case 'jpg':
            imagejpeg($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'jpeg':
            imagejpeg($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'png':
            imagepng($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
        case 'gif':
            imagegif($thumbnail, THUMNAIL_FOLDER . "/s_" . $originImg);
            break;
    }
}
Beispiel #7
0
/**
 * Function used to validate embed code
 */
function validate_video_link($val)
{
    if (empty($val) || $val == 'none') {
        return 'none';
    } else {
        //checking file exension
        $validExts = array('flv', 'mp4');
        $ext = getExt($val);
        if (!in_array($ext, $validExts) || !stristr($val, 'http://') && !stristr($val, 'https://') && !stristr($val, 'rtsp://') && !stristr($val, 'rtmp://')) {
            return false;
        }
        return $val;
    }
}
Beispiel #8
0
 public function download()
 {
     $id = intval($_GET['id']);
     $this->loadModel('schnippet');
     $schnippet = new Schnippet();
     $schnippet->load($id);
     if ($schnippet->getMember('protected') == 'on' && (!isset($_SESSION[APP_SES . 'id']) || $_SESSION[APP_SES . 'id'] == 0)) {
         $_SESSION[APP_SES . 'route'] = '/application/schnippets&m=edit&id=' . $_GET['id'];
         gotoUrl('/?route=/users/users');
         exit;
     }
     // remove all non-alphanumeric characters from title to make filename then replace whitespace with underscores
     $title = cleanString($schnippet->getMember('title'));
     // get file extension
     $ext = getExt($schnippet->getMember('lang'));
     header("Content-Type: plain/text");
     header("Content-Disposition: Attachment; filename={$title}.{$ext}");
     header("Pragma: no-cache");
     echo $schnippet->getMember('code');
 }
Beispiel #9
0
/**
 * 生成缩略图
 * @param string $fileName
 * @param string $destination
 * @param int $dst_w
 * @param int $dst_h
 * @param number $scale
 * @param bool $isReservedSource
 * @return Ambigous <string, unknown>
 */
function thumb($fileName, $destination = null, $dst_w = null, $dst_h = null, $scale = 0.5, $isReservedSource = true)
{
    //得到文件类型
    list($src_w, $src_h, $imagetype) = getimagesize($fileName);
    if (is_null($dst_w) || is_null($dst_h)) {
        $dst_w = ceil($src_w * $scale);
        $dst_h = ceil($src_h * $scale);
    }
    $mime = image_type_to_mime_type($imagetype);
    //得到方法名,通过拼接字符串得到,这样子做是为了能够处理不同类型的图片
    $createFun = str_replace("/", "createfrom", $mime);
    $outFun = str_replace("/", null, $mime);
    $src_image = $createFun($fileName);
    $dst_image = imagecreatetruecolor($dst_w, $dst_h);
    imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);
    $destination = $destination == null ? getUniName() . '.' . getExt($fileName) : $destination;
    $outFun($dst_image, $destination);
    imagedestroy($dst_image);
    imagedestroy($src_image);
    if (!$isReservedSource) {
        unlink($fileName);
    }
    return $destination;
}
Beispiel #10
0
			echo '没有文件被上传。';
			break;

		default:;

	}

}

//处理文件过程

$pic = $_FILES['pic'];

//拼接文件路径

$path = './' . mk_dir() . '/' . randName() . '.' . getExt($pic['name']);

//移动
if(move_uploaded_file($pic['tmp_name'], $path)){
	echo '文件成功';
}else{
	echo  '上传失败';
	echo '<pre>';
	print_r($pic);
	echo '</pre>';
}

echo '<h3>程序运行结束!</h3>';


Beispiel #11
0
function uploadFile($path = "uploads", $allowExt = array("gif", "jpeg", "png", "jpg", "wbmp"), $maxSize = 2097152, $imgFlag = true)
{
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    $files = buildInfo();
    $i = 0;
    if (!($files && is_array($files))) {
        return;
    }
    foreach ($files as $file) {
        if ($file['error'] == UPLOAD_ERR_OK) {
            $ext = getExt($file['name']);
            // 检查文件扩展名
            if (!in_array($ext, $allowExt)) {
                exit("非法文件类型");
            }
            // 检查是否真正图片类型
            if ($imgFlag) {
                if (!getimagesize($file['tmp_name'])) {
                    exit("不是真正图片类型");
                }
            }
            // 上传文件的大小
            if ($file['size'] > $maxSize) {
                exit("上传文件过大");
            }
            // 是否通过HTTP POST上传
            if (!is_uploaded_file($file['tmp_name'])) {
                exit("不是通过HTTP POST方式上传");
            }
            $filename = getUniName() . "." . $ext;
            $destination = $path . "/" . $filename;
            if (move_uploaded_file($file['tmp_name'], $destination)) {
                $file['name'] = $filename;
                unset($file['error'], $file['tmp_name'], $file['size'], $file['type']);
                //注销没用信息
                $uploadedFiles[$i] = $file;
                $i++;
            }
        } else {
            switch ($file['error']) {
                case 1:
                    $mes = "超过了配置文件上传文件的大小";
                    // UPLOAD_ERR_INI_SIZE
                    break;
                case 2:
                    $mes = "超过了表单设置上传文件的大小";
                    // UPLOAD_ERR_FORM_SIZE
                    break;
                case 3:
                    $mes = "文件部分被上传";
                    // UPLOAD_ERR_PARTIAL
                    break;
                case 4:
                    $mes = "没有文件被上传";
                    // UPLOAD_ERR_NO_FILE
                    break;
                case 6:
                    $mes = "没有找到临时目录";
                    // UPLOAD_ERR_NO_TMP_DIR
                    break;
                case 7:
                    $mes = "文件不可写";
                    // UPLOAD_ERR_CANT_WRITE
                    break;
                case 8:
                    $mes = "由于PHP的扩展程序终端了文件上传";
                    // UPLOAD_ERR_EXTENSION
            }
            echo $mes;
        }
    }
    return $uploadedFiles;
}
            <tr<?php 
                    echo $bkg++ % 2 == 0 ? " class=\"okbf_line\"" : "";
                    ?>
>
              <td class="okbf_table_td1"><a href="<?php 
                    echo "{$fData['resource']}/{$value}";
                    ?>
" onclick="window.open('<?php 
                    echo "{$fData['resource']}/{$value}";
                    ?>
', 'fum_viewfile', 'resizable=yes,width=640,height=480,scrollbars=yes,status=no'); return false;"><?php 
                    echo $value;
                    ?>
</a></td>
              <td class="okbf_table_td2"><?php 
                    echo strtoupper(getExt($value));
                    ?>
</td>
              <td class="okbf_table_td2">
                <?php 
                    $file_size = filesize($fData['resource'] . "/{$value}");
                    if ($file_size >= 1073741824) {
                        echo number_format($file_size / 1073741824, 2) . " GB";
                    } else {
                        if ($file_size >= 1048576) {
                            echo number_format($file_size / 1048576, 2) . " MB";
                        } else {
                            if ($file_size >= 1024) {
                                echo number_format($file_size / 1024, 2) . " kB";
                            } else {
                                if ($file_size >= 0) {
<?php

if (!defined('__KIMS__')) {
    exit;
}
checkAdmin(0);
$folder = './';
$tmpname = $_FILES['upfile']['tmp_name'];
$realname = $_FILES['upfile']['name'];
$fileExt = strtolower(getExt($realname));
$extPath = $g['path_tmp'] . 'app';
$extPath1 = $extPath . '/';
$saveFile = $extPath1 . $date['totime'] . '.zip';
if (is_uploaded_file($tmpname)) {
    if (substr($realname, 0, 7) != 'rb_etc_') {
        getLink('', '', '기타자료 패키지가 아닙니다.', '');
    }
    if ($fileExt != 'zip') {
        getLink('', '', '패키지는 반드시 zip압축 포맷이어야 합니다.', '');
    }
    move_uploaded_file($tmpname, $saveFile);
    require $g['path_core'] . 'opensrc/unzip/ArchiveExtractor.class.php';
    require $g['path_core'] . 'function/dir.func.php';
    $extractor = new ArchiveExtractor();
    $extractor->extractArchive($saveFile, $extPath1);
    unlink($saveFile);
    $opendir = opendir($extPath1);
    while (false !== ($file = readdir($opendir))) {
        if ($file != '.' && $file != '..') {
            if (is_file($extPath1 . $file)) {
                if (is_file($folder . $file)) {
         $_message = $comment["message"] ? $comment["message"] : null;
         mysqli_stmt_execute($dbComment);
         $uids[$_user_id] = $comment["from"]["name"];
         $commentCount++;
         if (isset($comment["attachment"]["media"])) {
             switch ($comment["attachment"]["type"]) {
                 case "photo":
                     $_photo_id = $comment["attachment"]["target"]["id"];
                     $_attached_to = $comment["id"];
                     $_attached_type = "comment";
                     $_album_id = null;
                     $_owner_id = $comment["from"]["id"];
                     $_height = $comment["attachment"]["media"]["image"]["height"];
                     $_width = $comment["attachment"]["media"]["image"]["width"];
                     $_src = $comment["attachment"]["media"]["image"]["src"];
                     $_src_ext = getExt($comment["attachment"]["media"]["image"]["src"]);
                     $_caption = null;
                     $_permalink = $comment["attachment"]["url"];
                     mysqli_stmt_execute($dbPhoto);
                     $pids[] = $_photo_id;
                     $photoCount++;
                     break;
             }
         }
     }
 }
 if (isset($post["comments"]["paging"]["next"])) {
     $post["comments"] = getGraphPage($fb, $post["comments"]["paging"]["next"]);
 } else {
     break;
 }
Beispiel #15
0
header('content-type:text/html;charset=utf-8');
//1.给你一个文件名1.txt  1.jpeg 1.txt.png,
//得到文件的扩展名
/**
 * 得到文件的扩展名
 * @param string $filename
 * @return string
 */
function getExt($filename)
{
    $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
    return $ext;
}
echo getExt('1.txt.jpeg');
echo '<br/>';
echo getExt('2.php');
/**
* 默认得到日期2015年8月21日 星期五
// 2015-8-21 星期五 2015/8/21 星期五
* @param string $del1
* @param string $del2
* @param string $del3
* @return string
*/
function getDateStr($del1 = '年', $del2 = '月', $del3 = '日')
{
    $search = array(0, 1, 2, 3, 4, 5, 6);
    $replace = array('日', '一', '二', '三', '四', '五', '六');
    $subject = date('w');
    return date("Y{$del1}m{$del2}d{$del3} 星期") . str_replace($search, $replace, $subject);
}
Beispiel #16
0
 function upload_thumb($array)
 {
     global $file_name, $LANG;
     //Get File Name
     $file = $array['name'];
     $ext = getExt($file);
     $image = new ResizeImage();
     if (!empty($file) && file_exists($array['tmp_name']) && !error()) {
         if ($image->ValidateImage($array['tmp_name'], $ext)) {
             $file = BASEDIR . '/files/thumbs/' . $_POST['file_name'] . '.' . $ext;
             $bfile = BASEDIR . '/files/thumbs/' . $_POST['file_name'] . '.-big.' . $ext;
             if (!file_exists($file)) {
                 move_uploaded_file($array['tmp_name'], $file);
                 $image->CreateThumb($file, $bfile, config('big_thumb_width'), $ext, config('big_thumb_height'), false);
                 $image->CreateThumb($file, $file, THUMB_WIDTH, $ext, THUMB_HEIGHT, false);
             }
         } else {
             e(lang('vdo_thumb_up_err'));
         }
     } else {
         return true;
     }
 }
Beispiel #17
0
				<td width="40">번호</td>
				<td>파일명</td>
				<td width="70">소유자</td>
				<td width="70">퍼미션</td>
				<td width="70">용량</td>
				<td width="70">크기(px)</td>
				<td width="55">&nbsp;</td>
			</tr>
			<?php 
    $j = 0;
    for ($i = ($p - 1) * $recnum; $i <= ($p - 1) * $recnum + $recnum - 1; $i++) {
        if ($files[$i]) {
            $j++;
            ?>
			<?php 
            $file_ext = strtolower(getExt($files[$i]));
            ?>
			<?php 
            $file_ext = strlen($file_ext) < 5 ? $file_ext : 'txt';
            ?>
			<?php 
            $IM = array();
            if (strstr('jpeg,jpg,gif,png,swf', strtolower($file_ext))) {
                $IM = getimagesize($tdir . $files[$i]);
            }
            ?>

			<tr class="loop">
				<td><input type="checkbox" name="members[]" value="<?php 
            echo getKRtoUTF($files[$i]);
            ?>
Beispiel #18
0
/**
 * 上传文件
 * @param array $fileInfo
 * @param string $path
 * @param array $allowExt
 * @param int $maxSize
 * @return string
 */
function uploadFile($fileInfo, $path, $allowExt = array("gif", "jpeg", "jpg", "png", "txt", "doc"), $maxSize = 10485760)
{
    //判断错误号
    if ($fileInfo['error'] == UPLOAD_ERR_OK) {
        //文件是否是通过HTTP POST方式上传上来的
        if (is_uploaded_file($fileInfo['tmp_name'])) {
            //上传文件的文件名,只允许上传jpeg|jpg、png、gif、txt的文件
            //$allowExt=array("gif","jpeg","jpg","png","txt");
            $ext = getExt($fileInfo['name']);
            //取出扩展名
            $uniqid = getUniqidName();
            //产生一个唯一的文件
            $destination = $path . "/" . pathinfo($fileInfo['name'], PATHINFO_FILENAME) . "_" . $uniqid . "." . $ext;
            if (in_array($ext, $allowExt)) {
                if ($fileInfo['size'] <= $maxSize) {
                    if (move_uploaded_file($fileInfo['tmp_name'], $destination)) {
                        $mes = "文件上传成功";
                    } else {
                        $mes = "文件移动失败";
                    }
                } else {
                    $mes = "文件过大";
                }
            } else {
                $mes = "非法文件类型";
            }
        } else {
            $mes = "文件不是通过HTTP POST方式上传上来的";
        }
    } else {
        switch ($fileInfo['error']) {
            case 1:
                $mes = "超过了配置文件的大小";
                break;
            case 2:
                $mes = "超过了表单允许接收数据的大小";
                break;
            case 3:
                $mes = "文件部分被上传";
                break;
            case 4:
                $mes = "没有文件被上传";
                break;
        }
    }
    return $mes;
}
Beispiel #19
0
                upload_error("File has no name.");
                exit(0);
            }
        }
    }
}
//Check file size
$file_size = @filesize($_FILES['Filedata']["tmp_name"]);
if (!$file_size || $file_size > $max_file_size_in_bytes) {
    upload_error("File exceeds the maximum allowed size");
    exit(0);
}
//Checking file type
$types_array = preg_replace('/,/', ' ', $types);
$types_array = explode(' ', $types_array);
$file_ext = strtolower(getExt($_FILES['Filedata']['name']));
if (!in_array($file_ext, $types_array)) {
    upload_error("Invalid file extension");
    exit(0);
}
move_uploaded_file($tempFile, $targetFile);
$Upload->add_conversion_queue($targetFileName, $file_directory);
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN')) {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName}");
} else {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName} &> /dev/null &");
}
$status_array['success'] = 'yes';
$status_array['file_name'] = $file_name;
echo json_encode($status_array);
Beispiel #20
0
/**
 * 多文件上传
 *
 */
function uploadFiles($allowExt = array("gif", "jpeg", "jpg", "png", "wbmp"), $maxSize = 2097152, $imgFlag = true, $path = "uploads")
{
    // 检查文件夹
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    $i = 0;
    $files = @buildInfo();
    if (!isset($files)) {
        exit("请不要上传不能被识别的文件,错误:\$" . "_" . "FILES" . " is empty");
    }
    foreach ($files as $file) {
        $tmp_name = $file['tmp_name'];
        $error = $file['error'];
        $size = $file['size'];
        $type = $file['type'];
        $name = $file['name'];
        if ($error == UPLOAD_ERR_OK) {
            $ext = getExt($name);
            // 检查文件拓展名
            if (!in_array($ext, $allowExt)) {
                exit("非法文件类型");
            }
            // 检查大小
            if ($size > $maxSize) {
                exit("文件过大");
            }
            // 检查是否是使用POST HTTP方式上传
            if (!is_uploaded_file($tmp_name)) {
                exit("不是使用POST HTTP方式上传");
            }
            // 检查是否是图片类型
            if ($imgFlag && !getimagesize($tmp_name)) {
                exit("不是真正的图片类型");
            }
            $uniName = getUniName() . '.' . $ext;
            $destination = $path . "/" . $uniName;
            if (move_uploaded_file($tmp_name, $destination)) {
                $file['name'] = $uniName;
                unset($file['tmp_name'], $file['error'], $file['size'], $file['type']);
                $uploadedFiles[$i] = $file;
                $i++;
            }
        } else {
            switch ($error) {
                case 1:
                    $mes = "超过了配置文件上传文件的大小";
                    //UPLOAD_ERR_INI_SIZE
                    break;
                case 2:
                    $mes = "超过了表单设置上传文件的大小";
                    //UPLOAD_ERR_FORM_SIZE
                    break;
                case 3:
                    $mes = "文件部分被上传";
                    //UPLOAD_ERR_PARTIAL
                    break;
                case 4:
                    $mes = "没有文件被上传";
                    //UPLOAD_ERR_NO_FILE
                    break;
                case 6:
                    $mes = "没有找到临时目录";
                    //UPLOAD_ERR_NO_TMP_DIR
                    break;
                case 7:
                    $mes = "文件不可写";
                    //UPLOAD_ERR_CANT_WRITE;
                    break;
                case 8:
                    $mes = "由于PHP的扩展程序中断了文件上传";
                    //UPLOAD_ERR_EXTENSION
                    break;
            }
            echo $mes;
        }
    }
    return $uploadedFiles;
}
function getFiles($path)
{
    global $dirContents, $pathURL, $codeMirrorModes, $nonce, $tz_offset;
    $filePath = $path == '.' ? '/' : '/' . $path . '/';
    if (!count($dirContents['files'])) {
        return;
    }
    natcasesort($dirContents['files']);
    $codeMirrorExists = (int) is_dir(CODEMIRROR_PATH);
    $zipSupport = zipSupport();
    //tt edition
    $correctpath = str_ireplace(separator__WFMB($_SERVER['DOCUMENT_ROOT']), '', separator__WFMB(ROOT));
    $correctpath = str_ireplace('\\', '/', $correctpath);
    foreach ($dirContents['files'] as $dirItem) {
        $dirItemURL = escape($dirItem);
        $dirItemHTML = htmlspecialchars($dirItem);
        $fullPath = $path . '/' . $dirItem;
        $mtime = filemtime($fullPath);
        $mod = getMod($fullPath);
        $ext = getExt($dirItem);
        $cmSupport = in_array($ext, $codeMirrorModes) ? 'cp ' : '';
        echo '  <li title="' . $dirItemHTML . '">' . "\n\t" . '<a href="' . escape($correctpath . $filePath . $dirItem) . '" title="' . $dirItemHTML . '" class="file" id="' . $dirItemHTML . '" target="_blank">' . $dirItemHTML . '</a>' . (pathinfo($dirItem, PATHINFO_EXTENSION) == 'sql' ? ' &nbsp;&nbsp;(<a href="javascript:export_import_db(\'importt\',\'' . $dirItemHTML . '\')">RESTORE INTO DATABASE</a>)' : '') . "\n\t" . '<span class="fs"  title="file size">' . getfs($path . '/' . $dirItem) . '</span>' . "\n\t" . '<span class="extension" title="file extension">' . $ext . '</span>' . "\n\t" . '<span class="filemtime" title="' . date('c', $mtime) . '">' . date('y-m-d | H:i:s', $mtime + $tz_offset) . '</span>' . "\n\t" . '<span class="mode" title="mode">' . $mod . '</span>' . ($zipSupport && $ext == 'zip' ? "\n\t" . '<a href="?do=extract&amp;path=' . $pathURL . '&amp;subject=' . $dirItemURL . '&amp;nonce=' . $nonce . '" title="Extract ' . $dirItemHTML . '" class="extract b"></a>' : '') . (filesize($fullPath) <= 1048576 * MaxEditableSize ? "\n\t" . '<a href="#" title="Edit ' . $dirItemHTML . '" onclick="edit.init(\'' . $dirItemURL . '\', \'' . $pathURL . '\', \'' . $ext . '\', ' . $codeMirrorExists . '); return false;" class="edit ' . $cmSupport . 'b"></a>' : '') . "\n\t" . '<a href="#" title="Chmod ' . $dirItemHTML . '" onclick="fOp.chmod(\'' . $pathURL . '\', \'' . $dirItemURL . '\', \'' . $mod . '\'); return false;" class="chmod b"></a>' . "\n\t" . '<a href="#" title="Move ' . $dirItemHTML . '" onclick="fOp.moveList(\'' . $dirItemURL . '\', \'' . $pathURL . '\', \'' . $pathURL . '\'); return false;" class="move b"></a>' . "\n\t" . '<a href="#" title="Copy ' . $dirItemHTML . '" onclick="fOp.copy(\'' . $dirItemURL . '\', \'' . $pathURL . '\', \'' . $pathURL . '\'); return false;" class="copy b"></a>' . "\n\t" . '<a href="#" title="Rename ' . $dirItemHTML . '" onclick="fOp.rename(\'' . $dirItemHTML . '\', \'' . $pathURL . '\'); return false;" class="rename b"></a>' . "\n\t" . '<a href="?do=delete&amp;path=' . $pathURL . '&amp;subject=' . $dirItemURL . '&amp;nonce=' . $nonce . '" title="Delete ' . $dirItemHTML . '" onclick="return confirm(\'Are you sure you want to delete ' . removeQuotes($dirItem) . '?\');" class="del b"></a>' . "\n  </li>\n";
    }
}
Beispiel #22
0
 } else {
     if ($_POST['catedescription'] == NULL) {
         $error['description'] = '1';
     } else {
         if ($_POST['catekeyword'] == NULL) {
             $error['keyword'] = '1';
         } else {
             if ($_POST['catecate'] != NULL && !is_number($_POST['catecate'])) {
                 $error['cate'] = '2';
             } else {
                 if ($_POST['cateimagestatus'] == '1' && $_FILES['cateimage']['name'] != NULL) {
                     if (in_array(getExt($_FILES['cateimage']['name']), $mimes)) {
                         if ($_FILES["cateimage"]["size"] <= 1024 * 1024 * $size) {
                             $size = getimagesize($_FILES["cateimage"]["tmp_name"]);
                             if ($size[0] >= 1500 && $size[1] >= 280 && $size[0] / $size[1] > 5) {
                                 $name = md5(rand(0, 9999999)) . md5(rand(0, 9999999)) . "." . getExt($_FILES['cateimage']['name']);
                                 move_uploaded_file($_FILES["cateimage"]["tmp_name"], "../../upload/" . $name);
                                 if ($_POST['catecate'] != NULL) {
                                     $sql = "INSERT INTO `cate2`(`id1`, `title`, `description`, `keyword`, `title-wrapper`) VALUES ('" . $_POST['catecate'] . "','" . $_POST['catetitle'] . "','" . $_POST['catedescription'] . "','" . $_POST['catekeyword'] . "','upload/" . $name . "')";
                                 } else {
                                     $sql = "INSERT INTO `cate1`(`title`, `description`, `keyword`, `title-wrapper`) VALUES ('" . $_POST['catetitle'] . "','" . $_POST['catedescription'] . "','" . $_POST['catekeyword'] . "','upload/" . $name . "')";
                                 }
                                 @mysql_query($sql);
                                 $error['done'] = '1';
                             } else {
                                 $error['image'] = '4';
                             }
                         } else {
                             $error['image'] = '3';
                         }
                     } else {
Beispiel #23
0
     $FTP_CRESULT = ftp_login($FTP_CONNECT, $d['mediaset']['ftp_user'], $d['mediaset']['ftp_pass']);
     if (!$FTP_CONNECT) {
         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++) {
Beispiel #24
0
/**
 * 针对于单文件、多个单文件、多文件的上传
 * @param array $fileInfo
 * @param string $path
 * @param string $flag
 * @param number $maxSize
 * @param array $allowExt
 * @return string
 */
function uploadFile($fileInfo, $path = './uploads', $flag = true, $maxSize = 1048576, $allowExt = array('jpeg', 'jpg', 'png', 'gif'))
{
    //$flag=true;
    //$allowExt=array('jpeg','jpg','gif','png');
    //$maxSize=1048576;//1M
    //判断错误号
    if ($fileInfo['error'] === UPLOAD_ERR_OK) {
        //检测上传得到小
        if ($fileInfo['size'] > $maxSize) {
            $res['mes'] = $fileInfo['name'] . '上传文件过大';
        }
        $ext = getExt($fileInfo['name']);
        //检测上传文件的文件类型
        if (!in_array($ext, $allowExt)) {
            $res['mes'] = $fileInfo['name'] . '非法文件类型';
        }
        //检测是否是真实的图片类型
        if ($flag) {
            if (!getimagesize($fileInfo['tmp_name'])) {
                $res['mes'] = $fileInfo['name'] . '不是真实图片类型';
            }
        }
        //检测文件是否是通过HTTP POST上传上来的
        if (!is_uploaded_file($fileInfo['tmp_name'])) {
            $res['mes'] = $fileInfo['name'] . '文件不是通过HTTP POST方式上传上来的';
        }
        if ($res) {
            return $res;
        }
        //$path='./uploads';
        if (!file_exists($path)) {
            mkdir($path, 0777, true);
            chmod($path, 0777);
        }
        $uniName = getUniName();
        $destination = $path . '/' . $uniName . '.' . $ext;
        if (!move_uploaded_file($fileInfo['tmp_name'], $destination)) {
            $res['mes'] = $fileInfo['name'] . '文件移动失败';
        }
        $res['mes'] = $fileInfo['name'] . '上传成功';
        $res['dest'] = $destination;
        return $res;
    } else {
        //匹配错误信息
        switch ($fileInfo['error']) {
            case 1:
                $res['mes'] = '上传文件超过了PHP配置文件中upload_max_filesize选项的值';
                break;
            case 2:
                $res['mes'] = '超过了表单MAX_FILE_SIZE限制的大小';
                break;
            case 3:
                $res['mes'] = '文件部分被上传';
                break;
            case 4:
                $res['mes'] = '没有选择上传文件';
                break;
            case 6:
                $res['mes'] = '没有找到临时目录';
                break;
            case 7:
            case 8:
                $res['mes'] = '系统错误';
                break;
        }
        return $res;
    }
}
Beispiel #25
0
        return $ext[count($ext) - 1];
    }
    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');
Beispiel #26
0
 private function _receive_file($str, &$model)
 {
     if (!empty($str)) {
         $ar = explode(",", $str);
         foreach ($ar as $key => $value) {
             $ar2 = explode("_", $value);
             $cid = $ar2[0];
             $inline = $ar2[1];
             $file_name = $ar2[2];
             $File = M("File");
             $File->name = $file_name;
             $File->user_id = $this->get_user_id();
             $File->size = filesize($this->tmpPath . urlencode($value));
             $File->extension = getExt($value);
             $File->create_time = time();
             $dir = 'mail/' . date("Ym");
             $File->savename = $dir . '/' . uniqid() . '.' . $File->extension;
             $save_name = $File->savename;
             if (!is_dir(C("SAVE_PATH") . $dir)) {
                 mkdir(C("SAVE_PATH") . $dir, 0777, true);
             }
             if (rename($this->tmpPath . urlencode($value), C("SAVE_PATH") . $File->savename)) {
                 $file_id = $File->add();
                 if ($inline == "INLINE") {
                     $model->content = str_ireplace("cid:{$cid}", "/" . C("SAVE_PATH") . $save_name, $model->content);
                 }
                 $add_file = $add_file . $file_id . ';';
             }
         }
     }
     return $add_file;
 }
Beispiel #27
0
 private function _receive_file($str, &$model)
 {
     if (!empty($str)) {
         $ar = array_filter(explode(",", $str));
         foreach ($ar as $key => $value) {
             $ar2 = explode("_", $value);
             $cid = $ar2[0];
             if (true) {
                 //if(strlen($cid)>10){
                 $inline = $ar2[1];
                 $file_name = $ar2[2];
                 $File = M("File");
                 $File->name = $file_name;
                 $File->user_id = $model->user_id;
                 $File->size = filesize($this->tmpPath . urlencode($value));
                 $File->extension = getExt($value);
                 $File->create_time = time();
                 $sid = get_sid();
                 $File->sid = $sid;
                 $File->module = MODULE_NAME;
                 $dir = 'mail/' . get_emp_no() . "/" . date("Ym");
                 $File->savename = $dir . '/' . uniqid() . '.' . $File->extension;
                 $save_name = $File->savename;
                 if (!is_dir(get_save_path() . $dir)) {
                     mkdir(get_save_path() . $dir, 0777, true);
                     chmod(get_save_path() . $dir, 0777);
                 }
                 if (!is_dir($this->tmpPath . $dir)) {
                     mkdir($this->tmpPath . $dir, 0777, true);
                     chmod($this->tmpPath . $dir, 0777);
                 }
                 if (rename($this->tmpPath . urlencode($value), get_save_path() . $save_name)) {
                     $file_id = $File->add();
                     if ($inline == "INLINE") {
                         $model->content = str_replace("cid:" . $cid, "/" . get_save_path() . $save_name, $model->content);
                     } else {
                         $add_file = $add_file . $sid . ';';
                     }
                 }
             }
         }
         return $add_file;
     }
 }
Beispiel #28
0
		<?php 
$i = 0;
?>
		<?php 
$dirs = opendir($folder . $sfolder);
?>
		<?php 
while (false !== ($file = readdir($dirs))) {
    ?>
		<?php 
    if ($file == '.' || $file == '..') {
        continue;
    }
    ?>
		<?php 
    $fileExt = strtolower(getExt($file));
    ?>
		<?php 
    if (!strstr('[jpg][jpeg][png][gif]', $fileExt)) {
        continue;
    }
    ?>
		<?php 
    $IM = getimagessize($folder . $sfolder . $file);
    ?>
		<?php 
    $i++;
    ?>
	
		<div class="photo"><img src="<?php 
    echo $g['url_root'] . str_replace('./', '/', $folder) . $sfolder . $file;
Beispiel #29
0
<?php

require_once '../lib/string.func.php';
header("content-type:text/html;charset=utf-8");
//$_FILES
$filename = $_FILES['myFile']['name'];
$type = $_FILES['myFile']['type'];
$tmp_name = $_FILES['myFile']['tmp_name'];
$error = $_FILES['myFile']['error'];
$size = $_FILES['myFile']['size'];
$allowExt = array("gif", "jpeg", "jpg", "png", "wbmp");
$maxSize = 1512000;
$imgFlag = true;
//判断下错误信息
if ($error == UPLOAD_ERR_OK) {
    $ext = getExt($filename);
    //限制上传文件类型
    if (!in_array($ext, $allowExt)) {
        exit("非法文件类型");
    }
    if ($size > $maxSize) {
        exit("文件过大");
    }
    if ($imgFlag) {
        //如何验证图片是否是一个真正的图片类型
        //getimagesize($filename):验证文件是否是图片类型
        $info = getimagesize($tmp_name);
        //var_dump($info);exit;
        if (!$info) {
            exit("不是真正的图片类型");
        }
Beispiel #30
0
     for ($i = 1; $i < 4; $i++) {
         if (!is_dir(${'savePath' . $i})) {
             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];