예제 #1
0
function addPics()
{
    global $moduleName, $iConfig;
    //$uploadPath = $iConfig['upload_path'];
    //if ((substr( $uploadPath, -1) ) == '/') { $uploadPath = substr( $uploadPath, 0, -1); }
    $inlineJS = '<script type="text/javascript">//<![CDATA[' . PHP_EOL;
    $inlineJS .= '	$(document).ready(function() {' . PHP_EOL;
    $inlineJS .= '		var options = {' . PHP_EOL;
    $inlineJS .= '			target:	\'#upload-alert\',' . PHP_EOL;
    $inlineJS .= '			url: \'modules.php?name=' . $moduleName . '&op=uploadMoveAjax\',' . PHP_EOL;
    $inlineJS .= '			success: function() {' . PHP_EOL;
    $inlineJS .= '				$(\'input:file\').MultiFile(\'reset\' );' . PHP_EOL;
    $inlineJS .= '				$(\'#upload-alert\').fadeIn(\'slow\' );' . PHP_EOL;
    $inlineJS .= '				$(\'#upload-file-list\').empty();' . PHP_EOL;
    $inlineJS .= '			}' . PHP_EOL;
    $inlineJS .= '		};' . PHP_EOL;
    $inlineJS .= '	$(\'#upload-form\').ajaxForm(options);' . PHP_EOL;
    $inlineJS .= '});' . PHP_EOL;
    $inlineJS .= '//]]></script>' . PHP_EOL;
    AddJSToHead('includes/jquery/jquery.js', 'file');
    AddJSToHead('modules/' . $moduleName . '/includes/jquery/jquery.form.js', 'file');
    AddJSToHead('modules/' . $moduleName . '/includes/jquery/jquery.MultiFile.pack.js', 'file');
    AddJSToHead($inlineJS, 'inline');
    galleryHeader();
    uploadDiv();
    galleryFooter();
}
예제 #2
0
function uploadMove($ajaxForm = 0)
{
    global $db, $prefix, $iConfig, $moduleName, $cookie;
    $uploadPath = $iConfig['upload_path'];
    $uploadsResize = intval($iConfig['upload_resize']);
    $uploadsAutoSize = intval($iConfig['upload_autosize']);
    $uploadMaxQuality = intval($iConfig['max_quality']);
    $uploadMaxFileSize = intval($iConfig['max_file_size']);
    $uploaded = '';
    $albumParent = $_POST['album_parent'];
    $submitter = $cookie[0];
    include 'modules/' . $moduleName . '/classes/class.upload.php';
    if (isset($_FILES['uploadFiles'])) {
        foreach ($_FILES['uploadFiles'] as $name => $value) {
            if (is_array($value)) {
                foreach ($value as $index => $data) {
                    $uploadFiles[$index][$name] = $data;
                }
            }
        }
    }
    if (is_array($uploadFiles)) {
        foreach ($uploadFiles as $filename) {
            $handle = new Upload($filename);
            // Check if the file has been uploaded properly
            if ($handle->uploaded) {
                // yes, the file is on the server
                $handle->allowed = allowedMimeTypes();
                //$handle->file_max_size = $uploadMaxFileSize;
                //$handle->jpeg_quality = 50;
                //$handle->image_watermark = NUKE_BASE_DIR .'modules/'. $moduleName .'/images/watermark.png';
                //$handle->image_watermark_position = 'BR';
                $saveTitle = $handle->file_src_name_body;
                // Save original title for later usage
                $handle->file_new_name_body = md5(time() . $filename['name']);
                if ($uploadsResize) {
                    $handle->image_resize = true;
                    $handle->image_ratio_no_zoom_in = true;
                    if ($uploadsAutoSize) {
                        $handle->image_x = $uploadsAutoSize;
                        $handle->image_y = $uploadsAutoSize;
                    }
                }
                // Copy the uploaded file from its temporary location
                $handle->Process(iPath($uploadPath));
                // Check if everything went fine
                if ($handle->processed) {
                    // everything was ok... Add it to database
                    $picture = $handle->file_dst_name;
                    $result = $db->sql_query('INSERT INTO ' . $prefix . '_igallery_temp VALUES(NULL, \'' . $albumParent . '\', \'' . $saveTitle . '\', \'\', \'' . $picture . '\', 1, \'' . time() . '\', \'' . $submitter . '\')');
                    if ($result) {
                        $uploaded .= '<li>' . _IG_FILE . ' ' . $filename['name'] . ' ' . _IG_ADDEDPIC . '</li>' . PHP_EOL;
                    }
                } else {
                    $uploaded .= '<li>' . _IG_FILE . ' ' . $filename['name'] . ' ' . _IG_ADDEDPICFAIL . ' ' . $handle->error . '</li>' . PHP_EOL;
                }
                // Delete the temporary files
                $handle->Clean();
            } else {
                // Upload failed! Something must be wrong...
                $uploaded .= '<li>' . _IG_FILE . ' ' . $filename['name'] . ' ' . _IG_ADDEDPICFAIL . ' ' . $handle->error . '</li>' . PHP_EOL;
            }
        }
    }
    if (!$ajaxForm) {
        galleryHeader();
    }
    echo '<div class="warning">' . PHP_EOL;
    echo '	<ul>' . PHP_EOL;
    if (!empty($uploaded)) {
        echo $uploaded;
    } elseif (!isset($_FILES['uploadFiles'])) {
        echo '<li>' . _IG_NO_FILES_SELECTED . '</li>' . PHP_EOL;
    } else {
        echo '<li>' . _IG_UNKNOWN_ERROR . '</li>' . PHP_EOL;
    }
    echo '	</ul>' . PHP_EOL;
    echo '</div>' . PHP_EOL;
    if (!$ajaxForm) {
        galleryFooter();
    }
}