Sveiki, iškilo problema: persidarinėjant php-fusion kažką "prisvilinau" : Kaip suprantu per admin panel sukuriant naujienas, jas išsaugo, bet pagrindiniame puslapyje jų neatkuria. Nebežinau kame bus problema, tikiuosi, kad padėsite. (+10)
/news.php failas:
<?php
require_once "maincore.php";
require_once "header.php";
if (isset($readmore) && !isNum($readmore)) fallback(FUSION_SELF);
// Predefined variables, do not edit these values
if ($settings['news_style'] == "1") { $i = 0; $rc = 0; $ncount = 1; $ncolumn = 1; $news_[0] = ""; $news_[1] = ""; $news_[2] = ""; } else { $i = 1; }
// This number should be an odd number to keep layout tidy
$items_per_page = 11;
$rows = dbcount("(news_id)", "news", groupaccess('news_visibility')."");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$result = dbquery(
"SELECT tn.*, tc.*, user_id, user_name FROM ".$db_prefix."news tn
LEFT JOIN ".$db_prefix."users tu ON tn.news_name=tu.user_id
LEFT JOIN ".$db_prefix."news_cats tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().")
ORDER BY news_sticky DESC, news_datestamp DESC LIMIT $rowstart,$items_per_page"
);
$numrows = dbrows($result);
if ($settings['news_style'] == "1") $nrows = round((dbrows($result) - 1) / 2);
while ($data = dbarray($result)) {
$news_subject = "<a name='news_".$data['news_id']."' id='news_".$data['news_id']."'></a>".stripslashes($data['news_subject']);
$news_news = $data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news']);
$news_info = array(
"news_id" => $data['news_id'],
"news_date" => $data['news_datestamp'],
);
if ($settings['news_style'] == "1") {
if ($rows <= 2 || $ncount == 1) {
$news_[0] .= "<table width='100%' cellpadding='0' cellspacing='0'>\n";
$news_[0] .= "<tr>\n<td class='tbl2'><b>$news_subject</b></td>\n</tr>\n";
$news_[0] .= "<tr>\n<td class='tbl1' style='text-align:justify'>$news_news</td>\n</tr>\n";
$news_[0] .= "<tr>\n<td align='center' class='tbl2'>\n";
$news_[0] .= "</td>\n</tr>\n</table>\n";
} else {
if ($i == $nrows && $ncolumn != 2) { $ncolumn = 2; $i = 0; }
$row_color = ($rc % 2 == 0 ? "tbl2" : "tbl1");
$news_[$ncolumn] .= "<table width='100%' cellpadding='0' cellspacing='0'>\n";
$news_[$ncolumn] .= "<tr>\n<td class='tbl2'><b>$news_subject</b></td>\n</tr>\n";
$news_[$ncolumn] .= "<tr>\n<td class='tbl1' style='text-align:justify'>$news_news</td>\n</tr>\n";
$news_[$ncolumn] .= "<tr>\n<td align='center' class='tbl2'>\n";
$i++; $rc++;
}
$ncount++;
} else {
echo "<table cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td class='capmain'>$news_subject</td>
</tr>
<tr>
<td class='main-body'>$news_news</td>
</tr>
</table>";
$i++;
}
}
if ($settings['news_style'] == "1") {
echo "<table cellpadding='0' cellspacing='0' style='width:100%'>\n<tr>\n<td colspan='3' style='width:100%'>\n";
echo $news_[0];
echo "</td>\n</tr>\n<tr>\n<td style='width:50%;vertical-align:top;'>\n";
echo $news_[1];
echo "</td>\n<td style='width:50%;vertical-align:top;'>\n";
echo $news_[2];
echo "</td>\n</tr>\n</table>\n";
}
if ($rows > $items_per_page) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,$items_per_page,$rows,3)."\n</div>\n";
} else {
echo "Naujienos";
echo "<center><br>Naujienu nera.</center>\n";
}
require_once "footer.php";
?>
admin/news.php failas:
<?php
require_once "../maincore.php";
require_once "../header.php";
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'");
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']));
echo "$bodypreview\n";
}
$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";
}
}
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";
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'];
$body = phpentities(stripslashes($data['news_news']));
}
}
if (isset($news_id)) {
$action = FUSION_SELF.$aidlink."&news_id=$news_id";
} else {
if (!isset($_POST['preview'])) {
$news_subject = "";
$body = "";
}
$action = FUSION_SELF.$aidlink;
}
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 valign='top' width='100' class='tbl'>".$locale['412']."</td>
<td width='80%' class='tbl'><textarea name='body' cols='38' rows='5' class='textbox'>$body</textarea></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";
echo "<script type='text/javascript'>
function DeleteNews() {
return confirm('".$locale['551']."');
}
</script>\n";
}
echo "</td>\n";
require_once BASEDIR."footer.php";
?>
|