diff --git a/dev/samples/create_order.php b/dev/samples/create_order.php index 7439f5f7460aa85d8dcba2bcb8c4714d0cd43db8..872dd86a0e30f795a02dd989a8e26f19502316b5 100644 --- a/dev/samples/create_order.php +++ b/dev/samples/create_order.php @@ -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; } diff --git a/dev/samples/create_product.php b/dev/samples/create_product.php index cd3372abea501353d93464fbfbd487e2e42192dd..fb323dee79d3c4f67f9c087ec071f1053c1f430d 100644 --- a/dev/samples/create_product.php +++ b/dev/samples/create_product.php @@ -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; } diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index f6e7ab0798f34661efcd8a0fa3504161730fe149..28ba84e454505853c24bf754629f4e4b2df1cd9b 100644 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -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 diff --git a/dev/skeletons/build_webservice_from_class.php b/dev/skeletons/build_webservice_from_class.php index dc5efecece3a837979018c01bbb8c38f3a23cad4..83389fe76e300addf357605cde8b0fbda4432c48 100644 --- a/dev/skeletons/build_webservice_from_class.php +++ b/dev/skeletons/build_webservice_from_class.php @@ -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 diff --git a/dev/skeletons/skeleton_script.php b/dev/skeletons/skeleton_script.php index 4ca769b753c4a256fd52ee956a56dd7a5f616777..936ab71b52a177f961c33b386dc9da9ba526ffa2 100644 --- a/dev/skeletons/skeleton_script.php +++ b/dev/skeletons/skeleton_script.php @@ -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; } diff --git a/dev/translation/autotranslator.php b/dev/translation/autotranslator.php index aef9e3b37cd6fcc47fad93edea31103097baa0a5..cde77595a0aff0c119d099913b96f69198d7ac21 100644 --- a/dev/translation/autotranslator.php +++ b/dev/translation/autotranslator.php @@ -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; diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 667d784bc19c5716f1557c9e4ed548082108bf8f..8faa8939d0025f28d41a1ecfa3c64530d54171fe 100644 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -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"); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index b75dadc48f1933135af285953415dcc016626b8d..131416e0f6ef9a181bc0eb3c51d672a0c6e2b351 100644 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -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"); diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 16b0006d44e275fe64f10127084582fd3cd06764..e88a4520853ee0ece0e41352da21e866802911a3 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -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; } diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 4e27b6c5893358a80e143c00f75ac577a9d30a1d..55d63d89242708d27c038fe757344b3866f62261 100644 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -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; } diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 2993937e11ded5b5f3de5ba525011503348afae6..bf592ec3c4961b9de7cf13859aa2cd43b83cb8e5 100644 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -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; diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index ce9679c41b2e45b8d5698b9393e21a5a449e1e94..07e5327989ecb1efe98cb06bffd30a3c0f11b17e 100644 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -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"); diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 571b1d0b6999c1cfd39288b4893c7319a9148a2d..f082f4e49fc0af56082aa334b34e56c16ce08439 100644 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -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"); diff --git a/scripts/withdrawals/prelevement-verif.php b/scripts/withdrawals/prelevement-verif.php index dec873f98412e889b9a0d1e111147d20cb43798e..4582b28a160c5b41fd574efc454ae5c8447d7e0c 100644 --- a/scripts/withdrawals/prelevement-verif.php +++ b/scripts/withdrawals/prelevement-verif.php @@ -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"); diff --git a/scripts/withdrawals/prelevement.php b/scripts/withdrawals/prelevement.php index 774b2b1710736ff176b937f961b9a474352e992d..b9bbd557c7598bf843d1fc74e53c9e8426975fc8 100644 --- a/scripts/withdrawals/prelevement.php +++ b/scripts/withdrawals/prelevement.php @@ -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");