Forums / Developer / Execute bin script outside eZ Publish root dir?

Execute bin script outside eZ Publish root dir?

Author Message

Bartek Modzelewski

Wednesday 29 July 2009 5:05:50 am

Hello,

I've got a big challenge: how to execute eZ Publish custom binary script from other directory than eZ Publish root? I've got the following file structure:

/
/ezpublish_root/ (contains typical ezpublish installation)
/sciprt.php

Now inside <i>script.php</i> i want to include ezpublish engne, i mean all $cli, $script etc .. that allows me to access all modules and stuff... In fact i need to access content module - just to get some data stored in eZContentObjets. Is it possible ?

I know that all calls to ezpublish must be done from eZ Publish root - that's what i'm doing for years, but now i try to do it out of ezpublish - it's just a try to integrate eZ Publish with other php software.

What should I do ? Is it possible somehow ? I have spent some time analyzing ezsys.php and other scrpts that initialize ezpublish, but general problem is with including classes. As we know aoutload/ezp_kernel.php contains path to libs, but there is still a lot of other places with includes. All my tries end with <i>An unexpected error has occurred. Please contact the webmaster.</i>

Can somebody help me ? Or tell me that it's just not possible to set some kind of "ez_base_path" ... so i will stop intregrating it this way, and find another :)

Thanks

P.S. One more thing: eZ Pulish must remain usable when accessing in browser http://mysite/ezpublish/

Baobaz
http://www.baobaz.com

Gaetano Giunta

Wednesday 29 July 2009 5:23:40 am

Try this as first lines of your script:

if ( isset( $_SERVER['REQUEST_METHOD'] ) )
{
    // this script is not meant to be accessed via the web!
    // note: ezscript class later does the same check, but after intializing a lot of stuff
    die();
}

// try to move to eZ Publish root dir if called in different dirs
if ( !file_exists( getcwd() . '/autoload.php' ) )
{
    $dir = dirname( __FILE__ );
    chdir( $dir . '/ezpublish_root' );
}

Principal Consultant International Business
Member of the Community Project Board

Bartek Modzelewski

Wednesday 29 July 2009 5:37:51 am

Thanks !

In fact I was thinking about it but ... "it's to simple, I will not work". So I haven't tried .. stupid me ;)

Baobaz
http://www.baobaz.com

eZ debug

Timing: Jan 19 2025 20:07:36
Script start
Timing: Jan 19 2025 20:07:36
Module start 'content'
Timing: Jan 19 2025 20:07:37
Module end 'content'
Timing: Jan 19 2025 20:07:37
Script end

Main resources:

Total runtime1.1990 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.0859180.8125
Module start 'content' 0.00631.0687 769.8984539.1719
Module end 'content' 1.07500.1239 1,309.0703332.7422
Script end 1.1989  1,641.8125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.3413210.0002
Check MTime0.00150.1276210.0001
Mysql Total
Database connection0.00080.063210.0008
Mysqli_queries1.133594.53461940.0058
Looping result0.00160.13731920.0000
Template Total1.172797.820.5864
Template load0.00190.158420.0009
Template processing1.170897.651020.5854
Template load and register function0.00020.016010.0002
states
state_id_array0.00100.081210.0010
state_identifier_array0.00140.114120.0007
Override
Cache load0.00150.1264190.0001
Sytem overhead
Fetch class attribute can translate value0.00180.148330.0006
Fetch class attribute name0.00140.113640.0003
XML
Image XML parsing0.00090.078730.0003
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00530.4386270.0002
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs