@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function login(Request $request) |
| 22 | 22 | { |
| 23 | - session(['laralang.password' => Crypt::encrypt($request->input('password'))]); |
|
| 23 | + session([ 'laralang.password' => Crypt::encrypt($request->input('password')) ]); |
|
| 24 | 24 | if (Crypt::decrypt(session('laralang.password')) != config('laralang.default.password')) { |
| 25 | 25 | return redirect(Route('laralang::login')) |
| 26 | 26 | ->with('status', 'Invalid password'); |
@@ -5,38 +5,38 @@ |
||
| 5 | 5 | class MymemoryTrans extends Translation |
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | - * Get translation from mymemory API. |
|
| 9 | - */ |
|
| 10 | - public function main() |
|
| 11 | - { |
|
| 12 | - $host = 'api.mymemory.translated.net'; |
|
| 13 | - |
|
| 14 | - // Check if host is online. |
|
| 15 | - if ($this->checkHost($host)) { |
|
| 16 | - |
|
| 17 | - // Host online |
|
| 18 | - $urlString = urlencode($this->string); |
|
| 19 | - $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
| 20 | - $data = json_decode($urldata, true); |
|
| 21 | - |
|
| 22 | - if ($data['responseStatus'] != 200) { |
|
| 23 | - if ($this->debug == true) { |
|
| 24 | - if ($data['responseStatus'] == 403) { |
|
| 25 | - $details = ($data['responseDetails']); |
|
| 26 | - } else { |
|
| 27 | - $details = $data['responseDetails']; |
|
| 28 | - } |
|
| 29 | - $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - return; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - $this->translation = $data['responseData']['translatedText']; |
|
| 36 | - |
|
| 37 | - $this->checkSave(); |
|
| 38 | - |
|
| 39 | - return; |
|
| 40 | - } |
|
| 41 | - } |
|
| 8 | + * Get translation from mymemory API. |
|
| 9 | + */ |
|
| 10 | + public function main() |
|
| 11 | + { |
|
| 12 | + $host = 'api.mymemory.translated.net'; |
|
| 13 | + |
|
| 14 | + // Check if host is online. |
|
| 15 | + if ($this->checkHost($host)) { |
|
| 16 | + |
|
| 17 | + // Host online |
|
| 18 | + $urlString = urlencode($this->string); |
|
| 19 | + $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to"); |
|
| 20 | + $data = json_decode($urldata, true); |
|
| 21 | + |
|
| 22 | + if ($data['responseStatus'] != 200) { |
|
| 23 | + if ($this->debug == true) { |
|
| 24 | + if ($data['responseStatus'] == 403) { |
|
| 25 | + $details = ($data['responseDetails']); |
|
| 26 | + } else { |
|
| 27 | + $details = $data['responseDetails']; |
|
| 28 | + } |
|
| 29 | + $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>'; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + $this->translation = $data['responseData']['translatedText']; |
|
| 36 | + |
|
| 37 | + $this->checkSave(); |
|
| 38 | + |
|
| 39 | + return; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // Checking response status |
| 23 | 23 | |
| 24 | - if ($data['responseStatus'] != 200) { |
|
| 24 | + if ($data[ 'responseStatus' ] != 200) { |
|
| 25 | 25 | if ($this->debug === true) { |
| 26 | - $this->translation = "<font style='color:red;'>Error ".$data['responseStatus'].': '.$data['responseDetails'].'</font>'; |
|
| 26 | + $this->translation = "<font style='color:red;'>Error ".$data[ 'responseStatus' ].': '.$data[ 'responseDetails' ].'</font>'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $transObtained = $data['responseData']['translatedText']; |
|
| 32 | + $transObtained = $data[ 'responseData' ][ 'translatedText' ]; |
|
| 33 | 33 | |
| 34 | 34 | $this->translation = ucfirst(strtolower(trim(str_replace('*', ' ', $transObtained)))); |
| 35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $words = explode(' ', $transObtained); |
| 41 | 41 | foreach ($words as $word) { |
| 42 | 42 | if ($word != '') { |
| 43 | - if ($word[0] == '*') { |
|
| 43 | + if ($word[ 0 ] == '*') { |
|
| 44 | 44 | $errors = $errors.substr($word, 1).', '; |
| 45 | 45 | } |
| 46 | 46 | } |