-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
46 lines (42 loc) · 1.29 KB
/
config.php
File metadata and controls
46 lines (42 loc) · 1.29 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
<?php
$cfg_recaptcha_secret = '';
$cfg_paypal_clientid = '';
$cfg_paypal_secret = '';
$cfg_pgsql_dsn = 'pgsql:dbname=w0bm-stickers;user=w0bm-stickers';
function exit_response($status, $error = null, $data = null) {
header("Content-type: application/json");
http_response_code($status);
exit(json_encode([
"success" => $status === 200,
"error" => $error,
"data" => $data
]));
}
function c_error($msg, $subject = null) {
return [
"msg" => $msg,
"subject" => $subject
];
}
function fetch($url, $method = "GET", $data = null, $content_type = "application/x-www-form-urlencoded") {
$context = [
"method" => $method,
"protocol_version" => "1.1"
];
$headers = [
"Content-Type: " . $content_type,
"Connection: close"
];
if($data) {
$context["content"]
= $content_type === "application/json"
? json_encode($data)
: http_build_query($data);
array_push($headers, "Content-Length: " . strlen($context["content"]));
}
for($i = 4; $i < func_num_args(); $i++)
array_push($headers, func_get_arg($i));
if($headers)
$context["header"] = $headers;
return file_get_contents($url, false, stream_context_create(["http" => $context]));
}