Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/old/indem/wisdom/
Upload File :
Current File : /var/www/html/mmishra/indem/old/indem/wisdom/z.php

<?php

function announcementfeed($role) {
	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 = date("Y-m-d") + 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 == "enable") {
		mysql_query("update $tbl set visibility='disable' where rowid=$rowid");
	} else if ($visibility == "disable") {
		mysql_query("update $tbl set visibility='enable' where rowid=$rowid");
	}

	$str = "<div align='right'>Upload file linked to this announcement 
	<input type='file' name='userfile'></div>

	<table class=normal width='90%'>";
	if (!$rowid) {
		$str .= "<tr><td nowrap>Subject</td>
		<td><select name='subject'>
		";
		foreach ($subjects as $sub) {
			$str .= "<option value='$sub'";
			if ($subject == $sub) $str .= ' selected';
			$str .= ">$sub</option>";
		}
		$str .= "</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 {
		$str .= "<tr><td>[ <a href='$PHP_SELF?conf=$conf&rowid='>New announcement</a> ]</td></tr>";
	}
	$str .= "</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) {
      			$str .= "<tr><td>$i</td><td>
      			<input type='hidden' name='rowid' value='$o->rowid'>
      			<table width='90%'>
      			<tr><td nowrap>Subject</td>
			<td><select name='subject'>
        		";
        		foreach ($subjects as $sub) {
                		$str .= "<option value='$sub'";
                		if ($subject == $sub) $str .= ' selected';
                		$str .= ">$sub</option>";
        		}
        		$str .= "</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 {
      			$str .= "<tr valign='top'><td>$i</td><td width='80%'><a name='$o->rowid'></a>" . 
			ucwords($o->subject) . ": $o->message 
      			[ <a href='$PHP_SELF?conf=$conf&rowid=$o->rowid#$o->rowid'>Edit</a> ] ";
      			if ($o->visibility == 'disable')
				$str .= "[ <a href='$PHP_SELF?conf=$conf&visibility=enable&rowid=$o->rowid'>Show</a> ]";
      			else 
				$str .= "[ <a href='$PHP_SELF?conf=$conf&visibility=disable&rowid=$o->rowid'>Hide</a> ]";
      			$str .= "<br>
			>> $o->description<br><div align='right'>";
      			if ($o->weburl) $str .= "Weburl: <a href='$o->weburl'>$o->weburl</a> "; 
			$str .= "( $o->dateupload - $o->dateexpiry, $o->counter times )</div></td></tr>";
		}
	}
	$str .= "</table>";
	echo $str;
}
?>