-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvkext.helper.php
More file actions
667 lines (595 loc) · 12.9 KB
/
vkext.helper.php
File metadata and controls
667 lines (595 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<?php
// Compiler for PHP (aka KPHP) polyfills
// Copyright (c) 2020 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt
/** @noinspection PhpUnused */
/** @noinspection PhpUnusedParameterInspection */
/** @noinspection PhpComposerExtensionStubsInspection */
/** @noinspection PhpDocSignatureInspection */
/** @noinspection PhpDocMissingReturnTagInspection */
/** @noinspection KphpDocInspection */
/** @noinspection NoTypeDeclarationInspection */
/** @noinspection KphpReturnTypeMismatchInspection */
/** @noinspection KphpParameterTypeMismatchInspection */
/*
* This file contains declarations of KPHP native functions that are written in C (vkext.so - PHP extension).
* So, while executing a script im plain PHP - vkext implementation is used,
* but after compilation they are replaced by built-in ones.
*
* This functions can't be polyfilled in plain PHP (or PHP versions would be very slow),
* that's why they are written in C.
*
* !!! File is used only to provide accurate autocompletion for IDE and must not be required.
*/
#ifndef KPHP
/**
* Converts string in utf8 to string in cp1251 with html-entities.
*
* @param string $s
* @param int $max_len
* @param bool $exit_on_error
* @return string
*/
function vk_utf8_to_win($s, $max_len = 0, $exit_on_error = false) {
return "";
}
/**
* Converts string in cp1251 with html-entities to string in utf8.
*
* @param string $s
* @return string
*/
function vk_win_to_utf8($s) {
return "";
}
/**
* @param string $name
* @param string $case_name
* @param int $sex
* @param string $type
* @param int $lang_id
* @return string
*/
function vk_flex($name, $case_name, $sex, $type, $lang_id = 0) {
return "";
}
/**
* @param mixed $v
* @return string
*/
function vk_json_encode($v) {
return "";
}
/**
* @param mixed $v
* @return string
*/
function vk_json_encode_safe($v) {
return "";
}
/**
* @param string $str
* @param bool $html_opt
* @return string
*/
function vk_whitespace_pack($str, $html_opt = false) {
return "";
}
/**
* Returns RPC connection to $host:$port, with given default actor_id and timeouts.
*
* @param string $host
* @param int $port
* @param int $default_actor_id
* @param float $default_timeout
* @param float $connect_timeout
* @param float $reconnect_timeout
* @return resource|false
*/
function new_rpc_connection($host, $port, $default_actor_id = 0, $default_timeout = 0.3, $connect_timeout = 0.3, $reconnect_timeout = 17.0) {
return 0;
}
/**
* Creates an rpc_queue, returns it id. Push $request_ids to it.
*
* @param array $request_ids
* @return int
*/
function rpc_queue_create($request_ids = []) {
return 0;
}
/**
* Check if rpc_queue with id queue_id is empty.
*
* @param int $queue_id
* @return bool
*/
function rpc_queue_empty($queue_id) {
return true;
}
/**
* Waits until any of requests in queue finished and returns id of any finished query in queue.
* Returned query is removed from queue.
* If timeout is not provided no timeout used.
*
* @param int $queue_id
* @param float $timeout
* @return int|false
*/
function rpc_queue_next($queue_id, $timeout = -1.0) {
return 0;
}
/**
* @param int $queue_id
* @return int|false
*/
function rpc_queue_next_synchronously($queue_id) {
return 0;
}
/**
* Pushes all $queries to queue with id $queue_id.
* Every queue can be pushed only to one queue only once.
* Used by rpc_tl_query_result.
* Return value should be ignored. It is different in php in kphp.
*
* @param int $queue_id
* @param array|int $queries
* @return void
*/
function rpc_queue_push($queue_id, $queries) {
}
/**
* @see rpc_tl_query_result, rpc_tl_query_result_one, new_rpc_connection
*
* Given a rpc_connection ($connection) and array of rpc-queries ($queries) send them and returns
* queries ids, which can be passed to rpc_tl_query_result.
*
* If no $timeout given default timeout for connection is used.
*
* If $ignore_result is true, query id will be equal to -1, and
* result can't be received.
*
* @param resource $connection
* @param array $queries
* @param float $timeout
* @param bool $ignore_result
* @param \KphpRpcRequestsExtraInfo $requests_extra_info
* @param bool $need_responses_extra_info
* @return array
*/
function rpc_tl_query($connection, $queries, $timeout = -1.0, $ignore_result = false,
$requests_extra_info = null, $need_responses_extra_info = false) {
return [];
}
/**
* @see rpc_tl_query_result, rpc_tl_query_result_one, new_rpc_connection
*
* Given a rpc_connection ($connection) and an rpc-query ($query) send it and returns
* query id, which can be passed to rpc_tl_query_result or rpc_tl_query_result_one.
*
* If no $timeout given default timeout for connection is used.
*
* @param resource $connection
* @param array $query
* @param float $timeout
* @return int
*/
function rpc_tl_query_one($connection, $query, $timeout = -1.0) {
return 0;
}
/**
* @see rpc_tl_query
*
* Given an array of rpc-queries ids returns result of this queries.
* Each result can be gotten only once.
*
* @param array $query_ids
* @return array
*/
function rpc_tl_query_result($query_ids) {
return [];
}
/**
* @see rpc_tl_query, rpc_tl_query_one
*
* Given an rpc-query id returns result of this query.
* Result can be gotten only once.
*
* @param int $query_id
* @return array
*/
function rpc_tl_query_result_one($query_id) {
return [];
}
/**
* @return array
*/
function rpc_get_last_send_error() {
return [];
}
/**
* Returns version of extension, including commit and compile date
*
* @return string
*/
function vkext_full_version() {
return "";
}
/**
* Simplify a string, like simplify in logs/antispam engine. Returns new string.
* Returns empty string on error.
*
* @param string $s
* @return string
*/
function vk_sp_simplify($s) {
return "";
}
/**
* Simplify a string, like full_simplify in logs/antispam engine. Returns new string.
* Returns empty string on error.
*
* @param string $s
* @return string
*/
function vk_sp_full_simplify($s) {
return "";
}
/**
* Simplify a string, by changing html entities (like &lq;) to ascii symbols. Returns new string.
* Returns empty string on error.
*
*
* @param string $s
* @return string
*/
function vk_sp_deunicode($s) {
return "";
}
/**
* Returns new string, where all characters are changed to uppercase. cp1251 is used for russian.
* Returns empty string on error.
*
* @param string $s
* @return string
*/
function vk_sp_to_upper($s) {
return "";
}
/**
* Returns new string, where all characters are changed to lowercase. cp1251 is used for russian.
* Returns empty string on error.
*
* @param string $s
* @return string
*/
function vk_sp_to_lower($s) {
return "";
}
/**
* Changes string, like sort in logs engine. Returns new string.
* Returns empty string on error.
*
* @param string $s
* @return string
*/
function vk_sp_sort($s) {
return "";
}
/**
* Given array of elements and size of hll stat, returns an hll stat for this set.
* Each non-int element in array is converted to int.
* Size has to be equal to 256 or 16384.
*
* @param array $elements
* @param int $size
* @return string|false
*/
function vk_stats_hll_create($elements = [], $size = 256) {
return "";
}
/**
* Given hll stat string and array of elements, returns new hll stat
* with all array elements added to given set.
* Each non-int element in array is converted to int.
* String has to contain unpacked hll of size 256 or 16384.
*
* @param string $hll
* @param array $elements
* @return string|false
*/
function vk_stats_hll_add($hll, $elements) {
return "";
}
/**
* Given array of hll stats, returns a hll stat for union of the sets.
* Length of all hlls should be same.
*
* @param array $hlls
* @return string|false
*/
function vk_stats_hll_merge($hlls) {
return "";
}
/**
* Given hll stat, returns an approximate number of different elements in set.
*
* @param string $hll
* @return float|false
*/
function vk_stats_hll_count($hll) {
return 0.0;
}
/**
* @return string
*/
function get_engine_version() {
return '';
}
/**
* Fetch int from RPC-buffer
* @return int
*/
function fetch_int() {
return 0;
}
/**
* Fetch byte from RPC-buffer, returns [0..255]
* @return int
*/
function fetch_byte() {
return 0;
}
/**
* Fetch long from RPC-buffer
* @return mixed
*/
function fetch_long() {
return '0';
}
/**
* Fetch string from RPC-buffer
* @return string
*/
function fetch_string() {
return '';
}
/**
* Fetch string in TL2 format from RPC-buffer
* @return string
*/
function fetch_string2() {
return '';
}
/**
* Fetch float from RPC-buffer
* @return float
*/
function fetch_double() {
return 0;
}
/**
* Lookup int from RPC-buffer
* @return int
*/
function fetch_lookup_int() {
return 0;
}
/**
* Lookup data of given length (in x4 bytes) from RPC-buffer
* @return string
*/
function fetch_lookup_data($x4_bytes_length) {
return '';
}
/**
* Checks if all data were fetched
* @return bool
*/
function fetch_eof() {
return false;
}
/**
* Get current position relative to start of RPC-buffer
* @return int
*/
function fetch_get_pos() {
return 0;
}
/**
* @param $errno
* @param $errtext
*/
function store_error($errno, $errtext) {
}
/**
* @param $int
*/
function store_int($int) {
}
/**
* @param $int
*/
function store_byte($int) {
}
/**
* @param $str
*/
function store_long($str) {
}
/**
* @param $str
*/
function store_string($str) {
}
/**
* @param $str
*/
function store_string2($str) {
}
/**
* Flushes stored bytes to the network
*/
function rpc_flush() {
}
/**
* Returns raw rpc result data for query $qid
*
* @param $qid int
* @return string|false
*/
function rpc_get($qid) {
return "";
}
/**
* Setups rpc parse buffer to $data. Return true on success.
*
* @param $data string
* @return bool
*/
function rpc_parse($data) {
return true;
}
/**
* Sends stored bytes to the $rpc_conn connection.
* @param resource $rpc_conn
* @param int $timeout
* @return int
*/
function rpc_send($rpc_conn, $timeout = -1.0) {
return 0;
}
/**
* Sends stored bytes to the $rpc_conn connection without flush to the network.
* @param resource $rpc_conn
* @param int $timeout
* @return int
*/
function rpc_send_noflush($rpc_conn, $timeout = -1.0) {
return 0;
}
/**
* Equal to rpc_parse(rpc_get($qid));
*
* @param $qid int
* @return bool
*/
function rpc_get_and_parse($qid) {
return true;
}
function rpc_clean() {
}
/**
* @return int
*/
function rpc_tl_pending_queries_count() {
return 0;
}
function store_finish() {
}
/**
* @return string
*/
function vkext_prepare_stats() {
return "";
}
/**
* @param int $conn \RpcConnection
* @param @tl\RpcFunction $request
* @param float $timeout
* @return int
*/
function typed_rpc_tl_query_one($conn, $request, $timeout = -1.0) {
return 0;
}
/**
* @param int $conn
* @param @tl\RpcFunction[] $requests
* @param float $timeout
* @param bool $ignore_result
* @param \KphpRpcRequestsExtraInfo $requests_extra_info
* @param bool $need_responses_extra_info
* @return array
*/
function typed_rpc_tl_query($conn, $requests, $timeout = 0.0, $ignore_result = false,
$requests_extra_info = null, $need_responses_extra_info = false) {
return [];
}
/**
* @param int $query_id
* @return @tl\RpcResponse
*/
function typed_rpc_tl_query_result_one($query_id) {
return null;
}
/**
* @param int[] $query_ids
* @return array
*/
function typed_rpc_tl_query_result(array $query_ids) {
return [];
}
/**
* When storing an int32 TL value, if an int64 value doesn't fit, return a storing error and don't send a query.
* @param bool $fail_rpc Enable this mode
* @return bool
*/
function set_fail_rpc_on_int32_overflow(bool $fail_rpc): bool {
return true;
}
/**
* Deserializes a server RPC request to a corresponding typed TL class.
* NB! Works only in KPHP - not in PHP - when it is launched as RPC server!
* @return @tl\RpcFunction
*/
function rpc_server_fetch_request() {
return null;
}
/**
* Serializes a server RPC response based on TL scheme and stores it in RPC buffer.
* NB! Works only in KPHP - not in PHP - when it is launched as RPC server!
* @param @tl\RpcFunctionReturnResult $response
*/
function rpc_server_store_response($response) {
}
/**
* Zstandard compression.
*
* @param string $data
* @param int $level
* @return string|false
*/
function zstd_compress(string $data, int $level = 3) {
return "";
}
/**
* Zstandard decompression.
*
* @param string $data
* @return string|false
*/
function zstd_uncompress(string $data) {
return "";
}
/**
* Zstandard compression using a digested dictionary.
*
* @param string $data
* @param string $dict
* @return string|false
*/
function zstd_compress_dict(string $data, string $dict) {
return "";
}
/**
* Zstandard decompression using a digested dictionary.
*
* @param string $data
* @param string $dict
* @return string|false
*/
function zstd_uncompress_dict(string $data, string $dict) {
return "";
}
exit("This file should not be included, only analyzed by your IDE");
#endif