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

📄 admin-tech_functions.php

📁 本代码是为客户联系管理而做的系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:

-----RETURNS:----------------------------------------
	Returns a two-dimensional array:
		$span[0] = array($spanstart, $spanend);
		$span[1] = array($spanstart, $spanend);

	Values returned are UNIX timestamps.
*****************************************************/

function get_intervals($start, $end, $interval) {
	$spans = array();
	while ($start < $end) {
		$spanstart = $start;
		$start = strtotime(date('r', $start) . " $interval");
		if ($start >= $end) {
			$spanend = $end;
		} else {
			$spanend = $start;
		}
		$spans[] = array($spanstart, $spanend);
	}
	return $spans;
}

/*****************************************************
	function user_delete

-----DESCRIPTION: -----------------------------------
	- 	Delete one or more users, passed in as a value 
	(for one user) or an array. This checks the current 
	user's permissions before performing the actual
	deletes.

-----ARGUMENTS: -------------------------------------
	userlist	:	If an integer, a userid. If an array, 
					an array of userids.

-----RETURNS:----------------------------------------
	Returns the number of users deleted, including zero 
	(no users deleted). Returns -1 if the user doesn't have 
	permission to delete the user.

*****************************************************/

function user_delete($userlist = '') {
	global $user, $db;

	if (!$user['p_delete_users'] AND !$user['is_admin']) {
		return -1;
	}

	$deleted = 0;
	if (is_array($userlist) OR ((int)$userlist)) {
		$queries = array(
			'DELETE FROM user_session WHERE userid IN ',
			'DELETE FROM faq_comments WHERE userid IN ',
			'DELETE FROM faq_rating WHERE userid IN ',
			'DELETE FROM faq_subscriptions WHERE id IN ',
			'DELETE FROM tech_start_tickets WHERE userid IN ',
			'DELETE FROM user_bill WHERE userid IN ',
			'DELETE FROM user_email WHERE userid IN ',
			'DELETE FROM user_notes WHERE userid IN ',
			'UPDATE faq_articles SET userid = 0 WHERE userid IN ',
			'DELETE FROM user WHERE id IN '
		);

		if (is_array($userlist)) {
			$term = array2sql($userlist);
		} else {
			$term = array2sql(array($userlist));
		}

		// run those queries
		foreach ($queries AS $val) {
			$db->query($val . $term);
		}
		if ($db->affected_rows()) {
			$deleted++;
		}

		$db->query("SELECT id FROM ticket WHERE userid IN $term");
		while ($result = $db->row_array()) {
			$ids[] = $result[id];
		}

		ticket_delete($ids);

	}

	return $deleted;
}


/*****************************************************
	function ticket_delete

-----DESCRIPTION: -----------------------------------
	- 	Delete one or more tickets, passed in as a 
	value (for one ticket) or an array. This checks 
	the current user's permissions before performing the
	actual deletes.

-----ARGUMENTS: -------------------------------------
	ticketlist	:	If an integer, a ticketid. If an 
					array, an array of ticketids.

-----RETURNS:----------------------------------------
	Returns an array, containing two elements:

	noperms		:	An array, a list of tickets the calling 
					tech has no permission to delete
	deleted		:	An array, a list of tickets deleted 
					by the function.

	If both arrays count() to zero, no tickets were passed 
	to the function.

*****************************************************/

function ticket_delete($ticketlist = '') {
	global $user, $db;

	if (is_array($ticketlist)) {
		$term = array2sql($ticketlist);
	} else {
		$term = array2sql(array($ticketlist));
		$ticketlist = array($ticketlist);
	}

	if (!count($ticketlist)) {
		return array(NULL, NULL);
	}

	$db->query("SELECT id, tech FROM ticket WHERE id IN $term");
	while ($res = $db->row_array()) {
		if ($res['tech'] == $user['id']) {
			if ($user['p_delete_own']) {
				$delete[] = $res['id'];
			} else {
				$noperms[] = $res['id'];
			}
		} else {
			if ($user['p_delete_other'] or $user['is_admin']) {
				$delete[] = $res['id'];
			} else {
				$noperms[] = $res['id'];
			}
		}
	}

	if (!@count($delete)) {
		return array($noperms, NULL);
	} else {
		$term = array2sql($delete);
	}

	$deleted = 0;
	if (is_array($ticketlist) OR ((int)$ticketlist)) {
		$queries = array(
			'DELETE FROM tech_ticket_watch WHERE ticketid IN ',
			'DELETE FROM ticket_attachments WHERE ticketid IN ',
			'DELETE FROM ticket_log WHERE ticketid IN ',
			'DELETE FROM ticket_notes WHERE ticketid IN ',
			'DELETE FROM tech_ticket_save WHERE ticketid IN ',
			'DELETE FROM ticket_message WHERE ticketid IN ',
			'DELETE FROM user_bill WHERE ticketid IN ',
			'DELETE FROM ticket WHERE id IN ',
			'DELETE FROM tech_ticket_watch WHERE ticketid IN '
		);

		// Grab attachment blobs to delete
		$db->query("SELECT blobid FROM ticket_attachments WHERE ticketid IN $term");
		while ($res = $db->row_array()) {
			$blobs[] = $res['blobid'];
		}
		$db->query("DELETE FROM blobs WHERE id IN " . array2sql($blobs));

		// get ticket messages and delete the source
		$db->query("SELECT id FROM ticket_message WHERE ticketid IN $term");
		while ($res = $db->row_array()) {
			$sources[] = $res['id'];
		}
		$db->query("DELETE FROM gateway_source WHERE id IN " . array2sql($sources));

		foreach ($queries AS $val) {
			$db->query($val . $term);
		}
	}

	return array($noperms, $delete);
}

/*****************************************************
	function ban_email

-----DESCRIPTION: -----------------------------------
	- 	Adds an e-mail address to the banned list.

-----ARGUMENTS: -------------------------------------
	email	:	E-mail address to ban.

-----RETURNS:----------------------------------------
	Returns -1 if permission denied (can't ban
	users), 0 if already banned, 1 if added
	successfully to banned list.

*****************************************************/

function ban_email($email) {
	global $user;

	if (!$user['p_edit_users'] AND !$user['is_admin']) {
		return -1;
	}
	$banned = unserialize(get_data('email_ban'));
	if (!@in_array($email, $banned)) {
		$banned[] = $email;
		update_data('email_ban', serialize($banned));
		return 1;
	} else {
		return 0;
	}
}


#####################################################################################
##################	HTML OUTPUT FUNCTIONS ###########################################
#####################################################################################


/*****************************************************
	function start_outline_table

-----DESCRIPTION: -----------------------------------
	- makes a border for a table (generally for links)

-----ARGUMENTS: -------------------------------------
	none

-----RETURNS:----------------------------------------
	echos the HTML directly

*****************************************************/

function outline_table($title='', $content='', $width='100%') {

	?>

	<table width="<?php echo $width; ?>" border="0" cellspacing="0" cellpadding="0">
	
	<tr><td height="18">
	<font color="#BF4343">\\</font> <strong><?php echo $title; ?></strong>
	</td></tr>
		
	<tr>
	<td height="19" bgcolor="#D1D1D1">

	<?php
	if (!$width) {
	$width = '100%';
	}
	?>

	<table width="100%" border="0" cellspacing="1" cellpadding="5">
	<tr><td bgcolor="#FFFFFF"> 

	<table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
	<tr><td>
	<?php echo $content; ?>
	</td></tr>
	</table>

	</td></tr></table>
	</td></tr></table>

	<?
	
}

/*****************************************************
	function get_javascript

-----DESCRIPTION: -----------------------------------
	- gets a javascript; takes account of where we are

-----ARGUMENTS: -------------------------------------
	action			: location of the javascript file

-----RETURNS:----------------------------------------
	The html to the javascript

*****************************************************/

function get_javascript($loc) {

	return "\n<script language=\"javascript\" src=\"" . constant('LOC_JAVASCRIPT') . $loc . "\"></script>\n";

}

/*****************************************************
	function get_css

-----DESCRIPTION: -----------------------------------
	- gets a css; takes account of where we are

-----ARGUMENTS: -------------------------------------
	action			: location of the css file

-----RETURNS:----------------------------------------
	The html to the css

*****************************************************/

function get_css($loc) {

	return "\n<link rel=\"stylesheet\" href=\"" . constant('LOC_CSS') . $loc . "\" type=\"text/css\">";

}

/*****************************************************
	function global_login

-----DESCRIPTION: -----------------------------------
	- gets a css; takes account of where we are

*****************************************************/

function global_login($message='', $logout = 0) {

	global $_REQUEST, $_GET, $_POST, $_FILES, $req, $settings;

	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
	header("Cache-Control: no-cache, must-revalidate");
	header("Pragma: no-cache"); 

	if (defined('ADMINZONE')) {
		admin_mini_header();
		if ($logout OR !$req) {
			$req = 'index.php';
		}
	} else {
		tech_mini_header();

		if ($logout OR !$req) {
			$req = '../home/index.php';
		}
	}

	echo '
<SCRIPT language="javascript">
if (parent.frames.length > 0) {
    parent.location.href = self.document.location
}
</SCRIPT>
';

	echo "<center><BR>";
	echo "<P><BR><BR><table width=\"400\"><tr><td>";
	
	if ($message) {
		echo table_border('<b><center>' . $message . '</center></b>');
	}

	$bit = array('<B>Username</B>', form_input('username', ''));
	$table[] = $bit;

	if (!$_REQUEST['_getvars']) {
		$get = $_GET;
	} else {
		$get = $_REQUEST['_getvars'];
	}

	if (!$_REQUEST['_postvars']) {
		$post = $_POST;
	} else {
		$post = $_REQUEST['_postvars'];
	}

	if (!$_REQUEST['_filevars']) {
		$file = $_FILE;
	} else {
		$file = $_REQUEST['_filevars'];
	}

	$bit = array('<B>Password</B>', form_password('password', '') . 
		form_hidden('_getvars', htmlspecialchars(serialize($get))) .
		form_hidden('_postvars', htmlspecialchars(serialize($post))) .
		form_hidden('_filevars', htmlspecialchars(serialize($file))) .
		form_hidden('_request', htmlspecialchars(serialize($_REQUEST))));

	$table[] = $bit;
	$bit = array('<b>Remember me<br /></b>until I log out manually', form_radio_yn('cookie').form_hidden('login_form', 'login').form_hidden('original_uri', urldecode($req)));
	$table[] = $bit;

	echo table_header('Please log in', urldecode($req));
	echo table_content('', $table);

	echo table_footer('Login');
	
	echo "</td></tr></table></center>";
	echo "<script language=\"JavaScript\">
		document.forms[0].username.focus();
	</SCRIPT>";
	
	echo "<BR><BR><BR><BR><center>Powered by: <!--WTN-WDYL-->DeskPRO v $settings[deskpro_version]</a><br />
	Copyright 

⌨️ 快捷键说明

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