⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quick_reply.php

📁 jsp程序开发系统
💻 PHP
字号:

<?php
// +-------------------------------------------------------------+
// | DeskPRO v [2.0.1 Production]
// | Copyright (C) 2001 - 2004 Headstart Solutions Limited
// | Supplied by WTN-WDYL
// | Nullified by WTN-WDYL
// | Distribution via WebForum, ForumRU and associated file dumps
// +-------------------------------------------------------------+
// | DESKPRO IS NOT FREE SOFTWARE
// +-------------------------------------------------------------+
// | License ID : Full Enterprise License =) ...
// | License Owner : WTN-WDYL Team
// +-------------------------------------------------------------+
// | $RCSfile: quick_reply.php,v $
// | $Date: 2004/02/10 01:34:30 $
// | $Revision: 1.17 $
// +-------------------------------------------------------------+
// | File Details:
// | - Quick reply management.
// +-------------------------------------------------------------+

error_reporting(E_ALL ^ E_NOTICE);

// start file
require("./../global.php");

// globalise variables
$global = array	(
			array('id')	// id
);
rg($global);

tech_nav('Quick Replies');

// default do
$_REQUEST['do'] = trim($_REQUEST['do']);
if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
	$_REQUEST['do'] = "view";
}

############################### DELETE CATEGORY (2) ###############################

if ($_REQUEST['do'] == "delete_cat") {

	if (!$_REQUEST['id']) {
		mistake('No category was specified for deletion.', 1);
	}

	$result = $db->query_return("SELECT * FROM quickreply_cat WHERE id = '$id'");
	if (!$db->num_rows()) {
		mistake('The specified category doesn\'t exist.', 1);
	}

	$result = $db->query("SELECT * FROM quickreply WHERE category = '$id'");
	if ($db->num_rows()) {
		mistake("The specified category isn't empty. Please delete the quick
			replies in this category before deleting it.");
	}

	if ($user['p_quickedit'] OR !$result['global']) {
		$db->query("DELETE FROM quickreply_cat WHERE id = '$id'");
	}
	update_cache();
}

############################### ADD CATEGORY (2) ###############################

if ($_REQUEST['do'] == "add_category2") {
	
	if ($_REQUEST['name'] == '') {

		$cat_error = "<B>Error: You have not entered a name for the category</b><br /><br />";
	
	} else {
	
		$name = xss_check($_REQUEST['name'], 'tech');

		$db->query("INSERT INTO quickreply_cat SET 
				name = '".mysql_escape_string($name)."', "
				. iff($user['p_quickedit'], "global = '" . iff($_REQUEST['global'], 1) . "',") .
				" techid = '$user[id]'
		");

	}

	$_REQUEST['do'] = "add_category";
	update_cache();	
}

############################### BUILD NAVIGATION ###############################

/*
function stat_table($title, $data, $width='100%') {

	$html = "<table width=\"$width%\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";

		$html .= '
		<tr>
		  <td height="1" colspan="20" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>

		<tr>
		  <td height="20" colspan="20" align="center" class="calendar1"><strong>' . " $title " . '</strong></td>
		</tr>

		<tr>
		  <td height="1" colspan="20" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>
		';

			if (is_array($data)) {
			foreach ($data AS $key => $var) {

				if (is_array($var)) {
					$html .= "<tr>";
					foreach ($var AS $key2 => $var2) {
						$html .= "<td height=\"20\">&nbsp;&nbsp;&nbsp;$var2</td>";
					}
					$html .= "</tr>";
				
				} else {
				
					$html .= "
					<tr>
					  <td height=\"20\" colspan=\"20\">&nbsp;&nbsp;&nbsp;$var</td>
					</tr>
					";
				}

			 $html .= '

			<tr>
			  <td height="1" colspan="20" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
			</tr>
				';
			}
		}

	  $html .='</table>';
	  return $html;
}

*/

	?>
	<table width="100%"><tr><td valign="top" width="20%">
		<table width="100%%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>
		<tr>
		  <td height="20" align="center" class="calendar1"><strong>Categories:</strong></td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>
		<tr>
			<td><br />
			
			<?php

			echo "<a href=\"quick_reply.php\">Top Category</a><br />";

			$db->query("SELECT * FROM quickreply_cat WHERE techid = $user[id] OR global");
			while ($result = $db->row_array()) {
				$quick[id] = $result[name];
				echo "&nbsp;&nbsp;<a href=\"quick_reply.php?id=$result[id]\">$result[name]</a> [<B>".
					jprompt('This will delete the category',
						"quick_reply.php?do=delete_cat&id=$result[id]",
						'x') . 
					'</b></a>]';

				if ($result['global']) {
					echo "&nbsp;<b>g</b>";
				}
				
				echo "<br />";
			}

			?>
			<br /></td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>	
		<tr>
		  <td height="20" align="center" class="calendar1"><strong>Actions:</strong></td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>
		<tr>
			<td><br />
		<a href="quick_reply.php?do=add_entry">Create Entry</a><br />
		<a href="quick_reply.php?do=add_category">Create Category</a>
		<br /><br /></td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>	
		<tr>
		  <td height="20" align="center" class="calendar1"><strong>Key:</strong></td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>
		<tr>
			<td><br />
		(g) = global category</b><br />
		[x] = delete category</a>
		<br /><br />
		</td>
		</tr>
		<tr>
		  <td height="1" bgcolor="#BF4343"><img src="../../images/spacer.gif" width="1" height="1"></td>
		</tr>

		</table>
		</td><td width="25"></td><td valign="top" width="80%">
		
	<?php

	if ($cat_error != "") {
		echo $cat_error;
	}


############################### UPDATE ENTRIES ###############################

if ($_REQUEST['do'] == "update") {
	
	foreach($_REQUEST[entryid] AS $key => $var) {

		if ($_REQUEST[delete][$key]) {
			$result = $db->query_return("SELECT techid FROM quickreply WHERE id = '$key'");
			if ($result[techid] == $user[id] OR $user['p_quickedit']) {
				$db->query("DELETE FROM quickreply WHERE id = '$key'");
			}
		} else {
			$checks = xss_check(array(
				$_REQUEST['name'][$key],
				$_REQUEST['response'][$key]), 'tech');

			$db->query("UPDATE quickreply 
				SET name = '" . mysql_escape_string($checks[0]) . "',
				response = '" . mysql_escape_string($checks[1]) . "'
				WHERE id = $key" . iff((!$user['p_quickedit']), " AND techid = $user[id]")
			);
		}
	}
	update_cache();	
	$_REQUEST['do'] = "view";

}

############################### LIST ENTRIES ###############################

if ($_REQUEST['do'] == "view") {

	// need to check category is global or ours
	$category = $db->query_return("SELECT techid, global FROM quickreply_cat WHERE id = '$id'");
	if ((!$category['global']) AND ($category[techid] != $user[id]) AND $id) {
		echo "<b>You do not have permission to view this category</b>";
		exit();
	}

	if (!$id) {
		$id = 0;
	}

	$db->query("SELECT * FROM quickreply WHERE category = '$id'");
	while ($result = $db->row_array()) {

		$table[] = array("<b>Reference name:</B> " . 
			form_input($result[id], $result[name], '40', 'name') . "&nbsp;&nbsp;&nbsp;&nbsp;<b>delete:</b>&nbsp;&nbsp;
			<input type=\"checkbox\" name=\"delete[$result[id]]\" value=\"1\"><br />" . 
			form_textarea($result[id], '90', '7', $result[response], 'response') . "<input type=\"hidden\" name=\"entryid[$result[id]]\" value=\"1\">");
	}

	if ($db->num_rows() < 1) {

		echo "<B>There are currently no quick replies for this category</b>";

	} else {

		table_header('Update Quick Replies', 'quick_reply.php', array('do' => 'update', 'id' => $id));
		table_content('', $table);
		table_footer('Update Entries');
		unset($table, $width);

	}

}

############################### ADD ENTRY (2) ###############################
if ($_REQUEST['do'] == "add_entry2") {
	
	if ($_REQUEST['name'] == '') {
		echo "<B>Error: You have left the name for the quick reply empty</b><br /><br />";
		$error = 1;
	}
	if ($_REQUEST['response'] == '') {
		echo "<B>Error: You have left the reply empty</b><br /><br />";
		$error = 1;
	}

	if (!$error) {

		$checks = xss_check(array(
			$_REQUEST['name'],
			$_REQUEST['response']), 'tech');

		$db->query("INSERT INTO quickreply SET
		name = '".mysql_escape_string($checks[0])."',
		response = '".mysql_escape_string($checks[1])."',
		category = '".mysql_escape_string($_REQUEST['category'])."',
		techid = $user[id]
		");

		echo "<b>Entry Created</b>";

	} else {
	
		$response = $_REQUEST['response'];
		$name = $_REQUEST['name'];
		$category2 = $_REQUEST['category'];

	}

	update_cache();	
	$_REQUEST['do'] = "add_entry";

}

############################### ADD ENTRY ###############################
if ($_REQUEST['do'] == "add_entry") {

	$category[0] = "Top Level Category";

	$db->query("SELECT * FROM quickreply_cat WHERE techid = '$user[id]' OR global");
	while ($cat = $db->row_array()) {
		if ($cat['global'] AND !$user['p_quickedit']) {
			continue;
		}
		$category[$cat[id]] = $cat[name];
	}

	$table[] = array(table_thelp('<b>Name:</b>', 'Quick Replies', 'Name'), form_input('name', $name));
	$table[] = array(table_thelp('<b>Category:</b>', 'Quick Replies', 'Category'), form_select(category, $category, '', $category2));
	$table[] = array(table_thelp('<b>Quick Reply:</b>', 'Quick Replies', 'Response'), form_textarea('response', '90', '7', $response));

	table_header('Add New Quick Reply', 'quick_reply.php', array('do' => 'add_entry2'));
	table_content('', $table);
	table_footer('Create Entry');
	unset($table, $width);

}

############################### ADD CATEGORY ###############################
if ($_REQUEST['do'] == "add_category") {

	if (!$user['p_quickedit']) {
		mistake('You do not have permission to edit quick replies.', 1);
	}

	$table[] = array(table_thelp('<b>Name:</b>', 'Quick Replies', 'Category Name'), form_input('name'));
	if ($user['p_quickedit']) {
		$table[] = array(table_thelp('<B>Global:</B>', 'Quick Replies', 'Global'), form_radio_yn('global', NULL));
	}

	table_header('Create Category', 'quick_reply.php', array('do' => 'add_category2'));
	table_content('', $table);
	table_footer('Create Category');
}

############################### END ###############################

echo "</td></tr></table>";

function update_cache() { ?>
<script language="JavaScript">
	top.empty.location.reload();
</script>
<?php
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -