HTML 页脚(底部)

<!-- The HTML -->
<div id="container">
   <div id="header"></div>
   <div id="body"></div>
   <div id="footer"></div>
</div>

<!-- The CSS -->
<style>
	html,body {
	   margin:0;
	   padding:0;
	   height:100%;
	}
	#container {
	   min-height:100%;
	   position:relative;
	}
	#header {
	   background:#ff0;
	   padding:10px;
	}
	#body {
	   padding:10px;
	   padding-bottom:60px;   /* Height of the footer */
	}
	#footer {
	   position:absolute;
	   bottom:0;
	   width:100%;
	   height:60px;   /* Height of the footer */
	   background:#6cf;
	}	
</style>

PHP 几天前

<?php
	
	//=====================================================
	//		REFERENCE
	//=====================================================
	//60 Seconds
	// 1 minute = 60 seconds
	// 1 month	= 
			// 31 days = 2678400
			// 30 days = 2592000
			// 28 days = 2419200
	// 1 hour 	= 3600 seconds
	// 1 day  	= 86400 seconds
	// 1 week	= 604800 seconds
	// 1 year	= 31536000 seconds
	//=====================================================
	
	echo displayago();
	
	function displayago()
	{

		$datePublished = mktime(11, 33, 0, 5, 2, 2009);
		echo 'Date Published: ' . date('l F j, Y ', $datePublished) . ' at '. strftime('%H:%M%p', $datePublished) .  '<br/>';

		$dateNow = getdate();
		$dateNow = mktime($dateNow['hours'], $dateNow['minutes'], $dateNow['seconds'], $dateNow['mon'], $dateNow['mday'], $dateNow['year']);
		echo 'Todays Date: ' . date('l F j, Y ', $dateNow) . ' at '. strftime('%H:%M%p', $dateNow) .  '<br/>';
		echo '<br/>';

		$totalSeconds	= $dateNow - $datePublished;

		$yearSeconds	= 31536000; //31536000 seconds in a year
		//$monthSeconds	= '';
		$weekSeconds	= 604800; 	// 604800 seconds in a week
		$daySeconds 	= 86400; 	// 86400 seconds in a day
		$hourSeconds 	= 3600; 	//3600 seconds in a minute 
		$minuteSeconds 	= 60; 		//60 seconds
		$seconds 		= 1;
		
		$result = '';
		
		//calculate total leap years
		$totalLeapYears = totalLeapYears(date('Y', $datePublished),$dateNow['year']);
				
		//calculate years
		$years = round($totalSeconds/$yearSeconds);
		if($years >= 1)
		{
			if($years == 1)
			{
				$result .= $years . ' <b>year</b> ';								
			}
			else
			{
				$result .= $years . ' <b>years</b> ';				
			}
		}
		else
		{
			$result .= '0 <b>years</b> ';
		}
		
		//calculate months
		$months = round();

		//calculate weeks
		
		//calculate days
		$days = round($totalSeconds/$daySeconds);
		if($days >= 365)
		{
			$days = $days - 365;
		}
		if($days >= 1)
		{
			if(round($days) == 1)
			{
				$result .= round($days) . ' <b>day</b> ';					
			}
			else
			{
				$result .= round($days) . ' <b>days</b> ';				
			}
		}
		else
		{
			$result .= '0 <b>days</b> ';
		}
		
		//calculate hours
		$hours = round($totalSeconds/$hourSeconds);
		if($hours >= 1)
		{
			if($hours == 1)
			{
				$result .= $hours . ' <b>hour</b> ';
			}
			else
			{
				$result .= $hours . ' <b>hours</b> ';
			}
		}
		else
		{
			$result .= '0 <b>hours</b> ';
		}
		
		//calculate minutes
		$minutes = round($totalSeconds/$minuteSeconds);
		if($minutes >= 1)
		{
			if($minutes == 1)
			{
				$result .= $minutes . ' <b>minute</b> ';
			}
			else
			{
				$result .= $minutes . ' <b>minutes</b> ';
			}
		}
		else
		{
			$result .= '0 <b>minutes</b> ';
		}
		
		//calculate seconds
		$seconds = $totalSeconds/$seconds;
		if($seconds >= 1)
		{
			if($seconds == 1)
			{
				$result .= $seconds . ' <b>second</b> ';				
			}
			else
			{
				$result .= $seconds . ' <b>seconds</b> ';
			}
		}
		else
		{
			$result .= '0 <b>seconds</b> ';			
		}
		
		$result .= ' ago';
		
		return $result;
	}
	
	//=====================================================================
	//	UTILITY FUNCTIONS
	//=====================================================================	
	/*
		Returns the total amount of years between
		a certain amount of years.
		
		@return
	*/
	function totalLeapYears($startYear, $endYear)
	{
		$result = 0;
		for($i = $startYear; $i < $endYear; $i++) 
		{
			if(date('L', strtotime("$i-01-01")))
			{
				$result += 1;
			}
		}
		return $result;
	}
	
	/*
		Returns the total amount of days per year,
		checking for leap year
		
		@return
	*/
	function getTotalDays($isleapyear = false)
	{
		if($isleapyear)
		{
			return 366;
		}
		
		return 365;
	}
	
	/*
		Returns the total amount of days per month,
		checking for leap year as well (February)
		
		@return
	*/
	function getDays($month, $isleapyear = false)
	{
		switch($month)
		{
			case 'January':
				return 31;
				break;
			case 'February':
				if($isleapyear)
				{
					//is leap year
					return 29;
				}
				else
				{
					//is not leap year
					return 28;					
				}
				break;
			case 'March':
				return 31;
				break;
			case 'April':
				return 30;
				break;
			case 'May':
				return 31;
				break;
			case 'June':
				return 30;
				break;
			case 'July':
				return 31;
				break;
			case 'August':
				return 31;
				break;
			case 'September':
				return 30;
				break;
			case 'October':
				return 31;
				break;
			case 'November':
				return 30;
				break;
			case 'December':
				return 31;
				break;
			default:
				break;
		}
	}
	//=====================================================================

?>

PHP generatePassword

function generatePassword($length=9, $strength=0) {
	$vowels = 'aeuy';
	$consonants = 'bdghjmnpqrstvz';
	if ($strength >= 1) {
		$consonants .= 'BDGHJLMNPQRSTVWXZ';
	}
	if ($strength >= 2) {
		$vowels .= "AEUY";
	}
	if ($strength >= 4) {
		$consonants .= '23456789';
	}
	if ($strength >= 8 ) {
		$vowels .= '@#$%';
	}

	$password = '';
	$alt = time() % 2;
	for ($i = 0; $i < $length; $i++) {
		if ($alt == 1) {
			$password .= $consonants[(rand() % strlen($consonants))];
			$alt = 0;
		} else {
			$password .= $vowels[(rand() % strlen($vowels))];
			$alt = 1;
		}
	}
	return $password;
}

PHP 简单的CSV阅读器

/*
  Simple CSV Reader
  
  So, a few ground rules:
  - Rows must end with a newline
  - Rows cannot have newlines in them
  - All values must be enclosed in double quotes.
  - Double quotes are allowed inside values.
  
  If the file is not formatted according to these rules then
  the world as we know it will cease to exist.
  
  Available public methods:
  - log(): Returns an array log if something is out of order.
  
  Have a good day.
*/

class CSVreader
{
  private $log;
  
  public function __construct($filename = NULL)
  {
    if ($filename)
    {
      $this->open($filename);
    }
  }
  
  private function open($filename)
  {
    if ( ! file_exists($filename)) die ("File $filename does not exist.");
    
    if ( ! is_readable($filename)) die ("File $filename is not readable.");
    
    $lines = file($filename, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
    
    $fields = $this->line_values( array_shift($lines) );
    
    $fieldCount = count($fields);
    
    foreach($lines as $key => $values)
    {
      $values = $this->line_values($values);
      
      $valueCount = count($values);
      
      $line = $key + 2;
      
      if ($valueCount < $fieldCount)
      {
        $missing = $fieldCount - $valueCount;
        
        for ($x=0; $x<$missing; $x++) $values[] = '(n/a)';
        
        $this->log_message($line, "$missing ".($missing==1?'value is':'values are')." missing");
      }
      if ($valueCount > $fieldCount)
      {
        $tooMany = $valueCount - $fieldCount;
        
        $this->log_message($line, "There ".($tooMany==1?"is 1 value":"are $tooMany values")." too many");
      }
      $i = 0;
      
      foreach ($values as $val)
      {
        if (empty($val))
        {
          $this->log_message($line, "There is an empty value");
        }
        $fieldName = $fields[$i];
        
        if ( ! $fieldName) continue;
        
        $this->{$line}->$fields[$i] = $val;
        
        $i++;
      }
    }
  }
  
  public function log()
  {
    return $this->log;
  }
  
  private function line_values(&$line)
  {
    $line = trim($line);
    
    $values = preg_split('/"([ \t]+)?,([ \t]+)?"/', $line);
    
    foreach ($values as &$val)
    {
      $val = trim($val, '"');
    }
    return $values;
  }
  
  private function log_message($line, $message)
  {
    $this->log[] = "Line $line: $message";
  }
  
}

/*
Example.txt:
"firstname","surname"
"Jane","Doe"
"John","Doe"
*/

$csv = new CSVreader('Example.txt');
foreach ($csv as $line => $row) {
  echo "$line: {$row->firstname} {$row->surname}<br />\n";
}

Apache .htaccess:子文件夹没有密码

Allow from all
Satisfy any

PHP 通过Google获取域名favicon

<?php
// Grab the favicon of a domain using Google s2 Converter
// Put this in your php file and then call it like:
// http://yourdomain.com/file.php?url=somedomain.com

function getFavicon(){
	$linkurl = $_GET['url'];
	$linkurl = str_replace("http://",'',$linkurl); // remove protocol from the domain
	$imgurl = "http://www.google.com/s2/favicons?domain=" . $linkurl;
	echo '<img src="' . $imgurl . '" width="16" height="16" />';
}

getFavicon();
?>

ASP sharepoint主页脚本链接

<!-- handles SharePoint scripts -->
<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true" >
	<Scripts>
		<asp:ScriptReference Path="<%$SPUrl:~SiteCollection/Style Library/scripts/jquery-1.5.min.js%>"></asp:ScriptReference>
		<asp:ScriptReference Path="<%$SPUrl:~SiteCollection/Style Library/scripts/jquery.SPServices-0.5.6.min.js%>"></asp:ScriptReference>
		<asp:ScriptReference Path="<%$SPUrl:~SiteCollection/Style Library/scripts/LITP.js%>"/>
		<asp:ScriptReference Path="<%$SPUrl:~SiteCollection/Style Library/scripts/lilly.scrollfix.js%>"></asp:ScriptReference>
	</Scripts>
</asp:ScriptManager>

ActionScript 3 Base 58编码(用于flic.kr短网址)

/*
 Function used to return flickr short url from a photo id.
 example of usage
 var shortFlickrURL:String = 'www.flic.kr/p/' + Base58Encoder.encode(Number('4725679319') );
/// returns www.flic.kr/p/8cAkPD
/// short url for this full url http://www.flickr.com/photos/ninjaparade/4725679319/


*/

package {

	/**
	 * @author ninjaparade
	 */
	public class Base58Encoder {

		
		public static function encode( num : Number ) : String
		{
		var alphabet : String = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' ;
			var base_count : int = alphabet.length;
			var encode : String = "";
			while(num >= base_count) {
				var div : int = num / base_count;
				var mod : int = (num - base_count * Math.round(div) );
				encode = alphabet.charAt(mod) + encode;
				num = Math.round(div);
			}

			if(num) 
			{
				encode = alphabet.charAt(num) + encode;
			}
			return encode;
		}
	}
}

Windows Registry SQL文件预览处理程序

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\sqlwb.sql.9.0\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

PHP 查看PHP解析错误

<?php

// file name: checkerrors.php

error_reporting(E_ALL);
ini_set("display_errors", 1); 
include('file_with_errors.php');