public function indexAction() { $commentModel = new Admin_Model_Comment(); $this->view->comments = $commentModel->fetchAll(K_Db_Select::create()->where(array('comment_status' => 'опубликован'))->order('comment_date DESC')); $capchaText = K_Secur::genCapchaText(); $this->view->capacha64 = K_Secur::genCapcha($capchaText); K_Auth::setUserKey('capchaText', $capchaText); K_Auth::setUserKey('capchaTime', time()); }
protected function seoGUI() { if (!K_Access::acl()->isAllowed(K_Auth::getRoles(), 'admin/tree/updateseo', true)) { return false; } $this->tabs['seo'] = 'SEO'; $this->view->node = $this->nodeData; return $this->x_render('seo', $this); }
protected function userExists(&$text, $fieldName) { if ($text != K_Auth::getUserInfo($fieldName)) { $result = $this->fetchRow(K_Db_Select::create()->where(array($fieldName => $text))); if (count($result)) { $this->errors[$fieldName] = 'пользователь с таким email`ом уже зарегестрирован'; return false; } } return true; }
public function ask() { if (!K_Request::isPost()) { $this->putAjax('ERROR'); } // var_dump( $_POST['capcha']);var_dump(K_Auth::getUserInfo('capchaText')); if (strcasecmp(trim($_POST['capcha']), K_Auth::getUserInfo('capchaText')) != 0 || time() - 300 > K_Auth::getUserInfo('capchaTime')) { $jsonReturn['error'] = true; $jsonReturn['msg'] = array(1 => array('label' => t('Символы с картинки', 'Символи з картинки'), 'error' => t('Неправильно введён код с картинки !!!', 'Неправильно введений код з малюнка !!!'))); $capchaText = K_Secur::genCapchaText(); K_Auth::setUserKey('capchaText', $capchaText); K_Auth::setUserKey('capchaTime', time()); $jsonReturn['callback'] = 'function callback(){$("#captcha-img").attr("src","data:image/png;base64,' . K_Secur::genCapcha($capchaText) . '");$("#capcha-text").val("")}'; if (K_Request::isAjax()) { $this->putJSON($jsonReturn); } else { K_Request::redirect('/'); } } $nameAccos = array('userName' => t('Ваше имя:', "Ваше ім'я:"), 'userContact' => t('Ваш E-mail*:', 'Ваш E-mail*:'), 'userPhone' => t('Ваш Телефон*:', 'Ваш Телефон*:'), 'userMessage' => t('Ваше сообщение:', 'Ваше повідомлення:')); $data = array('userName' => trim($_POST['userName']), 'userContact' => trim($_POST['userContact']), 'userPhone' => trim($_POST['userPhone']), 'userMessage' => trim($_POST['userMessage']), 'manager_email' => trim($_POST['manager_email'])); $managers = K_TreeQuery::crt('/manager/')->types('manager')->go(); foreach ($managers as $v) { $managerMails[] = $v['email']; } $validate = array('userName' => array('maxlen' => 255), 'userContact' => array('required' => true, 'notEmpty', 'email'), 'userPhone' => array('required' => true, 'notEmpty', 'phone'), 'userMessage' => array('required' => true, 'notEmpty', 'maxlen' => 1500), 'manager_email' => array('required' => true, 'notEmpty', 'enum' => $managerMails)); $commentModel = new Admin_Model_Valid(); if ($commentModel->isValidRow($data, $validate)) { $jsonReturn['error'] = false; $jsonReturn['msg'] = t("Ваш вопрос был отправлено успешно. Спасибо.", "Ваше питання було надіслано успішно. Спасибi."); $jsonReturn['clean'] = true; //Send mail /////////////////////////////////////////////////////////////////// $toMail = strip_tags(trim($data['manager_email'])); $mailText = 'Вам на сайт добавили вопрос. /r /n'; $mailText .= 'Имя:' . strip_tags($data['userName']) . ' /r /n'; $mailText .= 'E-mail:' . strip_tags($data['userContact']) . ' /r /n'; $mailText .= 'Телефон:' . strip_tags($data['userPhone']) . ' /r /n'; $mailText .= ' Сообщение: /r /n' . strip_tags($data['userMessage']); $mailer = new K_mail(); $mailer->setBody($mailText); $mailer->addTo($toMail); $mailer->send('*****@*****.**', 'На ваш сайт добавили новый вопрос'); //////////////////////////////////////////////////////////////// } else { $jsonReturn['error'] = true; $jsonReturn['msg'] = $commentModel->getErrorsD($nameAccos); } if (K_Request::isAjax()) { $this->putJSON($jsonReturn); } else { K_Request::redirect('/'); } }
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); }
public function logoutAction() { K_Auth::logout(); K_Request::redirect("/admin/auth"); }
public static function accessSiteCheck($res, $privilege = 'view') { self::init(); self::$lastKnowResourse = null; if (is_string($res)) { $res = explode('/', $res); } $allowTrigger = false; $access = false; $roles = K_Auth::getRoles(); foreach ($res as $v) { if (is_string($v)) { $resourseArr[] = $v; $resourse = strtolower(implode('/', $resourseArr)); $access = K_Access::acl()->isAllowed($roles, $resourse, $privilege); if (K_Access::acl()->lastResource == false) { $access = $allowTrigger; } else { self::$lastKnowResourse = K_Access::acl()->lastResource; } $allowTrigger = $access; } } return $access; }
public static function setUserKey($key, $value) { if (!is_array(self::$_userInfo)) { self::$_userInfo = []; } self::$_userInfo[$key] = $value; K_Session::write('UserInfo', self::$_userInfo, 'K_Auth'); }
public static function balanceRemove($count) { self::init(); //снимаем деньги со счёта $organizationModel = new Admin_Model_Organization(); $organizationModel->update(array('organization_pay_balance' => K_Db_Quote::quote(K_Auth::getUserInfo('org_balance') - $count)), 'organization_id=' . K_Auth::getUserInfo('organization')); $journalData['p_org'] = K_Auth::getUserInfo('organization'); $journalData['p_client'] = K_Auth::getUserInfo('id'); $journalData['p_balance'] = K_Auth::getUserInfo('org_balance'); $journalData['p_count'] = $count; $journalData['p_admins'] = 0; $journalData['p_users'] = 1; $journalData['p_acost'] = self::$_adminCost; $journal = new Admin_Model_PayJournal(); $journal->save($journalData); K_Auth::setUserKey('org_balance', K_Auth::getUserInfo('org_balance') - $count); }
Returns data for client-side tree var data = [ { label: 'Тест', children: [ { label: 'child1' }, { label: 'child2' } ] }, { label: 'Тест 2', children: [ { label: 'child3' } ] } ]; */ public function getAction() { $this->disableRender = true; $query = new K_Db_Query(); $treeStructure = array(); $treeElements = array(); if ($this->getParam('pid')) { $nodeId = $this->getParam('pid'); } else { $nodeId = 0; } // Прийдётся лезть в тип списка $pidType = K_TreeQuery::gOne((int) $nodeId); //var_dump($pidType); if ($pidType['sorted'] == "По алфавиту") { $order = "`t1`.`tree_title`"; } else { $order = "`t1`.`tree_lkey`"; } $sql = 'SELECT `t1`.*, COUNT(`t2`.`tree_id`) as subElements FROM `tree` as `t1` LEFT JOIN `tree` as `t2` ON `t2`.`tree_pid` = `t1`.`tree_id` WHERE `t1`.`tree_pid`=' . (int) $nodeId . ' GROUP BY `t1`.`tree_id`, `t1`.`tree_pid`, `t1`.`tree_title` ORDER BY ' . $order; $treeElements = $query->q($sql); foreach ($treeElements as $key => $column) { $treeElements[$key] = $column->toArray(); } if ($nodeId != '0') { $nodeArr = K_tree::getParents($nodeId); // выбираем всех родителей ноды $nodeArr[] = $nodeId; // добовляем id самой ноды // проверяем на доступ ноду со всеми её родителями к которой запрашиваються потомки /* foreach ( $pid_node_perents as $v ) { if ( is_string( $v ) ) { $resourse_arr[] = $v; $resourse = 't:' . implode( '/', $resourse_arr ); // echo $resourse; try { $access = K_Access::acl()->isAllowed( K_Auth::getRoles(), $resourse, 'view' ); // var_dump($access); } catch ( exception $e ) { $access = $allow_trigger; } $allow_trigger = $access; } }*/ //строим ресур запрашиваемой ноды если нода не равна 0 $allowTrigger = false; $access = false; $_nodeArr = $nodeArr; for ($i = count($_nodeArr); $i > 0; $i--) { $resourse = implode('/', $_nodeArr); array_pop($_nodeArr); $access = K_Access::aclTree()->isAllowed(K_Auth::getRoles(), $resourse, true); if (K_Access::aclTree()->lastResource) { break; } } $allowTrigger = $access;