đ WebAdmin FileManager
Linux 5.15.0-187-generic
PHP 8.3.33
/ Root
/
var
/
www
/
vhosts
/
nirmolakheera.com
/
httpdocs
/
app
/
Controllers
đ Files
đ¤ Upload
â New
âšī¸ Info
âŦī¸ Up
âī¸ Editing: Sikhism.php
â Back
<?php namespace App\Controllers; // use App\Controllers\frontend\Blog; use App\Models\Addressmodel; use App\Models\BlogsModel; use App\Models\Bulkmediamodel; use App\Models\Eventsmodel; use App\Models\File; use App\Models\LoginModel; use App\Models\Mediamodel; use App\Models\NotificationModel; use App\Models\Playlistmodel; use App\Models\Product; use App\Models\Pushmodel; use App\Models\SeoTagModel; use App\Models\SliderModel; use CodeIgniter\RESTful\ResourceController; use League\Csv\Reader; class Sikhism extends ResourceController { protected Eventsmodel $eventsmodel; protected BlogsModel $blogs; protected Product $product; protected Bulkmediamodel $bulkmediamodel; protected SeoTagModel $Seotag; protected Playlistmodel $Playlistmodel; protected LoginModel $loginmodel; protected NotificationModel $Notification_model; protected Pushmodel $Pushmodel; protected Mediamodel $mediamodel; protected Addressmodel $addressmodel; protected SliderModel $slidermodel; protected $form_validation; public function __construct() { //ini_set('memory_limit', '2048M'); $this->form_validation = \Config\Services::validation(); helper(['form']); // session_start(); $session = session(); if (!$session->get('logged_in')) { redirect()->to('admin'); } if ($session->get('logged_in')) { //echo view('admin/header'); } /* if(!$this->session->get('user')){ redirect('login/index'); }*/ $this->eventsmodel = model(Eventsmodel::class); $this->blogs = model(BlogsModel::class); $this->product = model(Product::class); $this->bulkmediamodel = model(Bulkmediamodel::class); $this->Seotag = model(SeoTagModel::class); $this->Playlistmodel = model(Playlistmodel::class); $this->loginmodel = model(LoginModel::class); $this->Notification_model = model(NotificationModel::class); $this->Pushmodel = model(Pushmodel::class); $this->addressmodel = model(Addressmodel::class); $this->slidermodel = model(Slidermodel::class); $this->zip = service('zip'); } public function profile() { echo view('admin/profile.php'); } public function uploaddropboxurl() { helper(['form', 'url']); // Load form and URL helper $file = $this->request->getFile('csv_file'); if ($file->isValid() && !$file->hasMoved()) { // Move the file to a temporary location $filePath = $file->getTempName(); // Parse the CSV using League\Csv $csv = Reader::createFromPath($filePath, 'r'); $csv->setHeaderOffset(0); // Assuming the first row contains headers $csvData = $csv->getRecords(); // Get the records as an iterator $notexist = []; if (!empty($csvData)) { foreach ($csvData as $val) { $ext = 1; $ex2 = 1; $audio_name = $val['name']; // Check in event_details $audiofile = $this->Notification_model->get_data_where_selects('event_details', ['audio_url' => $audio_name], ['id']); if ($audiofile) { $this->Notification_model->update_data( ['audio_url' => $audio_name], 'event_details', ['audio_url' => $val['download_url'], 'audio_status' => 0, 'download_status' => 0] ); } else { $ext = 2; } // Check in playlist_items $audiofile = $this->Notification_model->get_data_where_selects('playlist_items', ['audiourl' => $audio_name], ['id']); if ($audiofile) { $this->Notification_model->update_data( ['audiourl' => $audio_name], 'playlist_items', ['audiourl' => $val['download_url'], 'audio_status' => 0] ); } else { $ex2 = 2; } if ($ext == 2 && $ex2 == 2) { array_push($notexist, $audio_name); } } } echo json_encode(['total' => count($notexist), 'file' => $notexist]); } else { echo json_encode(['error' => 'Invalid file upload']); } } public function index($id = '') { $data['tokens'] = $this->Pushmodel->gettoken(); $data['upcomming'] = $this->eventsmodel->getUpcomingEvent($id, 'admin'); $data['last_file_exists_chk'] = $this->Notification_model->get_data_where_selects('tbl_setting', '', 'file_chk_server', 'id', 'ASC', '1'); echo view('admin/dashboard', $data); } public function addBlog($value = '') { echo view('admin/blogs.php'); } public function addblogcontent($value = '') { $data['res'] = model(SeoTagModel::class)->getbottomcontent(); echo view('admin/blogcontent.php', $data); } public function addprivacypolicy($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/privacypolicy.php', $data); } public function addvideocontent($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/videocontent.php', $data); } public function addkeertancontent($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/keertancontent.php', $data); } public function addeventcontent($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/eventcontent.php', $data); } public function addgallerycontent($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/gallerycontent.php', $data); } public function addplaylistcontent($value = '') { $data['res'] = $this->Seotag->getbottomcontent(); echo view('admin/playlistcontent.php', $data); } public function addSlide() { echo view('admin/addSlide'); } public function viewBlog($id = '') { $data['blog'] = model(BlogsModel::class)->getRows($id, 'admin'); echo view('admin/viewblogs', $data); } public function viewProduct($id = '') { $where = "(status=0) OR (status=1)"; $data['products'] = $this->Notification_model->get_data_where_selects('tbl_products', $where, array('*'), '', '', ''); echo view('admin/viewproduct', $data); } public function getProductDataById() { $data['getProductDataById'] = $this->product->get_data_where('tbl_products', array('id' => $this->request->getPost('id'))); echo json_encode($data['getProductDataById']); } public function viewSlide() { echo view('admin/viewmainslider'); } public function viewevents($id = '') { // echo view('admin/viewevent'); $data['events'] = $this->eventsmodel->getRows($id, 'admin'); echo view('admin/viewevent', $data); } public function addevents() { echo view('admin/addevent'); } public function eventsviewmore() { $id = service('uri')->getSegment(2); $this->eventsmodel = model(Eventsmodel::class); $events['eventdetails'] = $this->eventsmodel->getRows($id, 'admin'); echo view('admin/vieweventdetails', $events); } public function eventsdata($id = "") { $this->eventsmodel = model(Eventsmodel::class); $events = $this->eventsmodel->updategetrows($id); echo json_encode($events); } public function addoldmedia($value = '') { // $data['galleryname'] = $this->bulkmediamodel->getgallery(); echo view('admin/addoldmedia'); } public function addgallery($id = '') { $data['galleryid'] = service('uri')->getSegment(2); $data['galleryname'] = $this->bulkmediamodel->getgallery(0, "admin"); echo view('admin/addgallery', $data); } public function viewgallery($value = '') { $data['gallery'] = $this->bulkmediamodel->getgallery(0, "admin"); echo view('admin/viewgallery', $data); } public function viewupdategallery($value = '') { // if(isset($_GET['id'])){ // $id = $_GET['id']; // }else{ // $id = ''; // } $id = service('uri')->getSegment(2); $data['gallery'] = $this->bulkmediamodel->getgallery($id, 'admin'); // print_r($data['gallery']); // exit; echo view('admin/updategallery', $data); } public function viewupdategalleryitem($value = '') { // if(isset($_GET['id'])){ // $id = $_GET['id']; // }else{ // $id = ''; // } $id = service('uri')->getSegment(2); $data['galleryitem'] = $this->bulkmediamodel->getgalleryitemonly($id); echo view('admin/updategalleryitem', $data); } public function gallery_item_delete($id) { // $gallery_id = $_GET['galleryid']; $item_url = $_GET['itemurl']; $itemname = explode("/", $item_url); $imgname = $itemname[count($itemname) - 1]; //unlink('C:\xampp\htdocs\hmkaur\assets\gallery\childseats.png'); $files = glob($_SERVER["DOCUMENT_ROOT"]); $folderpath = $files[0] . "/hmkaur/assets/gallery/" . $imgname; if ($id) { //delete post $delete = $this->bulkmediamodel->galleryitemdelete($id); $redirecturl = base_url('view_gallery'); echo "<script> window.alert('Delete Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } public function gallery_delete($id) { if ($id) { //delete post $delete = $this->bulkmediamodel->gallerydelete($id); $redirecturl = base_url('view_gallery'); echo "<script> window.alert('Delete Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } public function viewgalleryitems($value = '') { // if(isset($_GET['id'])){ // $data['galleryid'] = $_GET['id']; // }else{ // $data['galleryid'] = ''; // } $data = $this->bulkmediamodel->getgalleryitems(service('uri')->getSegment(2)); if (!empty($data)) { //set the response and exit $data1['Data'] = $data; } else { $data1['Data'] = []; } $data1['galleryid'] = service('uri')->getSegment(2); echo view('admin/viewgalleryitems', $data1); } public function creategallery($value = '') { echo view('admin/creategallery'); } public function galleryajax($value = '') { if ($this->request->getFileMultiple('files')) { $output = ''; $files = $this->request->getFileMultiple('files'); $uploadPath = FCPATH . 'assets/galleryimage/'; if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777, true); } foreach ($files as $index => $file) { if ($file->isValid() && !$file->hasMoved()) { $fileName = $file->getRandomName(); $defaultname = pathinfo($file->getName(), PATHINFO_FILENAME); $file->move($uploadPath, $fileName); // Resize and rotate the image if needed $this->resizeAndRotateImage($uploadPath . $fileName); $output .= ' <div class="col-md-3"> <img src="' . base_url('uploads/galleryimage/' . $fileName) . '" class="img-responsive img-thumbnail" /> <input type="hidden" name="item[' . $index . '][item_url]" value="' . $fileName . '"> <input type="hidden" name="item[' . $index . '][item_url_thumbnail]" value="' . $fileName . '"> <label>Title:</label> <input type="text" class="form-control" name="item[' . $index . '][item_name]" value="' . $defaultname . '"> <label>Alt:</label> <input type="text" class="form-control" name="item[' . $index . '][item_alt]" value="' . $defaultname . '"> </div> '; } else { $output .= '<p class="text-danger">File upload error: ' . $file->getErrorString() . '</p>'; } } echo $output; } } private function resizeAndRotateImage($filePath) { $img = \Config\Services::image() ->withFile($filePath); // Resize the image list($width, $height) = getimagesize($filePath); if ($width >= $height) { $img->resize(800, 800, true); } else { $img->resize(800, 800, true); } // Rotate the image if needed based on EXIF data $exif = exif_read_data($filePath, 'IFD0'); if ($exif && isset($exif['Orientation'])) { switch ($exif['Orientation']) { case 3: $img->rotate(180); break; case 6: $img->rotate(270); break; case 8: $img->rotate(90); break; } } // Save the modified image $img->save($filePath); } public function galleryajax_old($value = '') { sleep(3); // Mimics delay for some reason, usually for loading animations if ($this->request->getFileMultiple('files')) { $output = ''; $files = $this->request->getFileMultiple('files'); $uploadPath = FCPATH . 'uploads/gallery/'; // Ensure the upload directory exists if (!is_dir($uploadPath . 'thumbnail/')) { mkdir($uploadPath . 'thumbnail/', 0777, true); } foreach ($files as $index => $file) { if ($file->isValid() && !$file->hasMoved()) { $fileName = $file->getRandomName(); $defaultname = pathinfo($file->getName(), PATHINFO_FILENAME); // Move the uploaded file $file->move($uploadPath, $fileName); // Resize the image and create a thumbnail $this->resizeGalleryItemImage($fileName, $uploadPath); $output .= ' <div class="col-md-3"> <img src="' . base_url('uploads/gallery/thumbnail/' . $fileName) . '" class="img-responsive img-thumbnail" /> <input type="hidden" name="item[' . $index . '][item_url]" value="' . base_url('uploads/gallery/' . $fileName) . '"> <input type="hidden" name="item[' . $index . '][item_url_thumbnail]" value="' . base_url('uploads/gallery/thumbnail/' . $fileName) . '"> <label>Title:</label> <input type="text" class="form-control" name="item[' . $index . '][item_name]" value="' . $defaultname . '"> <label>Alt:</label> <input type="text" class="form-control" name="item[' . $index . '][item_alt]" value="' . $defaultname . '"> </div> '; } else { $output .= '<p class="text-danger">File upload error: ' . $file->getErrorString() . '</p>'; } } echo $output; } } // Resizes the uploaded image and creates a thumbnail private function resizeGalleryItemImage($fileName, $uploadPath) { $sourceImage = $uploadPath . $fileName; $thumbnailImage = $uploadPath . 'thumbnail/' . $fileName; $image = \Config\Services::image() ->withFile($sourceImage) ->fit(200, 200, 'center') // Creates a thumbnail of 200x200 ->save($thumbnailImage); } public function oldmediaajax() { //ini_set('memory_limit', '2024M'); // Simulate a delay //sleep(3); // Check if files are uploaded if ($this->request->getFileMultiple('files')) { $output = ''; $files = $this->request->getFileMultiple('files'); $uploadPath = FCPATH . 'assets/bulkoldaudio/'; $allowedTypes = ['mp3']; foreach ($files as $index => $file) { if ($file->isValid() && !$file->hasMoved()) { // Validate file type if (in_array($file->getExtension(), $allowedTypes)) { // Move the file to the specified directory $file->move($uploadPath); // Get the file name and generate the form inputs $fileName = $file->getName(); $defaultname = pathinfo($fileName, PATHINFO_FILENAME); $audioUrl = base_url($uploadPath . $fileName); $output .= ' <div class="col-md-3"> <input type="hidden" name="item[' . $index . '][audio_url]" value="' . $audioUrl . '"> <label>Event Title:</label> <input type="text" class="form-control" name="item[' . $index . '][event_title]" value="' . $defaultname . '" required> <label>Event Text:</label> <input type="text" class="form-control" name="item[' . $index . '][event_text]" value="" required> <label>Event Date:</label> <input type="date" class="form-control" name="item[' . $index . '][event_date]" required> <label>Youtube URL:</label> <input type="text" class="form-control" name="item[' . $index . '][video_url]"> </div>'; } } } // Output the generated HTML echo $output; } } /*<label>category:</label> <input type="text" class="form-control" name="item['.$count.'][category]">*/ public function viewkeertana($id = '') { $data['keertan'] = $this->eventsmodel->getKeertanas($id, 'admin'); echo view('admin/viewkeertans', $data); } public function viewupdatekeertana() { $id = service('uri')->getSegment(2); $data['keertan'] = $this->eventsmodel->getKeertanas($id, 'admin'); echo view('admin/updatekeertana', $data); } public function viewupdateevent() { $id = service('uri')->getSegment(2); //$data['event'] = $this->eventsmodel->geteventdata($id); $data['event'] = $this->eventsmodel->updategetrows($id); echo view('admin/updateevent', $data); } public function addcategory() { echo view('admin/addcategory'); } public function addkeertan() { $blogs = model(BlogsModel::class); $data['category'] = $blogs->getcategory(); echo view('admin/addkeertans', $data); } //To saerch event bname if added before in event_name table. public function eventnamesearch($value = '') { $query = $this->request->getGet('query'); $data = $this->eventsmodel->fetch_event_name($query); echo json_encode($data); } //To search events which happened in pass and add audio and video files public function eventsearch($value = '') { /* if($this->input->get('query')) {*/ $query = $this->request->getGet('query'); $data = $this->eventsmodel->fetch_data($query); echo json_encode($data); /*}*/ } //MPS18072019: when upload old audio/events so we fatching old events in dropdown using below code public function maineventsearch($value = '') { if ($this->request->getGet('query')) { $query = $this->request->getGet('query'); $data = $this->eventsmodel->fetch_main_event_data($query); echo json_encode($data); } } public function updateSlide() { $id = service('uri')->getSegment(2); $sliders['slide'] = $this->slidermodel->getRows($id); echo view('admin/updatemainslider', $sliders); } public function updateblog() { $id = service('uri')->getSegment(2); $blogs = model(BlogsModel::class); $Seotag = model(SeoTagModel::class); $data['blogdetails'] = $blogs->getRows($id, 'admin'); $data['allblogcategory'] = $blogs->allblogcategory(); $data['seotag'] = $Seotag->getRows($id); echo view('admin/updateblog', $data); } public function viewmedia($value = '') { $media['filedata'] = $this->mediamodel->getRows(); echo view('admin/viewmedia', $media); } public function addmedia() { $data['country'] = $this->addressmodel->fetch_country(); $blogs = model(BlogsModel::class); $data['category'] = $blogs->getcategory(); echo view('admin/addmedias', $data); // echo view('admin/addmedias'); } public function updatemedia() { $id = $_GET['id']; $media['filedata'] = $this->mediamodel->getRows($id); $media['country'] = $this->addressmodel->fetch_country(); echo view('admin/updatemedia', $media); } public function updatesocialshare() { $social['sociallinks'] = $this->Seotag->getsocialshare(1); echo view('admin/updatesocialshare', $social); } public function files($value = '') { $session = session(); // Load file model $fileModel = model(File::class); $data = array(); // If file upload form is submitted and files are present if ($this->request->getPost('submit') && $this->request->getFiles()) { $files = $this->request->getFiles(); $uploadPath = FCPATH . 'assets/blogs/image/'; $uploadData = []; // Ensure the upload directory exists if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777, true); } foreach ($files['files'] as $file) { if ($file->isValid() && !$file->hasMoved()) { $fileName = $file->getRandomName(); // Move the uploaded file to the server if ($file->move($uploadPath, $fileName)) { $uploadData[] = [ 'file_name' => $fileName, 'uploaded_on' => date("Y-m-d H:i:s"), 'file_path' => base_url('uploads/blogs/image/' . $fileName) ]; } } else { // Handle the error for invalid files $session->setFlashdata('statusMsg', 'Some files could not be uploaded. Please try again.'); } } if (!empty($uploadData)) { // Insert files data into the database $insert = $fileModel->insertData($uploadData); // Set flash data for upload status message $statusMsg = $insert ? 'Files uploaded successfully.' : 'Some problem occurred, please try again.'; $session->setFlashdata('statusMsg', $statusMsg); } } // Get files data from the database $data['files'] = $fileModel->getRows(); echo "<pre>"; print_r($data); // Pass the files data to view // return view('upload_files/index', $data); } public function createplaylist($value = '') { echo view('admin/createplaylist'); } /*added by ag-12-05-2020*/ public function createsubplaylist($value = '') { // if(isset($_GET['id'])){ // $data['playlistid'] = $_GET['id']; // }else{ // $data['playlistid'] = ''; // } $data['playlistid'] = service('uri')->getSegment(2); echo view('admin/createsubplaylist', $data); } // public function viewplaylist($value='') // { // $data['playlist']= $this->Playlistmodel->getplaylist($id,'admin'); // echo view('admin/viewplaylist',$data); // } public function viewplaylist($value = '') { $data['playlist'] = $this->Playlistmodel->getplaylistdrag(0, 'admin'); echo view('admin/viewplaylist', $data); } public function ajaxdata() { $position = $this->request->getPost('position'); $this->Playlistmodel->ajaxdrag($position); } public function playlist_delete($id) { if ($id) { //delete post $delete = $this->Playlistmodel->playlistdelete($id); $redirecturl = base_url('view_playlist'); echo "<script> window.alert('Delete Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } public function subplaylist_delete($id) { if ($id) { //delete post $delete = $this->Playlistmodel->subplaylistdelete($id); $redirecturl = base_url('viewsubplaylist'); echo "<script> window.alert('Delete Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } public function updatesubplaylist($value = '') { // if(isset($_GET['id'])){ // $id = $_GET['id']; // }else{ // $id = ''; // } $id = service('uri')->getSegment(2); $data['subplaylist'] = $this->Playlistmodel->getsubplaylistbyid($id); echo view('admin/updatesubplaylist', $data); } public function viewupdateplaylist($value = '') { // if(isset($_GET['id'])){ // $id = $_GET['id']; // }else{ // $id = ''; // } $id = service('uri')->getSegment(2); $data['playlist'] = $this->Playlistmodel->getplaylist($id, 'admin'); echo view('admin/updateplaylist', $data); } /*added by ag-12-05-2020*/ public function viewsubplaylist($value = '') { if (isset($_GET['id'])) { $data['playlistid'] = $_GET['id']; } else { $data['playlistid'] = ''; } echo view('admin/viewsubplaylist', $data); } public function viewallplaylistitems($value = '') { // if(isset($_GET['id'])){ // $data['playlistid'] = $_GET['id']; // }else{ // $data['playlistid'] = ''; // } $data['playlistid'] = service('uri')->getSegment(2); $data['Data'] = $this->eventsmodel->fetchKeertnFilters(); $data['Data2'] = $this->Playlistmodel->getsubplaylist($data['playlistid']); echo view('admin/viewallplaylistitems', $data); } public function viewplaylistitems($value = '') { // if(isset($_GET['id'])){ // $data['playlistid'] = $_GET['id']; // }else{ // $data['playlistid'] = ''; // } $data['HTTP_REFERER'] = $this->request->getHeaderLine('Referer'); $data['playlistid'] = service('uri')->getSegment(2); $data['Data'] = $this->eventsmodel->fetchKeertnFilters(); $data['Data2'] = json_decode(file_get_contents(base_url('api/Playlist/playlistitems/' . $data['playlistid'] . '')), true); echo view('admin/viewplaylistitems', $data); } public function profile_data() { echo view('admin/admin_profile'); } public function changePass($id = '') { helper(['security', 'form']); $form_validation = \Config\Services::validation(); $form_validation->setRule('newpwd', 'Password:', 'required|trim'); $form_validation->setRule('cpwd', 'Confirm Password:', 'required|trim|matches[newpwd]'); if ($form_validation->run($_POST) == true) { $old_pass = $this->request->getPost('oldpwd'); $new_pass = md5($this->request->getPost('newpwd')); $confirm_pass = $this->request->getPost('cpwd'); $session_id = $this->request->getPost('id'); if ($new_pass != '') { $this->loginmodel->changepass($session_id, $new_pass); $redirecturl = base_url('Profile'); echo "<script> window.alert('Password Updated Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } else { echo view('admin/admin_profile'); } } public function joinus() { $content['Data'] = $this->Seotag->get_joinus(); echo view('admin/addjoinus', $content); } public function setjoinuspost() { $inputdata = $this->request->getPost(); unset($inputdata['submit']); $insert = false; if (!empty($inputdata['joinus_name'])) { $insert = $this->Seotag->insert_joinus($inputdata); } if ($insert) { $redirecturl = base_url('join_us'); echo "<script> window.alert('Insert Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; // $this->_flashAndRedirect( // $insert, // "Data Added Successfully.", // "Data Insert Failed.",$redirect // ); } else { $redirecturl = base_url('join_us'); $msg = "Please fill options name."; echo "<script> alert('$msg')</script>"; echo "<script> window.location.href= '$redirecturl' </script>"; // echo "<script> window.alert('Insert Successfully.'); </script>"; // echo "<script> window.location.href= '$redirecturl' </script>"; // $redirect = base_url('join_us'); // $this->_flashAndRedirect( // $insert, // "Data Added Successfully.", // "Data Insert Failed.",$redirect // ); } } private function _flashAndRedirect($successful, $successmsg, $failuremsg, $redirect) { $session = session(); if ($successful) { $session->setFlashdata('feedback', $successmsg); $session->setFlashdata('feedback_class', 'alert-success'); } else { $session->setFlashdata('feedback', $failuremsg); $session->setFlashdata('feedback_class', 'alert-danger'); } //$pageurl = strtolower($post['usertype']); //return redirect('admin/'.$pageurl.'home'); return redirect($redirect); } public function custom_notification($value = '') { $data['notification'] = $this->Notification_model->getnotification(0, "admin"); echo view('admin/custom_notification', $data); } public function add_notification() { echo view('admin/create_notification'); } public function viewupdatenotification($value = '') { $id = service('uri')->getSegment(2); $data['notification'] = $this->Notification_model->getnotification($id, 'admin'); echo view('admin/updatenotification', $data); } public function notification_delete($id) { if ($id) { //delete post $delete = $this->Notification_model->notificationdelete($id); $redirecturl = base_url('notifications'); echo "<script> window.alert('Delete Successfully.'); </script>"; echo "<script> window.location.href= '$redirecturl' </script>"; } } public function users() { // echo 1; exit; $id = ''; $data['users'] = $this->bulkmediamodel->getusers($id, "admin"); echo view('admin/viewusers', $data); } public function syncevents() { $data = $this->Playlistmodel->title_playlist_model("admin"); $au = array(); foreach ($data as $rw) { if (file_exists(FCPATH . 'assets/bulkoldaudio/' . $rw['audio_url'])) { array_push($au, $rw['id']); } } print_r(count($data)); echo '<br>'; print_r(count($au)); echo '<pre>'; print_r($au); exit; } public function downloadGenerateCheck() { //$allids = explode(",",$_POST['exportids']); $path = 'assets/bulkAudio.txt'; $handle = fopen($path, 'w'); fwrite($handle, $_POST['exportids']); fclose($handle); echo 1; exit; } public function downloadGeneratedData() { $filePath = FCPATH . 'uploads/bulkAudio.txt'; $baseURL = "http://www.staging.nirmolakheera.com/"; $audioPath = 'assets/bulkoldaudio/'; $zipFileName = 'abcd.zip'; // Check if the file exists if (!file_exists($filePath)) { return $this->response->setStatusCode(404)->setBody('File not found.'); } // Read file content $setids = file_get_contents($filePath); if (empty($setids)) { return $this->response->setStatusCode(404)->setBody('No data available.'); } // Load the ZipArchive class $zip = new \ZipArchive(); $tempZipPath = tempnam(sys_get_temp_dir(), $zipFileName); if ($zip->open($tempZipPath, \ZipArchive::CREATE) !== true) { return $this->response->setStatusCode(500)->setBody('Could not create ZIP file.'); } // Process each ID and fetch corresponding audio files $arr = explode(',', $setids); foreach ($arr as $val) { $audio = $this->eventsmodel->fetch_keertn_audios($val); if ($audio && !empty($audio[0]['audio_url'])) { $file = $audioPath . $audio[0]['audio_url']; // Check if the file exists before adding to the zip if (file_exists($file)) { $zip->addFile($file, basename($file)); } else { return $this->response->setStatusCode(404)->setBody('File does not exist: ' . $file); } } } // Close the ZIP archive $zip->close(); // Send the zip file as a download response return $this->response->download($tempZipPath, null)->setFileName($zipFileName)->setContentType('application/zip'); } /* public function downloadGeneratedData(){ //$path = 'assets/bulkAudio.txt'; //readfile($path); $setids = ''; $myfile = fopen("assets/bulkAudio.txt", "r"); if($myfile){ $setids = fread($myfile,filesize("assets/bulkAudio.txt")); $url$url fclose($myfile); } if($setids!=''){ $arr = explode(",",$setids); foreach($arr as $val){ $audio = $this->eventsmodel->fetch_keertn_audios($val); if($audio){ if($audio[0]['audio_url']!=''){ $audiname = $audio[0]['audio_url']; $base = "http://www.staging.nirmolakheera.com/"; $path = "assets/bulkoldaudio/"; $file = $path.$audio[0]['audio_url']; $url = $base.$file; $file_name = basename($file); if(file_exists($file)){ //readfile($file); header("Cache-Control: private"); header("Content-type: audio/mp3"); header("Content-Transfer-Encoding: binary"); header("Content-Disposition: attachment; filename=".$audiname); //So the browser can display the download progress header("Content-Length: ".filesize($file)); readfile($file); } } } } } } */ }
âī¸ Rename Item
Original:
Cancel
Rename