Example #1
0
if (isset($_SESSION['SimpleImageManager']) and count($_SESSION['SimpleImageManager']) > 0) {
    $html = '';
    foreach ($_SESSION['SimpleImageManager'] as $s) {
        $me = false;
        $exists = is_url_exist($s);
        $url_host = parse_url($s, PHP_URL_HOST);
        if ($url_host == $_SERVER['HTTP_HOST']) {
            $me = true;
        }
        if ($exists == false) {
            continue;
        }
        $extension = GetExtension($s);
        if ($me) {
            if (!is_image_extenstion($extension)) {
                $html .= '<div class="item"><a data-icon="' . get_file_icon_path($extension) . '" href="" class="pdf-thumbs" title="' . $s . '" rel="' . $s . '"><img src="' . get_file_icon_path($extension) . '" class="img-polaroid" width="130" height="90"></a></div>';
            } else {
                $html .= '<div class="item"><a href="" class="img-thumbs" title="' . $s . '" rel="' . $s . '"><img src="asc-thumb.php?src=' . $s . '&w=130&h=90" class="img-polaroid" width="130" height="90"></a></div>';
            }
        } elseif ($exists) {
            $html .= '<div class="item"><a href="" class="img-thumbs" title="' . $s . '" rel="' . $s . '"><img src="' . $s . '" class="img-polaroid" width="130" height="90"></a></div>';
        }
    }
    if ($html != '') {
        $output["html"] = $html;
    } else {
        $output["success"] = 0;
    }
} else {
    $output["success"] = 0;
}
Example #2
0
			<a class="lib-folder" href="" rel="' . urlencode($c['path']) . '" title="' . $c['name'] . '">
			<img src="bootstrap/img/130x90.png" class="img-polaroid" width="130" height="90">
			</a>
			<div>
			<a href="" class="pull-left transparent change-folder" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a>
			<a href="" class="pull-right transparent delete-folder" rel="' . urlencode($c['path']) . '" title="' . _lang('delete') . '"><i class="icon-trash"></i></a>
			<div class="clearfix"></div>
			<p class="caption">' . TrimText($c['name'], 17) . '</p>
			</div>
			</div>';
            } else {
                $extension = GetExtension($c['name']);
                if (!is_image_extenstion($extension)) {
                    $html .= '<div class="item">
				<a href="" class="pdf-thumbs" data-icon="' . get_file_icon_path($extension) . '" rel="' . $c['path'] . '" title="' . $c['name'] . '">
				<img src="' . get_file_icon_path($extension) . '" class="img-polaroid" width="130" height="90">
				</a>
				<div>
				<a href="" class="pull-left transparent change-file" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a>
				<a href="" class="pull-right transparent delete-file" data-path="' . urlencode($c['x']) . '" rel="' . urlencode($c['p']) . '" title="' . _lang('delete') . '"><i class="icon-trash"></i></a>
				<div class="clearfix"></div>
				<p class="caption">' . TrimText($c['name'], 17) . '</p>
				</div>
				</div>';
                } else {
                    $html .= '<div class="item">
				<a href="" class="img-thumbs" rel="' . $c['path'] . '" title="' . $c['name'] . '">
				<img src="asc-thumb.php?src=' . $c['path'] . '&w=130&h=90" class="img-polaroid" width="130" height="90">
				</a>
				<div>
				<a href="" class="pull-left transparent change-file" title="' . _lang('change_name') . '" rel="' . $c['name'] . '"><i class="icon-pencil"></i></a>
Example #3
0
function DoUpload($field = 'userfile')
{
    $output = array();
    $output["success"] = true;
    $output["is_pdf"] = 0;
    if (isset($_SESSION["tinymce_upload_directory"]) and $_SESSION["tinymce_upload_directory"] != "") {
        $current_folder = $_SESSION["tinymce_upload_directory"];
    } else {
        $current_folder = LIBRARY_FOLDER_PATH;
    }
    if (!CanAcessUploadForm()) {
        $output["reason"] = lang('no_permission_to_upload');
        $output["success"] = false;
        return $output;
    }
    if (!isset($_FILES[$field])) {
        $output["reason"] = lang('file_not_selected');
        $output["success"] = false;
        return $output;
    }
    if (!is_uploaded_file($_FILES[$field]['tmp_name'])) {
        $error = !isset($_FILES[$field]['error']) ? 4 : $_FILES[$field]['error'];
        $output["success"] = false;
        switch ($error) {
            case 1:
                // UPLOAD_ERR_INI_SIZE
                $output["reason"] = lang('file_exceeds_limit_size');
                break;
            case 2:
                // UPLOAD_ERR_FORM_SIZE
                $output["reason"] = lang('file_exceeds_limit_size');
                break;
            case 3:
                // UPLOAD_ERR_PARTIAL
                $output["reason"] = lang('file_uploaded_partially');
                break;
            case 4:
                // UPLOAD_ERR_NO_FILE
                $output["reason"] = lang('file_not_selected');
                break;
            case 6:
                // UPLOAD_ERR_NO_TMP_DIR
                $output["reason"] = lang('no_temp_directory');
                break;
            case 7:
                // UPLOAD_ERR_CANT_WRITE
                $output["reason"] = lang('unable_to_write_the_file');
                break;
            case 8:
                // UPLOAD_ERR_EXTENSION
                $output["reason"] = lang('invalid_extension');
                break;
            default:
                $output["reason"] = lang('file_not_selected');
                break;
        }
        return $output;
    }
    if (!ValidFileExtension($_FILES[$field]['name'])) {
        $output["reason"] = lang('invalid_extension');
        $output["success"] = false;
        return $output;
    }
    if (RENAME_UPLOADED_FILES == true) {
        $file_name = random_file_name($_FILES[$field]['name']);
        $file_name = set_filename($current_folder, $file_name);
    } else {
        $file_name = set_filename($current_folder, $_FILES[$field]['name']);
    }
    if (!@copy($_FILES[$field]['tmp_name'], $current_folder . $file_name)) {
        if (!@move_uploaded_file($_FILES[$field]['tmp_name'], $current_folder . $file_name)) {
            $output["reason"] = lang('could_not_move_file');
            $output["success"] = false;
            return $output;
        }
    }
    if (!isset($_SESSION['SimpleImageManager'])) {
        $_SESSION['SimpleImageManager'] = array();
    }
    $_SESSION['SimpleImageManager'][] = PathToUrl($current_folder) . $file_name;
    $output["file"] = PathToUrl($current_folder) . $file_name;
    if (is_image_extenstion(GetExtension($file_name))) {
        Resizing($current_folder, $file_name);
    } else {
        $output["is_pdf"] = 1;
        $output["icon"] = get_file_icon_path(GetExtension($file_name));
    }
    return $output;
}