File: /home/durgeshpandey215/public_html/zeeroprice.skilladders.com/phpfunctions.php
<?
function encode($val){
return str_replace("=","86t7",base64_encode(base64_encode($val ?? "")));
}
function decode($val){
return str_replace("86t7","=",base64_decode(base64_decode($val)));
}
function truncate($string, $length, $dots = "...") {
return (strlen($string) > $length) ? substr($string, 0, $length - strlen($dots)) . $dots : $string;
}
function titlecase($strtocase){
return ucwords(strtolower($strtocase));
}
function issetvar($val){
$retval = isset($_REQUEST[$val])? $_REQUEST[$val] : "";
return $retval;
}
function showdate($val){
$retval = date('d-M-Y',strtotime($val));
return $retval;
}
function showdatetime($val){
$retval = date('d-M-Y H:i:s',strtotime($val));
return $retval;
}
function friendlyURL($str)
{
$separator = 'dash';
$lowercase = TRUE;
if ($separator == 'dash')
{
$search = '_';
$replace = '-';
}else
{
$search = '-';
$replace = '_';
}
$trans = array(
'&\#\d+?;' => '',
'&\S+?;' => '',
'\s+' => $replace,
$replace.'+' => $replace,
$replace.'$' => $replace,
'^'.$replace => $replace,
'\.+$' => ''
);
$str = mb_strtolower($str ?? '','UTF-8');
$str = strip_tags($str);
$str = preg_replace("#\/#ui",'-',$str);
foreach ($trans AS $key => $val)
{
$str = preg_replace("#".$key."#ui", $val, $str);
}
return trim(stripslashes($str));
}
// You can call the function as you like
if (!function_exists('mb_str_word_count'))
{
function mb_str_word_count($string, $limitnum) {
mb_internal_encoding( 'UTF-8');
mb_regex_encoding( 'UTF-8');
$words = mb_split('[^\x{0600}-\x{06FF}]', $string ?? '');
$pos = explode(" ",$string ?? '');
$tcnt = 0;
$printtill = "";
foreach($pos as $key=>$val){
$printtill .= $val. " ";
if($tcnt==$limitnum){ break; }
$tcnt++;
}
return $printtill;
};
}
function PointsFromMRP($cost){
if($cost<=999){ $points = 1;}
if($cost>=1000 && $cost<=2499){ $points = 2;}
if($cost>=2500 && $cost<=4999){ $points = 3;}
if($cost>=5000 && $cost<=10000){ $points = 4;}
if($cost>=10001 && $cost<=25000){ $points = 5;}
if($cost>=25001 && $cost<=50000){ $points = 5;}
if($cost>=50001 && $cost<=100000){ $points = 6;}
if($cost>=100001 && $cost<=500000){ $points = 10;}
if($cost>=500001 && $cost<=1000000){ $points = 25;}
return $points;
}
function costofPoints($pointsval){
$costofPoints = $pointsval*1;
return $costofPoints;
}
function finalcost($cost){
return round($cost);
//return round($cost+($cost*COMMISSION/100));
}
function currSign($curr){
$currSign = "$";
if($curr=="INR"){ $currSign="₹"; }
return $currSign;
}
function sendemail($toemailid,$subjecttosend,$messagetosent,$sendtoname,$successmesage=""){
require_once 'class.phpmailer.php';
$to=$toemailid; //1st Parameter
$subject = $subjecttosend; //2nd Parameter
$message = '<br/>'.$messagetosent; //3rd Parameter
// Send mail
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
// SMTP Configuration
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.zeeroprice.com"; // SMTP server
$mail->Username = "info@zeeroprice.com";
$mail->Password = "Info123$";
$mail->Port = 25; // optional if you don't want to use the default
//$mail->Port = 587; // optional if you don't want to use the default
$mail->From = "info@zeeroprice.com";
$mail->FromName = "Info";
$mail->Subject = $subject;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML("<br /><br />" . $message);
// Add as many as you want
$mail->AddAddress($to, $sendtoname);
// If you want to attach a file, relative path to it
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
$response= NULL;
if(!$mail->Send()) {
$response = "Mailer Error: " . $mail->ErrorInfo;
$_SESSION['msg'] = $response. "<br/>Cannot send email to your email address<br/>";
} else {
$response = "Message sent!";
$_SESSION['msg'] = ($successmesage)? $successmesage:$response;
}
}
?>