eZ Publish  [4.0]
ezexec.php
Go to the documentation of this file.
00001 #!/usr/bin/env php
00002 <?php
00003 //
00004 // Created on: <03-May-2004 07:52:57 amos>
00005 //
00006 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00007 // SOFTWARE NAME: eZ Publish
00008 // SOFTWARE RELEASE: 4.0.x
00009 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00010 // SOFTWARE LICENSE: GNU General Public License v2.0
00011 // NOTICE: >
00012 //   This program is free software; you can redistribute it and/or
00013 //   modify it under the terms of version 2.0  of the GNU General
00014 //   Public License as published by the Free Software Foundation.
00015 //
00016 //   This program is distributed in the hope that it will be useful,
00017 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //   GNU General Public License for more details.
00020 //
00021 //   You should have received a copy of version 2.0 of the GNU General
00022 //   Public License along with this program; if not, write to the Free
00023 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 //   MA 02110-1301, USA.
00025 //
00026 //
00027 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00028 //
00029 
00030 //include_once( 'lib/ezutils/classes/ezcli.php' );
00031 //include_once( 'kernel/classes/ezscript.php' );
00032 
00033 require 'autoload.php';
00034 
00035 $cli = eZCLI::instance();
00036 $script = eZScript::instance( array( 'description' => ( "eZ Publish Script Executor\n\n" .
00037                                                         "Allows execution of simple PHP scripts which uses eZ Publish functionality,\n" .
00038                                                         "when the script is called all necessary initialization is done\n" .
00039                                                         "\n" .
00040                                                         "ezexec.php myscript.php" ),
00041                                      'use-session' => false,
00042                                      'use-modules' => true,
00043                                      'use-extensions' => true ) );
00044 
00045 $script->startup();
00046 
00047 $options = $script->getOptions( "",
00048                                 "[scriptfile]",
00049                                 array() );
00050 $script->initialize();
00051 
00052 if ( count( $options['arguments'] ) < 1 )
00053 {
00054     $script->shutdown( 1, "Missing script file" );
00055 }
00056 
00057 $scriptFile = $options['arguments'][0];
00058 
00059 if ( !file_exists( $scriptFile ) )
00060     $script->shutdown( 1, "Could execute the script '$scriptFile', file was not found" );
00061 
00062 $retCode = include( $scriptFile );
00063 
00064 if ( $retCode != 1 )
00065     $script->setExitCode( 1 );
00066 
00067 $script->shutdown();
00068 
00069 ?>