summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Request.php25
-rw-r--r--lib/lib_rss.php9
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 8b2b610d6..912c354ac 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -95,6 +95,7 @@ class Minz_Request {
*/
public static function init() {
self::magicQuotesOff();
+ self::initJSON();
}
/**
@@ -238,6 +239,30 @@ class Minz_Request {
}
/**
+ * Allows receiving POST data as application/json
+ */
+ private static function initJSON() {
+ $contentType = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '';
+ if ($contentType == '') { //PHP < 5.3.16
+ $contentType = isset($_SERVER['HTTP_CONTENT_TYPE']) ? $_SERVER['HTTP_CONTENT_TYPE'] : '';
+ }
+ $contentType = strtolower(trim($contentType));
+ if ($contentType === 'application/json') {
+ $ORIGINAL_INPUT = file_get_contents('php://input', false, null, 0, 1048576);
+ if ($ORIGINAL_INPUT != '') {
+ $json = json_decode($ORIGINAL_INPUT, true);
+ if ($json != null) {
+ foreach ($json as $k => $v) {
+ if (!isset($_POST[$k])) {
+ $_POST[$k] = $v;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Permet de récupérer une variable de type $_POST
* @param $param nom de la variable
* @param $default valeur par défaut à attribuer à la variable
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 89e9ddfea..3e0033a61 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -170,7 +170,7 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') {
$pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
$pow = min($pow, count($units) - 1);
$bytes /= pow($base, $pow);
- return format_number($bytes, $precision) . ' ' . $units[$pow];
+ return format_number($bytes, $precision) . ' ' . $units[$pow];
}
function timestamptodate ($t, $hour = true) {
@@ -303,12 +303,7 @@ function lazyimg($content) {
function uTimeString() {
$t = @gettimeofday();
- return $t['sec'] . str_pad($t['usec'], 6, '0');
-}
-
-function uSecString() {
- $t = @gettimeofday();
- return str_pad($t['usec'], 6, '0');
+ return $t['sec'] . str_pad($t['usec'], 6, '0', STR_PAD_LEFT);
}
function invalidateHttpCache($username = '') {