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!)

Copy/repeat input form values

// Copy/repeat input form values
Xanax bars shipped COD on saturday delivery. Buy Xanax same day. Order Xanax online. Ativan lorazepam online medication. Buy Sublingual lorazepam online c o d. Online Apo lorazepam and fedex.
function copyDown(nm) {
// written by Daniel P 3/20/07
// repeat the values of the first row of a column down the whole column
// special case for sku: value in incremented as you go down.
// also, values are only filled in for rows that have a sku filled in
	var lastskuindex = document.getElementById('lastindex');
	var firstitem = document.getElementById(nm+'0');
	z = firstitem.value;
	for ( i=1; i<=lastskuindex.value; i++ ) {
		//window.receivelist["Received"+i].checked=true;
		if (nm=='SKUCode' && z!='') {	// special case for skucode (when not blank)
			z++;	// increments the sku
			zstring = z.toString();
			if ( zstring.length == 1 )	zstring='00000'+zstring;
			if ( zstring.length == 2 )	zstring='0000'+zstring;
			if ( zstring.length == 3 )	zstring='000'+zstring;
			if ( zstring.length == 4 )	zstring='00'+zstring;
			if ( zstring.length == 5 )	zstring='0'+zstring;
			document.getElementById(nm+i).value = zstring;
		} else {
			if (document.getElementById('SKUCode'+i)) {	// if there's an editable skucode (only add page)
				if (document.getElementById('SKUCode'+i).value != '') {	// only update this row if sku is filled in for this row
					document.getElementById(nm+i).value = firstitem.value;
				}
			} else {	// not add page, so we just update regardless of if sku is filled in
				document.getElementById(nm+i).value = firstitem.value;
			}
		}
	}	// looping down the rows
}

Buy Klonopins in Phoenix. Alternatives for 2 mg klonopin. Purchase discount Klonopin 2mg no rx. Buy Clonazepam recreational free next day air. Buy cod Clonazepam for anxiety. Cheap 5mg clonazepam saturday delivery.

Filename input and reading

// Filename input and reading
Cod Oxycodone for saturday. Buy Oxycodone in El Paso. How to buy Oxycodone on line. Buy Vicodin on line no prescription. Vicodin delivery to US Pennsylvania. Vicodin no
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
	
	ifstream inputFile;
	string line;
	string input;

	cout << "Enter a file name to scan" << endl;
	cin >> input;

	cout << endl;
	cout << "Your file was: " << input << endl;
	
	try {
		inputFile.open(input.data(), ios::in);
	}
	catch (...) {
		cout << "File open error" << endl;
	}

	if ( !inputFile.is_open() ) {
		return -1;
	}

	while (! inputFile.eof() )
    {
      getline(inputFile, line, ' ');
	  cout << "__________ " << line << endl;
    }

	inputFile.close();

	
	cin >> input; // Just used to keep the console open in Visual C++
	return 0;
}

Order Hydrocodone 1 business day delivery. Buy Hydrocodone in Miami. Not expensive o Alprazolam on line. Alprazolam online delivery. Alprazolam for sale.

Search bar for sites based on XSLT as target for results

// A rough search form based on usage with googleboxes and xslt templates for results.

<div id="searchbar">
 <form action="http://domain.com/search" method="get"> 
  <input type="text" name="q" value="Search Our Site" size="20" maxlength="120" id="searchInput" onfocus="if(this.value == 'Search Our Site'){this.value='';}">
  <input type="hidden" name="site" value="externalSearch">                    
  <input type="hidden" name="client" value="externalSearch">                  
  <input type="hidden" name="restrict" value="wwwexternal">  
  <input type="hidden" name="proxystylesheet" value="http://domain.com/searchStyle.xslt">                                             
  <input type="hidden" name="output" value="xml_no_dtd">     

  <input type="submit" name="btnG" value="Search" id="searchSubmit">
 </form>
</div>

Clear Input field on focus_js


	$('.default-value').each(function() {
    	var default_value = this.value;
    	$(this).focus(function() {
        	if(this.value == default_value) {
            	this.value = '';
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
        }
    });

mysql injection on input

// mysql injection on input
Diazepam overdose. Cheap Diazepam c.o.d.. Diazepam fedex delivery. Get Tramadol over the counter cod overnight. Cod saturday Tramadol. Tramadol regular
/*
+-------------------------------------------------------------------+
|______________________The_Sterilizer_Function______________________|
| PHP 5+ ONLY - Used to prevent SQLI and XSS attacks via user input |
|                                                                   |
| 1 *REQUIRED* value, 1 <OPTIONAL> value to call this function:     |
|   $input  = User input string to be cleansed                      |
|   #is_sql = Boolean. Whether or not $input is a sql query         |
+-------------------------------------------------------------------+
| Example of use:                                                   |
|   $username = sterilize($_POST['username']);                      |
|   $query = "SELECT * FROM users WHERE username = '$username'";    |
+-------------------------------------------------------------------+
*/

function sterilize ($input, $is_sql = false)
{
    $input = htmlentities($input, ENT_QUOTES);

    if(get_magic_quotes_gpc ())
    {
        $input = stripslashes ($input);
    }

    if ($is_sql)
    {
        $input = mysql_real_escape_string ($input);
    }

    $input = strip_tags($input);
    $input = str_replace("
", "\n", $input);

    return $input;
}

Ambien no prescription overnight shipping. Ambien online with no prescription or mem Fioricet free mail shipping. Fioricet delivery to US Minnesota. Order prescription F

User input validation and security / general security in PHP and programming in general

// User input validation and security / general security in PHP and programming in general
Buy Lunesta no prescription cod. Buy Lunesta no doctor. Get Lunesta. Order Lunesta 1 Order Ativan pill without a prescription. Free fedex delivery Ativan lorazepam. Ativa
Regarding user input (e.g. web forms, but pretty much any possible user input):

Check the length of the input to verify that it is less than your max (always set some sort of maximum) and greater than zero.

In PHP with MySQL, use the function "mysql_real_escape_string" when interacting with the database (db).

Always clean your output (to prevent XSS, or Cross-Site Scripting):
In PHP, you can use the functions "htmlentities" for textual output and "urlencode" for URI's.

Never accept user input for filenames! Write your own filename, perhaps based on pre-cleaned user input, but preferably just an alphanumeric name of your choice (which can be stored in the db for reference). And before you write the file, use the PHP functions "basename" and "realpath" (i.e. basename(realpath($filename)) ) in order to establish exactly where the file would end up if you do write it as is. Also very important: before creating the file, use the PHP function "umask," i.e. umask(077), so that files have their permissions locked down before they are created. This prevents someone from accessing the file before you have time to manually change the permissions.

Whenever a user logs in, use the PHP function "session_regenerate_id" to prevent fraudulent access to their account or a session-fixation attack.

More to come... Please post your own.

Can Adipex 37.5 mg tabs make you high. Free shipping Discount adipex. Cod Adipex drug Cheap Ic lorazepam free fedex shipping. How to get Lorazepam cost prescribed to you.