send() публичный Метод

public send ( )
Пример #1
0
 /**
  * 入口点
  */
 function run()
 {
     $response = new response();
     $cacheConfig = config('cache');
     if ($cacheConfig['cache']) {
         $cache = cache::getInstance($cacheConfig);
         $content = $cache->check($this->http->url());
         if (!empty($content)) {
             $response->setBody($content);
             $response->send();
         }
     }
     try {
         $handler = $this->parseUrl();
         if (is_array($handler)) {
             list($control, $action) = $handler;
             $path = ROOT . '/application/control/' . $control . '.php';
             if (file_exists($path)) {
                 include $path;
                 $class = 'application\\control\\' . $control . 'Control';
                 if (class_exists($class)) {
                     //$class = new \ReflectionClass($class);
                     $class = new $class();
                     $class->response =& $response;
                     if (method_exists($class, $action) && is_callable(array($class, $action)) || method_exists($class, '__call')) {
                         $response->setCode(200);
                         $response->setBody($this->__200($class, $action));
                     } else {
                         $response->setCode(404);
                         $response->setBody($this->__404($control, $action));
                     }
                 } else {
                     $response->setCode(404);
                     $response->setBody($this->__404($control, $action));
                 }
             } else {
                 $response->setCode(404);
                 $response->setBody($this->__404($control, $action));
             }
         } else {
             include ROOT . '/application/thread/' . $handler . '.php';
             $class = 'application\\thread\\' . $handler . 'Thread';
             $class = new $class();
             $class->run();
         }
     } catch (\Exception $e) {
         $response->setCode(500);
         $response->setBody($this->__500($e));
     } finally {
         $response->send();
     }
 }
Пример #2
0
 /**
  *	System interfaces syncronization
  * @access protected
  */
 protected function sys_sync()
 {
     // Сбросить со всех записей признака проверен (поле check)
     $this->_flush();
     $this->insert_on_empty = false;
     $this->push_args(array('exist' => 0, '_sexist' => 1));
     $this->_set();
     $this->pop_args();
     $ep = data_interface::get_instance('entry_point');
     $interfaces = array('ui' => $this->get_di_array(), 'di' => $this->get_ui_array());
     $ep->register($interfaces);
     // Удаляем все ТВ, которые в процессе синхронизации не были отмечены как существующие
     $this->_flush();
     $this->insert_on_empty = false;
     $this->push_args(array('_sexist' => 0));
     $this->_unset();
     // Получаем массив ID удалённых записей и удаляем их из таблицы связей с группами
     $epg = data_interface::get_instance('entry_point_group');
     $ids = (array) $this->get_lastChangedId();
     foreach ($ids as $id) {
         $epg->remove_entry_point_from_groups($id);
     }
     $this->pop_args();
     response::send(array('success' => true), 'json');
 }
Пример #3
0
 /**
  *	Get UI entry point
  */
 protected function sys_public()
 {
     $this->_flush(true);
     $this->connector->fetchMethod = PDO::FETCH_ASSOC;
     $in = $this->join_with_di('interface', array('interface_id' => 'id'), array('name' => 'interface_name'));
     $this->what = array('SUBSTRING(`' . $this->get_alias() . '`.`name`, 5)' => 'name', 'human_name');
     $this->set_args(array('_sname' => 'pub_%'), true);
     response::send($this->_get(), 'json');
 }
Пример #4
0
 public function request()
 {
     $reponse = new response();
     if (user::authorization()) {
         $reponse->authorization(true);
         try {
             $request = new request($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']);
             call_user_func_array(array($reponse, 'set_content'), $request->getResponse());
             // send Request and set_content in response
         } catch (ExceptionTodoList $e) {
             $reponse->set_content('404', $e->getMessage(), null);
             echo $reponse->send();
             exit;
         }
     } else {
         $reponse->set_content('401', errorApi::AUTHENTICATION_ERR, null);
     }
     echo $reponse->send();
 }
Пример #5
0
 /**
  *	Форма фхода в админку
  * @access	protected
  */
 public function admin()
 {
     $args = request::get(array('user', 'secret'));
     $data = array('LC' => LC::get());
     try {
         if (!empty($args)) {
             authenticate::login();
         }
     } catch (Exception $e) {
         dbg::write($e->getMessage(), LOG_PATH . 'adm_access.log');
         $data['errors'] = $e->getMessage();
     }
     if (!authenticate::is_logged()) {
         $tmpl = new tmpl($this->pwd() . 'login.html');
         response::send($tmpl->parse($data), 'html');
     } else {
         response::redirect('/xxx/');
     }
 }
Пример #6
0
 /**
  *	Remove interfaces from group
  * @access protected
  */
 protected function sys_remove_interfaces_from_group()
 {
     //dbg::write($this->get_args());
     $success = true;
     $gid = $this->get_args('gid');
     $iids = split(',', $this->get_args('iids'));
     if (!empty($iids) && $gid > 0) {
         foreach ($iids as $iid) {
             $this->_flush();
             $this->set_args(array('_siid' => $iid, '_sgid' => $gid));
             $this->_unset();
         }
     } else {
         $success = false;
     }
     response::send(array('success' => $success), 'json');
 }
Пример #7
0
 /**
  *	ExtJS Grid of available entry points
  */
 protected function sys_interfaces()
 {
     $tmpl = new tmpl($this->pwd() . 'interfaces.js');
     response::send($tmpl->parse($this), 'js');
 }
Пример #8
0
 /**
  *	Сохранить данные и вернуть JSON-пакет для ExtJS
  * @access protected
  */
 protected function sys_mset()
 {
     $records = (array) json_decode($this->get_args('records'), true);
     foreach ($records as $record) {
         $record['_sid'] = $record['id'];
         unset($record['id']);
         $this->_flush();
         $this->push_args($record);
         $this->insert_on_empty = true;
         $data = $this->extjs_set_json(false);
         $this->pop_args();
     }
     response::send(array('success' => true), 'json');
 }
Пример #9
0
 /**
  *	Unset data to storage and return results in JSON
  * @access protected
  */
 protected function sys_unset()
 {
     $this->_flush();
     $data = $this->extjs_unset_json(false);
     // Remove all links between users and deleted groups
     $gu = data_interface::get_instance('group_user');
     $epg = data_interface::get_instance('entry_point_group');
     $ids = (array) $this->get_lastChangedId();
     foreach ($ids as $gid) {
         $gu->remove_users_from_group($gid);
         $epg->remove_entry_points_from_group($gid);
     }
     response::send($data, 'json');
 }
Пример #10
0
 /**
  *       Управляющий JS админки
  */
 protected function sys_main()
 {
     $tmpl = new tmpl($this->pwd() . 'help.js');
     response::send($tmpl->parse($this), 'js');
 }
Пример #11
0
 /**
  *	Remove users from group
  * @access protected
  */
 protected function sys_remove_users_from_group()
 {
     //dbg::write($this->get_args());
     $success = true;
     $gid = $this->get_args('gid');
     $uids = explode(',', $this->get_args('uids'));
     if (!empty($uids)) {
         foreach ($uids as $uid) {
             $this->_flush();
             $this->set_args(array('_suid' => $uid, '_sgid' => $gid));
             $this->_unset();
         }
     } else {
         $success = false;
     }
     response::send(array('success' => $success), 'json');
 }
Пример #12
0
<?php

/**
*	The user interface initialization code
*
* @author	Litvinenko S. Anthon <*****@*****.**>
* @version	2.0
* @access	public
* @package	CFsCMS2(PE)
*/
try {
    // Call user interface
    $ui = user_interface::get_instance(request::get('ui', UI_DEFAULT));
    if (($content = $ui->call(request::get('cll'), request::get())) === FALSE) {
        response::header('404');
    } else {
        response::send($content, 'html');
    }
} catch (Exception $e) {
    dbg::write($e->getMessage(), LOG_PATH . 'ui_errors.log');
    //response::header('404');
    //9* 28102010
    $out = user_interface::get_instance('action_page');
    $out->set_args(array('action_msg' => $e->getMessage()));
    return $out->render();
}
Пример #13
0
 protected function sys_browser()
 {
     $tmpl = new tmpl($this->pwd() . 'file_browser.html');
     response::send($tmpl->parse($this), 'html');
 }
Пример #14
0
 /**
  *	Удалить узел
  * @access protected
  */
 protected function sys_unset()
 {
     $id = intval($this->args['_sid']);
     $ns = new nested_sets($this);
     if ($id > 0 && $ns->delete_node($id)) {
         $data = array('success' => true);
     } else {
         $data = array('success' => false);
     }
     response::send($data, 'json');
 }
Пример #15
0
<?php

/**
*	The data interface initialization code
*
* @author	Litvinenko S. Anthon <*****@*****.**>
* @version	2.0
* @access	public
* @package	SBIN Diesel	
*/
try {
    // NOTE: If defined authentication data interface and user not logged in
    /* 9* старый вариант не рубил отдачу файлов по сслке /files/?id=6 например в случае  если юзер не залогинен
    	 и вот потому  дополнительно условие если аутх мое публик то на pub_ не будем руибить доступ ибо это публик по дефолту
    
    
    	if (defined('AUTH_DI') && !authenticate::is_logged())
    	*/
    if (defined('AUTH_DI') && !authenticate::is_logged() && AUTH_MODE != 'public') {
        // Then send error
        response::send('Session closed. Authorization needed.', 'error');
    }
    $di = data_interface::get_instance(request::get('di'));
    // If return FALSE then access denied
    if (!$di->call(request::get('cll'), request::get())) {
        response::send('Access denied.', 'error');
    }
} catch (Exception $e) {
    dbg::write("UID: " . UID . "\nREQUEST_URI: {$_SERVER['REQUEST_URI']}\n" . $e->getMessage() . "\n" . $e->getTraceAsString(), LOG_PATH . 'di_errors.log');
    response::send('Error while process request.', 'error');
}
Пример #16
0
 /**
  *	JS locale file
  */
 protected function sys_app_lang()
 {
     $locale = $this->args['locale'];
     if (file_exists(LOCALES_PATH . "app-lang-{$locale}.js")) {
         $file = LOCALES_PATH . "app-lang-{$locale}.js";
     } else {
         $file = LOCALES_PATH . "app-lang-default.js";
     }
     response::send(file_get_contents($file), 'js');
 }
Пример #17
0
 /**
  *	Сохранить данные и вернуть JSON-пакет для ExtJS
  * @access protected
  */
 protected function sys_set()
 {
     global $INST_R;
     $subfold = '';
     $inst_id = $this->args['inst_id'];
     $type_id = $this->args['type_id'];
     $ops_id = $this->args['ops_id'];
     if ($this->args['dop_type'] == 'and_kernel') {
         $this->dump_kernel_to_instance_cfg = true;
     }
     if ($type_id == 4) {
         $subfold = 'current/';
     }
     if ($inst_id == 'kernel') {
         $path_di = DI_PATH;
         $path_dump = DUMP_PATH . $subfold;
         if ($ops_id == 1) {
             $this->perform_dump($type_id, $path_di, $path_dump);
         } elseif ($ops_id == 2) {
             $this->perform_init($type_id, $path_di, $path_dump);
         }
     } elseif ($inst_id == 'all') {
         //9* dump instances
         foreach ($INST_R['instances_path'] as $key => $value) {
             $path_di = $value['di_path'];
             $path_dump = $value['dump_path'] . $subfold;
             if ($ops_id == 1) {
                 $this->perform_dump($type_id, $path_di, $path_dump);
             } elseif ($ops_id == 2) {
                 $this->perform_init($type_id, $path_di, $path_dump);
             }
         }
         //9* now dump the kernel
         $path_di = DI_PATH;
         $path_dump = DUMP_PATH . $subfold;
         if ($ops_id == 1) {
             $this->perform_dump($type_id, $path_di, $path_dump);
         } elseif ($ops_id == 2) {
             $this->perform_init($type_id, $path_di, $path_dump);
         }
     } else {
         foreach ($INST_R['instances_path'] as $key => $value) {
             if ($inst_id == $value['instance_name']) {
                 $path_di = $value['di_path'];
                 $path_dump = $value['dump_path'] . $subfold;
                 if ($ops_id == 1) {
                     $this->perform_dump($type_id, $path_di, $path_dump);
                 } elseif ($ops_id == 2) {
                     $this->perform_init($type_id, $path_di, $path_dump);
                 }
             }
         }
     }
     $data['success'] = '1';
     $data['data'] = array('msg' => 'Operation completed. See log for errors.');
     response::send($data, 'json');
 }
Пример #18
0
 /**
  *	External entry point
  * Return JSON-object neccessary UI for application
  */
 protected function sys_dependencies()
 {
     $face = $this->get_args('face');
     $faces = $this->get_entry_poins('/^' . UI_CALL_PREFIX . '\\w+/');
     try {
         if (!in_array(UI_CALL_PREFIX . $face, $faces)) {
             throw new Exception("Приложение {$this->interfaceName}.{$face} не существует.");
         }
         $dependencies = array();
         $deps = (array) $this->deps[$face];
         while (!empty($deps)) {
             $app = array_shift($deps);
             list($ui_name, $call) = preg_split('/\\./', $app);
             $ui = user_interface::get_instance($ui_name);
             $sub_deps = $ui->get_dependencies($call);
             foreach ($sub_deps as $dep) {
                 array_push($deps, $dep);
             }
             array_push($dependencies, $app);
         }
         $dependencies = array_reverse($dependencies);
         $dependencies = array_unique($dependencies);
         $dependencies = array_reverse($dependencies);
         response::send(array('success' => true, 'dependencies' => $dependencies), 'json');
     } catch (Exception $e) {
         response::send(array('success' => false, 'errors' => $e->getMessage()), 'json');
     }
 }
Пример #19
0
 /**
  *       Список типов
  */
 protected function sys_type()
 {
     $tmpl = new tmpl($this->pwd() . 'type.js');
     response::send($tmpl->parse($this), 'js');
 }
Пример #20
0
 private function sendResponse($content, $responseType)
 {
     $Response = new response($content, $responseType);
     return $Response->send();
 }
Пример #21
0
 /**
  *       ExtJs Form
  */
 protected function sys_item_form()
 {
     $tmpl = new tmpl($this->pwd() . 'item_form.js');
     response::send($tmpl->parse($this), 'js');
 }
Пример #22
0
 /**
  *	Удалить данные и сформировать JSON-пакет для ExtJS
  * @access	public
  * @param	boolean		$with_response	Если TRUE то автоматически отсылается JSON-пакет
  */
 public function extjs_unset_json($with_response = true)
 {
     try {
         $this->_unset();
         $data = array('success' => true, 'data' => array('id' => $this->get_lastChangedId(0)));
     } catch (Exception $e) {
         $data = array('success' => false, 'errors' => $e->getMessage());
     }
     if ($with_response) {
         response::send($data, 'json');
     } else {
         return $data;
     }
 }
Пример #23
0
 /**
  *	Удалить файл[ы]
  * @access protected
  */
 protected function sys_unset()
 {
     $this->_flush();
     $files = $this->_get();
     $this->_flush();
     $data = $this->extjs_unset_json(false);
     if (!empty($files)) {
         foreach ($files as $file) {
             file_system::remove_file($file->real_name);
         }
     }
     response::send($data, 'json');
 }
Пример #24
0
{
    $callduration = getValueFromArray($request, 'callduration');
    $status = getValueFromArray($request, 'status');
    $data = getValueFromArray($request, 'data');
    $message = getValueFromArray($request, 'message');
}
if (isset($_REQUEST['event']) && $_REQUEST['event'] == 'NewCall') {
    $r->addPlayText("Please wail while we connecting");
    $r->addDial($customerNumber, true);
    //phone number to dial
} elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Dial') {
    sendCallDoneInfo($_REQUEST);
    if ($_REQUEST['status'] == 'answered') {
        $r->addPlayText("dialled number is answered");
    } else {
        $r->addPlayText("dialled number is not answered");
    }
    $r->addHangup();
} elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Hangup') {
    if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'dial') {
        sendCallDoneInfo($_REQUEST);
    } else {
        if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'none') {
            sendCallInfo($_REQUEST);
        }
    }
} else {
    $r->addHangup();
}
$r->send();
Пример #25
0
 /**
  *       Простой список пользователей, с возможностью выбора
  */
 protected function sys_user_list()
 {
     $tmpl = new tmpl($this->pwd() . 'user_list.js');
     response::send($tmpl->parse($this), 'js');
 }