Przedszkolak
Postów: 31 Ostrzeżeń: 5
Data rejestracji: 27.02.2008 12:35
|
Witam chciałbym mieć 2 pole przeglądaj
w pliku przerobionym pliku submit.php?stype=p
czyli w dodawaniu zdjęcia do galerii
(bez akceptacji admina by Pieka)
i za bardzo nie wiem jak się za to zabrać proszę o pomoc:)
[chce żeby w jednej "podstronie" ze zdjęciem wyświetlały się 2]
To "mój" kod submit
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2009 Nick Jones
| http://www.php-fu...
+--------------------------------------------------------+
| Filename: dodaj_motocykl.php
| Author: Nick Jones, fazi
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licen... Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."dodaj_motocykl.php";
if (!iMEMBER) { redirect("index.php"); }
include INCLUDES."db.php";
if (!isset($_GET['dodaj']) || !preg_check("/^[a-z]$/", $_GET['dodaj'])) { redirect("index.php"); }
$submit_info = array();
if ($_GET['dodaj'] == "p") {
if (isset($_POST['submit_photo'])) {
require_once INCLUDES."photo_functions_include.php";
$error = "";
$submit_info['photo_title'] = stripinput($_POST['photo_title']);
$submit_info['photo_model'] = stripinput($_POST['photo_model']);
$submit_info['photo_tuning'] = stripinput($_POST['photo_tuning']);
$submit_info['photo_rokprod'] = stripinput($_POST['photo_rokprod']);
$submit_info['photo_description'] = stripinput($_POST['photo_description']);
$submit_info['album_id'] = isnum($_POST['album_id']) ? $_POST['album_id'] : "0";
if (is_uploaded_file($_FILES['photo_pic_file']['tmp_name'])) {
$photo_types = array(".gif",".jpg",".jpeg",".png");
$photo_pic = $_FILES['photo_pic_file'];
$photo_name = strtolower(substr($photo_pic['name'], 0, strrpos($photo_pic['name'], ".")));
$photo_ext = strtolower(strrchr($photo_pic['name'],"."));
define("SAFEMODE", @ini_get("safe_mode") ? true : false);
$photo_dest = PHOTOS2.(!SAFEMODE ? "album_".$submit_info['album_id']."/" : "");
if (!preg_match("/^[-0-9A-Z_\[\]]+$/i", $photo_name)) {
$error = 1;
} elseif ($photo_pic['size'] > $settings['photo_max_b']){
$error = 2;
} elseif (!in_array($photo_ext, $photo_types)) {
$error = 3;
} else {
$photo_file = image_exists($photo_dest, $photo_name.$photo_ext);
move_uploaded_file($photo_pic['tmp_name'], $photo_dest.$photo_file);
chmod($photo_dest.$photo_file, 0644);
$imagefile = @getimagesize($photo_dest.$photo_file);
if (!verify_image($photo_dest.$photo_file)) {
$error = 3;
unlink($photo_dest.$photo_file);
} elseif ($imagefile[0] > $settings['photo_max_w'] || $imagefile[1] > $settings['photo_max_h']) {
$error = 4;
unlink($photo_dest.$photo_file);
} else {
$submit_info['photo_file'] = $photo_file;
$photo_thumb1 = image_exists($photo_dest, $photo_name."_t1".$photo_ext);
createthumbnail($imagefile[2], $photo_dest.$photo_file, $photo_dest.$photo_thumb1, $settings['thumb_w'], $settings['thumb_h']);
if ($imagefile[0] > $settings['photo_w'] || $imagefile[1] > $settings['photo_h']) {
$photo_thumb2 = image_exists($photo_dest, $photo_name."_t2".$photo_ext);
createthumbnail($imagefile[2], $photo_dest.$photo_file, $photo_dest.$photo_thumb2, $settings['photo_w'], $settings['photo_h']);
}
}
}
}
add_to_title($locale['global_200'].$locale['570']);
opentable($locale['570']);
if (!$error) {
$photo_order = dbresult(dbquery("SELECT MAX(photo_order) FROM ".DB_PHOTOS2." WHERE album_id='".$submit_info['album_id']."'"), 0) + 1;
$result = dbquery("INSERT INTO ".DB_PHOTOS2." (album_id, photo_title ,photo_model, photo_tuning, photo_rokprod, photo_description, photo_filename, photo_thumb1, photo_thumb2, photo_datestamp, photo_user, photo_views, photo_order, photo_allow_comments, photo_allow_ratings) VALUES ('".$submit_info['album_id']."', '".$submit_info['photo_title']."','".$submit_info['photo_model']."','".$submit_info['photo_tuning']."','".$submit_info['photo_rokprod']."', '".$submit_info['photo_description']."', '".$submit_info['photo_file']."', '$photo_thumb1', '$photo_thumb2', '".time()."', '".$userdata['user_id']."', '0', '$photo_order', '1', '1')");
echo "<div style='text-align:center'><br />\n".$locale['580']."<br /><br />\n";
echo "<a href='dodaj_motocykl.php?dodaj=p'>".$locale['581']."</a><br /><br />\n";
echo "<a href='index.php'>".$locale['412']."</a><br /><br />\n</div>\n";
} else {
echo "<div style='text-align:center'><br />\n".$locale['600']."<br /><br />\n";
if ($error == 1) { echo $locale['601']; }
elseif ($error == 2) { echo sprintf($locale['602'], $settings['photo_max_b']); }
elseif ($error == 3) { echo $locale['603']; }
elseif ($error == 4) { echo sprintf($locale['604'], $settings['photo_max_w'], $settings['photo_max_h']); }
echo "<br /><br />\n<a href='dodaj_motocykl.php?dodaj=p'>".$locale['581']."</a><br /><br />\n</div>\n";
}
closetable();
} else {
$opts = "";
add_to_title($locale['global_200'].$locale['570']);
opentable($locale['570']);
$result = dbquery("SELECT * FROM ".DB_PHOTO_ALBUMS2." WHERE ".groupaccess("album_access")." ORDER BY album_title");
if (dbrows($result)) {
while ($data = dbarray($result)) $opts .= "<option value='".$data['album_id']."'>".$data['album_title']."</option>\n";
echo $locale['620']."<br /><br />\n";
echo "<form name='submit_form' method='post' action='".FUSION_SELF."?dodaj=p' enctype='multipart/form-data' onsubmit='return validatePhoto(this);'>\n";
echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
echo "<td class='tbl'>".$locale['621']."</td>\n";
echo "<td class='tbl'><input type='text' name='photo_title' maxlength='100' class='textbox' style='width:180px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['627']."</td>\n";
echo "<td class='tbl'><input type='text' name='photo_model' maxlength='100' class='textbox' style='width:110px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['628']."</td>\n";
echo "<td class='tbl'><input type='text' name='photo_rokprod' maxlength='4' class='textbox' style='width:50px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' class='tbl'>".$locale['629']."</td>\n";
echo "<td class='tbl'><textarea name='photo_tuning' cols='60' rows='5' class='textbox' style='width:300px;'></textarea></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' class='tbl'>".$locale['622']."</td>\n";
echo "<td class='tbl'><textarea name='photo_description' cols='60' rows='5' class='textbox' style='width:300px;'></textarea></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' class='tbl'>".$locale['623']."</td>\n";
echo "<td class='tbl'><input type='file' name='photo_pic_file' class='textbox' style='width:250px;' /><br />\n";
echo "<span class='small2'>".sprintf($locale['624'], parsebytesize($settings['photo_max_b']), $settings['photo_max_w'], $settings['photo_max_h'])."</span></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['625']."</td>\n";
echo "<td class='tbl'><select name='album_id' class='textbox'>\n$opts</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
echo "<input type='submit' name='submit_photo' value='".$locale['626']."' class='button' />\n</td>\n";
echo "</tr>\n</table>\n</form>\n";
} else {
echo "<div style='text-align:center'><br />\n".$locale['551']."<br /><br />\n</div>\n";
}
closetable();
}
} else {
redirect("index.php");
}
echo "<script type='text/javascript'>
function validatePhoto(frm) {
if (frm.photo_title.value==\"\" || frm.photo_description.value==\"\" || frm.photo_pic_file.value==\"\") {
alert(\"".$locale['550']."\");
return false;
}
}
</script>\n";
require_once THEMES."templates/footer.php";
?> Kliknij i zaczekaj na załadowanie kodu ...
//tak długi kod umieszczaj w znaczniki chili - chemix
PW od moderatora:
- Przeniesienie tematu - chemix 28.02 - 18:39
- Odświeżenie Tematu - Pieka 10.03 - 10:37
- Odświeżenie Tematu - Pieka 12.03 - 19:48
Edytowane przez fazi82 dnia 10.03.2009 09:45:03
|