Fix: Use preg functions

This commit is contained in:
Laurent Destailleur 2009-10-22 01:04:23 +00:00
parent 538736bedb
commit f3a1978b9a
15 changed files with 81 additions and 82 deletions

View File

@ -24,14 +24,14 @@
* \remarks Put here some comments
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = __FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI/Web. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,14 +24,14 @@
* \remarks Put here some comments
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = __FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI/Web. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -23,16 +23,15 @@
* \version $Id$
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
if (substr($sapi_type, 0, 3) == 'cgi')
{
echo "Error: You use PHP for CGI mode. To execute $script_file as a command line program, you must use PHP for CLI mode (try php-cli).\n";
exit;
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Include Dolibarr environment

View File

@ -23,16 +23,15 @@
* \version $Id$
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
if (substr($sapi_type, 0, 3) == 'cgi')
{
echo "Error: You use PHP for CGI mode. To execute $script_file as a command line program, you must use PHP for CLI mode (try php-cli).\n";
exit;
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Include Dolibarr environment

View File

@ -26,14 +26,14 @@
* \remarks Put here some comments
*/
// Test if batch mode and define path of script
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI/Web. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -25,12 +25,12 @@
* \remarks Put here some comments
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file = '/'.$reg[1].'/i';
$path=preg_replace($script_file,'',$_SERVER["PHP_SELF"]);
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;

View File

@ -24,13 +24,14 @@
* \version $Id$
*/
// Test si mode CLI
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
@ -42,7 +43,6 @@ $now=$argv[1];
// Recupere env dolibarr
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");

View File

@ -27,11 +27,15 @@
*/
// Test if CLI mode
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PH for CGI/Web. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
if (! isset($argv[1]) || ! $argv[1]) {
@ -40,10 +44,6 @@ if (! isset($argv[1]) || ! $argv[1]) {
}
$id=$argv[1];
// Recupere root dolibarr
$path=str_replace('mailing-send.php','',$_SERVER["PHP_SELF"]);
require_once ($path."../../htdocs/master.inc.php");
require_once (DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php");

View File

@ -24,14 +24,14 @@
* \version $Id$
*/
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PH for CGI/Web. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,13 +24,14 @@
* \version $Id$
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}

View File

@ -24,19 +24,19 @@
* \version $Id$
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Main
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
@set_time_limit(0);
$error=0;
$forcecommit=0;

View File

@ -24,13 +24,14 @@
* \version $Id$
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
@ -42,7 +43,6 @@ $now=$argv[1];
// Recupere env dolibarr
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");

View File

@ -24,13 +24,14 @@
* \version $Id$
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
@ -42,7 +43,6 @@ $now=$argv[1];
// Recupere env dolibarr
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");

View File

@ -24,19 +24,19 @@
* \version $Id$
*/
// Test si mode CLI
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
exit;
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Recupere env dolibarr
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");

View File

@ -24,19 +24,19 @@
* \version $Id$
*/
// Test si mode CLI
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (preg_match('/([^\\/]+)$/i',$script_file,$reg)) $script_file=$reg[1];
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
exit;
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Recupere env dolibarr
$version='$Revision$';
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/bon-prelevement.class.php");