makeFile() public méthode

Similar to makePath, but the second parameter is not only a path, it may contain say a file ending.
public makeFile ( string $pathA, string $pathB ) : string
$pathA string the leading path
$pathB string the ending path with file
Résultat string combined file path.
 /**
  * Delete the relative file, and any thumbnails.
  * @param string $relative the relative file.
  * @return boolean true if deleted, false otherwise.
  */
 function _delFile($relative)
 {
     $fullpath = Files::makeFile($this->getImagesDir(), $relative);
     //check that the file is an image
     if ($this->config['validate_images'] == true) {
         if (!is_array($this->getImageInfo($fullpath))) {
             return false;
         }
         //hmmm not an Image!!???
     }
     $thumbnail = $this->getThumbName($fullpath);
     if (Files::delFile($fullpath)) {
         return Files::delFile($thumbnail);
     } else {
         return false;
     }
 }
Exemple #2
0
 * relative to the base_dir given in config.inc.php
 * @author $Author$
 * @version $Id$
 * @package ImageManager
 */
require_once 'config.inc.php';
require_once 'Classes/ImageManager.php';
require_once 'Classes/Thumbnail.php';
//check for img parameter in the url
if (!isset($_GET['img'])) {
    exit;
}
$manager = new ImageManager($IMConfig);
//get the image and the full path to the image
$image = rawurldecode($_GET['img']);
$fullpath = Files::makeFile($manager->getBaseDir(), $image);
//not a file, so exit
if (!is_file($fullpath)) {
    exit;
}
$imgInfo = @getImageSize($fullpath);
//Not an image, send default thumbnail
if (!is_array($imgInfo)) {
    //show the default image, otherwise we quit!
    $default = $manager->getDefaultThumb();
    if ($default) {
        header('Location: ' . $default);
        exit;
    }
}
//if the image is less than the thumbnail dimensions
Exemple #3
0
$image = $_GET['img'];
$fullpath = Files::makeFile($manager->getImagesDir(), $image);
//not a file, so exit
if (!is_file($fullpath)) {
    js_fail("File {$fullpath} does not exist.");
}
$imgInfo = @getImageSize($fullpath);
//Not an image, bail out.
if (!is_array($imgInfo)) {
    js_fail("File {$fullpath} is not an image.");
}
if (!isset($_GET['to'])) {
    $resized = $manager->getResizedName($fullpath, $_GET['width'], $_GET['height']);
    $_GET['to'] = $manager->getResizedName($image, $_GET['width'], $_GET['height'], FALSE);
} else {
    $resized = Files::makeFile($manager->getImagesDir(), $_GET['to']);
}
// Check to see if it already exists
if (is_file($resized)) {
    // And is newer
    if (filemtime($resized) >= filemtime($fullpath)) {
        js_success($_GET['to']);
    }
}
// resize (thumbnailer will do this for us just fine)
$thumbnailer = new Thumbnail($_GET['width'], $_GET['height']);
$thumbnailer->proportional = FALSE;
$thumbnailer->createThumbnail($fullpath, $resized);
// did it work?
if (is_file($resized)) {
    js_success($_GET['to']);
 /**
  * Get the fullpath to a relative file.
  * @param string $relative the relative file.
  * @return string the full path, .ie. the base_dir + relative.
  */
 function getFullPath($relative)
 {
     return Files::makeFile($this->getBaseDir(), $relative);
 }
 function processPaste()
 {
     switch ($_GET['paste']) {
         case 'copyFile':
             $src = Files::makeFile($this->getImagesDir(), $_GET['srcdir'] . $_GET['file']);
             $file = $_GET['file'];
             $dest = Files::makeFile($this->getImagesDir(), $_GET['dir']);
             return Files::copyFile($src, $dest, $file);
             break;
         case 'copyDir':
             $basePath = $this->getImagesDir();
             $src = $_GET['srcdir'] . $_GET['file'];
             $dest = $_GET['dir'] . $_GET['file'];
             return Files::copyDir($basePath, $src, $dest);
             break;
         case 'moveFile':
             $src = Files::makePath($this->getImagesDir(), $_GET['srcdir'] . $_GET['file']);
             $dest = Files::makePath($this->getImagesDir(), $_GET['dir'] . $_GET['file']);
             return Files::rename($src, $dest);
             break;
         case 'moveDir':
             $src = Files::makeFile($this->getImagesDir(), $_GET['srcdir'] . $_GET['file']);
             $dest = Files::makeFile($this->getImagesDir(), $_GET['dir'] . $_GET['file']);
             return Files::rename($src, $dest);
             break;
     }
 }
Exemple #6
0
    $insertMode = $_REQUEST['mode'];
}
if (!isset($insertMode)) {
    $insertMode = "image";
}
require_once 'config.inc.php';
require_once 'Classes/ExtendedFileManager.php';
require_once '../ImageManager/Classes/Thumbnail.php';
//check for img parameter in the url
if (!isset($_GET['img'])) {
    exit;
}
$manager = new ExtendedFileManager($IMConfig, $insertMode);
//get the image and the full path to the image
$image = rawurldecode($_GET['img']);
$fullpath = Files::makeFile($manager->getImagesDir(), $image);
//not a file, so exit
if (!is_file($fullpath)) {
    exit;
}
$imgInfo = @getImageSize($fullpath);
//Not an image, send default thumbnail
if (!is_array($imgInfo)) {
    //show the default image, otherwise we quit!
    $default = $manager->getDefaultThumb();
    if ($default) {
        header('Location: ' . $default);
        exit;
    }
}
//if the image is less than the thumbnail dimensions
 /**
  * Delete the relative file, and any thumbnails.
  * @param string $relative the relative file.
  * @return boolean true if deleted, false otherwise.
  */
 function _delFile($relative)
 {
     $fullpath = Files::makeFile($this->getBaseDir(), $relative);
     //check that the file is an image
     if ($this->config['validate_images']) {
         if (!is_array($this->getImageInfo($fullpath))) {
             return false;
         }
         //hmmm not an Image!!???
     }
     $thumbnail = $this->getThumbName($fullpath);
     if (Files::delFile($fullpath)) {
         //deleting from the DB
         global $_course;
         if (isset($_course) && !empty($_course) && isset($_course['code'])) {
             $document_path = substr($fullpath, strpos($fullpath, '/document/') + 9, strlen($fullpath));
             //   /shared_folder/4/name
             DocumentManager::delete_document($_course, $document_path, $fullpath);
         }
         return Files::delFile($thumbnail);
     } else {
         return false;
     }
 }
 /**
  * Renames files if certain GET variables are set
  * @return bool
  */
 function processRenames()
 {
     if (!empty($_GET['rename']) && !empty($_GET['renameTo'])) {
         // new file name (without path and extension)
         $newName = Files::escape(rawurldecode($_GET['renameTo']));
         $newName = str_replace('.', '', $newName);
         // path to file (from base images directory)
         $oldName = rawurldecode($_GET['rename']);
         // strip parent dir ("..") to avoid escaping from base directiory
         $oldName = preg_replace('#\\.\\.#', '', $oldName);
         // path to old file
         $oldPath = Files::makeFile($this->getImagesDir(), $oldName);
         $ret = Files::renameFile($oldPath, $newName);
         if ($ret === true) {
             // delete old thumbnail
             Files::delFile($this->getThumbname($oldPath));
         }
         return $ret;
     }
     return null;
 }