So I have this bit of code:
function global_include($html,$section){
if (!isset($html)) { //Need to write better error checking
error_log('Global Include Error: '.iam().' '.$_SERVER['PHP_SELF'].' - '.$html.'-'.$section,0); // WRITE TO LOG
echo '<p>Error fetching data</p>';
}else {
ob_start();
include GLOBAL_DIR.'/assets/inc/pages/'.$html;
//$string = ob_get_clean();
$string = ob_get_contents();
ob_end_clean();
$htmlobj = str_get_html($string);
if(is_object($htmlobj)){//check for returned html to be a properly formed and parsed xml object
$el = $htmlobj->find($section, 0);
$innertext = $el->innertext;
echo $innertext;
}else{
error_log('(User tried to access invalid html object with global_include() at ' . GLOBAL_DIR . '/assets/inc/pages/' . $html . ') ' . 'Request URI: ' . $_SERVER['REQUEST_URI'] . ' - HTTP Referer: ' . $_SERVER['HTTP_REFERER'] . ' - User Agent: ' . $_SERVER['HTTP_USER_AGENT'] . ' - IP Address: ' . $_SERVER['REMOTE_ADDR'] . ' HTML ASKED: ' . $html . ' SECTION ASKED: ' . $section . ' SECTION RETURNED: ' . $string . ' HTMLOBJ: ' . print_r($htmlobj, true) . ' HEADERS: ' . print_r(getallheaders(), true));
}
}
}
For the life of me I cant figure out why everything in the error log is blank (it gets all the way to the last else statement where I am printing variables). Even the headers return nothing. This function is called with static parameters EVERYWHERE it is included. There is a 0% chance of this function being called without $html or $section having some value. HELP!!!!
-PS the page that this is being called from works fine when I try it.
Edit:To be a little more precise here, What it looks like its doing is NOT starting the buffer, including the file, and then dumping the contents of the buffer. Is there some way PHP will turn off the buffers on occasion if there are no headers of if the user disconnected already or something?