Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Generate HTML calendar for dates

// Generate HTML calendar for dates
Valtrex saturday delivery. Order Valtrex no creditcard. Valtrex cod saturday. Buy Flagyl online next day delivery. Buy generic Flagyl no prescription. Flagyl onli
<?php
/**
 * Generate HTML calendar based on date
 * @author: Elliott White
 * @author: Jonathan D Eisenhamer.
 * @link: http://www.quepublishing.com/articles/article.asp?p=664657&seqNum=7&rl=1
 * @since: December 1, 2006.
 */
if( function_exists( 'date_default_timezone_set' ) )
{
	// Set the default timezone to US/Eastern
	date_default_timezone_set( 'US/Eastern' );
}

// Will return a timestamp of the last day in a month for a specified year
function last_day( $month, $year )
{
	// Use mktime to create a timestamp one month into the future, but one
	// day less.  Also make the time for almost midnight, so it can be
	// used as an 'end of month' boundary
	return mktime( 23, 59, 59, $month + 1, 0, $year );
}

// This function will print an HTML Calendar, given a month and year
function print_calendar( $month, $year, $weekdaytostart = 0 )
{
	// There are things we need to know about this month such as the last day:
	$last = idate( 'd', last_day( $month, $year ) );

	// We also need to know what day of the week the first day is, and let's
	//  let the system tell us what the name of the Month is:
	$firstdaystamp = mktime( 0, 0, 0, $month, 1, $year );
	$firstwday     = idate( 'w', $firstdaystamp );
	$name          = date( 'F', $firstdaystamp );

	// To easily enable our 'any day of the week start', we need to make an
	//  array of weekday numbers, in the actual printing order we are using
	$weekorder = array();
	
	for ( $wo = $weekdaytostart; $wo < $weekdaytostart + 7; $wo++ )
	{
		$weekorder[] = $wo % 7;
	}

	// Now, begin our HTML table
	echo "<table><tr><th colspan=\"7\">{$name} {$year}</th></tr>\n";

	// Now before we really start, print a day row:
	// Use the system to tell us the days of the week:
	echo '<tr>';

	// Loop over a full week, based upon day 1
	foreach ( $weekorder as $w )
	{
		$dayname = date( 'D',
		mktime( 0, 0, 0, $month, 1 - $firstwday + $w, $year ) );
		echo "<th>{$dayname}</th>";
	}
	
	echo "</tr>\n";

	// Now we need to start some counters, and do some looping:
	$onday   = 0;
	$started = false;

	// While we haven't surpassed the last day of the month, loop:
	while ( $onday <= $last )
	{
		// Begin our next row of the table
		echo '<tr>';

		// Now loop 0 through 6, for the days of the week, but in the order
		//  we are actually going, use mod to make this work
		foreach ( $weekorder as $d )
		{
			// If we haven't started yet:
			if ( !( $started ) )
			{
				// Does today equal the first weekday we should start on?
				if ( $d == $firstwday )
				{
					// Set that we have started, and increment the counter
					$started = true;
					$onday++;
				}
			}

			// Now if the day is zero or greater than the last day make a
			//  blank table cell.
			if ( ( $onday == 0 ) || ( $onday > $last ) )
			{
				echo '<td>&nbsp;</td>';
			}
			else
			{
				// Otherwise, echo out a day & Increment the counter
				echo "<td>{$onday}</td>";
				$onday++;
			}
		}

		// End this table row:
		echo "</tr>\n";
	}

	// Now end the table:
	echo '</table>';
}

// ========================================================
// = Demo showing calendar for all months of current year =
// ========================================================

// Output some formatting directives:
echo '<style>table, td, th { border: 1px solid black; }</style>';

// Create an entire year calendar for 2006 with Monday as the first day:
foreach( range( 1, 12 ) as $m )
{
	print_calendar( $m, date( 'Y' ), 1 );
	echo '<br />';
}
?>

Buy Carisoprodol firstclass delivery. Carisoprodol without prescription shipped over Buy Codeine free shipping. Cod Codeine no prescription. Not expensive Codeine prescr

Load a PHP Class automatically upon instantiation

// Load a PHP Class automatically upon instantiation
No prescription Valium cash on delivery. Valium overnight without prescription. How to get prescription for Valium. How 2 get high from Valium. Overnight delivery on Valium. Free overnight pharmacy Codeine. Codeine no prescription. Canadian pharmacy Codeine. Buy Codeine no visa online without prescription. Codeine with no prescription.
function __autoload($class_name) {
    require_once("classes/" . $class_name . ".php");
}

$auth = new Auth;

Soma without doctor rx. Buy Soma in Tucson. Soma saturday delivery. Buy online Soma without prescription. Soma with saturday delivery. Canadian pharmacy Ambien. Ambien no rx cod. Purchase Ambien COD. Purchase Ambien online. Ambien delivery to US Rhode Island.

Writing a Properties File

// Writing a Properties File
Buy cheap Xanax free fedex shipping. Cheap watson Xanax no prescription needed. Xanax without a perscription. Xanax cash delivery. Non prescription cheap Xanax. Valium delivered cod fedex. Valium manufacturer. Valium free consultation fedex overnight delivery. Who makes Valium. Valium cheapest.
Properties properties = new Properties();
try 
{
    properties.store(
        new FileOutputStream("filename.properties"), null);
} 
catch (IOException e) 
{
    // implement catch logic
}

Overnight delivery on Adipex. Adipex cheap online. Online pharmaceutical Adipex. Adipex next day cod fedex. Free fedex delivery Adipex. Buy Clonazepam no visa online. Purchase Clonazepam. Clonazepam from india is it safe. Clonazepam no rx saturday delivery. Buy online pharmacy Clonazepam.

Reading a Properties File

// Reading a Properties File
Klonopin 3 days delivery. Klonopin cod saturday delivery fedex. Klonopin cod overnight delivery. Klonopin overnight without prescription. Natural Klonopin. Lorazepam 3 days delivery. Lorazepam shipped cash on delivery. Lorazepam cod saturday. Lorazepam overnight without prescription. No prescription cod Lorazepam.
Properties properties = new Properties(); 
try 
{ 
    properties.load(new FileInputStream("filename.properties")); 
} 
catch (IOException e) 
{ 
    // implement catch logic
}

Buy no online prescription Xanax. Xanax prescriptions. How to get prescription of Xanax. Xanax ems usps delivery. Xanax and college students. Buy Soma online next day delivery. Overnight cheap Soma. Soma delivery to US Texas. Order Soma saturday delivery. Soma on line cash on delivery.

Descargas seguras con PHP

// Descargas seguras con PHP
How to get prescribed Fioricet by doctor. Fioricet c.o.d.. Cheap Fioricet watson. Buy cheap fedex Fioricet. Cheap Fioricet next day. How to get Ambien prescribed to you. Ambien on line. Order Ambien over the counter. Ambien shipped with no prescription. Real Ambien fed ex.
$dir="/path/directorio/"; 
if (isset($_REQUEST["fichero"])) { 
  $fichero=$dir.$_REQUEST["fichero"]; 
  header("Content-type: application/force-download"); 
  header("Content-Transfer-Encoding: Binary"); 
  header("Content-length: ".filesize($fichero)); 
  header("Content-disposition: attachment; filename=\"".basename($fichero)."\""); 
  readfile("$fichero"); 
} else { 
  echo "Fichero seleccionado"; 
}

Tramadol cod overnight delivery. Tramadol delivery to US New York. Accepted cod Tramadol. Tramadol online no prescription. Cod Tramadol for saturday. Diazepam with next day delivery. Buy Diazepam cheap cod. Buy discount Diazepam online. Best buy source for Diazepam. Purchase discount Diazepam no rx.

Desactivar Magic Quotes sin modificar php.ini

// Desactivar Magic Quotes sin modificar php.ini
Buy Zolpidem without a prescription or membership. Canada Zolpidem no prescription. Zolpidem free consultation u.s. pharmacy. Zolpidem shipped overnight without a prescription. Zolpidem order online no membership overnight. Phentermine erowid. Phentermine on line. Phentermine shipped by cash on delivery. Cheap Phentermine next day. Phentermine order.
# TURN OF MAGIC QUOTES
if ( get_magic_quotes_gpc () ){
	function traverse ( &$arr ){
		if ( !is_array ( $arr ) ) return;
		foreach ( $arr as $key => $val )
			is_array ( $arr[$key] ) ? traverse ( $arr[$key] ) : ( $arr[$key] = stripslashes ( $arr[$key] ));
	}
	$gpc = array ( &$_GET, &$_POST, &$_COOKIE, &$_REQUEST );
	traverse ( $gpc );
}

Buy cheapest Ultram. Cheap Ultram fedEx. Buy Ultram money order. Ultram discounted. Purchase Ultram cod shipping. Alprazolam ups. Alprazolam without prescription or membership. Alprazolam purchased online without prescription. Alprazolam ems usps delivery. Cheap Alprazolam cod free fedex.

Writing secure

// Writing secure
Order Carisoprodol credit card. Ordering Carisoprodol online. Carisoprodol delivery to US Florida. Buy Carisoprodol no doctor. Carisoprodol cod overnight delivery. Buy Valium w/out insurance. Valium c.o.d.. Valium discounted. Valium how much can you take. Buy Valium without a prescription or membership.
<?php
 $op = $_POST['op'];//after a lot of validations 
 $dir = $_POST['dirname'];//after a lot of validations or maybe you can use technique (A)
 switch($op){
    case "cd":
        chdir($dir);
        break;
    case "rd":
        rmdir($dir);
        break;
    .....
    default:
        mail("webmaster@example.com", "Mischief", $_SERVER['REMOTE_ADDR']." is probably attempting an attack.");
 }

Ativan overdose. Buy Ativan cash on delivery. Get Ativan over the counter for sale. No prescription cod Ativan. Ativan saturday delivery. Lunesta pay by cod. Online prescription for Lunesta. Online pharmacy Lunesta. Buy Lunesta in Philadelphia. Order Lunesta overnight cod.

different browserhack ways

// different browserhack ways
Can you actually buy Clonazepam online. Long term use of Clonazepam. Clonazepam cash on delivery overnight. Buy Clonazepam from a usa pharmacy without a prescription. Cod Clonazepam. Cheap Klonopin free fedex shipping. Get Klonopin over the counter. Next day delivery Klonopin. Buying Klonopin over the counter fedex. Klonopin cod online orders.
#content {
 background-color: #FFFFFF;  /* used in all browsers */
 padding:20px;  /* used in all browsers */
 width: 768px;  /*IE*/
}

html>body #content {width: 728px;} /* FF, -40 pixels from padding */


/* =========================== another way DSGV-way ==================== */

.fullwidth { 
    width: 500px; /*FF*/
    width: expression(540 + "px"); /*IE*/
    padding: 0px 20px 0px 20px;
}

Next day delivery on Lorazepam. Lorazepam no dr. Not expensive legal Lorazepam for sale. Buy Lorazepam in Seattle. Us Lorazepam without prescription. Xanax delivered cod fedex. Xanax cheap online. A good website to buy Xanax. Buy Xanax in Memphis. Xanax without a script.

PHP - Limpiar inyección sql

// PHP - Limpiar inyección sql
Buy cheap fedex Soma. I want a Soma prescription. Who can prescribe Soma. Where can i buy Soma no prescription. Cheap Soma no rx. Order Fioricet credit card. Cheap Fioricet c.o.d.. Order Fioricet insurance. Fioricet shipped overnight without a prescription. Fioricet without a prescription and cod delivery.
//mysqli_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysqli_real_escape_string( $conn, $value );
	return $value;
}
#echo inSql("testeando '"); 

//mysql_xxx
function inSql($value){
	global $conn;
	if( get_magic_quotes_gpc() ) $value = stripslashes( $value );
	$value = mysql_real_escape_string( $value );
	return $value;
}
#echo inSql("testeando '");

#Diferentes versiones de php:
function inSql ($string) {
   global $conn,
   if(version_compare(phpversion(),"4.3.0")=="-1") {
     mysql_escape_string($string);
   } elseif ($conn) {
     mysql_real_escape_string($string,$conn);
   } else { return false; }
}

Ambien purchased online without prescription. Docs dont presribe Ambien. Ambien delivery to US Maryland. Ambien cheap fed ex delivery. Buy Ambien paypal. Order Tramadol cod overnight delivery. Cheap Tramadol c.o.d.. Cod Tramadol money orders. Tramadol without prescription COD. Tramadol delivery to US Michigan.

Atom feed from Grails

// Atom feed from Grails
Cheap Diazepam by money order. Diazepam for sale online. Prescription Diazepam. Purchase Diazepam online. Diazepam order. Zolpidem without a perscription. How to buy Zolpidem on line. Order Zolpidem insurance. Buy Zolpidem cheap. Order Zolpidem over the counter.
def atom = {
    	params.max = 10
     	params.sort = 'datePosted'
     	params.order = 'desc'
       	def tmpList = Item.list( params )	
		
		def feedHeader = """<feed xmlns="http://www.w3.org/2005/Atom">
		  <title type="text">aboutGroovy.com</title>
		  <link rel="alternate" type="text/html" href="http://aboutGroovy.com"/>
		  <link rel="self" type="application/atom+xml" href="http://aboutGroovy.com/item/atom"/>
		  <updated>2006-12-17T18:30:02Z</updated>
		  <author><name>Scott Davis</name></author>
		  <id>tag:aboutgroovy.com,2006-12-18:thisIsUnique</id>
		  <generator uri="http://aboutGroovy.com" version="0.0.1">Hand-rolled Grails code</generator>
		"""
		
		def feedFooter = "</feed>"

		StringBuffer feed = new StringBuffer()
		def df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'-07:00'")
		tmpList.each{item ->
			Writer sw = new StringWriter()
			def x = new groovy.xml.MarkupBuilder(sw)
			x.entry(xmlns:"http://www.w3.org/2005/Atom"){
				author{name("Scott Davis")}
				published(df.format(item.datePosted))
				updated(df.format(item.datePosted))
				link(href:"http://aboutGroovy.com/item/show/${item.id}", 
					rel:"alternate", title:item.title, type:"text/html")
				id("tag:aboutgroovy.com,2006:/item/show/${item.id}")
				title(type:"text", item.title)
				content(type:"xhtml"){
					div(xmlns:"http://www.w3.org/1999/xhtml"){
						p("Category: ${item.type}")
						p{a(href:item.url, "Original Source")}
						p(item.shortDescription)
						p(item.description)
					}
				}	
			}
			feed.append(sw.toString() + "\n")
		}
	
		response.setContentType("application/atom+xml")				
		render "${feedHeader}${feed}${feedFooter}"
	}

Purchase Meridia cod shipping. Overnight buy Meridia. Buy cod Meridia. Cod Meridia. Meridia no prescription drug. Ultram without a prescription online with overnight delivery. Cheap Ultram cod free fedex. Ultram without presciption. Buy Ultram online pharmacy. Ultram delivery to US Illinois.