merge upstream phpxmlrpc
[plcapi.git] / php / phpxmlrpc / demo / server / _prepend.php
diff --git a/php/phpxmlrpc/demo/server/_prepend.php b/php/phpxmlrpc/demo/server/_prepend.php
new file mode 100644 (file)
index 0000000..8dbf6cf
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Hackish code used to make the demos both viewable as source, runnable, and viewable as html
+ */
+
+// Make errors visible
+ini_set('display_errors', true);
+error_reporting(E_ALL);
+
+if (isset($_GET['showSource']) && $_GET['showSource']) {
+    $file = debug_backtrace()[0]['file'];
+    highlight_file($file);
+    die();
+}
+
+// Use the custom class autoloader. These two lines not needed when the phpxmlrpc library is installed using Composer
+include_once __DIR__ . '/../../src/Autoloader.php';
+PhpXmlRpc\Autoloader::register();
+
+// Out-of-band information: let the client manipulate the server operations.
+// We do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+    $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
+    if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
+        mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+        chmod($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 0777);
+    }
+
+    include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
+}