Example #1
0
<?php

require_once 'functions.php';
require_once 'functions/auth.php';
AUTH_ENABLE && force_login();
header('Content-Type: text/html; charset=utf-8');
/*
ini_set("log_errors", 1);
ini_set("error_log", "/var/log/php_errors.log");
*/
function get_online_objects()
{
    $device_browser_list = mmc_array_values(NS_DEVICE_LIST);
    time_print('性能分析:取列表:');
    if (isset($_GET['debug'])) {
        $device_count = mmc_array_length(NS_DEVICE_LIST);
        $memcache_obj = new Memcache();
        $memcache_obj->connect(MEMC_HOST, MEMC_PORT);
        $stats = $memcache_obj->getStats();
        $memcache_obj->close();
        $dbg_print = '开始时间:' . getDateStyle($stats['time'] - $stats['uptime']);
        $dbg_print .= ' 使用内存: ' . bytesToSize($stats['bytes']) . '/' . bytesToSize($stats['limit_maxbytes']);
        $dbg_print .= '<br>清理时间:' . getDateStyle(async_timer('/on_timer_online_list.php'));
        $dbg_print .= ' 维护设备数: ' . $device_count . '  活跃设备数: ' . count($device_browser_list);
        $xmlStr = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . '/channels-stats');
        $channels = json_decode($xmlStr);
        $dbg_print .= '<br>推送开始:' . getDateStyle(time() - $channels->uptime) . ' 频道数: ' . $channels->channels;
        $dbg_print .= ' 订阅数: ' . $channels->subscribers . ' 消息数: ' . $channels->published_messages;
        $dbg_print .= '<br>流程计数: ' . counter() . '<br>';
        echo $dbg_print;
    }
Example #2
0
function force_level($level)
{
    force_login();
    if (user()->level < $level) {
        header('HTTP/1.1 403 Access denied');
        echo '<div id="error">Deine Berechtigungen erlauben Dir nicht, diese Seite zu sehen</div>';
        return false;
    }
    return true;
}
<?php

force_login();
if (!empty($_POST)) {
    // PHP Code; nur für Admins {{{
    if (user()->level >= 2 && isset($_POST['code']) && $_POST['code'] && trim($_POST['desc'])) {
        // Vorschau-Modus
        if (isset($_POST['preview'])) {
            ob_end_clean();
            $userFn = create_function('', $_POST['code']);
            admin_log("Testet Code:\n| " . str_replace("\n", "\n| ", $_POST['code']));
            foreach ($userFn() as $item) {
                $sheet_out = format_data($item);
                list($url, $text) = split_data($item);
                if ($url) {
                    // Prüfen, ob die URL existiert
                    try {
                        check_if_url_changed($url, false);
                    } catch (Exception $ignore) {
                        $sheet_out .= ' (Die Datei wurde nicht gefunden)';
                    }
                }
                echo '<li>' . $sheet_out . '</li>';
            }
            die;
        }
        // Einen Testdurchlauf machen
        $userFn = create_function('', $_POST['code']);
        $retval = $userFn();
        if (empty($retVal) || is_array($retVal)) {
            admin_log("Speichert Code:\n| " . str_replace("\n", "\n| ", $_POST['code']));
/**
* check_authentication returns a username from http authentication or the session and forces login if not found
* @param string $msg_uname unique name of text blurb to show on the login page
* @deprecated since reason 4 beta 4 - use reason_check_authentication or reason_require_authentication
* @return string $username
*/
function check_authentication($msg_uname = '')
{
		if($username = get_authentication_from_server())
		{
				return $username;
		}
		else
		{
				if($username = get_authentication_from_session())
				{
						return $username;
				}
				else
				{
						force_login($msg_uname);
				}
		}
}
Example #5
0
	function _handle_authorization()
	{
		if(!empty($this->params['authorization']))
		{
			reason_include_once($this->params['authorization']);
			if(empty($GLOBALS[ '_reason_publication_auth_classes' ][$this->params['authorization']]) || !class_exists($GLOBALS[ '_reason_publication_auth_classes' ][$this->params['authorization']]))
			{
				trigger_error($this->params['authorization'].' did not define its class name properly in $GLOBALS[ \'_reason_publication_auth_classes\' ]');
				return; // should it shut everything down or open everything up???
			}
			else
			{
				$netid = $this->get_user_netid();
				$item_id = !empty($this->request[ $this->query_string_frag.'_id' ]) ? $this->request[ $this->query_string_frag.'_id' ] : NULL;
				
				$auth = new $GLOBALS[ '_reason_publication_auth_classes' ][$this->params['authorization']]();
				$auth->set_username($netid);
				$auth->set_item_id($item_id);
				if($this->has_issues())
				{
					$auth->set_issue_id($this->issue_id);
					if($ri = $this->get_most_recent_issue());
						$auth->set_most_recent_issue_id($ri->id());
				}
				if(!$auth->authorized_to_view())
				{
					if(!$netid)
					{
						// header to the login page
						force_login($auth->get_login_message_unique_name());
					}
					else
					{
						// store a not authorized flag for the display phase to pick up
						$this->_ok_to_view = false;
						$this->_unauthorized_message = $auth->get_unauthorized_message();
					}
				}
			}
		}
	}
Example #6
0
<?php

require_once "model/image.model.php";
require_once "model/user.model.php";
if (!force_login()) {
    exit;
}
unset($user);
if (isset($_SESSION['user'])) {
    $user = new userCon($_SESSION['user']);
}
$action = isset($_GET['action']);
$imgs = load_images_by_user_id($user->getId());
$page = isset($_GET['page']) ? $_GET['page'] * 1 : 1;
$img_nbr = isset($_GET['nbr']) ? $_GET['nbr'] * 1 : 3;
if (count($imgs) % $img_nbr == 0) {
    $page_count = floor(count($imgs) / $img_nbr);
} else {
    $page_count = floor(count($imgs) / $img_nbr + 1);
}
$imgs = array_slice($imgs, ($page - 1) * $img_nbr, $img_nbr);
if (!$clean) {
    require_once "view/gallery.view.php";
}