diff --git a/.gitignore b/.gitignore index a4854bef..32d3bd5c 100755 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ npm-debug.log # Laravel 4 specific bootstrap/compiled.php app/storage/ +storage/settings.json # Laravel 5 & Lumen specific public/storage diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 302b1057..15d9d20e 100755 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -4,6 +4,8 @@ use Illuminate\Http\Request; use App\Http\Controllers\Controller; +use \DiscordWebhooks\Client; +use \DiscordWebhooks\Embed; class SettingsController extends Controller { @@ -49,9 +51,50 @@ public function savePterodactyl(){ if(Request("ptero_appkey")!= null){ \Setting::set("pterodactyl_appkey", Request("ptero_appkey")); } +// \Setting::save(); + session()->flash('good', 'Your settings have been saved'); + return redirect()->back(); + } + + public function showDiscord(){ + return view('admin.pages.settings.discord.index'); + } +public function testDiscord(){ + $orderlink = \Setting::get("DISCORD_ORDER_WEBHOOK"); + $adminlink = \Setting::get("DISCORD_LOGIN_WEBHOOK"); + +$embed = new Embed(); +$embed->color("1376020"); +$embed->description('Discord Webook test called from MinePoS admin panel'); + +if($orderlink != null){ + (new Client($orderlink))->embed($embed)->send(); +} +if($adminlink != null){ + (new Client($adminlink))->embed($embed)->send(); +} + session()->flash('good', 'Discord test complete please check discord and verify the messages have been sent'); + return redirect()->back(); +} + public function saveDiscord(){ + + \Setting::set("DISCORD_LOGIN_ENABLED", (Request("admin_enabled") != null)); + \Setting::save(); + \Setting::set("DISCORD_ORDER_ENABLED", (Request("order_enabled") != null)); + \Setting::save(); + + if(Request("admin_link")!= null){ + \Setting::set("DISCORD_LOGIN_WEBHOOK", Request("admin_link")); + \Setting::save(); + } + if(Request("admin_link")!= null){ + \Setting::set("DISCORD_ORDER_WEBHOOK", Request("order_link")); + \Setting::save(); + } session()->flash('good', 'Your settings have been saved'); return redirect()->back(); + //DISCORD_LOGIN_WEBHOOK } public function magicPterodactyl(){ diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 98206a33..f8351eff 100755 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -43,19 +43,19 @@ public function showCategory(Category $category){ return view('category')->with(['category'=>$category]); } public function paymentDone(){ - $item_name = $_POST['item_name']; - $item_number = $_POST['item_number']; - $payment_status = $_POST['payment_status']; - $payment_amount = $_POST['mc_gross']; - $payment_currency = $_POST['mc_currency']; - $txn_id = $_POST['txn_id']; - $receiver_email = $_POST['receiver_email']; - $payer_email = $_POST['payer_email']; - $order = \App\Order::find($item_number); - if($order == null){ - abort(404); - return; - } - return view('paymentDone')->with(compact("item_name", "item_number", "payment_status","payment_amount","payment_currency","txn_id","receiver_email","payer_email","order")); + // $item_name = $_POST['item_name']; + // $item_number = $_POST['item_number']; + // $payment_status = $_POST['payment_status']; + // $payment_amount = $_POST['mc_gross']; + // $payment_currency = $_POST['mc_currency']; + // $txn_id = $_POST['txn_id']; + // $receiver_email = $_POST['receiver_email']; + // $payer_email = $_POST['payer_email']; + // $order = \App\Order::find($item_number); + // if($order == null){ + // abort(404); + // return; + // } + return view('paymentDone'); } } diff --git a/app/Http/Controllers/PayPalTestController.php b/app/Http/Controllers/PayPalTestController.php index 2df4ff84..8b0951ab 100755 --- a/app/Http/Controllers/PayPalTestController.php +++ b/app/Http/Controllers/PayPalTestController.php @@ -26,7 +26,8 @@ public function index(){ } $order = new Order; - $commands = "{ \"13\": [ \"bc %player% has just donated!\",\"give %player% diamond\",\"spawn %player%\" ] }"; + $sid = \App\Server::all()[0]->id; + $commands = "{ \"".$sid."\": [ \"bc %player% has just donated!\",\"give %player% diamond\"] }"; $commands = str_replace("%player%", \Store::username(), $commands); $order->username = \Store::username(); @@ -61,7 +62,7 @@ public function paypalIpn() Log::info("Payment verified agenst payapl and inserted to orders table to the database."); $ids = explode('|', $ipn->getPostData()['custom']); - $order = \App\Order::find($ids[0]); + $order = \App\Order::find($ipn->getPostData()['item_number']); $order->txid = $ipn->getPostData()['txn_id']; $order->gateway = "paypal"; diff --git a/app/Listeners/UserEventListener.php b/app/Listeners/UserEventListener.php index ba9e3754..a262b09c 100755 --- a/app/Listeners/UserEventListener.php +++ b/app/Listeners/UserEventListener.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use \DiscordWebhooks\Client; use \DiscordWebhooks\Embed; - +use \Setting; class UserEventListener { /** @@ -37,12 +37,12 @@ public function onUserLogout($event) public function onUserLogin($event) { - if(env('DISCORD_LOGIN_ENABLED', false)){ + if(Setting::get('DISCORD_LOGIN_ENABLED', false)){ $ip = \Request::ip(); if(env('APP_DEBUG', false)){ $ip = preg_replace('/[0-9]+/', '*', $ip); } - $webhook = env('DISCORD_LOGIN_WEBHOOK'); + $webhook = Setting::get('DISCORD_LOGIN_WEBHOOK'); $webhook = new Client($webhook); $embed = new Embed(); diff --git a/app/Order.php b/app/Order.php index 3a21245d..e5255662 100755 --- a/app/Order.php +++ b/app/Order.php @@ -15,8 +15,8 @@ public function lastIPN(){ public function orderNotification() { - if(env('DISCORD_ORDER_ENABLED', false)){ - $webhook = env('DISCORD_ORDER_WEBHOOK'); + if(\Setting::get('DISCORD_ORDER_ENABLED', false)){ + $webhook = \Setting::get('DISCORD_ORDER_WEBHOOK'); $webhook = new Client($webhook); $embed = new Embed(); @@ -25,7 +25,7 @@ public function orderNotification() $webhook->embed($embed)->send(); } - \Mail::to($this->lastIPN()['payer_email'])->send(new \App\Mail\OrderProcessed($this)); + //\Mail::to($this->lastIPN()['payer_email'])->send(new \App\Mail\OrderProcessed($this)); } public static function paymentsDays($days) { diff --git a/resources/views/PayPalTest.blade.php b/resources/views/PayPalTest.blade.php index ac85e202..a604095b 100755 --- a/resources/views/PayPalTest.blade.php +++ b/resources/views/PayPalTest.blade.php @@ -7,7 +7,6 @@ - diff --git a/resources/views/admin/layout.blade.php b/resources/views/admin/layout.blade.php index 900f53ce..746349f8 100755 --- a/resources/views/admin/layout.blade.php +++ b/resources/views/admin/layout.blade.php @@ -8,8 +8,10 @@ + + diff --git a/resources/views/admin/pages/settings/discord/index.blade.php b/resources/views/admin/pages/settings/discord/index.blade.php new file mode 100755 index 00000000..a028dc09 --- /dev/null +++ b/resources/views/admin/pages/settings/discord/index.blade.php @@ -0,0 +1,87 @@ +@extends('admin.layout') + +@section('title') +Discord +@endsection + +@section('desc') +Eye, Nice to see you want to use our discord intergration +@endsection + +@section('content') +
+
+
+

Discord + +

+
+ +
+ {{csrf_field()}} +
+ + +
+ +
+
+ +
+
+ + + + + + +
+ +
+
+ +
+ + +
+
+
+

Test webhooks +

+
+ +
+ {{csrf_field()}} +
+ This test process will attempt to send messages to both the webhooks +
+ +
+
+ +
+@endsection + +@section('head') + +@endsection +@section('extra') + + +@endsection \ No newline at end of file diff --git a/resources/views/admin/parts/navnormal.blade.php b/resources/views/admin/parts/navnormal.blade.php index 797b5ba3..fcf80c5d 100755 --- a/resources/views/admin/parts/navnormal.blade.php +++ b/resources/views/admin/parts/navnormal.blade.php @@ -57,7 +57,7 @@ @endif - @if(\Auth::user()->can('list orders') || \Auth::user()->can('create order')) + @if(\Auth::user()->can('list order') || \Auth::user()->can('create order'))
  • Orders @@ -69,8 +69,8 @@ @if(\Auth::user()->can('create order'))
  • Create Orders
  • @endif - @if(\Auth::user()->can('list orders')) -
  • Manage Orders
  • + @if(\Auth::user()->can('list order')) +
  • Manage Orders
  • @endif diff --git a/resources/views/admin/parts/navsettings.blade.php b/resources/views/admin/parts/navsettings.blade.php index bcd02243..7be776e4 100755 --- a/resources/views/admin/parts/navsettings.blade.php +++ b/resources/views/admin/parts/navsettings.blade.php @@ -4,4 +4,7 @@
  • Pterodactyl
  • -
  • Payments
  • \ No newline at end of file +
  • Payments
  • + +
  • + Discord
  • \ No newline at end of file diff --git a/resources/views/buycraft/paymentDone.blade.php b/resources/views/buycraft/paymentDone.blade.php index 1c9dc897..146c6b3b 100755 --- a/resources/views/buycraft/paymentDone.blade.php +++ b/resources/views/buycraft/paymentDone.blade.php @@ -5,5 +5,17 @@ @endsection @section('content') +
    +
    +
    +
    +

    Payment Complete

    +
    +

    Thank you for donating, your order should be processed soon

    +
    +
    +
    +
    +
    @endsection diff --git a/routes/admin/web.php b/routes/admin/web.php index 66b9f366..8d2f592d 100755 --- a/routes/admin/web.php +++ b/routes/admin/web.php @@ -71,6 +71,10 @@ Route::get('settings/pterodactyl','Admin\SettingsController@showPterodactyl')->middleware('permission:edit settings')->name("admin.settings.pterodactyl"); Route::post('settings/pterodactyl','Admin\SettingsController@savePterodactyl')->middleware('permission:edit settings')->name("admin.settings.pterodactyl"); + Route::get('settings/discord','Admin\SettingsController@showDiscord')->middleware('permission:edit settings')->name("admin.settings.discord"); + Route::post('settings/discord','Admin\SettingsController@saveDiscord')->middleware('permission:edit settings')->name("admin.settings.discord"); + Route::post('settings/discord','Admin\SettingsController@testDiscord')->middleware('permission:edit settings')->name("admin.settings.discord.test"); + Route::post('settings/pterodactyl/setup','Admin\SettingsController@magicPterodactyl')->middleware('permission:edit settings')->name("admin.settings.pterodactyl.setup"); Route::post('settings/update','Admin\SettingsController@save')->middleware('permission:edit settings')->name("admin.settings.save"); diff --git a/routes/web.php b/routes/web.php index d2dd7ec1..d2bfc28f 100755 --- a/routes/web.php +++ b/routes/web.php @@ -20,7 +20,7 @@ Route::get('/', 'HomeController@index')->name("store.index"); Route::get('/category/{category}', 'HomeController@showCategory')->name("store.category"); -Route::post('/payment-complete', 'HomeController@paymentDone')->name("store.paymentdone"); +Route::get('/payment-complete', 'HomeController@paymentDone')->name("store.paymentdone"); Route::get('paypal/','PayPalTestController@index')->name('paypal'); Route::get('paypal/ipn','PayPalTestController@paypalIpn')->name('paypal.ipn'); diff --git a/storage/settings.json b/storage/settings.json index 84cbafcb..06518f77 100755 --- a/storage/settings.json +++ b/storage/settings.json @@ -1 +1 @@ -{"theme":"buycraft","admin":{"url":"admin"},"home_title":"MinePoS","home_desc":"

    Demo MinePoS Store :)<\/p>","pterodactyl_link":"https:\/\/pterodactyl.minepos.net\/api\/","pterodactyl_key":"80qqDg8mdN3x3sqOdybDxwq7QpLOld1TY4zwxKMX7sFx0hNe","pterodactyl_appkey":"f5sUq0FcHL4NxlhbEsRRlZXhdThNecF9MBTVIKXXpeXBlrg7","PayPalSecret":"EAt5VBV3ae789prQ2xtltU6F17sQVPaXljXTHPOlHB8WLvQuKsAGWlcwhWiNE70ggXe-xCn9IqCe0tWN","PayPalClientID":"AWQMJBcuVcbMwVTYilN_fpB9M6cNxFZ7U5T0J-ATrfDbUrRkeVDP45iEYoxnpn-Hw9F_ALewAwrxkq0e","paypal_email":"seller@minepos.net"} \ No newline at end of file +{"theme":"buycraft","admin":{"url":"admin"},"home_title":"MinePoS","home_desc":"

    Demo MinePoS Store :)<\/p>","pterodactyl_link":"https:\/\/pterodactyl.minepos.net\/api\/","pterodactyl_key":"YPxmLf1k5a6v1LcLClvIkHeoaCvYKcm1donvgWDhq71gJlWb","pterodactyl_appkey":"r8JzVF4JKJj2GaM94snLNhMSq1YrRi89WIJVCnAyxq8jV6JK","PayPalSecret":"EAt5VBV3ae789prQ2xtltU6F17sQVPaXljXTHPOlHB8WLvQuKsAGWlcwhWiNE70ggXe-xCn9IqCe0tWN","PayPalClientID":"AWQMJBcuVcbMwVTYilN_fpB9M6cNxFZ7U5T0J-ATrfDbUrRkeVDP45iEYoxnpn-Hw9F_ALewAwrxkq0e","paypal_email":"seller@minepos.net","DISCORD_LOGIN_WEBHOOK":"https:\/\/discordapp.com\/api\/webhooks\/414863378188599314\/ooz3EkkWBWUHRz2YtAll1IafYgeAFSF31uc1IO6FPuJhjeVH8JiNTvbrT-URgdD-18WJ","DISCORD_ORDER_WEBHOOK":"https:\/\/discordapp.com\/api\/webhooks\/423094221914767370\/FNvJAzz6u4ra8UUgx3II-p2drhH-ADOZp0fbRgDwkXR0zCluU_1wG47US9P3z0anxvVO","DISCORD_LOGIN_ENABLED":true,"DISCORD_ORDER_ENABLED":true} \ No newline at end of file