Location: PHPKode > projects > Emilda > emilda-1.2.3/src/motd.php
<?php

//-----------------------------------------------------------------------------
//
// Copyright (C) 2003-2005 Oy Realnode Ab
//
//-----------------------------------------------------------------------------
//
// subject_headings.php
//     Part of the Emilda Project (http://www.emilda.org/)
//
// Description
//     Subject Headings.
//
// Authors
//     Christoffer Landtman <landtman (at) realnode com>
//     Erik Berglund <berglund (at) realnode com>
//     Mattias Nordstrom <nordstrom (at) realnode com>
//
//-----------------------------------------------------------------------------
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//-----------------------------------------------------------------------------
//
// $Id: motd.php,v 1.3.2.1 2005/02/02 13:28:31 eberglun Exp $
//
//-----------------------------------------------------------------------------

// Id used to identify this page within functions.
$PageID = "MOTD";

require_once "common.inc";

require_once "config.inc";
require_once "constants.inc";
require_once "db.inc";
require_once "error.inc";
require_once "layout.inc";
require_once "search.inc";
require_once "language.inc";
require_once "MARC.inc";
require_once "mgmnt.inc";

if(isset($_REQUEST['post']))
{
 	if(!isset($_REQUEST['to_group']) && check_priv("ADMIN"))
	{
		if($_REQUEST['valid'] == "" || !is_numeric($_REQUEST['valid']))
			$_REQUEST['valid'] = 7;

        $expiry = date("Y-m-d H:i:s", (time()+($_REQUEST['valid']*86400)));

		if (isset($_REQUEST['message']) && $_REQUEST['message'] != '')
		{
			$res = sql_query(	"INSERT INTO motd SET
									motd_group_id=0,
									motd_user_id=".USER_ID.",
									motd_priority=".$_REQUEST['priority'].",
									motd_message='".$_REQUEST['message']."',
									motd_date_added=NOW(),
									motd_date_expires='".$expiry."',
									motd_type=1");
		}
	}
	elseif(isset($_REQUEST['to_group']))
	{
		if($_REQUEST['valid'] == "" || !is_numeric($_REQUEST['valid']))
			$_REQUEST['valid'] = 7;

        $expiry = date("Y-m-d H:i:s", (time()+($_REQUEST['valid']*86400)));

		if(is_numeric($_REQUEST['to_group']) && is_group_manager($_REQUEST['to_group']))
		{
			if (isset($_REQUEST['message']) && $_REQUEST['message'] != '')
			{
				$res = sql_query(	"INSERT INTO motd SET
									motd_group_id=".$_REQUEST['to_group'].",
									motd_user_id=".USER_ID.",
									motd_priority=".$_REQUEST['priority'].",
									motd_message='".$_REQUEST['message']."',
									motd_date_added=NOW(),
									motd_date_expires='".$expiry."',
									motd_type=0");
			}
		}
		else
		{
			$fetch = sql_cquery("SELECT * FROM groups, linkage WHERE linkage.group_id=groups.group_id AND linkage.user_id=".USER_ID." AND linkage.group_manager=1");

			if(mysql_num_rows($fetch))
			{
				if (isset($_REQUEST['message']) && $_REQUEST['message'] != '')
				{
					while($row = mysql_fetch_array($fetch))
					{
						$res = sql_query(	"INSERT INTO motd SET
											motd_group_id=".$row['group_id'].",
											motd_user_id=".USER_ID.",
											motd_priority=".$_REQUEST['priority'].",
											motd_message='".$_REQUEST['message']."',
											motd_date_added=NOW(),
											motd_date_expires='".$expiry."',
											motd_type=0");
					}
				}
			}
			else
				error("session violation");
		}
	}
	else
		error("session violation");
}

layout_print_header();

?>
	<style type="text/css">
	body
	{
		background: #ffffff;
	}
	</style>
<?php	
	
if (isset($_REQUEST['post']))
{
	?>
	<script language="JavaScript1.1">
		window.opener.location.reload();
		self.close();
	</script>
	<?php
}

if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'system_message')
{
	if(check_priv("ADMIN"))
	{

	?>
		<form name='system_message' action='motd.php' method='post'>

			<input type='hidden' name='id' value='<?php echo $_REQUEST['id']?>'>
			<input type='hidden' name='auth' value='<?php echo $_REQUEST['auth']?>'>
			<input type="hidden" name="post" value="post">

			<table border="0" cellspacing="0" cellpadding="4">
				<tr>
					<td align="right">
						<?php echo _("Priority") ?>:&nbsp;
					</td>
					<td>
						<select name='priority'>
							<option value='4'><?php echo _("High") ?></option>
							<option value='3' selected><?php echo _("Normal") ?></option>
							<option value='2'><?php echo _("Low") ?></option>
						</select>
					</td>
				</tr>
				<tr>
					<td align="right">
						<?php echo _("Valid") ?>&nbsp;:
					</td>
					<td>
						<input type='text' name='valid' size='1' value='7'>&nbsp;<?php echo _("Days") ?>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<font class='tiny'><?php echo _("255 characters maximum") ?></font>
						<br />
						<textarea name='message' cols='20' rows='3' onKeyUp="check_length(document.forms.system_message.message, 'chars_left', '<?php echo _("Maximum of 255 characters") ?>')"></textarea>
					</td>
				</tr>
				<tr>
					<td align="right">
						<?php echo _("Chars left:") ?>
					</td>
					<td>
						<div id="chars_left" style="font-weight: bold;">255</div>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<input type='button' name='post' class='button' value='<?php echo _("Post") ?>&nbsp;&gt;&gt;' onClick="check_submit(document.forms.system_message.message, '<?php echo _("More than 255 chars. Please reduce!") ?>')">
					</td>
				</tr>
			</table>

		</form>
	<br />

	<?php
	}
	else {
		error('session viloation');
	}
}
elseif(check_priv("ADMIN"))
{
	
}

?>
		
</body>
</html>
Return current item: Emilda