%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php function compress_html($buffer){ ini_set("pcre.recursion_limit", "16777"); $re = '%# Collapse whitespace everywhere but in blacklisted elements. (?> # Match all whitespans other than single space. [^\S ]\s* # Either one [\t\r\n\f\v] and zero or more ws, | \s{2,} # or two or more consecutive-any-whitespace. ) # Note: The remaining regex consumes no text at all... (?= # Ensure we are not in a blacklist tag. [^<]*+ # Either zero or more non-"<" {normal*} (?: # Begin {(special normal*)*} construct < # or a < starting a non-blacklist tag. (?!/?(?:textarea|pre|script)\b) [^<]*+ # more non-"<" {normal*} )*+ # Finish "unrolling-the-loop" (?: # Begin alternation group. < # Either a blacklist start tag. (?>textarea|pre|script)\b | \z # or end of file. ) # End alternation group. ) # If we made it here, we are not in a blacklist tag. %Six'; $new_buffer = preg_replace($re, " ", $buffer); // We are going to check if processing has working if ($new_buffer === null) { $new_buffer = $buffer; } return $new_buffer; } function view($view, $data=array(), $layout="default"){ $ci =&get_instance(); $data['page_view']=$view; $data['page_title']=isset($data['page_title'])?$data['page_title']:''; $data['seo_keywords']=isset($data['seo_keywords'])?$data['seo_keywords']:''; $data['seo_description']=isset($data['seo_description'])?$data['seo_description']:''; if($layout) $html=$ci->load->view('layouts/'.$layout, $data, TRUE); else $html=$ci->load->view($view, array(), TRUE); echo compress_html($html); } function admin_view($view, $data=array(), $layout="admin_default"){ view($view, $data, $layout); } function set_flash($msg, $key='tmp_flash') { $ci =&get_instance(); $ci->session->set_flashdata($key,$msg); } function get_flash($key='tmp_flash') { $ci =&get_instance(); $msg=$ci->session->flashdata($key); return $msg; } function encrypt_text($txt) { $ci =&get_instance(); return hash_hmac('sha256', $txt, $ci->config->item('encryption_key')); } function set_error_css($errors, $class, $errMsg=TRUE, $errBdr=TRUE, $parent='') { if(is_array($errors)){ echo "<script>"; $ids=""; foreach($errors as $k=>$v){ if($v){ $ids.="$parent [name='$k'],"; } if($errMsg){ echo "jQuery('$parent [name=\"$k\"]').parent().append('<p class=\"text-danger\">$v</p>');"; } } if($ids){ $ids=substr($ids, 0, -1); if($errBdr){ echo "jQuery(\"$ids\").parent().addClass('$class');"; } } echo "</script>"; } } function trim_array($arr){ if(!$arr) {return $arr;} foreach($arr as &$v){if(!is_array($v)) {$v=trim($v);}} return $arr; } function url_encode($arg){ if(is_array($arg)){ foreach($arg as &$v){if(!is_array($v)) {$v=urlencode($v);}} } else if(is_string($arg)){$arg=urlencode($arg);} return $arg; } function url_decode($arg){ if(is_array($arg)){ foreach($arg as &$v){if(!is_array($v)) {$v=urldecode($v);}} } else if(is_string($arg)){$arg=urldecode($arg);} return $arg; } function encode($arg) { return base64_encode($arg); } function decode($arg) { return base64_decode($arg); } /** Misc **/ function set_checked($cond=FALSE) { if($cond) {echo 'checked="checked"';} } function key_val_array($arr, $key, $val) { $ar=array(); if($arr && is_array($arr)){ foreach($arr as $d){ if($key AND $d[$key]){ $ar[$d[$key]]=$d[$val]; }else{ $ar[]=$d[$val]; } } } return $ar; } function pr($data) { echo '<pre>';print_r($data);echo '</pre>'; } function short_string($string='',$len=0) { $string=strip_tags($string); $tmp=substr($string,0,$len); if(strlen($string)<=$len) { return $string; } return $tmp.((strlen($string)<=$len)?'':'...'); } function get_ext($file_name='') { return end(explode(".", $file_name)); } function append_to_filename($fn='',$appendTxt='') { $fn=str_replace(" ", "-", $fn); $ext=end(explode(".", $fn)); $n=str_replace(".".$ext,"",$fn); return $n.$appendTxt.".".$ext; } function is_blank_date($date){ $date=trim($date); if(!$date || $date=="" || $date=="0000-00-00 00:00:00" || $date=="0000-00-00") return true; } function show_date($timestamp=false,$long=false,$sufix=false) { if($timestamp) { if(!is_numeric($timestamp) && is_blank_date($timestamp)) return; if(!is_numeric($timestamp)) $timestamp=strtotime($timestamp); if($sufix) $df='dS M Y'; else $df='d M Y'; if($long) return date($df.' - h:i A',$timestamp); else return date($df,$timestamp); } } function show_time($time) { if($time && $time!='00:00:00' && $time!='0000-00-00 00:00:00'){ return date('h:i A', strtotime($time)); } return ''; } function h($data) { return htmlspecialchars($data); } function add_slash($data) { if(is_array($data)) { $inf=array(); foreach($data as $field=>$val) { if(!is_array($val)) $inf[$field]=addslashes($val); else $inf[$field]=$val; } } else $inf=addslashes($data); return $inf; } function strip_slash($data) { if(is_array($data)) { $inf=array(); foreach($data as $field=>$val) { if(!is_array($val)) $inf[$field]=stripslashes($val); else $inf[$field]=$val; } } else $inf=stripslashes($data); return $inf; } function escape_str($data, $like=FALSE) { $ci=&get_instance(); if (is_array($data)) { $inf = array(); foreach ($data as $field => $val) { if (!is_array($val)){ $inf[$field]=$ci->db->escape_str($val, $like); }else{ $inf[$field] = $val; } } } else{ $inf = $ci->db->escape_str($data, $like); } return $inf; } function is_ajax() { return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; } function get_lat_long($address) { $address = str_replace(" ","+",$address); $url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=India"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXYPORT, 3128); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $response = curl_exec($ch); curl_close($ch); $response_a = json_decode($response); $lat = $response_a->results[0]->geometry->location->lat; $long = $response_a->results[0]->geometry->location->lng; return array("Lat"=>$lat,"Long"=>$long); } function replace_special_chars($arg, $repW=0) { if(!$repW) $repW='-'; $arg=preg_replace('/[^a-zA-Z0-9_\-]/',$repW,$arg); return $arg; } function replace_slug_chars($arg, $repW=0) { if(!$repW) $repW='-'; $arg=str_replace(' & ', '-and-', $arg); $arg=str_replace(' &', '-and-', $arg); $arg=str_replace('& ', '-and-', $arg); $arg=str_replace('&', '-and-', $arg); $arg=preg_replace('/[^a-zA-Z0-9_\-]/',$repW,$arg); return strtolower($arg); } function encode_html($arg) { $arg=str_replace('<','<',$arg); return str_replace('>','>',$arg); } function encode_script($arg) { $arg=str_replace('<script>','<script>',$arg); return str_replace('</script>','</script>',$arg); } function del_file($file) { if(file_exists($file)) { unlink($file); } } function rename_exist_file($path, $file) { $file=str_replace(' ', '-', $file); if(file_exists($path.$file)) { $fn=str_replace(" ", "-", $file); $ext=end(explode(".", $fn)); $n=str_replace(".".$ext,"",$fn); $file=$n.'-'.time().".".$ext; } return $file; } function xml2array($xml) { $get = file_get_contents($xml); $array = simplexml_load_string($get); return $array; } function is_email($email) { if(filter_var($email, FILTER_VALIDATE_EMAIL)) return true; else return false; } function time_stamp($T) { if(!$T) return ''; if(!is_numeric($T) && is_blank_date($T)) return ''; if(!is_numeric($T)) $T=strtotime($T); return date('Y-m-d H:i:s', $T); } /** Paging **/ function paging_links($data, $url, $activeClass='', $sep='', $page_limit=10, $w1='', $w2='') { if(!$data) return; $start=$data['start']; $total_pages=$data['total_pages']; $cur_page=$data['cur_page']; $pages=array(); if($total_pages>1) { $qs=http_build_query($_GET); if(!empty($qs)) $qs='/?'.$qs; if(substr($url, -1, 1)=='/') $url=substr($url, 0, -1); $start=1; $end=$total_pages; if($total_pages>10) $end=$page_limit; $half = round($page_limit / 2); if ($cur_page > $half AND $total_pages > $page_limit) { $start = $cur_page - $half + 1; $end = $page_limit + $cur_page - $half; if($end>$total_pages){ $start = $total_pages - $page_limit + 1; $end=$total_pages; } } if($cur_page>1){ echo $w1.'<a href="'.$url.'/'.($cur_page-1).$qs.'"> < </a>'.$w2; } for($i=$start;$i<=$end;$i++) { if($cur_page==$i){ $link = '<a href="'.$url.'/'.$i.$qs.'" class="'.$activeClass.'">'.$i.'</a>'; }else{ $link = '<a href="'.$url.'/'.$i.$qs.'">'.$i.'</a>'; } if($cur_page==$i){ echo str_replace(">", " class='$activeClass'>", $w1).$link.$w2; }else{ echo $w1.$link.$w2; } if($sep && $i<$total_pages) echo ''.$sep.''; } if($cur_page<$total_pages){ echo $w1.'<a href="'.$url.'/'.($cur_page+1).$qs.'"> > </a>'.$w2; } } } /** **/ function del_files_from_folder($dir) { error_reporting(0); foreach(scandir($dir) as $file) { if ('.' === $file || '..' === $file) continue; if (is_dir("$dir/$file")) deleteFilesFromFolder("$dir/$file"); else unlink("$dir/$file"); } //rmdir($dir); //it will delete folders too. } function get_curl($url, $data=null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_PORT , 80); //curl_setopt($ch, CURLOPT_SSLVERSION,3); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $output = curl_exec($ch); //$info = curl_getinfo($ch); curl_close($ch); return $output; } /** Arrays Functions **/ function array_filter_value($array, $index, $value){ $newarray=array(); if(is_array($array) && count($array)>0) { foreach(array_keys($array) as $key){ $temp[$key] = $array[$key][$index]; if ($temp[$key] == $value){ $newarray[$key] = $array[$key]; } } } return $newarray; } function send_email($to, $fromname, $fromemail, $subject, $message, $file="", $smtp=FALSE) { if(!$fromname) {$fromname="Sharda Hospital";} if(!$fromemail) {$fromemail=ADMIN_EMAIL;} $CI =& get_instance(); $CI->load->library('email'); $mail=$CI->email; $mail->clear(); $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; if($smtp){ $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com"; $config['smtp_user'] = ""; $config['smtp_pass'] = ""; $config['smtp_port'] = "465"; $config['newline'] = "\r\n"; $config['crlf'] = "\r\n"; } $mail->initialize($config); $mail->from($fromemail, $fromname); $mail->to($to); $mail->reply_to('noreply@sharda.ac.in', $fromname); $mail->subject($subject); $mail->message($message); if($file){ $mail->attach($file); } return $mail->send(); } function send_email_multiple($to, $cc, $fromname, $fromemail, $subject, $message, $file="", $smtp=FALSE) { if(!$fromname) {$fromname="Sharda Hospital";} if(!$fromemail) {$fromemail=ADMIN_EMAIL;} $CI =& get_instance(); $CI->load->library('email'); $mail=$CI->email; $mail->clear(); $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; if($smtp){ $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com"; $config['smtp_user'] = ""; $config['smtp_pass'] = ""; $config['smtp_port'] = "465"; $config['newline'] = "\r\n"; $config['crlf'] = "\r\n"; } $mail->initialize($config); $mail->from($fromemail, $fromname); $mail->to($to); $mail->cc($cc); $mail->reply_to('noreply@sharda.ac.in', $fromname); $mail->subject($subject); $mail->message($message); if($file){ $mail->attach($file); } return $mail->send(); } function set_session($sname, $val) { $_SESSION[$sname]=$val; } function get_session($sname) { return isset($_SESSION[$sname])?$_SESSION[$sname]:''; } function delete_session($sname) { unset($_SESSION[$sname]); } function destroy_session($sname) { session_destroy(); } /** **/ function replace_null($arr) { if(!is_array($arr)) return $arr; foreach($arr as $k=>$v){ if((empty($v) OR is_null($v)) && $v!==0 && $v!=='0') $arr[$k]=''; } return $arr; } function currentDT(){ return date('Y-m-d H:i:s'); } function check_image_ext($filename){ $validExt=array('jpg', 'jpeg', 'png', 'gif'); $ext=get_ext($filename); if(in_array(strtolower($ext), $validExt)) return true; else return false; } function check_doc_ext($filename){ $validExt=array('pdf', 'doc', 'docx', 'xls', 'xlsx'); $ext=get_ext($filename); if(in_array(strtolower($ext), $validExt)) return true; else return false; } function ext_type($filename) { $ext=strtolower(get_ext($filename)); $type=''; if($ext=='pdf') $type='PDF'; else if($ext=='doc' OR $ext=='docx') $type='WORD'; else if($ext=='xls' OR $ext=='xlsx') $type='EXCEL'; else if(check_image_ext($filename)) $type='IMG'; return $type; } /** Push Notification **/ function push_notification($deviceToken, $message) { error_reporting(0); $deviceToken=trim($deviceToken); if(!$deviceToken) return; //$passphrase = 'push'; $passphrase = ''; //echo $deviceToken.'<br>'.$message; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'pem/dev.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); $fp = stream_socket_client( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); $body['aps'] = array( 'alert' => $message, 'sound' => 'default' ); // Encode the payload as JSON $payload = json_encode($body); // Build the binary notification $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload; // Send it to the server $result = fwrite($fp, $msg, strlen($msg)); //echo $deviceToken; if (!$result){//echo 'fail'; die; fclose($fp); return 'Message not delivered' . PHP_EOL; } else{//echo 'success'; die; fclose($fp); return 'Message successfully delivered' . PHP_EOL; } //echo json_encode($result;); fclose($fp); } function group_array($arr, $key){ $result = array(); foreach ($arr as $data) { $k = $data[$key]; if (isset($result[$k])) { $result[$k][] = $data; } else { $result[$k] = array($data); } } return $result; } function make_groups_array($arr, $key1, $key2=''){ $rs = array(); foreach ($arr as $data) { $k = $data[$key1]; if(isset($rs[$k])) { $rs[$k]['list'][]=$data; } else{ $rs[$k]['group'][$key1]=$data[$key1]; if($key2) $rs[$k]['group'][$key2]=$data[$key2]; $rs[$k]['list']=array($data); } } return $rs; } function set_validation_message_format(&$v) { $v->set_message('required', '%s is required'); $v->set_message('min_length', '%s must be %s characters long'); $v->set_message('is_unique', 'This %s already exists'); } function app_json_data($data=array(), $status="", $code="", $msg=""){ $status=$status?$status:'FALSE'; $code=$code?$code:'FAIL'; $data=$data?$data:array(); echo json_encode(array('payload'=>$data, 'status'=>$status, 'code'=>$code, 'message'=>$msg)); die; } /* * Function : getdynamicseo */ function getdynamicseo($SEOPageURL) { $row = array(); if(!empty($SEOPageURL)) { $ci=& get_instance(); $ci->load->database(); $ci->db->select('SEOTitle,SEOKeywords,SEODescription'); $ci->db->where('SEOPageURL', $SEOPageURL); $row = $ci->db->get('SH_SEO')->row(); } return $row; } function valid_password($password = '') { $password = trim($password); $regex_lowercase = '/[a-z]/'; $regex_uppercase = '/[A-Z]/'; $regex_number = '/[0-9]/'; $regex_special = '/[!@#$%^&*()\-_=+{};:,<.>ยง~]/'; if (empty($password)) { //$this->form_validation->set_message('valid_password', 'The {field} field is required.'); return FALSE; } if (preg_match_all($regex_lowercase, $password) < 1) { //$this->form_validation->set_message('valid_password', 'The {field} field must be at least one lowercase letter.'); return FALSE; } if (preg_match_all($regex_uppercase, $password) < 1) { //$this->form_validation->set_message('valid_password', 'The {field} field must be at least one uppercase letter.'); return FALSE; } if (preg_match_all($regex_number, $password) < 1) { //$this->form_validation->set_message('valid_password', 'The {field} field must have at least one number.'); return FALSE; } if (preg_match_all($regex_special, $password) < 1) { //$this->form_validation->set_message('valid_password', 'The {field} field must have at least one special character.' . ' ' . htmlentities('!@#$%^&*()\-_=+{};:,<.>ยง~')); return FALSE; } if (strlen($password) < 8) { //$this->form_validation->set_message('valid_password', 'The {field} field must be at least 8 characters in length.'); return FALSE; } if (strlen($password) > 32) { //$this->form_validation->set_message('valid_password', 'The {field} field cannot exceed 32 characters in length.'); return FALSE; } return TRUE; } ?>