Размер файла: 4.94Kb
<?php
/*-----------------------------------------------------------------------------------------
mcGalleryPRO
All code is © 2003 Marc Cagninacci.
No files may be redistributed in whole or significant part.
----------------- mcgalleryPRO IS NOT FREE SOFTWARE -------------------
You should have receive a file called license.txt in this package
--------------------------------------------------------------------------------------------*/
session_start();
if (empty($_SESSION['private_login']))
{
include "./sess.php";
exit;
}
include "./header.php";
$connect= mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);
// add a news
if ($submit != '' && $mod != 1)
{
$titlenews = addslashes($titlenews);
$textnews = addslashes($textnews);
$linktext = addslashes($linktext);
$query = "INSERT INTO mcgallery_news VALUES ('', '$datenews', '$titlenews', '$textnews', '$linkurl', '$linktext')";
mysql_query($query);
}
// delete a news
if ($act == 'del')
{
$query = "DELETE FROM mcgallery_news WHERE idnews=$id";
mysql_query($query);
}
// edit a news
if ($act == 'mod')
{
$query = "SELECT * FROM mcgallery_news WHERE idnews=$id";
$result = mysql_fetch_array(mysql_query($query));
$boxtitle = $l_News_modif;
$modify = 1;
}
else
{
$result['datenews'] = date("Y-m-d");
$result['textnews'] = $l_News_body;
$boxtitle = $l_News_add;
}
// modify a news
if ($mod == 1)
{
$titlenews = addslashes($titlenews);
$textnews = addslashes($textnews);
$linktext = addslashes($linktext);
$query = "UPDATE mcgallery_news SET datenews='$datenews', titlenews='$titlenews', textnews='$textnews', linkurl='$linkurl', linktext='$linktext' WHERE idnews=$id";
mysql_query($query);
}
?>
<form method="post" action="news_admin.php">
<table bgcolor="#000000" border="0" cellpadding="5" cellspacing="1" width="90%" align="center">
<tr><td bgcolor="#000000">
<font face="verdana" size="2" color="#ffffff"><?php echo $boxtitle; ?></font>
</td></tr>
<tr><td bgcolor="#DDDDDD" align="right">
<font face="verdana" size="1" color="#000000">
<?php echo $l_Date; ?>:
<input type="text" name="datenews" value="<?php echo $result['datenews']; ?>" size="10">
<?php echo $l_Titre; ?>:
<input type="text" name="titlenews" value="<?php echo htmlentities($result['titlenews']); ?>" size="40">
<br><?php echo $l_News_text; ?>:
<textarea name="textnews" cols="90" rows="8" onFocus="if(this.value=='News body here (HTML allowed)')this.value='';"><?php echo stripslashes($result['textnews']); ?></textarea></textarea>
<br><?php echo $l_News_link; ?> <?php echo $l_Site; ?>:
<input type="text" name="linkurl" size="40" value="<?php echo $result['linkurl']; ?>">
<?php echo $l_News_text; ?>:
<input type="text" name="linktext" size="40" value="<?php echo htmlentities($result['linktext']); ?>">
</font>
<input type="hidden" name="id" value="<?php echo $result['idnews']; ?>">
<input type="hidden" name="mod" value="<?php echo $modify; ?>">
<br><input type="submit" name="submit" value=" OK ">
</td></tr></table>
</form><br>
<?php
// display all news
$query = "SELECT * FROM mcgallery_news ORDER BY datenews DESC, idnews DESC";
$res = mysql_query($query);
?>
<table bgcolor="#000000" border="0" cellpadding="5" cellspacing="1" width="90%" align="center">
<tr>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"><?php echo $l_Date; ?></font>
</td>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"><?php echo $l_Titre; ?></font>
</td>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"><?php echo $l_News_text; ?></font>
</td>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"><?php echo $l_Site; ?></font>
</td>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"><?php echo $l_News_text; ?></font>
</td>
<td bgcolor="#000000">
<font face="verdana" size="1" color="#ffffff"> </font>
</td>
</tr>
<?php
while ($row = mysql_fetch_array($res))
{
echo '<tr><td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">'.$row['datenews'].'</font></td>';
echo '<td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">'.stripslashes($row['titlenews']).'</font></td>';
echo '<td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">'.nl2br(stripslashes($row['textnews'])).'</font></td>';
echo '<td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">'.$row['linkurl'].'</font></td>';
echo '<td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">'.stripslashes($row['linktext']).'</font></td>';
echo '<td bgcolor="#DDDDDD"><font face="verdana" size="1" color="black">';
echo '<a href="news_admin.php?act=mod&id='.$row['idnews'].'" class="lien1"><b>'.$l_News_edit.'</b></a><br>';
echo '<a href="news_admin.php?act=del&id='.$row['idnews'].'" class="lien1"><b>'.$l_Suppr.'</b></a>';
echo '</font></td></tr>';
}
?>
</table>
</body></html>