tweeper: make is_cli() stricter
authorAntonio Ospite <ao2@ao2.it>
Wed, 29 Jul 2015 20:52:15 +0000 (22:52 +0200)
committerAntonio Ospite <ao2@ao2.it>
Wed, 29 Jul 2015 20:52:15 +0000 (22:52 +0200)
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".

tweeper.php

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