本文整理汇总了PHP中js::error方法的典型用法代码示例。如果您正苦于以下问题:PHP js::error方法的具体用法?PHP js::error怎么用?PHP js::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js
的用法示例。
在下文中一共展示了js::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* Post a thread.
*
* @param int $boardID
* @access public
* @return void
*/
public function post($boardID = 0)
{
$this->loadModel('forum');
if ($this->app->user->account == 'guest') {
die(js::locate($this->createLink('user', 'login', "referer=" . helper::safe64Encode($this->app->getURI()))));
}
/* Get the board. */
$board = $this->loadModel('tree')->getById($boardID);
/* Checking the board exist or not. */
if (!$board) {
die(js::error($this->lang->forum->notExist) . js::locate('back'));
}
/* Checking current user can post to the board or not. */
if (!$this->forum->canPost($board)) {
die(js::error($this->lang->forum->readonly) . js::locate('back'));
}
/* Set editor for current user. */
$this->thread->setEditor($board->id, 'post');
/* User posted a thread, try to save it to database. */
if ($_POST) {
$threadID = $this->thread->post($boardID);
if (dao::isError()) {
$this->send(array('result' => 'fail', 'message' => dao::getError()));
}
$locate = inlink('view', "threadID={$threadID}");
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate));
}
$this->view->title = $board->name . $this->lang->minus . $this->lang->thread->post;
$this->view->board = $board;
$this->view->boards = $this->forum->getBoards();
$this->view->canManage = $this->thread->canManage($boardID);
$this->display();
}
示例2: changePassword
/**
* Change password , if use default password ,go to change
*
* @access public
* @return void
*/
public function changePassword()
{
if ($this->app->user->account == 'guest') {
die(js::alert('guest') . js::locate('back'));
}
if (!empty($_POST)) {
$password1 = $_POST['password1'];
if (!$password1) {
die(js::error('Please input password!'));
}
$isDefult = $this->dao->select('password')->from(TABLE_DEFAULTPASSWORD)->Where('password')->eq($this->post->password1)->fetchAll();
//如果用户使用默认密码则跳到修改密码界面
if ($isDefult) {
die(js::error('Password can not in default list!') . js::locate($this->createLink('my', 'changePassword', 'type=forbidden'), 'parent'));
}
$this->user->updatePassword($this->app->user->id);
if (dao::isError()) {
die(js::error(dao::getError()));
}
die(js::locate($this->createLink('my', 'profile'), 'parent'));
}
$this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->changePassword;
$this->view->position[] = $this->lang->my->changePassword;
$this->view->user = $this->user->getById($this->app->user->id);
$this->display();
}
示例3: batchCreate
/**
* Create a batch case.
*
* @access public
* @return void
*/
function batchCreate($productID)
{
$now = helper::now();
$cases = fixer::input('post')->get();
for ($i = 0; $i < $this->config->testcase->batchCreate; $i++) {
if ($cases->type[$i] != '' and $cases->title[$i] != '') {
$data[$i]->product = $productID;
$data[$i]->module = $cases->module[$i] == 'same' ? $i == 0 ? 0 : $data[$i - 1]->module : $cases->module[$i];
$data[$i]->type = $cases->type[$i] == 'same' ? $i == 0 ? '' : $data[$i - 1]->type : $cases->type[$i];
$data[$i]->story = $cases->story[$i] == 'same' ? $i == 0 ? 0 : $data[$i - 1]->story : $cases->story[$i];
$data[$i]->title = $cases->title[$i];
$data[$i]->openedBy = $this->app->user->account;
$data[$i]->openedDate = $now;
$data[$i]->status = 'normal';
$data[$i]->version = 1;
if ($data[$i]->story != 0) {
$data[$i]->storyVersion = $this->loadModel('story')->getVersion($this->post->story);
}
$this->dao->insert(TABLE_CASE)->data($data[$i])->autoCheck()->batchCheck($this->config->testcase->create->requiredFields, 'notempty')->exec();
if (dao::isError()) {
echo js::error(dao::getError());
die(js::reload('parent'));
}
$caseID = $this->dao->lastInsertID();
$actionID = $this->loadModel('action')->create('case', $caseID, 'Opened');
} else {
unset($cases->module[$i]);
unset($cases->type[$i]);
unset($cases->story[$i]);
unset($cases->title[$i]);
}
}
}
示例4: saveQuery
/**
* Save search query.
*
* @access public
* @return void
*/
public function saveQuery()
{
$this->search->saveQuery();
if (dao::isError()) {
die(js::error(dao::getError()));
}
die('success');
}
示例5: post
/**
* Post a thread.
*
* @param int $boardID
* @access public
* @return void
*/
public function post($boardID = 0)
{
$this->loadModel('forum');
if ($this->app->user->account == 'guest') {
die(js::locate($this->createLink('user', 'login', "referer=" . helper::safe64Encode($this->app->getURI()))));
}
/* Get the board. */
$board = $this->loadModel('tree')->getById($boardID);
/* Checking the board exist or not. */
if (!$board) {
die(js::error($this->lang->forum->notExist) . js::locate('back'));
}
/* Checking current user can post to the board or not. */
if (!$this->forum->canPost($board)) {
die(js::error($this->lang->forum->readonly) . js::locate('back'));
}
/* Set editor for current user. */
$this->thread->setEditor($board->id, 'post');
/* User posted a thread, try to save it to database. */
if ($_POST) {
$captchaConfig = isset($this->config->site->captcha) ? $this->config->site->captcha : 'auto';
$needCaptcha = false;
if ($captchaConfig == 'auto' and $this->loadModel('guarder')->isEvil($this->post->{$this->session->contentInput})) {
$needCaptcha = true;
}
if ($captchaConfig == 'open') {
$needCaptcha = true;
}
if ($captchaConfig == 'close') {
$needCaptcha = false;
}
/* If no captcha but is garbage, return the error info. */
$captchaInput = $this->session->captchaInput;
if ($this->post->{$captchaInput} === false and $needCaptcha) {
$this->send(array('result' => 'fail', 'reason' => 'needChecking', 'captcha' => $this->loadModel('guarder')->create4Thread()));
}
$result = $this->thread->post($boardID);
$this->send($result);
}
$titleInput = helper::createRandomStr(6, $skip = 'A-Z');
$contentInput = helper::createRandomStr(7, $skip = 'A-Z');
$this->session->set('titleInput', $titleInput);
$this->session->set('contentInput', $contentInput);
$this->config->thread->require->post = "{$this->session->titleInput}, {$this->session->contentInput}";
$this->config->thread->editor->post = array('id' => $this->session->contentInput, 'tools' => 'simple');
$this->view->title = $board->name . $this->lang->minus . $this->lang->thread->post;
$this->view->board = $board;
$this->view->canManage = $this->thread->canManage($boardID);
$this->view->titleInput = $titleInput;
$this->view->contentInput = $contentInput;
$this->view->board = $board;
$this->view->mobileURL = helper::createLink('thread', 'post', "boardID={$boardID}", '', 'mhtml');
$this->view->desktopURL = helper::createLink('thread', 'post', "boardID={$boardID}", '', 'html');
$this->display();
}
示例6: create
/**
* Create an article.
*
* @access public
* @return void
*/
public function create()
{
if (!empty($_POST)) {
$blogID = $this->blog->create();
if (dao::isError()) {
die(js::error(dao::getError()) . js::locate('back'));
}
die(js::locate(inlink('index')));
}
$this->view->title = $this->lang->blog->add;
$this->display();
}
示例7: post
/**
* Post a thread.
*
* @param int $boardID
* @access public
* @return void
*/
public function post($boardID = 0)
{
$this->loadModel('forum');
if ($this->app->user->account == 'guest') {
die(js::locate($this->createLink('user', 'login', "referer=" . helper::safe64Encode($this->app->getURI()))));
}
/* Get the board. */
$board = $this->loadModel('tree')->getById($boardID);
/* Checking the board exist or not. */
if (!$board) {
die(js::error($this->lang->forum->notExist) . js::locate('back'));
}
/* Checking current user can post to the board or not. */
if (!$this->forum->canPost($board)) {
die(js::error($this->lang->forum->readonly) . js::locate('back'));
}
/* Set editor for current user. */
$this->thread->setEditor($board->id, 'post');
/* User posted a thread, try to save it to database. */
if ($_POST) {
$captchaConfig = isset($this->config->site->captcha) ? $this->config->site->captcha : 'auto';
$needCaptcha = false;
if ($captchaConfig == 'auto' and $this->loadModel('captcha')->isEvil($this->post->content)) {
$needCaptcha = true;
}
if ($captchaConfig == 'open') {
$needCaptcha = true;
}
if ($captchaConfig == 'close') {
$needCaptcha = false;
}
/* If no captcha but is garbage, return the error info. */
if ($this->post->captcha === false and $needCaptcha) {
$this->send(array('result' => 'fail', 'reason' => 'needChecking', 'captcha' => $this->loadModel('captcha')->create4Thread()));
}
$threadID = $this->thread->post($boardID);
if (is_array($threadID)) {
$this->send($threadID);
}
if (dao::isError()) {
$this->send(array('result' => 'fail', 'message' => dao::getError()));
}
$locate = inlink('view', "threadID={$threadID}");
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate));
}
$this->view->title = $board->name . $this->lang->minus . $this->lang->thread->post;
$this->view->board = $board;
$this->view->canManage = $this->thread->canManage($boardID);
$this->display();
}
示例8: set
/**
* Custom
*
* @param string $module
* @param string $field
* @access public
* @return void
*/
public function set($module = 'story', $field = 'priList')
{
if ($module == 'user' and $field == 'priList') {
$field = 'roleList';
}
$currentLang = $this->app->getClientLang();
$this->app->loadLang($module);
$this->app->loadConfig('story');
$fieldList = $this->lang->{$module}->{$field};
if ($module == 'bug' and $field == 'typeList') {
unset($fieldList['designchange']);
unset($fieldList['newfeature']);
unset($fieldList['trackthings']);
}
if (!empty($_POST)) {
if ($module == 'story' && $field == 'review') {
$this->loadModel('setting')->setItem('system.story.needReview', fixer::input('post')->get()->needReview);
} else {
$lang = $_POST['lang'];
$this->custom->deleteItems("lang={$lang}&module={$module}§ion={$field}");
foreach ($_POST['keys'] as $index => $key) {
$value = $_POST['values'][$index];
if (!$value or !$key) {
continue;
}
$system = $_POST['systems'][$index];
/* the length of role is 20, check it when save. */
if ($module == 'user' and $field == 'roleList' and strlen($key) > 20) {
die(js::alert($this->lang->custom->notice->userRole));
}
$this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value);
}
}
if (dao::isError()) {
die(js::error(dao::getError()));
}
die(js::reload('parent'));
}
$this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->{$module}->common;
$this->view->position[] = $this->lang->custom->common;
$this->view->position[] = $this->lang->{$module}->common;
$this->view->needReview = $this->config->story->needReview;
$this->view->fieldList = $fieldList;
$this->view->dbFields = $this->custom->getItems("lang={$currentLang},all&module={$module}§ion={$field}");
$this->view->field = $field;
$this->view->module = $module;
$this->view->currentLang = $currentLang;
$this->view->canAdd = strpos($this->config->custom->canAdd[$module], $field) !== false;
$this->display();
}
示例9: edit
/**
* Edit cron.
*
* @param int $cronID
* @access public
* @return void
*/
public function edit($cronID)
{
if ($_POST) {
$this->cron->update($cronID);
if (dao::isError()) {
die(js::error(dao::getError()));
}
die(js::locate(inlink('index'), 'parent'));
}
$this->view->title = $this->lang->cron->edit . $this->lang->cron->common;
$this->view->position[] = html::a(inlink('index'), $this->lang->cron->common);
$this->view->position[] = $this->lang->cron->edit;
$this->view->cron = $this->cron->getById($cronID);
$this->display();
}
示例10: batchCreate
/**
* Create batch todo
*
* @access public
* @return void
*/
public function batchCreate()
{
$todos = fixer::input('post')->cleanInt('date')->get();
for ($i = 0; $i < $this->config->todo->batchCreate; $i++) {
if ($todos->names[$i] != '' || isset($todos->bugs[$i + 1]) || isset($todos->tasks[$i + 1])) {
$todo->account = $this->app->user->account;
if ($this->post->date == false) {
$todo->date = '2030-01-01';
} else {
$todo->date = $this->post->date;
}
$todo->type = $todos->types[$i];
$todo->pri = $todos->pris[$i];
$todo->name = isset($todos->names[$i]) ? $todos->names[$i] : '';
$todo->desc = $todos->descs[$i];
$todo->begin = $todos->begins[$i];
$todo->end = $todos->ends[$i];
$todo->status = "wait";
$todo->private = 0;
$todo->idvalue = 0;
if ($todo->type == 'bug') {
$todo->idvalue = isset($todos->bugs[$i + 1]) ? $todos->bugs[$i + 1] : 0;
}
if ($todo->type == 'task') {
$todo->idvalue = isset($todos->tasks[$i + 1]) ? $todos->tasks[$i + 1] : 0;
}
$this->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->exec();
if (dao::isError()) {
echo js::error(dao::getError());
die(js::reload('parent'));
}
} else {
unset($todos->types[$i]);
unset($todos->pris[$i]);
unset($todos->names[$i]);
unset($todos->descs[$i]);
unset($todos->begins[$i]);
unset($todos->ends[$i]);
}
}
}
示例11: sync2db
public function sync2db($config)
{
$ldapUsers = $this->getUsers($config);
$user = new stdclass();
$account = '';
$i = 0;
for (; $i < $ldapUsers['count']; $i++) {
$user->account = $ldapUsers[$i][$config->uid][0];
$user->email = $ldapUsers[$i][$config->mail][0];
$user->realname = $ldapUsers[$i][$config->name][0];
$account = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($user->account)->fetch('account');
if ($account == $user->account) {
$this->dao->update(TABLE_USER)->data($user)->where('account')->eq($user->account)->autoCheck()->exec();
} else {
$this->dao->insert(TABLE_USER)->data($user)->autoCheck()->exec();
}
if (dao::isError()) {
echo js::error(dao::getError());
die(js::reload('parent'));
}
}
return $i;
}
示例12: updateDefaultPwd
public function updateDefaultPwd()
{
$data = fixer::input('post')->get();
$pwdList = $this->post->pwdList ? $this->post->pwdList : array();
if (!empty($pwdList)) {
/* Initialize todos from the post data. */
foreach ($pwdList as $pwdID) {
$pwd = $data->password[$pwdID];
if ('' === $pwd) {
continue;
}
if ($pwdID > 0) {
$this->updatePwd($pwdID, $pwd);
} else {
$this->setdefaultpwd($pwd);
}
}
}
if (dao::isError()) {
echo js::error(dao::getError());
die(js::reload('parent'));
}
}
示例13: login
/**
* User login, identify him and authorize him.
*
* @access public
* @return void
*/
public function login($referer = '', $from = '')
{
$this->setReferer($referer);
$loginLink = $this->createLink('user', 'login');
$denyLink = $this->createLink('user', 'deny');
/* Reload lang by lang of get when viewType is json. */
if ($this->app->getViewType() == 'json' and $this->get->lang and $this->get->lang != $this->app->getClientLang()) {
$this->app->setClientLang($this->get->lang);
$this->app->loadLang('user');
}
/* If user is logon, back to the rerferer. */
if ($this->user->isLogon()) {
if ($this->app->getViewType() == 'json') {
$data = $this->user->getDataInJSON($this->app->user);
die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
}
if (strpos($this->referer, $loginLink) === false and strpos($this->referer, $denyLink) === false and $this->referer) {
die(js::locate($this->referer, 'parent'));
} else {
die(js::locate($this->createLink($this->config->default->module), 'parent'));
}
}
/* Passed account and password by post or get. */
if (!empty($_POST) or isset($_GET['account']) and isset($_GET['password'])) {
$account = '';
$password = '';
if ($this->post->account) {
$account = $this->post->account;
}
if ($this->get->account) {
$account = $this->get->account;
}
if ($this->post->password) {
$password = $this->post->password;
}
if ($this->get->password) {
$password = $this->get->password;
}
if ($this->user->checkLocked($account)) {
$failReason = sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes);
if ($this->app->getViewType() == 'json') {
die(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $failReason))));
}
die(js::error($failReason));
}
$user = $this->user->identify($account, $password);
if ($user) {
$this->user->cleanLocked($account);
/* Authorize him and save to session. */
$user->rights = $this->user->authorize($account);
$user->groups = $this->user->getGroups($account);
$this->session->set('user', $user);
$this->app->user = $this->session->user;
$this->loadModel('action')->create('user', $user->id, 'login');
/* Keep login. */
if ($this->post->keepLogin) {
$this->user->keepLogin($user);
}
/* Check password. */
if (isset($this->config->safe->mode) and $this->user->computePasswordStrength($password) < $this->config->safe->mode) {
echo js::alert($this->lang->user->weakPassword);
}
/* Go to the referer. */
if ($this->post->referer and strpos($this->post->referer, $loginLink) === false and strpos($this->post->referer, $denyLink) === false) {
if ($this->app->getViewType() == 'json') {
$data = $this->user->getDataInJSON($user);
die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
}
/* Get the module and method of the referer. */
if ($this->config->requestType == 'PATH_INFO') {
$path = substr($this->post->referer, strrpos($this->post->referer, '/') + 1);
$path = rtrim($path, '.html');
if (empty($path)) {
$path = $this->config->requestFix;
}
list($module, $method) = explode($this->config->requestFix, $path);
} else {
$url = html_entity_decode($this->post->referer);
$param = substr($url, strrpos($url, '?') + 1);
list($module, $method) = explode('&', $param);
$module = str_replace('m=', '', $module);
$method = str_replace('f=', '', $method);
}
if (common::hasPriv($module, $method)) {
die(js::locate($this->post->referer, 'parent'));
} else {
die(js::locate($this->createLink($this->config->default->module), 'parent'));
}
} else {
if ($this->app->getViewType() == 'json') {
$data = $this->user->getDataInJSON($user);
die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data)));
}
die(js::locate($this->createLink($this->config->default->module), 'parent'));
//.........这里部分代码省略.........
示例14: create
/**
* Create a user.
*
* @access public
* @return void
*/
public function create()
{
$this->checkPassword();
$user = fixer::input('post')->setForce('join', date('Y-m-d H:i:s'))->setForce('last', helper::now())->setForce('visits', 1)->setIF($this->post->password1 == false, 'password', '')->setIF($this->cookie->referer != '', 'referer', $this->cookie->referer)->setIF($this->cookie->referer == '', 'referer', '')->remove('admin, ip, fingerprint')->get();
$user->password = $this->createPassword($this->post->password1, $user->account);
$this->dao->insert(TABLE_USER)->data($user, $skip = 'password1,password2')->autoCheck()->batchCheck($this->config->user->require->register, 'notempty')->check('account', 'unique')->check('account', 'account')->check('email', 'email')->check('email', 'unique')->exec();
if (commonModel::isAvailable('score')) {
$viewType = $this->app->getViewType();
if (!dao::isError()) {
$this->app->user->account = $this->post->account;
$this->loadModel('score')->earn('register', '', '', 'REGISTER');
if ($viewType == 'json') {
die('success');
}
} else {
if ($viewType == 'json' and dao::isError()) {
die(js::error(dao::getError()));
}
}
}
}
示例15: batchEdit
/**
* Batch edit user.
*
* @access public
* @return void
*/
public function batchEdit()
{
if (empty($_POST['verifyPassword']) or md5($this->post->verifyPassword) != $this->app->user->password) {
die(js::alert($this->lang->user->error->verifyPassword));
}
$oldUsers = $this->dao->select('id, account')->from(TABLE_USER)->where('id')->in(array_keys($this->post->account))->fetchPairs('id', 'account');
$accountGroup = $this->dao->select('id, account')->from(TABLE_USER)->where('account')->in($this->post->account)->fetchGroup('account', 'id');
$accounts = array();
foreach ($this->post->account as $id => $account) {
$users[$id]['account'] = $account;
$users[$id]['realname'] = $this->post->realname[$id];
$users[$id]['commiter'] = $this->post->commiter[$id];
$users[$id]['email'] = $this->post->email[$id];
$users[$id]['join'] = $this->post->join[$id];
$users[$id]['dept'] = $this->post->dept[$id] == 'ditto' ? isset($prev['dept']) ? $prev['dept'] : 0 : $this->post->dept[$id];
$users[$id]['role'] = $this->post->role[$id] == 'ditto' ? isset($prev['role']) ? $prev['role'] : 0 : $this->post->role[$id];
if (isset($accountGroup[$account]) and count($accountGroup[$account]) > 1) {
die(js::error(sprintf($this->lang->user->error->accountDupl, $id)));
}
if (in_array($account, $accounts)) {
die(js::error(sprintf($this->lang->user->error->accountDupl, $id)));
}
if (!validater::checkAccount($users[$id]['account'])) {
die(js::error(sprintf($this->lang->user->error->account, $id)));
}
if ($users[$id]['realname'] == '') {
die(js::error(sprintf($this->lang->user->error->realname, $id)));
}
if ($users[$id]['email'] and !validater::checkEmail($users[$id]['email'])) {
die(js::error(sprintf($this->lang->user->error->mail, $id)));
}
if (empty($users[$id]['role'])) {
die(js::error(sprintf($this->lang->user->error->role, $id)));
}
$accounts[$id] = $account;
$prev['dept'] = $users[$id]['dept'];
$prev['role'] = $users[$id]['role'];
}
foreach ($users as $id => $user) {
$this->dao->update(TABLE_USER)->data($user)->where('id')->eq((int) $id)->exec();
if ($user['account'] != $oldUsers[$id]) {
$oldAccount = $oldUsers[$id];
$this->dao->update(TABLE_USERGROUP)->set('account')->eq($user['account'])->where('account')->eq($oldAccount)->exec();
if (strpos($this->app->company->admins, ',' . $oldAccount . ',') !== false) {
$admins = str_replace(',' . $oldAccount . ',', ',' . $user['account'] . ',', $this->app->company->admins);
$this->dao->update(TABLE_COMPANY)->set('admins')->eq($admins)->where('id')->eq($this->app->company->id)->exec();
}
if (!dao::isError() and $this->app->user->account == $oldAccount) {
$this->app->user->account = $users['account'];
}
}
}
}