PATH:
home
/
dkwgdcnelloreac
/
public_html
/
library
/
Editing: common-functions.php
<?php function sendSMS($to,$msg){ $curl = curl_init(); $url = "http://speed.igrandsms.in/websms/sendsms.aspx"; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt ($curl, CURLOPT_POST, 1); $post_params = "userid=chotuonline&password=chotu247&sender=CHOTUO&mobileno=".$to."&msg=".$msg; curl_setopt ($curl, CURLOPT_POSTFIELDS, $post_params); //curl_setopt ($curl, CURLOPT_COOKIEJAR, '/tmp/sms_cookie.txt'); curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 0); curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); return $result; } function sendEmail($template, $subject, $to, $text_msg, $web_settings, $base_url, $admin_url){ $from = "Chotu Online<info@chotuonline.com>"; $vars = array('LOGO' => $admin_url.$web_settings['logo'], 'URL' => $base_url, 'WEBSITE' => $web_settings['website_name'], 'TITLE' => $subject, 'IP_ADDRESS' => get_ip(), 'MESSAGE' =>$text_msg, 'FACEBOOK' => $web_settings['facebook'], 'LINKEDIN' => $web_settings['linkedin'], 'TWITTER' => $web_settings['twitter'], 'GOOGLE' => $web_settings['google']); $message = file_get_contents($template); foreach($vars as $search => $replace){ $message = str_ireplace('{' . $search . '}', $replace, $message); } // To send the HTML mail we need to set the Content-type header. $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; if(mail($to, $subject, $message, $headers)){ return TRUE; } else { return FALSE; } } function currentURL() { $currentURL = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://"; $currentURL .= $_SERVER["SERVER_NAME"]; if($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") { $currentURL .= ":".$_SERVER["SERVER_PORT"]; } $currentURL .= $_SERVER["REQUEST_URI"]; return $currentURL; } function is_valid_email($email, $test_mx = false){ if(eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) if($test_mx) { list($username, $domain) = split("@", $email); return getmxrr($domain, $mxrecords); } else return true; else return false; } function checkUserLogin($username,$password,$role){ $parameters = array("username"=>$username,"password"=>$password,"account_type"=>$role); $get_data = $db->select($table, $columns, $where = null); return $get_data; } function randomString($length) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; } function sessionEncrypt($key){ $fp = md5('CLINISOL'.$_SERVER['HTTP_USER_AGENT'].$key); return $fp; } function currentDate(){ return date("Y-m-d"); } //Current Time function currentTime(){ return date("H:i:s"); } function redirect($page){ header('Location:'.$page); exit(); } function upload_file($file,$tmp,$folder,$allowedexts){ $ext = explode(".", $file); $extension = strtolower($ext[1]); $random_digits=rand(0000,9999); $new_file=$random_digits.$file; $path = $folder.$new_file; if(in_array($extension, $allowedexts)){ if (file_exists($path)){ $msg = array("error","File Name already exists"); } else{ move_uploaded_file($tmp,$path); $msg = array("success",$path); } } else { $msg = array("error","Invalid file"); } return $msg; } function upload_any($file,$tmp,$folder){ $random_digits=rand(0000,9999); $new_file=$random_digits.$file; $path = $folder.$new_file; if (file_exists($path)){ $msg = array("error","File Name already exists"); } else{ move_uploaded_file($tmp,$path); $msg = array("success",$path); } return $msg; } function resize_image($filename, $tmpname, $xmax, $ymax){ $ext = explode(".", $filename); $ext = $ext[count($ext)-1]; if($ext == "jpg" || $ext == "jpeg") $im = imagecreatefromjpeg($tmpname); elseif($ext == "png") $im = imagecreatefrompng($tmpname); elseif($ext == "gif") $im = imagecreatefromgif($tmpname); $x = imagesx($im); $y = imagesy($im); if($x <= $xmax && $y <= $ymax) return $im; if($x >= $y) { $newx = $xmax; $newy = $newx * $y / $x; } else { $newy = $ymax; $newx = $x / $y * $newy; } $im2 = imagecreatetruecolor($newx, $newy); imagecopyresized($im2, $im, 0, 0, 0, 0, floor($newx), floor($newy), $x, $y); return $im2; } function slug($str) { $str = strtolower(trim($str)); $str = preg_replace('/[^a-z0-9-]/', '-', $str); $str = preg_replace('/-+/', "-", $str); return $str; } function admin_protect() { if(!isset($_SESSION['userid'])){ unset($_SESSION['userid']); unset($_SESSION['username']); unset($_SESSION['email']); unset($_SESSION['name']); $msg = "logout"; $url = "index.php?msg=".$msg; header("Location: index.php"); exit(); } } function admin_logout(){ unset($_SESSION['userid']); unset($_SESSION['username']); unset($_SESSION['email']); unset($_SESSION['name']); $msg = "logout"; $url = "index.php?msg=".$msg; header("Location: index.php?"); } function convertYoutube($string) { return preg_replace( "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "<iframe src=\"//www.youtube.com/embed/$2\" allowfullscreen></iframe>", $string ); } // Curl helper function function curl_get($url) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($curl); curl_close($curl); return $return; } function convertvimeo($url,$width,$height,$disableplay=0){ $oembed_endpoint = 'http://vimeo.com/api/oembed'; // Create the URLs if($disableplay==1){ $xml_url = $oembed_endpoint . '.xml?url=' . rawurlencode($url) . '&width='.$width.'&height='.$height; } else { $xml_url = $oembed_endpoint . '.xml?url=' . rawurlencode($url) . '&width='.$width.'&height='.$height.'&autoplay=1'; } // Load in the oEmbed XML $oembed = simplexml_load_string(curl_get($xml_url)); echo html_entity_decode($oembed->html); } function getvimeothumb($url){ $oembed_endpoint = 'http://vimeo.com/api/oembed'; // Create the URLs $xml_url = $oembed_endpoint . '.xml?url=' . rawurlencode($url); // Load in the oEmbed XML $oembed = simplexml_load_string(curl_get($xml_url)); return $oembed->thumbnail_url_with_play_button; } function get_ip() { //Just get the headers if we can or else use the SERVER global if ( function_exists( 'apache_request_headers' ) ) { $headers = apache_request_headers(); } else { $headers = $_SERVER; } //Get the forwarded IP if it exists if ( array_key_exists( 'X-Forwarded-For', $headers ) && filter_var( $headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { $the_ip = $headers['X-Forwarded-For']; } elseif ( array_key_exists( 'HTTP_X_FORWARDED_FOR', $headers ) && filter_var( $headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) { $the_ip = $headers['HTTP_X_FORWARDED_FOR']; } else { $the_ip = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ); } return $the_ip; } function moneyFormatIndia($num){ $num=explode('.',$num); $dec2=(count($num)==2)?'.'.$num[1]:'.00'; $dec=(strlen($dec2)==2)?$dec2.'0':$dec2; $num = (string)$num[0]; if( strlen($num) < 4) return $num.$dec; $tail = substr($num,-3); $head = substr($num,0,-3); $head = preg_replace("/\B(?=(?:\d{2})+(?!\d))/",",",$head); return $head.",".$tail.$dec; } ?>
SAVE
CANCEL