xoco70 /
kendozone
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | /** |
||
| 5 | * Set a flash message in the session. |
||
| 6 | * |
||
| 7 | * @param string $message |
||
| 8 | * @return void |
||
| 9 | */ |
||
| 10 | function flash($message = null) |
||
| 11 | { |
||
| 12 | 19 | $flash = app('App\Http\Flash'); |
|
| 13 | 19 | if (func_num_args() == 0) { |
|
| 14 | 19 | return $flash; |
|
| 15 | } |
||
| 16 | return $flash->info($message); |
||
| 17 | // session()->flash($state, $message); |
||
| 18 | } |
||
| 19 | |||
| 20 | function isNullOrEmptyString($param) |
||
| 21 | { |
||
| 22 | 9 | return (!isset($param) || $param == null || trim($param) === ''); |
|
| 23 | } |
||
| 24 | |||
| 25 | function sanitize($string, $force_lowercase = true, $anal = false) |
||
| 26 | { |
||
| 27 | $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", |
||
| 28 | "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", |
||
| 29 | "—", "–", ",", "<", ".", ">", "/", "?"); |
||
| 30 | $clean = trim(str_replace($strip, "", strip_tags($string))); |
||
| 31 | $clean = preg_replace('/\s+/', "-", $clean); |
||
| 32 | $clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean; |
||
| 33 | return ($force_lowercase) ? |
||
| 34 | (function_exists('mb_strtolower')) ? |
||
| 35 | mb_strtolower($clean, 'UTF-8') : |
||
| 36 | strtolower($clean) : |
||
| 37 | $clean; |
||
| 38 | } |
||
| 39 | |||
| 40 | function isJapanese($lang) |
||
| 41 | { |
||
| 42 | return preg_match('/[\x{4E00}-\x{9FBF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}]/u', $lang); |
||
| 43 | } |
||
| 44 | |||
| 45 | function isKorean($lang) |
||
| 46 | { |
||
| 47 | return preg_match('/[\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]/u', $lang); |
||
| 48 | } |
||
| 49 | |||
| 50 | |||
| 51 | // DB Helper |
||
| 52 | |||
| 53 | function setFKCheckOff() |
||
| 54 | { |
||
| 55 | 49 | switch (DB::getDriverName()) { |
|
| 56 | 49 | case 'mysql': |
|
| 57 | DB::statement('SET FOREIGN_KEY_CHECKS=0'); |
||
| 58 | break; |
||
| 59 | 49 | case 'sqlite': |
|
| 60 | 49 | DB::statement('PRAGMA foreign_keys = OFF'); |
|
| 61 | 49 | break; |
|
| 62 | } |
||
| 63 | 49 | } |
|
| 64 | |||
| 65 | function setFKCheckOn() |
||
| 66 | { |
||
| 67 | 49 | switch (DB::getDriverName()) { |
|
| 68 | 49 | case 'mysql': |
|
| 69 | DB::statement('SET FOREIGN_KEY_CHECKS=1'); |
||
| 70 | break; |
||
| 71 | 49 | case 'sqlite': |
|
| 72 | 49 | DB::statement('PRAGMA foreign_keys = ON'); |
|
| 73 | 49 | break; |
|
| 74 | } |
||
| 75 | 49 | } |
|
| 76 | |||
| 77 | function internet_connected() |
||
| 78 | { |
||
| 79 | 29 | $is_conn = false; |
|
| 80 | 29 | $connected = @fsockopen("www.google.com", 443); |
|
| 81 | 29 | if ($connected){ |
|
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 82 | 29 | $is_conn = true; |
|
| 83 | 29 | fclose($connected); |
|
| 84 | } |
||
| 85 | 29 | return $is_conn; |
|
| 86 | |||
| 87 | } |
||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 |