function sti_load_config($config_file_name) { $config_xml = new DOMDocument(); $config_xml->preserveWhiteSpace = false; $config_xml->formatOutput = true; $config_xml->load($config_file_name); $localization_directory = sti_get_localization_directory(); $localizations_list = sti_get_localizations_list($localization_directory); $localizations_list_node = sti_get_localizations_list_node($config_xml); foreach ($localizations_list as $localization_file_name) { $element = sti_get_localization_node($config_xml, $localization_directory, $localization_file_name); $localizations_list_node->appendChild($element); } return $config_xml->saveXML(); }
function sti_client_event_handler($client_key, $report_key, $client_data, $enable_compression) { switch ($client_key) { // Loading ViewerFx case "ViewerFx": if (!isset($report_key)) { $report_key = "null"; } $content = file_get_contents("viewer.html"); return str_replace("#MARKER_REPORT_PARAMS#", sti_get_parameters($enable_compression), $content); break; // Loading DesignerFx // Loading DesignerFx case "DesignerFx": if (!isset($report_key)) { $report_key = "null"; } $content = file_get_contents("designer.html"); return str_replace("#MARKER_REPORT_PARAMS#", sti_get_parameters($enable_compression), $content); break; // Loading configuration // Loading configuration case "LoadConfiguration": return sti_load_config("config.xml"); break; // Loading a report when running the viewer or designer // Loading a report when running the viewer or designer case "LoadReport": return sti_get_report($client_data); break; // Loading a report by the specified URL // Used for debug. Does not work in the released version // Loading a report by the specified URL // Used for debug. Does not work in the released version case "LoadReportFile": return file_get_contents($client_data); break; // Loading the requested localization file // Loading the requested localization file case "LoadLanguage": $localization_directory = sti_get_localization_directory(); return sti_load_localization_file($localization_directory . "/" . $client_data); break; // Saving a report // Saving a report case "SaveReport": $report = base64_decode(sti_get_xml_value($client_data, "Report")); $report_key = sti_get_xml_value($client_data, "ReportKey"); $new_report_flag = sti_get_xml_value($client_data, "NewReportFlag"); return sti_save_report($report, $report_key, $new_report_flag); break; // Test database connection // Test database connection case "TestConnection": $connection_type = sti_get_xml_value($client_data, "ConnectionType"); $connection_string = sti_create_connection_string($client_data); switch ($connection_type) { case "StiSqlDatabase": return sti_mssql_test_connection($connection_string); case "StiMySqlDatabase": return sti_mysql_test_connection($connection_string); case "StiOdbcDatabase": return sti_odbc_test_connection($connection_string); case "StiPostgreSQLDatabase": return sti_pg_test_connection($connection_string); case "StiOracleDatabase": return sti_oracle_test_connection($connection_string); case "StiFirebirdDatabase": return sti_firebird_test_connection($connection_string); case "StiMongoDBDatabase": return sti_mongodb_test_connection($connection_string); default: return ""; } break; // Retrieve table columns query // Retrieve table columns query case "RetrieveColumns": $connection_type = sti_get_xml_value($client_data, "ConnectionType"); $data_path = sti_get_xml_value($client_data, "DataPath"); $schema_path = sti_get_xml_value($client_data, "SchemaPath"); $connection_string = sti_create_connection_string($client_data); $query = sti_get_xml_value($client_data, "Query"); $query = base64_decode($query); switch ($connection_type) { case "StiXmlDatabase": return sti_xml_get_columns($data_path, $schema_path); case "StiSqlDatabase": return sti_mssql_get_columns($connection_string, $query); case "StiMySqlDatabase": return sti_mysql_get_columns($connection_string, $query); case "StiOdbcDatabase": return sti_odbc_get_columns($connection_string, $query); case "StiPostgreSQLDatabase": return sti_pg_get_columns($connection_string, $query); case "StiOracleDatabase": return sti_oracle_get_columns($connection_string, $query); case "StiFirebirdDatabase": return sti_firebird_get_columns($connection_string, $query); case "StiMongoDBDatabase": return sti_mongodb_get_columns($connection_string, $query); default: return ""; } break; // Data query // Response to the client - data in the xml format // Data query // Response to the client - data in the xml format case "LoadData": $connection_type = sti_get_xml_value($client_data, "ConnectionType"); $data_path = sti_get_xml_value($client_data, "DataPath"); $schema_path = sti_get_xml_value($client_data, "SchemaPath"); $connection_string = sti_create_connection_string($client_data); $data_source_name = sti_get_xml_value($client_data, "DataSourceName"); $query = sti_get_xml_value($client_data, "Query"); $query = base64_decode($query); switch ($connection_type) { case "StiXmlDatabase": return sti_xml_get_data($data_path, $schema_path); case "StiSqlDatabase": return sti_mssql_get_data($connection_string, $data_source_name, $query); case "StiMySqlDatabase": return sti_mysql_get_data($connection_string, $data_source_name, $query); case "StiOdbcDatabase": return sti_odbc_get_data($connection_string, $data_source_name, $query); case "StiPostgreSQLDatabase": return sti_pg_get_data($connection_string, $data_source_name, $query); case "StiOracleDatabase": return sti_oracle_get_data($connection_string, $data_source_name, $query); case "StiFirebirdDatabase": return sti_firebird_get_data($connection_string, $data_source_name, $query); case "StiMongoDBDatabase": return sti_mongodb_get_data($connection_string, $data_source_name, $query); default: return ""; } break; // Exported report // Exported report case "ExportReport": $format = sti_get_xml_value($client_data, "Format"); $report_key = sti_get_xml_value($client_data, "ReportKey"); $file_name = sti_get_xml_value($client_data, "FileName"); $data = base64_decode(sti_get_xml_value($client_data, "Data")); return sti_export_report($format, $report_key, $file_name, $data); break; // Send report by E-mail // Send report by E-mail case "SendEmailReport": $options = new DOMDocument(); $options->loadXML($client_data); $format = $options->getElementsByTagName("Format")->item(0)->nodeValue; $report_key = $options->getElementsByTagName("ReportKey")->item(0)->nodeValue; $data = base64_decode($options->getElementsByTagName("Data")->item(0)->nodeValue); $email_options = $options->getElementsByTagName("EmailOptions")->item(0); $email = $email_options->getElementsByTagName("Email")->item(0)->nodeValue; $subject = $email_options->getElementsByTagName("Subject")->item(0)->nodeValue; $message = $email_options->getElementsByTagName("Message")->item(0)->nodeValue; $file_name = $email_options->getElementsByTagName("FileName")->item(0)->nodeValue; return sti_send_email_report($format, $report_key, $email, $subject, $message, $file_name, $data); break; } }