@ECHO OFF
rem **********************************************************************
rem * Windows Wrapper to call PHP scripts from NVE scripts               *
rem * ====================================================               *
rem *                                                                    *
rem * Syntax  : php.cmd <jobid> <script> [<param 1> ... <param 7>]       *
rem *                                                                    *
rem * Returns :  -1 Mandatory script parameter missing                   *
rem *             0 Success                                              *
rem *             x Exit code given in PHP exit command, e.g. exit(x)    *
rem *           255 Usually indicating a missing php script file         *
rem *                                                                    *
rem * Remarks : When calling this CMD file, the active working directory *
rem *           has to be on the same drive!!                            *
rem *                                                                    *
rem * Company : New Voice International                                  *
rem *                                                                    *
rem * Author  : 16-06-2003   W. Bärtsch                                  *
rem *                                                                    *
rem * Updates : 10-03-2004   W. Bärtsch                                  *
rem *              Corrected override problem with ssl and intl libs     *
rem *           11-08.2004   W. Bärtsch                                  *
rem *              Moved php scripts into "playback" directory           *
rem *                                                                    *
rem **********************************************************************

set PHP_INI=\nv_web\apache\php.ini
set PHP_BIN=\nv_web\php4\cli\php.exe

set NV_TMPP=%PATH%
set NV_TMPD=%CD%

set ERRCOD=

rem Need to have the dynamic libs of php in the include path
set PATH=\nv_web\php4
rem Need to have the ssl libs in the include path prior to the ones from windows
cd \nv_web\apache\bin

call %PHP_BIN% -C -d output_buffering=1 -c %PHP_INI% -f \nv_web\htdocs\playback\%2.php -- %1 %3 %4 %5 %6 %7 %8 %9 > \nvt\log\%1.txt
set ERRCOD= %ERRORLEVEL%

rem Return to original working directory
cd %NV_TMPD%
set NV_TMPD=
rem Restore PATH
set PATH=%NV_TMPP%
set NV_TMPP=

@ECHO ON
@exit %ERRCOD%