functions.php

来自「在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布X」· PHP 代码 · 共 1,693 行 · 第 1/4 页

PHP
1,693
字号
	} else {		$checked = ' ';	}	echo '<p><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">'._LANG_F_TIMESTAMP.'</label> : <a href="http://wordpress.xwd.jp/wiki/index.php?Reference%20Post%2FEdit#timestamp" title="'._LANG_F_TIMESTAMP.'帮助">帮助</a><br />';	$time_adj = time() + ($time_difference * 3600);	$jj = ($edit) ? mysql2date('d', $postdata['Date']) : date('d', $time_adj);	$mm = ($edit) ? mysql2date('m', $postdata['Date']) : date('m', $time_adj);	$aa = ($edit) ? mysql2date('Y', $postdata['Date']) : date('Y', $time_adj);	$hh = ($edit) ? mysql2date('H', $postdata['Date']) : date('H', $time_adj);	$mn = ($edit) ? mysql2date('i', $postdata['Date']) : date('i', $time_adj);	$ss = ($edit) ? mysql2date('s', $postdata['Date']) : date('s', $time_adj);	echo '<input type="text" name="jj" value="'.$jj.'" size="2" maxlength="2" />'."\n";	echo "<select name=\"mm\">\n";	for ($i=1; $i < 13; $i=$i+1) {		echo "\t\t\t<option value=\"$i\"";		if ($i == $mm)		echo " selected='selected'";		if ($i < 10) {			$ii = "0".$i;		} else {			$ii = "$i";		}		echo ">".$month["$ii"]."</option>\n";	} ?></select><input type="text" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @<input type="text" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :<input type="text" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" /> :<input type="text" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> </p>	<?php}function gzip_compression() {	global $gzip_compressed;		if (!$gzip_compressed) {		$phpver = phpversion(); //start gzip compression		if($phpver >= "4.0.4pl1") {			if(extension_loaded("zlib")) {				ob_start("ob_gzhandler");			}		} else if($phpver > "4.0") {			if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {				if(extension_loaded("zlib")) {					$do_gzip_compress = TRUE;					ob_start();					ob_implicit_flush(0);					header("Content-Encoding: gzip");				}			}		} //end gzip compression - that piece of script courtesy of the phpBB dev team		$gzip_compressed=1;	}}function alert_error($msg) { // displays a warning box with an error message (original by KYank)	?>	<html>	<head>	<script language="JavaScript">	<!--	alert("<?php echo $msg ?>");	history.back();	//-->	</script>	</head>	<body>	<!-- this is for non-JS browsers (actually we should never reach that code, but hey, just in case...) -->	<?php echo $msg; ?><br />	<a href="<?php echo $_SERVER["HTTP_REFERER"]; ?>">go back</a>	</body>	</html>	<?php	exit;}function alert_confirm($msg) { // asks a question - if the user clicks Cancel then it brings them back one page	?>	<script language="JavaScript">	<!--	if (!confirm("<?php echo $msg ?>")) {	history.back();	}	//-->	</script>	<?php}function redirect_js($url,$title="...") {	?>	<script language="JavaScript">	<!--	function redirect() {	window.location = "<?php echo $url; ?>";	}	setTimeout("redirect();", 100);	//-->	</script>	<p>Redirecting you : <b><?php echo $title; ?></b><br />	<br />	If nothing happens, click <a href="<?php echo $url; ?>">here</a>.</p>	<?php	exit();}// functions to count the page generation time (from phpBB2)// ( or just any time between timer_start() and timer_stop() )function timer_start() {    global $timestart;    $mtime = microtime();    $mtime = explode(" ",$mtime);    $mtime = $mtime[1] + $mtime[0];    $timestart = $mtime;    return true;}function timer_stop($display=0,$precision=3) { //if called like timer_stop(1), will echo $timetotal    global $timestart,$timeend;    $mtime = microtime();    $mtime = explode(" ",$mtime);    $mtime = $mtime[1] + $mtime[0];    $timeend = $mtime;    $timetotal = $timeend-$timestart;    if ($display)        echo number_format($timetotal,$precision);    return $timetotal;}// pings Weblogs.comfunction pingWeblogs($blog_ID = 1) {	// original function by Dries Buytaert for Drupal	global  $siteurl,$my_pingserver;	if ((!((get_settings('blogname')=="my weblog") && ($siteurl=="http://example.com"))) && (!preg_match("/localhost\//",$siteurl)) && (get_settings('use_weblogsping'))) {		$message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval(get_settings('blogname')), new xmlrpcval($siteurl."/index.php")));		foreach($my_pingserver as $p) {			$client = new xmlrpc_client($p['path'],$p['server'],$p['port']);			$result = $client->send($message, 30);			unset($client);		}		unset($message);		if (!$result || $result->faultCode()) {			return false;		}		return true;	} else {		return false;	}}// pings Weblogs.com/rssUpdatesfunction pingWeblogsRss($blog_ID = 1, $rss_url) {	global $use_weblogsrssping,  $rss_url;	if (get_settings('blogname') != 'my weblog' && $rss_url != 'http://example.com/b2rdf.php' && $use_weblogsrssping) {		$client = new xmlrpc_client('/RPC2', 'rssrpc.weblogs.com', 80);		$message = new xmlrpcmsg('rssUpdate', array(new xmlrpcval(get_settings('blogname')), new xmlrpcval($rss_url)));		$result = $client->send($message);		if (!$result || $result->faultCode()) {			return false;		}		return true;	} else {		return false;	}}// pings Caf癍og.comfunction pingCafelog($cafelogID,$title='',$p='') {	global $use_cafelogping,  $siteurl;	if ((!((get_settings('blogname')=="my weblog") && ($siteurl=="http://example.com"))) && (!preg_match("/localhost\//",$siteurl)) && ($use_cafelogping) && ($cafelogID != '')) {		$client = new xmlrpc_client("/xmlrpc.php", "cafelog.tidakada.com", 80);		$message = new xmlrpcmsg("b2.ping", array(new xmlrpcval($cafelogID), new xmlrpcval($title), new xmlrpcval($p)));		$result = $client->send($message);		if (!$result || $result->faultCode()) {			return false;		}		return true;	} else {		return false;	}}// pings Blo.gsfunction pingBlogs($blog_ID="1") {	global   $use_rss,  $siteur;	if ((!((get_settings('blogname')=='my weblog') && ($siteurl=='http://example.com'))) && (!preg_match('/localhost\//',$siteurl)) && (get_settings('use_blodotgsping'))) {		$url = (get_settings('blodotgsping_url') == 'http://example.com') ? $siteurl.'/index.php' : get_settings('blodotgsping_url');		$client = new xmlrpc_client('/', 'ping.blo.gs', 80);		if ($use_rss) {			$message = new xmlrpcmsg('weblogUpdates.extendedPing', array(new xmlrpcval(get_settings('blogname')), new xmlrpcval($url), new xmlrpcval($url), new xmlrpcval($siteurl.'/b2rss.xml')));		} else {			$message = new xmlrpcmsg('weblogUpdates.ping', array(new xmlrpcval(get_settings('blogname')), new xmlrpcval($url)));		}		$result = $client->send($message);		if (!$result || $result->faultCode()) {			return false;		}		return true;	} else {		return false;	}}// Send a Trackbackfunction trackback($trackback_url, $title, $excerpt, $ID, $charset = "") {	global  $wpdb,  $blog_charset ;	$ID=intval($ID);	$title = stripslashes($title);	$excerpt = stripslashes($excerpt);	$blog_name = stripslashes(get_settings('blogname'));	if ($charset) {		/*		if (function_exists('mb_convert_encoding')) {			$title = mb_convert_encoding($title,$charset,$blog_charset);			$excerpt = mb_convert_encoding($excerpt,$charset,$blog_charset);			$blog_name = mb_convert_encoding($blog_name,$charset,$blog_charset);		}		*/		if (function_exists('xoopschina_convert_encoding')) {			$title = xoopschina_convert_encoding($title, $blog_charset, $charset);			$excerpt = xoopschina_convert_encoding($excerpt, $blog_charset, $charset);			$blog_name = xoopschina_convert_encoding($blog_name, $blog_charset, $charset);		}	} else {		$charset = $blog_charset;	}	$title1 = urlencode($title);	$excerpt1 = urlencode($excerpt);	$blog_name1 = urlencode($blog_name);	$tb_url = $trackback_url;	$url = urlencode(get_permalink($ID));	$query_string = "title=$title1&url=$url&blog_name=$blog_name1&excerpt=$excerpt1&charset=$charset";	$trackback_url = parse_url($trackback_url);	if ($trackback_url['query']=="") {		$http_request  = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";	} else {		$http_request  = 'POST '.$trackback_url['path']."?".$trackback_url['query']." HTTP/1.0\r\n";	}	$http_request .= 'Host: '.$trackback_url['host']."\r\n";	$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.$charset."\r\n";	$http_request .= 'Content-Length: '.strlen($query_string)."\r\n";	$http_request .= "\r\n";	$http_request .= $query_string;	$fs = @fsockopen($trackback_url['host'], 80);	@fputs($fs, $http_request);	if(false) {		$debug_file = '../log/trackback.log';		$fp = fopen($debug_file, 'a');		fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");		fwrite($fp, "CHARSET:$charset\n");		fwrite($fp, "TITLE:$title\n");		fwrite($fp, "TITLE1:".urldecode($title1)."\n");		fwrite($fp, "EXCERPT:$excerpt\n");		while(!@feof($fs)) {			fwrite($fp, @fgets($fs, 4096));		}		fwrite($fp, "\n\n");		fclose($fp);	}	@fclose($fs);	$wpdb->query("UPDATE {$wpdb->posts} SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = $ID");	$wpdb->query("UPDATE {$wpdb->posts} SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = $ID");	return $result;}// trackback - replyfunction trackback_response($error = 0, $error_message = '') {	global $blog_charset;	if ($error) {		echo "<?xml version=\"1.0\" encoding=\"$blog_charset\"?".">\n";		echo "<response>\n";		echo "<error>1</error>\n";		echo "<message>$error_message</message>\n";		echo "</response>";	} else {		echo "<?xml version=\"1.0\" encoding=\"$blog_charset\"?".">\n";		echo "<response>\n";		echo "<error>0</error>\n";		echo "</response>";	}	die();}function make_url_footnote($content) {	global $siteurl;	preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches);	$j = 0;	for ($i=0; $i<count($matches[0]); $i++) {		$links_summary = (!$j) ? "\n" : $links_summary;		$j++;		$link_match = $matches[0][$i];		$link_number = '['.($i+1).']';		$link_url = $matches[2][$i];		$link_text = $matches[4][$i];		$content = str_replace($link_match, $link_text.' '.$link_number, $content);		$link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? $siteurl.$link_url : $link_url;		$links_summary .= "\n".$link_number.' '.$link_url;	}	$content = strip_tags($content);	$content .= $links_summary;	return $content;}function xmlrpc_getposttitle($content) {	global $post_default_title;	if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) {		$post_title = $matchtitle[0];		$post_title = preg_replace('/<title>/si', '', $post_title);		$post_title = preg_replace('/<\/title>/si', '', $post_title);	} else {		$post_title = $post_default_title;	}	return $post_title;}function xmlrpc_getpostcategory($content) {	global $post_default_category;	if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) {		$post_category = $matchcat[0];		$post_category = preg_replace('/<category>/si', '', $post_category);		$post_category = preg_replace('/<\/category>/si', '', $post_category);	} else {		$post_category = $post_default_category;	}	return $post_category;}function xmlrpc_removepostdata($content) {	$content = preg_replace('/<title>(.+?)<\/title>/si', '', $content);	$content = preg_replace('/<category>(.+?)<\/category>/si', '', $content);	$content = trim($content);	return $content;}function debug_fopen($filename, $mode) {	global $debug;	if ($debug == 1) {		$fp = fopen($filename, $mode);		return $fp;	} else {		return false;	}}function debug_fwrite($fp, $string) {	global $debug;	if ($debug == 1) {		fwrite($fp, $string);	}}function debug_fclose($fp) {	global $debug;	if ($debug == 1) {		fclose($fp);	}}function pingback($content, $post_ID) {	// original code by Mort (http://mort.mine.nu:8080)	global $siteurl, $wp_version;	$log = debug_fopen('./pingback.log', 'a');	$post_links = array();	debug_fwrite($log, 'BEGIN '.time()."\n");	// Variables	$ltrs = '\w';	$gunk = '/#~:.?+=&%@!\-';	$punc = '.:?\-';	$any = $ltrs.$gunk.$punc;	$pingback_str_dquote = 'rel="pingback"';	$pingback_str_squote = 'rel=\'pingback\'';	$x_pingback_str = 'x-pingback: ';	$pingback_href_original_pos = 27;	// Step 1	// Parsing the post, external links (if any) are stored in the $post_links array	// This regexp comes straight from phpfreaks.com	// http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php	preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);	// Debug	debug_fwrite($log, 'Post contents:');	debug_fwrite($log, $content."\n");	// Step 2.	// Walking thru the links array	// first we get rid of links pointing to sites, not to specific files	// Example:	// http://dummy-weblog.org	// http://dummy-weblog.org/	// http://dummy-weblog.org/post.php	// We don't wanna ping first and second types, even if they have a valid <link/>	foreach($post_links_temp[0] as $link_test){		$test = parse_url($link_test);		if (isset($test['query'])) {			$post_links[] = $link_test;		} elseif(($test['path'] != '/') && ($test['path'] != '')) {			$post_links[] = $link_test;		}	}	foreach ($post_links as $pagelinkedto){		debug_fwrite($log, 'Processing -- '.$pagelinkedto."\n\n");		$bits = parse_url($pagelinkedto);		if (!isset($bits['host'])) {			debug_fwrite($log, 'Couldn\'t find a hostname for '.$pagelinkedto."\n\n");			continue;		}		$host = $bits['host'];		$path = isset($bits['path']) ? $bits['path'] : '';		if (isset($bits['query'])) {			$path .= '?'.$bits['query'];		}		if (!$path) {			$path = '/';

⌨️ 快捷键说明

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