?
Current Path : /home1/savoy/www/savoyglobal.net/talentquest2013/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/www/savoyglobal.net/talentquest2013/application/models/mastermodel.php |
<?php class Mastermodel extends CI_Model { function __construct() { parent::__construct(); } function htmlmail($subject,$content) { $this->mail->send($content, $subject,'info@savoyglobal.net','Savoy Global Talent Quest 2013','sherinsavoy','smtp.gmail.com',1); } 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); //echo $this->db->last_query(); 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_data1($table,$id,$field,$sortfield="") { $data = array(); $this->db->where($field,$id); if(!empty($sortfield)) { $this->db->order_by($sortfield,'asc'); } $Q= $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); 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,$sortfield="") { $data = array(); $this->db->where($field,$id); if(!empty($sortfield)) { $this->db->order_by($sortfield,'asc'); } $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['q1_fullName1']['first']." ".$postdata['q1_fullName1']['last']; $organization = $postdata['q7_organization']; $contact_no = $postdata['q3_phoneNumber3']['area'].$postdata['q3_phoneNumber3']['phone']; $email = $postdata['q4_email4']; $website = $postdata['q5_website']; $comments = $postdata['q6_comments']; $tbl1Values=array('name'=>$name, 'organization'=>$organization, 'contact_no'=>$contact_no, 'email'=>$email, 'website'=>$website, 'reference'=>$comments, 'datetime'=>date("Y-m-d H:i:s")); $this->db->insert('contact', $tbl1Values); $content='<table> <tr><td colspan="2">Talent Quest Website contact form was submitted with the following information:</td></tr> <tr><td>Name :</td><td>'.$name.'</td></tr> <tr><td>Organization:</td><td>'.$organization.'</td></tr> <tr><td>Contact No:</td><td>'.$contact_no.'</td></tr> <tr><td>Email:</td><td>'.$email.'</td></tr> <tr><td>Website:</td><td>'.$website.'</td></tr> <tr><td>Comments:</td><td>'.$comments.'</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", "$organization")) {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", "$website")) {echo "$SpamErrorMessage"; exit();} if (preg_match("/http/i", "$comments")) {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); $organization = preg_replace($pattern, "", $organization); $contact_no = preg_replace($pattern, "", $contact_no); $email = preg_replace($pattern, "", $email); $website = preg_replace($pattern, "", $website); $reference = preg_replace($pattern, "", $comments); // 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); $organization = preg_replace($find, "$SpamReplaceText", $organization); $email = preg_replace($find, "$SpamReplaceText", $email); $contact_no = preg_replace($find, "$SpamReplaceText", $contact_no); $website = preg_replace($find, "$SpamReplaceText", $website); $reference = preg_replace($find, "$SpamReplaceText", $comments); // Check to see if the fields contain any content we want to ban if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($organization, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($email, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($contact_no, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($website, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} if(stristr($comments, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->mastermodel->htmlmail("Savoy Global Talent Quest 2013 Contact Form Filled",$content); $this->db->trans_commit(); $data['res']=1; return $data; } } function insert_registration($postdata) { $tbl1Values=array( 'registration_school_name'=>$postdata['school_name'], 'registration_event_id'=>$postdata['event_id'], 'contact_person'=>$postdata['contact_person'], 'contact_no'=>$postdata['contact_no'], 'contact_email'=>$postdata['contact_email'], 'datetime'=>date("Y-m-d H:i:s")); $this->db->insert('registration', $tbl1Values); $registration_id= mysql_insert_id(); $i=1; $event_name= $this->get_single_field_value('event','event_name','event_id',$postdata['event_id']); $content='<table><tr><td colspan="2">Talent Quest Website Registration for <b>'.$event_name.'</b> was submitted with the following information:</td></tr></table>'; $content.='<table><tr><td colspan="2">School Name : <b>'.$postdata['school_name'].'</b></td></tr>'; $content.='<tr><td colspan="2">Contact Person : <b>'.$postdata['contact_person'].'</b></td></tr>'; $content.='<tr><td colspan="2">Contact No : <b>'.$postdata['contact_no'].'</b></td></tr>'; $content.='<tr><td colspan="2">Email : <b>'.$postdata['contact_email'].'</b></td></tr></table>'; $content.='<table cellpadding="10" cellspacing="0" border="1"> <tr> <th>Name of Participant</th> <th>Qatar ID</th> <th>Class</th> </tr>'; while(isset($postdata['participant_name_'.$i])) { $tbl1Values=array( 'registration_id'=>$registration_id, 'participant_name'=>$postdata['participant_name_'.$i], 'participant_qatar_id'=>$postdata['participant_qatar_id_'.$i], 'participant_class'=>$postdata['participant_class_'.$i]); $this->db->insert('registration_partcipant', $tbl1Values); $content .= ' <tr><td>'.$postdata['participant_name_'.$i].'</td> <td>'.$postdata['participant_qatar_id_'.$i].'</td> <td>'.$postdata['participant_class_'.$i].'</td> </tr>'; $i++; } $content.='</table>'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->mastermodel->htmlmail("Talent Quest Website Registration for $event_name filled",$content); $this->db->trans_commit(); $data['res']=1; return $data; } } function get_data_table($table,$id,$field,$sortfield="") { $data = array(); $this->db->where($field,$id); if(!empty($sortfield)) { $this->db->order_by($sortfield,'asc'); } $Q= $this->db->get($table); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_events() { $data = array(); $this->db->order_by('event_id','asc'); $Q= $this->db->get('event'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_participants($event_id) { $data = array(); $this->db->order_by('registration_school_name','asc'); $this->db->where('registration_event_id',$event_id); $this->db->where('active','1'); $Q= $this->db->get('registration'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_single_field_value($table,$field,$condition,$value) { $data=$this->db->query("select ". $field. " from ". $table . " where ". $condition . "='". $value ."'"); $result= $data->row(); if($result) { return $result->$field; } else { return ""; } } } ?>