<?php
/*
(c) copyright 2011 nadlabs.co.uk. All rights reserved.
Please read the full text of the nl-DFLA licence for this software at
http://www.nadlabs.co.uk/licence.php
*/
//call any includes here
/*none yet*/
//load some general functions
function globalIsSet($arrayPostGet,$postGetList){
$flagValidation = true;
foreach ($postGetList as $testValue){
if (!(isset($arrayPostGet[$testValue]))){
//echo 'fail---'.$testValue.'';
$flagValidation = false;
}
}
return $flagValidation;
}
function globalMagic($stripValue){
if(get_magic_quotes_gpc()) {
$stripValue = stripslashes(trim($stripValue));
}
$stripValue = mysql_real_escape_string(trim($stripValue));
return $stripValue ;
}
function globalQuery($finalSQL,$conn,$type){
//insert
if ($type==1){
$results = @mysql_query($finalSQL,$conn);//or die(mysql_error());
$uid = @mysql_insert_id();
$mar=0;
$mar = @mysql_affected_rows($conn);
$dataPostBack = array($uid,$mar,@mysql_insert_id());
}
else{
//select
if ($type==2){
$results = @mysql_query($finalSQL,$conn); //or die(mysql_error());
$dbarray = @mysql_fetch_array($results); //or die(mysql_error());
$numRow=0;
$numRow = @mysql_num_rows($results); //or die(mysql_error());
$dataPostBack = array($dbarray,$numRow);
}
else{
//update/delete
if ($type==3){
$results = @mysql_query($finalSQL,$conn);
$mar=0;
$mar = @mysql_affected_rows($conn);
$dataPostBack = array("0",$mar);
}
}
}
return $dataPostBack;
}
function globalQueryPlus($finalSQL,$conn,$type){
//need to do error checking/catching here.
//insert
if ($type==1){
$results = @mysql_query($finalSQL,$conn);
$uid = @mysql_insert_id();
$mar=0;
$mar = @mysql_affected_rows($conn);
$dataPostBack = array($uid,$mar);
}
else{
//select
if ($type==2){
$results = @mysql_query($finalSQL,$conn);
$numRow=0;
$numRow = @mysql_num_rows($results);
$dataPostBack = array($results,$numRow);
}
else{
//update/delete
if ($type==3){
$results = @mysql_query($finalSQL,$conn);
$mar=0;
$mar = @mysql_affected_rows($conn);
$dataPostBack = array("0",$mar);
}
}
}
return $dataPostBack;
}
function loop_to_array($recordset){
$set = array();
while($row = mysql_fetch_array($recordset,MYSQL_ASSOC)) {
$set[] = $row;
}
return $set;
}
function getDomain($url){
if(filter_var($url,FILTER_VALIDATE_URL,FILTER_FLAG_HOST_REQUIRED)){
$parseUrl = parse_url(trim($url));
if (isset($parseUrl['host'])){
return trim($parseUrl['host'] ? $parseUrl['host'] : array_shift(explode('/', $parseUrl['path'], 2)));
}
else{
return 'not-found';
}
}
else{
return 'not-found';
}
}
?>