common.php 631 B

12345678910111213141516171819202122
  1. <?php
  2. function assertCli() {
  3. if (php_sapi_name() != 'cli' && !getenv('PHP_IS_CLI')) {
  4. echo 'Script cannot be called from web-browser (if you are indeed calling via cli,
  5. set environment variable PHP_IS_CLI to work around this).';
  6. exit(1);
  7. }
  8. }
  9. function prefix_is($comp, $subject) {
  10. return strncmp($comp, $subject, strlen($comp)) === 0;
  11. }
  12. function postfix_is($comp, $subject) {
  13. return strlen($subject) < $comp ? false : substr($subject, -strlen($comp)) === $comp;
  14. }
  15. // Load useful stuff like FSTools
  16. require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';
  17. // vim: et sw=4 sts=4