Jeg har ik pillet ved upload, og den virkede ik fra starten af, sådan ser admin.php ud:
<?php
session_start();
if (isset($_SESSION['aid'])) {
include("config.php");
if($_POST['upload']){
if ($_POST['pic'] == 1) {
$files = $_FILES['upfil']['name'];
$dist = $_SERVER["DOCUMENT_ROOT"] . "/";
move_uploaded_file($_FILES['upfil']['tmp_name'], $dist . $files);
}
elseif ($_POST['pic'] == 2) {
$files = "csnews.jpg";
} else {
$files = "nopic.jpg";
}
$_POST[text] = str_replace(":)", "<img src=\"smilies/smile.gif\">", $_POST[text]);
$_POST[text] = str_replace(":P", "<img src=\"smilies/tongue.gif\">", $_POST[text]);
$_POST[text] = str_replace(":D", "<img src=\"smilies/biggrin.gif\">", $_POST[text]);
$_POST[text] = str_replace("/cry", "<img src=\"smilies/cry.gif\">", $_POST[text]);
$_POST[text] = str_replace(":@", "<img src=\"smilies/devil.gif\">", $_POST[text]);
$_POST[text] = str_replace("/mad", "<img src=\"smilies/mad.gif\">", $_POST[text]);
$_POST[text] = str_replace("/nono", "<img src=\"smilies/nono.gif\">", $_POST[text]);
$_POST[text] = str_replace(":(", "<img src=\"smilies/sad.gif\">", $_POST[text]);
$_POST[text] = str_replace(":-O", "<img src=\"smilies/shocked.gif\">", $_POST[text]);
$_POST[text] = str_replace(":S", "<img src=\"smilies/sick.gif\">", $_POST[text]);
$_POST[text] = str_replace("/uhh", "<img src=\"smilies/uhh.gif\">", $_POST[text]);
$_POST[text] = str_replace(";)", "<img src=\"smilies/wink.gif\">", $_POST[text]);
mysql_query("INSERT INTO news (title, text, name, file) values ('$_POST[title]', '$_POST[text]', '$_POST[name]', '$files')");
header("Location: index.php");
}
if ($_GET["func"] == "slet") {
mysql_query("DELETE FROM news WHERE id='$_GET[id]'");
mysql_query("DELETE FROM comment WHERE newsid='$_GET[id]'");
echo "Nyheden er nu slettet<br>";
} elseif($_GET["func"] == "update") {
$_POST['besked'] = ereg_replace("<([^>]+)>", "", $_POST['besked']);
$_POST[text] = str_replace(":)", "<img src=\"smilies/smile.gif\">", $_POST[text]);
$_POST[text] = str_replace(":P", "<img src=\"smilies/tongue.gif\">", $_POST[text]);
$_POST[text] = str_replace(":D", "<img src=\"smilies/biggrin.gif\">", $_POST[text]);
$_POST[text] = str_replace("/cry", "<img src=\"smilies/cry.gif\">", $_POST[text]);
$_POST[text] = str_replace(":@", "<img src=\"smilies/devil.gif\">", $_POST[text]);
$_POST[text] = str_replace("/mad", "<img src=\"smilies/mad.gif\">", $_POST[text]);
$_POST[text] = str_replace("/nono", "<img src=\"smilies/nono.gif\">", $_POST[text]);
$_POST[text] = str_replace(":(", "<img src=\"smilies/sad.gif\">", $_POST[text]);
$_POST[text] = str_replace(":-O", "<img src=\"smilies/shocked.gif\">", $_POST[text]);
$_POST[text] = str_replace(":S", "<img src=\"smilies/sick.gif\">", $_POST[text]);
$_POST[text] = str_replace("/uhh", "<img src=\"smilies/uhh.gif\">", $_POST[text]);
$_POST[text] = str_replace(";)", "<img src=\"smilies/wink.gif\">", $_POST[text]);
mysql_query("UPDATE news SET name='$_POST[name]', title='$_POST[title]', text='$_POST[text]' WHERE id='$_GET[id]'");
echo "Nyheden er nu opdateret<br>";
}
?>
<html>
<head>
<meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)">
<title>Admin system</title>
</head>
<script language="JavaScript">
function openWindow(URL,name,features) {
window.open(URL,name,features);
}
</script>
<body body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="0" leftmargin="10" text="#FFFFFF" bgcolor="#101318">
<p align="center"><font face="MS Sans Serif" size="2"><br>
<img src='
http://www.weirdweapon.com/images/nyhedsystem.jpg' border='0' width="162" height="26"/></font></p>
<?php
if ($_GET["func"] == "getnews") {
$query = mysql_query("SELECT title, text, name FROM news WHERE id='$_GET[id]'");
$get = mysql_fetch_array($query);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?id=<?php echo $_GET[id]; ?>&func=update" method="post">
<p>
<font face="MS Sans Serif" size="1">Bruger:</font><br>
<input type="text" name="name" size="30" value="<?php echo $get[name]; ?>" style="font-family: MS Sans Serif; font-size: 8pt"><br>
<font face="MS Sans Serif" size="1"><br>
Overskrift:</font><br>
<input type="text" name="title" size="30" value="<?php echo $get[title]; ?>" style="font-size: 8pt; font-family: MS Sans Serif"><br>
<br>
<font size="1" face="MS Sans Serif">Nyhed:</font><br>
<textarea rows="6" name="text" cols="41" style="font-family: MS Sans Serif; font-size: 8pt"><?php echo $get[text]; ?></textarea><p>
<input type="submit" value="Post It Now....!" name="Opdater" style="font-size: 8pt; font-family: MS Sans Serif"></p>
</form>
<?php
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<p>
<font face="MS Sans Serif" size="1">Bruger:</font><br>
<input type="text" name="name" size="30" style="color: #000000; font-family: MS Sans Serif; font-size: 8 pt"><br>
<br>
<font face="MS Sans Serif" size="1">Overskrift:<br>
</font>
<input type="text" name="title" size="30" style="font-family: MS Sans Serif; font-size: 8 pt"><br>
<font face="MS Sans Serif" size="1"><br>
<br>
Billede:<br>
</font>
<input type="radio" value="1" name="pic" style="font-family: MS Sans Serif; font-size: 8 pt">
<input type="file" name="upfil" size="20" style="font-family: MS Sans Serif; font-size: 8 pt"> <p><input type="radio" value="2" name="pic"> <font face="MS Sans Serif" size="1">
CS News</font></p>
<p><input type="radio" value="3" name="pic" checked> <font face="MS Sans Serif" size="1">
Intet billede<br>
<br>
Nyhed: <a href smilies.htm onClick="openWindow('smilies.htm','vindueNavn','toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=250, height=350')" border="0" style="cursor:pointer; cursor:hand; text-decoration: none"> Smilies</a><br>
</font>
<textarea rows="6" name="text" cols="41" style="font-family: MS Sans Serif; font-size: 8 pt"></textarea></p>
<p>
<input type="submit" value="Post It Now....!" name="upload" style="font-family: MS Sans Serif; font-size: 8 pt"></p>
</form>
<?php
}
?>
<br>
<div style="border-top-style: solid; border-top-width: 1px; padding-top: 1px">
<p align="center"><font face="MS Sans Serif" size="2"><b>Slet/Opdater Nyheder</b></font></p>
</div>
<?php
$query = mysql_query("SELECT id, title FROM news ORDER BY id DESC");
while ($row = mysql_fetch_array($query)) {
echo "<p align='center'><a href='$_SERVER[PHP_SELF]?id=$row[id]&func=slet'><font size='1' face='MS Sans Serif'>Slet</a> - <a href='$_SERVER[PHP_SELF]?id=$row[id]&func=getnews'>Opdater</a> - $row[title]<br>";
}
?>
<p align='center'><a href="index.php">
<img border="0" src="../images/back.jpg" width="57" height="14"></a></p>
<p></p>
</body>
</html>
<?php
}
?>