Functions

<?php
// General Function File
@ob_start();
session_start();
$sess_id=session_id();
@extract($_ENV);
@extract($_SESSION);
@extract($_GET);
@extract($_POST);
@extract($_FILES);
@extract($_COOKIE);
@extract($_SERVER);
global $DB;
//$dbmode='local';
$dbmode='live';
if($dbmode=='local')
{
// Local Date Base Connection Here
//$DB["dbName"] ='';
//$DB["host"] = 'localhost';
//$DB["user"] = 'root';
//$DB["pass"] = '';
}
else
{
//Server Date Base Connection Here
$DB["dbName"] ='';
$DB["host"] = '';
$DB["user"] = '';
$DB["pass"] = '';
}
$link = mysql_connect($DB["host"], $DB["user"], $DB["pass"],false,MYSQL_CLIENT_COMPRESS) or die("An Internal Error has Occured. Please report following error to the site administrator.

“.mysql_error().”‘”);
mysql_select_db($DB[“dbName”]);

// User Define Here
define(‘SITE_URL’, ‘http://localhost/morgan/&#8217;);
$curryear=date(‘Y’);
define(‘COPYRIGHT_TEXT’, “© Copyright $curryear Morgan Travel”);
define(‘ADMIN_TITLE’, ‘Morgan Travel’);
//define(‘PAGESIZE’, ’40’); no need as this is defined in database

function executeQuery($sql)
{
$result = mysql_query($sql) or die(“An Internal Error has Occured. Please report following error to the site administrator.

“.$sql.”

“.mysql_error().”‘“);
return $result;
}

function getSingleResult($sql)
{
$response = “”;
$result = mysql_query($sql) or die(“An Internal Error has Occured. Please report following error to the site administrator.

“.$sql.”

“.mysql_error().”‘”);
if ($line = mysql_fetch_array($result)) {
$response = $line[0];
}
return $response;
}

function sort_arrows($column)
{
global $_SERVER;
return ‘ ‘;
}

function get_qry_str($over_write_key = array(), $over_write_value= array())
{
global $_GET;
$m = $_GET;
if(is_array($over_write_key)){
$i=0;
foreach($over_write_key as $key){
$m[$key] = $over_write_value[$i];
$i++;
}
}else{
$m[$over_write_key] = $over_write_value;
}
$qry_str = qry_str($m);
return $qry_str;
}

function qry_str($arr, $skip = ”)
{
$s = “?”;
$i = 0;
foreach($arr as $key => $value) {
if ($key != $skip) {
if ($i == 0) {
$s .= “$key=$value”;
$i = 1;
} else {
$s .= “&$key=$value”;
}
}
}
return $s;
}

function ms_stripslashes($text)
{
if (is_array($text)) {
$tmp_array = Array();
foreach($text as $key => $value) {
$tmp_array[$key] = ms_stripslashes($value);
}
return $tmp_array;
} else {
return stripslashes($text);
}
}

function ms_addslashes($text)
{
if (is_array($text)) {
$tmp_array = Array();
foreach($text as $key => $value) {
$tmp_array[$key] = ms_addslashes($value);
}
return $tmp_array;
} else {
return addslashes(stripslashes($text));
}
}

function imageResizeTarget($width, $height,$target_width,$target_height) {
if($height>$width)
{
if($height>$target_height)
{
$h=$target_height;
$newheight=$h;
$newwidth=($width*$newheight)/$height;
}
else
{
$newwidth=$width;
$newheight=$height;
}
}
else
{
if($width>$target_width)
{
$w=$target_width;
$newwidth=$w;
$newheight=($height/$width)*$w;

}
else
{
$newwidth=$width;
$newheight=$height;
}

}
return “width=\”$newwidth\” height=\”$newheight\””;
}

function imageResize($width, $height,$target_width,$target_height) {
if($height>$width)
{
if($height>$target_height)
{
$h=$target_height;
$newheight=$h;
$newwidth=($width*$newheight)/$height;
}
else
{
$newwidth=$width;
$newheight=$height;
}
}
else
{
if($width>$target_width)
{
$w=$target_width;
$newwidth=$w;
$newheight=($height/$width)*$w;

}
else
{
$newwidth=$width;
$newheight=$height;
}

}
//returns the new sizes in html image tag format…this is so you
//can plug this function inside an image tag and just get the
return “width=\”$newwidth\” height=\”$newheight\””;
}

function actionButtons($buttons,$blockname)
{
$butt=”;
foreach($buttons as $button=>$url)
{
$butt.=”“;
}
return $butt;
}
//

function actiondelButtons($delbuttons,$blockname)
{
$butt=”;
foreach($delbuttons as $delbutton=>$url)
{
$butt.=”“;
}
return $butt;
}

//
function actiondelButtonsall($delbuttonsall,$blockname)
{
$butt=”;
foreach($delbuttonsall as $delbutton=>$url)
{
$butt.=”“;
}
return $butt;
}
//
//
function showTitle($name, $id)
{
if($id==”)
{
return “Add “.$name;
}
else
{
return “Edit “.$name;
}
}
function imageUploader($image,$path)
{
$file_temp_name=$_FILES[$image][‘tmp_name’];
if(is_uploaded_file($file_temp_name))
{
$file_name=$_FILES[$image][‘name’];
$file_name=date(‘U’).$file_name;
$file_path=$path.”/”.$file_name;
copy($file_temp_name,$file_path);
}
return $file_name;
}
include_once ‘site-functions.php’;
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: