Fixed a bug in FileBrowser Module wherein no returns would lead to calls being interpreted as failed. Also fixed a short-form PHP tag to long-form in index.php
parent
d2dbb72d06
commit
4b4e71279c
|
@ -241,10 +241,14 @@ class MediaServe {
|
|||
Params:
|
||||
$var - variable name to store
|
||||
$data - data to store
|
||||
|
||||
Returns:
|
||||
Pointer to stored variable
|
||||
================================
|
||||
*/
|
||||
static function storeData($var, $data) {
|
||||
static function &storeData($var, $data) {
|
||||
$_SESSION[$var] = $data;
|
||||
return $_SESSION[$var];
|
||||
}
|
||||
/*
|
||||
================================
|
||||
|
|
132
MusicServe.php
132
MusicServe.php
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
namespace ktk\MusicServe;
|
||||
session_start();
|
||||
|
||||
class MusicServe {
|
||||
static public $modules = array();
|
||||
static public $errors = array();
|
||||
static public $warnings = array();
|
||||
static private $storage = array();
|
||||
|
||||
static function loadModule($name) {
|
||||
if (file_exists('modules/'.$name.'.php')) {
|
||||
include_once 'modules/'.$name.'.php';
|
||||
array_push(self::$modules, $name);
|
||||
} else {
|
||||
self::reportError(__CLASS__, __FUNCTION__, "Module ".$name." does not exist!");
|
||||
}
|
||||
}
|
||||
static function checkModule($name) {
|
||||
return array_search($name, self::$modules);
|
||||
}
|
||||
|
||||
static function initProgram() {
|
||||
foreach(self::$modules as $module) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$module, 'onInit')) {
|
||||
call_user_func('ktk\\MusicServe\\'.$module.'::onInit');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function processProgram() {
|
||||
// check for module commands and call them if so
|
||||
if (isset($_POST['m'])) {
|
||||
if (isset($_POST['c'])) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$_POST['m'], $_POST['c'])) {
|
||||
call_user_func('ktk\\MusicServe\\'.$_POST['m'].'::'.$_POST['c'], $_POST['p1']);
|
||||
}
|
||||
}
|
||||
} else if (isset($_GET['m'])) {
|
||||
if (isset($_GET['c'])) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$_GET['m'], $_GET['c'])) {
|
||||
call_user_func('ktk\\MusicServe\\'.$_GET['m'].'::'.$_GET['c'], $_GET['p1']);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach(self::$modules as $module) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$module, 'onProcess')) {
|
||||
call_user_func('ktk\\MusicServe\\'.$module.'::onProcess');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function renderCss() {
|
||||
echo ' <link rel="stylesheet" href="main.css" type="text/css" media="screen" charset="utf-8">'.PHP_EOL;
|
||||
foreach(self::$modules as $module) {
|
||||
if (file_exists('modules/'.$module.'.css')) {
|
||||
echo ' <link rel="stylesheet" href="modules/'.$module.'.css" type="text/css" media="screen" charset="utf-8">'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function renderProgram() {
|
||||
foreach(self::$modules as $module) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$module, 'onRender')) {
|
||||
call_user_func('ktk\\MusicServe\\'.$module.'::onRender');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function closeProgram() {
|
||||
foreach(self::$modules as $module) {
|
||||
if (method_exists('ktk\\MusicServe\\'.$module, 'onClose')) {
|
||||
call_user_func('ktk\\MusicServe\\'.$module.'::onClose');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function reportError($context, $subcontext, $error) {
|
||||
if(!self::$errors[$context."::".$subcontext])
|
||||
self::$errors[$context."::".$subcontext] = array();
|
||||
array_push(self::$errors[$context."::".$subcontext], $error);
|
||||
}
|
||||
|
||||
static function reportWarning($context, $subcontext, $warning) {
|
||||
if(!self::$warnings[$context."::".$subcontext])
|
||||
self::$warnings[$context."::".$subcontext] = array();
|
||||
array_push(self::$warnings[$context."::".$subcontext], $warning);
|
||||
}
|
||||
|
||||
static function loadConf($file) {
|
||||
if (file_exists('conf/'.$file.'.ini')) {
|
||||
return parse_ini_file('conf/'.$file.'.ini');
|
||||
} else {
|
||||
self::reportWarning(__CLASS__, __FUNCTION__, "Could not load ".'conf/'.$file.'.ini');
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
static function saveConf($data) {
|
||||
if ($fp = fopen($data, 'w')) {
|
||||
self::writeData_r($fp, $data);
|
||||
fclose($fp);
|
||||
} else {
|
||||
MusicServe::reportError(__CLASS__, __FUNCTION__, "Could not write to \"".$data."\", please check your permissions!");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
static function writeData_r($handle, $value) {
|
||||
foreach ($data as $key=>$value) {
|
||||
if (is_array($value)) {
|
||||
fwrite($handle, '['.$key.']'.PHP_EOL);
|
||||
self::writeData_r($handle, $value);
|
||||
} else {
|
||||
fwrite($handle, $key.'='.$value.PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static function storeData($var, $data) {
|
||||
$_SESSION[$var] = $data;
|
||||
}
|
||||
|
||||
static function &getData($data) {
|
||||
if (isset($_SESSION[$data])) {
|
||||
return $_SESSION[$data];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -10,7 +10,7 @@ ktk\MediaServe\MediaServe::loadModule("Player");
|
|||
ktk\MediaServe\MediaServe::initProgram();
|
||||
ktk\MediaServe\MediaServe::processProgram();
|
||||
?>
|
||||
<? echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
||||
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
|
|
|
@ -119,7 +119,6 @@ class FileBrowser {
|
|||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!$directory_handle = opendir($directory)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -137,7 +136,7 @@ class FileBrowser {
|
|||
$i++;
|
||||
}
|
||||
}
|
||||
MediaServe::storeData('dir_list', $files);
|
||||
return(MediaServe::storeData('dir_list', $files));
|
||||
}
|
||||
|
||||
/* INTERNAL FUNCTIONS */
|
||||
|
|
Loading…
Reference in New Issue