Error: [$errno] $errstr"; } //set error handler set_error_handler("customError"); */ /***********************************************************************************/ /******************** GENERAL FUNCTION TO REMOVE SILGLE QUOTES**********************/ /***********************************************************************************/ var $title; var $list_spaces; var $counter,$count_cat_id; function generalfunctions(){ $this->list_spaces = ""; $this->counter = 1; $this->count_cat_id = 1; } function removeQuotes($strToChange){ $strToChange=str_replace("'","'",$strToChange); return $strToChange; } /***********************************************************************************/ /******************** REVERSE DATE FROM MYSQL TO HUMAN **********************/ /***********************************************************************************/ function nicedate($sqldate){ $ary = explode("-",$sqldate); $ary = array_reverse ($ary); $date = implode("/",$ary); return $date; } /***********************************************************************************/ /******************** GENERAL FUNCTION TO REDIRECT THE PAGES **********************/ /***********************************************************************************/ function redirect($url){ echo(""); die(); } /***********************************************************************************/ /******************** GENERAL FUNCTIONS TO GET RANDOM NUMBER **********************/ /***********************************************************************************/ /*********************************/ function assign_rand_value($num, $alphanums) { $rand_value = $alphanums[$num]; return $rand_value; } /*********************************/ function get_rand_id($length) { // ID is letters and numbers $alphanum = 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", "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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); if($length>0) { $rand_id=""; for($i=1; $i<=$length; $i++) { mt_srand((double)microtime() * 1000000); $num = mt_rand(1,62); $rand_id .= $this->assign_rand_value($num, $alphanum); } } return $rand_id; } /*********************************/ function get_rnd_iv($iv_len) { $iv = ''; while ($iv_len-- > 0) { $iv .= chr(mt_rand() & 0xff); } return $iv; } /***********************************************************************************/ /******************** GENERAL FUNCTIONS GET DATA AGAINST DB ID **********************/ /***********************************************************************************/ /*********************************/ function showValue($sql,$showfld){ $rss=mysql_query($sql) or die(mysql_error()); $show=mysql_fetch_array($rss); echo($show[$showfld]); } /***********************************************************************************/ /****** GENERAL FUNCTIONS GET DATA AGAINST DB ID for HTML EMAIL FORMATE************/ /***********************************************************************************/ /*********************************/ function showValueOnly($sql,$showfld){ $rss=mysql_query($sql) or die(mysql_error()); $show=mysql_fetch_array($rss); return $show[$showfld]; } /*********************************/ /***********************************************************************************/ /**************** GENERAL FUNCTIONS TO DYMANIC MAKE DROP DOWN **********************/ /***********************************************************************************/ function makeDropDown(){ $numargs = func_num_args(); $rs=mysql_query(func_get_arg (0)) or die(mysql_error()); while($row=mysql_fetch_array($rs,MYSQL_BOTH)){ ?> redirect($rd_sucess); } else { $this->redirect($rd_fail."?id=2&userid=".$_POST[$frm_user]); } ob_end_flush(); } function loginClient($tblname, $fld_user, $fld_pass, $frm_user, $frm_pass, $rd_sucess, $rd_fail){ ob_start(); $sql="select * from $tblname where $fld_user='".$_POST[$frm_user]."'"; $rs=mysql_query($sql) or die(mysql_error()); $row=mysql_fetch_array($rs); $pass=$_POST[$frm_pass]; if($row[$fld_pass]==($pass)){ setcookie("candidate_id",$row['candidate_id']); setcookie("email",$row['email']); $this->redirect($rd_sucess); } else { $this->redirect($rd_fail."?id=2&userid=".$_POST[$frm_user]); } ob_end_flush(); } function loginClientarch($tblname, $fld_user, $fld_pass, $frm_user, $frm_pass, $rd_sucess, $rd_fail){ ob_start(); # $sql="select * from $tblname where $fld_user='".$_POST[$frm_user]."' and is_archive ='N' ORDER BY candidate_id DESC LIMIT 1"; $sql="select * from $tblname where $fld_user='".$_POST[$frm_user]."' and is_archive ='N'"; $rs=mysql_query($sql) or die(mysql_error()); $row=mysql_fetch_array($rs); $pass=$_POST[$frm_pass]; if($row[$fld_pass]==($pass)){ setcookie("candidate_id",$row['candidate_id']); setcookie("email",$row['email']); $this->redirect($rd_sucess); } else { # $this->redirect($rd_fail."?id=2&userid=".$_POST[$frm_user]."&p1=".$_POST[$frm_pass]."&p2=".$pass); $this->redirect($rd_fail."?id=2&userid=".$_POST[$frm_user]); } ob_end_flush(); } function clientsLogin($tblname, $fld_user, $fld_pass, $frm_user, $frm_pass, $rd_sucess, $rd_fail){ ob_start(); $sql="select * from $tblname where $fld_user='".$_POST[$frm_user]."'"; $rs=mysql_query($sql) or die(mysql_error()); $row=mysql_fetch_array($rs); $pass=$_POST[$frm_pass]; if($row[$fld_pass]==($pass)){ setcookie("contact_id",$row['contact_id']); setcookie("contact_email",$row['email']); setcookie("client_id",$row['client_id']); $this->redirect($rd_sucess); } else { $this->redirect($rd_fail."?id=2&userid=".$_POST[$frm_user]); } ob_end_flush(); } /***********************************************************************************/ /**************** GENERAL FUNCTIONS Sate RTE (FOR RTE)**********************/ /***********************************************************************************/ function RTESafe($strText) { $tmpString = trim($strText); $tmpString = str_replace(chr(145), chr(39), $tmpString); $tmpString = str_replace(chr(146), chr(39), $tmpString); $tmpString = str_replace("'", "'", $tmpString); $tmpString = str_replace(chr(147), chr(34), $tmpString); $tmpString = str_replace(chr(148), chr(34), $tmpString); $tmpString = str_replace(chr(10), " ", $tmpString); $tmpString = str_replace(chr(13), " ", $tmpString); return $tmpString; } /***********************************************************************************/ /**************** GENERAL FUNCTIONS IMAGE UPLOAD **********************/ /***********************************************************************************/ function uploadImage($varName,$path) { $chk=1;$ext=0; if($_FILES[$varName]['name']!=""){ $maxSize = "104857"; $allowedExtensions = array("jpg", "JPG", "JPEG","gif","png", "rtf", "doc", "pdf"); $extension = pathinfo($_FILES[$varName]['name']); $ext=$extension['extension']; for($k=0; $k<=7; $k++){ if(strcasecmp($ext,$allowedExtensions[$k])==0){ $chk=0; break; }else { $error ="'".$extension['extension']."' Extension not allowed"; $chk=1; } } } chdir($path); if($_FILES[$varName]['name']!="" && $chk==0){ $newpath=$_FILES[$varName]['name']; $ext=substr($newpath,(strlen($newpath)-4),strlen($newpath)); $newpath=getcwd()."/".$_FILES[$varName]['name']; copy($_FILES[$varName]['tmp_name'],$newpath); $hidvar="$ext"; $picpath=$hidvar; $width = 250; $height = 190; $srcFile=getcwd()."/".$_FILES[$varName]['name']; $destFile= getcwd()."/".$_FILES[$varName]['name']; $hidvar=$_FILES[$varName]['name']; }else{ $hidvar="no.jpg"; } return $hidvar; } /***********************************************************************************/ /**************** GENERAL FUNCTIONS FILE UPLOAD *********** **********************/ /***********************************************************************************/ function uploadFile($varName,$path) { $chk=1;$ext=0; #echo "Executing upload file"; chdir($path); #echo "
Path: ",$path; #echo "
File Name: ",$_FILES[$varName]['name']; #echo "
File Type: ",$_FILES[$varName]['type']; #echo "
File error: ",$_FILES[$varName]['error']; #print_r($_FILES); if($_FILES[$varName]['name']!=""){ $newpath=$_FILES[$varName]['name']; $ext=substr($newpath,(strlen($newpath)-4),strlen($newpath)); $newpath=getcwd()."/".$_FILES[$varName]['name']; copy($_FILES[$varName]['tmp_name'],$newpath); $hidvar="$ext"; $picpath=$hidvar; $width = 250; $height = 190; $srcFile=getcwd()."/".$_FILES[$varName]['name']; $destFile= getcwd()."/".$_FILES[$varName]['name']; $fileName=$_FILES[$varName]['name']; }else{ $fileName=""; } return $fileName; } function uploadFileConcatenate($varName,$path,$concatenate) { $chk=1;$ext=0; chdir($path); if($_FILES[$varName]['name']!=""){ $newpath=$_FILES[$varName]['name']; $ext=substr($newpath,(strlen($newpath)-4),strlen($newpath)); $newpath=getcwd()."/".$concatenate.$_FILES[$varName]['name']; copy($_FILES[$varName]['tmp_name'],$newpath); $hidvar="$ext"; $picpath=$hidvar; $width = 250; $height = 190; $srcFile=getcwd()."/".$_FILES[$varName]['name']; $destFile= getcwd()."/".$_FILES[$varName]['name']; $fileName=$concatenate.$_FILES[$varName]['name']; }else{ $fileName=""; } return $fileName; } /***********************************************************************************/ /**************** GENERAL FUNCTIONS URL back **************************************/ /***********************************************************************************/ function send_back_form($url){ $vars=""; foreach($_POST as $key=>$value){ $vars.='&'.$key.'='.$value; } $this->redirect($url.$vars); die(); } /***********************************************************************************/ /*************** GENERAL FUNCTIONS RETURN ARRAY AS , SAPRITAED ************************/ /***********************************************************************************/ function getCSVarray($array,$method){ $value=""; if($method=='p'){ for($k=0;$kremoveQuotes($_POST[$array][$k]); if((count($_POST[$array])-1)!=$k) $value.=','; } } if($method=='g'){ for($k=0;$k= $dbDate){ return 1; }else { return 0; } } /***********************************************************************************/ /******** GENERAL FUNCTION TO CALCULATE THE DIFFERENCE BETWEEN TWO DATES IN DAYS ***************/ /***********************************************************************************/ function dateDiff($dformat, $endDate, $beginDate) { # Usage of gregoriantojd (mm,dd,yyyy) # This function assumes the format of the date argument is supplied as dd/mm/yyyy $date_parts1=explode($dformat, $beginDate); $date_parts2=explode($dformat, $endDate); if ($date_parts1[1]==0) { return null; } $start_date=gregoriantojd($date_parts1[1], $date_parts1[0], $date_parts1[2]); $end_date=gregoriantojd($date_parts2[1], $date_parts2[0], $date_parts2[2]); return $end_date - $start_date; } } ?>