@artilingo/artiframe-cli 1.4.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core-stubs/bin/SystemMethod.php +600 -521
- package/core-stubs/bin/ViewMethod.php +591 -393
- package/core-stubs/docs/de.html +4347 -4390
- package/core-stubs/docs/en.html +4347 -4389
- package/core-stubs/docs/es.html +4347 -4390
- package/core-stubs/docs/fr.html +4347 -4389
- package/core-stubs/docs/tr.html +138 -109
- package/package.json +1 -1
- package/src/App.php +8 -0
- package/src/Commands/AddCommand.php +1 -1
- package/src/Commands/ListCommand.php +2 -1
- package/src/Commands/MakeApiCommand.php +1 -1
- package/src/Commands/MakeClassCommand.php +1 -1
- package/src/Commands/MakeViewCommand.php +1 -1
- package/src/Commands/NewProjectCommand.php +37 -25
- package/src/Commands/RemoveCommand.php +21 -10
- package/src/Commands/ServeCommand.php +29 -9
- package/src/Commands/TableCommand.php +2 -1
- package/src/Commands/UpgradeCommand.php +209 -0
- package/src/Commands/VersionCommand.php +2 -1
- package/src/Lang/de.php +7 -1
- package/src/Lang/en.php +6 -0
- package/src/Lang/es.php +7 -1
- package/src/Lang/fr.php +6 -0
- package/src/Lang/tr.php +7 -1
- package/src/Services/Safeguard.php +25 -0
- package/stubs/service/image.stub +334 -334
- package/stubs/service/iyzico.stub +637 -637
- package/stubs/service/jwt.stub +312 -312
- package/stubs/service/phpmailer.stub +143 -143
- package/stubs/service/pusher.stub +232 -232
- package/stubs/service/qrcode.stub +169 -169
- package/stubs/service/redis.stub +361 -361
- package/stubs/service/s3.stub +377 -377
- package/stubs/service/sentry.stub +76 -106
- package/stubs/service/stripe.stub +526 -526
- package/stubs/service/twilio.stub +361 -361
- package/core-stubs/app/R2Manager.php +0 -130
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<?php
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* ArtiFrame Core Engine
|
|
4
5
|
*
|
|
@@ -12,632 +13,710 @@
|
|
|
12
13
|
* and remain open-source under the AGPLv3 license.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
|
-
namespace Bin
|
|
16
|
-
|
|
17
|
-
class SystemMethod
|
|
18
|
-
{
|
|
19
|
-
/**
|
|
20
|
-
* E-posta adresinin format olarak geçerli olup olmadığını doğrular.
|
|
21
|
-
*
|
|
22
|
-
* @param string $email Doğrulanacak E-Posta
|
|
23
|
-
* @return bool
|
|
24
|
-
*/
|
|
25
|
-
public static function verifyEmail(string $email): bool
|
|
26
|
-
{
|
|
27
|
-
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
|
28
|
-
}
|
|
16
|
+
namespace Bin {
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
* Gelen veriyi güvenli bir Integer (tam sayı) değerine dönüştürür.
|
|
32
|
-
* Harfleri siler ve sayısal karakter bırakır.
|
|
33
|
-
*
|
|
34
|
-
* @param mixed $value
|
|
35
|
-
* @return int
|
|
36
|
-
*/
|
|
37
|
-
public static function sanitizeInt($value): int
|
|
18
|
+
class SystemMethod
|
|
38
19
|
{
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
/**
|
|
21
|
+
* E-posta adresinin format olarak geçerli olup olmadığını doğrular.
|
|
22
|
+
*
|
|
23
|
+
* @param string $email Doğrulanacak E-Posta
|
|
24
|
+
* @return bool
|
|
25
|
+
*/
|
|
26
|
+
public static function verifyEmail(string $email): bool
|
|
27
|
+
{
|
|
28
|
+
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
|
|
29
|
+
}
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Gelen veriyi güvenli bir Integer (tam sayı) değerine dönüştürür.
|
|
33
|
+
* Harfleri siler ve sayısal karakter bırakır.
|
|
34
|
+
*
|
|
35
|
+
* @param mixed $value
|
|
36
|
+
* @return int
|
|
37
|
+
*/
|
|
38
|
+
public static function sanitizeInt($value): int
|
|
39
|
+
{
|
|
40
|
+
return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
|
41
|
+
}
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Gelen verideki HTML etiketlerini ve zararlı kodları temizler.
|
|
45
|
+
* Veritabanına String kaydetmeden önce mutlaka kullanılmalıdır.
|
|
46
|
+
*
|
|
47
|
+
* @param string $value
|
|
48
|
+
* @return string
|
|
49
|
+
*/
|
|
50
|
+
public static function sanitizeString(string $value): string
|
|
51
|
+
{
|
|
52
|
+
return strip_tags(trim($value));
|
|
53
|
+
}
|
|
63
54
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Sayfaya gelen isteğin bir form gönderimi (POST) olup olmadığını kontrol eder.
|
|
57
|
+
*
|
|
58
|
+
* @return bool
|
|
59
|
+
*/
|
|
60
|
+
public static function isPost(): bool
|
|
61
|
+
{
|
|
62
|
+
return $_SERVER['REQUEST_METHOD'] === 'POST';
|
|
71
63
|
}
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Oturum (Session) tabanlı CSRF (Cross-Site Request Forgery) güvenlik token'ı üretir.
|
|
67
|
+
*/
|
|
68
|
+
public static function generateCsrf(): string
|
|
69
|
+
{
|
|
70
|
+
if (session_status() === PHP_SESSION_NONE) {
|
|
71
|
+
session_start();
|
|
72
|
+
}
|
|
73
|
+
if (empty($_SESSION['csrf_token'])) {
|
|
74
|
+
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
75
|
+
}
|
|
76
|
+
return $_SESSION['csrf_token'];
|
|
74
77
|
}
|
|
75
|
-
return $_SESSION['csrf_token'];
|
|
76
|
-
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Formdan gelen CSRF token'ın doğruluğunu onaylar. (Form güvenlik kalkanı)
|
|
81
|
+
*/
|
|
82
|
+
public static function verifyCsrf(?string $token): bool
|
|
83
|
+
{
|
|
84
|
+
if (session_status() === PHP_SESSION_NONE) {
|
|
85
|
+
session_start();
|
|
86
|
+
}
|
|
87
|
+
if (empty($_SESSION['csrf_token']) || empty($token)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return hash_equals($_SESSION['csrf_token'], $token);
|
|
85
91
|
}
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* İsteğin AJAX üzerinden gelip gelmediğini kontrol eder. (Fetch / Axios destekli)
|
|
95
|
+
*/
|
|
96
|
+
public static function isAjax(): bool
|
|
97
|
+
{
|
|
98
|
+
return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
|
|
88
99
|
}
|
|
89
|
-
return hash_equals($_SESSION['csrf_token'], $token);
|
|
90
|
-
}
|
|
91
100
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
/**
|
|
102
|
+
* API'ler için hızlı ve standart JSON yanıt (response) oluşturur.
|
|
103
|
+
* Kullanıldığı anda işlemi sonlandırır (exit).
|
|
104
|
+
*
|
|
105
|
+
* @param array $data JSON'a çevrilecek dizi (array)
|
|
106
|
+
* @param int $statusCode HTTP Durum Kodu (200 OK, 404 Not Found vb.)
|
|
107
|
+
*/
|
|
108
|
+
public static function jsonResponse(array $data, int $statusCode = 200): void
|
|
109
|
+
{
|
|
110
|
+
http_response_code($statusCode);
|
|
111
|
+
header('Content-Type: application/json; charset=utf-8');
|
|
112
|
+
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
113
|
+
exit;
|
|
114
|
+
}
|
|
99
115
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
112
|
-
exit;
|
|
113
|
-
}
|
|
116
|
+
/**
|
|
117
|
+
* Standart API yanıtı (JSON) oluşturur.
|
|
118
|
+
* APP_ENV = 1 (Debug) ise Exception detaylarını mesaja yazar.
|
|
119
|
+
* APP_ENV = 0 (Prod) ise kullanıcının girdiği temiz mesajı gösterir.
|
|
120
|
+
*/
|
|
121
|
+
public static function apiResponse(string $status, string $message, array $data = [], \Throwable $exception = null): void
|
|
122
|
+
{
|
|
123
|
+
// Debug modundaysak ve bir exception geldiyse, mesajı ezip sistem hatasını basıyoruz
|
|
124
|
+
if (defined('APP_ENV') && APP_ENV === 1 && $exception !== null) {
|
|
125
|
+
$message = $exception->getMessage() . ' (Dosya: ' . $exception->getFile() . ' Satır: ' . $exception->getLine() . ')';
|
|
126
|
+
}
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (defined('APP_ENV') && APP_ENV === 1 && $exception !== null) {
|
|
124
|
-
$message = $exception->getMessage() . ' (Dosya: ' . $exception->getFile() . ' Satır: ' . $exception->getLine() . ')';
|
|
128
|
+
$response = [
|
|
129
|
+
'status' => $status,
|
|
130
|
+
'message' => $message,
|
|
131
|
+
'data' => $data
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
$statusCode = ($status === 'success') ? 200 : 400;
|
|
135
|
+
self::jsonResponse($response, $statusCode);
|
|
125
136
|
}
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Sayfaya gelen isteğin GET olup olmadığını kontrol eder.
|
|
140
|
+
*/
|
|
141
|
+
public static function isGet(): bool
|
|
142
|
+
{
|
|
143
|
+
return $_SERVER['REQUEST_METHOD'] === 'GET';
|
|
144
|
+
}
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Sayfaya gelen isteğin PUT olup olmadığını kontrol eder.
|
|
148
|
+
*/
|
|
149
|
+
public static function isPut(): bool
|
|
150
|
+
{
|
|
151
|
+
return $_SERVER['REQUEST_METHOD'] === 'PUT';
|
|
152
|
+
}
|
|
136
153
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Sayfaya gelen isteğin DELETE olup olmadığını kontrol eder.
|
|
156
|
+
*/
|
|
157
|
+
public static function isDelete(): bool
|
|
158
|
+
{
|
|
159
|
+
return $_SERVER['REQUEST_METHOD'] === 'DELETE';
|
|
160
|
+
}
|
|
144
161
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Kullanıcının gerçek IP adresini tespit eder (Cloudflare ve Proxy destekli).
|
|
164
|
+
*/
|
|
165
|
+
public static function getClientIp(): string
|
|
166
|
+
{
|
|
167
|
+
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
|
|
168
|
+
return $_SERVER['HTTP_CF_CONNECTING_IP'];
|
|
169
|
+
}
|
|
170
|
+
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
|
171
|
+
return $_SERVER['HTTP_CLIENT_IP'];
|
|
172
|
+
}
|
|
173
|
+
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
|
174
|
+
$ipList = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
|
175
|
+
return trim($ipList[0]);
|
|
176
|
+
}
|
|
177
|
+
return $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
|
178
|
+
}
|
|
152
179
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
/**
|
|
181
|
+
* İstenilen sayfaya yönlendirme yapar ve çalışmayı durdurur.
|
|
182
|
+
*/
|
|
183
|
+
public static function redirect(string $url): void
|
|
184
|
+
{
|
|
185
|
+
header("Location: " . $url);
|
|
186
|
+
exit;
|
|
187
|
+
}
|
|
160
188
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return $_SERVER['HTTP_CF_CONNECTING_IP'];
|
|
189
|
+
/**
|
|
190
|
+
* Kriptografik olarak güvenli, rastgele bir token üretir (Örn: Parola sıfırlama, API Key).
|
|
191
|
+
*/
|
|
192
|
+
public static function generateToken(int $length = 32): string
|
|
193
|
+
{
|
|
194
|
+
return bin2hex(random_bytes($length));
|
|
168
195
|
}
|
|
169
|
-
|
|
170
|
-
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Şifreyi bcrypt algoritmasıyla güvenli bir şekilde hash'ler.
|
|
199
|
+
* Boş veya null gelirse güvenliği sağlamak adına exception fırlatır.
|
|
200
|
+
*/
|
|
201
|
+
public static function hashPassword(?string $password): string
|
|
202
|
+
{
|
|
203
|
+
if (empty($password)) {
|
|
204
|
+
throw new \Exception('Password cannot be empty or null.');
|
|
205
|
+
}
|
|
206
|
+
return password_hash($password, PASSWORD_BCRYPT);
|
|
171
207
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Düz metin şifreyi veritabanındaki hash ile karşılaştırır.
|
|
211
|
+
* Herhangi biri null veya boşsa her zaman false döner.
|
|
212
|
+
*/
|
|
213
|
+
public static function verifyPassword(?string $password, ?string $hash): bool
|
|
214
|
+
{
|
|
215
|
+
if (empty($password) || empty($hash)) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return password_verify($password, $hash);
|
|
175
219
|
}
|
|
176
|
-
return $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
|
|
177
|
-
}
|
|
178
220
|
|
|
179
|
-
/**
|
|
180
|
-
* İstenilen sayfaya yönlendirme yapar ve çalışmayı durdurur.
|
|
181
|
-
*/
|
|
182
|
-
public static function redirect(string $url): void
|
|
183
|
-
{
|
|
184
|
-
header("Location: " . $url);
|
|
185
|
-
exit;
|
|
186
|
-
}
|
|
187
221
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
222
|
+
/**
|
|
223
|
+
* E-posta adresini zararlı karakterlerden temizler.
|
|
224
|
+
*/
|
|
225
|
+
public static function sanitizeEmail(string $email): string
|
|
226
|
+
{
|
|
227
|
+
return filter_var($email, FILTER_SANITIZE_EMAIL);
|
|
228
|
+
}
|
|
195
229
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
throw new \Exception('Password cannot be empty or null.');
|
|
230
|
+
/**
|
|
231
|
+
* Gelen veriyi güvenli bir ondalıklı (float) sayıya dönüştürür.
|
|
232
|
+
* Fiyat ve oran hesaplamalarında kullanılır.
|
|
233
|
+
*/
|
|
234
|
+
public static function sanitizeFloat($value): float
|
|
235
|
+
{
|
|
236
|
+
return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
|
204
237
|
}
|
|
205
|
-
return password_hash($password, PASSWORD_BCRYPT);
|
|
206
|
-
}
|
|
207
238
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return false;
|
|
239
|
+
/**
|
|
240
|
+
* Bir diziden sadece belirtilen anahtarlara (keys) sahip olanları seçer.
|
|
241
|
+
* Güvenli mass-assignment (toplu atama) için kullanılır.
|
|
242
|
+
*/
|
|
243
|
+
public static function arrayOnly(array $source, array $keys): array
|
|
244
|
+
{
|
|
245
|
+
return array_intersect_key($source, array_flip($keys));
|
|
216
246
|
}
|
|
217
|
-
return password_verify($password, $hash);
|
|
218
|
-
}
|
|
219
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Hızlı hata ayıklama aracı. (Dump & Die)
|
|
250
|
+
*/
|
|
251
|
+
public static function dd(...$vars): void
|
|
252
|
+
{
|
|
253
|
+
echo '<pre style="background:#1d232a;color:#a6adbb;padding:16px;border-radius:8px;font-size:14px;overflow-x:auto;z-index:9999;position:relative;">';
|
|
254
|
+
foreach ($vars as $var) {
|
|
255
|
+
var_dump($var);
|
|
256
|
+
}
|
|
257
|
+
echo '</pre>';
|
|
258
|
+
exit;
|
|
259
|
+
}
|
|
220
260
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Metni URL dostu bir slug'a çevirir (Örn: "Utku", "Egemen" -> "utku-egemen")
|
|
263
|
+
* (SystemMethod için global kullanılabilir versiyon)
|
|
264
|
+
*/
|
|
265
|
+
public static function slugify(string ...$texts): string
|
|
266
|
+
{
|
|
267
|
+
$text = implode('-', $texts);
|
|
268
|
+
$text = mb_strtolower($text, 'UTF-8');
|
|
269
|
+
|
|
270
|
+
$search = [
|
|
271
|
+
'ç',
|
|
272
|
+
'ğ',
|
|
273
|
+
'ı',
|
|
274
|
+
'ö',
|
|
275
|
+
'ş',
|
|
276
|
+
'ü', // TR
|
|
277
|
+
'ä',
|
|
278
|
+
'ß', // DE
|
|
279
|
+
'ñ', // ES
|
|
280
|
+
'é',
|
|
281
|
+
'è',
|
|
282
|
+
'ê',
|
|
283
|
+
'ë',
|
|
284
|
+
'à',
|
|
285
|
+
'á',
|
|
286
|
+
'â',
|
|
287
|
+
'î',
|
|
288
|
+
'ï',
|
|
289
|
+
'í',
|
|
290
|
+
'ô',
|
|
291
|
+
'ó',
|
|
292
|
+
'ú',
|
|
293
|
+
'û',
|
|
294
|
+
'ù',
|
|
295
|
+
'æ',
|
|
296
|
+
'œ' // FR & ES
|
|
297
|
+
];
|
|
298
|
+
$replace = [
|
|
299
|
+
'c',
|
|
300
|
+
'g',
|
|
301
|
+
'i',
|
|
302
|
+
'o',
|
|
303
|
+
's',
|
|
304
|
+
'u',
|
|
305
|
+
'ae',
|
|
306
|
+
'ss',
|
|
307
|
+
'n',
|
|
308
|
+
'e',
|
|
309
|
+
'e',
|
|
310
|
+
'e',
|
|
311
|
+
'e',
|
|
312
|
+
'a',
|
|
313
|
+
'a',
|
|
314
|
+
'a',
|
|
315
|
+
'i',
|
|
316
|
+
'i',
|
|
317
|
+
'i',
|
|
318
|
+
'o',
|
|
319
|
+
'o',
|
|
320
|
+
'u',
|
|
321
|
+
'u',
|
|
322
|
+
'u',
|
|
323
|
+
'ae',
|
|
324
|
+
'oe'
|
|
325
|
+
];
|
|
326
|
+
|
|
327
|
+
$text = str_replace($search, $replace, $text);
|
|
328
|
+
$text = preg_replace('/[^a-z0-9\-]/', '-', $text);
|
|
329
|
+
$text = preg_replace('/-+/', '-', $text);
|
|
330
|
+
return trim($text, '-');
|
|
331
|
+
}
|
|
228
332
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
333
|
+
/**
|
|
334
|
+
* Natively generates a raw 16-byte binary UUIDv7.
|
|
335
|
+
* Ideal for BINARY(16) database columns (High performance indexing).
|
|
336
|
+
*
|
|
337
|
+
* @return string 16-byte raw binary string
|
|
338
|
+
*/
|
|
339
|
+
public static function byteId(): string
|
|
340
|
+
{
|
|
341
|
+
// Get current timestamp in milliseconds (48-bit)
|
|
342
|
+
$ts = (int)(microtime(true) * 1000);
|
|
343
|
+
$timeHex = str_pad(dechex($ts), 12, '0', STR_PAD_LEFT);
|
|
344
|
+
$timeBin = hex2bin($timeHex);
|
|
345
|
+
|
|
346
|
+
// Generate 10 bytes of randomness
|
|
347
|
+
$rand = random_bytes(10);
|
|
348
|
+
|
|
349
|
+
// Set UUID Version (7) -> 4 bits of the 7th byte
|
|
350
|
+
$rand[0] = chr((ord($rand[0]) & 0x0F) | 0x70);
|
|
351
|
+
|
|
352
|
+
// Set UUID Variant (10) -> 2 bits of the 9th byte
|
|
353
|
+
$rand[2] = chr((ord($rand[2]) & 0x3F) | 0x80);
|
|
354
|
+
|
|
355
|
+
// Return exactly 16 bytes (6 bytes time + 10 bytes rand)
|
|
356
|
+
return $timeBin . $rand;
|
|
357
|
+
}
|
|
237
358
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Bi-directional UUID formatter (String <-> Binary)
|
|
361
|
+
*
|
|
362
|
+
* @param string $value 16-byte binary string OR 36-character UUID string
|
|
363
|
+
* @param string $to 'auto', 'binary', or 'string'
|
|
364
|
+
* @return string
|
|
365
|
+
*/
|
|
366
|
+
public static function formatId(string $value, string $to = 'auto'): string
|
|
367
|
+
{
|
|
368
|
+
// Target: Binary conversion (String -> Binary)
|
|
369
|
+
if ($to === 'binary' || ($to === 'auto' && strlen($value) !== 16)) {
|
|
370
|
+
$cleanHex = str_replace('-', '', $value);
|
|
371
|
+
|
|
372
|
+
if (strlen($cleanHex) !== 32) {
|
|
373
|
+
throw new \InvalidArgumentException("Invalid UUID string format.");
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return hex2bin($cleanHex);
|
|
377
|
+
}
|
|
246
378
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
379
|
+
// Target: String conversion (Binary -> String)
|
|
380
|
+
if (strlen($value) !== 16) {
|
|
381
|
+
throw new \InvalidArgumentException("Invalid binary UUID length. Expected 16 bytes.");
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
$hex = bin2hex($value);
|
|
385
|
+
|
|
386
|
+
return sprintf(
|
|
387
|
+
'%s-%s-%s-%s-%s',
|
|
388
|
+
substr($hex, 0, 8),
|
|
389
|
+
substr($hex, 8, 4),
|
|
390
|
+
substr($hex, 12, 4),
|
|
391
|
+
substr($hex, 16, 4),
|
|
392
|
+
substr($hex, 20, 12)
|
|
393
|
+
);
|
|
255
394
|
}
|
|
256
|
-
echo '</pre>';
|
|
257
|
-
exit;
|
|
258
|
-
}
|
|
259
395
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
$search = [
|
|
270
|
-
'ç', 'ğ', 'ı', 'ö', 'ş', 'ü', // TR
|
|
271
|
-
'ä', 'ß', // DE
|
|
272
|
-
'ñ', // ES
|
|
273
|
-
'é', 'è', 'ê', 'ë', 'à', 'á', 'â', 'î', 'ï', 'í', 'ô', 'ó', 'ú', 'û', 'ù', 'æ', 'œ' // FR & ES
|
|
274
|
-
];
|
|
275
|
-
$replace = [
|
|
276
|
-
'c', 'g', 'i', 'o', 's', 'u',
|
|
277
|
-
'ae', 'ss',
|
|
278
|
-
'n',
|
|
279
|
-
'e', 'e', 'e', 'e', 'a', 'a', 'a', 'i', 'i', 'i', 'o', 'o', 'u', 'u', 'u', 'ae', 'oe'
|
|
280
|
-
];
|
|
281
|
-
|
|
282
|
-
$text = str_replace($search, $replace, $text);
|
|
283
|
-
$text = preg_replace('/[^a-z0-9\-]/', '-', $text);
|
|
284
|
-
$text = preg_replace('/-+/', '-', $text);
|
|
285
|
-
return trim($text, '-');
|
|
286
|
-
}
|
|
396
|
+
/**
|
|
397
|
+
* Generates a standard formatted UUIDv7 string.
|
|
398
|
+
*
|
|
399
|
+
* @return string 36-character hyphenated UUID string
|
|
400
|
+
*/
|
|
401
|
+
public static function makeId(): string
|
|
402
|
+
{
|
|
403
|
+
return self::formatId(self::byteId());
|
|
404
|
+
}
|
|
287
405
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
{
|
|
296
|
-
// Get current timestamp in milliseconds (48-bit)
|
|
297
|
-
$ts = (int)(microtime(true) * 1000);
|
|
298
|
-
$timeHex = str_pad(dechex($ts), 12, '0', STR_PAD_LEFT);
|
|
299
|
-
$timeBin = hex2bin($timeHex);
|
|
300
|
-
|
|
301
|
-
// Generate 10 bytes of randomness
|
|
302
|
-
$rand = random_bytes(10);
|
|
303
|
-
|
|
304
|
-
// Set UUID Version (7) -> 4 bits of the 7th byte
|
|
305
|
-
$rand[0] = chr((ord($rand[0]) & 0x0F) | 0x70);
|
|
306
|
-
|
|
307
|
-
// Set UUID Variant (10) -> 2 bits of the 9th byte
|
|
308
|
-
$rand[2] = chr((ord($rand[2]) & 0x3F) | 0x80);
|
|
309
|
-
|
|
310
|
-
// Return exactly 16 bytes (6 bytes time + 10 bytes rand)
|
|
311
|
-
return $timeBin . $rand;
|
|
312
|
-
}
|
|
406
|
+
/**
|
|
407
|
+
* Rastgele Integer ID üretir. (Max 9 hane - MySQL INT sınırı)
|
|
408
|
+
*/
|
|
409
|
+
public static function intId(int $length = 8): int
|
|
410
|
+
{
|
|
411
|
+
if ($length > 9) $length = 9;
|
|
412
|
+
if ($length < 1) $length = 1;
|
|
313
413
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
*
|
|
317
|
-
* @param string $value 16-byte binary string OR 36-character UUID string
|
|
318
|
-
* @param string $to 'auto', 'binary', or 'string'
|
|
319
|
-
* @return string
|
|
320
|
-
*/
|
|
321
|
-
public static function formatId(string $value, string $to = 'auto'): string
|
|
322
|
-
{
|
|
323
|
-
// Target: Binary conversion (String -> Binary)
|
|
324
|
-
if ($to === 'binary' || ($to === 'auto' && strlen($value) !== 16)) {
|
|
325
|
-
$cleanHex = str_replace('-', '', $value);
|
|
326
|
-
|
|
327
|
-
if (strlen($cleanHex) !== 32) {
|
|
328
|
-
throw new \InvalidArgumentException("Invalid UUID string format.");
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return hex2bin($cleanHex);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Target: String conversion (Binary -> String)
|
|
335
|
-
if (strlen($value) !== 16) {
|
|
336
|
-
throw new \InvalidArgumentException("Invalid binary UUID length. Expected 16 bytes.");
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
$hex = bin2hex($value);
|
|
340
|
-
|
|
341
|
-
return sprintf(
|
|
342
|
-
'%s-%s-%s-%s-%s',
|
|
343
|
-
substr($hex, 0, 8),
|
|
344
|
-
substr($hex, 8, 4),
|
|
345
|
-
substr($hex, 12, 4),
|
|
346
|
-
substr($hex, 16, 4),
|
|
347
|
-
substr($hex, 20, 12)
|
|
348
|
-
);
|
|
349
|
-
}
|
|
414
|
+
$min = (int) str_pad('1', $length, '0');
|
|
415
|
+
$max = (int) str_pad('9', $length, '9');
|
|
350
416
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
*
|
|
354
|
-
* @return string 36-character hyphenated UUID string
|
|
355
|
-
*/
|
|
356
|
-
public static function makeId(): string
|
|
357
|
-
{
|
|
358
|
-
return self::formatId(self::byteId());
|
|
359
|
-
}
|
|
417
|
+
return random_int($min, $max);
|
|
418
|
+
}
|
|
360
419
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
$max = (int) str_pad('9', $length, '9');
|
|
371
|
-
|
|
372
|
-
return random_int($min, $max);
|
|
373
|
-
}
|
|
420
|
+
/**
|
|
421
|
+
* Rastgele BigInt ID üretir.
|
|
422
|
+
* Javascript MAX_SAFE_INTEGER (15 hane) sınırını aşmamak için varsayılan 15'tir.
|
|
423
|
+
* 16-18 hane istenirse veri kaybını önlemek için asString = true önerilir.
|
|
424
|
+
*/
|
|
425
|
+
public static function bigintId(int $length = 15, bool $asString = false)
|
|
426
|
+
{
|
|
427
|
+
if ($length > 18) $length = 18;
|
|
428
|
+
if ($length < 1) $length = 1;
|
|
374
429
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
* Javascript MAX_SAFE_INTEGER (15 hane) sınırını aşmamak için varsayılan 15'tir.
|
|
378
|
-
* 16-18 hane istenirse veri kaybını önlemek için asString = true önerilir.
|
|
379
|
-
*/
|
|
380
|
-
public static function bigintId(int $length = 15, bool $asString = false)
|
|
381
|
-
{
|
|
382
|
-
if ($length > 18) $length = 18;
|
|
383
|
-
if ($length < 1) $length = 1;
|
|
430
|
+
$min = str_pad('1', $length, '0');
|
|
431
|
+
$max = str_pad('9', $length, '9');
|
|
384
432
|
|
|
385
|
-
|
|
386
|
-
$max = str_pad('9', $length, '9');
|
|
433
|
+
$result = random_int((int)$min, (int)$max);
|
|
387
434
|
|
|
388
|
-
|
|
435
|
+
return $asString ? (string) $result : $result;
|
|
436
|
+
}
|
|
389
437
|
|
|
390
|
-
|
|
391
|
-
|
|
438
|
+
/**
|
|
439
|
+
* Sadece sayılardan oluşan rastgele bir OTP (One-Time Password) kodu üretir.
|
|
440
|
+
* @param int $length Hanelerin sayısı (Varsayılan 6)
|
|
441
|
+
*/
|
|
442
|
+
public static function otpInt(int $length = 6): int
|
|
443
|
+
{
|
|
444
|
+
if ($length < 1) $length = 1;
|
|
445
|
+
if ($length > 18) $length = 18; // PHP 64-bit safe max length
|
|
392
446
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
* @param int $length Hanelerin sayısı (Varsayılan 6)
|
|
396
|
-
*/
|
|
397
|
-
public static function otpInt(int $length = 6): int
|
|
398
|
-
{
|
|
399
|
-
if ($length < 1) $length = 1;
|
|
400
|
-
if ($length > 18) $length = 18; // PHP 64-bit safe max length
|
|
401
|
-
|
|
402
|
-
$min = (int) str_pad('1', $length, '0');
|
|
403
|
-
$max = (int) str_pad('9', $length, '9');
|
|
404
|
-
|
|
405
|
-
return random_int($min, $max);
|
|
406
|
-
}
|
|
447
|
+
$min = (int) str_pad('1', $length, '0');
|
|
448
|
+
$max = (int) str_pad('9', $length, '9');
|
|
407
449
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
* @param int $length Hanelerin sayısı (Varsayılan 6)
|
|
411
|
-
* @param string $case 'c': Sadece küçük, 'C': Sadece büyük, 'cC'/'Cc': Karışık
|
|
412
|
-
*/
|
|
413
|
-
public static function otpStr(int $length = 6, string $case = 'C'): string
|
|
414
|
-
{
|
|
415
|
-
$lower = 'abcdefghijklmnopqrstuvwxyz';
|
|
416
|
-
$upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
417
|
-
|
|
418
|
-
$chars = match (strtolower($case)) {
|
|
419
|
-
'c' => $lower,
|
|
420
|
-
'cc' => $lower . $upper,
|
|
421
|
-
default => $upper,
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
$otp = '';
|
|
425
|
-
$maxIndex = strlen($chars) - 1;
|
|
426
|
-
for ($i = 0; $i < $length; $i++) {
|
|
427
|
-
$otp .= $chars[random_int(0, $maxIndex)];
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return $otp;
|
|
431
|
-
}
|
|
450
|
+
return random_int($min, $max);
|
|
451
|
+
}
|
|
432
452
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
return $otp;
|
|
457
|
-
}
|
|
453
|
+
/**
|
|
454
|
+
* Sadece harflerden oluşan rastgele bir OTP kodu üretir.
|
|
455
|
+
* @param int $length Hanelerin sayısı (Varsayılan 6)
|
|
456
|
+
* @param string $case 'c': Sadece küçük, 'C': Sadece büyük, 'cC'/'Cc': Karışık
|
|
457
|
+
*/
|
|
458
|
+
public static function otpStr(int $length = 6, string $case = 'C'): string
|
|
459
|
+
{
|
|
460
|
+
$lower = 'abcdefghijklmnopqrstuvwxyz';
|
|
461
|
+
$upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
462
|
+
|
|
463
|
+
$chars = match (strtolower($case)) {
|
|
464
|
+
'c' => $lower,
|
|
465
|
+
'cc' => $lower . $upper,
|
|
466
|
+
default => $upper,
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
$otp = '';
|
|
470
|
+
$maxIndex = strlen($chars) - 1;
|
|
471
|
+
for ($i = 0; $i < $length; $i++) {
|
|
472
|
+
$otp .= $chars[random_int(0, $maxIndex)];
|
|
473
|
+
}
|
|
458
474
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
475
|
+
return $otp;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Harf ve sayılardan (Alphanumeric) oluşan rastgele bir OTP kodu üretir.
|
|
480
|
+
* @param int $length Hanelerin sayısı (Varsayılan 6)
|
|
481
|
+
* @param string $case 'c': Küçük+Sayı, 'C': Büyük+Sayı, 'cC'/'Cc': Karışık+Sayı
|
|
482
|
+
*/
|
|
483
|
+
public static function otpMix(int $length = 6, string $case = 'C'): string
|
|
484
|
+
{
|
|
485
|
+
$numbers = '0123456789';
|
|
486
|
+
$lower = 'abcdefghijklmnopqrstuvwxyz';
|
|
487
|
+
$upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
488
|
+
|
|
489
|
+
$chars = match (strtolower($case)) {
|
|
490
|
+
'c' => $numbers . $lower,
|
|
491
|
+
'cc' => $numbers . $lower . $upper,
|
|
492
|
+
default => $numbers . $upper,
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
$otp = '';
|
|
496
|
+
$maxIndex = strlen($chars) - 1;
|
|
497
|
+
for ($i = 0; $i < $length; $i++) {
|
|
498
|
+
$otp .= $chars[random_int(0, $maxIndex)];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return $otp;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Gelen veriyi (özellikle BigInt ID'leri) güvenli bir şekilde string'e çevirir.
|
|
506
|
+
* Javascript'te 15 haneyi aşan sayılardaki veri kaybını engellemek için
|
|
507
|
+
* View dosyalarında data-id=<?= stringer($id) ?> şeklinde kullanılır.
|
|
508
|
+
*/
|
|
509
|
+
public static function stringer($value): string
|
|
510
|
+
{
|
|
511
|
+
return (string) $value;
|
|
512
|
+
}
|
|
513
|
+
} // end class SystemMethod
|
|
514
|
+
|
|
515
|
+
} // end namespace Bin
|
|
469
516
|
|
|
470
517
|
// Global helper functions for backend methods
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
518
|
+
namespace {
|
|
519
|
+
|
|
520
|
+
if (!function_exists('verifyEmail')) {
|
|
521
|
+
function verifyEmail(string $email): bool
|
|
522
|
+
{
|
|
523
|
+
return \Bin\SystemMethod::verifyEmail($email);
|
|
524
|
+
}
|
|
474
525
|
}
|
|
475
|
-
}
|
|
476
526
|
|
|
477
|
-
if (!function_exists(
|
|
478
|
-
|
|
479
|
-
|
|
527
|
+
if (!function_exists('sanitizeInt')) {
|
|
528
|
+
function sanitizeInt($value): int
|
|
529
|
+
{
|
|
530
|
+
return \Bin\SystemMethod::sanitizeInt($value);
|
|
531
|
+
}
|
|
480
532
|
}
|
|
481
|
-
}
|
|
482
533
|
|
|
483
|
-
if (!function_exists(
|
|
484
|
-
|
|
485
|
-
|
|
534
|
+
if (!function_exists('sanitizeString')) {
|
|
535
|
+
function sanitizeString(string $value): string
|
|
536
|
+
{
|
|
537
|
+
return \Bin\SystemMethod::sanitizeString($value);
|
|
538
|
+
}
|
|
486
539
|
}
|
|
487
|
-
}
|
|
488
540
|
|
|
489
|
-
if (!function_exists(
|
|
490
|
-
|
|
491
|
-
|
|
541
|
+
if (!function_exists('isPost')) {
|
|
542
|
+
function isPost(): bool
|
|
543
|
+
{
|
|
544
|
+
return \Bin\SystemMethod::isPost();
|
|
545
|
+
}
|
|
492
546
|
}
|
|
493
|
-
}
|
|
494
547
|
|
|
495
|
-
if (!function_exists(
|
|
496
|
-
|
|
497
|
-
|
|
548
|
+
if (!function_exists('jsonResponse')) {
|
|
549
|
+
function jsonResponse(array $data, int $statusCode = 200): void
|
|
550
|
+
{
|
|
551
|
+
\Bin\SystemMethod::jsonResponse($data, $statusCode);
|
|
552
|
+
}
|
|
498
553
|
}
|
|
499
|
-
}
|
|
500
554
|
|
|
501
|
-
if (!function_exists(
|
|
502
|
-
|
|
503
|
-
|
|
555
|
+
if (!function_exists('apiResponse')) {
|
|
556
|
+
function apiResponse(string $status, string $message, array $data = [], \Throwable $exception = null): void
|
|
557
|
+
{
|
|
558
|
+
\Bin\SystemMethod::apiResponse($status, $message, $data, $exception);
|
|
559
|
+
}
|
|
504
560
|
}
|
|
505
|
-
}
|
|
506
561
|
|
|
507
|
-
if (!function_exists(
|
|
508
|
-
|
|
509
|
-
|
|
562
|
+
if (!function_exists('generateCsrf')) {
|
|
563
|
+
function generateCsrf(): string
|
|
564
|
+
{
|
|
565
|
+
return \Bin\SystemMethod::generateCsrf();
|
|
566
|
+
}
|
|
510
567
|
}
|
|
511
|
-
}
|
|
512
568
|
|
|
513
|
-
if (!function_exists(
|
|
514
|
-
|
|
515
|
-
|
|
569
|
+
if (!function_exists('verifyCsrf')) {
|
|
570
|
+
function verifyCsrf(?string $token): bool
|
|
571
|
+
{
|
|
572
|
+
return \Bin\SystemMethod::verifyCsrf($token);
|
|
573
|
+
}
|
|
516
574
|
}
|
|
517
|
-
}
|
|
518
575
|
|
|
519
|
-
if (!function_exists(
|
|
520
|
-
|
|
521
|
-
|
|
576
|
+
if (!function_exists('isAjax')) {
|
|
577
|
+
function isAjax(): bool
|
|
578
|
+
{
|
|
579
|
+
return \Bin\SystemMethod::isAjax();
|
|
580
|
+
}
|
|
522
581
|
}
|
|
523
|
-
}
|
|
524
582
|
|
|
525
|
-
if (!function_exists(
|
|
526
|
-
|
|
527
|
-
|
|
583
|
+
if (!function_exists('isGet')) {
|
|
584
|
+
function isGet(): bool
|
|
585
|
+
{
|
|
586
|
+
return \Bin\SystemMethod::isGet();
|
|
587
|
+
}
|
|
528
588
|
}
|
|
529
|
-
}
|
|
530
589
|
|
|
531
|
-
if (!function_exists(
|
|
532
|
-
|
|
533
|
-
|
|
590
|
+
if (!function_exists('isPut')) {
|
|
591
|
+
function isPut(): bool
|
|
592
|
+
{
|
|
593
|
+
return \Bin\SystemMethod::isPut();
|
|
594
|
+
}
|
|
534
595
|
}
|
|
535
|
-
}
|
|
536
596
|
|
|
537
|
-
if (!function_exists(
|
|
538
|
-
|
|
539
|
-
|
|
597
|
+
if (!function_exists('isDelete')) {
|
|
598
|
+
function isDelete(): bool
|
|
599
|
+
{
|
|
600
|
+
return \Bin\SystemMethod::isDelete();
|
|
601
|
+
}
|
|
540
602
|
}
|
|
541
|
-
}
|
|
542
603
|
|
|
543
|
-
if (!function_exists(
|
|
544
|
-
|
|
545
|
-
|
|
604
|
+
if (!function_exists('getClientIp')) {
|
|
605
|
+
function getClientIp(): string
|
|
606
|
+
{
|
|
607
|
+
return \Bin\SystemMethod::getClientIp();
|
|
608
|
+
}
|
|
546
609
|
}
|
|
547
|
-
}
|
|
548
610
|
|
|
549
|
-
if (!function_exists(
|
|
550
|
-
|
|
551
|
-
|
|
611
|
+
if (!function_exists('redirect')) {
|
|
612
|
+
function redirect(string $url): void
|
|
613
|
+
{
|
|
614
|
+
\Bin\SystemMethod::redirect($url);
|
|
615
|
+
}
|
|
552
616
|
}
|
|
553
|
-
}
|
|
554
617
|
|
|
555
|
-
if (!function_exists(
|
|
556
|
-
|
|
557
|
-
|
|
618
|
+
if (!function_exists('generateToken')) {
|
|
619
|
+
function generateToken(int $length = 32): string
|
|
620
|
+
{
|
|
621
|
+
return \Bin\SystemMethod::generateToken($length);
|
|
622
|
+
}
|
|
558
623
|
}
|
|
559
|
-
}
|
|
560
624
|
|
|
561
|
-
if (!function_exists(
|
|
562
|
-
|
|
563
|
-
|
|
625
|
+
if (!function_exists('sanitizeEmail')) {
|
|
626
|
+
function sanitizeEmail(string $email): string
|
|
627
|
+
{
|
|
628
|
+
return \Bin\SystemMethod::sanitizeEmail($email);
|
|
629
|
+
}
|
|
564
630
|
}
|
|
565
|
-
}
|
|
566
631
|
|
|
567
|
-
if (!function_exists(
|
|
568
|
-
|
|
569
|
-
|
|
632
|
+
if (!function_exists('sanitizeFloat')) {
|
|
633
|
+
function sanitizeFloat($value): float
|
|
634
|
+
{
|
|
635
|
+
return \Bin\SystemMethod::sanitizeFloat($value);
|
|
636
|
+
}
|
|
570
637
|
}
|
|
571
|
-
}
|
|
572
638
|
|
|
573
|
-
if (!function_exists(
|
|
574
|
-
|
|
575
|
-
|
|
639
|
+
if (!function_exists('arrayOnly')) {
|
|
640
|
+
function arrayOnly(array $source, array $keys): array
|
|
641
|
+
{
|
|
642
|
+
return \Bin\SystemMethod::arrayOnly($source, $keys);
|
|
643
|
+
}
|
|
576
644
|
}
|
|
577
|
-
}
|
|
578
645
|
|
|
579
|
-
if (!function_exists(
|
|
580
|
-
|
|
581
|
-
|
|
646
|
+
if (!function_exists('dd')) {
|
|
647
|
+
function dd(...$vars): void
|
|
648
|
+
{
|
|
649
|
+
\Bin\SystemMethod::dd(...$vars);
|
|
650
|
+
}
|
|
582
651
|
}
|
|
583
|
-
}
|
|
584
652
|
|
|
585
|
-
if (!function_exists(
|
|
586
|
-
|
|
587
|
-
|
|
653
|
+
if (!function_exists('slugify')) {
|
|
654
|
+
function slugify(string ...$texts): string
|
|
655
|
+
{
|
|
656
|
+
return \Bin\SystemMethod::slugify(...$texts);
|
|
657
|
+
}
|
|
588
658
|
}
|
|
589
|
-
}
|
|
590
659
|
|
|
591
|
-
if (!function_exists(
|
|
592
|
-
|
|
593
|
-
|
|
660
|
+
if (!function_exists('byteId')) {
|
|
661
|
+
function byteId(): string
|
|
662
|
+
{
|
|
663
|
+
return \Bin\SystemMethod::byteId();
|
|
664
|
+
}
|
|
594
665
|
}
|
|
595
|
-
}
|
|
596
666
|
|
|
597
|
-
if (!function_exists(
|
|
598
|
-
|
|
599
|
-
|
|
667
|
+
if (!function_exists('formatId')) {
|
|
668
|
+
function formatId(string $value, string $to = 'auto'): string
|
|
669
|
+
{
|
|
670
|
+
return \Bin\SystemMethod::formatId($value, $to);
|
|
671
|
+
}
|
|
600
672
|
}
|
|
601
|
-
}
|
|
602
673
|
|
|
603
|
-
if (!function_exists(
|
|
604
|
-
|
|
605
|
-
|
|
674
|
+
if (!function_exists('makeId')) {
|
|
675
|
+
function makeId(): string
|
|
676
|
+
{
|
|
677
|
+
return \Bin\SystemMethod::makeId();
|
|
678
|
+
}
|
|
606
679
|
}
|
|
607
|
-
}
|
|
608
680
|
|
|
609
|
-
if (!function_exists(
|
|
610
|
-
|
|
611
|
-
|
|
681
|
+
if (!function_exists('intId')) {
|
|
682
|
+
function intId(int $length = 8): int
|
|
683
|
+
{
|
|
684
|
+
return \Bin\SystemMethod::intId($length);
|
|
685
|
+
}
|
|
612
686
|
}
|
|
613
|
-
}
|
|
614
687
|
|
|
615
|
-
if (!function_exists(
|
|
616
|
-
|
|
617
|
-
|
|
688
|
+
if (!function_exists('bigintId')) {
|
|
689
|
+
function bigintId(int $length = 15, bool $asString = false)
|
|
690
|
+
{
|
|
691
|
+
return \Bin\SystemMethod::bigintId($length, $asString);
|
|
692
|
+
}
|
|
618
693
|
}
|
|
619
|
-
}
|
|
620
694
|
|
|
621
|
-
if (!function_exists(
|
|
622
|
-
|
|
623
|
-
|
|
695
|
+
if (!function_exists('stringer')) {
|
|
696
|
+
function stringer($value): string
|
|
697
|
+
{
|
|
698
|
+
return \Bin\SystemMethod::stringer($value);
|
|
699
|
+
}
|
|
624
700
|
}
|
|
625
|
-
}
|
|
626
701
|
|
|
627
|
-
if (!function_exists(
|
|
628
|
-
|
|
629
|
-
|
|
702
|
+
if (!function_exists('otpInt')) {
|
|
703
|
+
function otpInt(int $length = 6): int
|
|
704
|
+
{
|
|
705
|
+
return \Bin\SystemMethod::otpInt($length);
|
|
706
|
+
}
|
|
630
707
|
}
|
|
631
|
-
}
|
|
632
708
|
|
|
633
|
-
if (!function_exists(
|
|
634
|
-
|
|
635
|
-
|
|
709
|
+
if (!function_exists('otpStr')) {
|
|
710
|
+
function otpStr(int $length = 6, string $case = 'C'): string
|
|
711
|
+
{
|
|
712
|
+
return \Bin\SystemMethod::otpStr($length, $case);
|
|
713
|
+
}
|
|
636
714
|
}
|
|
637
|
-
}
|
|
638
715
|
|
|
639
|
-
if (!function_exists(
|
|
640
|
-
|
|
641
|
-
|
|
716
|
+
if (!function_exists('otpMix')) {
|
|
717
|
+
function otpMix(int $length = 6, string $case = 'C'): string
|
|
718
|
+
{
|
|
719
|
+
return \Bin\SystemMethod::otpMix($length, $case);
|
|
720
|
+
}
|
|
642
721
|
}
|
|
643
722
|
}
|