Example #1
0
 /**
  * Call
  * @param array $env
  * @return array[status, header, body]
  */
 public function call(&$env)
 {
     try {
         return $this->app->call($env);
     } catch (Exception $e) {
         $env['slim.log']->error($e);
         $response = new Slim_Http_Response($this->renderBody($env, $e), 500);
         return $response->finalize();
     }
 }
 public function set_current_theme()
 {
     if (!$this->isAjax || $this->method != 'POST' || empty($this->postData['themename'])) {
         $this->app->abort(404, 'Page not found...');
     }
     if ($no_auth = $this->checkAuth()) {
         return $no_auth;
     }
     $data = array();
     $data['action'] = 'manageTheme';
     $error = $this->setlocalization('There is no such skin');
     $data['name'] = $data['title'] = $data['preview'] = '';
     $themes = \Middleware::getThemes();
     if (!empty($themes) && in_array($this->postData['themename'], $themes)) {
         $this->db->setCurrentTheme($this->postData['themename']);
         $error = '';
         $event = new \SysEvent();
         $event->setUserListByMac('online');
         $event->sendReboot();
         $data['name'] = $this->postData['themename'];
         $data['title'] = ucwords(str_replace('_', ' ', $this->postData['themename']));
         $data['preview'] = $this->theme_path . $this->postData['themename'] . "/preview.png";
     }
     $response = $this->generateAjaxResponse($data, $error);
     return new Response(json_encode($response), empty($error) ? 200 : 500);
 }
Example #3
0
 private static function action()
 {
     //禁止使用模块检测
     if (in_array(MODULE, C('http.deny_module'))) {
         throw new Exception("模块禁止访问");
     }
     $class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
     //控制器不存在
     if (!class_exists($class)) {
         throw new Exception("{$class} 不存在");
     }
     $controller = Route::$app->make($class, TRUE);
     //执行控制器中间件
     \Middleware::performControllerMiddleware();
     //执行动作
     try {
         $reflection = new ReflectionMethod($controller, ACTION);
         if ($reflection->isPublic()) {
             //执行动作
             if ($result = call_user_func_array([$controller, ACTION], self::$routeArgs)) {
                 if (IS_AJAX && is_array($result)) {
                     ajax($result);
                 } else {
                     echo $result;
                 }
             }
         } else {
             throw new ReflectionException('请求地址不存在');
         }
     } catch (ReflectionException $e) {
         $action = new ReflectionMethod($controller, '__call');
         $action->invokeArgs($controller, [ACTION, '']);
     }
 }
Example #4
0
 public function bootstrap()
 {
     $this->constant();
     //加载服务配置项
     $servers = (require __DIR__ . '/service.php');
     $config = (require ROOT_PATH . '/system/config/service.php');
     $servers['providers'] = array_merge($config['providers'], $servers['providers']);
     $servers['facades'] = array_merge($config['facades'], $servers['facades']);
     $this->servers = $servers;
     //自动加载系统服务
     Loader::register([$this, 'autoload']);
     //绑定核心服务提供者
     $this->bindServiceProvider();
     //添加初始实例
     $this->instance('App', $this);
     //设置外观类APP属性
     ServiceFacade::setFacadeApplication($this);
     //启动服务
     $this->boot();
     //定义错误/异常处理
     Error::bootstrap();
     //命令行模式
     IS_CLI and die(Cli::bootstrap());
     //导入类库别名
     Loader::addMap(c('app.alias'));
     //自动加载文件
     Loader::autoloadFile();
     //开启会话
     Session::start();
     //执行全局中间件
     Middleware::globals();
     //解析路由
     Route::dispatch();
 }
Example #5
0
 private static function action()
 {
     //禁止使用模块检测
     if (in_array(MODULE, C('http.deny_module'))) {
         throw new Exception("模块禁止访问");
     }
     $class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
     //控制器不存在
     if (!class_exists($class)) {
         throw new Exception("{$class} 不存在");
     }
     $controller = Route::$app->make($class, true);
     //执行控制器中间件
     Middleware::controller();
     //执行动作
     try {
         $result = App::callMethod($controller, ACTION);
         if (IS_AJAX && is_array($result)) {
             ajax($result);
         } else {
             echo $result;
         }
     } catch (ReflectionException $e) {
         $action = new ReflectionMethod($controller, '__call');
         $action->invokeArgs($controller, [ACTION, '']);
     }
 }
 public function create(RESTRequest $request)
 {
     $data = $request->getData();
     if (empty($data)) {
         throw new RESTCommandException('HTTP POST data is empty');
     }
     $allowed_to_update_fields = array_fill_keys(array('login', 'password', 'full_name', 'phone', 'account_number', 'tariff_plan', 'status', 'stb_mac', 'comment', 'end_date', 'account_balance'), true);
     $account = array_intersect_key($data, $allowed_to_update_fields);
     if (empty($account)) {
         throw new RESTCommandException('Insert data is empty');
     }
     if (!empty($account['stb_mac'])) {
         $mac = Middleware::normalizeMac($account['stb_mac']);
         if (!$mac) {
             throw new RESTCommandException('Not valid mac address');
         }
         $account['stb_mac'] = $mac;
     }
     if (empty($account['login'])) {
         throw new RESTCommandException('Login required');
     }
     $user = User::getByLogin($account['login']);
     if (!empty($user)) {
         throw new RESTCommandException('Login already in use');
     }
     if (!empty($account['stb_mac'])) {
         $user = User::getByMac($account['stb_mac']);
         if (!empty($user)) {
             throw new RESTCommandException('MAC address already in use');
         }
     }
     return (bool) User::createAccount($account);
 }
 protected function parseUri()
 {
     $path = isset($_GET['route']) ? $_GET['route'] : ST::redirectToRoute('Index/index');
     $path = trim(parse_url($path, PHP_URL_PATH), "/");
     @(list($controller, $action, $params) = explode("/", $path, 3));
     $mv = new Middleware();
     $mv->ProcessCheck($mv->CheckRequestedRoute(strtolower($controller), strtolower($action)));
     if (isset($controller)) {
         $this->setController($controller);
     }
     if (isset($action)) {
         $this->setAction($action);
     }
     if (isset($params)) {
         $this->setParams(explode("/", $params));
     }
 }
 private function filter($profile)
 {
     if (empty($profile)) {
         throw new RESTNotFound("User not found");
     }
     $profile = array_intersect_key($profile, $this->fields_map);
     $themes = \Middleware::getThemes();
     $profile['theme'] = empty($profile['theme']) || !array_key_exists($profile['theme'], $themes) ? \Mysql::getInstance()->from('settings')->get()->first('default_template') : $profile['theme'];
     $profile['themes'] = $themes;
     return $profile;
 }
Example #9
0
 /**
  * Set user list by id
  *
  * @param mixed $list
  */
 public function setUserListById($list)
 {
     if (is_string($list) || is_int($list)) {
         if ($list == 'all') {
             $this->param['user_list'] = Middleware::getAllUsersId();
         } else {
             $this->param['user_list'] = array($list);
         }
     } else {
         $this->param['user_list'] = $list;
     }
 }
Example #10
0
 /**
  * Toupti constructor
  * @todo throw TouptiException if not instance of Route (wrong path)
  */
 public function __construct($conf = array())
 {
     parent::__construct($conf);
     if (isset($this->conf['route'])) {
         include $this->conf['route'];
         $this->route = $route;
         // throw TouptiException if not instance of Route
         if (!$this->route instanceof Route) {
             throw new TouptiException("Unable to load route from {$this->conf['route']}.");
         }
     } else {
         $this->route = new Route();
     }
 }
Example #11
0
 private static function action()
 {
     //禁止使用模块检测
     if (in_array(MODULE, C('http.deny_module'))) {
         throw new Exception("模块禁止访问");
     }
     $class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
     //控制器不存在
     if (!class_exists($class)) {
         throw new Exception("{$class} 不存在");
     }
     $controller = App::make($class, true);
     //执行控制器中间件
     Middleware::controller();
     //执行动作
     try {
         /**
          * 参数处理
          * 控制器路由方式访问时解析路由参数并注入到控制器方法参数中
          */
         //反射方法实例
         $reflectionMethod = new \ReflectionMethod($class, ACTION);
         $args = [];
         foreach ($reflectionMethod->getParameters() as $k => $p) {
             if (isset(self::$routeArgs[$p->name])) {
                 //如果GET变量中存在则将GET变量值赋予,也就是说GET优先级高
                 $args[$p->name] = self::$routeArgs[$p->name];
             } else {
                 //如果类型为类时分析类
                 if ($dependency = $p->getClass()) {
                     $args[$p->name] = App::build($dependency->name);
                 } else {
                     //普通参数时获取默认值
                     $args[$p->name] = App::resolveNonClass($p);
                 }
             }
         }
         //执行控制器方法
         $result = $reflectionMethod->invokeArgs($controller, $args);
         if (IS_AJAX && is_array($result)) {
             ajax($result);
         } else {
             echo $result;
         }
     } catch (ReflectionException $e) {
         $action = new ReflectionMethod($controller, '__call');
         $action->invokeArgs($controller, [ACTION, '']);
     }
 }
Example #12
0
 public function bootstrap()
 {
     define('IS_CLI', PHP_SAPI == 'cli');
     define('NOW', $_SERVER['REQUEST_TIME']);
     define('__ROOT__', IS_CLI ? '' : trim('http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']), '/\\'));
     IS_CLI or define('IS_GET', $_SERVER['REQUEST_METHOD'] == 'GET');
     IS_CLI or define('IS_POST', $_SERVER['REQUEST_METHOD'] == 'POST');
     IS_CLI or define('IS_DELETE', $_SERVER['REQUEST_METHOD'] == 'DELETE' ? TRUE : isset($_POST['_method']) && $_POST['_method'] == 'DELETE');
     IS_CLI or define('IS_PUT', $_SERVER['REQUEST_METHOD'] == 'PUT' ? TRUE : isset($_POST['_method']) && $_POST['_method'] == 'PUT');
     IS_CLI or define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
     IS_CLI or define('IS_WEIXIN', isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== FALSE);
     IS_CLI or define('__URL__', trim('http://' . $_SERVER['HTTP_HOST'] . '/' . trim($_SERVER['REQUEST_URI'], '/\\'), '/'));
     IS_CLI or define("__HISTORY__", isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '');
     //加载服务配置项
     $servers = (require __DIR__ . '/service.php');
     $config = (require ROOT_PATH . '/system/config/service.php');
     $servers['providers'] = array_merge($config['providers'], $servers['providers']);
     $servers['facades'] = array_merge($config['facades'], $servers['facades']);
     $this->servers = $servers;
     //自动加载系统服务
     Loader::register([$this, 'autoload']);
     //绑定核心服务提供者
     $this->bindServiceProvider();
     //添加初始实例
     $this->instance('App', $this);
     //设置外观类APP属性
     ServiceFacade::setFacadeApplication($this);
     //定义错误/异常处理
     Error::bootstrap();
     //导入类库别名
     Loader::addMap(c('app.alias'));
     //自动加载文件
     Loader::autoloadFile();
     //启动服务
     $this->boot();
     //CLI模式
     $this->cli();
     //应用开始中间件
     \Middleware::exe('app_start');
     //解析路由
     Route::dispatch();
     //记录日志
     Log::save();
     //中间件
     \Middleware::exe('app_end');
 }
Example #13
0
 private function compare($uri)
 {
     $this->uri = $uri;
     $this->uri = trim($this->uri, "/");
     $this->params = explode(",", $this->uri);
     $this->params = array_shift($this->params);
     if (array_key_exists($this->uri, Config::get("valid_requests"))) {
         if (array_key_exists('middleware', Config::get("valid_requests")[$this->uri])) {
             foreach (Config::get("valid_requests")[$this->uri]['middleware'] as $middleware) {
                 Middleware::run($middleware);
             }
         }
         $this->controller = $this->declareController(Config::get("valid_requests")[$this->uri]['controller']);
         $this->method = Config::get("valid_requests")[$this->uri]['method'];
     } else {
         #print_r(Config::get("default_request")["not_found"]);
         $this->controller = $this->declareController(Config::get("default_request")["not_found"]['controller']);
         $this->method = Config::get("default_request")["not_found"]['method'];
     }
 }
 public function getEvents()
 {
     $just_started = isset($_REQUEST['init']) ? (int) $_REQUEST['init'] : 0;
     if (isset($_REQUEST['init']) && Config::getSafe('log_mac_clones', false) && $just_started == 0 && Stb::getInstance()->getParam('just_started') == 0) {
         $clone_ip = Middleware::getClonesIPAddress($this->stb->mac);
         if ($clone_ip) {
             Stb::logDoubleMAC($clone_ip);
         }
     }
     if ($this->stb->getParam('ip') != $this->stb->ip) {
         $user = User::getInstance($this->stb->id);
         $user->getInfoFromOSS();
     }
     $this->db->update('users', array('keep_alive' => 'NOW()', 'ip' => $this->stb->ip, 'now_playing_type' => intval($_REQUEST['cur_play_type']), 'just_started' => $just_started, 'last_watchdog' => 'NOW()'), array('mac' => $this->stb->mac));
     $events = Event::getAllNotEndedEvents($this->stb->id);
     $messages = count($events);
     $res['data'] = array();
     $res['data']['msgs'] = $messages;
     if ($messages > 0) {
         if ($events[0]['sended'] == 0) {
             Event::setSended($events[0]['id']);
             if ($events[0]['need_confirm'] == 0) {
                 Event::setEnded($events[0]['id']);
             }
         }
         if ($events[0]['id'] != @$_GET['data']['event_active_id']) {
             $res['data']['id'] = $events[0]['id'];
             $res['data']['event'] = $events[0]['event'];
             $res['data']['need_confirm'] = $events[0]['need_confirm'];
             $res['data']['msg'] = $events[0]['msg'];
             $res['data']['reboot_after_ok'] = $events[0]['reboot_after_ok'];
             $res['data']['auto_hide_timeout'] = $events[0]['auto_hide_timeout'];
             $res['data']['param1'] = $events[0]['param1'];
             if (Config::getSafe('display_send_time_in_message', false)) {
                 $res['data']['send_time'] = $events[0]['addtime'];
             }
         }
     }
     $res['data']['additional_services_on'] = Config::getSafe('enable_tariff_plans', false) ? '1' : $this->stb->additional_services_on;
     return $res;
 }
 public function create(RESTRequest $request)
 {
     $data = $request->getData();
     if (empty($data)) {
         throw new RESTCommandException('HTTP POST data is empty');
     }
     $allowed_to_update_fields = array_fill_keys(array('mac', 'login', 'password', 'status', 'additional_services_on', 'ls', 'end_date', 'account_balance'), true);
     $data = array_intersect_key($data, $allowed_to_update_fields);
     if (empty($data)) {
         throw new RESTCommandException('Insert data is empty');
     }
     if (isset($data['end_date'])) {
         $data['expire_billing_date'] = $data['end_date'];
         unset($data['end_date']);
     }
     if (!empty($data['mac'])) {
         $mac = Middleware::normalizeMac($data['mac']);
         if (!$mac) {
             throw new RESTCommandException('Not valid mac address');
         }
         $data['mac'] = $mac;
     }
     if (empty($data['mac']) && (empty($data['login']) || empty($data['password']))) {
         throw new RESTCommandException('Login and password required');
     }
     try {
         $uid = Stb::create($data);
     } catch (Exception $e) {
         throw new RESTCommandException($e->getMessage());
     }
     $stb_list = $this->manager->getByUids(array($uid));
     $stb_list = $this->formatList($stb_list);
     if (count($stb_list) == 1) {
         return $stb_list[0];
     }
     return $stb_list;
 }
Example #16
0
 public function push(Middleware $newMiddleware)
 {
     $newMiddleware->setApplication($this);
     $newMiddleware->setNextMiddleware($this->middleware[0]);
     array_unshift($this->middleware, $newMiddleware);
 }
Example #17
0
 public static function getByMac($mac)
 {
     $mac = Middleware::normalizeMac($mac);
     if (empty($mac)) {
         return null;
     }
     return Mysql::getInstance()->from('users')->where(array('mac' => $mac))->get()->first();
 }
 public function get_userlist_single()
 {
     $this->user_list = array(\Middleware::getUidByMac($this->postData['mac']));
     return $this;
 }
Example #19
0
<?php

include_once __DIR__ . '/Middleware.php';
$url = array_slice(preg_split('/\\//', $_GET["_url"]), 1);
$parametros = array_slice($url, 3);
$middleware = new Middleware($url[0], $url[1], $url[2]);
//echo $middleware->send();
//print_r($parametros);
include_once __DIR__ . '/util/Encrypter.php';
echo Encrypter::decrypt($middleware->send($parametros));
 private function saveUsersData(&$form, $edit = FALSE)
 {
     if (!empty($this->method) && $this->method == 'POST') {
         $form->handleRequest($this->request);
         $data = $form->getData();
         $action = isset($this->user) ? 'updateUserById' : 'insertUsers';
         if (array_key_exists('password', $data) && $edit && empty($data['password'])) {
             unset($data['password']);
         }
         if ($form->isValid()) {
             $stb_groups = new \StbGroup();
             $member = $stb_groups->getMemberByUid(intval($data['id']));
             $id = $data['id'];
             if (empty($member)) {
                 $stb_groups->addMember(array('mac' => \Middleware::normalizeMac($data['mac']), 'uid' => \Middleware::getUidByMac($data['mac']), 'stb_group_id' => $data['group_id']));
             } else {
                 $stb_groups->setMember(array('stb_group_id' => $data['group_id']), $member['id']);
             }
             $curr_fields = $this->db->getTableFields('users');
             $curr_fields = $this->getFieldFromArray($curr_fields, 'Field');
             $curr_fields = array_flip($curr_fields);
             $data = array_intersect_key($data, $curr_fields);
             $match = array();
             if (!empty($data['expire_billing_date']) && preg_match("/(0[1-9]|[12][0-9]|3[01])([- \\/\\.])(0[1-9]|1[012])[- \\/\\.](19|20)\\d\\d/im", $data['expire_billing_date'], $match)) {
                 $data['expire_billing_date'] = implode('-', array_reverse(explode($match[2], $data['expire_billing_date'])));
             } else {
                 $data['expire_billing_date'] = 0;
             }
             if ($data['reseller_id'] == '-') {
                 $data['reseller_id'] = NULL;
             }
             if (!empty($this->user) && array_key_exists('status', $this->user) && (int) $this->user['status'] != (int) $data['status']) {
                 $data['last_change_status'] = FALSE;
                 $event = new \SysEvent();
                 $event->setUserListById($data['id']);
                 if ((int) $data['status'] == 0) {
                     $event->sendCutOn();
                 } else {
                     $event->sendCutOff();
                 }
             } else {
                 unset($data['last_change_status']);
             }
             unset($data['version']);
             $result = call_user_func_array(array($this->db, $action), array($data, $data['id']));
             if (!empty($this->postData['tariff_plan_packages'])) {
                 $this->changeUserPlanPackages($id, $this->postData['tariff_plan_packages']);
             }
             return TRUE;
         }
     }
     return FALSE;
 }
Example #21
0
    $access->policy('deny');
    $access->allow('/admin/*', 'admin');
    $access->allow('GET|POST /admin/Auth*');
    $access->allow('GET|POST /admin/auth*');
    if (!$f3->exists('SESSION.user_type') && !$f3->exists('COOKIE.user')) {
        $f3->set('SESSION.user_type', 'guest');
    }
    $access->authorize($f3->get('SESSION.user_type'), function ($route, $subject) {
        \F3::reroute('@admin_pack(@pack=Auth)');
    });
    /* 
    	Default settings for template #1
    */
    if ($f3->exists("COOKIE.user") or $f3->exists("SESSION.user")) {
        $userz = \User::createUser(\kksd\Sesi::$DB);
        $userz->load(array('id=?', $f3->exists("COOKIE.user") ? $f3->COOKIE['user'] : $f3->SESSION['user']));
        $f3->set("system.user", $userz);
    }
    \Template::instance()->extend('php', function ($args) {
        $html = isset($args[0]) ? $args[0] : '';
        return "<?php {$html} ?>";
    });
});
\F3::route("GET  @admin:      /admin", "\\Control\\Admin\\App->home");
\F3::route("GET  @admin_home: /admin/dash", "\\Control\\Admin\\App->dash");
\F3::route("GET  @admin_pack: /admin/@pack", "\\Control\\Admin\\@pack->index");
\F3::route("POST @admin_pack", "\\Control\\Admin\\@pack->post_index");
\F3::route("GET  @admin_pack_func: /admin/@pack/@func", "\\Control\\Admin\\@pack->get_@func");
\F3::route("POST @admin_pack_func", "\\Control\\Admin\\@pack->post_@func");
\Middleware::instance()->run();
//we've settinged a middleware, be4.
Example #22
0
            if (file_exists($file)) {
                readfile($file);
            }
        }
    }
} elseif (strpos($_GET['type'], '.css') !== false) {
    if (preg_match('/_(\\d+)\\.css/', $_GET['type'], $match)) {
        $resolution_prefix = '_' . $match[1];
    } else {
        $resolution_prefix = '';
    }
    $user = Stb::getByMac($mac);
    if (empty($user)) {
        return false;
    }
    $theme = empty($user['theme']) || !array_key_exists($user['theme'], Middleware::getThemes()) ? Mysql::getInstance()->from('settings')->get()->first('default_template') : $user['theme'];
    $path = Config::getSafe('portal_url', '/stalker_portal/');
    ob_start(function ($buffer) use($resolution_prefix, $theme, $path) {
        return str_replace(array('i' . $resolution_prefix . '/', 'i/', 'fonts/'), array($path . 'c/template/' . $theme . '/i' . $resolution_prefix . '/', $path . 'c/template/' . $theme . '/i/', $path . 'c/template/' . $theme . '/fonts/'), $buffer);
    });
    header("Content-Type: text/css");
    foreach ($available_modules as $module) {
        if (strpos($module, 'external_') === 0) {
            continue;
        }
        $file = PROJECT_PATH . '/../c/template/' . $theme . '/' . $module . $resolution_prefix . '.css';
        if (file_exists($file)) {
            readfile($file);
        }
    }
}
$group = $stb_groups->getById($_GET['group_id']);
if (empty($group)) {
    echo 'wtf?';
    exit;
}
if (@$_POST['add']) {
    Admin::checkAccess(AdminAccess::ACCESS_CREATE);
    $stb_groups->addMember(array('mac' => Middleware::normalizeMac($_POST['mac']), 'uid' => Middleware::getUidByMac($_POST['mac']), 'stb_group_id' => $_GET['group_id']));
    header("Location: stbgroup_members.php?group_id=" . @$_GET['group_id']);
    exit;
}
$action = !empty($_POST['edit']) ? 'edit' : (!empty($_GET['del']) ? 'del' : FALSE);
if (!empty($id) && $action) {
    if ($action == 'edit') {
        Admin::checkAccess(AdminAccess::ACCESS_EDIT);
        $stb_groups->setMember(array('mac' => Middleware::normalizeMac($_POST['mac']), 'uid' => Middleware::getUidByMac($_POST['mac'])), $id);
    } else {
        Admin::checkAccess(AdminAccess::ACCESS_DELETE);
        $stb_groups->removeMember($id);
    }
    header("Location: stbgroup_members.php?group_id=" . @$_GET['group_id']);
    exit;
}
if (@$_GET['edit'] && !empty($id)) {
    $action_name = 'edit';
    $action_value = _('Save');
    $edit_member = $stb_groups->getMember($id);
}
$members = $stb_groups->getAllMembersByGroupId($_GET['group_id']);
$debug = '<!--' . ob_get_contents() . '-->';
ob_clean();
Example #24
0
 /**
  * @param Request\Request $request
  * @return array
  */
 public function buildHeader($request)
 {
     $date = gmdate('D, d M Y H:i:s T');
     $idempotencyKey = $request->getIdempotence() ? md5(uniqid(rand(), true)) : '';
     $signature = Middleware::generateSignature(parse_url($this->apiUrl, PHP_URL_HOST) . ':' . parse_url($this->apiUrl, PHP_URL_PORT), $request->getMethod(), parse_url($this->apiUrl . $request->getPath(), PHP_URL_PATH), parse_url($this->apiUrl, PHP_URL_QUERY), $date, $idempotencyKey, $request->getBody(), $this->paymentKey);
     $header = array("Host: " . parse_url($this->apiUrl, PHP_URL_HOST), "Date: " . $date, "User-Agent: " . $this->userAgent, "Authorization: BZ1-HMAC-SHA256 DivisionId=" . $this->divisionId . ", Signature=" . $signature);
     if ($idempotencyKey !== '') {
         $header[] = "Idempotency-Key: " . $idempotencyKey;
     }
     return $header;
 }
Example #25
0
session_start();
include "./common.php";
Admin::checkAuth();
Admin::checkAccess(AdminAccess::ACCESS_VIEW);
foreach (@$_POST as $key => $value) {
    //$_POST[$key] = trim($value);
}
$error = '';
$action_name = 'add';
$action_value = _('Add');
$tariff_plans = Mysql::getInstance()->select('id, name')->from('tariff_plan')->orderby('name')->get()->all();
if (!empty($_POST)) {
    if (!empty($_POST['login']) && !empty($_POST['password'])) {
        $user = \User::getByLogin($_POST['login']);
        if (!empty($_POST['stb_mac'])) {
            $mac = Middleware::normalizeMac($_POST['stb_mac']);
            $_POST['stb_mac'] = $mac;
            if (!$mac) {
                $error = _('Error: Not valid mac address');
            } else {
                $user_by_mac = \User::getByMac($mac);
                if (!empty($user_by_mac)) {
                    $error = _('Error: STB with such MAC address already exists');
                }
            }
        }
        if ($error) {
        } else {
            if (!empty($user)) {
                $error = _('Error: Login already in use');
            } else {
Example #26
0
            $event->sendPlayChannel(@$_POST['channel']);
            break;
        case 'update_image':
            $event->sendUpdateImage();
            break;
    }
}
$mac = '';
if (!empty($_POST['mac'])) {
    $mac = $_POST['mac'];
} else {
    if (!empty($_GET['mac'])) {
        $mac = $_GET['mac'];
    }
}
$uid = Middleware::getUidByMac($mac);
$events = Event::getAllNotEndedEvents($uid);
$debug = '<!--' . ob_get_contents() . '-->';
ob_clean();
echo $debug;
if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'events.php') === false) {
    $_SESSION['back_url'] = $_SERVER['HTTP_REFERER'];
} elseif (empty($_SERVER['HTTP_REFERER'])) {
    $_SESSION['back_url'] = 'index.php';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
Example #27
0
    $stb_groups = new StbGroup();
    $member = $stb_groups->getMemberByUid(intval($_GET['id']));
    if (empty($member)) {
        $stb_groups->addMember(array('mac' => Middleware::normalizeMac($_POST['mac']), 'uid' => Middleware::getUidByMac($_POST['mac']), 'stb_group_id' => $_POST['group_id']));
    } else {
        $stb_groups->setMember(array('stb_group_id' => $_POST['group_id']), $member['id']);
    }
    header("Location: profile.php?id=" . @$_GET['id']);
    exit;
}
if (@$_POST['account']) {
    Admin::checkAccess(AdminAccess::ACCESS_EDIT);
    $stb_groups = new StbGroup();
    $member = $stb_groups->getMemberByUid(intval($_GET['id']));
    if (empty($member)) {
        $stb_groups->addMember(array('mac' => Middleware::normalizeMac($_POST['mac']), 'uid' => Middleware::getUidByMac($_POST['mac']), 'stb_group_id' => $_POST['group_id']));
    } else {
        $stb_groups->setMember(array('stb_group_id' => $_POST['group_id']), $member['id']);
    }
    Mysql::getInstance()->update('users', array('fname' => $_POST['fname'], 'phone' => $_POST['phone'], 'ls' => $_POST['ls'], 'comment' => $_POST['comment'], 'expire_billing_date' => $_POST['expire_billing_date']), array('id' => intval($_GET['id'])));
    header("Location: profile.php?id=" . @$_GET['id']);
    exit;
}
if (@$_GET['video_out']) {
    Admin::checkAccess(AdminAccess::ACCESS_CONTEXT_ACTION);
    $video_out = @$_GET['video_out'];
    $id = intval($_GET['id']);
    if ($video_out == 'svideo') {
        $new_video_out = 'svideo';
    } else {
        $new_video_out = 'rca';
 $bonus2 = get_bonus2();
 $stb_id_arr = array();
 foreach ($f_cont as $cont_str) {
     list($ls, $macs, $ch) = explode(",", $cont_str);
     $macs_arr = explode(";", $macs);
     $ch = trim($ch);
     $ls = trim($ls);
     foreach ($macs_arr as $mac) {
         if (preg_match("/[а-я,А-Я]/", $mac)) {
             _log('mac "' . $mac . '", ЛС ' . $ls . ' содержит русские буквы ');
         }
         if (strpos($mac, 'ts') !== false) {
             $mac = str_replace('ts', '', $mac);
             $ch = '00203';
         }
         $mac = Middleware::normalizeMac($mac);
         if (@array_key_exists($mac, $stb_id_map)) {
             $stb = Stb::getByMac($mac);
             $status = $stb['status'];
             if ($status == 1 && $update_status) {
                 Mysql::getInstance()->update('users', array('status' => 0, 'last_change_status' => 'NOW()'), array('mac' => $mac));
                 $event = new SysEvent();
                 $event->setUserListByMac($mac);
                 $event->sendCutOn();
                 $cut_on++;
             }
             $stb_id = $stb_id_map[$mac];
             $stb_id_arr[] = $stb_id;
             if (array_key_exists($ch, $service_id_map)) {
                 if (!@array_key_exists($stb_id, $result)) {
                     $result[$stb_id] = array();
Example #29
0
 public static function run($resource, $method)
 {
     $top = count(self::$stack) - 1;
     if ($top < 0) {
         return;
     }
     $isExternal = $top == 0;
     $resource = Route::route($resource, self::$stack[$top]);
     if (!self::isAvailable($resource, $method)) {
         if ($isExternal) {
             $resource = 'errors/access-denied';
         } else {
             return '';
         }
     }
     list($controller, $action, $data) = Url::route($resource, $method);
     self::$stack[$top] = array_merge(self::$stack[$top], $data);
     $handler = Url::handler($controller, $action);
     if ($isExternal) {
         Middleware::processBefore($resource, $action, self::$stack[$top], $method);
         self::runHandler($handler);
         Middleware::processAfter($resource, $action, self::$stack[$top], $method);
     } else {
         if (!self::runInternalHandler($handler)) {
             return '';
         }
     }
     if (!empty(self::$stack[$top]['display'])) {
         $handler .= '.' . self::$stack[$top]['display'];
     }
     if ($isExternal && self::$response->code == '404 Not Found') {
         list($controller, $action, $data) = Url::route('errors/not-found', 'get');
         $handler = Url::handler($controller, $action);
         self::$response->result("error", self::$response->code);
     }
     if ($isExternal && self::$response->code == '403 Forbidden') {
         list($controller, $action, $data) = Url::route('errors/not-found', 'get');
         $handler = Url::handler($controller, $action);
         self::$response->result("error", self::$response->code);
     }
     $r = self::$response->fetch($handler, $isExternal);
     if ($isExternal) {
         Language::rewrite($r);
     }
     return $r;
 }
 /**
  * 执行下一个预处理中间件调用
  * @return void
  */
 public final function runNext()
 {
     if ($this->nextMw) {
         $this->nextMw->call();
     }
 }