close(403, JText::translate('JINVALID_TOKEN')); } $result = [ 'processed' => 0, 'generated' => 0, ]; $dbo = JFactory::getDbo(); $dbo->setQuery( $dbo->getQuery(true) ->select([ $dbo->qn('id'), $dbo->qn('img'), ]) ->from($dbo->qn('#__vikbooking_rooms')) ->where($dbo->qn('avail') . ' = 1') ); $listings = $dbo->loadAssocList(); $updpath = VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR; foreach ($listings as $listing) { // increase counter $result['processed']++; if (is_file($updpath . $listing['img']) && !is_file($updpath . 'mini_' . $listing['img'])) { // generate thumbnail try { // resize the original image (new VikResizer)->proportionalImage($updpath . $listing['img'], $updpath . 'mini_' . $listing['img'], 96, 96); // increase counter $result['generated']++; } catch (Throwable $e) { // silently catch any PHP GD error and continue } } } // send result to output VBOHttpDocument::getInstance()->json($result); } /** * AJAX endpoint to get the eligible options/extras for a given room party. * * @return void * * @since 1.18.8 (J) - 1.8.8 (WP) */ public function get_eligible_options() { if (!JSession::checkToken()) { VBOHttpDocument::getInstance()->close(403, JText::translate('JINVALID_TOKEN')); } $app = JFactory::getApplication(); // gather request values $listingId = $app->input->getUInt('listing_id', 0); $adults = $app->input->getUInt('adults', 0); $children = $app->input->getUInt('children', 0); $rateId = $app->input->getUInt('rate_id', 0); $checkin = $app->input->getString('checkin', ''); $checkout = $app->input->getString('checkout', ''); // get the listing eligible options for the given room party $eligibleOptions = VBORoomHelper::getInstance()->getEligibleOptions($listingId, [ 'checkin' => $checkin, 'checkout' => $checkout, 'adults' => $adults, 'children' => $children, 'rate_id' => $rateId, ]); // send list to output VBOHttpDocument::getInstance($app)->json($eligibleOptions); } }