?
Current Path : /home1/savoy/public_html/savoyglobal.net/koolkids/school/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/savoyglobal.net/koolkids/school/application/controllers/document.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Document extends BaseController { function __construct() { parent::BaseController(); $this->load->model('documentmodel'); $this->load->model('mastermodel'); $this->load->model('settingsmodel'); $this->load->library('Fpaginate'); } function get_post_values() { $data = array(); foreach ($_POST as $key => $value) { if($key != "submit") { $data[$key] = $this->input->post($key); } } return $data; } function viewindocument($modelfunction,$page,$pagenum,$parent_id="") { /*<---------------- For pagination purpose------------>*/ $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],0); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; } else { $data['id']= (($pagenum-1)*$perpage)+1; } $_SESSION['searchdata'] = ''; /*<---------------- For pagination purpose------------> */ if(isset($encoded_data)) { $decoded_data= urldecode($encoded_data); $postdata=json_decode($decoded_data, true); } else { $postdata=""; } $output=$this->documentmodel->$modelfunction($postdata,$pagenum,$parent_id); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['parent_id']=$output['parent_id']; $data['viewinfo']=$output['results']; $this->load->view('Document/'.$page.'',$data); } } function viewindocumentsearch($modelfunction,$page,$pagenum,$parent_id="") { /*<---------------- For pagination purpose------------>*/ $perpage= $this->config->item('perpage'); $data['pagenum']=$pagenum; if($pagenum==1) { $data['id']=1; $postdata=$this->get_post_values(); $_SESSION['searchdata']=$postdata; } else { $data['id']= (($pagenum-1)*$perpage)+1; } /*<---------------- For pagination purpose------------> */ $_SESSION['searchdata']=$postdata; if(!isset($_SESSION['searchdata'])) $_SESSION['searchdata']=""; $output=$this->documentmodel->$modelfunction($postdata,$pagenum,$parent_id); $data['startpage']=$output['startpage']; $data['endpage']=$output['endpage']; $data['parent_id']=$output['parent_id']; $data['viewinfo']=$output['results']; $this->load->view('Document/'.$page.'',$data); } function addindocument($modelfunction,$page) { $postdata=$this->get_post_values(); if(isset($postdata['to_upload'])) { $path = './school/uploads/'; $tracepath=$this->documentmodel->tracepath($postdata['parent_id']); $path=$path.$tracepath['plocation']; if (!is_file("$path/".$_FILES["upload_file"]["name"])) { if (!(move_uploaded_file($_FILES["upload_file"]["tmp_name"],$path."/".$_FILES["upload_file"]["name"]))) { $data['res']=0; $data['resfunction']='searchdocument'; } else { $postdata['file_name']=$path."/".$_FILES["upload_file"]["name"]; $data=$this->documentmodel->$modelfunction($postdata); } } else { echo "File already exists"; } } else if(isset($postdata['create_dir'])) { $path = './school/uploads/'; $tracepath=$this->documentmodel->tracepath($postdata['parent_id']); $path=$path.$tracepath['plocation']; if ($postdata['directory_name'] !== false && preg_match('~([^A-Z0-9]+)~i', $postdata['directory_name'], $matches) === 0) { if (!is_dir($path.$postdata['directory_name'])) { if (mkdir($path . $postdata['directory_name'], 0777)) { chmod($path . $postdata['directory_name'], 0777); $data=$this->documentmodel->$modelfunction($postdata); } else { $error = "Directory {$postdata['directory_name']} already exists."; //echo $error; $data['res']=0; $data['resfunction']='searchdocument'; } } else { $postdata['directory_name'] = htmlentities($postdata['directory_name']); $error = "You have invalid values in {$postdata['directory_name']}."; //echo $error; $data['res']=0; $data['resfunction']='searchdocument'; } } else { $error = "Premission Denied"; //echo $error; $data['res']=0; $data['resfunction']='searchdocument'; } } else { $data=$this->documentmodel->$modelfunction($postdata); } if($data['res']==1) { if($data['resfunction']=='searchdocument') { $this->viewindocument($data['resfunction'],$page,'1',$data['parent_id']); } else { $this->viewindocument($data['resfunction'],$page,'1'); } $this->load->view('insertsuccess'); } else { $this->viewindocument($data['resfunction'],$page,'1'); $this->load->view('insertfailure'); } } function editform($controllerfunction,$id) { $perm=$this->mastermodel->check_user_permission($_SESSION['current_mode'], $_SESSION['userid'],1); if(!$perm) { $this->load->view('Settings/nopermission'); } else { $this->$controllerfunction($id); } } function adddocument($id) { $data['parent_id']=$id; $this->load->view('Document/adddocument',$data); } function editdocument($id) { $data['document']=$this->mastermodel->get_data_srow('directory',$id,'directory_id'); $this->load->view('Document/editdocument',$data); } function uploaddocument($id) { $data['parent_id']=$id; $this->load->view('Document/uploaddocument',$data); } function singledocument($id) { $data['document']=$this->mastermodel->get_data_srow('directory',$id,'directory_id'); $data['document_file']=$this->mastermodel->get_data_srow('directory_file',$id,'directory_id'); $this->load->view('Document/singledocument',$data); } }