コード例 #1
0
ファイル: phpWizard.php プロジェクト: rhempen/cms
// rotate - background-color
// filters
$phpThumb->fltr = $_REQUEST['fltr'];
// filter parameters
//-------------------------------------------------------------------------
// update image
$tfile = pathinfo($_REQUEST['src']);
$clib = $tfile['dirname'] . '/';
// current library
$nfile = $tfile['basename'];
// file name
$ext = strtolower($tfile['extension']);
// current extension
$path = str_replace('//', '/', $cfg['root_dir'] . $clib);
// remove double slash in path
$nfile = fixFileName($nfile);
// check file name
if (!isset($_REQUEST['nfi'])) {
    // if not set, new file will be created, otherwise existing file will be overwritten
    $nfile = chkFileName($path, $nfile);
    // rename file if new filename already exists
}
//-------------------------------------------------------------------------
// generate & output
if ($phpThumb->GenerateThumbnail()) {
    if (!$phpThumb->RenderToFile($path . $nfile)) {
        echo 'Failed: ' . implode("\n", $phpThumb->debugmessages);
    }
    @chmod($path . $nfile, 0755) or die('chmod didn\'t work');
    unset($phpThumb);
    // free up some memory
コード例 #2
0
ファイル: rfiles.php プロジェクト: burak-tekin/CMScout2
function uploadImg($clib, $chkT, $selR)
{
    global $cfg;
    global $l;
    if (!$cfg['upload']) {
        return false;
    }
    foreach ($_FILES['nfile']['size'] as $key => $size) {
        if ($size > 0) {
            // get file extension and check for validity
            $ext = pathinfo($_FILES['nfile']['name'][$key]);
            $ext = strtolower($ext['extension']);
            if (!in_array($ext, $cfg['valid'])) {
                // invalid image
                echo $l->m('er_029');
                return false;
            }
            $path = str_replace('//', '/', $cfg['root_dir'] . $clib);
            // remove double slash in path
            $nfile = fixFileName($_FILES['nfile']['name'][$key]);
            // remove invalid characters in filename
            // move file to temp directory for processing
            if (!move_uploaded_file($_FILES['nfile']['tmp_name'][$key], $cfg['temp'] . '/' . $nfile)) {
                // upload image to temp dir
                echo $l->m('er_028');
                return false;
            }
            $size = getimagesize($cfg['temp'] . '/' . $nfile);
            // process (thumbnail) images
            $arr = $cfg['thumbs'];
            foreach ($arr as $key => $thumb) {
                if (in_array($key, $chkT)) {
                    // create new phpThumb() object
                    require_once dirname(__FILE__) . '/phpThumb/phpthumb.class.php';
                    $phpThumb = new phpThumb();
                    // create object
                    // parameters
                    $phpThumb->config_cache_disable_warning = true;
                    // disable cache warning
                    $phpThumb->config_output_format = $ext;
                    // output format
                    $phpThumb->src = $cfg['temp'] . '/' . $nfile;
                    // destination
                    $phpThumb->q = 95;
                    // compression level for jpeg
                    if ($selR != '') {
                        // set auto rotate
                        $phpThumb->ar = $selR;
                    }
                    //-------------------------------------------------------------------------
                    if ($thumb['size'] > 0 && ($size[0] >= $thumb['size'] || $size[1] >= $thumb['size'])) {
                        // size value is set -> RESIZING and source image is larger than preset sizes
                        // resize parameters
                        if ($size[0] < $size[1]) {
                            // portrait
                            $phpThumb->h = $thumb['size'];
                            // max. height
                        } else {
                            $phpThumb->w = $thumb['size'];
                            // max. width
                        }
                        // crop parameters
                        if ($thumb['crop'] == true) {
                            $phpThumb->zc = 1;
                            // set zoom crop
                            $phpThumb->w = $thumb['size'];
                            // width
                            $phpThumb->h = $thumb['size'];
                            // height
                        }
                        // create file suffix
                        if ($thumb['ext'] == '*') {
                            // image size is used
                            $dim = '_' . $thumb['size'];
                            // e.g. _1280
                        } else {
                            if ($thumb['ext'] == '') {
                                // no suffix is created
                                $dim = '';
                            } else {
                                // suffix is set to $thumb['ext']
                                $dim = '_' . $thumb['ext'];
                            }
                        }
                        //-------------------------------------------------------------------------
                    } elseif ($thumb['size'] == 0 || $thumb['size'] == '*') {
                        // size value is set to '0' -> NO RESIZING
                        // crop parameters
                        if ($thumb['crop'] == true) {
                            $phpThumb->zc = 1;
                            // set zoom crop
                            if ($size[0] < $size[1]) {
                                // portrait
                                $phpThumb->w = $size[0];
                                // getimagesize width value
                                $phpThumb->h = $size[0];
                                // getimagesize width value
                            } else {
                                // landscape
                                $phpThumb->w = $size[1];
                                // getimagesize height value
                                $phpThumb->h = $size[1];
                                // getimagesize height value
                            }
                        }
                        // create file suffix
                        if ($thumb['ext'] == '*') {
                            // image size is used
                            $dim = '_' . ($size[0] <= $size[1] ? $size[1] : $size[0]);
                            // source height or width - e.g. _1280
                        } else {
                            if ($thumb['ext'] == '') {
                                // no suffix is created
                                $dim = '';
                            } else {
                                // suffix is set to $thumb['ext']
                                $dim = '_' . $thumb['ext'];
                            }
                        }
                        //-------------------------------------------------------------------------
                    } else {
                        // default setting - images smaller than predefined sizes
                        $dim = '';
                        // no file suffix is used
                    }
                    //-------------------------------------------------------------------------
                    $nthumb = fixFileName(basename($nfile, '.' . $ext) . $dim . '.' . $ext);
                    $nthumb = chkFileName($path, $nthumb);
                    // rename if file already exists
                    if ($phpThumb->GenerateThumbnail()) {
                        $phpThumb->RenderToFile($path . $nthumb);
                        @chmod($path . $nthumb, 0755) or die($l->m('er_028'));
                    } else {
                        // error
                        echo $l->m('er_028');
                        return false;
                    }
                    unset($phpThumb);
                }
            }
            @unlink($cfg['temp'] . '/' . $nfile);
            // delete temporary file
        }
    }
    return $nthumb;
}
コード例 #3
0
ファイル: files_delete.php プロジェクト: shaamimahmed/tsugi
require_once $CFG->dirroot . "/lib/lms_lib.php";
require_once "files_util.php";
use Tsugi\Core\Debug;
use Tsugi\Core\LTIX;
// Sanity checks
$LTI = LTIX::requireData();
$fn = $_REQUEST['file'];
if (strlen($fn) < 1) {
    die("File name not found");
}
$fn = fixFileName($fn);
$foldername = getFolderName();
$filename = $foldername . '/' . fixFileName($fn);
if (isset($_POST["doDelete"])) {
    $foldername = getFolderName();
    $filename = $foldername . '/' . fixFileName($_POST['file']);
    if (unlink($filename)) {
        $_SESSION['success'] = 'File deleted';
        header('Location: ' . addSession('index.php'));
    } else {
        $_SESSION['err'] = 'File delete failed';
        header('Location: ' . addSession('index.php'));
    }
    return;
}
// Switch to view / controller
$OUTPUT->header();
$OUTPUT->flashMessages();
echo '<h4 style="color:red">Are you sure you want to delete: ' . $fn . "</h4>\n";
?>
<form name=myform enctype="multipart/form-data" method="post">
コード例 #4
0
ファイル: files_serve.php プロジェクト: shaamimahmed/tsugi
<?php

require_once "../../config.php";
require_once $CFG->dirroot . "/pdo.php";
require_once $CFG->dirroot . "/lib/lms_lib.php";
require_once "files_util.php";
use Tsugi\Core\LTIX;
// Sanity checks
$LTI = LTIX::requireData();
$fn = $_REQUEST['file'];
if (strlen($fn) < 1) {
    die("File name not found");
}
$fn = fixFileName($fn);
$foldername = getFolderName();
$filename = $foldername . '/' . fixFileName($fn);
if (!file_exists($filename)) {
    die("File does not exist");
}
// Get the mime type
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// return mime type ala mimetype extension
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
// die($mimetype);
if (strlen($mimetype) > 0) {
    header('Content-Type: ' . $mimetype);
}
header('Content-Disposition: attachment; filename="' . $fn . '"');
echo readfile($filename);
コード例 #5
0
ファイル: index.php プロジェクト: shaamimahmed/tsugi
require_once $CFG->dirroot . "/lib/lms_lib.php";
require_once "files_util.php";
use Tsugi\Core\Debug;
use Tsugi\Core\LTIX;
// Sanity checks
$LTI = LTIX::requireData();
// Model
$p = $CFG->dbprefix;
if (isset($_FILES['uploaded_file']) && $_FILES['uploaded_file']['error'] == 1) {
    $_SESSION['error'] = 'Error: Maximum size of ' . maxUpload() . 'MB exceeded.';
    header('Location: ' . addSession('index.php'));
    return;
}
if (isset($_FILES['uploaded_file']) && $_FILES['uploaded_file']['error'] == 0) {
    $filename = strtolower(basename($_FILES['uploaded_file']['name']));
    $filename = fixFileName($filename);
    $foldername = getFolderName();
    $ext = "." . $ext;
    $newname = $foldername . '/' . $filename;
    if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $newname)) {
        $_SESSION['success'] = 'File uploaded';
        header('Location: ' . addSession('index.php'));
    } else {
        $_SESSION['err'] = 'File upload failed';
        header('Location: ' . addSession('index.php'));
    }
    return;
}
// Sometimes, if the maxUpload_SIZE is exceeded, it deletes all of $_POST
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $_SESSION['error'] = 'Error: Maximum size of ' . maxUpload() . 'MB exceeded.';
コード例 #6
0
ファイル: phpWizard.php プロジェクト: hungnv0789/vhtm
	// rotate
	$phpThumb->ra 	= $_REQUEST['ra'];												// rotate - angle
	$phpThumb->ar 	= $_REQUEST['ar'];												// rotate - type
	$phpThumb->bg 	= $_REQUEST['bg'];												// rotate - background-color
	
	// filters
	$phpThumb->fltr = $_REQUEST['fltr'];											// filter parameters	
	
	//-------------------------------------------------------------------------
	// update image	
	$tfile = pathinfo($_REQUEST['src']);
	$clib  = $tfile['dirname'] . '/'; 												// current library
	$nfile = $tfile['basename'];													// file name
    $ext   = strtolower($tfile['extension']);										// current extension
	$path  = str_replace('//', '/', $cfg['root_dir'] . $clib); 						// remove double slash in path	
	$nfile = fixFileName($nfile); 													// check file name	
	
	if (!isset($_REQUEST['nfi'])) {													// if not set, new file will be created, otherwise existing file will be overwritten	
		$nfile = chkFileName($path, $nfile);										// rename file if new filename already exists
	}
	
	//-------------------------------------------------------------------------
	// generate & output
  	if ($phpThumb->GenerateThumbnail()) {
    	if (!$phpThumb->RenderToFile($path . $nfile)) {    
    		echo 'Failed: ' . implode("\n", $phpThumb->debugmessages);
    	}
		@chmod($path . $nfile, 0755) or die('chmod didn\'t work');		
		unset($phpThumb); 															// free up some memory	
  	} else {
    	// do something with debug/error messages
コード例 #7
0
ファイル: rfiles.php プロジェクト: JovanyJeff/hrp
function uploadImg($clib, $chkT, $selR)
{
    global $cfg;
    global $l;
    if (!$cfg['upload']) {
        return false;
    }
    foreach ($_FILES['nfile']['size'] as $key => $size) {
        if ($size > 0) {
            // get file extension and check for validity
            $ext = pathinfo($_FILES['nfile']['name'][$key]);
            $mimeType = String::mime_content_type($_FILES['nfile']['tmp_name'][0]);
            $ext = strtolower($ext['extension']);
            if (!in_array($ext, $cfg['valid'])) {
                // invalid image (only checks extension)
                echo $l->m('er_029');
                return false;
            }
            if (!in_array($mimeType, $cfg['mimeTypes'])) {
                // invalid image (checks mime type)
                echo $l->m('er_029');
                return false;
            }
            $path = str_replace('//', '/', $cfg['root_dir'] . $clib);
            // remove double slash in path
            $nfile = fixFileName($_FILES['nfile']['name'][$key]);
            // remove invalid characters in filename
            // Check that the user doesn't exceed their upload limit:
            $newSize = dirsize($path) + $_FILES['nfile']['size'][$key];
            if ($newSize > $cfg['ulLimit'] && $cfg['ulLimit'] != 0) {
                echo 'Warning: Upload limit exceeded';
                return false;
            }
            // move file to temp directory for processing
            if (!move_uploaded_file($_FILES['nfile']['tmp_name'][$key], $path . '/' . $nfile)) {
                // upload image to temp dir
                echo $l->m('er_028');
                return false;
            }
            $size = getimagesize($path . '/' . $nfile);
            // process (thumbnail) images
            $arr = $cfg['thumbs'];
            foreach ($arr as $key => $thumb) {
                if (in_array($key, $chkT)) {
                    // create new phpThumb() object
                    require_once dirname(__FILE__) . '/phpThumb/ThumbLib.inc.php';
                    $phpThumb = PhpThumbFactory::create($path . '/' . $nfile);
                    // Create object
                    //-------------------------------------------------------------------------
                    if ($thumb['size'] > 0 && ($size[0] >= $thumb['size'] || $size[1] >= $thumb['size'])) {
                        // size value is set -> RESIZING and source image is larger than preset sizes
                        // resize parameters
                        $phpThumb->resize($thumb['size'], $thumb['size']);
                        // create file suffix
                        if ($thumb['ext'] == '*') {
                            // image size is used
                            $dim = '_' . $thumb['size'];
                            // e.g. _1280
                        } else {
                            if ($thumb['ext'] == '') {
                                // no suffix is created
                                $dim = '';
                            } else {
                                // suffix is set to $thumb['ext']
                                $dim = '_' . $thumb['ext'];
                            }
                        }
                        //-------------------------------------------------------------------------
                    } elseif ($thumb['size'] == 0 || $thumb['size'] == '*') {
                        // size value is set to '0' -> NO RESIZING
                        // create file suffix
                        if ($thumb['ext'] == '*') {
                            // image size is used
                            $dim = '_' . ($size[0] <= $size[1] ? $size[1] : $size[0]);
                            // source height or width - e.g. _1280
                        } else {
                            if ($thumb['ext'] == '') {
                                // no suffix is created
                                $dim = '';
                            } else {
                                // suffix is set to $thumb['ext']
                                $dim = '_' . $thumb['ext'];
                            }
                        }
                        //-------------------------------------------------------------------------
                    } else {
                        // default setting - images smaller than predefined sizes
                        $dim = '';
                        // no file suffix is used
                    }
                    //-------------------------------------------------------------------------
                    $nthumb = fixFileName(basename($nfile, '.' . $ext) . sanitize_filename($dim) . '.' . $ext);
                    $nthumb = chkFileName($path, $nthumb);
                    // rename if file already exists
                    $phpThumb->save($path . $nthumb);
                    @chmod($path . $nthumb, 0755) or die($l->m('er_028'));
                    unset($phpThumb);
                }
            }
            @unlink($path . '/' . $nfile);
            // delete temporary file
        }
    }
    return $nthumb;
}