mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 21:21:52 +00:00
Factor out cli execution guard to common.php
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1343 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
0b743fb2db
commit
82f8561123
9
maintenance/common.php
Normal file
9
maintenance/common.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function assertCli() {
|
||||||
|
if (php_sapi_name() != 'cli' && !getenv('PHP_IS_CLI')) {
|
||||||
|
echo 'Script cannot be called from web-browser (if you are calling via cli,
|
||||||
|
set environment variable PHP_IS_CLI to work around this).';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,15 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'common.php';
|
||||||
|
assertCli();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes the default HTMLDefinition serial cache
|
* Flushes the default HTMLDefinition serial cache
|
||||||
* @param Accepts one argument, cache type to flush; otherwise flushes all
|
* @param Accepts one argument, cache type to flush; otherwise flushes all
|
||||||
* the caches.
|
* the caches.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (php_sapi_name() != 'cli' && !getenv('PHP_IS_CLI')) {
|
|
||||||
echo 'Script cannot be called from web-browser (if you are calling via cli,
|
|
||||||
set environment variable PHP_IS_CLI to work around this).';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Flushing cache... \n";
|
echo "Flushing cache... \n";
|
||||||
|
|
||||||
require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
|
require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once 'common.php';
|
||||||
|
assertCli();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses *.ent files into an entity lookup table, and then serializes and
|
* Parses *.ent files into an entity lookup table, and then serializes and
|
||||||
* writes the whole kaboodle to a file. The resulting file should be versioned.
|
* writes the whole kaboodle to a file. The resulting file should be versioned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (php_sapi_name() != 'cli' && !getenv('PHP_IS_CLI')) {
|
|
||||||
echo 'Script cannot be called from web-browser. (if you are calling via cli,
|
|
||||||
set environment variable PHP_IS_CLI to work around this).';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
chdir( dirname(__FILE__) );
|
chdir( dirname(__FILE__) );
|
||||||
|
|
||||||
// here's where the entity files are located, assuming working directory
|
// here's where the entity files are located, assuming working directory
|
||||||
|
Loading…
Reference in New Issue
Block a user