diff --git a/classes/headers/IncludeHeader.php b/classes/headers/IncludeHeader.php index 7d39e709..a9dd2b49 100644 --- a/classes/headers/IncludeHeader.php +++ b/classes/headers/IncludeHeader.php @@ -1,7 +1,12 @@ report).'/'.$value; + if($value[0] === '/') { + $report_path = substr($value,1); + } + else { + $report_path = dirname($report->report).'/'.$value; + } if(!file_exists(PhpReports::$config['reportDir'].'/'.$report_path)) { $possible_reports = glob(PhpReports::$config['reportDir'].'/'.$report_path.'.*'); diff --git a/classes/report_types/MongoReportType.php b/classes/report_types/MongoReportType.php index 7dda50c7..bcb2859e 100644 --- a/classes/report_types/MongoReportType.php +++ b/classes/report_types/MongoReportType.php @@ -53,7 +53,7 @@ public static function run(&$report) { 'mongo '.$config['host'].':'.$config['port'].'/'.$mongo_database.' --quiet --eval '."'...'". ''. 'Eval String:'. - '
'.$eval.'+ '
'.htmlentities($eval).''; $result = shell_exec($command); diff --git a/classes/report_types/PhpReportType.php b/classes/report_types/PhpReportType.php index 23c6cde6..aefdd257 100644 --- a/classes/report_types/PhpReportType.php +++ b/classes/report_types/PhpReportType.php @@ -1,7 +1,19 @@ raw_query = "report."\n".trim($report->raw_query); + //if there are any included reports, add it to the top of the raw query + if(isset($report->options['Includes'])) { + $included_code = ''; + foreach($report->options['Includes'] as &$included_report) { + $included_code .= "\n".trim($included_report->raw_query).""; + } + + if($included_code) $included_code.= "\n"; + + $report->raw_query = $included_code . $report->raw_query; + } } public static function openConnection(&$report) { @@ -12,14 +24,31 @@ public static function closeConnection(&$report) { } - public static function run(&$report) { - extract($report->macros); + public static function run(&$report) { + $eval = "macros as $key=>$value) { + $eval .= "\n".'$'.$key.' = "'.addslashes($value).'";'; + } + $eval .= "\n?>".$report->raw_query; $config = PhpReports::$config; $database = PhpReports::$config['databases'][$report->options['Database']]; + $report->options['Query'] = $report->raw_query; + + $parts = preg_split('/<\?php \/\*(BEGIN|END) (INCLUDED REPORT|REPORT MACROS)\*\/ \?>/',$eval); + $formatted = ''; + $code = '
'.$formatted.'