Example #1
0
 * @subpackage Files
 */
// Setup inclusions
$load['plugin'] = true;
// Include common.php
include 'inc/common.php';
if (!defined('GSIMAGEWIDTH')) {
    $width = 200;
    //New width of image
} else {
    $width = GSIMAGEWIDTH;
}
if ($_POST['sessionHash'] === $SESSIONHASH) {
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $name = clean_img_name(to7bit($_FILES['Filedata']['name']));
        $targetPath = isset($_POST['path']) ? GSDATAUPLOADPATH . $_POST['path'] . "/" : GSDATAUPLOADPATH;
        $targetFile = str_replace('//', '/', $targetPath) . $name;
        //validate file
        if (validate_safe_file($tempFile, $_FILES["Filedata"]["name"], $_FILES["Filedata"]["type"])) {
            move_uploaded_file($tempFile, $targetFile);
            if (defined('GSCHMOD')) {
                chmod($targetFile, GSCHMOD);
            } else {
                chmod($targetFile, 0644);
            }
            exec_action('file-uploaded');
        } else {
            i18n('ERROR_UPLOAD');
            exit;
        }
Example #2
0
    $subPath = '';
    $subFolder = '';
}
// if a file was uploaded
if (isset($_FILES['file'])) {
    $uploadsCount = count($_FILES['file']['name']);
    if ($uploadsCount > 0) {
        $errors = array();
        $messages = array();
        for ($i = 0; $i < $uploadsCount; $i++) {
            if ($_FILES["file"]["error"][$i] > 0) {
                $errors[] = i18n_r('ERROR_UPLOAD');
            } else {
                //set variables
                $count = '1';
                $file_base = clean_img_name(to7bit($_FILES["file"]["name"][$i]));
                $file_loc = $path . $file_base;
                //prevent overwriting
                if (!isset($_POST['fileoverwrite']) && file_exists($file_loc)) {
                    list($file_base, $filecount) = getNextFileName($path, $file_base);
                    $file_loc = $path . $file_base;
                }
                //validate file
                if (validate_safe_file($_FILES["file"]["tmp_name"][$i], $_FILES["file"]["name"][$i])) {
                    move_uploaded_file($_FILES["file"]["tmp_name"][$i], $file_loc);
                    gs_chmod($file_loc);
                    exec_action('file-uploaded');
                    // generate thumbnail
                    genStdThumb($subFolder, $file_base);
                    $messages[] = i18n_r('FILE_SUCCESS_MSG');
                    if (requestIsAjax()) {
<?php

/**
 * Upload Folder Checker Ajax
 *
 * Return true if the file exists
 *
 * @author Ronnie Garcia
 * @package GetSimple
 * @subpackage Files
 */
include 'inc/common.php';
login_cookie_check();
$path = isset($_GET['path']) ? $_GET['path'] . "/" : "";
$name = clean_img_name($_POST['filename']);
if (file_exists(GSDATAUPLOADPATH . $path . $name)) {
    echo 1;
} else {
    echo 0;
}
Example #4
0
 $uploadsCount = count($_FILES['file']['name']);
 if ($uploadsCount > 0) {
     $errors = array();
     $messages = array();
     for ($i = 0; $i < $uploadsCount; $i++) {
         if ($_FILES["file"]["error"][$i] > 0) {
             $errors[] = i18n_r('ERROR_UPLOAD');
         } else {
             //set variables
             $count = '1';
             $file_loc = $path . clean_img_name(to7bit($_FILES["file"]["name"][$i]));
             $base = clean_img_name(to7bit($_FILES["file"]["name"][$i]));
             //prevent overwriting
             while (file_exists($file_loc)) {
                 $file_loc = $path . $count . '-' . clean_img_name(to7bit($_FILES["file"]["name"][$i]));
                 $base = $count . '-' . clean_img_name(to7bit($_FILES["file"]["name"][$i]));
                 $count++;
             }
             //validate file
             if (validate_safe_file($_FILES["file"]["tmp_name"][$i], $_FILES["file"]["name"][$i], $_FILES["file"]["type"][$i])) {
                 move_uploaded_file($_FILES["file"]["tmp_name"][$i], $file_loc);
                 if (defined('GSCHMOD')) {
                     chmod($file_loc, GSCHMOD);
                 } else {
                     chmod($file_loc, 0644);
                 }
                 exec_action('file-uploaded');
                 $messages[] = i18n_r('FILE_SUCCESS_MSG') . ': <a href="' . $SITEURL . 'data/uploads/' . $subFolder . $base . '">' . $SITEURL . 'data/uploads/' . $subFolder . $base . '</a>';
             } else {
                 $messages[] = $_FILES["file"]["name"][$i] . ' - ' . i18n_r('ERROR_UPLOAD');
             }
Example #5
0
$load['plugin'] = true;
// Include common.php
include 'inc/common.php';
if (!defined('GSIMAGEWIDTH')) {
    $width = 200;
    //New width of image
} else {
    $width = GSIMAGEWIDTH;
}
if ($_POST['sessionHash'] === $SESSIONHASH) {
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $file = $_FILES['Filedata']['name'];
        $extension = pathinfo($file, PATHINFO_EXTENSION);
        $name = pathinfo($file, PATHINFO_FILENAME);
        $name = clean_img_name(to7bit($name));
        $targetPath = isset($_POST['path']) ? GSDATAUPLOADPATH . $_POST['path'] . "/" : GSDATAUPLOADPATH;
        $targetFile = str_replace('//', '/', $targetPath) . $name . '.' . $extension;
        //validate file
        if (validate_safe_file($tempFile, $_FILES["Filedata"]["name"])) {
            move_uploaded_file($tempFile, $targetFile);
            if (defined('GSCHMOD')) {
                chmod($targetFile, GSCHMOD);
            } else {
                chmod($targetFile, 0644);
            }
            exec_action('file-uploaded');
        } else {
            die(i18n_r('ERROR_UPLOAD') . ' - ' . i18n_r('BAD_FILE'));
            // invalid file
        }
Example #6
0
// Setup inclusions
$load['plugin'] = true;
// Relative
$relative = '../';
// Include common.php
include 'inc/common.php';
if (!defined('GSIMAGEWIDTH')) {
    $width = 200;
    //New width of image
} else {
    $width = GSIMAGEWIDTH;
}
if ($_REQUEST['sessionHash'] === $SESSIONHASH) {
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $name = clean_img_name($_FILES['Filedata']['name']);
        $targetPath = GSDATAUPLOADPATH;
        $targetFile = str_replace('//', '/', $targetPath) . $name;
        move_uploaded_file($tempFile, $targetFile);
        $ext = strtolower(substr($name, strrpos($name, '.') + 1));
        if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png') {
            //thumbnail for post
            $imgsize = getimagesize($targetFile);
            switch (strtolower(substr($targetFile, -3))) {
                case "jpg":
                    $image = imagecreatefromjpeg($targetFile);
                    break;
                case "png":
                    $image = imagecreatefrompng($targetFile);
                    break;
                case "gif":
Example #7
0
// Variable settings
login_cookie_check();
$path = tsl("../data/uploads/");
// if a file was uploaded
if (isset($_FILES["file"])) {
    if ($_FILES["file"]["error"] > 0) {
        $error = $i18n['ERROR_UPLOAD'];
    } else {
        //set variables
        $count = '1';
        $file_loc = $path . clean_img_name($_FILES["file"]["name"]);
        $base = $_FILES["file"]["name"];
        //prevent overwriting
        while (file_exists($file_loc)) {
            $file_loc = $path . $count . '-' . clean_img_name($_FILES["file"]["name"]);
            $base = $count . '-' . clean_img_name($_FILES["file"]["name"]);
            $count++;
        }
        //create file
        move_uploaded_file($_FILES["file"]["tmp_name"], $file_loc);
        exec_action('file-uploaded');
        //successfull message
        $success = $i18n['FILE_SUCCESS_MSG'] . ': <a href="' . $SITEURL . 'data/uploads/' . $base . '">' . $SITEURL . 'data/uploads/' . $base . '</a>';
    }
}
?>

<?php 
get_template('header', cl($SITENAME) . ' &raquo; ' . $i18n['FILE_MANAGEMENT']);
?>