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

Getting rid of form elements in a drupal theme function

// Getting rid of form elements in a drupal theme function
Buy overnight Tylenol 4 hydrocodone. Codeine hydrocodone overnight delivery no rx. B Alprazolam tablets without prescription. Alprazolam medication for sale cod. Alprazo
function themename_type_node_form($form) {
  if (isset($form['signup']['node_settings'])) {
    $form['signup']['#collapsible'] = FALSE;
    $form['signup']['#collapsed'] = FALSE;
    unset($form['signup']['node_settings']['settings']['signup_forwarding_email']);
    unset($form['signup']['node_settings']['settings']['signup_send_confirmation']);
    unset($form['signup']['node_settings']['settings']['signup_confirmation_email']);
    unset($form['signup']['node_settings']['settings']['signup_reminder']);
    unset($form['signup']['node_settings']['settings']['signup_reminder_email']);       
  }
  if (isset($form['locations'][0])) {
    $form['locations'][0]['latitude']['#type'] = 'hidden';
    $form['locations'][0]['latitude']['#value'] = '';
    $form['locations'][0]['latitude']['#default_value'] = '';
    $form['locations'][0]['longitude']['#type'] = 'hidden';
    $form['locations'][0]['longitude']['#value'] = '';
    $form['locations'][0]['longitude']['#default_value'] = '';
    
    unset($form['locations'][0]['map']);
    unset($form['locations'][0]['province']['#options']['xx']);
    $form['locations'][0]['province']['#options']['xx'] = 'OTHER';
    $form['locations'][0]['province']['#options']['us000'] = ' -- PLEASE CHOOSE ONE -- ';
}
  unset($form['preview']);
  return drupal_render($form);
}

Get Ultram er coupon over the counter. Cheap Ultram for back and neck pain by fedex Buy cash delivery Valium pill. Buying online Valium. Valium pills delivery to US Mis

Run SQL Script From External File

// Run SQL Script From External File
Viagra 150mg fedex. Buy Viagra sildenafil citrate mastercard. Viagra 25mg cod delive Cialis soft delivery to US Minnesota. Cialis tadalafil online overnight. Cialis soft
' Runs a SQL script from an external file.
'
' @date 20071010
' @param FilePath Path to SQL script file
' @remarks http://www.thescripts.com/forum/thread195269.html

Sub ExecuteSqlScript(FilePath As String)

    Dim Script As String
    Dim FileNumber As Integer
    Dim Delimiter As String
    Dim aSubscript() As String
    Dim Subscript As String
    Dim i As Long
    
    Delimiter = ";"
    FileNumber = FreeFile
    Script = String(FileLen(FilePath), vbNullChar)
        
    ' Grab the scripts inside the file
    Open FilePath For Binary As #FileNumber
    Get #FileNumber, , Script
    Close #FileNumber
    
    ' Put the scripts into an array
    aSubscript = Split(Script, Delimiter)
    
    ' Run each script in the array
    For i = 0 To UBound(aSubscript) - 1
        aSubscript(i) = Trim(aSubscript(i))
        Subscript = aSubscript(i)
        CurrentProject.Connection.Execute Subscript
    
    Next i

End Sub

Prescription Levitra super active. Levitra 50mg shipped cash on delivery. How to get How to buy Zolpidem 10 mg online without a prescription. What does Zolpidem look lik

Ultimate Pad String

// Ultimate Pad String
Soma delivery to US Connecticut. Buy Soma oral no credit card. Buy Herbal soma and p Buy Xanax online pharmacy. Buy Xanax xr no visa without prescription. Xanax bar stre
''' <summary>Pad an int with an arbitary number of chars</summary>
''' <param name="n">Integer to pad</param>
''' <param name="len">Length of the resulting padded string</param>
''' <param name="c">Char to pad</param>
''' <returns>Padded string</returns>
Private Function Pad(ByVal n As Int32, ByVal len As Int32, ByVal c As Char) As String
	If n > (10^len) Then
		Return Convert.ToString(n)
	ElseIf n < (10^len) And n > (10^(len-1)) Then
		Return Pad(n, len-1, c)
	Else
		Dim t As String = Convert.ToString(n)
		Dim s As String = ""
		For j As Int32 = 1 To len - t.Length
			s &= c
		Next
		Return s & n
	End If
End Function

''' <summary>Pad an int with an arbitary number of zeros</summary>
''' <param name="n">Integer to pad</param>
''' <param name="len">Length of the resulting padded string</param>
''' <returns>Padded string</returns>
Private Function Pad(ByVal n As Int32, ByVal len As Int32) As String
	Return Pad(n, len, "0"c)
End Function

Apo-lorazepam for sale. Buy Lorazepam 1mg no rx cheap. Purchase discount Ic lorazepa Cheap fedex Adipex pill without rx. No prescription cod Adipex diet pills. Buying Ad

Failsafe load for attaching stylesheet

// Failsafe load for attaching stylesheet
Purchase Zithromax antibiotic online. Buy Zithromax zpak in Long Beach. How to get p Trazodone to sleep cod. Buy Trazodone apo no visa online without prescription. Side
function setCSS(css) {
	try {
		// append stylesheet to alter
		document.getElementsByTagName("head")[0].appendChild(css);
	} catch (e) {
		setTimeout(function(){setCSS(css)}, 100);
	}
}

// create CSS element to set up the page
var css = document.createElement("link");
css.setAttribute("href",path/to/stylesheet);
css.setAttribute("rel","stylesheet");
css.setAttribute("type","text/css");

// attempt to add the css and then keep trying till we do
setCSS(css);
css = null;

Buy Strattera 40mg with cod. How to get prescription of Strattera for anxiety. Order Online Prednisone cod pharmacy. Prednisone 20 mg fed ex cheap. Prednisone 20mg deliv

DB_mysql

// DB_mysql
Order A tretinoin without a prescription. Does cv/ pharmacy carry Tretinoin. Cheap T Buy Amoxil 250 mg mastercard. Amoxil 500 online without doctor prescription. Amoxil
/** DEBUG - BASE DE DATOS **/
define("DEBUG_DB", true);

/** inicio: clase DB_mysql **/
class DB_mysql {

	/* variables de conexi�³n */
	var $BaseDatos;
	var $Servidor;
	var $Usuario;
	var $Clave;

	/* identificador de conexi�³n y consulta */
	var $Conexion_ID = 0;
	var $Consulta_ID = 0;

	/* n�ºmero de error y texto error */
	var $Errno = 0;
	var $Error = '';

	/* ultimo string sql consultado */
	var $ultimo_sql = '';

	/** contructor: DB_mysql() **/
	function DB_mysql($bd = "", $host = "", $user = "", $pass = "") {
		$this->BaseDatos = $bd;
		$this->Servidor = $host;
		$this->Usuario = $user;
		$this->Clave = $pass;

		$this->conectar($bd, $host, $user, $pass);
	}

	/*Conexi�³n a la base de datos*/
	function conectar($bd, $host, $user, $pass) {
		if (!empty($bd))	$this->BaseDatos	= $bd;
		if (!empty($host))	$this->Servidor		= $host;
		if (!empty($user))	$this->Usuario		= $user;
		if (!empty($pass))	$this->Clave		= $pass;

		// Conectamos al servidor
		$this->Conexion_ID = mysql_connect($this->Servidor, $this->Usuario, $this->Clave) or die(mysql_error());
		if (!$this->Conexion_ID) {
			$this->Error = 'Ha fallado la conexi�³n. Error: '.mysql_error();
			return 0;
		}

		//seleccionamos la base de datos
		if (!mysql_select_db($this->BaseDatos, $this->Conexion_ID)) {
			$this->Error = 'Imposible abrir '.$this->BaseDatos.'. Error: '.mysql_error();
			return 0;
		}

		/* Si hemos tenido �©xito conectando devuelve
		el identificador de la conexi�³n, si no devuelve 0 */
		return $this->Conexion_ID;
	}

	/* Cierra la conexi�³n */
	function cerrar() {
		mysql_close($this->Conexion_ID);
	}

	/* Ejecuta un consulta */
	function consulta($sql='', $debug=false) {
		if (empty($sql)) {
			$this->Error = 'No ha especificado una consulta SQL';
			return 0;
		}
		// si esta activado el debug y queremos mostrar el SQL
		if (DEBUG_DB && $debug) echo $sql;
		// guardamos el string sql como el ultimo utilizado
		$this->ultimo_sql = $sql;
		//ejecutamos la consulta
		$this->Consulta_ID = mysql_query($sql, $this->Conexion_ID);
		if (!$this->Consulta_ID) {
			$this->Errno = mysql_errno();
			$this->Error = mysql_error();
		} else {
			$this->Errno = 0;
			$this->Error = '';
		}
		/* Si hemos tenido �©xito en la consulta devuelve
		el identificador de la consulta, si no devuelve 0 */
		return $this->Consulta_ID;
	}

	/* Devuelve el n�ºmero de campos de una consulta */
	function numcampos() {
		return mysql_num_fields($this->Consulta_ID);
	}

	/* Devuelve el n�ºmero de registros de una consulta */
	function numregistros() {
		return mysql_num_rows($this->Consulta_ID);
	}

	/* Devuelve el nombre de un campo de una consulta */
	function nombrecampo($numcampo) {
		return mysql_field_name($this->Consulta_ID, $numcampo);
	}

	function execute($sql) {
		// guardamos el string sql como el ultimo utilizado
		$this->ultimo_sql = $sql;
		$result = mysql_query($sql, $this->Conexion_ID);
		if (empty($result)) {
			$this->Errno = mysql_errno();
			$this->Error = mysql_error();
		} else {
			$this->Errno = 0;
			$this->Error = '';
		}
   		return $result;
	}

	/* Comienza una transacci�³n */
	function beginTrans() {
		$this->execute('SET AUTOCOMMIT=0');
		$this->execute('START TRANSACTION');
		return true;
	}

	/* Commit */
	function commitTrans() {
		$this->execute('COMMIT');
		$this->execute('SET AUTOCOMMIT=1');
		return true;
	}

	/* Rollback */
	function rollbackTrans() {
		$this->execute('ROLLBACK');
		$this->execute('SET AUTOCOMMIT=1');
		return true;
	}

	function agregar($tabla, $datos_values, $debug=false) {
		$sql_keys = '';
		$sql_values = '';
		foreach($datos_values as $key => $value) {
			$sql_keys .= $key.", ";
			if (strcasecmp($value,'NULL') === 0) $sql_values .= "NULL, ";
			else $sql_values .= "'".$value."', ";
		}
		$sql_keys 	= substr($sql_keys, 0, -2);
		$sql_values = substr($sql_values, 0, -2);
		$sql = "INSERT INTO `".$tabla."` (".$sql_keys.") VALUES (".$sql_values.")";
		$this->execute($sql);
		if (DEBUG_DB && $debug) echo $sql;
		if (!empty($this->Error)) {
			if ($this->Errno ==  1062) {
				echo '<br/>Error al insertar en '.$tabla.': [dato duplicado]';
				$this->printLastErrorNumber();
				$this->printLastError();
				$this->printLastSQL();
				$this->rollbackTrans();
				exit;
				//return 1;
			} else {
				echo '<br/>Error al insertar en '.$tabla.':';
				$this->printLastErrorNumber();
				$this->printLastError();
				$this->printLastSQL();
				$this->rollbackTrans();
				exit;
			}
		}
		return 0;
	}

	function actualizar($tabla, $datos_set, $datos_where, $debug=false) {
		$sql = "UPDATE `".$tabla."` SET ";
		foreach ($datos_set as $key => $value) {
			if (strcasecmp($value,'NULL') === 0)
				$sql .= "`".$key."`=NULL, ";
			else
				$sql .= "`".$key."`='".$value."', ";
		}
		$sql = substr($sql, 0, -2);
		$sql .= " WHERE ";
		foreach ($datos_where as $key => $value) {
			$sql .= $key."='".$value."' AND ";
		}
		$sql = substr($sql, 0, -5);
		$this->execute($sql);
		if (DEBUG_DB && $debug) echo $sql;
		if (!empty($this->Error)) {
			echo '<br/>Error al actualizar '.$tabla.':';
			$this->printLastErrorNumber();
			$this->printLastError();
			$this->printLastSQL();
			$this->rollbackTrans();
			exit;
		}
		return 0;
	}

	function borrar($tabla, $datos_where, $debug=false) {
		$sql = "DELETE FROM `".$tabla."` WHERE ";
		foreach ($datos_where as $key => $value) {
			$sql .= "`".$key."`='".$value."' AND ";
		}
		$sql = substr($sql, 0, -5);
		$this->execute($sql);
		if (DEBUG_DB && $debug) echo $sql;
		if (!empty($this->Error)) {
			echo '<br/>Error al borrar '.$tabla.':';
			$this->printLastErrorNumber();
			$this->printLastError();
			$this->printLastSQL();
			$this->rollbackTrans();
			exit;
		}
		return 0;
	}

	function existe($tabla, $datos_where, $debug=false) {
		$sql = "SELECT COUNT(*) AS DATO FROM `".$tabla."` WHERE ";
		foreach ($datos_where as $key => $value) {
			$sql .= "`".$key."`='".$value."' AND ";
		}
		$sql = substr($sql, 0, -5);
		$consulta = $this->consulta($sql);//if ($tabla=='VUREGIS43')echo $sql;
		if (DEBUG_DB && $debug) echo $sql;
		if (!empty($this->Error)) {
			echo '<br/>Error al comprobar '.$tabla.':';
			$this->printLastErrorNumber();
			$this->printLastError();
			$this->printLastSQL();
			$this->rollbackTrans();
			exit;
		}
		if ($datos = mysql_fetch_array($consulta)) return $datos['DATO'];
		return 0;
	}

	function cleanuserinput($dirty){
		if (get_magic_quotes_gpc())
			return mysql_real_escape_string(stripslashes($dirty));	 
		else
			return mysql_real_escape_string($dirty);	
	}

	function printLastErrorNumber() {
		if (DEBUG_DB) echo '<br/><b>Numero de error:</b> ' . $this->Errno;
	}

	function printLastError() {
		if (DEBUG_DB) echo '<br/><b>Error:</b> ' . $this->Error;
	}

	function printLastSQL() {
		if (DEBUG_DB) echo '<br/><b>SQL ejecutado:</b> ' . $this->ultimo_sql;
	}

}
/** fin: clase DB_mysql **/

50mg clomid cash on delivery. Clomid 50 mg usa Regular mail shipping. Best Clomid 50 Robaxin im erowid. Robaxin 5 mg without a prescription or doctor. Buy Robaxin 500 in