Upload i dodanie zdjęcia podczas dodawania newsa
|
ravenger |
Dodany dnia 24.04.2008 22:10:16
|
Przedszkolak
Postów: 12
v7.02.03 Data rejestracji: 07.01.2008 22:36
|
Tytuł chyba jasny ale przedstawię problem szerzej.
Chodzi o dodanie dodatkowego pola do formularza dodawania newsa w PA. Jak to powinno wyglądać można zobaczyć poniżej.
http://www.fotosi...65d23ec487
Chciałbym ułatwić trochę życie adminom, często bywa tak, że nie każdy ma dostęp do ftp na którym jest strona, na dodatek nie ma własnego serwera a chciałby dodać zdjęcie/obrazek do newsa. Teoretycznie można skorzystać z fotosika, imageshack itp. no ale to takie połowiczne rozwiązanie.
Problem był już poruszany na forum ale jakoś nikt nie odważył się go rozwiązać a chyba czas najwyższy się za to zabrać :P
Do admin/news.php wstawiłem formularz z admin/images.php, troszkę przerobiłem by lepiej wyglądało no ale najważniejsze jest to że nie działa ;]
Mam dwa pomysły na rozwiązanie tego problemu:
1) Upload zdjęcia, pobranie adresu, wstawienie go do treści newsa (jak na obrazku), dalsze pisanie newsa - zapewne konieczne będzie przeładowanie strony po wgraniu zdjęcia
2) Wybranie zdjęcia, napisanie newsa, klik na Dodaj newsa i dodanie newsa wraz z obrazkiem (który się w tym czasie uploaduje) na początku newsa
Pierwsze rozwiązanie wydaje mi się lepsze gdyż daje możliwość umieszczenia zdjęcia w dowolnym miejscu newsa, w drugim przypadku jest to narzucone z góry ale można zmienić podczas edycji.
Linki do podobnych tematów lub takich które mogą okazać się pomocne:
http://www.php-fu...post_84411
http://www.php-fu...post_86079
http://www.php-fu...post_83813
http://www.php-fu...post_39988
http://www.php-fu...#post_2429
http://www.php-fu...post_74151
Dodaję kod który zmodyfikowałem, z góry muszę zaznaczyć że szałowy to on nie jest :P
Żeby oszczędzić wam analizowania całości - modyfikacja w linijce 17 oraz 198-208.
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../maincore.php";
require_once "subheader.php";
require_once ADMIN."navigation.php";
include LOCALE.LOCALESET."admin/news-articles.php";
$docelowy = "../img";
if (!checkrights("N") || !defined("iAUTH") || $aid != iAUTH) fallback("../index.php");
if (isset($news_id) && !isNum($news_id)) fallback(FUSION_SELF);
if ($settings['tinymce_enabled'] == 1) echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
if (isset($status)) {
if ($status == "su") {
$title = $locale['400'];
$message = "<b>".$locale['401']."</b>";
} elseif ($status == "sn") {
$title = $locale['404'];
$message = "<b>".$locale['405']."</b>";
} elseif ($status == "del") {
$title = $locale['406'];
$message = "<b>".$locale['407']."</b>";
}
opentable($title);
echo "<div align='center'>".$message."</div>\n";
closetable();
tablebreak();
}
if (isset($_POST['save'])) {
$news_subject = stripinput($_POST['news_subject']);
$news_cat = isNum($_POST['news_cat']) ? $_POST['news_cat'] : "0";
$body = addslash($_POST['body']);
if ($_POST['body2']) $body2 = addslash(preg_replace("(^<p>\s</p>$)", "", $_POST['body2']));
$news_start_date = 0; $news_end_date = 0;
if ($_POST['news_start']['mday']!="--" && $_POST['news_start']['mon']!="--" && $_POST['news_start']['year']!="----") {
$news_start_date = mktime($_POST['news_start']['hours'],$_POST['news_start']['minutes'],0,$_POST['news_start']['mon'],$_POST['news_start']['mday'],$_POST['news_start']['year']);
}
if ($_POST['news_end']['mday']!="--" && $_POST['news_end']['mon']!="--" && $_POST['news_end']['year']!="----") {
$news_end_date = mktime($_POST['news_end']['hours'],$_POST['news_end']['minutes'],0,$_POST['news_end']['mon'],$_POST['news_end']['mday'],$_POST['news_end']['year']);
}
$news_visibility = isNum($_POST['news_visibility']) ? $_POST['news_visibility'] : "0";
$news_sticky = isset($_POST['news_sticky']) ? "1" : "0";
if ($settings['tinymce_enabled'] != 1) { $news_breaks = isset($_POST['line_breaks']) ? "y" : "n"; } else { $news_breaks = "n"; }
$news_comments = isset($_POST['news_comments']) ? "1" : "0";
$news_ratings = isset($_POST['news_ratings']) ? "1" : "0";
if (isset($news_id)) {
if ($news_sticky == "1") $result = dbquery("UPDATE ".$db_prefix."news SET news_sticky='0' WHERE news_sticky='1'");
$result = dbquery("UPDATE ".$db_prefix."news SET news_subject='$news_subject', news_cat='$news_cat', news_news='$body', news_extended='$body2', news_breaks='$news_breaks',".($news_start_date != 0 ? " news_datestamp='$news_start_date'," : "")." news_start='$news_start_date', news_end='$news_end_date', news_visibility='$news_visibility', news_sticky='$news_sticky', news_allow_comments='$news_comments', news_allow_ratings='$news_ratings' WHERE news_id='$news_id'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
if ($news_sticky == "1") $result = dbquery("UPDATE ".$db_prefix."news SET news_sticky='0' WHERE news_sticky='1'");
$result = dbquery("INSERT INTO ".$db_prefix."news (news_subject, news_cat, news_news, news_extended, news_breaks, news_name, news_datestamp, news_start, news_end, news_visibility, news_sticky, news_reads, news_allow_comments, news_allow_ratings) VALUES ('$news_subject', '$news_cat', '$body', '$body2', '$news_breaks', '".$userdata['user_id']."', '".($news_start_date != 0 ? $news_start_date : time())."', '$news_start_date', '$news_end_date', '$news_visibility', '$news_sticky', '0', '$news_comments', '$news_ratings')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} else if (isset($_POST['delete'])) {
$result = dbquery("DELETE FROM ".$db_prefix."news WHERE news_id='$news_id'");
$result = dbquery("DELETE FROM ".$db_prefix."comments WHERE comment_item_id='$news_id' and comment_type='N'");
$result = dbquery("DELETE FROM ".$db_prefix."ratings WHERE rating_item_id='$news_id' and rating_type='N'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$news_subject = stripinput($_POST['news_subject']);
$body = phpentities(stripslash($_POST['body']));
$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body']));
if ($_POST['body2']) {
$body2 = phpentities(stripslash($_POST['body2']));
$body2preview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body2']));
}
if (isset($_POST['line_breaks'])) {
$news_breaks = " checked";
$bodypreview = nl2br($bodypreview);
if ($body2) $body2preview = nl2br($body2preview);
} else {
$news_breaks = "";
}
$news_start = array(
"mday" => isNum($_POST['news_start']['mday']) ? $_POST['news_start']['mday'] : "--",
"mon" => isNum($_POST['news_start']['mon']) ? $_POST['news_start']['mon'] : "--",
"year" => isNum($_POST['news_start']['year']) ? $_POST['news_start']['year'] : "----",
"hours" => isNum($_POST['news_start']['hours']) ? $_POST['news_start']['hours'] : "0",
"minutes" => isNum($_POST['news_start']['minutes']) ? $_POST['news_start']['minutes'] : "0",
);
$news_end = array(
"mday" => isNum($_POST['news_end']['mday']) ? $_POST['news_end']['mday'] : "--",
"mon" => isNum($_POST['news_end']['mon']) ? $_POST['news_end']['mon'] : "--",
"year" => isNum($_POST['news_end']['year']) ? $_POST['news_end']['year'] : "----",
"hours" => isNum($_POST['news_end']['hours']) ? $_POST['news_end']['hours'] : "0",
"minutes" => isNum($_POST['news_end']['minutes']) ? $_POST['news_end']['minutes'] : "0",
);
$news_sticky = isset($_POST['news_sticky']) ? " checked" : "";
$news_comments = isset($_POST['news_comments']) ? " checked" : "";
$news_ratings = isset($_POST['news_ratings']) ? " checked" : "";
opentable($news_subject);
echo "$bodypreview\n";
closetable();
if (isset($body2preview)) {
tablebreak();
opentable($news_subject);
echo "$body2preview\n";
closetable();
}
tablebreak();
}
$editlist = ""; $sel = "";
$result = dbquery("SELECT * FROM ".$db_prefix."news ORDER BY news_datestamp DESC");
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
if (isset($news_id)) $sel = ($news_id == $data['news_id'] ? " selected" : "");
$editlist .= "<option value='".$data['news_id']."'$sel>".$data['news_subject']."</option>\n";
}
}
opentable($locale['408']);
echo "<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."'>
<center>
<select name='news_id' class='textbox' style='width:250px'>
$editlist</select>
<input type='submit' name='edit' value='".$locale['409']."' class='button'>
<input type='submit' name='delete' value='".$locale['410']."' onclick='return DeleteNews();' class='button'>
</center>
</form>\n";
closetable();
tablebreak();
if (isset($_POST['edit'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."news WHERE news_id='$news_id'");
if (dbrows($result) != 0) {
$data = dbarray($result);
$news_subject = $data['news_subject'];
$news_cat = $data['news_cat'];
$body = phpentities(stripslashes($data['news_news']));
$body2 = phpentities(stripslashes($data['news_extended']));
if ($data['news_start'] > 0) $news_start = getdate($data['news_start']);
if ($data['news_end'] > 0) $news_end = getdate($data['news_end']);
$news_breaks = $data['news_breaks'] == "y" ? " checked" : "";
$news_comments = $data['news_allow_comments'] == "1" ? " checked" : "";
$news_ratings = $data['news_allow_ratings'] == "1" ? " checked" : "";
$news_visibility = $data['news_visibility'];
$news_sticky = $data['news_sticky'] == "1" ? " checked" : "";
}
}
if (isset($news_id)) {
$action = FUSION_SELF.$aidlink."&news_id=$news_id";
opentable($locale['400']);
} else {
if (!isset($_POST['preview'])) {
$news_subject = "";
$body = "";
$body2 = "";
$news_breaks = " checked";
$news_comments = " checked";
$news_ratings = " checked";
$news_visibility = 0;
$news_sticky = "";
}
$action = FUSION_SELF.$aidlink;
opentable($locale['404']);
}
$image_files = makefilelist(IMAGES_N, ".|..|index.php", true);
$image_list = makefileopts($image_files);
$result = dbquery("SELECT * FROM ".$db_prefix."news_cats ORDER BY news_cat_name");
$news_cat_opts = ""; $sel = "";
if (dbrows($result)) {
while ($data = dbarray($result)) {
if (isset($news_cat)) $sel = ($news_cat == $data['news_cat_id'] ? " selected" : "");
$news_cat_opts .= "<option value='".$data['news_cat_id']."'$sel>".$data['news_cat_name']."</option>\n";
}
}
$visibility_opts = ""; $sel = "";
$user_groups = getusergroups();
while(list($key, $user_group) = each($user_groups)){
$sel = ($news_visibility == $user_group['0'] ? " selected" : "");
$visibility_opts .= "<option value='".$user_group['0']."'$sel>".$user_group['1']."</option>\n";
}
echo "<form name='inputform' method='post' action='$action' onSubmit='return ValidateForm(this);'>
<table align='center' cellpadding='0' cellspacing='0'>
<tr>
<td width='100' class='tbl'>".$locale['411']."</td>
<td width='80%' class='tbl'><input type='text' name='news_subject' value='$news_subject' class='textbox' style='width: 250px'></td>
</tr>
<tr>
<td width='100' class='tbl'>".$locale['511']."</td>
<td width='80%' class='tbl'><select name='news_cat' class='textbox'>
<option value='0'>".$locale['425']."</option>
$news_cat_opts</select>
</td>
</tr>
<tr>
<form name='uploadform' method='post' action='".FUSION_SELF.$aidlink."&ifolder=$docelowy' enctype='multipart/form-data'>
<td width='100' class='tbl'>Wybierz obrazek</td>
<td class='tbl'><input type='file' name='myfile' class='textbox' style='width:250px;'></td>
</tr>
<tr>
<td></td>
<td colspan='2' class='tbl'>
<input type='submit' name='uploadimage' value='Dodaj obrazek' class='button' style='width:100px;'></td>
</tr></form>\n
</tr>
<tr>
<td valign='top' width='100' class='tbl'>".$locale['412']."</td>
<td width='80%' class='tbl'><textarea name='body' cols='95' rows='10' class='textbox'>$body</textarea></td>
</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>
<input type='button' value='b' class='button' style='font-weight:bold;width:25px' onClick=\"addText('body', '<b>', '</b>');\">
<input type='button' value='i' class='button' style='font-style:italic;width:25px' onClick=\"addText('body', '<i>', '</i>');\">
<input type='button' value='u' class='button' style='text-decoration:underline;width:25px' onClick=\"addText('body', '<u>', '</u>');\">
<input type='button' value='link' class='button' style='width:35px' onClick=\"addText('body', '<a href=\'', '\' target=\'_blank\'>Link</a>');\">
<input type='button' value='img' class='button' style='width:35px' onClick=\"addText('body', '<img src=\'".str_replace("../","",IMAGES_N)."', '\' style=\'margin:5px\' align=\'left\'>');\">
<input type='button' value='center' class='button' style='width:45px' onClick=\"addText('body', '<center>', '</center>');\">
<input type='button' value='small' class='button' style='width:40px' onClick=\"addText('body', '<span class=\'small\'>', '</span>');\">
<input type='button' value='small2' class='button' style='width:45px' onClick=\"addText('body', '<span class=\'small2\'>', '</span>');\">
<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\"><br>
<select name='setcolor' class='textbox' style='margin-top:5px' onChange=\"addText('body', '<span style=\'color:' + this.options[this.selectedIndex].value + '\'>', '</span>');this.selectedIndex=0;\">
<option value=''>".$locale['420']."</option>
<option value='maroon' style='color:maroon'>Maroon</option>
<option value='red' style='color:red'>Red</option>
<option value='orange' style='color:orange'>Orange</option>
<option value='brown' style='color:brown'>Brown</option>
<option value='yellow' style='color:yellow'>Yellow</option>
<option value='green' style='color:green'>Green</option>
<option value='lime' style='color:lime'>Lime</option>
<option value='olive' style='color:olive'>Olive</option>
<option value='cyan' style='color:cyan'>Cyan</option>
<option value='blue' style='color:blue'>Blue</option>
<option value='navy' style='color:navy'>Navy Blue</option>
<option value='purple' style='color:purple'>Purple</option>
<option value='violet' style='color:violet'>Violet</option>
<option value='black' style='color:black'>Black</option>
<option value='gray' style='color:gray'>Gray</option>
<option value='silver' style='color:silver'>Silver</option>
<option value='white' style='color:white'>White</option>
</select>
<select name='insertimage' class='textbox' style='margin-top:5px' onChange=\"insertText('body', '<img src=\'".str_replace("../","",IMAGES_N)."' + this.options[this.selectedIndex].value + '\' style=\'margin:5px\' align=\'left\'>');this.selectedIndex=0;\">
<option value=''>".$locale['421']."</option>
$image_list</select>
</td>
</tr>\n";
}
echo "<tr>\n<td valign='top' width='100' class='tbl'>".$locale['413']."</td>
<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox'>$body2</textarea></td>
</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>
<input type='button' value='b' class='button' style='font-weight:bold;width:25px' onClick=\"addText('body2', '<b>', '</b>');\">
<input type='button' value='i' class='button' style='font-style:italic;width:25px' onClick=\"addText('body2', '<i>', '</i>');\">
<input type='button' value='u' class='button' style='text-decoration:underline;width:25px' onClick=\"addText('body2', '<u>', '</u>');\">
<input type='button' value='link' class='button' style='width:35px' onClick=\"addText('body2', '<a href=\'', '\' target=\'_blank\'>Link</a>');\">
<input type='button' value='img' class='button' style='width:35px' onClick=\"addText('body2', '<img src=\'".str_replace("../","",IMAGES_N)."', '\' style=\'margin:5px\' align=\'left\'>');\">
<input type='button' value='center' class='button' style='width:45px' onClick=\"addText('body2', '<center>', '</center>');\">
<input type='button' value='small' class='button' style='width:40px' onClick=\"addText('body2', '<span class=\'small\'>', '</span>');\">
<input type='button' value='small2' class='button' style='width:45px' onClick=\"addText('body2', '<span class=\'small2\'>', '</span>');\">
<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\"><br>
<select name='setcolor' class='textbox' style='margin-top:5px' onChange=\"addText('body2', '<span style=\'color:' + this.options[this.selectedIndex].value + '\'>', '</span>');this.selectedIndex=0;\">
<option value=''>".$locale['420']."</option>
<option value='maroon' style='color:maroon'>Maroon</option>
<option value='red' style='color:red'>Red</option>
<option value='orange' style='color:orange'>Orange</option>
<option value='brown' style='color:brown'>Brown</option>
<option value='yellow' style='color:yellow'>Yellow</option>
<option value='green' style='color:green'>Green</option>
<option value='lime' style='color:lime'>Lime</option>
<option value='olive' style='color:olive'>Olive</option>
<option value='cyan' style='color:cyan'>Cyan</option>
<option value='blue' style='color:blue'>Blue</option>
<option value='navy' style='color:navy'>Navy Blue</option>
<option value='purple' style='color:purple'>Purple</option>
<option value='violet' style='color:violet'>Violet</option>
<option value='black' style='color:black'>Black</option>
<option value='gray' style='color:gray'>Gray</option>
<option value='silver' style='color:silver'>Silver</option>
<option value='white' style='color:white'>White</option>
</select>
<select name='insertimage' class='textbox' style='margin-top:5px' onChange=\"insertText('body2', '<img src=\'".str_replace("../","",IMAGES_N)."' + this.options[this.selectedIndex].value + '\' style=\'margin:5px\' align=\'left\'>');this.selectedIndex=0;\">
<option value=''>".$locale['421']."</option>
$image_list</select>
</td>
</tr>\n";
}
echo "<tr>
<td class='tbl'>".$locale['414']."</td>
<td class='tbl'><select name='news_start[mday]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_start['mday']) && $news_start['mday'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_start[mon]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_start['mon']) && $news_start['mon'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_start[year]' class='textbox'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_start['year']) && $news_start['year'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> /
<select name='news_start[hours]' class='textbox'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_start['hours']) && $news_start['hours'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> :
<select name='news_start[minutes]' class='textbox'>\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_start['minutes']) && $news_start['minutes'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> : 00 <span class='alt'>".$locale['416']."</span></td>
</tr>
<tr>
<td class='tbl'>".$locale['415']."</td>
<td class='tbl'><select name='news_end[mday]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_end['mday']) && $news_end['mday'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_end[mon]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_end['mon']) && $news_end['mon'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_end[year]' class='textbox'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_end['year']) && $news_end['year'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> /
<select name='news_end[hours]' class='textbox'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_end['hours']) && $news_end['hours'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> :
<select name='news_end[minutes]' class='textbox'>\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_end['minutes']) && $news_end['minutes'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> : 00 <span class='alt'>".$locale['416']."</span></td>
</tr>
<tr>
<td class='tbl'>".$locale['422']."</td>
<td class='tbl'><select name='news_visibility' class='textbox'>
$visibility_opts</select></td>
</tr>
<tr>
<td class='tbl'></td><td class='tbl'>
<input type='checkbox' name='news_sticky' value='yes'$news_sticky> ".$locale['426']."<br>\n";
if ($settings['tinymce_enabled'] != 1) echo "<input type='checkbox' name='line_breaks' value='yes'$news_breaks> ".$locale['417']."<br>\n";
echo "<input type='checkbox' name='news_comments' value='yes' onClick='SetRatings();'$news_comments> ".$locale['423']."<br>
<input type='checkbox' name='news_ratings' value='yes'$news_ratings> ".$locale['424']."</td>
</tr>
<tr>
<td align='center' colspan='2' class='tbl'><br>
<input type='submit' name='preview' value='".$locale['418']."' class='button'>
<input type='submit' name='save' value='".$locale['419']."' class='button'></td>
</tr>
</table>
</form>\n";
closetable();
echo "<script type='text/javascript'>
function DeleteNews() {
return confirm('".$locale['551']."');
}
function ValidateForm(frm) {
if(frm.news_subject.value=='') {
alert('".$locale['550']."');
return false;
}
}
function SetRatings() {
if (inputform.news_comments.checked == false) {
inputform.news_ratings.checked = false;
inputform.news_ratings.disabled = true;
} else {
inputform.news_ratings.disabled = false;
}
}
</script>\n";
}
echo "</td>\n";
require_once BASEDIR."footer.php";
?>
Edytowane przez Pieka dnia 01.04.2009 15:42:44
|
|
|
|
Wścibski Gość |
Dodany dnia 24.11.2024 21:01:44
|
Pan Kontekstualny
Postów: n^x
Data rejestracji: Zawsze
|
|
IP: localhost |
|
|
wlodekp |
Dodany dnia 25.04.2008 08:35:12
|
Weteran
Postów: 3101 Pomógł: 29
Data rejestracji: 21.05.2005 22:27
|
To nie jest taka prosta sprawa jak w Twoim kodzie.
Grafika jest plikiem i samo dodanie pola do formularza niczego nie załatwia, bo brak jest w nim funkcji wykonującej upload pliku move_uploaded_file a dodanie jej do dodaj news bez sprawdzania zawartości tego pliku przeczy zasadom bezpieczeństwa, bo to by działało, jeśli grafika poszłaby bez sprawdzeń na dzień dobry do images/news.
|
|
|
|
ravenger |
Dodany dnia 25.04.2008 11:57:13
|
Przedszkolak
Postów: 12
v7.02.03 Data rejestracji: 07.01.2008 22:36
|
Wiem że nie będzie łatwo.
Co do zabezpieczenia i kodu - to tylko wersja alpha, zawsze można tam wrzucić te funkcje które sprawdzają plik jak przy dodawaniu zdjęć. Najpierw chciałbym zrobić to tak by działało, później popracować nad bezpieczeństwem. |
|
|
|
wlodekp |
Dodany dnia 25.04.2008 12:29:14
|
Weteran
Postów: 3101 Pomógł: 29
Data rejestracji: 21.05.2005 22:27
|
Nie zrozumiałeś mnie to co chcesz osiągnąć jest realizowane w dwóch różnych dodaj: newsa i plik gdzie np sam plik przechodzi weryfikację admina i jeśli mowa o dodaj to sprawę należy traktować przez pryzmat dwóch plików submit.php:
dodaj co gdzie i jak oraz adminstration/submissions.php:
wstaw skąd gdzie i jak,
a może nawet nie plik a foto gdzie nastąpi skalowanie nie mniej jednak potrzebny będzie dodatkowy katalog przejściowy oczekiwania plików przed akceptacją, o takim elemencie zabezpieczeń mówie, bo nie można plików puścić bez weryfikacj, sprawdzenia- obraz skalowania itd.
Tak więc Twój kod w obecnej postaci nie zawiera nawet podstawowych rzeczy dodawania grafik-plików.
Wiele pracy przed Tobą.
|
|
|
|
ravenger |
Dodany dnia 25.04.2008 12:52:41
|
Przedszkolak
Postów: 12
v7.02.03 Data rejestracji: 07.01.2008 22:36
|
No nie zrozumieliśmy się.
Po co plik ma być weryfikowany przez admina jeśli to admin będzie go dodawał wraz z newsem? Możliwości dodawania plików przez użytkownika nie biorę pod uwagę, zresztą w pierwszym poście napisałem że chcę ułatwić życie adminom bo nie każdy z nich ma dostęp do ftp jak superadmin.
Co do kodu to zawiera on tylko formularz który nie działa no ale powiedzmy że to tylko projekt wstępny i jednocześnie wizualizacja - łatwiej zrobić screena czegoś co istnieje niż wklejać to w PS/Gimpie itp.
Generalnie ma to działać jak Twój upload przez ftp który zamieściłeś na forum, funkcja ma zwracać adres upniętego pliku i wklejać go do textarea, sprawdzanie poprawności pliku i jego ewentualne skalowanie można "zapożyczyć" z funkcji dodawania zdjęć.
Tyle teorii, gorzej z praktyką. |
|
|
|
kefirek |
Dodany dnia 25.04.2008 17:57:21
|
Zaawansowany
Postów: 1191 Pomógł: 418 Ostrzeżeń: 1
v6.00.xxx Data rejestracji: 06.04.2008 21:59
|
Hmmmm zrobiłem to o co ci chodziło dodajesz zdjęcie które się zapisuje w images\news\
I potem po dodaniu zdjęcia może je wybrać klikając na - Wybierz obraz – Zdjęcie dodajesz przed napisaniem newsa ponieważ następuje przeładowanie strony przy dodawaniu
Kolego ravenger w miejscu w którym ty wstawiłem formularz do wysłania pliku powoduje błąd wiec formularz musi być na początku przed znacznikiem:
echo "<form name='inputform' method='post' action='$action' onSubmit='return ValidateForm(this);'>
Nie może się znajdować w nim.
Oto kod całego formularza:
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright Š 2002 - 2006 Nick Jones
| http://www.php-fu...
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../maincore.php";
require_once "subheader.php";
require_once ADMIN."navigation.php";
include LOCALE.LOCALESET."admin/news-articles.php";
if (!checkrights("N") || !defined("iAUTH") || $aid != iAUTH) fallback("../index.php");
if (isset($news_id) && !isNum($news_id)) fallback(FUSION_SELF);
if ($settings['tinymce_enabled'] == 1) echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
if (isset($status)) {
if ($status == "su") {
$title = $locale['400'];
$message = "<b>".$locale['401']."</b>";
} elseif ($status == "sn") {
$title = $locale['404'];
$message = "<b>".$locale['405']."</b>";
} elseif ($status == "del") {
$title = $locale['406'];
$message = "<b>".$locale['407']."</b>";
}
opentable($title);
echo "<div align='center'>".$message."</div>\n";
closetable();
tablebreak();
if ($settings['rss']) require_once INFUSIONS."rss_builder/rss_builder.php";
}
if (isset($_POST['save'])) {
$news_subject = stripinput($_POST['news_subject']);
$news_cat = isNum($_POST['news_cat']) ? $_POST['news_cat'] : "0";
$body = addslash($_POST['body']);
$rss = addslash($_POST['rss']);
if ($_POST['body2']) $body2 = addslash(preg_replace("(^<p>\s</p>$)", "", $_POST['body2']));
$news_start_date = 0; $news_end_date = 0;
if ($_POST['news_start']['mday']!="--" && $_POST['news_start']['mon']!="--" && $_POST['news_start']['year']!="----") {
$news_start_date = mktime($_POST['news_start']['hours'],$_POST['news_start']['minutes'],0,$_POST['news_start']['mon'],$_POST['news_start']['mday'],$_POST['news_start']['year']);
}
if ($_POST['news_end']['mday']!="--" && $_POST['news_end']['mon']!="--" && $_POST['news_end']['year']!="----") {
$news_end_date = mktime($_POST['news_end']['hours'],$_POST['news_end']['minutes'],0,$_POST['news_end']['mon'],$_POST['news_end']['mday'],$_POST['news_end']['year']);
}
$news_visibility = isNum($_POST['news_visibility']) ? $_POST['news_visibility'] : "0";
$news_sticky = isset($_POST['news_sticky']) ? "1" : "0";
if ($settings['tinymce_enabled'] != 1) { $news_breaks = isset($_POST['line_breaks']) ? "y" : "n"; } else { $news_breaks = "n"; }
$news_comments = isset($_POST['news_comments']) ? "1" : "0";
$news_ratings = isset($_POST['news_ratings']) ? "1" : "0";
if (isset($news_id)) {
if ($news_sticky == "1") $result = dbquery("UPDATE ".$db_prefix."news SET news_sticky='0' WHERE news_sticky='1'");
$result = dbquery("UPDATE ".$db_prefix."news SET news_subject='$news_subject', news_cat='$news_cat', news_news='$body', news_extended='$body2', news_breaks='$news_breaks',".($news_start_date != 0 ? " news_datestamp='$news_start_date'," : "")." news_start='$news_start_date', news_end='$news_end_date', news_visibility='$news_visibility', news_sticky='$news_sticky', news_allow_comments='$news_comments', news_allow_ratings='$news_ratings', news_rss='$rss' WHERE news_id='$news_id'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
if ($news_sticky == "1") $result = dbquery("UPDATE ".$db_prefix."news SET news_sticky='0' WHERE news_sticky='1'");
$result = dbquery("INSERT INTO ".$db_prefix."news (news_subject, news_cat, news_news, news_extended, news_breaks, news_name, news_datestamp, news_start, news_end, news_visibility, news_reads, news_sticky, news_allow_comments, news_allow_ratings, news_rss) VALUES('$news_subject', '$news_cat', '$body', '$body2', '$news_breaks', '".$userdata['user_id']."', '".($news_start_date != 0 ? $news_start_date : time())."', '$news_start_date', '$news_end_date', '$news_visibility', '0', '$news_sticky', '$news_comments', '$news_ratings', '$rss')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} else if (isset($_POST['delete'])) {
$dane = dbarray(dbquery("SELECT news_name FROM ".$db_prefix."news WHERE news_id='$news_id'"));
if (EPS)
{
$przydzial = dbarray(dbquery("SELECT point_ammount from ".DB_PREFIX."eps_points WHERE point_id='5'"));
$result = dbquery("UPDATE ".DB_PREFIX."users SET points_normal=points_normal-".($przydzial['point_ammount'])." WHERE user_id='".$dane['news_name']."'");
}
$result = dbquery("DELETE FROM ".$db_prefix."news WHERE news_id='$news_id'");
$result = dbquery("DELETE FROM ".$db_prefix."comments WHERE comment_item_id='$news_id' and comment_type='N'");
$result = dbquery("DELETE FROM ".$db_prefix."ratings WHERE rating_item_id='$news_id' and rating_type='N'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$news_subject = stripinput($_POST['news_subject']);
$body = phpentities(stripslash($_POST['body']));
$bodypreview = parsesmileys(str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body'])));
if ($_POST['body2']) {
$body2 = phpentities(stripslash($_POST['body2']));
$body2preview = parsesmileys(str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body2'])));
}
if (isset($_POST['line_breaks'])) {
$news_breaks = " checked";
$bodypreview = nl2br($bodypreview);
if ($body2) $body2preview = nl2br($body2preview);
} else {
$news_breaks = "";
}
$news_start = array(
"mday" => isNum($_POST['news_start']['mday']) ? $_POST['news_start']['mday'] : "--",
"mon" => isNum($_POST['news_start']['mon']) ? $_POST['news_start']['mon'] : "--",
"year" => isNum($_POST['news_start']['year']) ? $_POST['news_start']['year'] : "----",
"hours" => isNum($_POST['news_start']['hours']) ? $_POST['news_start']['hours'] : "0",
"minutes" => isNum($_POST['news_start']['minutes']) ? $_POST['news_start']['minutes'] : "0",
);
$news_end = array(
"mday" => isNum($_POST['news_end']['mday']) ? $_POST['news_end']['mday'] : "--",
"mon" => isNum($_POST['news_end']['mon']) ? $_POST['news_end']['mon'] : "--",
"year" => isNum($_POST['news_end']['year']) ? $_POST['news_end']['year'] : "----",
"hours" => isNum($_POST['news_end']['hours']) ? $_POST['news_end']['hours'] : "0",
"minutes" => isNum($_POST['news_end']['minutes']) ? $_POST['news_end']['minutes'] : "0",
);
$news_sticky = isset($_POST['news_sticky']) ? " checked" : "";
$news_comments = isset($_POST['news_comments']) ? " checked" : "";
$news_ratings = isset($_POST['news_ratings']) ? " checked" : "";
opentable($news_subject);
echo "$bodypreview\n";
closetable();
if (isset($body2preview)) {
tablebreak();
opentable($news_subject);
echo "$body2preview\n";
closetable();
}
tablebreak();
}
$editlist = ""; $sel = "";
$result = dbquery("SELECT * FROM ".$db_prefix."news ORDER BY news_datestamp DESC");
if (dbrows($result) != 0) {
while ($data = dbarray($result)) {
if (isset($news_id)) $sel = ($news_id == $data['news_id'] ? " selected" : "");
$editlist .= "<option value='".$data['news_id']."'$sel>".$data['news_subject']."</option>\n";
}
}
opentable($locale['408']);
echo "<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."'>
<center>
<select name='news_id' class='textbox' style='width:250px'>
$editlist</select>
<input type='submit' name='edit' value='".$locale['409']."' class='button'>
<input type='submit' name='delete' value='".$locale['410']."' onclick='return DeleteNews();' class='button'>
</center>
</form>\n";
closetable();
tablebreak();
if (isset($_POST['edit'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."news WHERE news_id='$news_id'");
if (dbrows($result) != 0) {
$data = dbarray($result);
$news_subject = $data['news_subject'];
$news_cat = $data['news_cat'];
$body = phpentities(stripslashes($data['news_news']));
$body2 = phpentities(stripslashes($data['news_extended']));
$rss = phpentities(stripslashes($data['news_rss']));
if ($data['news_start'] > 0) $news_start = getdate($data['news_start']);
if ($data['news_end'] > 0) $news_end = getdate($data['news_end']);
$news_breaks = $data['news_breaks'] == "y" ? " checked" : "";
$news_comments = $data['news_allow_comments'] == "1" ? " checked" : "";
$news_ratings = $data['news_allow_ratings'] == "1" ? " checked" : "";
$news_visibility = $data['news_visibility'];
$news_sticky = $data['news_sticky'] == "1" ? " checked" : "";
}
}
if (isset($news_id)) {
$action = FUSION_SELF.$aidlink."&news_id=$news_id";
opentable($locale['400']);
} else {
if (!isset($_POST['preview'])) {
$news_subject = "";
$body = "";
$body2 = "";
$rss = "";
$news_breaks = " checked";
$news_comments = " checked";
$news_ratings = " checked";
$news_visibility = 0;
$news_sticky = "";
}
$action = FUSION_SELF.$aidlink;
opentable($locale['404']);
}
$image_files = makefilelist(IMAGES_N, ".|..|index.php", true);
$image_list = makefileopts($image_files);
$result = dbquery("SELECT * FROM ".$db_prefix."news_cats ORDER BY news_cat_name");
$news_cat_opts = ""; $sel = "";
if (dbrows($result)) {
while ($data = dbarray($result)) {
if (isset($news_cat)) $sel = ($news_cat == $data['news_cat_id'] ? " selected" : "");
$news_cat_opts .= "<option value='".$data['news_cat_id']."'$sel>".$data['news_cat_name']."</option>\n";
}
}
$visibility_opts = ""; $sel = "";
$user_groups = getusergroups();
while(list($key, $user_group) = each($user_groups)){
$sel = ($news_visibility == $user_group['0'] ? " selected" : "");
$visibility_opts .= "<option value='".$user_group['0']."'$sel>".$user_group['1']."</option>\n";
}
echo "<table align='center' cellpadding='0' cellspacing='0'>
<tr><form enctype='multipart/form-data' method='post'>
<td width='100' class='tbl'>Dodaj zdjęcie:</td>
<td width='80%' class='tbl'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<input name='plik' type='file' class='textbox' style='width: 300px'>
<input type='submit' value='dodaj zdjęcie' class='button'></td></form></tr>";
$plik_tmp = $_FILES['plik']['tmp_name'];
$plik_nazwa = $_FILES['plik']['name'];
if(is_uploaded_file($plik_tmp)) {
move_uploaded_file($plik_tmp, "../images/news/$plik_nazwa");
}
echo "<form name='inputform' method='post' action='$action' onSubmit='return ValidateForm(this);'>
<tr>
<td width='100' class='tbl'>".$locale['411']."</td>
<td width='80%' class='tbl'><input type='text' name='news_subject' value='$news_subject' class='textbox' style='width: 250px'></td>
</tr>
<tr>
<td width='100' class='tbl'>".$locale['511']."</td>
<td width='80%' class='tbl'><select name='news_cat' class='textbox'>
<option value='0'>".$locale['425']."</option>
$news_cat_opts</select>
</td>
</tr>
<tr>
<td valign='top' width='100' class='tbl'>".$locale['412']."</td>
<td width='80%' class='tbl'><textarea name='body' cols='95' rows='10' class='textbox'>$body</textarea></td>
</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>
<input type='button' value='b' class='button' style='font-weight:bold;width:25px' onClick=\"addText('body', '<b>', '</b>');\">
<input type='button' value='i' class='button' style='font-style:italic;width:25px' onClick=\"addText('body', '<i>', '</i>');\">
<input type='button' value='u' class='button' style='text-decoration:underline;width:25px' onClick=\"addText('body', '<u>', '</u>');\">
<input type='button' value='link' class='button' style='width:35px' onClick=\"addText('body', '<a href=\'http://\' target=\'_blank\'>', '</a>');\">
<input type='button' value='img' class='button' style='width:35px' onClick=\"addText('body', '<img src=\'".str_replace("../","",IMAGES_N)."', '\' style=\'margin:5px\' align=\'left\'>');\">
<input type='button' value='center' class='button' style='width:45px' onClick=\"addText('body', '<center>', '</center>');\">
<input type='button' value='small' class='button' style='width:40px' onClick=\"addText('body', '<span class=\'small\'>', '</span>');\">
<input type='button' value='small2' class='button' style='width:45px' onClick=\"addText('body', '<span class=\'small2\'>', '</span>');\">
<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body', '<span class=\'alt\'>', '</span>');\"><br>
<select name='setcolor' class='textbox' style='margin-top:5px' onChange=\"addText('body', '<span style=\'color:' + this.options[this.selectedIndex].value + '\'>', '</span>');this.selectedIndex=0;\">
<option value=''>".$locale['420']."</option>
<option value=' maroon' style='color:maroon'>Maroon</option>
<option value=' red' style='color:red'>Red</option>
<option value=' orange' style='color:orange'>Orange</option>
<option value=' brown' style='color:brown'>Brown</option>
<option value=' yellow' style='color:yellow'>Yellow</option>
<option value=' green' style='color:green'>Green</option>
<option value=' lime' style='color:lime'>Lime</option>
<option value=' olive' style='color:olive'>Olive</option>
<option value=' cyan' style='color:cyan'>Cyan</option>
<option value=' blue' style='color:blue'>Blue</option>
<option value=' navy' style='color:navy'>Navy Blue</option>
<option value=' purple' style='color:purple'>Purple</option>
<option value=' violet' style='color:violet'>Violet</option>
<option value=' black' style='color:black'>Black</option>
<option value=' gray' style='color:gray'>Gray</option>
<option value=' silver' style='color:silver'>Silver</option>
<option value=' white' style='color:white'>White</option>
</select>
<select name='insertimage' class='textbox' style='margin-top:5px' onChange=\"insertText('body', '<img src=\'".str_replace("../","",IMAGES_N)."' + this.options[this.selectedIndex].value + '\' style=\'margin:5px\' align=\'left\'>');this.selectedIndex=0;\">
<option value=''>".$locale['421']."</option>
$image_list</select>
</td>
</tr>\n";
}
echo "<tr><td> </td><td class='tbl2'>".displaysmileys("body")."</td></tr>";
echo "<tr>\n<td valign='top' width='100' class='tbl'>".$locale['413']."</td>
<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox'>$body2</textarea></td>
</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>
<input type='button' value='b' class='button' style='font-weight:bold;width:25px' onClick=\"addText('body2', '<b>', '</b>');\">
<input type='button' value='i' class='button' style='font-style:italic;width:25px' onClick=\"addText('body2', '<i>', '</i>');\">
<input type='button' value='u' class='button' style='text-decoration:underline;width:25px' onClick=\"addText('body2', '<u>', '</u>');\">
<input type='button' value='link' class='button' style='width:35px' onClick=\"addText('body2', '<a href=\'http://\' target=\'_blank\'>', '</a>');\">
<input type='button' value='img' class='button' style='width:35px' onClick=\"insertText('body2', '<img src=\'".str_replace("../","",IMAGES_N)."', '\' style=\'margin:5px\' align=\'left\'>');\">
<input type='button' value='center' class='button' style='width:45px' onClick=\"addText('body2', '<center>', '</center>');\">
<input type='button' value='small' class='button' style='width:40px' onClick=\"addText('body2', '<span class=\'small\'>', '</span>');\">
<input type='button' value='small2' class='button' style='width:45px' onClick=\"addText('body2', '<span class=\'small2\'>', '</span>');\">
<input type='button' value='alt' class='button' style='width:25px' onClick=\"addText('body2', '<span class=\'alt\'>', '</span>');\"><br>
<select name='setcolor' class='textbox' style='margin-top:5px' onChange=\"addText('body2', '<span style=\'color:' + this.options[this.selectedIndex].value + '\'>', '</span>');this.selectedIndex=0;\">
<option value=''>".$locale['420']."</option>
<option value='maroon' style='color:maroon'>Maroon</option>
<option value='red' style='color:red'>Red</option>
<option value='orange' style='color:orange'>Orange</option>
<option value='brown' style='color:brown'>Brown</option>
<option value='yellow' style='color:yellow'>Yellow</option>
<option value='green' style='color:green'>Green</option>
<option value='lime' style='color:lime'>Lime</option>
<option value='olive' style='color:olive'>Olive</option>
<option value='cyan' style='color:cyan'>Cyan</option>
<option value='blue' style='color:blue'>Blue</option>
<option value='navy' style='color:navy'>Navy Blue</option>
<option value='purple' style='color:purple'>Purple</option>
<option value='violet' style='color:violet'>Violet</option>
<option value='black' style='color:black'>Black</option>
<option value='gray' style='color:gray'>Gray</option>
<option value='silver' style='color:silver'>Silver</option>
<option value='white' style='color:white'>White</option>
</select>
<select name='insertimage' class='textbox' style='margin-top:5px' onChange=\"insertText('body2', '<img src=\'".str_replace("../","",IMAGES_N)."' + this.options[this.selectedIndex].value + '\' style=\'margin:5px\' align=\'left\'>');this.selectedIndex=0;\">
<option value=''>".$locale['421']."</option>
$image_list</select>
</td>
</tr>\n";
}
echo "<tr><td> </td><td class='tbl2'>".displaysmileys("body2")."</td></tr>
<tr><td class='tbl1' valign='top'>".$locale['rss']."</td><td class='tbl1'>
<textarea name='rss' cols='95' rows='10' class='textbox'>$rss</textarea></td></tr>";
echo "<tr>
<td class='tbl'>".$locale['414']."</td>
<td class='tbl'><select name='news_start[mday]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_start['mday']) && $news_start['mday'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_start[mon]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_start['mon']) && $news_start['mon'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_start[year]' class='textbox'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_start['year']) && $news_start['year'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> /
<select name='news_start[hours]' class='textbox'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_start['hours']) && $news_start['hours'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> :
<select name='news_start[minutes]' class='textbox'>\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_start['minutes']) && $news_start['minutes'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> : 00 <span class='alt'>".$locale['416']."</span></td>
</tr>
<tr>
<td class='tbl'>".$locale['415']."</td>
<td class='tbl'><select name='news_end[mday]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_end['mday']) && $news_end['mday'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_end[mon]' class='textbox'>\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_end['mon']) && $news_end['mon'] == $i ? " selected" : "").">$i</option>\n";
echo "</select>
<select name='news_end[year]' class='textbox'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_end['year']) && $news_end['year'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> /
<select name='news_end[hours]' class='textbox'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_end['hours']) && $news_end['hours'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> :
<select name='news_end[minutes]' class='textbox'>\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_end['minutes']) && $news_end['minutes'] == $i ? " selected" : "").">$i</option>\n";
echo "</select> : 00 <span class='alt'>".$locale['416']."</span></td>
</tr>
<tr>
<td class='tbl'>".$locale['422']."</td>
<td class='tbl'><select name='news_visibility' class='textbox'>
$visibility_opts</select></td>
</tr>
<tr>
<td class='tbl'></td><td class='tbl'>
<input type='checkbox' name='news_sticky' value='yes'$news_sticky> ".$locale['426']."<br>\n";
if ($settings['tinymce_enabled'] != 1) echo "<input type='checkbox' name='line_breaks' value='yes'$news_breaks> ".$locale['417']."<br>\n";
echo "<input type='checkbox' name='news_comments' value='yes' onClick='SetRatings();'$news_comments> ".$locale['423']."<br>
<input type='checkbox' name='news_ratings' value='yes'$news_ratings> ".$locale['424']."</td>
</tr>
<tr>
<td align='center' colspan='2' class='tbl'><br>
<input type='submit' name='preview' value='".$locale['418']."' class='button'>
<input type='submit' name='save' value='".$locale['419']."' class='button'></td>
</tr>
</table>
</form>\n";
if ($settings['tinymce_enabled']==0)
{
echo "<div style='text-align:center;'><br />";
require_once INCLUDES."colorpicker.php";
echo "</div>";
}
closetable();
echo "<script type='text/javascript'>
function DeleteNews() {
return confirm('".$locale['551']."');
}
function ValidateForm(frm) {
if(frm.news_subject.value=='') {
alert('".$locale['550']."');
return false;
}
}
function SetRatings() {
if (inputform.news_comments.checked == false) {
inputform.news_ratings.checked = false;
inputform.news_ratings.disabled = true;
} else {
inputform.news_ratings.disabled = false;
}
}
</script>\n";
}
echo "</td>\n";
require_once BASEDIR."footer.php";
?> Kliknij i zaczekaj na załadowanie kodu ...
Wklej u siebie ponizsze:
echo "<table align='center' cellpadding='0' cellspacing='0'>
<tr><form enctype='multipart/form-data' method='post'>
<td width='100' class='tbl'>Dodaj zdjęcie:</td>
<td width='80%' class='tbl'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<input name='plik' type='file' class='textbox' style='width: 300px'>
<input type='submit' value='dodaj zdjęcie' class='button'></td></form></tr>";
$plik_tmp = $_FILES['plik']['tmp_name'];
$plik_nazwa = $_FILES['plik']['name'];
if(is_uploaded_file($plik_tmp)) {
move_uploaded_file($plik_tmp, "../images/news/$plik_nazwa");
}
Kliknij i zaczekaj na załadowanie kodu ...
Edytowane przez Pieka dnia 01.04.2009 15:44:33
|
|
|
|
ravenger |
Dodany dnia 29.04.2008 23:08:00
|
Przedszkolak
Postów: 12
v7.02.03 Data rejestracji: 07.01.2008 22:36
|
Oki, dzięki, sprawdzę to w weekend |
|
|
|
piotrvx |
Dodany dnia 27.12.2009 01:48:56
|
Przedszkolak
Postów: 32 Ostrzeżeń: 2
Data rejestracji: 15.08.2009 23:27
|
Cześć, jest to bardzo fajny gadżet. Próbowałem zastosować to u siebie w PHP-Fusion 7 ale z mizernym skutkiem:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: news.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| 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 http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEME."header_mce.php";
include LOCALE.LOCALESET."admin/news.php";
if (!checkrights("N") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { fallback("../index.php"); }
if ($settings['tinymce_enabled']) {
echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
} else {
require_once INCLUDES."html_buttons_include.php";
}
if (isset($_GET['status'])) {
if ($_GET['status'] == "sn") {
$message = $locale['410'];
} elseif ($_GET['status'] == "su") {
$message = $locale['411'];
} elseif ($_GET['status'] == "del") {
$message = $locale['412'];
}
if ($message) { echo "<div class='admin-message'>".$message."</div>\n"; }
}
if (isset($_POST['save'])) {
$news_subject = stripinput($_POST['news_subject']);
$news_cat = isnum($_POST['news_cat']) ? $_POST['news_cat'] : "0";
$body = addslash($_POST['body']);
if ($_POST['body2']) {
$body2 = addslash(preg_replace("(^<p>\s</p>$)", "", $_POST['body2']));
} else {
$body2 = "";
}
$news_start_date = 0; $news_end_date = 0;
if ($_POST['news_start']['mday']!="--" && $_POST['news_start']['mon']!="--" && $_POST['news_start']['year']!="----") {
$news_start_date = mktime($_POST['news_start']['hours'],$_POST['news_start']['minutes'],0,$_POST['news_start']['mon'],$_POST['news_start']['mday'],$_POST['news_start']['year']);
}
if ($_POST['news_end']['mday']!="--" && $_POST['news_end']['mon']!="--" && $_POST['news_end']['year']!="----") {
$news_end_date = mktime($_POST['news_end']['hours'],$_POST['news_end']['minutes'],0,$_POST['news_end']['mon'],$_POST['news_end']['mday'],$_POST['news_end']['year']);
}
$news_visibility = isnum($_POST['news_visibility']) ? $_POST['news_visibility'] : "0";
$news_draft = isset($_POST['news_draft']) ? "1" : "0";
$news_sticky = isset($_POST['news_sticky']) ? "1" : "0";
if ($settings['tinymce_enabled'] != 1) { $news_breaks = isset($_POST['line_breaks']) ? "y" : "n"; } else { $news_breaks = "n"; }
$news_comments = isset($_POST['news_comments']) ? "1" : "0";
$news_ratings = isset($_POST['news_ratings']) ? "1" : "0";
if (isset($_POST['news_id']) && isnum($_POST['news_id'])) {
if ($news_sticky == "1") { $result = dbquery("UPDATE ".DB_NEWS." SET news_sticky='0' WHERE news_sticky='1'"); }
$result = dbquery("UPDATE ".DB_NEWS." SET news_subject='$news_subject', news_cat='$news_cat', news_news='$body', news_extended='$body2', news_breaks='$news_breaks',".($news_start_date != 0 ? " news_datestamp='$news_start_date'," : "")." news_start='$news_start_date', news_end='$news_end_date', news_visibility='$news_visibility', news_draft='$news_draft', news_sticky='$news_sticky', news_allow_comments='$news_comments', news_allow_ratings='$news_ratings' WHERE news_id='".$_POST['news_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
if ($news_sticky == "1") { $result = dbquery("UPDATE ".DB_NEWS." SET news_sticky='0' WHERE news_sticky='1'"); }
$result = dbquery("INSERT INTO ".DB_NEWS." (news_subject, news_cat, news_news, news_extended, news_breaks, news_name, news_datestamp, news_start, news_end, news_visibility, news_draft, news_sticky, news_reads, news_allow_comments, news_allow_ratings) VALUES ('$news_subject', '$news_cat', '$body', '$body2', '$news_breaks', '".$userdata['user_id']."', '".($news_start_date != 0 ? $news_start_date : time())."', '$news_start_date', '$news_end_date', '$news_visibility', '$news_draft', '$news_sticky', '0', '$news_comments', '$news_ratings')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} else if (isset($_POST['delete']) && (isset($_POST['news_id']) && isnum($_POST['news_id']))) {
$result = dbquery("DELETE FROM ".DB_NEWS." WHERE news_id='".$_POST['news_id']."'");
$result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$_POST['news_id']."' and comment_type='N'");
$result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$_POST['news_id']."' and rating_type='N'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$news_subject = stripinput($_POST['news_subject']);
$news_cat = isnum($_POST['news_cat']) ? $_POST['news_cat'] : "0";
$body = phpentities(stripslash($_POST['body']));
$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body']));
if ($_POST['body2']) {
$body2 = phpentities(stripslash($_POST['body2']));
$body2preview = str_replace("src='".str_replace("../", "", IMAGES_N), "src='".IMAGES_N, stripslash($_POST['body2']));
} else {
$body2 = "";
}
if (isset($_POST['line_breaks'])) {
$news_breaks = " checked='checked'";
$bodypreview = nl2br($bodypreview);
if ($body2) { $body2preview = nl2br($body2preview); }
} else {
$news_breaks = "";
}
$news_start = array(
"mday" => isnum($_POST['news_start']['mday']) ? $_POST['news_start']['mday'] : "--",
"mon" => isnum($_POST['news_start']['mon']) ? $_POST['news_start']['mon'] : "--",
"year" => isnum($_POST['news_start']['year']) ? $_POST['news_start']['year'] : "----",
"hours" => isnum($_POST['news_start']['hours']) ? $_POST['news_start']['hours'] : "0",
"minutes" => isnum($_POST['news_start']['minutes']) ? $_POST['news_start']['minutes'] : "0",
);
$news_end = array(
"mday" => isnum($_POST['news_end']['mday']) ? $_POST['news_end']['mday'] : "--",
"mon" => isnum($_POST['news_end']['mon']) ? $_POST['news_end']['mon'] : "--",
"year" => isnum($_POST['news_end']['year']) ? $_POST['news_end']['year'] : "----",
"hours" => isnum($_POST['news_end']['hours']) ? $_POST['news_end']['hours'] : "0",
"minutes" => isnum($_POST['news_end']['minutes']) ? $_POST['news_end']['minutes'] : "0",
);
$news_visibility = isnum($_POST['news_visibility']) ? $_POST['news_visibility'] : "0";
$news_draft = isset($_POST['news_draft']) ? " checked='checked'" : "";
$news_sticky = isset($_POST['news_sticky']) ? " checked='checked'" : "";
$news_comments = isset($_POST['news_comments']) ? " checked='checked'" : "";
$news_ratings = isset($_POST['news_ratings']) ? " checked='checked'" : "";
opentable($news_subject);
echo "$bodypreview\n";
closetable();
if (isset($body2preview)) {
opentable($news_subject);
echo "$body2preview\n";
closetable();
}
}
$result = dbquery("SELECT * FROM ".DB_NEWS." ORDER BY news_draft DESC, news_datestamp DESC");
if (dbrows($result) != 0) {
$editlist = ""; $sel = "";
while ($data = dbarray($result)) {
if ((isset($_POST['news_id']) && isnum($_POST['news_id'])) || (isset($_GET['news_id']) && isnum($_GET['news_id']))) {
$news_id = isset($_POST['news_id']) ? $_POST['news_id'] : $_GET['news_id'];
$sel = ($news_id == $data['news_id'] ? " selected='selected'" : "");
}
$editlist .= "<option value='".$data['news_id']."'$sel>".($data['news_draft'] ? $locale['438']." " : "").$data['news_subject']."</option>\n";
}
opentable($locale['400']);
echo "<div style='text-align:center; width: 250px; margin: 0 auto'>\n<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."&action=edit'>\n";
echo "<select name='news_id' style='width:250px;'>\n".$editlist."</select><br />\n";
echo "<input type='submit' name='edit' value='".$locale['420']."' class='button' />\n";
echo "<input type='submit' name='delete' value='".$locale['421']."' onclick='return DeleteNews();' class='button' />\n";
echo "</form>\n</div>\n";
closetable();
}
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['news_id']) && isnum($_POST['news_id'])) || (isset($_GET['news_id']) && isnum($_GET['news_id']))) {
$result = dbquery("SELECT * FROM ".DB_NEWS." WHERE news_id='".(isset($_POST['news_id']) ? $_POST['news_id'] : $_GET['news_id'])."'");
if (dbrows($result)) {
$data = dbarray($result);
$news_subject = $data['news_subject'];
$news_cat = $data['news_cat'];
$body = phpentities(stripslashes($data['news_news']));
$body2 = phpentities(stripslashes($data['news_extended']));
if ($data['news_start'] > 0) $news_start = getdate($data['news_start']);
if ($data['news_end'] > 0) $news_end = getdate($data['news_end']);
$news_visibility = $data['news_visibility'];
$news_draft = $data['news_draft'] == "1" ? " checked='checked'" : "";
$news_sticky = $data['news_sticky'] == "1" ? " checked='checked'" : "";
$news_breaks = $data['news_breaks'] == "y" ? " checked='checked'" : "";
$news_comments = $data['news_allow_comments'] == "1" ? " checked='checked'" : "";
$news_ratings = $data['news_allow_ratings'] == "1" ? " checked='checked'" : "";
} else {
redirect(FUSION_SELF.$aidlink);
}
}
if ((isset($_POST['news_id']) && isnum($_POST['news_id'])) || (isset($_GET['news_id']) && isnum($_GET['news_id']))) {
opentable($locale['402']);
} else {
if (!isset($_POST['preview'])) {
$news_subject = "";
$news_cat = "0";
$body = "";
$body2 = "";
$news_visibility = 0;
$news_draft = "";
$news_sticky = "";
$news_breaks = " checked='checked'";
$news_comments = " checked='checked'";
$news_ratings = " checked='checked'";
}
opentable($locale['401']);
}
$result = dbquery("SELECT * FROM ".DB_NEWS_CATS." ORDER BY news_cat_name");
$news_cat_opts = ""; $sel = "";
if (dbrows($result)) {
while ($data = dbarray($result)) {
if (isset($news_cat)) $sel = ($news_cat == $data['news_cat_id'] ? " selected='selected'" : "");
$news_cat_opts .= "<option value='".$data['news_cat_id']."'$sel>".$data['news_cat_name']."</option>\n";
}
}
$visibility_opts = ""; $sel = "";
$user_groups = getusergroups();
while(list($key, $user_group) = each($user_groups)){
$sel = ($news_visibility == $user_group['0'] ? " selected='selected'" : "");
$visibility_opts .= "<option value='".$user_group['0']."'$sel>".$user_group['1']."</option>\n";
}
echo
"<table align='center' cellpadding='0' cellspacing='0'>
<tr><form enctype='multipart/form-data' method='post'>
<td width='100' class='tbl'>Dodaj zdjęcie:</td>
<td width='80%' class='tbl'> <input type='hidden' name='MAX_FILE_SIZE' value='1000000'>
<input name='plik' type='file' class='textbox' style='width: 300px'>
<input type='submit' value='dodaj zdjęcie' class='button'></td></form></tr>"
;
$plik_tmp = $_FILES['plik']['tmp_name'];
$plik_nazwa = $_FILES['plik']['name'];
if(is_uploaded_file($plik_tmp)) {
move_uploaded_file($plik_tmp, "../images/news/$plik_nazwa");
}
echo "<form name='inputform' method='post' action='".FUSION_SELF.$aidlink."' onsubmit='return ValidateForm(this);'>\n";
echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['422']."</td>\n";
echo "<td width='80%' class='tbl'><input type='text' name='news_subject' value='".$news_subject."' class='textbox' style='width: 250px' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>".$locale['423']."</td>\n";
echo "<td width='80%' class='tbl'><select name='news_cat' >\n";
echo "<option value='0'>".$locale['424']."</option>\n".$news_cat_opts."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' width='100' class='tbl'>".$locale['425']."</td>\n";
echo "<td width='80%' class='tbl'><textarea name='body' cols='95' rows='10' class='textbox' style='width:500px'>".$body."</textarea></td>\n";
echo "</tr>\n";
if (!$settings['tinymce_enabled']) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>\n";
echo display_html("inputform", "body", true, true, true, IMAGES_N);
echo "</td>\n</tr>\n";
}
echo "<tr>\n<td valign='top' width='100' class='tbl'>".$locale['426']."</td>\n";
echo "<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox' style='width:500px'>".$body2."</textarea></td>\n";
echo "</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td>\n<td class='tbl'>\n";
echo display_html("inputform", "body2", true, true, true, IMAGES_N);
echo "</td>\n</tr>\n";
}
echo "<tr>\n";
echo "<td class='tbl'>".$locale['427']."</td>\n";
echo "<td class='tbl'><div class='div-sel'><select name='news_start[mday]' >\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_start['mday']) && $news_start['mday'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'><select name='news_start[mon]' >\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_start['mon']) && $news_start['mon'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'><select name='news_start[year]'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_start['year']) && $news_start['year'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>/</div><div class='div-sel'><select name='news_start[hours]'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_start['hours']) && $news_start['hours'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>:</div><div class='div-sel'><select name='news_start[minutes]' >\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_start['minutes']) && $news_start['minutes'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>:</div><div class='div-sel'>00 ".$locale['429']."</div></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['428']."</td>\n";
echo "<td class='tbl'><div class='div-sel'><select name='news_end[mday]'>\n<option>--</option>\n";
for ($i=1;$i<=31;$i++) echo "<option".(isset($news_end['mday']) && $news_end['mday'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'><select name='news_end[mon]'>\n<option>--</option>\n";
for ($i=1;$i<=12;$i++) echo "<option".(isset($news_end['mon']) && $news_end['mon'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'><select name='news_end[year]'>\n<option>----</option>\n";
for ($i=2004;$i<=2010;$i++) echo "<option".(isset($news_end['year']) && $news_end['year'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>/</div><div class='div-sel'><select name='news_end[hours]'>\n";
for ($i=0;$i<=24;$i++) echo "<option".(isset($news_end['hours']) && $news_end['hours'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>:</div><div class='div-sel'><select name='news_end[minutes]'>\n";
for ($i=0;$i<=60;$i++) echo "<option".(isset($news_end['minutes']) && $news_end['minutes'] == $i ? " selected='selected'" : "").">$i</option>\n";
echo "</select></div><div class='div-sel'>:</div><div class='div-sel'>00 ".$locale['429']."</div></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'>".$locale['430']."</td>\n";
echo "<td class='tbl'><select name='news_visibility'>\n".$visibility_opts."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'></td><td class='tbl'><div class='custom-checkbox'>\n";
echo "<input type='checkbox' name='news_draft' id='news_draft' value='yes'".$news_draft." /><label for='news_draft'> ".$locale['431']."</label><br />\n";
echo "<input type='checkbox' name='news_sticky' id='news_sticky' value='yes'".$news_sticky." /><label for='news_sticky'> ".$locale['432']."</label><br />\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<input type='checkbox' name='line_breaks' id='line_breaks' value='yes'".$news_breaks." /><label for='line_breaks'> ".$locale['433']."</label><br />\n";
}
echo "<input type='checkbox' name='news_comments' id='news_comments' value='yes' onclick='SetRatings();'".$news_comments." /><label for='news_comments'> ".$locale['434']."</label><br />\n";
echo "<input type='checkbox' name='news_ratings' id='news_ratings' value='yes'".$news_ratings." /><label for='news_ratings'> ".$locale['435']."</label></div></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
if ((isset($_POST['edit']) && (isset($_POST['news_id']) && isnum($_POST['news_id']))) || (isset($_POST['preview']) && (isset($_POST['news_id']) && isnum($_POST['news_id']))) || (isset($_GET['news_id']) && isnum($_GET['news_id']))) {
echo "<input type='hidden' name='news_id' value='".(isset($_POST['news_id']) ? $_POST['news_id'] : $_GET['news_id'])."' />\n";
}
echo "<input type='submit' name='preview' value='".$locale['436']."' class='button' />\n";
echo "<input type='submit' name='save' value='".$locale['437']."' class='button' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
closetable();
echo "<script type='text/javascript'>\n"."function DeleteNews() {\n";
echo "return confirm('".$locale['451']."');\n}\n";
echo "function ValidateForm(frm) {\n"."if(frm.news_subject.value=='') {\n";
echo "alert('".$locale['450']."');\n"."return false;\n}\n}\n";
echo "function SetRatings() {\n"."if (inputform.news_comments.checked == false) {\n";
echo "inputform.news_ratings.checked = false;\n"."inputform.news_ratings.disabled = true;\n";
echo "} else {\n"."inputform.news_ratings.disabled = false;\n}\n}\n</script>\n";
}
require_once THEME."footer.php";
?>
Edytowane przez Pieka dnia 27.12.2009 02:33:06
|
|
|