1
Hi how are you? I have been executing PHP and XOOPS from a Cron Job, I am finding up until version 2.5.3 this was happening fine however now there is a couple of warning and notices as well as protector consuming all memory on the system.
The following is the error I am recieving continually from the Cron Job, and I have tried to increase the allocated memory but this still causes and error with protector and is consumed.
le="color: #000000"><?php PHP Notice: Undefined index: SCRIPT_NAME in /home/chronola/public_html/class/xoopskernel.php on line 150 X-Powered-By: PHP/5.3.8 Content-type: text/html <br /> <b>Notice</b>: Undefined index: SCRIPT_NAME in <b>/home/chronola/public_html/class/xoopskernel.php</b> on line <b>150</b><br /> PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7680 bytes) in /home/chronola/xoops_lib/modules/protector/include/precheck.inc.php on line 6 <br /> <b>Fatal error</b>: Allowed memory size of 134217728 bytes exhausted (tried to allocate 7680 bytes) in <b>/home/chronola/xoops_lib/modules/protector/include/precheck.inc.php</b> on line <b>6</b><br />
The cronjob i am executing is:
le="color: #000000"><?php /usr/bin/php /home/yoursite/public_html/modules/twitterbomb/cron/tweet.php
The following changes to protector so it only runs when an HTTP or HTTPS session occurs seem to fix the issue:
/xoops_lib/modules/protector/include/precheck.inc.php (local execution on cron fix)
<?php require_once dirname(__FILE__).'/postcheck_functions.php' ; if( ! defined( 'PROTECTOR_PRECHECK_INCLUDED' ) ) { require dirname(__FILE__).'/precheck.inc.php' ; return ; } define( 'PROTECTOR_POSTCHECK_INCLUDED' , 1 ) ; if (!isset($_SERVER['SCRIPT_NAME'])) { return false; } if( ! class_exists( 'Database' ) ) return ; protector_postcommon() ; ?>
/xoops_lib/modules/protector/include/postcheck.inc.php (local execution on cron fix)
<?php require_once dirname(__FILE__).'/precheck_functions.php' ; if( class_exists( 'Database' ) ) { require dirname(__FILE__).'/postcheck.inc.php' ; return ; } define( 'PROTECTOR_PRECHECK_INCLUDED' , 1 ) ; define( 'PROTECTOR_VERSION' , file_get_contents( dirname(__FILE__).'/version.txt' ) ) ; if (!isset($_SERVER['SCRIPT_NAME'])) { return false; } // set $_SERVER['REQUEST_URI'] for IIS if ( empty( $_SERVER[ 'REQUEST_URI' ] ) ) { // Not defined by IIS // Under some configs, IIS makes SCRIPT_NAME point to php.exe :-( if ( !( $_SERVER[ 'REQUEST_URI' ] = @$_SERVER['PHP_SELF'] ) ) { $_SERVER[ 'REQUEST_URI' ] = $_SERVER['SCRIPT_NAME']; } if ( isset( $_SERVER[ 'QUERY_STRING' ] ) ) { $_SERVER[ 'REQUEST_URI' ] .= '?' . $_SERVER[ 'QUERY_STRING' ]; } } protector_prepare() ; ?>
/class/xoopskernel.php - Replace this function
le="color: #000000"><?php function pathTranslation() { /** * *#@+ * Host abstraction layer */ if (!isset($_SERVER['PATH_TRANSLATED']) && isset($_SERVER['SCRIPT_FILENAME'])) { $_SERVER['PATH_TRANSLATED'] =& $_SERVER['SCRIPT_FILENAME']; // For Apache CGI } else if (isset($_SERVER['PATH_TRANSLATED']) && !isset($_SERVER['SCRIPT_FILENAME'])) { $_SERVER['SCRIPT_FILENAME'] =& $_SERVER['PATH_TRANSLATED']; // For IIS/2K now I think :-( } /** * User Mulitbytes */ if (empty($_SERVER['REQUEST_URI']) && isset($_SERVER['SCRIPT_NAME'])) { // Not defined by IIS // Under some configs, IIS makes SCRIPT_NAME point to php.exe :-( if (!($_SERVER['REQUEST_URI'] = @$_SERVER['PHP_SELF'])) { $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; } if (isset( $_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } }