| Current Path : /var/www/html/mmishra/indem/old/indem/wisdom/ |
| Current File : /var/www/html/mmishra/indem/old/indem/wisdom/announcements.php |
<?php
checkadmin($role);
$tbl = "announcements";
$subjects = array('advertisement','enquiry','event','information','notice','tender');
$rowid = $_REQUEST["rowid"];
$subject = htmlsafe($_POST["subject"]);
$message = htmlsafe($_POST["message"]);
$description = htmlsafe($_POST["description"]);
$weburl = htmlsafe($_POST["weburl"]);
if (basename($_FILES['userfile']['name'])) {
//$weburl = strtolower('documents/'.basename($_FILES['userfile']['name']));
$weburl = strtolower(basename($_FILES['userfile']['name']));
upload_file();
}
$dateexpiry = $_POST["dateexpiry"];
if (!$dateexpiry) $dateexpiry = DateAdd(7);
$visibility = $_REQUEST["visibility"];
$submit = $_POST["submit"];
if ($submit == 'SAVE') {
if (mysql_num_rows(mysql_query("select * from $tbl where rowid=$rowid"))) {
mysql_query("update $tbl set subject='$subject',message='$message',description='$description',
$weburl='$weburl',dateexpiry='$dateexpiry' where rowid=$rowid");
} else {
mysql_query("insert into $tbl(subject,message,description,weburl,dateupload,dateexpiry,visibility,counter)
values('$subject','$message','$description','$weburl',now(),'$dateexpiry','enable',1)");
}
} else if ($submit == "DELETE") {
mysql_query("delete from $tbl where rowid=$rowid");
} else if ($visibility == "disable") {
mysql_query("update $tbl set visibility='disable' where rowid=$rowid");
} else if ($visibility == "enable") {
mysql_query("update $tbl set visibility='enable' where rowid=$rowid");
}
echo "<div align='right'>Upload file linked to this announcement
<input type='file' name='userfile'></div>
<table class=normal width='90%'>";
if (!$rowid) {
echo "<tr><td nowrap>Subject</td>
<td><select name='subject'>
";
foreach ($subjects as $sub) {
echo "<option value='$sub'";
if ($subject == $sub) echo ' selected';
echo ">$sub</option>";
}
echo "</select></td></tr>
<tr><td nowrap>Message</td>
<td><input type='text' name='message' value='' size='50'></td></tr>
<tr valign='top'><td>Description</td>
<td><textarea name='description' rows='2' cols='50'></textarea></td></tr>
<tr><td nowrap>Web URL</td>
<td><input type='text' name='weburl' value='' size='50'>
(if file is to be uploaded, leave it blank)</td></tr>
<tr><td nowrap>Expiry Date</td>
<td><input type='text' name='dateexpiry' value='$dateexpiry' size='15'></td></tr>
<tr><td></td>
<td><input type='submit' name='submit' value='SAVE' style='width:80px'></td></tr>";
} else {
echo "<tr><td>[ <a href='$PHP_SELF?conf=$conf&rowid='>New announcement</a> ]</td></tr>";
}
echo "</table>
<table class='normal' width='98%'>
<tr><th>No.</th><th width='95%'>Announcement</th></tr>";
$rs = mysql_query("select * from $tbl order by visibility desc, dateupload desc,rowid desc");
while ($o = mysql_fetch_object($rs)) {
$i++;
if ($rowid == $o->rowid) {
echo "<tr><td>$i</td><td>
<input type='hidden' name='rowid' value='$o->rowid'>
<table class=normal width='90%'>
<tr><td nowrap>Subject</td>
<td><select name='subject'>
";
foreach ($subjects as $sub) {
echo "<option value='$sub'";
if ($subject == $sub) echo ' selected';
echo ">$sub</option>";
}
echo "</select></td></tr>
<tr><td nowrap>Message</td>
<td><input type='text' name='message' value='$o->message' size='50'></td></tr>
<tr valign='top'><td nowrap>Description</td>
<td><textarea name='description' rows='2' cols='50'>$o->description</textarea></td></tr>
<tr><td nowrap>Web URL</td>
<td><input type='text' name='weburl' value='$o->weburl' size='50'></td></tr>
<tr><td nowrap>Expiry Date</td>
<td nowrap><input type='text' name='dateexpiry' value='$o->dateexpiry' size='15'></td></tr>
<tr><td></td>
<td><input type='submit' name='submit' value='SAVE' style='width:80px'>
<input type='submit' name='submit' value='DELETE' style='width:80px'></td></tr>
</table></td></tr>";
} else {
if ($i % 2) echo "<tr valign='top' bgcolor='$col1'>";
else echo "<tr valign='top' bgcolor='$col2'>";
echo "<td>$i</td><td width='80%'><a name='$o->rowid'></a>";
echo ucwords($o->subject) . ": $o->message
[ <a href='$PHP_SELF?conf=$conf&rowid=$o->rowid#$o->rowid'>Edit</a> ] ";
if ($o->visibility == 'disable')
echo "[ <a href='$PHP_SELF?conf=$conf&visibility=enable&rowid=$o->rowid'>Show</a> ]";
else
echo "[ <a href='$PHP_SELF?conf=$conf&visibility=disable&rowid=$o->rowid'>Hide</a> ]";
echo "<br>
>> $o->description<br>";
if ($o->weburl) echo "<div align='right'>Filename: <a href='$o->weburl'>$o->weburl</a>
($o->dateupload - $o->dateexpiry, $o->counter times)</td></tr>";
}
}
echo "</table>";
?>