Просмотр файла banners.ru/www/admin/news.php

Размер файла: 5.2Kb
<? 
Error_Reporting(E_ALL & ~E_NOTICE);
session_start();
require ('../data/config.php');
require ('../data/mysql.php');
require ('../data/functions.php');
require ('../data/mail.php');
if ($cookie_user<>$admin_login and $cookie_passwd<>$admin_passw)
        {
        header("Location:/index.php?err=falce");
        exit();
        }
?>
<html>
<head><meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml" charset="utf-8"/>
<title>Администраторская - <? print "$site_title";?></title>
<? require ('../html/style.php');?>
</head>

<BODY BGCOLOR=#D3DDF4 LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<center>
<? require ('../html/up_admin.php');?>
<?
if ($action=="edit")
        {
        if (!checkdate($mm,$dd,$yy))
                print "<br><font color=red><b>не правильная дата</b><br>";
        else
                {
                $datew=mktime(1,1,1,$mm,$dd,$yy);
                $result= mysql_query("UPDATE news SET
                                date='$datew',
                                txt='$txt'
                              WHERE id='$id'");
                print "<br><font color=green><b>изменения внесены</b><br>";
                }
        }
if ($action=="add")
        {
        if (!checkdate($mm,$dd,$yy))
                print "<br><font color=red><b>не правильная дата</b><br>";
        else
                {
                $datew=mktime(1,1,1,$mm,$dd,$yy);
                $result= mysql_query("INSERT INTO news (date,txt) VALUES ('$datew','$txt')");
                print "<br><font color=green><b>добавлено</b><br>";
                }
        }
if ($action=="del")
        {
        $result= mysql_query("DELETE FROM news WHERE id='$id'");
        print "<br><font color=green><b>удалено</b><br>";
        }

print "<center class=p><b>FAQ</b></center>";


        print "
        <center class=p><br>
        <b>ДОБАВИТЬ НОВОСТЬ:</b>
        <TABLE WIDTH=600 BORDER=0 CELLPADDING=2 CELLSPACING=2>
        <form action=$PHP_SELF method=post>
                <tr>
                        <td align=left valign=top class=p>
                        <b>дата:</td>
                        <td align=left valign=top class=p>";
                        $dd=date("d",time());
                        $mm=date("m",time());
                        $yy=date("Y",time());
                        print "
                        <input type=text name=dd class=p value=$dd size=2>.
                        <input type=text name=mm class=p value=$mm size=2>.
                        <input type=text name=yy class=p value=$yy size=4>
                        </td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>текст:</td>
                        <td align=left valign=top class=p>
                        <TEXTAREA rows=5 cols=100 name=txt class=p></TEXTAREA></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <input type=hidden name=action value=add></td>
                        <td align=left valign=top class=p>
                        <input type=submit value=\"добавить\" class=p></td>
                </tr>
        </form>
        </table>
<bR><b>новости:</b>
        </center>

        ";

$result= mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 10");
while ($row = mysql_fetch_array($result))
        {
        print "
        <center><br>
        <TABLE WIDTH=600 BORDER=0 CELLPADDING=2 CELLSPACING=2>
        <form action=$PHP_SELF method=post>
                <tr>
                        <td align=left valign=top class=p>
                        <b>дата</b></td>
                        <td align=left valign=top class=p>";
                        $dd=date("d",$row[date]);
                        $mm=date("m",$row[date]);
                        $yy=date("Y",$row[date]);
                        print "
                        <input type=text name=dd class=p value=$dd size=2>.
                        <input type=text name=mm class=p value=$mm size=2>.
                        <input type=text name=yy class=p value=$yy size=4>

                        </td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <b>ответ:</td>
                        <td align=left valign=top class=p>
                        <TEXTAREA rows=5 cols=100 name=txt class=p>$row[txt]</TEXTAREA></td>
                </tr>
                <tr>
                        <td align=left valign=top class=p>
                        <input type=hidden name=id value=$row[id]>
                        <input type=hidden name=action value=edit></td>
                        <td align=left valign=top class=p>
                        <input type=submit value=\"изменить\" class=p> <a href=$PHP_SELF?action=del&id=$row[id] class=p>удалить</a></td>
                </tr>
        </form>
        </table>
        </center>";
        }
?>
</center>
</body>
</html>