?
Current Path : /home1/savoy/public_html/savoyeducation.com/Backup23-11-16/application/controllers/ |
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/controllers/admin.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?> <?php class Admin extends MY_Controller { public function __construct() { parent::MY_Controller(); $this->load->model('adminmodel'); $this->load->model('mastermodel'); $this->load->library('Fpaginate'); } function home() { $_SESSION['admin_page']='home'; $this->load->view('admin/home'); } function news($pagenum="1") { $_SESSION['admin_page']='news'; $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } $output=$this->mastermodel->getdatas('news','news_date','desc',$pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['news']=$output['results']; $this->load->view('admin/news',$data); } function contact($pagenum="1") { $_SESSION['admin_page']='contact'; $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } $output=$this->mastermodel->getdatas('contact','datetime','',$pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['registration']=$output['results']; $this->load->view('admin/contact',$data); } function gallery($pagenum="1") { $_SESSION['admin_page']='gallery'; $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } $output=$this->mastermodel->getdatas('gallery','directory_id','desc',$pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['gallery']=$output['results']; $this->load->view('admin/gallery',$data); } function folder($pagenum="1") { $_SESSION['admin_page']='folder'; $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } $output=$this->mastermodel->getdatas('directory','sort','asc',$pagenum); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['gallery']=$output['results']; $this->load->view('admin/folder',$data); } function add_gallery() { $_SESSION['admin_page']='gallery'; $this->load->library('image_moo') ; $data['upload_path'] = $upload_path = "assets/images/gallery/normal/" ; $data['destination_thumbs'] = $destination_thumbs = "assets/images/gallery/thumbs/" ; $data['large_photo_exists'] = $data['thumb_photo_exists'] = $data['error'] = NULL ; $data['thumb_width'] = "75"; $data['thumb_height'] = "75"; $data['img']['image_width']="500"; $data['img']['image_height']="500"; if (!empty($_POST['upload'])) { $config['upload_path'] = $upload_path ; $config['allowed_types']= 'gif|jpg|png|jpeg'; $config['max_size'] = '2000'; $config['max_width'] = '1025'; $config['max_height'] = '685'; $this->load->library('upload', $config); if ($this->upload->do_upload("image")) { $data['img'] = $this->upload->data(); $data['large_photo_exists'] = "<img src=\"".base_url() . $upload_path.$data['img']['file_name']."\" alt=\"Large Image\"/>"; } } elseif (!empty($_POST['upload_thumbnail'])) { $postdata = $this->mastermodel->get_post_values(); $x1 = $this->input->post('x1',TRUE) ; $y1 = $this->input->post('y1',TRUE) ; $x2 = $this->input->post('x2',TRUE) ; $y2 = $this->input->post('y2',TRUE) ; $w = $this->input->post('w',TRUE) ; $h = $this->input->post('h',TRUE) ; $file_name = $this->input->post('file_name',TRUE) ; $postdata['filename']=$file_name; if ($file_name) { $this->image_moo ->load($upload_path . $file_name) ->crop($x1,$y1,$x2,$y2) ->save($destination_thumbs . $file_name) ; $res= $this->adminmodel->add_gallery($postdata); if ($this->image_moo->errors) { $data['error'] = $this->image_moo->display_errors() ; } else { $data['thumb_photo_exists'] = "<img src=\"".base_url() . $destination_thumbs . $file_name."\" alt=\"Thumbnail Image\"/>"; $data['large_photo_exists'] = "<img src=\"".base_url() . $upload_path.$file_name."\" alt=\"Large Image\"/>"; } } redirect('admin/gallery'); } $this->load->view('admin/add_gallery',$data); } function add_folder() { $_SESSION['admin_page']='gallery'; $postdata=$this->mastermodel->get_post_values(); $path = './assets/images/gallery/folder'; if(isset($postdata['savep'])) { if(isset($_FILES['directory_image']) && $_FILES['directory_image']['name'] != "") { $_FILES["directory_image"]["name"]=date("y-m-d-H-i-s").$_FILES["directory_image"]["name"]; if (!is_file("$path/".$_FILES["directory_image"]["name"])) { (move_uploaded_file($_FILES["directory_image"]["tmp_name"],$path."/".$_FILES["directory_image"]["name"])); $postdata['directory_image']=$_FILES["directory_image"]["name"]; } } else { $postdata['directory_image']=""; } $res= $this->adminmodel->add_folder($postdata); redirect('admin/gallery'); } else $this->load->view('admin/add_folder'); } function add_news() { $_SESSION['admin_page']='news'; if(isset($_POST['savep'])) { $postdata = $this->mastermodel->get_post_values(); $path = './assets/news'; if(isset($_FILES['attach_news']) && $_FILES['attach_news']['name'] != "") { if (!is_file("$path/".$_FILES["attach_news"]["name"])) { (move_uploaded_file($_FILES["attach_news"]["tmp_name"],$path."/".$_FILES["attach_news"]["name"])); $postdata['attach_news']=$_FILES["attach_news"]["name"]; } else { echo "File already exists"; $postdata['attach_news']=''; } } else { $postdata['attach_news']=""; } $res=$this->adminmodel->add_news($postdata); redirect('admin/news'); } $this->load->view('admin/add_news'); } function update_news($id="") { $_SESSION['admin_page']='testimonial'; if(isset($_POST['savep'])) { $postdata = $this->mastermodel->get_post_values(); $path = './assets/news'; if(isset($_FILES['attach_news']) && $_FILES['attach_news']['name'] != "") { if (!is_file("$path/".$_FILES["attach_news"]["name"])) { (move_uploaded_file($_FILES["attach_news"]["tmp_name"],$path."/".$_FILES["attach_news"]["name"])); $postdata['attach_news']=$_FILES["attach_news"]["name"]; } else { echo "File already exists"; $postdata['attach_news']=''; } } else { $postdata['attach_news']=""; } $res= $this->adminmodel->update_news($postdata); redirect('admin/news'); } $data['news']=$this->mastermodel->get_data_srow('news',$id,'news_id'); $this->load->view('admin/update_news',$data); } function update_gallery($id="") { $_SESSION['admin_page']='gallery'; if(isset($_POST['savep'])) { $postdata = $this->mastermodel->get_post_values(); $res= $this->adminmodel->update_gallery($postdata); redirect('admin/gallery'); } $data['gallery']=$this->mastermodel->get_data_srow('gallery',$id,'id'); $this->load->view('admin/update_gallery',$data); } function update_folder($id='') { $_SESSION['admin_page']='gallery'; if(isset($_POST['savep'])) { $postdata = $this->mastermodel->get_post_values(); $path = './assets/images/gallery/folder'; if(isset($_FILES['directory_image']) && $_FILES['directory_image']['name'] != "") { $_FILES["directory_image"]["name"]=date("y-m-d-H-i-s").$_FILES["directory_image"]["name"]; if (!is_file("$path/".$_FILES["directory_image"]["name"])) { (move_uploaded_file($_FILES["directory_image"]["tmp_name"],$path."/".$_FILES["directory_image"]["name"])); $postdata['directory_image']=$_FILES["directory_image"]["name"]; } } else { $postdata['directory_image']=""; } $res= $this->adminmodel->update_folder($postdata); redirect('admin/folder'); } $data['folder']=$this->mastermodel->get_data_srow('directory',$id,'directory_id'); $this->load->view('admin/update_folder',$data); } function settings() { $_SESSION['admin_page']='settings'; $this->load->view('admin/settings'); } function update_password() { $_SESSION['admin_page']='settings'; $postdata = $this->mastermodel->get_post_values(); $this->adminmodel->update_password($postdata); $this->load->view('admin/settings'); } public function logout() { session_destroy(); redirect('site/login'); } function deletegallery($field,$id) { $imgdet=$this->mastermodel->get_data_srow('gallery',$id,'id'); $this->mastermodel->deletedata('gallery',$field,$id); try { $res=$this->mastermodel->deletedata('gallery',$field,$id); if($res==1) { unlink('assets/images/gallery/normal/'.$imgdet->image.''); unlink('assets/images/gallery/thumbs/'.$imgdet->image.''); } else { throw new Exception("Error"); } redirect('admin/gallery'); } catch(Exception $exception) { redirect('admin/gallery'); } } function delete($table,$field,$id,$function) { $this->mastermodel->deletedata($table,$field,$id); try { $res=$this->mastermodel->deletedata($table,$field,$id); if($res!=1) { throw new Exception("Error"); } redirect('admin/'.$function); } catch(Exception $exception) { redirect('admin/'.$function); } } } ?>