joomla/com_wk1/site/wk1.php
<?php
/**
* @package Joomla.Administrator
* @subpackage com_wk1
*
* @copyright
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$fun = 9;
if ($fun == 1) {
echo "<html><body><h1>wk1.php direct echo<h1>from " . __file__ . "</body>";
jExit();
} elseif ($fun == 2) {
// $fn = 'images/cyrSpa50.jpg';
$fn = '/wkArchive/bilder/2016/1608steingletscher/DSCN0310p700.JPG';
$mimeTypes = array(
'pdf' => 'application/pdf',
'txt' => 'text/plain',
'html' => 'text/html',
'exe' => 'application/octet-stream',
'zip' => 'application/zip',
'doc' => 'application/msword',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'gif' => 'image/gif',
'png' => 'image/png',
'jpeg' => 'image/jpg',
'jpg' => 'image/jpg',
'php' => 'text/plain'
);
if ( ! is_readable($fn) ) {
echo "<h1>is not readable: $fn</h1>";
} elseif ( ! is_file($fn) ) {
echo "<h1>is not a regular file: $fn</h1>";
} elseif ( ! isset($mimeTypes[$ty = strtolower(substr($fn, strrpos($fn, '.') + 1))]) ) {
echo "<h1> tiletype '$ty' not supported for file: $fn</h1>";
} else {
header('Content-Type: ' . $mimeTypes[$ty]);
readFile($fn);
}
jExit();
} elseif ($fun == 9) {
echo '<ul><li> component wk1 from ' . __file__ ;
echo '</li><li>$_SERVER[REQUEST_METHOD] = ' . $_SERVER['REQUEST_METHOD'];
echo '</li><li>$_SERVER[REQUEST_URI] = ' . $_SERVER['REQUEST_URI'];
echo '</li><li> $_GET = '; print_r($_GET);
echo '</li><li> $_POST = '; print_r($_POST);
echo '</li><li> headers_list() = '; print_r(headers_list());
echo '</li><li> headers_sent() = '; print_r(headers_sent());
echo '</li><li>filesize = ' . filesize('/wkArchive/bilder/2016/1608steingletscher/DSCN0310p700.JPG');
echo '</li><li>JURI toString = ' .JURI::getInstance()->toString();
echo '</li><li>JURI = '; print_r(JURI::getInstance());
echo '</li><li>input->get(file) = '; print_r(JFactory::getApplication()->input->get('file', 'fileUndefined'));
echo '</li><li>input = '; print_r(JFactory::getApplication()->input);
echo '</li><li>Wk1::log</li>' . Wk1Router::$msg . '</ul>';
echo '</li></ul>';
}
// Get an instance of the controller prefixed by wk1
$controller = JControllerLegacy::getInstance('Wk1');
// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));
// Redirect if set by the controller
$controller->redirect();