summaryrefslogtreecommitdiffstats
path: root/application/helpers/filebin_helper.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-05-17 21:36:32 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-05-17 21:40:00 +0200
commitac6d834e2b4f02d656e38fe300b5c6404d1f75e6 (patch)
tree8ce13504d568098e3b37501c69c562ed3fb0d074 /application/helpers/filebin_helper.php
parent59b763e9896d6f6196a894c6d57d58ef9ddd6bc6 (diff)
improve is_cli_client() and use everywhere
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers/filebin_helper.php')
-rw-r--r--application/helpers/filebin_helper.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index 4c1423725..d9a490bd6 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -170,16 +170,25 @@ function mb_str_pad($ps_input, $pn_pad_length, $ps_pad_string = " ", $pn_pad_typ
return $ret;
}
-function is_cli_client()
+function is_cli_client($override = null)
{
- // official client uses "fb-client/$version" as useragent
- $clients = array("fb-client", "libcurl", "pyfb");
- foreach ($clients as $client) {
- if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], $client) !== false) {
- return true;
+ static $is_cli = null;
+
+ if ($override !== null) {
+ $is_cli = $override;
+ }
+
+ if ($is_cli === null) {
+ $is_cli = false;
+ // official client uses "fb-client/$version" as useragent
+ $clients = array("fb-client", "libcurl", "pyfb");
+ foreach ($clients as $client) {
+ if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], $client) !== false) {
+ $is_cli = true;
+ }
}
}
- return false;
+ return $is_cli;
}
function random_alphanum($min_length, $max_length = null)