* @see https://codeigniter.com/userguide3/general/urls.html */ public function index(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['services'] = $this->Service_model->getAllServiceByServiceType(); $data['pageTitle'] = ''; $this->load->view('pages/home', $data); } public function booking(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; //$data['services'] = $this->Service_model->getAllServiceByServiceType(); $cleaningService = array('1'); $data['cleaningServices'] = $this->Service_model->getAllServiceByGroups($cleaningService); /*echo '
';
		print_r($data['cleaningServices']);
		echo '
';*/ $carService = array('2,3,4,5, 6,11'); $data['carServices'] = $this->Service_model->getAllServiceByGroups($carService); $helphandService = array('7'); $data['helphandServices'] = $this->Service_model->getAllServiceByGroups($helphandService); $gardenService = array('8'); $data['gardenServices'] = $this->Service_model->getAllServiceByGroups($gardenService); $houseService = array('9'); $data['houseServices'] = $this->Service_model->getAllServiceByGroups($houseService); $buildService = array('10'); $data['buildServices'] = $this->Service_model->getAllServiceByGroups($buildService); $data['serviceGroups'] = $this->Service_model->getServiceGroups(); $data['workgroups'] = $this->Group_model->getAllActiveGroups(); $data['activeWorkgroup'] = $this->Group_model->getAvailableGroup('2024-08-25', '1'); $this->load->view('pages/booking', $data); } public function booking_finished(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $this->load->view('pages/booking-finished', $data); } public function quotation_finished(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $this->load->view('pages/quotation-finished', $data); } public function water_channel(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['services'] = $this->Service_model->getAllServiceByServiceType(); $this->load->view('pages/water-channel', $data); } public function painting(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['services'] = $this->Service_model->getAllServiceByServiceType(); $this->load->view('pages/painting', $data); } public function carefree_vacation(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['services'] = $this->Service_model->getAllServiceByServiceType(); $this->load->view('pages/carefree-vacation', $data); } public function polishing(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['services'] = $this->Service_model->getAllServiceByServiceType(); $this->load->view('pages/polishing', $data); } public function ledigestilling(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['services'] = $this->Service_model->getAllServiceByServiceType(); $this->load->view('pages/ledigestilling', $data); } public function email_verification(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $this->load->model('Log_model'); $data['pageTitle'] = ''; $this->load->view('pages/email-verification', $data); } public function ajax(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $this->load->model('Group_model'); $this->load->model('Log_model'); $data['pageTitle'] = ''; if(isset($_POST['action']) && $_POST['action'] == 'calculate_service_length' && isset($_POST['service_ids'])){ if($_POST['service_ids'] != ''){ $explodedServiceIds = explode(',', $_POST['service_ids']); $totalLength = '00:00:00'; if(!empty($explodedServiceIds)){ foreach($explodedServiceIds as $explodedServiceIdItem){ $currentService = $this->Service_model->getServiceById($explodedServiceIdItem); $time = $totalLength; $time2 = $currentService->service_time; $secs = strtotime($time2)-strtotime("00:00:00"); $addedTotal = date("H:i:s",strtotime($time)+$secs); $totalLength = $addedTotal; } } echo $totalLength; } } if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimeOptions' && isset($_POST['selectedDate'])){ $results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']); $rowIndex = 1; if(is_array($results)){ foreach($results as $resultIem){ ?> Group_model->getAvailableGroup($_POST['booking_date'], $_POST['service_category']); echo $selectedGroup->group_id; } else{ echo 0; } } if(isset($_POST['action']) && $_POST['action'] == 'isTimeAvailable' && isset($_POST['selectedDate'])){ $results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength']); $timeIsAvailable = 0; if(is_array($results)){ foreach($results as $resultIem){ if(date('H:i:s', strtotime($resultIem)) == $_POST['selectedTime']){ $timeIsAvailable = 1; } } echo $timeIsAvailable; } else{ echo 0; } } if(isset($_POST['action']) && $_POST['action'] == 'getAvailableTimes' && isset($_POST['selectedDate'])){ $results = $this->Service_model->getAvailableTimes($_POST['group_id'], $_POST['selectedDate'], $_POST['servicelength'].':00'); $rowIndex = 1; if(!empty($results)){ foreach($results as $resultIem){ ?>
Group_model->getGroupById($_POST['group_id']); if(is_object($result)){ ?>
group_name;?>
User_model->getUserById($_POST['user_id']); $userArray = array( 'is_enabled' => $_POST['newValue'] ); $this->User_model->updateUser($_POST['user_id'], $userArray); $this->Log_model->addLog('change_user_status', $data['currentUser']->username.' státusza változott - '.($_POST['newValue']?'aktív':'letiltva').' állapotra', $_POST['operator']); } if(isset($_POST['action']) && $_POST['action'] == 'checkUser'){ echo $this->User_model->isUsernameAvailable($_POST['username']); } if(isset($_POST['action']) && $_POST['action'] == 'refreshLogMonitor'){ $logInfoArray = $this->Log_model->getAllLoginfo(); $logrow = ''; foreach($logInfoArray as $logInfoItem){ $logDateTime = new datetime($logInfoItem->event_datetime); $logrow .= date_format($logDateTime,"Y-m-d H:i").'  '.$logInfoItem->username.'  '.$logInfoItem->event_content.' '; } echo $logrow; } $this->load->view('pages/ajax', $data); } public function booking_process(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Service_model'); $data['pageTitle'] = ''; $data['subpage'] = ''; if(isset($_POST['sendFormCarefreeVacation'])){ $bookingArray = array( 'name' => $_POST['name'], 'address' => $_POST['address'], 'email' => $_POST['email'], 'phonenumber' => $_POST['phonenumber'], 'type_of_building' => $_POST['type_of_building'], 'blomstervanning_enebolig' => $_POST['blomstervanning_Enebolig'], 'postinntak_enebolig' => $_POST['Postinntak_Enebolig'], 'number_of_worker' => $_POST['number_of_worker'], 'user_notes' => $_POST['user_notes'] ); $content = ''; $content = 'Kjære Partner,

'; $content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.
'; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
Service: Sorgløs ferie
Navn: '.$bookingArray['name'].'
E-post: '.$bookingArray['email'].'
Telefon: '.$bookingArray['phonenumber'].'
Adresse: '.$bookingArray['address'].'
Bygningstype: '.$bookingArray['type_of_building'].'
Enebolig: '.($bookingArray['blomstervanning_enebolig']?'Ja':'Nei').'
Postinntak: '.($bookingArray['postinntak_enebolig']?'Ja':'Nei').'
Hvor mange ganger skal vi totalt komme: '.$bookingArray['number_of_worker'].'
Utfyllende kommentarer: '.$bookingArray['user_notes'].'
'; $content .= '
DIN BESTE HJELPER
'; $content .= '
Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no'; $emailItem = array( 'addressee_email' => $bookingArray['email'], 'addressee_name' => $bookingArray['name'], 'subject' => '[dinbestehjelper] Din timebestilling har kommet', 'content' => $content, 'attachments' => array() ); $emailArray[] = $emailItem; $this->User_model->sendEmail($emailArray); header('Location:'.SITEURL.'quotation-finished/'); } if(isset($_POST['sendFormPainting'])){ $bookingArray = array( 'name' => $_POST['name'], 'address' => $_POST['address'], 'email' => $_POST['email'], 'phonenumber' => $_POST['phonenumber'], 'type_of_building' => $_POST['type_of_building'], 'year_of_construction' => $_POST['year_of_construction'], 'home_inhabited' => $_POST['home_inhabited'], 'painting_on_plastered_surfaces' => $_POST['painting_on_plastered_surfaces'], 'wall_paint_on_a_plasterboard_surface' => $_POST['wall_paint_on_a_plasterboard_surface'], 'floor_area' => $_POST['floor_area'], 'ceiling_height' => $_POST['ceiling_height'], 'user_notes' => $_POST['user_notes'] ); $content = ''; $content = 'Kjære Partner,

'; $content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.
'; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
Service: Malerarbeid
Navn: '.$bookingArray['name'].'
E-post: '.$bookingArray['email'].'
Telefon: '.$bookingArray['phonenumber'].'
Adresse: '.$bookingArray['address'].'
Bygningstype: '.$bookingArray['type_of_building'].'
Byggeår: '.($bookingArray['year_of_construction']).'
Er boligen bebodd under byggearbeidene? '.($bookingArray['home_inhabited']?'Ja':'Nei').'
Maling på pussede overflater? '.($bookingArray['painting_on_plastered_surfaces']?'Ja':'Nei').'
Veggmaling på gipsplateoverflate? '.($bookingArray['wall_paint_on_a_plasterboard_surface']?'Ja':'Nei').'
Gulvareal i rommet som skal males: '.$bookingArray['floor_area'].' m2
Takhøyde: '.$bookingArray['ceiling_height'].' m
Utfyllende kommentarer: '.$bookingArray['user_notes'].'
'; $content .= '
DIN BESTE HJELPER
'; $content .= '
Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no'; $emailItem = array( 'addressee_email' => $bookingArray['email'], 'addressee_name' => $bookingArray['name'], 'subject' => '[dinbestehjelper] Din timebestilling har kommet', 'content' => $content, 'attachments' => array() ); $emailArray[] = $emailItem; $this->User_model->sendEmail($emailArray); header('Location:'.SITEURL.'quotation-finished/'); } if(isset($_POST['sendFormPolishing'])){ $serviceArray = $this->Service_model->getAllServiceByServiceType(); $bookingArray = array( 'name' => $_POST['name'], 'address' => $_POST['address'], 'email' => $_POST['email'], 'phonenumber' => $_POST['phonenumber'], 'merke' => $_POST['merke'], 'type_of_car' => $_POST['type_of_car'], 'farge' => $_POST['farge'], 'arsmodell' => $_POST['Arsmodell'], 'user_notes' => $_POST['user_notes'] ); $content = ''; $content = 'Kjære Partner,

'; $content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.
'; $content .= '
'; $content .= '1. Vi behandler opplysningene du oppga så raskt som mulig.
'; $content .= '2. Vi kontakter deg per e-post eller sms, for å avtale tidspunkt.
'; $content .= '3. Vi kommer til avtalt tid for å besiktige stedet/oppgaven.
'; $content .= '4. Deretter gir vi et tilbud per e-post.
'; $content .= '5. Hvis du godtar det, begynner arbeidet så raskt som mulig.
'; $content .= '
Opplysninger:
'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
Service: Full polering
Navn: '.$bookingArray['name'].'
E-post: '.$bookingArray['email'].'
Telefon: '.$bookingArray['phonenumber'].'
Adresse: '.$bookingArray['address'].'
Merke: '.$bookingArray['merke'].'
Type of car: '.($bookingArray['type_of_car']).'
Farge: '.($bookingArray['farge']).'
Arsmodell: '.($bookingArray['arsmodell']).'
Utfyllende kommentarer: '.$bookingArray['user_notes'].'
'; $content .= '
DIN BESTE HJELPER
'; $content .= '
Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no'; $emailItem = array( 'addressee_email' => $bookingArray['email'], 'addressee_name' => $bookingArray['name'], 'subject' => '[dinbestehjelper] Din timebestilling har kommet', 'content' => $content, 'attachments' => array() ); $emailArray[] = $emailItem; $this->User_model->sendEmail($emailArray); header('Location:'.SITEURL.'quotation-finished/'); } if(isset($_POST['sendFormWaterChannel'])){ $formArray = array( 'name' => $_POST['name'], 'address' => $_POST['address'], 'email' => $_POST['email'], 'phonenumber' => $_POST['phonenumber'], 'type_of_building' => $_POST['type_of_building'], 'year_of_construction' => $_POST['year_of_construction'], 'home_inhabited' => $_POST['home_inhabited'], 'demolition_of_old_system' => $_POST['demolition_of_old_system'], 'installation_of_new_system' => $_POST['installation_of_new_system'], 'installation_of_water_in_kitchen' => $_POST['installation_of_water_in_kitchen'], 'installation_of_water_in_the_bathroom' => $_POST['installation_of_water_in_the_bathroom'], 'connection_of_washbasin' => $_POST['connection_of_washbasin'], 'replacement_of_toilet' => $_POST['replacement_of_toilet'], 'installation_of_connection_for_household' => $_POST['installation_of_connection_for_household'], 'connecting_a_dishwasher' => $_POST['connecting_a_dishwasher'], 'connection_of_washing_machine' => $_POST['connection_of_washing_machine'], 'connection_of_dryer' => $_POST['connection_of_dryer'], 'installation_of_a_garden_tap' => $_POST['installation_of_a_garden_tap'], 'installation_of_water_purification' => $_POST['installation_of_water_purification'], 'user_notes' => $_POST['user_notes'] ); $content = ''; $content = 'Kjære Partner,

'; $content .= 'Vi har mottatt din forespørsel om tilbud. Her er opplysningene du oppga.
'; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
Service: Rørleggerarbeid
Navn: '.$bookingArray['name'].'
E-post: '.$bookingArray['email'].'
Telefon: '.$bookingArray['phonenumber'].'
Adresse: '.$bookingArray['address'].'
Bygningstype: '.$bookingArray['type_of_building'].'
Byggeår: '.($bookingArray['year_of_construction']?'Ja':'Nei').'
Er boligen bebodd under byggearbeidene?: '.($bookingArray['home_inhabited']?'Ja':'Nei').'
Rivning av gammelt system (komplett til vannmåler): '.($bookingArray['demolition_of_old_system']?'Ja':'Nei').'
Installasjon av nytt system (fra måler): '.($bookingArray['installation_of_new_system']?'Ja':'Nei').'
Installasjon av vann og avløp i kjøkken: '.($bookingArray['installation_of_water_in_kitchen']?'Ja':'Nei').'
Installasjon av vann og avløp på bad: '.($bookingArray['installation_of_water_in_the_bathroom']?'Ja':'Nei').'
Tilkobling av servant, badekar, dusj: '.($bookingArray['connection_of_washbasin']?'Ja':'Nei').'
Utskifting av toalett, håndvask, nyinstallasjon: '.($bookingArray['replacement_of_toilet']?'Ja':'Nei').'
Installasjon av tilkobling for husholdningsapparater: '.($bookingArray['installation_of_connection_for_household']?'Ja':'Nei').'
Tilkobling av oppvaskmaskin: '.($bookingArray['connecting_a_dishwasher']?'Ja':'Nei').'
Tilkobling av vaskemaskin: '.($bookingArray['connection_of_washing_machine']?'Ja':'Nei').'
Tilkobling av tørketrommel: '.($bookingArray['connection_of_dryer']?'Ja':'Nei').'
Installasjon av hagekran: '.($bookingArray['installation_of_a_garden_tap']?'Ja':'Nei').'
Installasjon av vannrenseutstyr: '.($bookingArray['installation_of_water_purification']?'Ja':'Nei').'
Utfyllende kommentarer: '.$bookingArray['user_notes'].'
'; $content .= '
DIN BESTE HJELPER
'; $content .= '
Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no'; $emailItem = array( 'addressee_email' => $bookingArray['email'], 'addressee_name' => $bookingArray['name'], 'subject' => '[dinbestehjelper] Din timebestilling har kommet', 'content' => $content, 'attachments' => array() ); $emailArray[] = $emailItem; $this->User_model->sendEmail($emailArray); header('Location:'.SITEURL.'quotation-finished/'); } if(isset($_POST['sendBooking'])){ //calculate finish time $serviceStartTime = date("H:i:s", strtotime($_POST['booking_start_time'])); $serviceLengthTime = date("H:i:s", strtotime($_POST['servicelength'])); $secs = strtotime($serviceLengthTime)-strtotime("00:00:00"); $serviceFinishTime = date("H:i:s",strtotime($serviceStartTime)+$secs); $data['services'] = $this->Service_model->getAllServiceByServiceType(); $data['workgroups'] = $this->Group_model->getAllGroups(); $selectedServiceArray = array(); //find selected services if(is_array($data['services'])){ foreach($data['services'] as $serviceItem){ if(isset($_POST['service_'.$serviceItem->service_id])){ if($_POST['service_'.$serviceItem->service_id]){ $selectedServiceArray[] = array( 'service_id' => $serviceItem->service_id, 'quantity' => $_POST['quantity_'.$serviceItem->service_id] ); } } } } $bookingArray = array( 'guest_name' => $_POST['guest_name'], 'guest_email' => $_POST['guest_email'], 'guest_phone' => $_POST['guest_phone'], 'guest_addresse' => $_POST['guest_addresse'], 'guest_car_reg_number' => $_POST['guest_car_reg_number'], 'guest_car_type' => $_POST['guest_car_type'], 'group_id' => $_POST['group_id'], 'booking_date' => $_POST['booking_date'], 'booking_start_time' => $_POST['booking_start_time'], 'booking_finish_time' => $serviceFinishTime, 'service_ids' => serialize($selectedServiceArray), 'guest_confirmed' => '0', 'total_price' => $_POST['totalPrice'], 'guest_confirm_code' => '1234', ); $this->Service_model->createBooking($bookingArray); $group = $this->Group_model->getGroupById($bookingArray['group_id']); $services = unserialize($bookingArray['service_ids']); $serviceArray = array(); $emailArray = array(); if(is_array($services)){ foreach($services as $serviceItem){ $selectedService = $this->Service_model->getServiceById($serviceItem['service_id']); if(is_object($selectedService)){ $tmpService = (array)$selectedService; $tmpService['quantity'] = $serviceItem['quantity']; $serviceArray[] = (object)$tmpService; } } } $content = ''; $content = 'Kjære Bestiller,

'; $content .= 'Takk for din bestilling. Her er opplysningene du oppga.
'; $content .= '
'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; if($bookingArray['guest_car_reg_number'] != ''){ $content .= ''; } if($bookingArray['guest_car_type'] != ''){ $content .= ''; } $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
Navn: '.$bookingArray['guest_name'].'
E-post: '.$bookingArray['guest_email'].'
Telefon: '.$bookingArray['guest_phone'].'
Adresse: '.$bookingArray['guest_addresse'].'
Registreringsnummer: '.$bookingArray['guest_car_reg_number'].'
Bilmerke: '.$bookingArray['guest_car_type'].'
Dato: '.$bookingArray['booking_date'].'
Tid: '.$bookingArray['booking_start_time'].' - '.$bookingArray['booking_finish_time'].'
Tjenester: '; $totalServicePrice = 0; foreach($serviceArray as $serviceArrayItem){ $totalServicePrice += $serviceArrayItem->service_price; $content .= ''; } $content .= '
'.$serviceArrayItem->service_name.'('.$serviceArrayItem->quantity.' x '.$serviceArrayItem->service_price.' kr) '.$serviceArrayItem->quantity*$serviceArrayItem->service_price.' kr
Totalpris: '.$bookingArray['total_price'].' kr
'; $content .= '
DIN BESTE HJELPER
'; $content .= '
Dersom du ønsker å avbestille, kan du gjøre det i en melding på Instagram, Facebook eller til følgende e-post timebestilling@dinbestehjelper.no'; $emailItem = array( 'addressee_email' => $bookingArray['guest_email'], 'addressee_name' => $bookingArray['guest_name'], 'subject' => '[dinbestehjelper] Din timebestilling har kommet', 'content' => $content, 'attachments' => array() ); $emailArray[] = $emailItem; $this->User_model->sendEmail($emailArray); header('Location:'.SITEURL.'booking-finished/'); } $this->load->view('pages/booking-process', $data); } public function profile(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Log_model'); $this->load->model('Module_model'); $data['message'] = ''; $data['message_class'] = ''; $data['fullname'] = ''; $data['password'] = ''; $data['profile_img_url'] = ''; if(isset($_SESSION['username'])){ $data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']); $data['message'] = ''; $data['message_class'] = ''; $data['pageTitle'] = 'Profil szerkesztése'; if($this->User_model->is_user_admin($_SESSION['username'])){ $data['activeModules'] = $this->Module_model->getAllModule(); } else{ $data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id); } if(isset($_POST["storeProfile"])) { if($_POST['fullname'] != $data['currentUser']->fullname){ $userArray = array( 'fullname' => $_POST['fullname'] ); $this->User_model->updateUser($data['currentUser']->user_id, $userArray); $this->Log_model->addLog('profile', 'A felhasználó módosította a teljes nevét: '.$data['currentUser']->fullname.' => '.$_POST['fullname'],$_SESSION['username']); } if($_POST['password'] != ''){ $userArray = array( 'password' => hash('sha256', $_POST['password']) ); $this->User_model->updateUser($data['currentUser']->user_id, $userArray); $this->Log_model->addLog('profile', 'A felhasználó módosította a jelszavát',$_SESSION['username']); } //upload profile image if($_FILES["profile_img"]["tmp_name"] != ''){ $target_dir = getcwd()."/assets/img/profiles/"; $target_file = $target_dir . str_replace('.','_', str_replace('@','_',$_SESSION['username'])); $imageFileType = strtolower(pathinfo(basename($_FILES["profile_img"]["name"]),PATHINFO_EXTENSION)); if (move_uploaded_file($_FILES["profile_img"]["tmp_name"], $target_file.'.'.$imageFileType)) { $data['message'] = 'A profilkép sikeresen feltöltve!'; $data['message_class'] = 'successMessage'; $data['profile_img_url'] = 'assets/img/profiles/'.str_replace('.','_', str_replace('@','_',$_SESSION['username'])).'.'.$imageFileType; $userArray = array( 'profile_img_url' => $data['profile_img_url'] ); $this->User_model->updateUser($data['currentUser']->user_id, $userArray); $this->Log_model->addLog('profile', 'A felhasználó lecserélte a profilképét ',$_SESSION['username']); } else { $data['message'] = 'Hiba a feltöltés közben!'; $data['message_class'] = 'errorMessage'; } } $data['message'] = 'A profil sikeresen módosítva!'; $data['message_class'] = 'successMessage'; } $data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']); $this->load->view('pages/profile', $data); } else{ header("Location:".SITEURL."login"); } } public function log_monitor(){ $this->load->helper('url'); $this->load->model('User_model'); $this->load->model('Log_model'); $this->load->model('Module_model'); if(isset($_SESSION['username'])){ $data['currentUser'] = $this->User_model->getUserByUsername($_SESSION['username']); $data['message'] = ''; $data['message_class'] = ''; $data['pageTitle'] = 'Rendszermonitor'; $data['logInfoLink'] = ''; if($this->User_model->is_user_admin($_SESSION['username'])){ $data['activeModules'] = $this->Module_model->getAllModule(); } else{ $data['activeModules'] = $this->Module_model->getUserModules($data['currentUser']->user_id); } $selectedModule = $this->Module_model->getModuleBySlug('log-monitor'); if($this->Module_model->is_module_available($selectedModule->module_id, $data['currentUser']->user_id)){ if(isset($_POST['exportToFile'])){ $logInfoArray = $this->Log_model->getAllLoginfo(); $logrow = ''; $logTxt = fopen(getcwd()."/documents/loginfo.csv", "w") or die("Hiba a fájl mentésekor!"); $row = '"Esemény ideje";'.'"Esemény típusa";'.'"Felhasználónév";"Bejegyzés tartalma";'.PHP_EOL; $string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row ); fwrite($logTxt, $string_encoded); foreach($logInfoArray as $logInfoItem){ $logDateTime = new datetime($logInfoItem->event_datetime); $row = date_format($logDateTime,"Y-m-d H:i").';"'.$logInfoItem->event_type.'";"'.$logInfoItem->username.'";"'.$logInfoItem->event_content.'";'.PHP_EOL; $string_encoded = iconv( mb_detect_encoding( $row ), 'ISO-8859-2', $row ); fwrite($logTxt, $string_encoded); } fclose($logTxt); $data['logInfoLink'] = 'A loginfo.csv fájl letöltése'; } $this->load->view('log-monitor', $data); } else{ header("Location:".SITEURL."home"); } } else{ header("Location:".SITEURL."login"); } } }