Example #1
0
 private static function loginValid_file()
 {
     $http_user = $_SERVER['PHP_AUTH_USER'];
     $http_pass = $_SERVER['PHP_AUTH_PW'];
     $method = Config::get('auth_method');
     switch ($method) {
         case 'file':
             $file = Config::get('auth_file');
             if (file_exists($file)) {
                 $lines = file($file);
                 $users = array();
                 foreach ($lines as $line) {
                     list($user, $hash) = explode(':', $line);
                     $users[trim($user)] = trim($hash);
                 }
                 if (array_key_exists($http_user, $users) && $users[$http_user] == $http_pass) {
                     return true;
                 }
             }
             break;
         default:
             return true;
             break;
     }
     return false;
 }
Example #2
0
 /**
  * Intialize logger
  *
  * @static
  * @access public
  *
  * @throws \Exception        If log directory not exists or not writeable
  */
 public static function init()
 {
     self::$logdir = realpath(Config::read('log_dir'));
     self::$level = Config::read('log_level');
     if (!file_exists(self::$logdir)) {
         throw new Exception('Log directory "' . self::$logdir . '" does not exist.');
     }
     if (!is_writeable(self::$logdir)) {
         throw new Exception('Log directory "' . self::$logdir . '" is not writeable.');
     }
 }
Example #3
0
        if (file_exists($filepath)) {
            $content .= "\n// " . $filename . "\n\n";
            $content .= file_get_contents($filepath);
        }
    }
    if (Config::read('minify_js')) {
    }
    header('Content-Type: application/javascript');
    echo trim($content);
}
if (isset($_GET['css'])) {
    $tmp = explode('|', $_GET['css']);
    $path = BASE_PATH . DS . 'res' . DS . 'css' . DS;
    $content = '';
    foreach ($tmp as $filename) {
        $filepath = $path . $filename;
        if (file_exists($filepath)) {
            $content .= "\n/* " . $filename . " */\n\n";
            $content .= file_get_contents($filepath);
        }
    }
    if (Config::read('minify_css')) {
        $content = preg_replace('#/\\*.*?\\*/#s', '', $content);
        $content = preg_replace('/\\s*([{}|:;,])\\s+/', '$1', $content);
        $content = preg_replace('/\\s\\s+(.*)/', '$1', $content);
        $content = str_replace(';}', '}', $content);
    }
    $content = str_replace('../', 'res/', $content);
    header('Content-Type: text/css');
    echo trim($content);
}
Example #4
0
            <link rel="stylesheet" type="text/css" href="res/css/<?php 
        echo $cssfile;
        ?>
" />
        <?php 
    }
    ?>
    <?php 
}
?>

	<script src="res/js/jquery.min.js" type="text/javascript"></script>
	<script src="res/jqueryui/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>

    <?php 
if (Config::read('minify_js')) {
    ?>

        <script type="text/javascript" src="resources.php?js=<?php 
    echo join('|', $javascript);
    ?>
"></script>
    <?php 
} else {
    ?>

        <?php 
    foreach ($javascript as $jsfile) {
        ?>

            <script type="text/javascript" src="res/js/<?php 
Example #5
0
 /**
  * Subscribe to event notifies
  *
  * @access public
  *
  * @return string    Subscription ID
  */
 public function subscribe()
 {
     $url = $this->service->getEventSubUrl();
     $urldata = parse_url($url);
     $eventUrl = 'http://' . Config::read('host_name') . '/pupnp/event.php';
     $header = array('HOST: ' . $urldata['host'] . ':' . $urldata['port'], 'USER-AGENT: Linux/2.6.31-1.0 UPnP/1.0 pupnp/0.1', 'CALLBACK: <' . $eventUrl . '>', 'NT: upnp:event', 'TIMEOUT: 180');
     Logger::debug('Subscribe to ' . $this->device->getId() . ' with: ' . "\n" . print_r($header, true), 'subscription');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->service->getEventSubUrl());
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'SUBSCRIBE');
     $result = curl_exec($ch);
     $tmp = explode("\r\n", trim($result));
     $response = array();
     foreach ($tmp as $line) {
         $tmp = explode(':', $line);
         $key = strtoupper(trim(array_shift($tmp)));
         $value = trim(join(':', $tmp));
         $response[$key] = $value;
     }
     if (isset($response['SID'])) {
         return $response['SID'];
     }
     return null;
 }
Example #6
0
 */
use at\mkweb\upnp\Config;
use at\mkweb\upnp\frontend\AuthManager;
require_once 'src/at/mkweb/upnp/init.php';
if (AuthManager::authEnabled()) {
    AuthManager::authenticate();
}
$config = Config::getAll();
$errors = array();
if (isset($_POST['save'])) {
    $new = $_POST['config'];
    $errors = Config::validate($new);
    print_r($errors);
    print_r($_POST);
    if (count($errors) == 0) {
        Config::change($new);
        $_SESSION['flash'] = _('Sucessfully saved.');
        header('Location: ?page=config');
        exit;
    }
}
?>
<html>
<head>
    <title>pUPnP Device Tester</title>

    <link rel="stylesheet" type="text/css" href="res/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="resources.php?css=style.css" />
            
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="res/js/bootstrap.min.js"></script>