$host="sg2plzcpnl506846.prod.sin2.secureserver.net";$userName="kiranbhor";$passWord="hY%43E&yt#8";$dbName="kiran707";@$db=mysql_pconnect($host,$userName,$passWord);mysql_select_db($dbName);?>
function linkbuild($string){
$link = strtolower(str_replace('& ','',$string));
$link = str_replace('’','',$link);
$link = str_replace('&','',$link);
$link = str_replace(',','',$link);
$link = str_replace('/','',$link);
$link = str_replace(' ','-',$link);
return $link;
}
function linkunbuild($string){
$link = ucwords(str_replace("-"," ",$string));
return $link;
}
function validate_str($vlu, $req, $min_ln, $max_ln, $typ)
{
$website_string="/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i";
$email_string="/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i";
$phone_string="(^((([0-9\-\+\(\)' ']+)(\,)?)*)$)";
$name_string="(^([a-zA-Z\-\.' ']+)$)";
$str_string="(^(([a-zA-Z0-9\-\.\/\,\+\(\)\;' '\&\#]+)*)$)";
$num_string="(^([0-9]+)$)";
$pass_ptr = '/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/';
$vlu=mysql_real_escape_string(trim($vlu));
$ret_valu='true';
if((($req==0)&&($vlu!='')) || ($req==1))
{
if((strlen($vlu)<$min_ln) || (strlen($vlu)>$max_ln))
$ret_valu='false';
switch ($typ)
{
case 'str':
if(!(preg_match($str_string, $vlu)))
$ret_valu='false';
break;
case 'name':
if(!(preg_match($name_string, $vlu)))
$ret_valu='false';
break;
case 'num':
if(!(preg_match($num_string, $vlu)))
$ret_valu='false';
break;
case 'phone':
if(!(preg_match($phone_string, $vlu)))
$ret_valu='false';
break;
case 'email':
if(!(preg_match($email_string, $vlu)))
$ret_valu='false';
break;
case 'website':
if(!(preg_match($website_string, $vlu)))
$ret_valu='false';
break;
}
}
return $ret_valu;
}
function strFrmat($string){
$string = trim($string);
$inChar=array("'");
$outChar=array("'");
$string = str_replace($inChar, $outChar, $string);
return $string;
}
function strUnFrmat($string){
$string = trim($string);
$inChar=array("'");
$outChar=array("'");
$string = str_replace($inChar, $outChar, $string);
return $string;
}
function addRecord($table, $record, $printquery = 0)
{
$k = 0;
foreach($record as $key => $val)
{
$FIELDS[$k] = "`".$key."`";
$VALUES[$k] = "'".($val)."'";
$k++;
}
$txtFIELDS= implode (',' , $FIELDS);
$txtVALUES= implode (',' , $VALUES);
$query = "insert into ".$table." (".$txtFIELDS.") values (".$txtVALUES.")";
mysql_query($query);
if ($printquery == 1) echo "
QUERY :
".$query."
";
$id=mysql_insert_id();
return $id;
}
function updateRecord($table, $record, $cond, $printquery = 0)
{
$k = 0;
foreach($record as $key => $val)
{
$UPARR[$k] = "`".$key."` = '".($val)."'";
$k++;
}
$UPTXT = implode (',' , $UPARR);
$query = "update ".$table." set ".$UPTXT." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
mysql_query($query);
}
function deleteRecord($table, $cond, $printquery = 0)
{
$query="delete from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
mysql_query($query);
}
function saveOrders($table, $ordArr, $idsArr, $printquery = 0)
{
for ($i=0; $i < sizeof($idsArr); $i++)
{
$query="update ".$table." set `order`='".$ordArr[$i]."' where id='".$idsArr[$i]."'";
mysql_query($query);
}
if ($printquery == 1) echo "
QUERY :
".$query."
";
}
function swapStatus($table, $cond, $printquery = 0)
{
$query="update ".$table." set status=abs(status-1) where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
mysql_query($query);
}
?>
function getByQuery($query, $printquery = 0)
{
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$num=mysql_num_rows($result);
for ($i=0; $i<$num; $i++)
{
$row=mysql_fetch_array($result);
$s[$i]=$row;
}
}
return $s;
}
function getAllData($table, $cond, $printquery = 0)
{
$query="select * from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$num=mysql_num_rows($result);
for ($i=0; $i<$num; $i++)
{
$row=mysql_fetch_array($result);
$s[$i]=$row;
}
}
return $s;
}
function getDataByPages($table, $cond, $page, $rpp, $printquery = 0)
{
if ($page != 1000000001)
{
$start=($page-1)* $rpp;
$query="select * from ".$table." where ".$cond." limit ".$start.", ".$rpp;
}
else
$query="select * from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$num=mysql_num_rows($result);
for ($i=0; $i<$num; $i++)
{
$row=mysql_fetch_array($result);
$s[$i]=$row;
}
}
return $s;
}
function countDataPages($table, $cond, $rpp, $field, $printquery = 0)
{
if($field=='') $field='id';
$query="select count(".$field.") from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$row=mysql_fetch_array($result);
return ceil($row[0]/$rpp);
}
}
function getDefaultOrder($table, $cond = 1, $printquery = 0)
{
$query="select max(`order`) from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$res=mysql_fetch_array($result);
return ($res[0]+1);
}
}
function getMinOrder($table, $cond = 1, $printquery = 0)
{
$query="select min(`order`) from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$res=mysql_fetch_array($result);
return ($res[0]-1);
}
}
function getDetails($table, $cond, $printquery = 0)
{
$query="select * from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$res=mysql_fetch_array($result);
return $res;
}
}
function getTitle($table, $title, $cond, $printquery = 0)
{
$query="select ".$title." from ".$table." where ".$cond;
if ($printquery == 1) echo "
QUERY :
".$query."
";
$result=mysql_query($query);
if ($result)
{
$res=mysql_fetch_array($result);
return $res;
}
}
?>
function encodeRequest($string)
{
$hex='';
for ($i=0; $i < strlen($string); $i++)
{
$hex .= dechex(ord($string[$i]));
}
return $hex;
}
function decodeRequest($hex)
{
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2)
{
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
return $string;
}
?>
function findHowLongDays($mktimeDate)
{
$now = mktime();
$diff = $now- $mktimeDate;
$diff2M = round($diff / 60);
if ($diff2M < 60) return $diff2M.' minutes';
else
{
$diff2H = round($diff2M / 60);
if ($diff2H <= 1) return '1 hour';
else if ($diff2H < 24) return $diff2H.' hours';
else
{
$diff2D = round($diff2H / 24);
if ($diff2D <= 1) return '1 day';
else if ($diff2D <= 30) return $diff2D.' days';
else return 'more than 30 days';
}
}
}
$sessionUserID = $_SESSION['login_userid'];
function addLog($action)
{
global $sessionUserID;
$logObj['x_user_id'] = $_SESSION['login_userid'];
date_default_timezone_set('UTC');
$logObj['ts'] = mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y"));
$logObj['action'] = $action;
$logObj['ip'] = $_SERVER['REMOTE_ADDR'];
addRecord('x_logs', $logObj);
}
function getYoutubeIDfromURL($url)
{
// find the video id
// links exmaples
// http://www.youtube.com/watch?v=RarVtwbrjgY
// http://www.youtube.com/watch?v=9z1LvtCdNZQ&feature=related
// http://youtu.be/9z1LvtCdNZQ
$temp = explode ('youtu.be/', $url);
if ($temp[1] != '') $id = $temp[1];
else
{
$temp = explode ('watch?v=', $url);
$temp1 = explode ('&', $temp[1]);
$id = $temp1[0];
}
return $id;
}
function substrBYwords($str, $numOfWords)
{
// for HTML Code
$replaceArr = array ('
', '
','', '', ' ' , '' , '
');
$str = str_replace ($replaceArr , ' ' , $str);
$str = strip_tags($str);
$wordsArr = explode(' ' , $str);
$totalWords = sizeof($wordsArr);
for ($i = 0; $i < min($numOfWords, $totalWords); $i++)
{
$finalRes[$i] = $wordsArr[$i];
}
$strRes = implode (' ' , $finalRes);
return $strRes;
}
function stripTxt($str, $striped)
{
return str_replace($striped , '', $str);
}
function strip_only($str, $tags, $stripContent = false) {
$content = '';
if(!is_array($tags)) {
$tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
if(end($tags) == '') array_pop($tags);
}
foreach($tags as $tag) {
if ($stripContent)
$content = '(.+'.$tag.'[^>]*>|)';
$str = preg_replace('#?'.$tag.'[^>]*>'.$content.'#is', '', $str);
}
return $str;
}
function formatData($string)
{
$string = trim($string);
$string = addslashes($string);
return $string;
}
function unFormatData($string)
{
$replaceArr = array ("\r", "\n" , "\t");
$string = str_replace ($replaceArr , ' ' , $string );
if(is_array($string))
$string = stripslashes($string[0]);
else
$string = stripslashes($string);
$string = strip_only($string, '