commit 7b5642b2004dccd19da36d4a3c491db45a6a7145
parent eaf122bfa83a0151f99c4a05e666298966e64fa6
Author: Claudio Alessi <smoppy@gmail.com>
Date: Thu, 4 Feb 2016 19:29:10 +0100
Add the curl_post() function.
This commit also fix dbupd() which now uses SQL NULL in place of 'NULL'.
Diffstat:
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/bored.php b/bored.php
@@ -205,7 +205,10 @@ function dbupd($tbl, $info, $id) {
$vals = [];
foreach($info as $k => $v) {
$v = dbin($v);
- $vals[] = "`$k`= '$v'";
+ if($v == NULL)
+ $vals[] = "`$k`= NULL";
+ else
+ $vals[] = "`$k`= '$v'";
}
$vals = implode(',', $vals);
$sql = "update `$tbl` set $vals where id = $id";
@@ -445,6 +448,23 @@ function humanstime($timestamp, $fmts = null) {
return sprintf($fmts[$k], $ht['unit']);
}
+function curl_post($uri, $curlopts = []) {
+ $c = curl_init();
+
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($c, CURLOPT_URL, $uri);
+ curl_setopt($c, CURLOPT_POST, true);
+
+ if($curlopts)
+ foreach($curlopts as $k => $v)
+ curl_setopt($c, $k, $v);
+
+ $ret = curl_exec($c);
+ curl_close($c);
+
+ return $ret;
+}
+
function prepare_form() {
$key = key($_FILES);
if(!$key)
@@ -516,7 +536,6 @@ function view($name, $data = [], $layout = null, $layoutdata = []) {
return viewlinc($name, $data, $layout, $layoutdata);
}
-/* called by the app */
function bored_run() {
echo route($_SERVER['REQUEST_METHOD'], (string)@explode('?', $_SERVER['REQUEST_URI'])[0]);
}