ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd ' . "\r\n"; ini_set("sendmail_from", ""); if(mail($to, $subject, $content, $headers)) { return true; }else{ return false; } } function valPhone($phone){ $phone = str_replace(' ','',$phone); if(strlen($phone)==10){ $first_char = substr($phone,0,1); if(!($first_char=="0")){ return false; }else if(!ctype_digit($phone)){ return false; }else{ return true; } }else if(strlen($phone)==13){ $country_code = substr($phone,0,4); $other_parts = explode("+233",$phone); if(!($country_code=="+233")){ return false; }else if(!ctype_digit($other_parts[1])){ return false; }else if(!(strlen($other_parts[1])==9)){ return false; }else{ return true; } }else if(strlen($phone)==14){ $country_code = substr($phone,0,5); $other_parts = explode("00233",$phone); if(!($country_code=="00233")){ return false; }else if(!ctype_digit($other_parts[1])){ return false; }else if(!(strlen($other_parts[1])==9)){ return false; }else{ return true; } }else{ return false; } } function db_phone_format($phone){ $phone = str_replace(' ','',$phone); if(strlen($phone)==10){ $phone = "+233".substr($phone,1,10); }else if(strlen($phone)==13){ $phone = $phone; }else if(strlen($phone)==14){ $other_parts = explode("00233",$phone); $phone = "+233".$other_parts[1]; } return $phone; } function valFloat($value){ if(is_numeric($value)){ return true; }else{ return false; } } function valInt($value){ if(!ctype_digit($value)){ return false; }else{ return true; } } function encryptPassword($password) { return sha1(sha1(md5(md5($password)))); } function controlpanel_timeout(){ return "3600000"; } function username($fn,$ln){ return ucfirst(strtolower($fn))." ".ucfirst(strtolower($ln)); } function plural($count){ if($count>1){ return "s"; }else{ return ""; } } function validatePassword($password) { /*/Password length must be greater than 10 for security reasons*/ if(strlen($password)<4) { return false; } else { return true; } } function valusername($username){ /* Must be either numbers, letters or mixed and not less than 4 characters */ if(strlen($username)<4){ return false; }else if(!ctype_alnum($username)){ return false; }else if(strlen($username)>28){ return false; }else{ return true; } /* if ( !preg_match('/^[a-z0-9][a-z0-9_]{3,28}[a-z0-9]$/', $username) ){ return false; }else{ return true; } */ } function validateDate($date) { /*/split the date to check if all are numbers */ $atoms = explode('-',$date); $day = $atoms[2]; $month = $atoms[1]; $year = $atoms[0]; if((is_numeric($day))&&(is_numeric($month))&&(is_numeric($year))) { if (checkdate($month, $day, $year)) { return true; } else { return false; } } else { return false; } } function shortenwords($string,$length) { $truncated = (strlen($string) > $length) ? substr($string, 0, $length) . '...' : $string; return $truncated; } function sanitize($text) { /*$text = htmlspecialchars($text, ENT_QUOTES);*/ $text = str_replace("\n\r","\n",$text); $text = str_replace("\r\n","\n",$text); $text = str_replace("\n","
",$text); return $text; } function _make_url_clickable_cb($matches) { $ret = ''; $url = $matches[2]; if ( empty($url) ) return $matches[0]; // removed trailing [.,;:] from URL if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($url, -1); $url = substr($url, 0, strlen($url)-1); } return $matches[1] . "$url" . $ret; } function _make_web_ftp_clickable_cb($matches) { $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; if ( empty($dest) ) return $matches[0]; // removed trailing [,;:] from URL if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) { $ret = substr($dest, -1); $dest = substr($dest, 0, strlen($dest)-1); } return $matches[1] . "$dest" . $ret; } function _make_email_clickable_cb($matches) { $email = $matches[2] . '@' . $matches[3]; return $matches[1] . "$email"; } function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster $ret = preg_replace_callback('#([\s>])([\w]+?://[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]*)#is', '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links $ret = preg_replace("#(]+?>|>))]+?>([^>]+?)#i", "$1$3", $ret); $ret = trim($ret); return $ret; } function unsanitize($text){ return strip_tags($text); } function optionSelected($comp,$value){ if($comp==$value){ return "selected"; }else{ return ""; } } function option_checked($comp,$value){ if($comp==$value){ return "checked"; }else{ return ""; } } function is_checked($comp,$value){ if($comp==$value){ return correct_mark(); }else{ return ""; } } function generateToken() { $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 0; $i < 20; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); //turn the array into a string } function generateShortToken() { $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 0; $i < 10; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); //turn the array into a string } function generateLongToken(){ $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 0; $i < 40; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); //turn the array into a string } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } function slugify($string){ /*$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string); return $slug;*/ $slug = trim($string); /* trim the string */ $slug= preg_replace('/[^a-zA-Z0-9 -]/','',$slug ); /* only take alphanumerical characters, but keep the spaces and dashes too... */ $slug= str_replace(' ','-', $slug); /* replace spaces by dashes */ $slug= strtolower($slug); /* make it lowercase */ return $slug; } function url_slug($url){ $path = parse_url($url, PHP_URL_PATH); $pathFragments = explode('/', $path); $end = end($pathFragments); return $end; } function get_url_slug(){ $url = $_SERVER['REQUEST_URI']; $slug = url_slug($url); return $slug; } function create_folder($name){ /* create the folder and return the name of the folder */ $folder_ok = 0; $attempt = 0; $folder = ""; while($folder_ok==0){ if($attempt==0){ $slug = slugify(trim($name)); }else{ $slug = slugify(trim($name))."-".$attempt; } $folder = strtolower($slug); $path = dirname(__FILE__)."/{$folder}/"; if (!is_dir($path)) { if(mkdir($path, 0777)){ $folder_ok = 1; } } $attempt++; } return $folder; } function deleteDir($dirPath) { if (! is_dir($dirPath)) { /*throw new InvalidArgumentException("$dirPath must be a directory");*/ } if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } $files = glob($dirPath . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file)) { deleteDir($file); } else { unlink($file); } } rmdir($dirPath); } function page_not_found(){ return "

The requested page can not be found

"; } function correct_mark(){ return "✔"; } function wrong_mark(){ return "✖"; } function has_dupes($array) { $duplicate = 0; $container = array(); for($i=0;$i0){ return true; }else{ return false; } } function gen_digits($digits){ return str_pad(rand(0,pow(10,$digits)-1),$digits,'0',STR_PAD_LEFT); } function last_digit_number($digits,$digit){ return substr($digits, -$digit); } function first_n_letters($string,$n){ return substr($string,0,$n); } function remove_empty_space($string){ $string = preg_replace('/\s+/', '', $string); return $string; } function modifyUrl($website){ $url = ""; if ((strpos($website,'http://') === false)&&(strpos($website,'https://') === false)){ $url= 'http://'.$website; }else{ $url = $website; } return $url; } function is_valid_url($url){ if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { return false; }else{ return true; } } function url_exists($url) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_NOBODY, true); $result = curl_exec($curl); if ($result !== false) { $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($statusCode == 404) { return false; } else { return true; } }else{ return false; } } function logo_url($logo){ return "http://kuulchatmedia.com/clap/pics/".$logo; } function pic_url($pic){ return "http://kuulchatmedia.com/clap/pics/".$pic; } function cv_url($cv){ return "http://kuulchatmedia.com/cvs/".$cv; } function newsfeed_link($image){ return "http://closeapp.kuulchatmedia.com/newsfeed/".$image; } function business_image_url($image){ return "http://kuulchatmedia.com/company/businesses/".$image; } function ad_image($image){ return "http://kuulchatmedia.com/ads/".$image; } function offer_image_link($image){ return "http://kuulchatmedia.com/closeapp/offers/".$image; } function announcement_imageUrl($image){ return "http://kuulchatmedia.com/announcements/".$image; } function help_imageUrl($image){ return "http://kuulchatmedia.com/help/".$image; } function business_corner_imageUrl($image){ return "http://kuulchatmedia.com/company/businesses/articles/".$image; } function formatAmount($amount) { return number_format($amount,2); } function currency() { return "GHc"; } function receipt_company_header(){ return '

Loc: Adjacent Teshie Krobor 1 Sch.
Tel: +233 20 6930 402
Website: kuulchatmedia.com

'; } function receipt_dimension(){ return 280; } function product_image_folder(){ return "products"; } function product_image($image){ return home()."/kc/".product_image_folder()."/".$image; } function staff_image_folder(){ return "staff"; } function staff_image($image){ return home()."/kc/".staff_image_folder()."/".$image; } function translate_day($day){ if($day==1){ return "Monday"; }else if($day==2){ return "Tuesday"; }else if($day==3){ return "Wednesday"; }else if($day==4){ return "Thursday"; }else if($day==5){ return "Friday"; }else if($day==6){ return "Saturday"; }else if($day==7){ return "Sunday"; } } function translate_month($date){ $atoms = explode("-",$date); $month = $atoms[1]; if($month=="01"){ return "January"; }else if($month=="02"){ return "February"; }else if($month=="03"){ return "March"; }else if($month=="04"){ return "April"; }else if($month=="05"){ return "May"; }else if($month=="06"){ return "June"; }else if($month=="07"){ return "July"; }else if($month=="08"){ return "August"; }else if($month=="09"){ return "September"; }else if($month=="10"){ return "October"; }else if($month=="11"){ return "November"; }else if($month=="12"){ return "December"; } } function changeDateToDayMonthYear($date){ $atoms = explode("-",$date); return $atoms[2].".".$atoms[1].".".$atoms[0]; } function mytxtbox_clientId(){ return "xzuefbjm"; } function mytxtbox_secretKey(){ return "bgfjdopj"; } function mytxtbox_from(){ return "CloseApp"; } function encodeUrl($text){ return urlencode($text); } /* function sendTextMessage($to,$message){ $url = "http://api.mytxtbox.com/v3/messages/send?" . "From=".encodeUrl(mytxtbox_from()) . "&To=".encodeUrl($to) . "&Content=".encodeUrl($message) . "&ClientId=".mytxtbox_clientId() . "&ClientSecret=".mytxtbox_secretKey() . "&RegisteredDelivery=true"; Fire the request and wait for the response $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "GET", )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); } */ function sendTextMessage($to,$message){ $url = "https://smscharis.tk/api/sendSms?phone_number=".db_phone_format($to)."&message=".$message."&sender_id=".senderID()."&api_key=Z29kd2luQGFwaTokMnkkMTAkTWNPUTNMNnJvOTU2ak9Da3h3cUg0LnRoVjAva0N6TlVEZHp2OGtsWDRKc09LRGJEaWR3dTI="; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "GET", )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); } function senderID(){ return "CloseApp"; } /* function sendTextMessage($to,$message){ error_reporting(E_ALL || E_NOTICE); $base = "https://smstoday.net/websms/api/v1/send.php"; $sms = array( messages => array( array( text => $message, to => db_phone_format($to) ) ), apikey => "HNMVHFLWPKF6KASPJAPQMCLD1", // your API key from => senderID(), // Your Sender ID password => "StrongPassword2019" // Your Password ); $query = "data=".urlencode(json_encode($sms)); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $base); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS,$query); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec ($ch); curl_close ($ch); if($server_output){ // Json response $json = json_decode($server_output,true); /*print_r($json);*/ /* output - on success RESPONSE_CODE 200 will return Array ( [RESPONSE_TYPE] => Queue successful [RESPONSE_CODE] => 200 [GROUP_QUE_ID] => 1510559593 [QUE_COUNT] => 0 [BALANCE] => 330 ) } else { } } */ function sendPushData($to,$data,$priority){ // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AAAAqOv0K7E:APA91bF2iuXb2A8DBUTak0f779Bt4WECS5FRHUsvg-M21rETlCxQ7ycmkx9ZpYmpTexYk0PK0KxC-kNmgjJ2TvVjRr1ICL2S_bH-vkJE3vbZUEnQd7yV-SZxDZ18ByJ8VcW3fccRLLyz' ); // prep the bundle $fields = array ( 'to' => $to, "priority"=>$priority, 'data' => $data ); $headers = array ( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); /*echo $result;*/ } function sendPushDataEcho($to,$data,$priority){ // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AAAAqOv0K7E:APA91bF2iuXb2A8DBUTak0f779Bt4WECS5FRHUsvg-M21rETlCxQ7ycmkx9ZpYmpTexYk0PK0KxC-kNmgjJ2TvVjRr1ICL2S_bH-vkJE3vbZUEnQd7yV-SZxDZ18ByJ8VcW3fccRLLyz' ); // prep the bundle $fields = array ( 'to' => $to, "priority"=>$priority, 'data' => $data ); $headers = array ( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result; } function sendPushDataCloseApp($to,$data,$priority){ // API access key from Google API's Console define( 'API_ACCESS_KEY', 'AAAAajIT0T0:APA91bGzKOxGBHGqFsmpt41TCnssjT9Uwg87V4lZ6jvI5dWwiPgg2rU4BLZNzZPkPoxGoU9U0Ua6bRoktFCT-7jPmOu8PKUeguY_Del2kOlc7AWzERNMwu90co-pw0I-R9q6G_NcY6rI' ); // prep the bundle $fields = array ( 'to' => $to, "priority"=>$priority, 'data' => $data ); $headers = array ( 'Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); /*echo $result;*/ } function day_of_the_week(){ $day_of_week = date('N'); return $day_of_week; } function translate_target($target){ if($target==1){ return "People nearby"; }else if($target==2){ return "The whole country"; } } function translate_status($status){ if($status==0){ return "Pending"; }else if($status==1){ return "Active"; }else if($status==2){ return "Paused"; }else if($status==3){ return "Completed"; }else if($status==4){ return "Declined"; } } function transaction_desc($type){ if($type==1){ return "Top Up"; }else if($type==2){ return "Offer Post"; }else if($type==3){ return "Offer Refund"; }else if($type==4){ return "Subscription"; }else if($type==5){ return "Advertisement"; }else if($type==6){ return "Advertisement Refund"; } } function translate_agency($agency){ if($agency==1){ return "Kuulchat Media"; }else if($agency==2){ return "Individual Application"; } } function compressImage($source, $destination, $quality) { $info = getimagesize($source); if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source); elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source); elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source); imagejpeg($image, $destination, $quality); } function image_quality($size){ if($size<81000){ return 100; }else if($size<100000){ return 70; }else if($size<150000){ return 50; }else if($size<200000){ return 40; }else{ return 25; } } ?>