index browsing and cool code snipets

Posted by: §intå×

index browsing and cool code snipets - 11/10/05 03:27 PM

Code:
 
Code from  http://www.ogobin.org/bin/scripts/31337.php.inc 
<?php
/**************************************************
* PHP leetspeak - Version 1.0                     *
* by Oliver Gobin <[email protected]>                 *
* http://www.ogobin.org/bin/scripts/31337.php.inc *
*                                                 *
* PHP port of the PERL Version                    *
* http://www.ogobin.org/bin/sources/31337.perl    *
*                                                 *
* What is leetspeak?                              *
* http://www.wikipedia.org/wiki/Leet              *
* http://www.heise.de/ct/00/11/003/               *
***************************************************/

if(isset($text)) {
  $alphabet = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
  $level1   = array("4", "b", "c", "d", "3", "f", "g", "h", "i", "j", "k", "1", "m", "n", "0", "p", "9", "r", "s", "7", "u", "v", "w", "x", "y", "z");
  $level2   = array("4", "b", "c", "d", "3", "f", "g", "h", "1", "j", "k", "1", "m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x", "y", "2");
  $level3   = array("4", "8", "c", "d", "3", "f", "6", "h", "'", "j", "k", "1", "m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x", "'/", "2");
  $level4   = array("@", "8", "c", "d", "3", "f", "6", "h", "'", "j", "k", "1", "m", "n", "0", "p", "9", "r", "5", "7", "u", "v", "w", "x", "'/", "2");
  $level5   = array("@", "|3", "c", "d", "3", "f", "6", "#", "!", "7", "|<", "1", "m", "n", "0", "|>", "9", "|2", "$", "7", "u", "\\/", "w", "x", "'/", "2");
  $level6   = array("@", "|3", "c", "|)", "&", "|=", "6", "#", "!", ",|", "|<", "1", "m", "n", "0", "|>", "9", "|2", "$", "7", "u", "\\/", "w", "x", "'/", "2");
  $level7   = array("@", "|3", "[", "|)", "&", "|=", "6", "#", "!", ",|", "|<", "1", "^^", "^/", "0", "|*", "9", "|2", "5", "7", "(_)", "\\/", "\\/\\/", "><", "'/", "2");
  $level8   = array("@", "8", "(", "|)", "&", "|=", "6", "|-|", "!", "_|", "|\(", "1", "|\\/|", "|\\|", "()", "|>", "(,)", "|2", "$", "|", "|_|", "\\/", "\\^/", ")(", "'/", "\"/_");
  $level9   = array("@", "8", "(", "|)", "&", "|=", "6", "|-|", "!", "_|", "|\{", "|_", "/\\/\\", "|\\|", "()", "|>", "(,)", "|2", "$", "|", "|_|", "\\/", "\\^/", ")(", "'/", "\"/_");
  
  $levels = array($level1, $level2, $level3, $level4, $level5, $level6, $level7, $level8, $level9);
  
  echo "<h4>Original</h4>\n

$text"; 
  
  for($level = 0; $level <= 8; $level++) {
    $tmp = strtolower($text);
    for($item = 0; $item <= 23; $item++) {
      $tmp = ereg_replace($alphabet[$item], $levels[$level][$item], $tmp);
    }
    echo "<h4>Level $level</h4>\n

$tmp";
  }
}

?>
 
Posted by: §intå×

Re: index browsing and cool code snipets - 11/10/05 03:32 PM

Look closely and find acces to a db

Code:
from  http://www.microexport.org/php/inc/dbSubs.inc
<?php

function dbDate($in_date)
{
	if($in_date)
		return date('Y-m-d', strtotime($in_date));
	else
		return "";
}

function dbDispDate($in_date)
{
	if($in_date)
		return date('d-M-y', strtotime($in_date));
	else
		return "";
}


function dbDispTime($in_date)
{
	if($in_date)
		return date('g:i A', strtotime($in_date));
	else
		return "";
}


function dbOpen()
{
	global $db_conn;
	
	$db_conn = mysql_pconnect(c_mySqlServer, c_mySqlLogin, c_mySqlPW)
				or die("Could not connect to " . c_mySqlServer . "(" . c_mySqlLogin . ")
" 
							.mysql_error());

	mysql_select_db(c_mySqlDBName, $db_conn)
  			or die ("Can't use " . c_mySqlDBName . " : " . mysql_error());

	return $db_conn;
}


function dbClose()
{
	global $db_conn;
	
}


function dbExecute($in_sql)
{
	global $db_conn;
	
  if(mysql_query($in_sql, $db_conn))
  	return TRUE;
  else
  	return FALSE;
}

function dbSelect($in_sql)
{
	global $db_conn;
	
  return mysql_query($in_sql, $db_conn);
}


function dbSingleValue($in_sql)
{
	global $db_conn;
	
	$result = mysql_query($in_sql, $db_conn);
	
	if($result)
	{
		if(mysql_num_rows($result) > 0)
		{
      $lRow = mysql_fetch_array($result);
			$retVal = $lRow[0];
			mysql_free_result($result);
      return $retVal;
		}
	}
	
	return NULL;
}
	
function dbSingleValueColumn($in_sql, $in_column)
{
	global $db_conn;
	
	$result = mysql_query($in_sql, $db_conn);
	
	if($result)
	{
		if(mysql_num_rows() > 0)
		{
      $lRow = mysql_fetch_array($result);
      $retVal = $lRow[$in_column];
			mysql_free_result($result);
      return $retVal;
		}
	}
	
	return NULL;
}




function dbGetAffiliateOperatorID($in_affiliateID)
{
	if(in_affiliateID > 0)
		return dbSingleValue("SELECT operatorID from benBankOp, benBankBranch WHERE benBankOp.benBankID = benBankBranch.benBankId AND benBankBranchID = " . $in_affiliateID);
	else
		return 0;
}


function dbGetMemberBankName($in_bankID)
{
	return dbSingleValue("SELECT name FROM memberBank WHERE memberBankID = " . $in_bankID);
}


function dbGetDepSlipCost($in_memberID)
{
	$lSql = "SELECT cost
						FROM depSlipRequest
						WHERE memberID= " . $in_memberID
					. " ORDER BY delivered DESC ";
					
	$l_cost = dbSingleValue($lSql);
	
	if($l_cost > 0)
		return $l_cost;
	else
		return 0;
}


function dbGetMemberFee($in_benID, $in_memberID)
{
	if($in_benID > 0)
	{
		$l_depositCount = dbSingleValue("SELECT COUNT(*) FROM trans WHERE benID = " . $in_benID);
		if($l_depositCount > 0)
			return 0;
	}
	
				// The beneficiary has not had any transactions, check the member
	
	$l_depositCount = dbSingleValue("SELECT COUNT(*) FROM trans WHERE memberID = " . $in_memberID);
	if($l_depositCount > 0)
	{
		if($in_benID > 0)
		{
				// This must be the first transaction for a new beneficiary
				// See if this is the first send for the member
			$l_depositCount = dbSingleValue("SELECT COUNT(*) 
																				FROM member, trans 
																				WHERE member.memberID = trans.memberID
																				AND trans.transTypeID IN (" . c_transTypeIDSend . ", " . c_transTypeIDCarteraSend . ")");
			
				// There have been sends, but not for this beneficiary so charge new ben fee
			if($l_depositCount > 0)
			{
				return c_newBenFee;
			}
				// There have been no sends, this must be the first send after a cartera, no charge
			else
				return 0;
			

				// If this is the default beneficiary check for carteras

/*				
			$l_depositCount = dbSingleValue("SELECT COUNT(*) 
																				FROM member, trans 
																				WHERE member.defaultBenID = " . $in_benID . "
																				AND member.memberID = trans.memberID
																				AND trans.transTypeID = " . c_transTypeIDCarteraDeposit);
																				
				// If this is the default benficiary and there have been cartera deposits
				// Then waive the new beneficiary fee
			if($l_depositCount > 0)
				return 0;
				
				// No deposits for this beneficiary - no qualifying cartera deposits - charge new ben fee
			else
				return c_newBenFee;
*/			
		}
		
				// This is apparently a cartera transaction for a member with at least one prior transaction
				// Therefore no member fee
		else
			return 0;
	}
	
				// No Transactions for the member -- Charge the new member fee
	else
		return c_normalMemberFee;

}


function dbGetMostRecentXRate($in_currencyID)
{
	return dbSingleValue("SELECT basic FROM xRate WHERE currencyID = " . $in_currencyID
												. " ORDER BY xRateDate DESC");
}


function dbGetMaxXRate($in_currencyID, $in_depDate, $in_type = "basic")
{
	$sqlSel = New clsSqlSelect;
	
		$sqlSel->init("xRate");
		$sqlSel->addColumn("MAX(" . $in_type . ")", $in_type);
		$sqlSel->addCondition("currencyID=" . $in_currencyID);
		$sqlSel->addCondition("TO_DAYS(xRateDate) >= TO_DAYS('" . dbDate($in_depDate) . "')");
		$sqlSel->execute();

		if($sqlSel->fields[$in_type] > 0)
			$l_xRate = $sqlSel->fields[$in_type];
		else
			$l_xRate = 0;
			
		$sqlSel->unload();
		
		return $l_xRate;
}



function dbGetXRate($in_currencyID, $in_depDate, $in_type = "basic")
{
	$sqlSel = New clsSqlSelect;
	
		$sqlSel->init("xRate");
		$sqlSel->addColumn($in_type);
		$sqlSel->addCondition("currencyID=" . $in_currencyID);
		$sqlSel->addCondition("TO_DAYS(xRateDate) = TO_DAYS('" . dbDate($in_depDate) . "')");
		$sqlSel->execute();

		if($sqlSel->fields[$in_type] > 0)
			$l_xRate = $sqlSel->fields[$in_type];
		else
			$l_xRate = 0;
			
		$sqlSel->unload();
		
		return $l_xRate;
}


function dbSetMemberInactive($in_memberID)
{
	dbExecute("UPDATE member SET status = 'Cancelled' WHERE memberID = $in_memberID");
}

function dbSetBenInactive($in_benID)
{
	dbExecute("UPDATE ben SET status = 'Cancelled' WHERE benID = $in_benID");
}

function dbGetBenFullName($in_benID)
{
	return dbSingleValue("SELECT CONCAT_WS(' ', name, paternalFamilyName, maternalFamilyName) AS benName 
														FROM ben WHERE benID = " . $in_benID);
}

function dbGetBenFirstTransID($in_benID)
{
	return dbSingleValue("SELECT MIN(transID) FROM trans WHERE benID = " . $in_benID);
}


function dbGetMemberFullName($in_memberID)
{
	return dbSingleValue("SELECT CONCAT_WS(' ', name, paternalFamilyName, maternalFamilyName) AS memberName 
													FROM member WHERE memberID = " . $in_memberID);
}


function dbGetPostDate()
{
	return dbSingleValue("SELECT value FROM settings WHERE code = 'postDate'");
}

function dbGetCountryID($in_name)
{
	return dbSingleValue("SELECT countryID FROM country "
												.	" WHERE UPPER(name) = '" . strtoupper($in_name) . "'");
}

function dbGetProvinceID($in_countryID, $in_name)
{
	return dbSingleValue("SELECT benProvinceID FROM benProvince "
												.	" WHERE countryID = " . $in_countryID
												. " AND (UPPER(abrev) = '" . strtoupper($in_name) . "'"
													. " OR UPPER(name) = '" . strtoupper($in_name) . "')");
}


function dbGetGenderID($in_gender)
{
	return dbSingleValue("SELECT genderID FROM gender "
												. " WHERE upper(spanishDesc) = '" . strtoupper($in_gender) . "'"
												. " OR UPPER(englishDesc) = '" . strtoupper($in_gender) . "'");
}

?>