Exemple #1
0
 public static function set($data)
 {
     if (K_Registry::get('lang') == 'uk') {
         if (!empty($data['tree_meta_title_uk'])) {
             self::$title = $data['tree_meta_title_uk'];
         }
         if (!empty($data['tree_meta_description_uk'])) {
             self::$description = $data['tree_meta_description_uk'];
         }
         if (!empty($data['tree_meta_keywords_uk'])) {
             self::$keywords = $data['tree_meta_keywords_uk'];
         }
         if (!empty($data['tree_meta_canonical_uk'])) {
             self::$canonical = $data['tree_meta_canonical_uk'];
         }
     } else {
         if (!empty($data['tree_meta_title'])) {
             self::$title = $data['tree_meta_title'];
         }
         if (!empty($data['tree_meta_description'])) {
             self::$description = $data['tree_meta_description'];
         }
         if (!empty($data['tree_meta_keywords'])) {
             self::$keywords = $data['tree_meta_keywords'];
         }
         if (!empty($data['tree_meta_canonical'])) {
             self::$canonical = $data['tree_meta_canonical'];
         }
     }
 }
function l()
{
    if (K_Registry::get('lang') == 'uk') {
        return '/uk';
    } else {
        return '';
    }
}
 public function indexAction()
 {
     $this->view->one = K_Registry::get('one');
     K_Registry::write('h1', $this->view->one['name']);
     K_Crumbs::add(array('Вакансии', 'taxi-work'));
     K_Crumbs::add(array($this->view->one['name'], $this->view->one['tree_name']));
     $this->render('onevacancy');
 }
 protected function userTruePass(&$text, $fieldName)
 {
     $oldPassword = md5(md5($text . K_Registry::get('Configure.salt')));
     $result = $this->fetchRow(K_Db_Select::create()->where(array($fieldName => $oldPassword)));
     if (!count($result)) {
         $this->errors[$fieldName] = 'неправильный действующий пароль';
         return false;
     }
     return true;
 }
Exemple #5
0
 /**
  * Run & draw into output
  * @param Array $routerInfo - array( 'controller'=>'...', 'action'=>'...', 'module'=>'...', 'disableLayout'=true, ['params'=>array()] )
  */
 public function run($routerInfo = array())
 {
     $routerInfo['disableLayout'] = isset($routerInfo['disableLayout']) ? $routerInfo['disableLayout'] : true;
     $routerInfo['breakOnRender'] = false;
     $routerInfo['caller'] = 1;
     // 0 - call from internet request, 1 - call local
     $application = K_Registry::read('bootstrap')->getApplication();
     $application->executeRequest($routerInfo, true, false);
     // execute router with autoRender attribute
 }
Exemple #6
0
 public function saveAction()
 {
     $returnJson = array();
     $returnJson['error'] = false;
     $userModel = new Admin_Model_User();
     $data = array('user_name' => trim($_POST['user_name']), 'user_login' => trim($_POST['user_login']), 'user_email' => trim($_POST['user_email']), 'user_password' => trim($_POST['user_password']));
     $validate = array('user_name' => array('required' => true), 'user_login' => array('required' => true, 'userExists'), 'user_password' => array('pwdTest'), 'user_email' => array('required' => true, 'lengthTest', 'email', 'userExists'));
     if ($_POST['save_type'] == 'update') {
         $data['user_id'] = $_POST['user_id'];
         $validate['user_login'][0] = 'userExistsUpdate';
         $validate['user_email'][2] = 'userExistsUpdate';
         $validate['user_password'][0] = 'pwdTestUpdate';
     }
     if ($userModel->isValidRow($data, $validate)) {
         if ($_POST['save_type'] == 'add') {
             $data['user_password'] = md5(md5($data['user_password'] . K_Registry::get('Configure.salt')));
             $user_id = $userModel->save($data);
             $returnJson['user']['type'] = 'add';
             $returnJson['user']['id'] = $user_id;
         } else {
             if ($_POST['save_type'] == 'update') {
                 if (mb_strlen($data['user_password']) > 0) {
                     $data['user_password'] = md5(md5($data['user_password'] . K_Registry::get('Configure.salt')));
                 } else {
                     unset($data['user_password']);
                 }
                 $user_id = $userModel->update($data, array('user_id' => (int) $_POST['user_id']));
                 $returnJson['user']['type'] = 'update';
                 $user_id = intval($_POST['user_id']);
                 $returnJson['user']['id'] = $_POST['user_id'];
             }
         }
         $userRolesModel = new Admin_Model_UserRole();
         $userRolesModel->remove(K_Db_Select::create()->where(array('usrol_user_id' => $user_id)));
         if (isset($_POST['roles']) && count($_POST['roles']) > 0) {
             foreach ($_POST['roles'] as $v) {
                 $rd['usrol_user_id'] = $user_id;
                 $rd['usrol_role_id'] = intval($v);
                 $rolesData[] = $rd;
             }
             $userRolesModel->saveAll($rolesData);
             $returnJson['user']['roles'] = $_POST['roles'];
         }
         $returnJson['user']['name'] = $data['user_name'];
         $returnJson['user']['login'] = $data['user_login'];
         $returnJson['user']['email'] = $data['user_email'];
         $returnJson['error'] = false;
         $returnJson['msg'] = "<strong>OK:</strong>Пользователь удачно сохранён";
     } else {
         $returnJson['error'] = true;
         $returnJson['msg'] = $userModel->getErrorsD($this->dictionary);
     }
     $this->putJSON($returnJson);
 }
Exemple #7
0
 public function indexAction()
 {
     $this->view->one = K_Registry::get('one');
     K_Registry::write('h1', $this->view->one['header']);
     //        var_dump($one);
     K_Crumbs::add(array('Новости', 'taxi-novosti'));
     K_Crumbs::add(array($this->view->one['tree_title'], $this->view->one['tree_name']));
     $next = K_Tree::getNextBro('', $this->view->one);
     $prev = K_Tree::getPrevBro('', $this->view->one);
     $this->view->next = $next['tree_name'];
     $this->view->prev = $prev['tree_name'];
     $this->render('one');
 }
Exemple #8
0
 public function indexAction()
 {
     $auth_error = false;
     //Если авторизован отпровляем в админку
     if (K_Access::acl()->isAllowed(K_Auth::getRoles(), 'admin')) {
         K_Request::redirect("/admin");
     }
     if (isset($_POST['btnauth'])) {
         $login = K_Arr::get($_POST, 'login', false);
         if ($login and strlen($login) < 100) {
             $password = K_Arr::get($_POST, 'password', false);
             if ($password) {
                 $password_hash = md5(md5($password . K_Registry::get('Configure.salt')));
                 $user_model = new Admin_Model_User();
                 $user_arr = $user_model->find(K_Db_Select::create()->fields('user_id, user_name, user_login , user_email')->where(array('and' => array('user_login' => $login, "user_password" => $password_hash)))->limit(1));
                 if (is_array($user_arr) && count($user_arr)) {
                     $user = $user_arr[0]->toArray();
                     $user_role = new Admin_Model_UserRole();
                     // находим все роли пользователя
                     $user_roles_arr = $user_role->fetchAssoc('role_acl_key', 'SELECT r.role_acl_key FROM (`users_roles`)inner join `role` as r on usrol_role_id=r.role_id  WHERE usrol_user_id = "' . $user['user_id'] . '"');
                     foreach ($user_roles_arr as $v) {
                         $user_roles[] = $v["role_acl_key"];
                     }
                     //Загружаем роли в класc авторизации
                     // var_dump ($user);
                     //даже если у пользователя нет ролей даём ему роль guests
                     if (!isset($user_roles)) {
                         $user_roles = array('guests');
                     }
                     K_Auth::authorize($user, $user_roles);
                     K_Request::redirect("/admin");
                 } else {
                     $auth_error = true;
                 }
             } else {
                 $auth_error = true;
             }
         } else {
             $auth_error = true;
         }
     }
     $this->view->error_msg = '';
     if ($auth_error) {
         $this->view->error_msg = "Ошибка авторизации, неверный логин или пароль";
     }
 }
 public function saveAction()
 {
     if (!K_Request::isPost()) {
         $this->putAjax('ERROR');
     }
     if (!K_Auth::isLogin()) {
         $this->putAjax('ERROR');
     }
     $validate = array('user_password' => array('required' => true, 'userTruePass'), 'user_email' => array('required' => true, 'lengthTest', 'email', 'userExists'));
     $userSettings = new Admin_Model_UserSettings();
     $oldPassword = K_Arr::get($_POST, 'oldpassword', '');
     $data = array('user_password' => trim($_POST['user_password']), 'user_email' => trim($_POST['user_email']), 'password1' => trim($_POST['password1']), 'password2' => trim($_POST['password2']));
     if (strlen($data['password1']) > 0 || strlen($data['password2']) > 0) {
         $validate['password1'] = array('required' => true, 'pwdTest');
     }
     if ($userSettings->isValidRow($data, $validate)) {
         unset($data['user_password']);
         if (strlen($data['password1']) > 0) {
             $data['user_password'] = md5(md5($data['password1'] . K_Registry::get('Configure.salt')));
         }
         unset($data['password1']);
         unset($data['password2']);
         /*  if (! strlen($data['user_email']) > 0) {
                 unset($data['user_email']);
             }*/
         if (count($data)) {
             $data['user_id'] = K_Auth::getUserInfo('user_id');
             $userSettings->save($data);
             K_Auth::mergeUserInfo($data);
         }
         $returnJson['error'] = false;
         $returnJson['msg'] = "<strong>OK:</strong>Настройки удачно сохранены";
     } else {
         $returnJson['error'] = true;
         $returnJson['msg'] = $userSettings->getErrorsD($this->dictionary);
     }
     $this->putJSON($returnJson);
 }
 /** @method B initTranslate() Инициализация перевода в зависимости от под домена
  *  @
  */
 public function initTranslate()
 {
     $num = 0;
     $siteDomen = parse_url($_SERVER['HTTP_HOST']);
     $podDomen = explode(".", $siteDomen["path"]);
     if ($podDomen[$num] == "www") {
         $langDomen = $podDomen[++$num];
     }
     $langDomen = $podDomen[$num];
     if ($langDomen == 'en') {
         $Arrx8yrtge1 = 'en';
         K_Registry::set('lang', $Arrx8yrtge1);
         K_Locale::set('en_US');
     } else {
         $Arrx8yrtge1 = 'ua';
         K_Registry::set('lang', $Arrx8yrtge1);
         K_Locale::set('uk_UA');
     }
     K_Translate::setDirectory(ROOT_PATH . '/translate');
 }
Exemple #11
0
<?php 
error_reporting(E_ALL & ~E_NOTICE);
date_default_timezone_set('UTC');
header("Content-Type: text/xml");
$siteurl = K_Registry::get('site');
$sitemap = new Sitemap();
//настройки источников и для формирования ссылок
$TypesPlases = array('articles' => array('/articles/' => array("source" => '/articles/', "opt" => array('direct' => true))));
// Добавляем главную страницу
$sitemap->addUrl($siteurl, $update, 'daily', '0.9');
$noInSitemap = array('baseblocks', '404', 'index', 'search', 'articlepage', 'object', 'print', 'articles');
//кастомные страницы  // учитывать страницы с листалкой
$staticPages = K_TreeQuery::crt("/pages/")->types('page')->go();
$pagesForCount = array_keys($pagesCounts);
foreach ($staticPages as $v) {
    if (!in_array($v['tree_name'], $noInSitemap)) {
        /*
                            if (in_array($v['tree_name'],$pagesForCount)){
        if($pagesCounts[$v['tree_name']] && count($pagesCounts[$v['tree_name']])){
            // статические страницы с листалкой - начальная страница
                      echo "<url>\n<loc>".$siteurl.'/'.$v['tree_name']."</loc> 
                                 <lastmod>$update</lastmod> 
                                 <changefreq>daily</changefreq> 
                                  <priority>0.5</priority>
                             </url>\n"; 
                             
             $pCount = ceil($pagesCounts[$v['tree_name']]/10);
                  for($i=2;$i<$pCount;$i++){ 
             // статические страницы с листалкой - сама листалка
                        echo "<url>\n<loc>".$siteurl.'/'.$v['tree_name'].'.list.'.$i.".10</loc> 
                                  <lastmod>$update</lastmod> 
Exemple #12
0
 public static function parseCurrency()
 {
     $cacheManager = K_Registry::get('cacheManager');
     $cacheEver = K_Cache_Manager::get('unlim');
     $cache24h = K_Cache_Manager::get('24h');
     $currencyList = array();
     if (!$cache24h->test('CURS')) {
         $content = file_get_contents('http://finance.ua/ru/');
         $matches = array();
         preg_match('#<div\\s*id="portlet-currency-cash-cashless".*?>.*?<div\\s*class="portlet-content">(?P<table>.*?)</div>#is', $content, $matches);
         if (!empty($matches['table'])) {
             $table = $matches['table'];
             $matches = array();
             preg_match_all('#<tr\\s*class="(odd|even)">(?P<list>.*?)</tr>#is', $table, $matches);
             if (count($matches['list'])) {
                 foreach ($matches['list'] as $line) {
                     $matches = array();
                     $pattern = '<td\\s*class="iname">';
                     $pattern .= '.*?<a.*?>(?P<currency_digit>\\d+|)(?P<currency_name>.*?)</a>';
                     // чуток поправил паттерн
                     $pattern .= '.*?<td.*?>.*?(?P<cur1>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur2>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur3>[0-9.]+)';
                     $pattern .= '.*?<td.*?>.*?(?P<cur4>[0-9.]+)';
                     preg_match('#' . $pattern . '#is', $line, $matches);
                     if (count($matches)) {
                         $currencyList[$matches['currency_name']] = array('digit' => $matches['currency_digit'], 'cash_bid' => number_format($matches['cur1'], 2, '.', ' '), 'cash_ask' => number_format($matches['cur2'], 2, '.', ' '), 'noncash_bid' => number_format($matches['cur3'], 2, '.', ' '), 'noncash_ask' => number_format($matches['cur4'], 2, '.', ' '));
                     }
                 }
             }
         }
         preg_match('#<div\\s*id="portlet-currency-official".*?>.*?<div\\s*class="portlet-content">(?P<table>.*?)</div>#is', $content, $matches);
         if (!empty($matches['table'])) {
             $table = $matches['table'];
             $matches = array();
             preg_match_all('#<tr\\s*class="(odd|even)">(?P<list>.*?)</tr>#is', $table, $matches);
             if (count($matches['list'])) {
                 foreach ($matches['list'] as $line) {
                     $matches = array();
                     $pattern = '<td\\s*class="iname">';
                     $pattern .= '.*?<a.*?>(?P<currency_digit>\\d+|)(?P<currency_name>.*?)</a>';
                     // чуток поправил паттерн
                     $pattern .= '.*?<td.*?>.*?(?P<cur1>[0-9.]+)';
                     preg_match('#' . $pattern . '#is', $line, $matches);
                     if (count($matches)) {
                         $currencyListNbu[$matches['currency_name']] = array('cash' => number_format($matches['cur1'], 2, '.', ' '));
                     }
                 }
             }
         }
         if (count($currencyListNbu)) {
             $currencyList['NBU'] = $currencyListNbu;
         }
         if (count($currencyList)) {
             $cacheEver->save('CURS', $currencyList);
         } else {
             $currencyList = $cacheEver->load('CURS');
             // K_Log_Syslog::write();  @to-do сделать оповищение о ошибке парсинга
         }
         $cache24h->save('CURS', $currencyList);
     } else {
         $currencyList = $cache24h->load('CURS');
     }
     return $currencyList;
 }
Exemple #13
0
 public function indexAction()
 {
     $this->view->item = K_Registry::read('articles');
     $this->render('article');
 }
Exemple #14
0
 /** preRouter дополнительный роутинг который проверяет ссылки первого уровня
  */
 private function preRouter($link)
 {
     //		Новость
     $oneNode = K_TreeQuery::gOne('/news' . $link, 'news');
     if (!empty($oneNode)) {
         K_Registry::write('one', $oneNode);
         K_Seo::set($oneNode);
         return $link = '/system-pages/one/';
     }
     //		Вакансия
     $oneNode = K_TreeQuery::gOne('/vacancies' . $link, 'vacancy');
     if (!empty($oneNode)) {
         K_Registry::write('one', $oneNode);
         K_Seo::set($oneNode);
         return $link = '/system-pages/onevacancy/';
     }
     //********************  Статья отдельно.
     $articleNode = K_TreeQuery::gOne('/articles' . $link, 'articles');
     if (!empty($articleNode)) {
         // если есть статья с такой ссылкой переходим на неё
         K_Registry::write('articles', $articleNode);
         K_Seo::set($articleNode);
         return $link = '/system-pages/article/';
     }
     return false;
 }