Source Location: /sonic.inc
main library
generic functions for CLI, utility, curl, http, etc...
boolean file_mode_contents(
string $file_name, string $string, [string $mode = 'w'])
[line 223]
file_put_contents() (reserved alias)
write string to filename
[ Top ]
boolean file_put_contents(
string $file_name, string $string)
[line 206]
[ Top ]
array sonic_args(
[boolean $argv_shift_opts = false])
[line 1525]
get argv
custom argv manipulator function
[ Top ]
array sonic_args_qsf(
array $argv)
[line 1490]
argv escaped/quoted string fix
will process standard argv type array and concat/implode where needed eg. escaped characters or quoted strings
[ Top ]
integer sonic_byte_longhand(
string $size)
[line 1630]
byte, string to integer conversion
reverse map string representation into actual byte amount
[ Top ]
string sonic_checksum(
string $data, [integer $bit_amt = 32])
[line 375]
buffer/string/packet/data checksum
no and den...
[ Top ]
string sonic_datef(
[string $format = SONIC_DATEF])
[line 1620]
date time
current time by default or supplied date format
[ Top ]
array sonic_define(
[array $sonic_ini = array()])
[line 66]
environment init. (define defaults)
sets defined constants and sets missing defaults in supplied sonic_ini() array
[ Top ]
array sonic_ext_check(
array $exts, [boolean $fatal = true])
[line 29]
PHP extension check (core requirement checker)
checks for loaded .dll or .so, will echo on error
[ Top ]
boolean sonic_file_mode_contents(
string $file_name, string $string, [string $mode = 'w'], [string $lock_dir = SONIC_TMP_PATH])
[line 168]
file_mode_contents() (lock safe)
write string to filename
[ Top ]
array sonic_header2array(
string $header)
[line 1602]
HTTP string to array conversion (header tag filter)
filters all HTTP type header key-paired tags from any given string into array
[ Top ]
interger sonic_http_env(
string $header_raw, [array $default_index = array('index.php', 'index.html')], [string $tmp_dir = SONIC_TMP_PATH])
[line 442]
sonic_http_env_engine() wrapper
[ Top ]
integer sonic_http_env_engine(
string $header_raw, array &$opts)
[line 484]
setup PHP HTTP/CGI Environment
will process given HTTP header key-paired tag formatted string (eg. usually a HTTP request) and prepare and/or set PHP type superglobals for HTTP/CGI type environment
where possible return values can be..
1+: OK
0+: not get|post aka unknown method
-1: bad get|post aka invalid syntax
-2: bad post
-3: script filename does not exist
-4: bad script aka invalid syntax
-5: no default index found
[ Top ]
integer sonic_http_env_get(
string $header_raw, array &$get_globals, [array $default_index = array('index.php', 'index.html')], [string $tmp_dir = SONIC_TMP_PATH])
[line 422]
sonic_http_env_engine() wrapper
[ Top ]
array sonic_http_header_check(
[array $http_headers_a = array()])
[line 849]
HTTP header check
will make sure that essential header parts are of standard word casing to prevent double hashing of same header via mismatch case indexing
[ Top ]
array sonic_http_header_split(
string $hresp, array &$hresp_headers, [array $opts = array('header_max' => 5)])
[line 1446]
split HTTP header from body
NB, this function is untested, mainly for sonic_http_request() as CURLOPT_HEADER=1
this function will _not_ return the split of the _first_ HTTP header from its body. WARN, you do not want use this function to prevent HTTP smuggling.
this function will take the last header as the real, final and only header associated with the body. usually you should split the first header and the body will contain any other remaining/smuggled headers (and not be treated as such). however when processing a response from cURL with headers returned, all headers cURL encountered to reach the final header will be returned (and you will probably want to filter them out).
this function will return the split of the _last_ HTTP header from its body.
[ Top ]
mixed sonic_http_request(
string $http_request, [array $curl_opt = array('tmp' => SONIC_TMP_PATH, 'default_scheme' => 'http://')])
[line 1288]
HTTP request (via cURL)
NB, HTTP header request must contain the 'Host' tag as the destination
[ Top ]
array sonic_http_request_post(
string $http_request, &$_FILES_PHP &$_FILES_PHP, [ $tmp_dir = SONIC_TMP_PATH])
[line 1109]
setup $_FILES from HTTP request
process HTTP request and setup PHP superglobal $_FILES type array
[ Top ]
string sonic_http_response(
integer $http_response_code, string $http_body, [array $http_headers_a = array()])
[line 899]
form HTTP response from parts
will merge the supplied parts given and fill-in any gaps that are missing to form a single compliant reponse
[ Top ]
array sonic_ini(
string $filename, [boolean $process_sections = false])
[line 134]
parse_ini_file() SONIC
sets global $_SONIC['SONIC_INI'] from SONIC section of ini file
[ Top ]
string sonic_mimetype(
string $file)
[line 801]
mimetype
will attempt to use any inbuilt mime_content_type() function first before loading its own
[ Top ]
ANDed sonic_socket_set_options(
resource &$socket, integer $level, [mixed $so_options = SONIC_SOCK_OPTIONS])
[line 268]
socket_set_option()'s
iterate list of socket set options and return summation NB, scalar lists key-paired values will first be cast to their constant equivilant (if it has one) before being assigned as a value
[ Top ]
integer sonic_socket_write(
resource $socket, string $buffer, integer $length, [string $lock_dir = SONIC_TMP_PATH])
[line 323]
socket_write()
socket_write() with write lock wait management
[ Top ]