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

📄 admin-tech_functions.php

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

-----ARGUMENTS: -------------------------------------
	message		Message to display

-----RETURNS:----------------------------------------
	None; directly generates output and exits

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

function mistake($message='', $noheader = 0) {

	if (!$noheader) {
		if (defined('ADMINZONE')) {
			admin_header();
		}

		if (defined('TECHZONE')) {
			tech_nav();
		}
	}

	echo "<br /><br />";

	if ($message) {
		echo table_border("<P><b>There has been an error:</b><BR /><BR />$message</b></P>");
	} else {
		echo table_border("<P><B>There has been an error:</B><BR /><BR />The action you attempted could not be completed. Please contact your helpdesk administrator for assistance.</P>");
	}
	exit();
}

/*****************************************************
	function time_since

-----DESCRIPTION: -----------------------------------
	Calculates time passed since the specified time.
	- converts number of seconds into days/hours/minutes/seconds
	- displays in x days, y hours, z minutes, v seconds format.

-----ARGUMENTS: -------------------------------------
	time	Timestamp

-----RETURNS:----------------------------------------
	Time elapsed, expressed in "X days, Y hours, Z minutes, V seconds" format.

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

function display_time($time) {

	// calculate components
	$days =	floor(($time / (60 * 60 * 24)));
	$time = $time - ($days * 60 * 60 * 24);
	$hours = floor(($time / (60 * 60)));
	$time = $time - ($hours * 60 * 60);
	$minutes = floor(($time / 60));
	$time = ($time - ($minutes * 60));
	$seconds = $time;
	
	// format time
	if ($days != "") {
		if ($days == "1") {
			return $days . " day";
		} else {
			return $days . " days";
		}
	}
	
	if ($hours != "") {
		if ($hours == "1") {
			return $hours . " hour";
		} else {
			return $hours . " hours";
		}
	}
	
	if ($minutes != "") {
		if ($minutes == "1") {
			return $minutes . " minute";
		} else {
			return $minutes . " minutes";
		}
	}
	
	if ($seconds != "") {
		if ($seconds == "1") {
			return $seconds . " second";
		} else {
			return $seconds . " seconds";
		}
	}
}

/*****************************************************
	function array_unshift_keys

-----DESCRIPTION: -----------------------------------
	

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

function array_unshift_keys(&$arr, $key, $val) { 

	$arr = array_reverse($arr, true); 
	$arr[$key] = $val; 
	$arr = array_reverse($arr, true); 
	count($arr); 

}

/*****************************************************
	function mini_table

-----DESCRIPTION: -----------------------------------
	Generates HTML for a small message table

-----ARGUMENTS: -------------------------------------
	content		HTML to insert into the table
	color		Table background color (#ABCDEF format)
	width		[Optional] Table width.

-----RETURNS: ---------------------------------------
	HTML for the table.

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

function mini_table($content, $color, $width="100%") {
	return "<table width=\"$width\" align=\"center\" cellpadding=\"3\"><tr><td bgcolor=\"$color\">$content</td></tr></table>";
}

/*****************************************************
	function convert_date

-----DESCRIPTION: -----------------------------------
	Calculate timestamp for a given numeric date.

-----ARGUMENTS: -------------------------------------
	date	Date to convert (YYYY-MM-DD format)

-----RETURNS:----------------------------------------
	Timestamp of specified date, or FALSE for invalid date.

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

function convert_date($date) {
	$datebits = explode("-",$date);
	$time = mktime(0, 0, 0, $datebits[1], $datebits[2], $datebits[0]);
	return $time;
}

/*****************************************************
	function wysiwyg

-----DESCRIPTION: -----------------------------------
	Return HTML for a submit button to open the
	WYSIWYG editor.

-----ARGUMENTS: -------------------------------------
	form		Name of the form to update
	element		Form element to update
	text		Button name and value
	return		[Optional] Return value

-----RETURNS: ---------------------------------------
	HTML for the submit button.

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

function wysiwyg($form, $element, $text, $return='') {
 
	return "<input type=\"button\" name=\"$text\" value=\"$text\" onclick=\"wysiwyg('$form', '$element', '$return')\">";
}

/*****************************************************
	function form_jump

-----DESCRIPTION: -----------------------------------
	Display a popup message, then redirect to the specified
	form handler (passing hidden form values along).

-----ARGUMENTS: -------------------------------------
	url			URL to submit to
	message		Message to display before jumping
	hidden		Form values to submit

-----RETURNS: ---------------------------------------
	Nothing.

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

function form_jump($url, $message, $hidden='') {

	if (defined('ADMINZONE')) {
		admin_mini_header('', "<title>$message</title>");
	}

	if (defined('TECHZONE')) {
		tech_mini_header('', "<title>$message</title>");
	}

	if (!$message) {
		$message = "No actions were specified; no changes made.";
	}

	echo "
	<html>
	<body onload=\"alert('$message');deskpro.submit();\">
	<form method=\"post\" name=\"deskpro\" action=\"$url\">";
	if (is_array($hidden)) {
		foreach ($hidden AS $key => $var) {
			echo form_hidden($key, $var);
		}
	}
	echo "
	<br /><br /><br /><br /><br /><p align=\"center\">
	<input type=\"submit\" name=\"Click here to continue\" value=\"Click here to continue\" onclick=\"javascript:deskpro.submit();\">
	</p>
	</form>
	</body>
	</html>
	";
	exit();
	
}

/*****************************************************
	function jump

-----DESCRIPTION: -----------------------------------
	Redirect to another URL

-----ARGUMENTS: -------------------------------------
	url			URL to redirect to
	message		Message to show during redirection

-----RETURNS: ---------------------------------------
	Nothing.

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

function jump($url, $message) {

	if (defined('ADMINZONE')) {
		admin_mini_header('', "<title>$message</title><meta http-equiv=\"Refresh\" content=\"1; URL=$url\">");
	}

	if (defined('TECHZONE')) {
		tech_mini_header('', "<title>$message</title><meta http-equiv=\"Refresh\" content=\"1; URL=$url\">");
	}
	
	echo "
	<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
	<table width=\"720\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"left\">
	<tr align=\"center\" valign=\"middle\">
	<td align=\"center\">
	<table border=\"0\" cellspacing=\"0\" cellpadding=\"10\" bgcolor=\"\" width=\"70%\">
	<tr>
	<td>
	<center><p><b>$message</b><br />
	<br />
	You are now being re-directed<br />
	<a href=\"$url\">Click here if you do not
	want to wait any longer (or if your browser does not automatically
	forward you).</a> </smallfont> </p></center>
	</td>
	</tr>
	</table>
	</td>
	</tr>
	</table>
	</body>
	</html>
	";
	
}

/*****************************************************
	function jprompt

-----DESCRIPTION: -----------------------------------
	Return HTML to generate a link that produces a confirmation 
	popup, redirecting to the specified URL if the user
	selects 'okay'.

-----ARGUMENTS: -------------------------------------
	message		Message to display
	url			URL to redirect to
	text		Link text to display
	danger		[Deprecated]

-----RETURNS: ---------------------------------------
	HTML to generate the link.
*****************************************************/

function jprompt($message, $url, $text, $danger=0) {
	$nonjs = "<a href=\"$url\">$text</a>";
	$message = addslashes_js($message);
	$url = addslashes_js($url);
	$text = addslashes_js($text);
	$js = "<a href=\"javascript:jprompt(\'$message\', \'$url\')\">$text</a>";
	return "<script language=\"JavaScript\">document.write('$js');</script><noscript>$nonjs</noscript>";
}

/*****************************************************
	function jprompt_multi

-----DESCRIPTION: -----------------------------------
	Return HTLM to generate a link that produces a double
	popup; the first confirms that an action is desired, and
	the second selects between two actions.

-----ARGUMENTS: -------------------------------------
	message		First message to display
	message2	Second message to display
	urltrue		URL to redirect to if second message is answered with "true"
	urlfalse	URL to redirect to if second message is answered with "false"
	text		Link text to display

-----RETURNS: ---------------------------------------
	HTML to generate the link.
*****************************************************/

function jprompt_multi($message, $message2, $urltrue, $urlfalse, $text) {
	return "<a href=\"javascript:jprompt_multi('$message', '$message2', '$urltrue', '$urlfalse')\">$text</a>";
}

/*****************************************************
	function table_thelp

-----DESCRIPTION: -----------------------------------


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

function table_thelp($text, $category, $topic) {
	return "<TABLE><TR><TD>$text</TD><TD VALIGN=\"middle\">" . thelp($category, $topic) . "</TD></TR></TABLE>";
}

/*****************************************************
	function thelp

-----DESCRIPTION: -----------------------------------
	Return a link to popup a tech interface help dialog 
	for the given topic

-----ARGUMENTS: -------------------------------------
	category	Category (string, not integer)
	topic		Topic (string, not integer)

-----RETURNS:----------------------------------------
	The HTML for a graphical link to pop up a window
	containing the appropriate help text, or NULL if
	no matching topic is found.
*****************************************************/

function thelp($category, $topic) {
	global $settings;

	$category = urlencode($category);
	$topic = urlencode($topic);
	$url = "'../help/deskpro_help.php?category=$category&entry=$topic&mini=1'";
	$gfx = "\"../../images/help.gif\"";
	return "<A onClick=\"openWindow($url, 650, 550, 'Help')\"><IMG SRC=$gfx BORDER=\"0\" ALIGN=\"bottom\"></A>";
}

/*****************************************************
	function ahelp

-----DESCRIPTION: -----------------------------------
	return a link to popup an admin interface help dialog 
	for the given topic

-----ARGUMENTS: -------------------------------------
	category	Category (string, not an integer)
	topic		Topic (string, not an integer)

-----RETURNS:----------------------------------------
	The HTML for a graphical link to pop up a window
	containing the appropriate help text, or NULL if
	no matching topic is found.
*****************************************************/

function ahelp($category, $topic) {
	global $settings;

	$category = urlencode($category);
	$topic = urlencode($topic);
	$url = "'../admin/help.php?category=$category&entry=$topic&mini=1'";
	$gfx = "\"../images/but071.gif\"";
	return "<A onClick=\"openWindow($url, 500, 550, 'Help')\"><IMG SRC=$gfx BORDER=\"0\" ALIGN=\"bottom\"></A>";
}

/*****************************************************
	function get_intervals

-----DESCRIPTION: -----------------------------------
	- Divide the period of time specified by
	$start and $end into time units of $interval
	length.

-----ARGUMENTS: -------------------------------------
	start		: Starting time and date, UNIX
				  time stamp format
	end			: Ending time and date, UNIX
	              time stamp format
	interval    : strtotime() acceptable format
	              of time and date specification
				  (e.g. "+1 years 4 days 3 hours
				  2 minutes")

⌨️ 快捷键说明

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