?
Current Path : /home1/savoy/public_html/savoyeducation.com/Backup23-11-16/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyeducation.com/Backup23-11-16/application/models/mastermodel.php |
<?php class Mastermodel extends CI_Model { function __construct() { parent::__construct(); } function htmlmail($to,$subject,$content,$from) { $theboundary = "-----" . md5(uniqid("EMAIL")); $headers = "Date: " . date("r", time()) . "\r\n" . "From: $from" . "\r\n"; $baseContentType = "multipart/mixed"; $headers .= "X-Mailer: " . "PHP-EMAIL, Samplephpcodes.com" . "\r\n" . "MIME-Version: 1.0" . "\r\n" . "Content-Type: $baseContentType; " . "boundary=\"$theboundary\"" . "\r\n" . "\r\n"; $theemailtype = "text/html"; $Charset = "iso-8859-1"; $thebody = "--$theboundary" . "\r\n" . "Content-Type: $theemailtype; charset=$Charset" . "\r\n" . "Content-Transfer-Encoding: 8bit" . "\r\n" . "\r\n" . $content . "\r\n" . "\r\n"; $thebody .= "--$theboundary--"; return mail($to, $subject, $thebody, $headers); } function getdatas($table,$sortfield="",$sorttype="asc",$pagenum="") { $data = array(); $count= $this->db->count_all_results($table); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($pagenum)) $this->db->limit($perpage, $start); if(!empty ($sortfield)) { $this->db->order_by($sortfield, $sorttype); } $data['results'] = $this->db->get($table); return $data; } function getdir() { $data = array(); $this->db->order_by('sort', 'asc'); $data = $this->db->get('directory'); return $data; } function getprogramme() { $data = array(); $this->db->where('active !=', '1'); $this->db->order_by('order', 'asc'); $data = $this->db->get('programme'); return $data; } function get_data($table,$id,$field,$sortfield="",$sorttype="asc",$pagenum="") { $data = array(); $this->db->where($field,$id); $this->db->get($table); $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; $this->db->where($field,$id); if(!empty($sortfield)) { $this->db->order_by($sortfield, $sorttype); } $data['results'] = $this->db->get($table); return $data; } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } function get_data_srow($table,$id,$field) { $data = array(); $this->db->where($field,$id); $Q= $this->db->get($table); $row=$Q->row(); return $row; } function deletedata($table,$field,$id) { $this->db->where($field,$id); $res=$this->db->delete($table); return $res; } function get_num_rows($table,$field,$value) { $this->db->where($field,$value); $Q= $this->db->get($table); return $Q->num_rows(); } function insert_contact($postdata) { $SpamCheck = "Y"; // Y or N $SpamReplaceText = "*content removed*"; $data=array(); $this->db->trans_begin(); $name = $postdata['name']; $contact_no = $postdata['contactno']; $email = $postdata['email']; $subject = $postdata['subject']; $message = $postdata['message']; $tbl1Values=array('name'=>$name, 'contact_no'=>$contact_no, 'email'=>$email, 'subject'=>$subject, 'message'=>$message, 'datetime'=>date("Y-m-d H:i:s")); $this->db->insert('contact', $tbl1Values); $content='<table> <tr><td colspan="2">SEC Website contact form was submitted with the following information:</td></tr> <tr><td>Name :</td><td>'.$name.'</td></tr> <tr><td>Contact No:</td><td>'.$contact_no.'</td></tr> <tr><td>Email:</td><td>'.$email.'</td></tr> <tr><td>Subject:</td><td>'.$subject.'</td></tr> <tr><td>Message:</td><td>'.$message.'</td></tr> </table>'; if ($SpamCheck == "Y") { // Check for Website URL's in the form input boxes as if we block website URLs from the form, // then this will stop the spammers wastignt ime sending emails if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$contact_no")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$subject")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();} // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string $name = preg_replace($pattern, "", $name); $contact_no = preg_replace($pattern, "", $contact_no); $email = preg_replace($pattern, "", $email); $subject = preg_replace($pattern, "", $subject); $message = preg_replace($pattern, "", $message); // Check for the injected headers from the spammer attempt // This will replace the injection attempt text with the string you have set in the above config section $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); $name = preg_replace($find, "$SpamReplaceText", $name); $email = preg_replace($find, "$SpamReplaceText", $email); $contact_no = preg_replace($find, "$SpamReplaceText", $contact_no); $subject = preg_replace($find, "$SpamReplaceText", $subject); $message = preg_replace($find, "$SpamReplaceText", $message); // Check to see if the fields contain any content we want to ban if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($email, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($contact_no, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->mastermodel->htmlmail("info@savoyeducation.com, jerrybabu@savoyglobal.net, sajan@savoyglobal.net","Website Contact form Filled",$content,$email); $this->db->trans_commit(); $data['res']=1; return $data; } } function getdatastable($table,$sortfield="",$sorttype="asc") { $data = array(); if(!empty ($sortfield)) { $this->db->order_by($sortfield, $sorttype); } $Q = $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function convertdatenormalformat($date) { if($date == "" || $date == "0000-00-00") { return ""; } else { $time = strtotime( $date ); return date( 'd-m-Y', $time ); } } } ?>