Multiupload:
Hier ist jetzt eine verbesserte Version des Multiuploads http://www.4homepages.de/forum/index.php?topic=30224.0, den ich schonmal gepostet hab.
Der upload verkleinert die ausgewählten Bilder auf die gewünschte Größe bevor die Dateien hochgeladen werden, d. h. die user brauchen nicht mehr solage um ein Bild hochzuladen, da diese schon vor dem upload eine kleinere Dateigröße besitzen.
Fogende Verbesserungen: Es werden automatisch Thumbnails beim Hochladen erstellt und die Bild, Thumbnail, Größen, etc. können jetzt übers Admin Kontrolpanel eingestellt werden. Desweiteren kann man einstellen, ob die Bilder gleich direkt freigeschaltet werden , oder ob sie im Admin Kontrolpanel angezeigt werden, um freigeschaltet zu werden. 1. Entpacke den Ordner multiupload2 von der rar Datei des Anhangs in folgendes Verzeichnis:
includes/
somit ergibt sich dann folgendes Verzeichnis:
includes/multiupload2
2. Erstelle ein neues html Dokument mit dem Namen member_multiuploadform.html in folgendes
Verzeichnis:
templates/your templates/
2.1 Füge folgenden code in das member_multiuploadform.html ein:
<?php
session_start();
$_SESSION["file_info"] = array();
?>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: "multiupload_2.php",
post_params: {"PHPSESSID": "<?php echo session_id(); ?>" ,
"user_id" : "{user_id_upload_multi}" ,
"max_thumb_height" : "{max_thumb2_height}" ,
"max_thumb_width" : "{max_thumb2_width}" ,
"auto_thumbnail_quality" : "{auto_thumbnail2_quality}" ,
"thumbnail_proportions" : "{thumbnail_proportions}" ,
"direct_upload" : "{direct_upload}" ,
"cat_id" : "<?php echo $cat_id; ?>" },
// File Upload Settings
file_size_limit : "10 MB",
file_types : "*.jpg;*.png",
file_types_description : "JPG Images; PNG Image",
file_upload_limit : 0,
// Event Handler Settings - these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
swfupload_preload_handler : preLoad,
swfupload_load_failed_handler : loadFailed,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
queue_complete_handler : queueComplete,
// Button Settings
button_image_url : "./includes/multiupload2/images/SmallSpyGlassWithTransperancy_17x18.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 200,
button_height: 18,
button_text : '<span class="button">Durchsuchen & Hochladen</span>',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 15pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 0,
button_text_left_padding: 18,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,
// Flash Settings
flash_url : "./includes/multiupload2/swfupload/swfupload.swf",
flash9_url : "./includes/multiupload2/swfupload/swfupload_fp9.swf",
custom_settings : {
upload_target : "divFileProgressContainer",
max_image_height: "{max_image2_height}",
max_image_width: "{max_image2_width}",
image_quality: "{image_multi_quality}",
cat_id: "<?php echo $cat_id; ?>",
direct_upload: "{direct_upload}"
},
// Debug Settings
debug: false
});
};
</script>
<div id="content">
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td valign="top" class="head1">
<table width="100%" border="0" bordercolor="#0066ff" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="head1">{lang_user_upload_multi}</td>
</tr>
<tr>
<td width="50%" class="row1"><b>{lang_user_current_cat}</b></td>
<td width="50%" class="row1"><div style="padding-left: 6px;"><b>{cat_name}</b></div></td>
</tr>
<tr>
<form onsubmit="if (cat_id.options[cat_id.selectedIndex].value==0){ alert('{cat_name_required}'); return false;};" method="get" name="jumpbox" action="{url_member}">
<td width="50%" class="row2"><b>{lang_user_upload_multi_other_cat}</b></td>
<td width="50%" class="row2"><input type="hidden" name="action" value="multiuploadform">{upload_dropdown_multi}<input type="submit" value="{lang_go}" class="button" /></td>
</form>
</tr>
<tr>
<form>
<td colspan="2" class="row1"><div align="center"><div style="width: 200px; height: 22px; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;"><span id="spanButtonPlaceholder"></span></div></div></td>
</form>
</tr>
<tr>
<td colspan="2" class="row2"><div align="center"><div id="divFileProgressContainer"></div></div></td>
</tr>
<tr>
<td colspan="2" class="row1"><div align="center"><div id="divStatus"></div></div></td>
</tr>
</table>
</td>
</tr>
</table>
<br />
<div id="thumbnails" style="width: 800px;">
<?php
// Read the files from the saved images folder
$dir = new DirectoryIterator("data/thumbnails/$cat_id");
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot() && $fileinfo->isFile()) {
echo '<img style="margin: 5px; vertical-align: middle;" src="data/thumbnails/'.$cat_id.'/' . $fileinfo->getFilename() . '" />';
}
}
?>
</div>
</div>
3. Öffne lang/your lang/main.php und such nach:
$lang['new_upload_validate_desc'] = "Nach Überprüfung durch einen Administrator wird Ihr Bild freigeschaltet."; füg danach folgendes ein:
//-----------------------------------------------------
//--- Image Upload Multi ----------------------
//-----------------------------------------------------
$lang['user_upload_multi'] = "Bilder Upload";
$lang['user_current_cat'] = "Lade in folgendes Album Bilder hoch:";
$lang['user_upload_multi_other_cat'] = "Oder wähle ein anderes Album aus:";4. öffne lang/your lang admin.php und such nach:
$setting['auto_thumbnail_quality'] = "Bild-Qualität des erstellten Thumbnails<br /><span class=\"smalltext\">von 0 bis 100</span>"; füg folgendes danach ein:
/*-- Setting-Group 10 --*/
$setting_group[10]="Multiupload Einstellungen";
$setting['max_thumb2_width'] = "Maximale Breite der Thumbnail-Bilder in Pixel";
$setting['max_thumb2_height'] = "Maximale Höhe der Thumbnail-Bilder in Pixel";
$setting['max_image2_width'] = "Maximale Breite der Bilder in Pixel";
$setting['max_image2_height'] = "Maximale Höhe der Bilder in Pixel";
$setting['auto_thumbnail_resize_type2'] = "Proportionen";
$auto_thumbnail_resize_type2_optionlist = array(
"1" => "Proportional verkleinern",
"2" => "Quadratisch verkleinern",
);
$setting['auto_thumbnail2_quality'] = "Bild-Qualität des erstellten Thumbnails<br /><span class=
\"smalltext\">von 0 bis 100</span>";
$setting['image_multi_quality'] = "Bild-Qualität der erstellten Bilder<br /><span class=\"smalltext\">von 0
bis 100</span>";5. Öffne templates/your templates/categories.html
such nach:
{upload_button} füg fogendes danach ein:
{upload_button_multi}6. Öffne categories.php und such nach:
if (!check_permission("auth_upload", $cat_id)) {
$upload_url = "";
$upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />"; füg folgendes danach ein:
$upload_url_multi = "";
$upload_button_multi = "<img src=\"".get_gallery_image("multiupload_off.gif")."\" border=\"0\" alt=\"\" />";6.1 such nach:
$upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&".URL_CAT_ID."=".$cat_id);
$upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>"; für folgendes danach ein:
$upload_url_multi = $site_sess->url(ROOT_PATH."member.php?action=multiuploadform&".URL_CAT_ID."=".$cat_id);
$upload_button_multi = "<a href=\"".$upload_url_multi."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";6.2 such nach:
"upload_url" => $upload_url,
"upload_button" => $upload_button, füg folgendes danach ein:
"upload_url_multi" => $upload_url_multi,
"upload_button_multi" => $upload_button_multi,7. öffne member.php und such nach:
$content = $site_template->parse_template("member_uploadform");
} füg fogendes danach ein:
if ($action == "multiuploadform") {
if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
show_error_page($lang['no_permission']);
exit;
}
$txt_clickstream = "";
if ($cat_id && isset($cat_cache[$cat_id])) {
$txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$txt_clickstream .= $lang['user_upload'];
if (!$sendprocess) {
$remote_media_file = "";
$remote_thumb_file = "";
$image_name = "";
$image_description = "";
$image_keywords = "";
$image_download_url = "";
$image_allow_comments = 1;
}
if (check_permission("auth_directupload", $cat_id)) {
$direct_upload = "1";
}
else {
$direct_upload = "0";
}
$site_template->register_vars(array(
"cat_id" => $cat_id,
/*
MOD UPLOAD CATEGORIES DROPDOWN
ORIGINAL LINE:
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
*/
/*
MOD UPLOAD CATEGORIES DROPDOWN
BEGIN REPLACE
*/
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),
"upload_dropdown_multi" => get_category_dropdown_upload($cat_id),
// "cat_name" => ($cat_id != 0 && (!isset($HTTP_POST_VARS['showdropdown']))) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id)."<input type=\"hidden\" name=\"showdropdown\" value=\"1\">",
"cat_name_required" => addslashes(preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required'])),
/*
MOD UPLOAD CATEGORIES DROPDOWN
END REPLACE
*/
"lang_user_upload_multi" => $lang['user_upload_multi'],
"lang_user_current_cat" => $lang['user_current_cat'],
"lang_user_upload_multi_other_cat" => $lang['user_upload_multi_other_cat'],
"direct_upload" => $direct_upload,
"image_multi_quality" => $config['image_multi_quality'],
"thumbnail_proportions" => $config['auto_thumbnail_resize_type2'],
"auto_thumbnail2_quality" => $config['auto_thumbnail2_quality'],
"user_id_upload_multi" => $user_info['user_id'],
"max_image2_width" => $config['max_image2_width'],
"max_image2_height" => $config['max_image2_height'],
"max_thumb2_width" => $config['max_thumb2_width'],
"max_thumb2_height" => $config['max_thumb2_height']
));
$content = $site_template->parse_template("member_multiuploadform");
}
8. kopier die Datei multiupload_2.php und thumbnail.php von der rar Datei in dein root(Haupt) Verzeichnis.
9. Öffne includes/functions.php und füg vor ?> folgendes ein:
/*
MOD UPLOAD CATEGORIES DROPDOWN
BEGIN INSERT
*/
function get_category_dropdown_upload_bits($cat_id = 0, $cid = 0, $depth = 1)
{
global $site_db, $drop_down_cat_cache, $cat_cache, $config;
if (!isset($drop_down_cat_cache[$cid]))
{
return "";
}
$category_list = "";
foreach ($drop_down_cat_cache[$cid] as $key => $category_id)
{
if (check_permission("auth_viewcat", $category_id))
{
if (check_permission("auth_upload", $category_id))
{
$disable = 0;
}
else
{
$disable = 1;
}
$category_list .= "<option value=\"".(($disable) ? 0 : $category_id)."\"";
if ($cat_id == $category_id)
{
$category_list .= " selected=\"selected\"";
}
if ($disable)
{
if (($cat_cache[$category_id]['cat_parent_id'] == 0))
{
$category_list .= " class=\"dropdowndisable\""; //upload not avalable and this is a main category
}
else
{
$category_list .= " class=\"dropdowndisable\""; //upload not avalable
}
}
else
{
if (($cat_cache[$category_id]['cat_parent_id'] == 0))
{
// $category_list .= " class=\"dropdownmarker\""; //upload avalable and this is a main category
}
else
{
// $category_list .= " class=\"dropdownok\""; //upload avalable
}
}
// $category_list .= ">".(($disable) ? "- " : "+ ");
$category_list .= ">";
if ($depth > 1)
{
$category_list .= str_repeat("--", $depth - 1)." ";
}
$category_list .= $cat_cache[$category_id]['cat_name']."</option>\n";
$category_list .= get_category_dropdown_upload_bits($cat_id, $category_id, $depth + 1);
}
}
unset($drop_down_cat_cache[$cid]);
return $category_list;
}
function get_category_dropdown_upload($cat_id = 0)
{
global $lang, $drop_down_cat_cache, $cat_parent_cache;
$category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
$category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
$category .= "<option value=\"0\">-------------------------------</option>\n";
$drop_down_cat_cache = array();
$drop_down_cat_cache = $cat_parent_cache;
$category .= get_category_dropdown_upload_bits($cat_id);
$category .= "</select>\n";
return $category;
}
/*
MOD UPLOAD CATEGORIES DROPDOWN
END INSERT
*/10. Öffne admin/settings.php und such nach:
show_setting_row("auto_thumbnail_resize_type", "show_auto_thumbnail_resize_type_options");
show_setting_row("auto_thumbnail_quality"); füg folgendes danach ein:
show_table_separator($setting_group[10], 2, "setting_group_10");
show_setting_row("max_thumb2_width");
show_setting_row("max_thumb2_height");
show_setting_row("max_image2_width");
show_setting_row("max_image2_height");
show_setting_row("auto_thumbnail_resize_type2", "show_auto_thumbnail_resize_type2_options");
show_setting_row("auto_thumbnail2_quality");
show_setting_row("image_multi_quality");10.1 such nach:
function show_auto_thumbnail_resize_type_options($setting_name, $setting_value) {
global $auto_thumbnail_resize_type_optionlist;
foreach ($auto_thumbnail_resize_type_optionlist as $key => $val) {
echo "<input type=\"radio\" name=\"setting_item[".$setting_name."]\" value=\"$key\"";
if ($setting_value == $key) {
echo " checked=\"checked\"";
}
echo "> ".$val."<br />";
}
} füg folgendes danach ein:
function show_auto_thumbnail_resize_type2_options($setting_name, $setting_value) {
global $auto_thumbnail_resize_type2_optionlist;
foreach ($auto_thumbnail_resize_type2_optionlist as $key => $val) {
echo "<input type=\"radio\" name=\"setting_item[".$setting_name."]\" value=\"$key\"";
if ($setting_value == $key) {
echo " checked=\"checked\"";
}
echo "> ".$val."<br />";
}
}11. Öffne fogendes Verzeichnis:
templates/your templates/style.css und füg am Schluss folgendes ein:
/*--Mutliupload-----------------------------------------------*/
/*--Mutliupload-----------------------------------------------*/
/*--Mutliupload-----------------------------------------------*/
/*--Mutliupload-----------------------------------------------*/
/* -- Form Styles ------------------------------- */
form {
margin: 0;
padding: 0;
}
div.fieldset {
border: 1px solid #afe14c;
margin: 10px 0;
padding: 20px 10px;
}
div.fieldset span.legend {
position: relative;
background-color: #FFF;
padding: 3px;
top: -30px;
font: 700 14px Arial, Helvetica, sans-serif;
color: #73b304;
}
div.flash {
width: 375px;
margin: 10px 5px;
border-color: #004c75;
-moz-border-radius:5px 5px 5px 5px; /* Firefox */
-webkit-border-radius:5px 5px 5px 5px; /* Chrome, Safari */
-khtml-border-radius:5px 5px 5px 5px; /* Konqueror */
border-radius:5px 5px 5px 5px; /* CSS3 */
}
button,
input,
select,
textarea {
border-width: 1px;
margin-bottom: 10px;
padding: 2px 3px;
}
input[disabled]{ border: 1px solid #ccc } /* FF 2 Fix */
label {
width: 150px;
text-align: right;
display:block;
margin-right: 5px;
}
#btnSubmit { margin: 0 0 0 155px ; }
/* -- Table Styles ------------------------------- */
td {
font: 10pt Helvetica, Arial, sans-serif;
vertical-align: top;
}
.progressWrapper {
width: 375px;
overflow: hidden;
}
.progressContainer {
margin: 5px;
padding: 4px;
border: solid 1px #E8E8E8;
background-color: #F7F7F7;
overflow: hidden;
}
/* Message */
.message {
margin: 1em 0;
padding: 10px 20px;
border: solid 1px #FFDD99;
background-color: #FFFFCC;
overflow: hidden;
}
/* Error */
.red {
border: solid 1px #B50000;
background-color: #FFEBEB;
}
/* Current */
.green {
border: solid 1px #DDF0DD;
background-color: #EBFFEB;
}
/* Complete */
.blue {
border: solid 1px #CEE2F2;
background-color: #F0F5FF;
}
.progressName {
font-size: 8pt;
font-weight: 700;
color: #555;
width: 323px;
height: 14px;
text-align: left;
white-space: nowrap;
overflow: hidden;
}
.progressBarInProgress,
.progressBarComplete,
.progressBarError {
font-size: 0;
width: 0%;
height: 2px;
background-color: blue;
margin-top: 2px;
}
.progressBarComplete {
width: 100%;
background-color: green;
visibility: hidden;
}
.progressBarError {
width: 100%;
background-color: red;
visibility: hidden;
}
.progressBarStatus {
margin-top: 2px;
width: 337px;
font-size: 7pt;
font-family: Arial;
text-align: left;
white-space: nowrap;
}
a.progressCancel {
font-size: 0;
display: block;
height: 14px;
width: 14px;
background-image: url(../../includes/multiupload2/images/cancelbutton.gif);
background-repeat: no-repeat;
background-position: -14px 0px;
float: right;
}
a.progressCancel:hover {
background-position: 0px 0px;
}
/* -- SWFUpload Object Styles ------------------------------- */
.swfupload {
vertical-align: top;
}12. Öffne fogende Datei:
templates/your templates/header.html und such nach
</head> füg davor fogendes ein:
<script type="text/javascript" src="includes/multiupload2/swfupload/swfupload.js"></script>
<script type="text/javascript" src="includes/multiupload2/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="includes/multiupload2/js/handlers.js"></script>13. Lade die Datei multiupload.gif und multiupload_off.gif in folgendes Verzeichnis:
templates/your templates/images/
14. zum Schluss lade noch die install_multiupload.php in dein root(Haupt) Verzeichnis und öffne diese in einem Browser, danach wenn alles geklappt hat kannst du die Datei wieder von deinem Server löschen. Ich hoff ich hab jetzt nichts vergessen, bei Fragen einfach melden.
15. Edit: für umlaute im Bildnamen:
such in der multiupload_2.php:
$valid_chars_regex = '.A-Z0-9_ !@#$%^&+={}\[\]\',~`-';
$file_name_1 = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES['Filedata']['name']));
$file_name_2 = preg_replace("/\.jpg$/i", "", $file_name_1);
$file_name_3 = str_replace(' ', '_', $file_name_2);
$file_name_4 = strtolower($file_name_3);
// 4images Name
$file_name_4images = $file_name_2;
$file_name = $file_name_4 . ".jpg";
und ersetz es mit:
$valid_chars_regex = '.A-Z0-9_ !@#$%^&+={}\[\]\',~`-';
$umlaute_1 = array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
$replace_1 = array("ae","oe","ue","Ae","Oe","Ue","ss");
$file_name_0 = preg_replace($umlaute_1, $replace_1, ($_FILES['Filedata']['name']));
$file_name_1 = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($file_name_0));
$file_name_2 = preg_replace("/\.jpg$/i", "", $file_name_1);
$file_name_3 = str_replace(' ', '_', $file_name_2);
$file_name_4 = strtolower($file_name_3);
$umlaute_2 = array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
$replace_2 = array("ä","ö","ü","Ä","Ö","Ü","ß");
$file_name_5 = preg_replace($umlaute_2, $replace_2, ($_FILES['Filedata']['name']));
$file_name_6 = str_replace('_', ' ', $file_name_5);
$file_name_7 = preg_replace("/\.jpg$/i", "", $file_name_6);
// 4images Name
$file_name_4images = $file_name_7;
$file_name = $file_name_4 . ".jpg";