コード例 #1
0
ファイル: menu.php プロジェクト: s-kalaus/ekernel
 function get_url_valid()
 {
     if ($this->url) {
         return $this->url;
     }
     $route = $this->route ? $this->route : 'default';
     $p = array('controller' => $this->controller, 'action' => $this->action);
     if ($this->param) {
         if (is_string($this->param)) {
             $param = explode(',', $this->param);
             $map = is_string($this->map) ? explode(',', $this->map) : array();
             if ($map) {
                 foreach ($map as $n => $el) {
                     $el = trim($el);
                     if ($el) {
                         $p[$el] = trim(@$param[$n]);
                     }
                 }
             }
         } else {
             $pp = clone $this->param;
             if ($pp instanceof data) {
                 $pp = $pp->to_array();
             }
             $p = array_merge($p, $pp);
         }
     }
     $view = application::get_instance()->controller->view;
     $href = $view->url($p, $route);
     return $href;
 }
コード例 #2
0
ファイル: entity.php プロジェクト: s-kalaus/ekernel
 function __get($k)
 {
     if ($k == 'view') {
         return $this->view;
     }
     // Смысл класса сущности - в создании виртуальных переменных класса, не связанных с данными сущности. Виртуальная переменная транслируется в метод get_имя_паременной класса сущности, который должен вернуть ее значение
     $method = 'get_' . $k;
     $k_replaced = preg_replace('/\\_(valid|control|lang)$/i', '', $k);
     if (method_exists($this, $method)) {
         $ret = $this->{$method}();
     } else {
         $ret = $this->get($k);
         if ($ret === null && $k != $k_replaced) {
             $ret = $this->get($k_replaced);
         }
     }
     if ($k != $k_replaced) {
         $reg = application::get_instance()->controller->view->lang(true);
         if ($reg && array_key_exists('ml_' . $k_replaced . '_' . $reg->id, $this->_data)) {
             $ret_lang = $this->get('ml_' . $k_replaced . '_' . $reg->id);
             if (strlen($ret_lang) == 0) {
                 if (array_key_exists('ml_' . $k_replaced . '_' . application::get_instance()->controller->view->lang()->default->id, $this->_data)) {
                     $ret_lang = $this->get('ml_' . $k_replaced . '_' . application::get_instance()->controller->view->lang()->default->id);
                     if (strlen($ret_lang) > 0) {
                         $ret = $ret_lang;
                     }
                 }
             } else {
                 $ret = $ret_lang;
             }
         }
     }
     return $ret;
 }
コード例 #3
0
ファイル: user.php プロジェクト: s-kalaus/ekernel
 public function init()
 {
     if ($this->_inited) {
         return;
     }
     $this->_inited = true;
     $config = application::get_instance()->config->user;
     $config->model = array();
     $config->model->user = isset($config->model->user) ? $config->model->user : $this->default_model_user;
     $this->model_user = '******' . $config->model->user;
     if (class_exists($this->model_user)) {
         $this->model_user = new $this->model_user();
         $this->_key = 'user_' . $this->model_user->name;
     }
     $this->model_usersoc = 'model_' . (isset($config->model->usersoc) ? $config->model->usersoc : $this->default_model_usersoc);
     $this->model_usersoc = class_exists($this->model_usersoc) ? new $this->model_usersoc() : null;
     if ($config->acl) {
         $this->model_role = 'model_' . (isset($config->model->role) ? $config->model->role : $this->default_model_role);
         $this->model_role = class_exists($this->model_role) ? new $this->model_role() : null;
         $this->model_rule = 'model_' . (isset($config->model->rule) ? $config->model->rule : $this->default_model_rule);
         $this->model_rule = class_exists($this->model_rule) ? new $this->model_rule() : null;
         $this->model_resource = 'model_' . (isset($config->model->resource) ? $config->model->resource : $this->default_model_resource);
         $this->model_resource = class_exists($this->model_resource) ? new $this->model_resource() : null;
         $this->model_role2role = 'model_' . (isset($config->model->role2role) ? $config->model->role2role : $this->default_model_role2role);
         $this->model_role2role = class_exists($this->model_role2role) ? new $this->model_role2role() : null;
         $this->model_rule2role = 'model_' . (isset($config->model->rule2role) ? $config->model->rule2role : $this->default_model_rule2role);
         $this->model_rule2role = class_exists($this->model_rule2role) ? new $this->model_rule2role() : null;
         $this->model_rule2resource = 'model_' . (isset($config->model->rule2resource) ? $config->model->rule2resource : $this->default_model_rule2resource);
         $this->model_rule2resource = class_exists($this->model_rule2resource) ? new $this->model_rule2resource() : null;
         $this->init_acl();
     }
     $this->salt = $config->salt;
     $this->login_auto();
 }
コード例 #4
0
ファイル: translate.php プロジェクト: s-kalaus/ekernel
 public function init()
 {
     if ($this->data) {
         return;
     }
     $lang = application::get_instance()->config->translate->lang;
     if (file_exists(PATH_ROOT . '/' . DIR_LIBRARY . '/translate/' . $lang . '.php')) {
         $data = (include PATH_ROOT . '/' . DIR_LIBRARY . '/translate/' . $lang . '.php');
         if ($data) {
             $this->data = array_merge($this->data, $data);
         }
     }
     if (file_exists(PATH_ROOT . '/' . DIR_APPLICATION . '/translate/' . $lang . '.php')) {
         $data = (include PATH_ROOT . '/' . DIR_APPLICATION . '/translate/' . $lang . '.php');
         if ($data) {
             $this->data = array_merge($this->data, $data);
         }
     }
     if (class_exists('model_translate')) {
         $m = new model_translate();
         $data_db = $m->fetch_all();
         if ($data_db) {
             $data_array = array();
             foreach ($data_db as $el) {
                 $data_array[$el->key] = $el->value_lang;
             }
             $this->data = array_merge($this->data, $data_array);
         }
     }
 }
コード例 #5
0
ファイル: error.php プロジェクト: s-kalaus/ekernel
 public static function call($message = 'Application Error', $code = 500)
 {
     $_SERVER['REQUEST_URI'] = '/error';
     header('HTTP/1.1 ' . $code . ' ' . $message);
     application::$instance = new application();
     application::get_instance()->bootstrap()->run();
     exit;
 }
コード例 #6
0
ファイル: url.php プロジェクト: s-kalaus/ekernel
 public function url($data = null, $route = 'default')
 {
     if ($data === null) {
         return $this;
     }
     $router = application::get_instance()->router;
     $request = application::get_instance()->request;
     return isset($router->route[$route]) ? $router->route[$route]->assemble($data, $request, $this->default) : '';
 }
コード例 #7
0
ファイル: lang.php プロジェクト: s-kalaus/ekernel
 public function set($lang)
 {
     if (application::get_instance()->config->resource->lang->type != 'session') {
         return false;
     }
     if ($lang) {
         session::set('lang', $lang);
     } else {
         session::remove('lang');
     }
     setcookie($this->_key, $lang, time() + 86400 * 30, '/');
 }
コード例 #8
0
ファイル: element.php プロジェクト: s-kalaus/ekernel
 public function __construct($name, $param = array())
 {
     $this->name = $name;
     if (isset($param['id'])) {
         $this->id = $param['id'];
     }
     if (isset($param['class'])) {
         $this->class = $param['class'];
     }
     if (isset($param['view_script'])) {
         $this->view_script = $param['view_script'];
     }
     if (isset($param['frame_view_script'])) {
         $this->frame_view_script = $param['frame_view_script'];
     }
     if (isset($param['class_error'])) {
         $this->class_error = $param['class_error'];
     }
     if (isset($param['class_frame'])) {
         $this->class_frame = $param['class_frame'];
     }
     if (isset($param['class_control'])) {
         $this->class_control = $param['class_control'];
     }
     if (isset($param['class_label'])) {
         $this->class_label = $param['class_label'];
     }
     if (isset($param['label'])) {
         $this->label = $param['label'];
     }
     if (isset($param['attr'])) {
         $this->attr = $param['attr'];
     }
     if (isset($param['validator'])) {
         $this->validator = $param['validator'];
     }
     if (isset($param['description'])) {
         $this->description = $param['description'];
     }
     if (isset($param['required'])) {
         $this->required = $param['required'];
     }
     if (isset($param['value'])) {
         $this->value = $param['value'];
     }
     if (isset($param['attribute'])) {
         $this->attribute = new data($param['attribute']);
     }
     if (isset($param['item'])) {
         $this->item = new data($param['item']);
     }
     $this->view = application::get_instance()->controller->view;
 }
コード例 #9
0
ファイル: response.php プロジェクト: s-kalaus/ekernel
 public function send()
 {
     if ($this->body) {
         $res = implode('', $this->body);
         $config = application::get_instance()->config->html;
         if ($config->compress && ob_start("ob_gzhandler")) {
             ini_set('zlib.output_compression_level', 6);
         } else {
             ob_start();
         }
         echo $res;
     }
 }
コード例 #10
0
ファイル: collector.php プロジェクト: s-kalaus/ekernel
 function url($url = '')
 {
     $url = $url ? $url : application::get_instance()->request->url;
     if (application::get_instance()->config->resource->lang) {
         $m = new model_lang();
         $langs = $m->fetch_col('stitle', array('show_it' => 1));
         $url = preg_replace('/^\\/(' . implode('|', $langs) . ')\\//si', '/', $url);
     }
     $m = new model_meta();
     $data = $m->fetch_by_url($url);
     if ($data) {
         $this->auto($data, false);
     }
 }
コード例 #11
0
ファイル: controller.php プロジェクト: s-kalaus/ekernel
 public function forward($action, $controller = null, $param = null)
 {
     $app = $this->layout = application::get_instance();
     $app->request->controller = $controller;
     if (!$app->request->controller) {
         $app->request->controller = str_replace('controller_', '', get_class($app->controller));
     }
     $app->request->action = $action;
     if ($param) {
         $app->request->param = new data($param);
     }
     $app->run_controller();
     exit;
 }
コード例 #12
0
ファイル: sms.php プロジェクト: s-kalaus/ekernel
 function iqsms($message, $phones, $config)
 {
     $y = application::get_instance()->config->sms->iqsms;
     $ok = 0;
     foreach ($phones as $phone) {
         $ch = curl_init('http://gate.iqsms.ru/send/?phone=' . rawurlencode($phone) . '&text=' . rawurlencode($message) . (@$config['sender'] ? '&sender=' . rawurlencode($config['sender']) : ''));
         curl_setopt($ch, CURLOPT_USERPWD, $y['login'] . ':' . $y['password']);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $res = curl_exec($ch);
         $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($status_code == 200 && stripos($res, 'accepted') !== false) {
             $ok++;
         }
     }
     return $ok;
 }
コード例 #13
0
ファイル: lang.php プロジェクト: s-kalaus/ekernel
 function __construct($config)
 {
     if ($config->type != 'session') {
         if (preg_match('/^\\/x\\//i', @$_SERVER['REQUEST_URI'])) {
             return;
         }
         $route = new data();
         if (count(application::get_instance()->config->route)) {
             $ml = new model_lang();
             $default = $ml->fetch_one('stitle', array('is_default' => 1));
             foreach (application::get_instance()->config->route as $k => $v) {
                 $route->{$k} = array('type' => 'chain', 'param' => array('part' => array(array('type' => 'rewrite', 'param' => array('url' => '([^\\/]+)', 'map' => 'lang', 'default' => $default)), clone $v), 'controller' => $v->param ? $v->param->controller : null, 'action' => $v->param ? $v->param->action : null, 'inner' => $v->inner, 'title' => $v->title));
             }
         }
         application::get_instance()->router = new router($route);
     }
     application::get_instance()->config->plugin[] = 'lang';
 }
コード例 #14
0
ファイル: pay.php プロジェクト: s-kalaus/ekernel
 function init()
 {
     $this->config = application::get_instance()->config->pay ? clone application::get_instance()->config->pay : new data();
     $mt = new model_translate();
     $config_db = $mt->fetch_col('key', '(SUBSTRING(`key`, 1, 4) = "pay_")');
     if ($config_db) {
         foreach ($config_db as $v) {
             $p = explode('_', $v);
             array_shift($p);
             $p0 = array_shift($p);
             if ($p0 && $p) {
                 $p = implode('_', $p);
                 $this->config[$p0] = isset($this->config[$p0]) ? $this->config[$p0] : array();
                 $this->config[$p0][$p] = $this->view->translate($v);
             }
         }
     }
 }
コード例 #15
0
ファイル: lang.php プロジェクト: s-kalaus/ekernel
 public function controller_before()
 {
     $ml = new model_lang();
     $ids = $ml->fetch_col('stitle', array('show_it' => 1));
     if (@application::get_instance()->config->resource->lang->type == 'session') {
         if ($ids) {
             $lang_session = session::get('lang');
             $lang_cookie = @$_COOKIE['lang'];
             if ($lang_session && !in_array($lang_session, $ids)) {
                 session::remove('lang');
                 $lang_session = null;
             }
             if ($lang_cookie && !in_array($lang_cookie, $ids) || $lang_cookie && $lang_session && $lang_session != $lang_cookie) {
                 setcookie('lang', null, time() + 86400 * 30, '/');
             }
             if ($lang_cookie && !$lang_session) {
                 session::set('lang', $lang_cookie);
                 $lang_session = $lang_cookie;
             }
             if (application::get_instance()->config->resource->lang->detect && !$lang_session) {
                 $lang_detected = $this->prefered_language($ids, @$_SERVER['HTTP_ACCEPT_LANGUAGE']);
                 if ($lang_detected) {
                     session::set('lang', $lang_detected);
                 }
             }
         }
     } else {
         if ($ids && !in_array(application::get_instance()->controller->request->param->lang, $ids)) {
             unset(application::get_instance()->controller->request->param->lang);
         }
         if (!application::get_instance()->controller->request->param->lang) {
             application::get_instance()->controller->request->param->lang = application::get_instance()->controller->view->lang()->default->stitle;
         }
         if (application::get_instance()->request->url == '/control') {
             header('Location: /' . application::get_instance()->controller->view->lang()->default->stitle . '/control');
             exit;
         } else {
             if (application::get_instance()->request->url == '/error') {
                 header('Location: /' . application::get_instance()->controller->view->lang('stitle') . '/error');
                 exit;
             }
         }
     }
 }
コード例 #16
0
ファイル: js.php プロジェクト: s-kalaus/ekernel
 public function render($name = null)
 {
     $config = application::get_instance()->config->js;
     ksort($this->item);
     ksort($this->item_inline);
     if ($this->item) {
         if ($config->merge) {
             $js = array();
             $m = '';
             foreach ($this->item as $offset => $item) {
                 if (stripos($item, '//') === false) {
                     $js[$offset] = $item;
                     $this->remove($offset);
                     $m .= @filemtime(PATH_ROOT . $item) . filesize(PATH_ROOT . $item);
                 }
             }
             if ($js) {
                 $c = '';
                 $nm = $name ? '/' . DIR_CACHE . '/js/' . $name . '.js' : $this->name('js', $m);
                 $ex = file_exists(PATH_ROOT . $nm);
                 if (!$ex) {
                     foreach ($js as $item) {
                         $c .= file_get_contents(PATH_ROOT . $item) . "\n";
                     }
                     $this->save('js', PATH_ROOT . $nm, trim($c));
                 }
                 $this->append($nm);
             }
         } else {
             foreach ($this->item as $offset => $item) {
                 if (stripos($item, '//') === false) {
                     $m = @filemtime(PATH_ROOT . $item) . filesize(PATH_ROOT . $item);
                     if ($m) {
                         $nm = $this->name('js', $m);
                         $this->save('js', PATH_ROOT . $nm, trim(file_get_contents(PATH_ROOT . $item)));
                         $this->set($offset, $nm);
                     }
                 }
             }
         }
     }
     return ($this->item ? '<script type="text/javascript" src="' . implode('"></script><script type="text/javascript" src="', $this->item) . '"></script>' : '') . ($this->item_inline ? '<script type="text/javascript">' . implode("\n", $this->item_inline) . '</script>' : '');
 }
コード例 #17
0
ファイル: action.php プロジェクト: s-kalaus/ekernel
 public function action($action, $controller = null, $param = null)
 {
     $app = $this->layout = application::get_instance();
     $old_request = clone $app->request;
     $old_response = clone $app->response;
     unset($param['controller']);
     unset($param['action']);
     $param['inner'] = true;
     $app->request->controller = $controller;
     $app->request->action = $action;
     $app->request->param = new data($param);
     ob_start();
     $app->run_controller(true);
     $res = ob_get_clean();
     unset($app->request);
     $app->request = $old_request;
     unset($app->response);
     $app->response = $old_response;
     return $res;
 }
コード例 #18
0
ファイル: messify.php プロジェクト: s-kalaus/ekernel
 public function __call($method, $args)
 {
     if ($this->_messify === null) {
         $messify = application::get_instance()->config->messify;
         if (!class_exists('\\Magwai\\Messify\\Messify')) {
             include PATH_ROOT . '/' . DIR_LIBRARY . '/lib/messify/Messify.php';
         }
         try {
             $opt = clone $messify;
             common::to_array($opt);
             $this->_messify = new \Magwai\Messify\Messify(array_merge(array('path_root' => PATH_ROOT, 'cache_dir' => DIR_CACHE . '/messify', 'scss' => array('images_dir' => './', 'fonts_dir' => 'img')), $opt));
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
     if (method_exists($this->_messify, $method)) {
         try {
             return call_user_func_array(array($this->_messify, $method), $args);
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
     return $this;
 }
コード例 #19
0
ファイル: navigation.php プロジェクト: s-kalaus/ekernel
 public function is_active($inner = false)
 {
     $was_active = false;
     if ($inner && $this->pages) {
         foreach ($this->pages as $el) {
             $active = $el->is_active(true);
             if ($active) {
                 $was_active = true;
                 break;
             }
         }
     }
     if (!$was_active) {
         if ($this->active === null) {
             $router = application::get_instance()->router;
             $request = application::get_instance()->request;
             $route = $this->route ? $this->route : 'default';
             $this->active = $was_active = isset($router->route[$route]) ? $router->route[$route]->match($this->get_param(), $request) : false;
         } else {
             $was_active = $this->active;
         }
     }
     return $was_active;
 }
コード例 #20
0
ファイル: scss.php プロジェクト: s-kalaus/ekernel
<?php

application::get_instance()->controller->layout = null;
$d = array();
if ($this->host && $this->file) {
    $ip = $this->ip ? $this->ip : 'noip';
    $path = PATH_ROOT . '/' . DIR_CACHE . '/scss/' . $this->host . '/' . $this->file . '/' . $ip;
    if (!file_exists($path)) {
        mkdir($path, 0777, true);
    }
    if ($this->ch == 'get') {
        function recursive_scss($path, $dir, &$d)
        {
            $cur = $path . ($dir ? '/' . $dir : '');
            foreach (scandir($cur) as $fn) {
                if ($fn == '.' || $fn == '..') {
                    continue;
                }
                if (is_dir($cur . '/' . $fn)) {
                    recursive_scss($path, $dir . ($dir ? '/' : '') . $fn, $d);
                } else {
                    if (preg_match('/\\.(png|jpg|gif|scss)/i', $fn)) {
                        $d[$dir . ($dir ? '/' : '') . $fn] = md5(file_get_contents($cur . '/' . $fn));
                    }
                }
            }
        }
        recursive_scss($path, '', $d);
    } else {
        if ($this->ch == 'set') {
            $zip = file_get_contents('php://input');
コード例 #21
0
ファイル: json.php プロジェクト: s-kalaus/ekernel
 public function json($data)
 {
     application::get_instance()->response->header_add('Content-Type', 'application/json');
     return json_encode($data);
 }
コード例 #22
0
ファイル: model.php プロジェクト: s-kalaus/ekernel
 public function override_lang(&$data)
 {
     if ($this->lang_field || $this->lang_type) {
         $reg = application::get_instance()->controller->view->lang(true);
         if ($reg) {
             switch ($this->lang_type) {
                 case 'column':
                     $data['lang'] = $reg->id;
                     break;
                 default:
                     foreach ($data as $k => $v) {
                         if (in_array($k, $this->lang_field)) {
                             $data['ml_' . $k . '_' . $reg->id] = $v;
                             unset($data[$k]);
                         }
                     }
                     break;
             }
         }
     }
 }
コード例 #23
0
ファイル: vk.php プロジェクト: s-kalaus/ekernel
 function request($method, $param = array())
 {
     if (time() - $this->last < 4) {
         sleep(4);
     }
     $config = application::get_instance()->config->vk;
     $post = array('v' => 5.17, 'uid' => $config->user, 'access_token' => $config->access_token);
     $url = $this->api_url . $method;
     if ($param) {
         foreach ($param as $k => $v) {
             if ($k && $v) {
                 $post[$k] = $v;
             }
         }
     }
     //echo $url;print_r($post);
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $this->last_response = curl_exec($ch);
     echo $this->last_response . '***';
     if ($this->last_response) {
         $this->last_response = json_decode($this->last_response);
         if (@$this->last_response->error) {
             $this->last_error = $this->last_response->error;
         }
         if (@$this->last_response->response) {
             return $this->last_response->response;
         }
     }
     $this->last = time();
     return false;
 }
コード例 #24
0
ファイル: control.php プロジェクト: s-kalaus/ekernel
 public function render()
 {
     // Записываем уведомления
     if (count($this->config->notify)) {
         $mn = new model_cnotify();
         foreach ($this->config->notify as $el) {
             $mn->insert($el->to_array());
         }
     }
     // Если заполнен текущий возвратный контроллер, то делаем редирект
     if (count($this->config->request->current)) {
         $p = clone $this->config->param;
         unset($p['id']);
         unset($p['ids']);
         //unset($p['oid']);
         unset($p['prev']);
         $p->set($this->config->request->current->param);
         $p['ccontroller'] = $this->config->request->current->controller;
         $p['caction'] = $this->config->request->current->action;
         header('Location: ' . $this->view->url($p, 'control'));
         application::get_instance()->controller->layout = null;
     }
     // Вызываем коллбэк для финальных настроек из вьюшки перед рендером лейаута
     if ($this->config->callback->prelayout) {
         $f = $this->config->callback->prelayout;
         $f($this);
     }
 }
コード例 #25
0
ファイル: form.php プロジェクト: s-kalaus/ekernel
 public function __construct($param = array())
 {
     if (isset($param['element_view_script'])) {
         $this->element_view_script = $param['element_view_script'];
     }
     if (isset($param['error_view_script'])) {
         $this->error_view_script = $param['error_view_script'];
     }
     if (isset($param['view_script'])) {
         $this->view_script = $param['view_script'];
     }
     if (isset($param['autocomplete'])) {
         $this->autocomplete = $param['autocomplete'];
     }
     if (isset($param['class'])) {
         $this->class = $param['class'];
     }
     if (isset($param['class_wrap'])) {
         $this->class_wrap = $param['class_wrap'];
     }
     if (isset($param['legend'])) {
         $this->legend = $param['legend'];
     }
     if (isset($param['attr'])) {
         $this->attr = $param['attr'];
     }
     if (isset($param['class_element_frame'])) {
         $this->class_element_frame = $param['class_element_frame'];
     }
     if (isset($param['class_element_control'])) {
         $this->class_element_control = $param['class_element_control'];
     }
     if (isset($param['class_element_label'])) {
         $this->class_element_label = $param['class_element_label'];
     }
     if (isset($param['class_element_error'])) {
         $this->class_element_error = $param['class_element_error'];
     }
     if (isset($param['class_error_frame'])) {
         $this->class_error_frame = $param['class_error_frame'];
     }
     if (isset($param['class_element_text'])) {
         $this->class_element_text = $param['class_element_text'];
     }
     if (isset($param['class_element_textarea'])) {
         $this->class_element_textarea = $param['class_element_textarea'];
     }
     if (isset($param['class_element_select'])) {
         $this->class_element_select = $param['class_element_select'];
     }
     if (isset($param['action'])) {
         $this->action = $param['action'];
     }
     if (isset($param['method'])) {
         $this->method = $param['method'];
     }
     if (isset($param['enctype'])) {
         $this->enctype = $param['enctype'];
     }
     $this->view = application::get_instance()->controller->view;
     $this->element = new data();
 }
コード例 #26
0
ファイル: mail.php プロジェクト: s-kalaus/ekernel
 public function mail($param)
 {
     $mail = new lib_phpmailer_class();
     $mail->isHTML(true);
     $mail->CharSet = 'UTF-8';
     //$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
     //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
     if (@$param['body']) {
         $param['message'] = @$param['body'];
     } else {
         if (@$param['template'] && !@$param['message']) {
             $mt = new model_mailtemplate();
             $template = $mt->fetch_row(array('key' => $param['template']));
             if ($template) {
                 $p = array_merge(array('site_title' => $this->view->translate('site_title'), 'site_url' => 'http://' . $_SERVER['HTTP_HOST'], 'lang_stitle' => $this->view->lang('stitle')), $param);
                 $param['message'] = $this->process_template($template->message_lang, $p);
                 if (!@$param['subject']) {
                     $param['subject'] = $this->process_template($template->subject_lang, $p);
                 }
             }
         }
         if (@$param['view']) {
             $param['message'] = $this->view->render('mail/' . $param['view'], $param);
         }
     }
     $html = $this->view->render('mail/frame', array('message' => $param['message']));
     $mail->Body = $html;
     $mail->AltBody = strip_tags($html);
     $fm = $this->view->translate('site_mail');
     $from = @$param['from'] ? $param['from'] : $this->view->translate('site_mail');
     $to = @$param['to'] ? $param['to'] : $this->view->translate('site_mail');
     $to = preg_split('/(\\;|\\,)/i', $to);
     $reply_to = @$param['reply_to'];
     $from_name = @$param['from_name'] ? $param['from_name'] : ($from == $fm ? $this->view->translate('site_title') : $from);
     if ($reply_to) {
         $mail->addReplyTo($reply_to, $from_name);
     }
     $mail->From = $from;
     $mail->FromName = $from_name;
     $tn = @$param['to_name'] ? $param['to_name'] : $to;
     foreach ($to as $n => $el) {
         $el = trim($el);
         if (!$el) {
             continue;
         }
         $tn_el = is_array($tn) ? isset($tn[$n]) ? $tn[$n] : @$tn[0] : $tn;
         $mail->addAddress($el, $tn_el);
     }
     if (@$param['subject_full']) {
         $mail->Subject = $param['subject_full'];
     } else {
         $mail->Subject = $this->view->translate('site_title') . ($param['subject'] ? ' — ' . $param['subject'] : '');
     }
     $ok = true;
     try {
         $is_sent = false;
         $config = application::get_instance()->config;
         if (@$config['mail']) {
             if (@$config['mail']['transports'] && @$config['mail']['transports']['transport']) {
                 foreach ($config['mail']['transports']['transport'] as $k => $v) {
                     $func = 'is' . ucfirst($v);
                     $mail->{$func}();
                     $mail->Host = $config['mail']['transports'][$v]['host'][$k];
                     $mail->SMTPAuth = $config['mail']['transports'][$v]['auth'][$k] ? true : false;
                     $mail->Username = $config['mail']['transports'][$v]['username'][$k];
                     $mail->Password = $config['mail']['transports'][$v]['password'][$k];
                     $mail->SMTPSecure = $config['mail']['transports'][$v]['ssl'][$k] ? 'ssl' : 'tls';
                     $ok = $mail->send();
                     if ($ok) {
                         $is_sent = true;
                         break;
                     }
                 }
             } else {
                 if (@$config['mail']['transport']) {
                     $k = $config['mail']['transport'];
                     if (@$config['mail'][$k] && @$config['mail'][$k]['host']) {
                         $func = 'is' . ucfirst($k);
                         $mail->{$func}();
                         $mail->Host = $config['mail'][$k]['host'];
                         $mail->SMTPAuth = $config['mail'][$k]['auth'] ? true : false;
                         $mail->Username = $config['mail'][$k]['username'];
                         $mail->Password = $config['mail'][$k]['password'];
                         $mail->SMTPSecure = $config['mail'][$k]['ssl'] ? 'ssl' : 'tls';
                         $ok = $mail->send();
                         if ($ok) {
                             $is_sent = true;
                         }
                     }
                 }
             }
         }
         if (!$is_sent) {
             $mail->isMail();
             $ok = $mail->send();
             if ($ok) {
                 $is_sent = true;
             }
         }
     } catch (Exception $e) {
         $ok = false;
     }
     return $ok;
 }
コード例 #27
0
ファイル: minify.php プロジェクト: s-kalaus/ekernel
 public function minify_util($res, $type, $compressor)
 {
     $config = application::get_instance()->config->util;
     $data = urlencode($res);
     $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-Type: multipart/form-data' . "\r\n" . 'Content-Length: ' . strlen($data) . "\r\n", 'content' => $data)));
     $result = file_get_contents($config->host . '/x/minify/type/' . $type . '/compressor/' . $compressor, false, $context);
     if ($result) {
         $result = json_decode($result, true);
         $res = "/* minified_" . $compressor . " */\n" . $result['data'];
     }
     return $res;
 }
コード例 #28
0
ファイル: lang.php プロジェクト: s-kalaus/ekernel
if (count($this->data)) {
    $reg = $this->lang(true);
    ?>
<li class="dropdown">
	<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php 
    echo $reg->title;
    ?>
 <span class="caret"></span></a>
	<ul class="dropdown-menu">
<?php 
    foreach ($this->data as $el) {
        if (application::get_instance()->config->resource->lang->type == 'session') {
            $h = $this->url(array('controller' => 'lang', 'action' => 'set', 'id' => $el->stitle), 'default');
        } else {
            $h = str_ireplace('/' . $reg->stitle . '/', '/' . $el->stitle . '/', application::get_instance()->request->url);
        }
        ?>
		<li><a href="<?php 
        echo $h;
        ?>
"><?php 
        echo $el->title;
        ?>
</a></li>
<?php 
    }
    ?>
	</ul>
</li>
<?php 
コード例 #29
0
ファイル: select.php プロジェクト: s-kalaus/ekernel
 function __construct($sql = '', $adapter = null)
 {
     $this->adapter = $adapter ? $adapter : application::get_instance()->bootstrap->resource->database->adapter;
     $this->sql = $sql;
 }
コード例 #30
0
ファイル: css.php プロジェクト: s-kalaus/ekernel
 public function preprocess_util($content, $file)
 {
     if (substr($file, -5) == '.scss') {
         $config = application::get_instance()->config->util;
         $path = PATH_ROOT . '/img';
         $d = array(basename($file) => md5(file_get_contents($file)));
         if (!function_exists('recursive_scss')) {
             function recursive_scss($path, $dir, &$d)
             {
                 $cur = $path . ($dir ? '/' . $dir : '');
                 foreach (scandir($cur) as $fn) {
                     if ($fn == '.' || $fn == '..') {
                         continue;
                     }
                     if (is_dir($cur . '/' . $fn) && !in_array($fn, array('font'))) {
                         recursive_scss($path, $dir . ($dir ? '/' : '') . $fn, $d);
                     } else {
                         if (preg_match('/\\.(' . ($dir == 'sprites' ? 'png|' : '') . 'scss)/i', $fn)) {
                             $d[$dir . ($dir ? '/' : '') . $fn] = md5(file_get_contents($cur . '/' . $fn));
                         }
                     }
                 }
             }
         }
         recursive_scss($path, '', $d);
         if ($d) {
             $res = file_get_contents($config->host . '/x/scss/ch/get/host/' . $_SERVER['HTTP_HOST'] . '/ip/' . $_SERVER['REMOTE_ADDR'] . '/file/' . basename($file));
             if ($res) {
                 if (!class_exists('Zip')) {
                     require PATH_ROOT . '/' . DIR_LIBRARY . '/lib/Zip.php';
                 }
                 $zip = new Zip();
                 $res = json_decode($res, true);
                 foreach ($d as $k => $v) {
                     if ($v != @$res[$k]) {
                         $zip->addFile(file_get_contents($path . '/' . $k), $k);
                     }
                 }
                 $data = urlencode($zip->getZipData());
                 $context = stream_context_create(array('http' => array('method' => 'POST', 'header' => 'Content-Type: multipart/form-data' . "\r\n" . 'Content-Length: ' . strlen($data) . "\r\n", 'content' => $data)));
                 $res = file_get_contents($config->host . '/x/scss/ch/set/host/' . $_SERVER['HTTP_HOST'] . '/ip/' . $_SERVER['REMOTE_ADDR'] . '/file/' . basename($file), false, $context);
                 if ($res) {
                     $res = json_decode($res, true);
                     file_put_contents(PATH_ROOT . '/' . DIR_CACHE . '/css/temp.zip', urldecode($res['data']));
                     require PATH_ROOT . '/' . DIR_LIBRARY . '/lib/Unzip.php';
                     $zip = new Unzip();
                     $zip->extract(PATH_ROOT . '/' . DIR_CACHE . '/css/temp.zip', PATH_ROOT . '/' . DIR_CACHE . '/css');
                     unlink(PATH_ROOT . '/' . DIR_CACHE . '/css/temp.zip');
                     $nfn = str_replace('.scss', '.css', basename($file));
                     $content = @file_get_contents(PATH_ROOT . '/' . DIR_CACHE . '/css/' . $nfn);
                     unlink(PATH_ROOT . '/' . DIR_CACHE . '/css/' . $nfn);
                 }
             }
         }
     }
     return $content;
 }