⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.216
Server IP:
65.21.180.239
Server:
Linux gowhm.eplangoweb.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.0.30
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
eplangoweb
/
.trash
/
updater
/
View File Name :
UpdateController.php
<?php namespace App\Http\Controllers; use App\Models\BasicExtended; use Illuminate\Support\Facades\Schema; use App\Models\Language; use App\Models\User; use App\Models\User\Language as UserLanguage; use App\Models\User\UserEmailTemplate; use App\Models\User\UserPermission; use App\Models\User\UserVcard; use Illuminate\Http\Request; use Artisan; use DB; class UpdateController extends Controller { public function version() { return view('updater.version'); } public function filesFolders($src, $des) { $dir = $src; //"path/to/targetFiles"; $dirNew = $des; //path/to/destination/files // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo '<br>Archivo: ' . $file; //exclude unwanted if ($file == 'move.php') { continue; } if ($file == '.') { continue; } if ($file == '..') { continue; } if ($file == 'viejo2014') { continue; } if ($file == 'viejo2013') { continue; } if ($file == 'cgi-bin') { continue; } //if ($file=="index.php") continue; for example if you have index.php in the folder if (rename($dir . '/' . $file, $dirNew . '/' . $file)) { echo ' Files Copyed Successfully'; echo ": $dirNew/$file"; //if files you are moving are images you can print it from //new folder to be sure they are there } else { echo 'File Not Copy'; } } closedir($dh); } } } public function recurse_copy($src, $dst) { $dir = opendir(base_path($src)); @mkdir(base_path($dst), 0775, true); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir(base_path($src) . '/' . $file)) { $this->recurse_copy($src . '/' . $file, $dst . '/' . $file); } else { // dd(base_path($src . '/' . $file), $src, file_exists(base_path($src . '/' . $file))); copy(base_path($src . '/' . $file), base_path($dst) . '/' . $file); } } } closedir($dir); } public function upversion(Request $request) { $assets = [ ['path' => 'assets/admin/css', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/admin/js', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/admin/fonts', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/css', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/js', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/user', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/fonts', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/img/user/templates', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/img/theme9', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/front/img/themes', 'type' => 'folder', 'action' => 'replace'], ['path' => 'assets/tenant/css', 'type' => 'folder', 'action' => 'add'], ['path' => 'assets/tenant/js', 'type' => 'folder', 'action' => 'add'], ['path' => 'assets/user/js', 'type' => 'folder', 'action' => 'replace'], ['path' => 'config', 'type' => 'folder', 'action' => 'replace'], ['path' => 'database/migrations', 'type' => 'folder', 'action' => 'add'], ['path' => 'resources/views', 'type' => 'folder', 'action' => 'replace'], // ['path' => 'vendor', 'type' => 'folder', 'action' => 'replace'], ['path' => 'routes/web.php', 'type' => 'file', 'action' => 'replace'], ['path' => 'app', 'type' => 'folder', 'action' => 'replace'], ['path' => 'composer.json', 'type' => 'file', 'action' => 'replace'], ['path' => 'composer.lock', 'type' => 'file', 'action' => 'replace'], ['path' => 'version.json', 'type' => 'file', 'action' => 'replace'], ]; foreach ($assets as $key => $asset) { $des = ''; if (strpos($asset['path'], 'assets/') !== false) { $des = 'public/' . $asset['path']; } else { $des = $asset['path']; } // if updater need to replace files / folder (with/without content) if ($asset['action'] == 'replace') { if ($asset['type'] == 'file') { copy(base_path('public/updater/' . $asset['path']), base_path($des)); } if ($asset['type'] == 'folder') { // @unlink(base_path($des)); $this->delete_directory($asset['path']); $this->recurse_copy('public/updater/' . $asset['path'], $des); } } // if updater need to add files / folder (with/without content) elseif ($asset['action'] == 'add') { if ($asset['type'] == 'folder') { @mkdir($des . '/', 0775, true); $this->recurse_copy('public/updater/' . $asset['path'], $des); } } } $arr = ['WEBSITE_HOST' => $request->website_host]; setEnvironmentValue($arr); $this->updateLanguage(); Artisan::call('config:clear'); // run migration files Artisan::call('migrate'); $users = User::all(); $this->updateUserMailTemplates($users); $langs = UserLanguage::all(); $newKeys = [ 'Active' => 'Active', 'all_category' => 'All Category', 'all_courses' => 'All Courses', 'All_Room_Bookings' => 'All Room Bookings', 'Amenities' => 'Amenities', 'Ammenity_Name' => 'Ammenity Name', 'Anonymous_Donation' => 'Anonymous Donation', 'Answer' => 'Answer', 'ascending' => 'ascending', 'Attachment' => 'Attachment', 'Attachment_Image' => 'Attachment Image', 'Bath' => 'Bath', 'Baths' => 'Baths', 'Bed' => 'Bed', 'Beds' => 'Beds', 'book_now' => 'book now', 'Booking_Date' => 'Booking Date', 'Booking_Details' => 'Booking Details', 'Booking_No' => 'Booking No', 'Booking_Number' => 'Booking Number', 'Booking_Status' => 'Booking Status', 'Card_Number' => 'Card Number', 'Cause' => 'Cause', 'cause_details' => 'Cause Details', 'Causes' => 'Causes', 'certificate' => 'Certificate', 'Certificate_Settings' => 'Certificate Settings', 'Certificate_Status' => 'Certificate Status', 'Certificate_Text' => 'Certificate Text', 'Certificate_Title' => 'Certificate Title', 'check' => 'check', 'Check_In_/_Out_Date' => 'Check In / Out Date', 'Click_Here' => 'Click Here', 'Code' => 'Code', 'Completed' => 'Completed', 'contact_info' => 'Contact Info', 'Content' => 'Content', 'Contents' => 'Contents', 'Correct' => 'Correct', 'Count' => 'Count', 'Coupon_Type' => 'Coupon Type', 'Coupons' => 'Coupons', 'course' => 'Course', 'Course_Categories' => 'Course Categories', 'course_details' => 'Course Details', 'Course_Duration' => 'Course Duration', 'Course_Enrolments' => 'Course Enrolments', 'Course_Management' => 'Course Management', 'Course_Price' => 'Course Price', 'Course_Title' => 'Course Title', 'course_type' => 'Course Type', 'Courses' => 'Courses', 'Cover_Image' => 'Cover Image', 'Created' => 'Created', 'Current_Price' => 'Current Price', 'curriculum' => 'Curriculum', 'Custom_Amount' => 'Custom Amount', 'Customer_Email' => 'Customer Email', 'Customer_Full_Name' => 'Customer Full Name', 'Customer_Mail_Address' => 'Customer Mail Address', 'Customer_Phone_Number' => 'Customer Phone Number', 'CVC_Number' => 'CVC Number', 'Dates' => 'Dates', 'Deactive' => 'Deactive', 'Delete' => 'Delete', 'descending' => 'descending', 'Details' => 'Details', 'Details_&_Edit' => 'Details & Edit', 'Disable' => 'Disable', 'discounted_price' => 'Discounted Price', 'Donate_Now' => 'Donate Now', 'donation' => 'Donation', 'Donation_Categories' => 'Donation Categories', 'Donation_Details' => 'Donation Details', 'Donation_Form' => 'Donation Form', 'Donation_History' => 'Donation History', 'Donation_Id' => 'Donation ID', 'donation_payment_success_msg' => 'Your payment for donation is successful. We sent you an email with Invoice. Please check your inbox', 'Donations' => 'Donations', 'download' => 'Download', 'Download_CV' => 'Download CV', 'Draft' => 'Draft', 'duration' => 'Duration', 'Edit' => 'Edit', 'Education' => 'Education', 'Enable' => 'Enable', 'Enforce_Quiz_Completion' => 'Enforce Quiz Completion', 'Enrol_Date' => 'Enrol Date', 'enrol_now' => 'Enrol Now', 'Enrolled_Courses' => 'Enrolled Courses', 'Enrolment_Details' => 'Enrolment Details', 'Enter_Answer' => 'Enter Answer', 'enter_card_code' => 'Enter Card Code', 'Enter_Customer_Email' => 'Enter Customer Email', 'enter_CVC_number' => 'Enter CVC Number', 'enter_expiry_month' => 'Enter Expiry Month', 'enter_expiry_year' => 'Enter Expiry Year', 'Enter_Full_Name' => 'Enter Full Name', 'Enter_Option' => 'Enter Option', 'Enter_Phone_Number' => 'Enter Phone Number', 'Enter_Question' => 'Enter Question', 'enter_your_card_number' => 'Enter Your Card Number', 'enter_your_feedback' => 'Enter Your Feedback', 'Event' => 'Event', 'Expired' => 'Expired', 'Expiry_Month' => 'Expiry Month', 'Expiry_Year' => 'Expiry Year', 'FAQs' => 'FAQs', 'Featured' => 'Featured', 'Featured_Image' => 'Featured Image', 'Features' => 'Features', 'Filter_Rooms' => 'Filter Rooms', 'Filters' => 'Filters', 'find_course' => 'Find Course', 'find_your_dream_course' => 'Find Your Dream Course', 'Fixed' => 'Fixed', 'free_courses' => 'Free Courses', 'frequently_asked_questions' => 'Frequently Asked Questions', 'Full_Name' => 'Full Name', 'Gateway' => 'Gateway', 'goal' => 'goal', 'Goal_Amount' => 'Goal Amount', 'Google_Map' => 'Google Map', 'Guest' => 'Guest', 'Guest_Checkout' => 'Guest Checkout', 'Guests' => 'Guests', 'Hide' => 'Hide', 'Icon' => 'Icon', 'Incorrect' => 'Incorrect', 'Information' => 'Information', 'Instructor' => 'Instructor', 'Instructors' => 'Instructors', 'Introduction_Video' => 'Introduction Video', 'Invoice' => 'Invoice', 'It_might_take_upto_24_-_48_hours' => 'It might take upto 24 - 48 hours.', 'ITEM' => 'ITEM', 'ITEMS' => 'ITEMS', 'Job' => 'Job', 'Language' => 'Language', 'Latest_Rooms' => 'Latest Rooms', 'Leave_this_field_empty_for_all_rooms' => 'Leave this field empty for all rooms', 'Lesson' => 'Lesson', 'Make_New_Booking' => 'Make New Booking', 'Manage' => 'Manage', 'Manage_Quiz' => 'Manage Quiz', 'Max_Guests' => 'Max Guests', 'Meaning' => 'Meaning', 'Minimum_Amount' => 'Minimum Amount', 'Minimum_Quiz_Score' => 'Minimum Quiz Score', 'Minimum_quiz_score_needed_to_complete_quiz_of_a_lesson' => 'Minimum quiz score needed to complete quiz of a lesson', 'Module' => 'Module', 'Modules' => 'Modules', 'More_Amenities' => 'More Amenities', 'my_courses' => 'Courses', 'new_course' => 'New Course', 'next' => 'Next', 'Night' => 'Night', 'No' => 'No', 'no_cause_found' => 'No Cause Found !', 'No_Content_Found' => 'No Content Found!', 'NO_COUNTER_INFORMATION_FOUND' => 'NO COUNTER INFORMATION FOUND', 'NO_COUPON_FOUND' => 'NO COUPON FOUND', 'NO_COURSE_CATEGORY_FOUND' => 'NO COURSE CATEGORY FOUND', 'no_course_found' => 'No Course Found', 'NO_DONATION_FOUND' => 'NO DONATION FOUND!', 'NO_ENROLMENT_FOUND' => 'NO ENROLMENT FOUND', 'No_Feature_Found' => 'No Feature Found', 'no_information_found' => 'No Information Found', 'NO_INSTRUCTOR_FOUND' => 'NO INSTRUCTOR FOUND!', 'NO_LANGUAGE_FOUND' => 'NO LANGUAGE FOUND', 'NO_MODULE_FOUND' => 'NO MODULE FOUND!', 'NO_PORTFOLIO_FOUND' => 'NO PORTFOLIO FOUND', 'No_Related_Rooms_Found' => 'No Related Rooms Found!', 'NO_ROOM_AMENITY_FOUND' => 'NO ROOM AMENITY FOUND!', 'NO_ROOM_BOOKING_FOUND' => 'NO ROOM BOOKING FOUND!', 'NO_ROOM_CATEGORY_FOUND' => 'NO ROOM CATEGORY FOUND!', 'No_Room_Found!' => 'No Room Found!', 'NO_SERVICE_FOUND' => 'NO SERVICE FOUND!', 'NO_Skill_FOUND' => 'NO Skill FOUND !', 'NO_SOCIAL_LINK_FOUND' => 'NO SOCIAL LINK FOUND!', 'NO_TESTIMONIAL_FOUND' => 'NO TESTIMONIAL FOUND!', 'Number_of_Guests' => 'Number of Guests', 'Number_of_Nights' => 'Number of Nights', 'Number_of_nights_will_be_calculated_based_on_checkin_&_checkout_date' => 'Number of nights will be calculated based on checkin & checkout date', 'Occupation' => 'Occupation', 'of' => 'of', 'old_course' => 'Old Course', 'Oldest_Rooms' => 'Oldest Rooms', 'Option' => 'Option', 'Order_ID' => 'Order ID', 'Paid' => 'Paid', 'Paid_Room_Bookings' => 'Paid Room Bookings', 'Paid_via' => 'Paid via', 'Payment' => 'Payment', 'Payment_Information' => 'Payment Information', 'Percentage' => 'Percentage', 'Please' => 'Please', 'please_login_to_give_your_feedback' => 'Please login to give your feedback', 'popular_features' => 'Popular Features', 'Premium' => 'Premium', 'premium_courses' => 'Premium Courses', 'Present' => 'Present', 'Preview' => 'Preview', 'Preview_Image' => 'Preview Image', 'Previous_Price' => 'Previous Price', 'Pricing_Type' => 'Pricing Type', 'print' => 'print', 'Products' => 'Products', 'Published' => 'Published', 'Purchase_History' => 'Purchase History', 'Question' => 'Question', 'quiz' => 'Quiz', 'Quizzes' => 'Quizzes', 'raised' => 'raised', 'Raised' => 'Raised', 'Raised_Amount' => 'Raised Amount', 'ratings' => 'Ratings', 'read_more' => 'read more', 'read_more' => 'read more', 'Recent_Blogs' => 'Recent Blogs', 'related_courses' => 'Related Courses', 'Recent_Room_Bookings' => 'Recent_Room_Bookings', 'Related_Rooms' => 'Related Rooms', 'Rent' => 'Rent', 'Rent_/_Night' => 'Rent / Night', 'Rent:_High_to_Low' => 'Rent: High to Low', 'Rent:_Low_to_High' => 'Rent: Low to High', 'retake_quiz' => 'retake_quiz', 'Review' => 'Review', 'Right_Answer' => 'Right Answer', 'Room' => 'Room', 'Room_Amenities' => 'Room Amenities', 'Room_Booking_Details' => 'Room Booking Details', 'room_booking_payment_success_msg' => 'Your payment for room booking is successful. We sent you an email with Invoice. Please check your inbox', 'Room_Bookings' => 'Room Bookings', 'Room_Categories' => 'Room Categories', 'room_details' => 'Room Details', 'Room_Name' => 'Room Name', 'Room_Settings' => 'Room_Settings', 'Room_Status' => 'Room Status', 'Room_Title' => 'Room Title', 'Room_Type' => 'Room Type', 'Rooms' => 'Rooms', 'Save' => 'Save', 'search' => 'search', 'Search_By_Booking_No' => 'Search By Booking No.', 'Search_by_Transaction_Id' => 'Search by Transaction ID', 'search_course' => 'Search Course', 'Select' => 'Select', 'Select_a_Category' => 'Select a Category', 'Select_a_language' => 'Select a language', 'Select_a_Method' => 'Select a Method', 'Select_a_Room' => 'Select a Room', 'Select_a_Status' => 'Select a Status', 'Select_a_Type' => 'Select a Type', 'Select_Courses' => 'Select Courses', 'Select_Dates' => 'Select Dates', 'select_payment_gateway' => 'Select Payment Gateway', 'Send_Mail' => 'Send Mail', 'Settings' => 'Settings', 'Shortcodes' => 'Shortcodes', 'Sider_Images' => 'Slider Images', 'Student_Name' => 'Student Name', 'students' => 'Students', 'Students_Enrolled' => 'Students Enrolled', 'Social_Icon' => 'Social Icon', 'Summary' => 'Summary', 'Text' => 'Text', 'Thank_You' => 'Thank You.', 'Thanks_Page' => 'Thanks Page', 'This_coupon_can_be_applied_to_this_room' => 'This coupon can be applied to these rooms', 'this_course_includes' => 'This Course Includes', 'this_course_is_not_reviewed_yet' => 'This course is not reviewed yet', 'This_Room_Has_No_Review_Yet.' => 'This Room Has No Review Yet.', 'Thumbnail_Image' => 'Thumbnail Image', 'Total_Rent' => 'Total Rent', 'Unpaid' => 'Unpaid', 'Unpaid_Room_Bookings' => 'Unpaid Room Bookings', 'url' => 'URL', 'User_Information' => 'User Information', 'user_offline_payment_success_text' => 'user offline payment success text', 'Value' => 'Value', 'We_have_received_your_booking_request.' => 'We have received your booking request.', 'We_have_sent_you_a_mail_with_an_invoice' => 'We have sent you a mail with an invoice.', 'Yes' => 'Yes', 'You_can_use_these_short_codes_to_show_dynamic_data_in_certificate_text' => 'You can use these short codes to show dynamic data in certificate text', 'you_have_already_enrolled_in_this_course' => 'You have already enrolled in this course', 'you_scored' => 'You scored', 'Your_transaction_request_was_received_and_sent_for_review' => 'Your transaction request was received and sent for review.', 'Your_transaction_was_successful' => 'Your transaction was successful', ]; foreach ($langs as $key => $lang) { $keyArr = json_decode($lang->keywords, true); foreach ($newKeys as $key => $newKey) { $keyArr["$key"] = $newKey; } $lang->keywords = json_encode($keyArr); $lang->save(); } \Session::flash('success', 'Updated successfully'); return redirect('updater/success.php'); } function delete_directory($dirname) { $dir_handle = null; if (is_dir($dirname)) { $dir_handle = opendir($dirname); } if (!$dir_handle) { return false; } while ($file = readdir($dir_handle)) { if ($file != '.' && $file != '..') { if (!is_dir($dirname . '/' . $file)) { unlink($dirname . '/' . $file); } else { $this->delete_directory($dirname . '/' . $file); } } } closedir($dir_handle); rmdir($dirname); return true; } public function updateLanguage() { $langCodes = []; $languages = Language::all(); foreach ($languages as $key => $language) { $langCodes[] = $language->code; } $langCodes[] = 'default'; foreach ($langCodes as $key => $langCode) { // read language json file $data = file_get_contents(base_path('resources/lang/' . $langCode . '.json')); // decode default json $json_arr = json_decode($data, true); // new keys $newKeywordsJson = file_get_contents(base_path('public/updater/language.json')); $newKeywords = json_decode($newKeywordsJson, true); foreach ($newKeywords as $key => $newKeyword) { // # code... if (!array_key_exists($key, $json_arr)) { $json_arr[$key] = $key; } } // push the new key-value pairs in language json files file_put_contents(base_path('resources/lang/' . $langCode . '.json'), json_encode($json_arr)); } } public function redirectToWebsite(Request $request) { $arr = ['WEBSITE_HOST' => $request->website_host]; setEnvironmentValue($arr); \Artisan::call('config:clear'); return redirect()->route('front.index'); } public function updateUserMailTemplates($users) { foreach ($users as $key => $user) { $uTemplate = UserEmailTemplate::where('user_id', $user->id) ->where('email_type', 'email_verification') ->count(); DB::table('user_email_templates')->insert([ ['user_id' => $user->id, 'email_type' => 'room_booking', 'email_subject' => 'Thank you for your Room Booking', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'donation_approved', 'email_subject' => 'You payment is approved for donation.', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'donation', 'email_subject' => 'Thank you for your donation', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'course_enrolment', 'email_subject' => 'Thank you for your course enrolment.', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'course_enrolment_approved', 'email_subject' => 'Your course enrollment payment is approved.', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'course_enrolment_rejected', 'email_subject' => 'Your course enrollment payment is rejected.', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'payment_cancelled', 'email_subject' => 'Your payment is rejected.', 'email_body' => '<p></p>'], ['user_id' => $user->id, 'email_type' => 'payment_received', 'email_subject' => 'Your payment is recived.', 'email_body' => '<p></p>'], ]); } } }