diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 6a40fd1..bd3dd25 100755 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -788,6 +788,45 @@ function sendSMSText($number, $content) return $result; } +/*** + * send sms + * @param string $number phone number + * @param string $content sms content + * @return bool|string + */ +function sendSMSText2($number, $content) +{ + + $url = 'http://ara11.ir:3002/api/v1/send'; + + $options = array( + 'content-type' => 'application/x-www-form-urlencoded', + 'cache-control' => 'no-cache' + ); + $fields_string = http_build_query(array( + 'user' => 'mahyar', + 'password' => 'MahGold;123', + 'number' => $number, + 'text' => $content, + 'isflash' => 'false' + )); + +//open connection + $ch = curl_init(); + +//set the url, number of POST vars, POST data + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); + +//So that curl_exec returns the contents of the cURL; rather than echoing it + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + +//execute post + $result = curl_exec($ch); + return json_decode($result,true); +} + /*** * remove title of html code * @param $str diff --git a/app/Http/Controllers/Admin/XlangController.php b/app/Http/Controllers/Admin/XlangController.php index c5dd3ff..818cfd1 100644 --- a/app/Http/Controllers/Admin/XlangController.php +++ b/app/Http/Controllers/Admin/XlangController.php @@ -6,6 +6,8 @@ use App\Http\Controllers\Controller; use App\Http\Requests\XlangSaveRequest; use App\Models\Xlang; use Illuminate\Http\Request; +use GuzzleHttp\Client; + use Illuminate\Support\Facades\Artisan; use function Xmen\StarterKit\Helpers\logAdmin; use function Xmen\StarterKit\Helpers\logAdminBatch; @@ -148,6 +150,25 @@ class XlangController extends Controller define("TRANSLATE_FILE", PREFIX_PATH . 'resources/lang/' . $tag . '.json'); return response()->download(TRANSLATE_FILE, $tag . '.json'); } + public function ai($tag) + { + +// set_time_limit(300); + + define("TRANSLATE_FILE", PREFIX_PATH . 'resources/lang/' . $tag . '.json'); + $file = file_get_contents(TRANSLATE_FILE); + $url = 'http://5.255.98.77:3001/json?form=en&to='.$tag; + + $client = new Client([ + 'headers' => [ 'Content-Type' => 'application/json' ] + ]); + + $response = $client->post($url, + ['body' => $file] + ); + file_put_contents(TRANSLATE_FILE,$response->getBody()); + return redirect()->back()->with(['message' => __("Translated by ai xstack service:").' '.$tag]); + } public function upload($tag, Request $request) { diff --git a/resources/views/admin/langs/translateIndex.blade.php b/resources/views/admin/langs/translateIndex.blade.php index bc91554..c4845bd 100755 --- a/resources/views/admin/langs/translateIndex.blade.php +++ b/resources/views/admin/langs/translateIndex.blade.php @@ -28,7 +28,10 @@ {{__("Upload file")}} - + + + {{__("Translate with AI")}} + @endforeach diff --git a/routes/web.php b/routes/web.php index 74ba017..15fc42a 100755 --- a/routes/web.php +++ b/routes/web.php @@ -41,6 +41,7 @@ Route::prefix(config('starter-kit.uri'))->name('admin.')->group( Route::post('/update/{xlang}', [\App\Http\Controllers\Admin\XlangController::class,'update'])->name('update'); Route::post('bulk', [\App\Http\Controllers\Admin\XlangController::class, "bulk"])->name('bulk'); Route::get('/download/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'download'])->name('download'); + Route::get('/ai/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'ai'])->name('ai'); Route::post('/upload/{tag}', [\App\Http\Controllers\Admin\XlangController::class,'upload'])->name('upload'); }); @@ -289,6 +290,24 @@ Route::get('/resetStock', [App\Http\Controllers\WebsiteController::class, "reset Route::get('/resetQ', [App\Http\Controllers\WebsiteController::class, "resetQuantity"])->name('resetQuantity'); Route::get('/credit/pay/{invoice}', [App\Http\Controllers\CustomerController::class, 'credit'])->name('credit'); +Route::get('/test/sms',function (){ + if (auth()->check()){ + $result = \App\Helpers\sendSMSText2('09209517726','پیامک'); + if ($result == null){ + return 'fatal error'; + }else{ + if ($result['OK']){ + return $result['Msg']; + }else{ + return 'err'.$result['Code'].': '.$result['Msg']; + } + } + } else{ + return abort(403); + } +}); + + //Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); if (\App\Helpers\getSetting('redirect') == 'yes') { Route::get('{any}', [\App\Http\Controllers\RedirectController::class, 'check'])->where('any', '.*');