From: Antonio Ospite <ao2@ao2.it>
Date: Wed, 29 Jul 2015 20:52:15 +0000 (+0200)
Subject: tweeper: make is_cli() stricter
X-Git-Tag: v0.4~12
X-Git-Url: https://git.ao2.it/tweeper.git/commitdiff_plain/b453301fecc757e4d95191a65b24259e81b53f87?ds=inline

tweeper: make is_cli() stricter

Assume that tweeper is running from an actual command line only when
php_sapi_name() matches _exactly_ the string "cli".

This makes it possible to use tweeper in a browser using the PHP
built-in web server, for which php_sapi_name() returns "cli-server".
---

diff --git a/tweeper.php b/tweeper.php
index 5e9d242..f07382b 100644
--- a/tweeper.php
+++ b/tweeper.php
@@ -285,7 +285,7 @@ class Tweeper {
 
 function is_cli()
 {
-  return (substr(php_sapi_name(), 0, 3) == 'cli');
+  return (php_sapi_name() === "cli");
 }
 
 function usage($argv)