PHP Drupal 6 - 自定义“Who's Online”阻止私人消息链接。

function online_block() {
	$localIP=$_SERVER['SERVER_ADDR'];

	//Count users with activity in the past defined period.
	$time_period = variable_get('user_block_seconds_online', 150);

	//Perform database queries to gather online user lists.
	$guests = sess_count(time() - $time_period);

	$total_guests = db_result(db_query('SELECT COUNT(hostname) FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period));
	$users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period);
	$total_users = db_result(db_query('SELECT DISTINCT COUNT(u.uid) FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period));

	//Display a list of currently online users.
	$max_users = variable_get('user_block_max_list_count', 10);

	if ($total_users && $max_users) {
		$items = array();
		while ($max_users-- && $account = db_fetch_object($users)) {
			$items[] = $account;
		}
		$output.="<div class=\"item-list\"><h4>Members online</h4><p>Within the last 150 seconds</p><ul>";
		for($i=0; $i<count($items); $i++) {
			//Add the account type.
			$account=user_load(array('uid'=>$items[$i]->uid));
			$acc = "";
			if (in_array("gold member", $account->roles)) {
				$acc = "Gold";
			}elseif(in_array("silver member", $account->roles)){
				$acc = "Silver";
			}elseif(in_array("site manager", $account->roles)){
				$acc = "Tim";
			}elseif(in_array("performer", $account->roles)){
				$acc = "Performer";
			}elseif(in_array("admin", $account->roles)){
				$acc = "Admin";
			}
			$output .= '<li><a href="/messages/new/'.$items[$i]->uid.'">'.$items[$i]->name.'</a> - ' . $acc . '</li>';
		}
		$output.="</ul><p>Lurkers online: ".$guests."</p></div>";
	}

	return $output;
}

PHP Drupal 6 - 从模板中显示默认的“Who's online”块。

$block = (object) module_invoke('user', 'block', 'view', '3');
print theme('block',$block);

Apache 压缩

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

JavaScript JS:打开弹出窗口

// construct for explorer compatibility
var newwindow = '';
// EG:  pop_up_window("http://www.google.com", 200, 200)
function pop_up_window(url, sizeh, sizew) {
	if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = url;
	}
	else {
		newwindow=window.open(url,'name','height=' + sizeh + ', width=' + sizew + ', status=1, resizable=1, location=1, scrollbars=1 ');   /*resizable=1*/
		if (!newwindow.opener) newwindow.opener = self;
			 newwindow.moveTo(100,100);
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

PHP 在wordpress中显示您的latrest推文

<?php
    $username = "TwitterUsername"; // Your twitter username.
    $prefix = ""; // Prefix – some text you want displayed before your latest tweet.
    $suffix = ""; // Suffix – some text you want display after your latest tweet.
    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";

    function parse_feed($feed) {
    $stepOne = explode("<content type=\"html\">", $feed);
    $stepTwo = explode("</content>", $stepOne[1]);
    $tweet = $stepTwo[0];
    $tweet = str_replace("<", "<", $tweet);
    $tweet = str_replace(">", ">", $tweet);
    return $tweet;
    }

    $twitterFeed = file_get_contents($feed);
    echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
    ?>

PHP 显示您的类别rss供稿列表

<?php wp_list_categories('feed_image=http://www.wpbeginner.com/image.gif&feed=XML Feed&optioncount=1&children=0'); ?>

CSS 将子div与父div的底部对齐

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title></title>
 </head>
 <style>
 html, body {height: 100%}
 #outer {position: relative; height: 50%;}
 #inner {position: absolute; bottom: 10px;}
 #outer, #inner {border: 1px solid #ccc;}
 </style>
 <body>
<div id="outer">OUTER
<div id="inner">INNER
</div>
</div>
 </body>
</html>

CSS clearfix更新

.clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
* html .clearfix             { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */

PHP PHP - 随机图像

<?php
//total number of images
$totalimages = "300";
//file type
$file_type = ".jpg";
//location
$image_folder = "../assets/images/";
//start counting from number
$startcounter = "1";
$random = mt_rand($startcounter, $totalimages);
$image_name = $image_folder . $random . $file_type;
?>
<img src="<?php echo $image_name; ?>" name="image<?php echo $random; ?>" width="" height="" border="0" id="image<?php echo $random; ?>" alt="" />

CSS CSS3线性渐变

-webkit-gradient(
    linear,
    left bottom,
    left top,
    color-stop(0, rgb(0,0,0)),
    color-stop(1, rgb(255,255,255))
)
-moz-linear-gradient(
    center bottom,
    rgb(0,0,0) 0%,
    rgb(255,255,255) 100%
)