public static function dumpToFile($obj, $fileName = '') { $id = buildIdFromCallstack(1); $outputDirPath = defined('ROOT_PATH') ? ROOT_PATH : ''; $outputDirPath .= DIRECTORY_SEPARATOR . 'data/tmp/dump/' . $id; if (!file_exists($outputDirPath)) { mkdir($outputDirPath, 0777, true); } if (!empty($fileName)) { $fileName .= '-'; } $fileName .= IFR_Main_Time::udate('Ymd-His-u') . '.txt'; $dumpFilePath = $outputDirPath . DIRECTORY_SEPARATOR . $fileName; $outputFile = fopen($dumpFilePath, 'wt'); self::_dump($obj, '', -1, $outputFile); fclose($outputFile); return $dumpFilePath; }
/** * @static * @throws Exception */ public static function shutdown() { if (!self::$_stopped) { self::$_level = 1; self::mp('__SCRIPT_END__'); self::$_level = 0; } if (self::$_flags & self::ENABLE_COLLECT_SERVER) { $data = 'data=' . base64_encode(serialize(array('mp' => self::$_timers['mp'], 'SERVER_ADDR' => $_SERVER['SERVER_ADDR'], 'REMOTE_ADDR' => $_SERVER['REMOTE_ADDR'], 'HTTP_HOST' => $_SERVER['HTTP_HOST'], 'REQUEST_URI' => $_SERVER['REQUEST_URI'], 'QUERY_STRING' => $_SERVER['QUERY_STRING'], 'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'], 'POST' => $_POST, 'GET' => $_GET, 'COOKIE' => $_COOKIE))); $ch = curl_init('http://mp.ifresearch.org/dump.php'); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_exec($ch); curl_close($ch); } $debug = false; try { if (!class_exists('Zend_Registry')) { throw new Exception('Zend_Registry class not found'); } $debug = Zend_Registry::get('debug'); } catch (Exception $e) { $debug = isset($_GET['debug']) && $_GET['debug'] == 'ifresearch'; } if (self::$_flags & self::ENABLE_VISIBLE_STATS || $debug && self::$_flags & self::ENABLE_VISIBLE_STATS_DEBUG) { $max_diff = 0; foreach (self::$_timers['mp'] as $mp) { if ($mp['diff'] > $max_diff) { $max_diff = $mp['diff']; } } echo '<hr /><br /><center>'; echo '<table border="1" cellspacing="0" cellpadding="0" align="center">'; echo '<tr>'; foreach (array_keys(reset(self::$_timers['mp'])) as $value) { $skip = false; switch ($value) { case 'time': $skip = true; break; } if (!$skip) { echo '<th>' . $value . '</th>'; } } echo '</tr>'; foreach (self::$_timers['mp'] as $mp) { echo '<tr>'; foreach ($mp as $key => $value) { $skip = false; switch ($key) { case 'diff': $color = floor(255 - 255 * $value / $max_diff); echo '<td style="background-color: rgb(255,' . $color . ',' . $color . ')">'; break; case 'time': $skip = true; break; default: echo '<td>'; } if (!$skip) { echo $value; echo '</td>'; } } echo '</tr>'; } echo '</table></center><br />'; } }