Bywalec
Postów: 888 Pomógł: 66
Data rejestracji: 19.08.2007 19:49
|
@diablo, twój kod niestety nie działa, bo przy edytowaniu (bez względu na to czy została przypisana miniatura czy nie) pokazuje zawsze pierwszy obrazek.
@kefirek, sprawdziłem zmienne i $img zwraca prawidłową wartość. Zmiana niestety nie pomogła.
Cały kod:
require_once "../maincore.php";
require_once THEMES."templates/admin_header_mce.php";
if (!checkrights("R") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
if ($settings['tinymce_enabled'] == 1) {
echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
} else {
require_once INCLUDES."html_buttons_include.php";
}
if (isset($_GET['status']) && !isset($message)) {
if ($_GET['status'] == "sn") {
$message = "Dodano recenzję.";
} elseif ($_GET['status'] == "su") {
$message = "Zaktualizowano recenzję.";
} elseif ($_GET['status'] == "del") {
$message = "Usunięto recenzję.";
}
if ($message) { echo "<div class='admin-message'>".$message."</div>\n"; }
}
$result = dbquery("SELECT * FROM ".DB_RECENZJE_CATS);
if (dbrows($result)) {
if (isset($_POST['save'])) {
$subject = stripinput($_POST['subject']);
$subject_jap = stripinput($_POST['subject_jap']);
$subject_ang = stripinput($_POST['subject_ang']);
$subject_pl = stripinput($_POST['subject_pl']);
$img = stripinput($_POST['img']);
$body = addslash($_POST['body']);
$body2 = addslash($_POST['body2']);
$draft = isset($_POST['recenzje_draft']) ? "1" : "0";
$filer = isset($_POST['recenzje_filer']) ? "1" : "0";
if ($settings['tinymce_enabled'] != 1) { $breaks = isset($_POST['line_breaks']) ? "y" : "n"; } else { $breaks = "n"; }
$odp = stripinput($_POST['odp']);
$comments = isset($_POST['recenzje_comments']) ? "1" : "0";
$ratings = isset($_POST['recenzje_ratings']) ? "1" : "0";
if (isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id'])) {
$result = dbquery("UPDATE ".DB_RECENZJE." SET recenzje_cat='".intval($_POST['recenzje_cat'])."', recenzje_subject='$subject', recenzje_subject_jap='$subject_jap', recenzje_subject_ang='$subject_ang', recenzje_subject_pl='$subject_pl', recenzje_img='$img', recenzje_snippet='$body', recenzje_article='$body2', recenzje_draft='$draft', recenzje_filer='$filer', recenzje_breaks='$breaks', recenzje_odp='$odp', recenzje_allow_comments='$comments', recenzje_allow_ratings='$ratings' WHERE recenzje_id='".$_POST['recenzje_id']."'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$result = dbquery("INSERT INTO ".DB_RECENZJE." (recenzje_cat, recenzje_subject, recenzje_subject_jap, recenzje_subject_ang, recenzje_subject_pl, recenzje_img, recenzje_snippet, recenzje_article, recenzje_draft, recenzje_filer, recenzje_breaks, recenzje_odp, recenzje_name, recenzje_datestamp, recenzje_reads, recenzje_allow_comments, recenzje_allow_ratings) VALUES ('".intval($_POST['recenzje_cat'])."', '$subject', '$subject_jap', '$subject_ang', '$subject_pl', '$img', '$body', '$body2', '$draft', '$filer', '$breaks', '$odp', '".$userdata['user_id']."', '".time()."', '0', '$comments', '$ratings')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} else if (isset($_POST['delete']) && (isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id']))) {
$result = dbquery("DELETE FROM ".DB_RECENZJE." WHERE recenzje_id='".$_POST['recenzje_id']."'");
$result = dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$_POST['recenzje_id']."' and comment_type='R'");
$result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$_POST['recenzje_id']."' and rating_type='R'");
redirect(FUSION_SELF.$aidlink."&status=del");
} else {
if (isset($_POST['preview'])) {
$recenzje_cat = $_POST['recenzje_cat'];
$subject = stripinput($_POST['subject']);
$subject_jap = stripinput($_POST['subject_jap']);
$subject_ang = stripinput($_POST['subject_ang']);
$subject_pl = stripinput($_POST['subject_pl']);
$img = stripinput($_POST['img']);
$body = phpentities(stripslash($_POST['body']));
$body2 = phpentities(stripslash($_POST['body2']));
$bodypreview = str_replace("src='".str_replace("../", "", IMAGES_R), "src='".IMAGES_R, stripslash($_POST['body']));
$body2preview = str_replace("src='".str_replace("../", "", IMAGES_R), "src='".IMAGES_R, stripslash($_POST['body2']));
$draft = isset($_POST['recenzje_draft']) ? " checked='checked'" : "";
$filer = isset($_POST['recenzje_filer']) ? " checked='checked'" : "";
$odp = stripinput($_POST['odp']);
if (isset($_POST['line_breaks'])) {
$breaks = " checked='checked'";
$bodypreview = nl2br($bodypreview);
$body2preview = nl2br($body2preview);
} else {
$breaks = "";
}
$comments = isset($_POST['recenzje_comments']) ? " checked='checked'" : "";
$ratings = isset($_POST['recenzje_ratings']) ? " checked='checked'" : "";
opentable($subject);
echo $bodypreview."\n";
closetable();
opentable($subject);
echo $body2preview."\n";
closetable();
}
$result = dbquery("SELECT * FROM ".DB_RECENZJE." ORDER BY recenzje_draft DESC, recenzje_datestamp DESC");
if (dbrows($result)) {
$editlist = "";
$sel = "";
while ($data = dbarray($result)) {
if ((isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id'])) || (isset($_GET['recenzje_id']) && isnum($_GET['recenzje_id']))) {
$recenzje_id = isset($_POST['recenzje_id']) ? $_POST['recenzje_id'] : $_GET['recenzje_id'];
$sel = ($recenzje_id == $data['recenzje_id'] ? " selected='selected'" : "");
} else {
$sel = "";
}
$editlist .= "<option value='".$data['recenzje_id']."'".$sel.">".($data['recenzje_draft'] ? "[SZKIC]"." " : "").$data['recenzje_subject']."</option>\n";
}
opentable("Istniej±ce recenzje");
echo "<div style='text-align:center'>\n<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."&action=edit'>\n";
echo "<select name='recenzje_id' class='textbox' style='width:250px;'>\n".$editlist."</select>\n";
echo "<input type='submit' name='edit' value='Edytuj' class='button' />\n";
echo "<input type='submit' name='delete' value='Usuń' onclick='return DeleteRecenzje();' class='button' />\n";
echo "</form>\n</div>\n";
closetable();
}
if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id'])) || (isset($_GET['recenzje_id']) && isnum($_GET['recenzje_id']))) {
$result = dbquery("SELECT * FROM ".DB_RECENZJE." WHERE recenzje_id='".(isset($_POST['recenzje_id']) ? $_POST['recenzje_id'] : $_GET['recenzje_id'])."'");
if (dbrows($result)) {
$data = dbarray($result);
$recenzje_cat = $data['recenzje_cat'];
$subject = $data['recenzje_subject'];
$subject_jap = $data['recenzje_subject_jap'];
$subject_ang = $data['recenzje_subject_ang'];
$subject_pl = $data['recenzje_subject_pl'];
$img = $data['recenzje_img'];
$body = phpentities(stripslashes($data['recenzje_snippet']));
$body2 = phpentities(stripslashes($data['recenzje_article']));
$draft = $data['recenzje_draft'] ? " checked='checked'" : "";
$filer = $data['recenzje_filer'] ? " checked='checked'" : "";
$breaks = $data['recenzje_breaks'] == "y" ? " checked='checked'" : "";
$odp = $data['recenzje_odp'];
$comments = $data['recenzje_allow_comments'] ? " checked='checked'" : "";
$ratings = $data['recenzje_allow_ratings'] ? " checked='checked'" : "";
} else {
redirect(FUSION_SELF.$aidlink);
}
}
if ((isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id'])) || (isset($_GET['recenzje_id']) && isnum($_GET['recenzje_id']))) {
opentable("Edytuj recenzję");
} else {
if (!isset($_POST['preview'])) {
$subject = "";
$subject_jap = "";
$subject_ang = "";
$subject_pl = "";
$img = "";
$body = "";
$body2 = "";
$draft = "";
$filer = "";
$breaks = " checked='checked'";
$odp = "";
$comments = " checked='checked'";
$ratings = " checked='checked'";
}
opentable("Dodaj recenzję");
}
$result = dbquery("SELECT * FROM ".DB_RECENZJE_CATS." ORDER BY recenzje_cat_name DESC");
$catlist = "";
$sel = "";
while ($data = dbarray($result)) {
if (isset($recenzje_cat)) $sel = ($recenzje_cat == $data['recenzje_cat_id'] ? " selected='selected'" : "");
$catlist .= "<option value='".$data['recenzje_cat_id']."'$sel>".$data['recenzje_cat_name']."</option>\n";
}
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'>Kategoria:</td>\n";
echo "<td class='tbl'><select name='recenzje_cat' class='textbox' style='width:250px;'>".$catlist."</select></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Numer:</td>\n";
echo "<td class='tbl'><input type='text' name='subject' value='$subject' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Tytuł oryginalny:</td>\n";
echo "<td class='tbl'><input type='text' name='subject_jap' value='$subject_jap' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Tytuł angielski:</td>\n";
echo "<td class='tbl'><input type='text' name='subject_ang' value='$subject_ang' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Tytuł polski:</td>\n";
echo "<td class='tbl'><input type='text' name='subject_pl' value='$subject_pl' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td width='100' class='tbl'>Miniaturka:</td>\n";
echo "<td class='tbl'>";
echo "<select name='img' class='textbox' style='width:250px;' />";
echo "<option>---</option>";
$dir = opendir(IMAGES_R);
$list = "";
$sel2 = "";
while (false !== ($file = readdir($dir))) {
if($file != '.' && $file != '..') {
if (isset($img)) $sel2 = ($file == $data['recenzje_img'] ? " selected='selected'" : "");
$list .= "<option value='".$file."'$sel2>".$file."</option>\n";
}
}
echo $list."</select>";
echo "</td>\n";
echo "</tr>\n<tr>\n";
echo "<td valign='top' width='100' class='tbl'>Streszczenie:</td>\n";
echo "<td class='tbl'><textarea name='body' cols='95' rows='5' class='textbox' style='width:98%'>".$body."</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", "body", true, true, true, IMAGES_R);
echo "</td>\n</tr>\n";
}
echo "<tr>\n<td valign='top' width='100' class='tbl'>Tre¶ć:</td>\n";
echo "<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox' style='width:98%'>".$body2."</textarea></td>\n";
echo "</tr>\n";
if ($settings['tinymce_enabled'] != 1) {
echo "<tr>\n<td class='tbl'></td><td class='tbl'>\n";
echo "<input type='button' value='Dodaj stronę' class='button' style='width:80px;' onclick=\"insertText('body2', '<--PAGEBREAK-->');\" />\n";
echo display_html("inputform", "body2", true, true, true, IMAGES_R);
echo "</td>\n</tr>\n";
}
echo "<td width='100' class='tbl'>Odpowiednik w anime/mandze:</td>\n";
echo "<td class='tbl'><input type='text' name='odp' value='$odp' class='textbox' style='width:250px;' /></td>\n";
echo "</tr>\n<tr>\n";
echo "<td class='tbl'></td><td class='tbl'>\n";
echo "<label><input type='checkbox' name='recenzje_filer' value='yes'".$filer." /> Czy jest to filer?</label><br />\n";
echo "<label><input type='checkbox' name='recenzje_draft' value='yes'".$draft." /> Zapisz jako szkic</label><br />\n";
if ($settings['tinymce_enabled'] != 1) { echo "<label><input type='checkbox' name='line_breaks' value='yes'".$breaks." /> Wł±cz automatyczne łamanie linii</label><br />\n"; }
echo "<label><input type='checkbox' name='recenzje_comments' value='yes'".$comments." /> Wł±cz komentarze</label><br />\n";
echo "<label><input type='checkbox' name='recenzje_ratings' value='yes'".$ratings." /> Wł±cz ocenianie</label></td>\n";
echo "</tr>\n<tr>\n";
echo "<td align='center' colspan='2' class='tbl'><br />\n";
if ((isset($_POST['recenzje_id']) && isnum($_POST['recenzje_id'])) || (isset($_GET['recenzje_id']) && isnum($_GET['recenzje_id']))) {
echo "<input type='hidden' name='recenzje_id' value='".(isset($_POST['recenzje_id']) ? $_POST['recenzje_id'] : $_GET['recenzje_id'])."' />\n";
}
echo "<input type='submit' name='preview' value='Podgl±d' class='button' />\n";
echo "<input type='submit' name='save' value='Zapisz' class='button' /></td>\n";
echo "</tr>\n</table>\n</form>\n";
closetable();
echo "<script type='text/javascript'>"."\n"."function DeleteRecenzje() {\n";
echo "return confirm('Usun±ć recenzję?');\n}\n";
echo "function ValidateForm(frm) {"."\n"."if(frm.subject.value=='') {\n";
echo "alert('Wpisz temat.');"."\n"."return false;\n}\n}\n</script>\n";
}
} else {
opentable("Recenzje");
echo "<div style='text-align:center'>Nie zdefiowano kategorii recenzji<br />\nPrzed dodaniem recenzji musisz zdefiniować przynajmniej jedn± kategorię recenzji.<br />\n";
echo "<a href='recenzje_cats.php".$aidlink."'>Utwórz kategorię recenzji</a></div>\n";
closetable();
}
require_once THEMES."templates/footer.php";
Kliknij i zaczekaj na załadowanie kodu ...
Edytowane przez Szapko dnia 01.06.2010 20:25:19
|