本文整理汇总了PHP中jAuth类的典型用法代码示例。如果您正苦于以下问题:PHP jAuth类的具体用法?PHP jAuth怎么用?PHP jAuth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Displays a list of project for a given repository.
*
* @param string $repository. Name of the repository.
* @return Html page with a list of projects.
*/
function index()
{
if ($this->param('theme')) {
jApp::config()->theme = $this->param('theme');
}
$rep = $this->getResponse('html');
// Get lizmap services
$services = lizmap::getServices();
// only maps
if ($services->onlyMaps) {
$repository = lizmap::getRepository($services->defaultRepository);
if ($repository && jAcl2::check('lizmap.repositories.view', $repository->getKey())) {
$project = lizmap::getProject($repository->getKey() . '~' . $services->defaultProject);
if ($project) {
// test redirection to an other controller
$items = jEvent::notify('mainviewGetMaps')->getResponse();
foreach ($items as $item) {
if ($item->parentId == $repository->getKey() && $item->id == $services->defaultProject) {
$rep = $this->getResponse('redirectUrl');
$rep->url = $item->url;
return $rep;
}
}
// redirection to default controller
$rep = $this->getResponse('redirect');
$rep->action = 'view~map:index';
return $rep;
}
}
}
// Get repository data
$repository = $this->param('repository');
$repositoryList = array();
if ($repository) {
if (!jAcl2::check('lizmap.repositories.view', $repository)) {
$rep = $this->getResponse('redirect');
$rep->action = 'view~default:index';
jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error');
return $rep;
}
}
$title = jLocale::get("view~default.repository.list.title");
$rep->body->assign('repositoryLabel', $title);
$rep->body->assign('isConnected', jAuth::isConnected());
$rep->body->assign('user', jAuth::getUserSession());
if ($services->allowUserAccountRequests) {
$rep->body->assign('allowUserAccountRequests', True);
}
if ($repository) {
$lrep = lizmap::getRepository($repository);
$title .= ' - ' . $lrep->getData('label');
}
$rep->title = $title;
$rep->body->assignZone('MAIN', 'main_view', array('repository' => $repository));
$rep->addJSCode("\n \$(window).load(function() {\n \$('.liz-project-img').parent().mouseenter(function(){\n var self = \$(this);\n self.find('.liz-project-desc').slideDown();\n self.css('cursor','pointer');\n }).mouseleave(function(){\n var self = \$(this);\n self.find('.liz-project-desc').hide();\n }).click(function(){\n var self = \$(this);\n window.location = self.parent().find('a.liz-project-view').attr('href');\n return false;\n });\n });\n ");
// Js hack to normalize the height of the project thumbnails to avoid line breaks with long project titles
$bp = jApp::config()->urlengine['basePath'];
$rep->addJSLink($bp . 'js/view.js');
return $rep;
}
示例2: install
function install()
{
if (self::$key === null) {
self::$key = jAuth::getRandomPassword(30, true);
}
$authconfig = $this->config->getValue('auth', 'coordplugins');
$authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true);
$forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
if ($forWS) {
$pluginIni = 'authsw.coord.ini.php';
} else {
$pluginIni = 'auth.coord.ini.php';
}
$authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni;
if ($this->firstExec('auth:' . $authconfig)) {
// no configuration, let's install the plugin for the entry point
$this->config->setValue('auth', $authconfig, 'coordplugins');
if (!file_exists(jApp::configPath($authconfig))) {
$this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
}
}
}
$localConfigIni = $this->entryPoint->localConfigIni;
$key = $localConfigIni->getValue('persistant_crypt_key', 'coordplugin_auth');
if ($key === 'exampleOfCryptKey' || $key == '') {
$localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
}
}
示例3: sendMail
/**
* Send an email to the members that have subsribe to this post
* @param integer $id of the subscribed post
* @return void
*/
public static function sendMail($id)
{
if (!jAuth::isConnected()) {
return;
}
$dao = jDao::get(self::$daoSub);
$memberDao = jDao::get('havefnubb~member');
//get all the members that subscribe to this thread except "ME" !!!
$records = $dao->findSubscribedPost($id, jAuth::getUserSession()->id);
$gJConfig = jApp::config();
// then send them a mail
foreach ($records as $record) {
//get all the member that subscribe to the thread id $id (called by hfnupost -> savereply )
$thread = jClasses::getService('havefnubb~hfnuposts')->getThread($id);
$post = jClasses::getService('havefnubb~hfnuposts')->getPost($thread->id_last_msg);
//get the email of the member that subscribes this thread
$member = $memberDao->getById($record->id_user);
$subject = jLocale::get('havefnubb~post.new.comment.received') . " : " . $post->subject;
$mail = new jMailer();
$mail->From = $gJConfig->mailer['webmasterEmail'];
$mail->FromName = $gJConfig->mailer['webmasterName'];
$mail->Sender = $gJConfig->mailer['webmasterEmail'];
$mail->Subject = $subject;
$tpl = new jTpl();
$tpl->assign('server', $_SERVER['SERVER_NAME']);
$tpl->assign('post', $post);
$tpl->assign('login', $member->login);
$mail->Body = $tpl->fetch('havefnubb~new_comment_received', 'text');
$mail->AddAddress($member->email);
$mail->Send();
}
}
示例4: create
/**
*
*/
function create()
{
$rep = $this->getResponse('json');
$category_id = $this->intParam('category_id', null, true);
$title = $this->param('title', '', true);
$url = $this->param('url', '', true);
//$description=$this->param('description', '', true);
//insert
if (!empty($url) && !empty($title) && !empty($category_id)) {
$this->msg = 'link non ajouté';
// instanciation de la factory
$tb = jDao::get("link");
// creation d'un record correspondant au dao foo
$record = jDao::createRecord("link");
// on remplit le record
$record->title = $title;
$record->url = $url;
$record->category_id = $category_id;
$record->user_id = jAuth::getUserSession()->id;
// on le sauvegarde dans la base
try {
$tb->insert($record);
$this->success = true;
$this->msg = "Lien ajouté ";
} catch (Exception $e) {
$this->success = false;
$this->msg = "lien non ajouté ";
}
}
$rep->data = array('success' => $this->success, 'msg' => $this->msg);
return $rep;
}
示例5: update
/**
*
*/
function update()
{
$id = $this->param('j_user_login');
$pwd = $this->param('pwd');
$pwdconf = $this->param('pwd_confirm');
$rep = $this->getResponse('redirect');
if ($this->personalView && $id != jAuth::getUserSession()->login) {
jMessage::add(jLocale::get('jelix~errors.acl.action.right.needed'), 'error');
$rep->action = 'master_admin~default:index';
return $rep;
}
if (trim($pwd) == '' || $pwd != $pwdconf) {
jMessage::add(jLocale::get('crud.message.bad.password'), 'error');
$rep->action = 'password:index';
$rep->params['j_user_login'] = $id;
return $rep;
}
if (jAuth::changePassword($id, $pwd)) {
jMessage::add(jLocale::get('crud.message.change.password.ok', $id), 'notice');
if ($this->personalView) {
$rep->action = 'user:index';
} else {
$rep->action = 'default:view';
}
$rep->params['j_user_login'] = $id;
return $rep;
} else {
jMessage::add(jLocale::get('crud.message.change.password.notok'), 'error');
$rep->action = 'password:index';
$rep->params['j_user_login'] = $id;
}
return $rep;
}
示例6: out
/**
*
*/
function out()
{
jAuth::logout();
$rep = $this->getResponse('text');
$rep->content = 'LOGOUT';
return $rep;
}
示例7: _prepareTpl
protected function _prepareTpl()
{
$config = new \Jelix\JCommunity\Config();
$this->_tpl->assign('canRegister', $config->isRegistrationEnabled());
$this->_tpl->assign('canResetPassword', $config->isResetPasswordEnabled());
if (jAuth::isConnected()) {
$this->_tpl->assign('login', jAuth::getUserSession()->login);
} else {
$conf = jAuth::loadConfig();
$this->_tpl->assign('persistance_ok', jAuth::isPersistant());
$form = jForms::get("jcommunity~login");
if (!$form) {
$form = jForms::create("jcommunity~login");
}
$this->_tpl->assign('form', $form);
$this->_tpl->assign('url_return', '');
if ($conf['enable_after_login_override']) {
$req = jApp::coord()->request;
if ($req->getParam('auth_url_return')) {
$this->_tpl->assign('url_return', $req->getParam('auth_url_return'));
} else {
if ($this->param('as_main_content')) {
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] && $_SERVER['HTTP_REFERER'] != jUrl::getCurrentUrl(false, true)) {
$this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']);
}
} else {
if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') {
$this->_tpl->assign('url_return', jUrl::getCurrentUrl(false, true));
}
}
}
}
}
}
示例8: out
/**
*
*/
function out()
{
$rep = $this->getResponse('redirectUrl');
jAuth::logout();
$conf = jApp::coord()->getPlugin('auth')->config;
if ($conf['after_logout'] == '') {
throw new jException('jcommunity~login.error.no.auth_logout');
}
if (jApp::coord()->execOriginalAction()) {
if ($conf['enable_after_logout_override']) {
$url_return = $this->param('auth_url_return');
if ($url_return) {
$rep->url = $url_return;
} else {
$rep->url = jUrl::get($conf['after_logout']);
}
}
} else {
// we are here because of an internal redirection (authentication missing)
// if we can indicate the url to go after the login, let's pass this url
// to the next action (which is in most of case a login form)
if ($conf['enable_after_login_override']) {
$rep->url = jUrl::get($conf['after_logout'], array('auth_url_return' => jUrl::getCurrentUrl()));
} else {
$rep->url = jUrl::get($conf['after_logout']);
}
}
return $rep;
}
示例9: check
/**
* check if there is a flood
* @param integer $timeInterval time between two actions
* @param integer $onlySameIp true: the flood is checked only between same ip
* @return boolean true if flood is detected
*/
public static function check($timeInterval, $onlySameIp)
{
// since we don't store data of anonymous user, and anonymous user
// are not allowed to post, we don't check
if (!jAuth::isConnected()) {
return false;
}
// check if the user is member of Admins (groupid 0) / Moderators (groupid 3)
// if so, no need to stop the action of this group of users
// FIXME we should check, not the group, but the rights !
foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
if ($grp->id_aclgrp == 'admins' or $grp->id_aclgrp == 'moderators') {
return false;
}
}
$dao = jDao::get('havefnubb~posts');
$rec = $dao->getMyLastEditedPost(jAuth::getUserSession()->id);
if ($rec->member_last_post + $timeInterval > time()) {
return false;
}
if ($onlySameIp && isset($_SERVER['REMOTE_ADDR']) && $rec->poster_ip != $_SERVER['REMOTE_ADDR']) {
return false;
}
return true;
}
示例10: testAll
public function testAll()
{
if ($this->config === null) {
$this->sendMessage('Ldap plugin for jauth is not tested because there isn\'t configuration.' . ' To test it, you should create and configure an auth_ldap.coord.ini.php file.');
return;
}
for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
$myUser = jAuth::createUserObject("testldap usr {$i}", "pass{$i}");
$this->assertTrue($myUser instanceof jAuthUserLDAP);
jAuth::saveNewUser($myUser);
$myUserLDAP = jAuth::getUser("testldap usr {$i}");
$user = "\n <object class=\"jAuthUserLDAP\">\n <string property=\"login\" value=\"testldap usr {$i}\" />\n <string property=\"email\" value=\"\" />\n <array property=\"cn\">array('testldap usr {$i}')</array>\n <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n <array property=\"name\">array('testldap usr {$i}')</array>\n <string property=\"password\" value=\"\" />\n </object>\n ";
$this->assertComplexIdenticalStr($myUserLDAP, $user);
$myUser->email = "usr{$i}.testldap@domain.com";
jAuth::updateUser($myUser);
$myUserLDAP = jAuth::getUser("testldap usr {$i}");
$user = "\n <object>\n <string property=\"login\" value=\"testldap usr {$i}\" />\n <array property=\"email\">array('usr{$i}.testldap@domain.com')</array>\n <array property=\"cn\">array('testldap usr {$i}')</array>\n <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n <array property=\"name\">array('testldap usr {$i}')</array>\n <string property=\"password\" value=\"\" />\n </object>\n ";
$this->assertComplexIdenticalStr($myUserLDAP, $user);
$this->assertTrue(jAuth::verifyPassword("testldap usr {$i}", "pass{$i}"));
$this->assertTrue(jAuth::changePassword("testldap usr {$i}", "newpass{$i}"));
}
$myUsersLDAP = jAuth::getUserList('testldap usr*');
$users = "<array>";
for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
$users .= "\n <object>\n <array property=\"login\">array('testldap usr {$i}')</array>\n <array property=\"email\">array('usr{$i}.testldap@domain.com')</array>\n <array property=\"cn\">array('testldap usr {$i}')</array>\n <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n <array property=\"name\">array('testldap usr {$i}')</array>\n <string property=\"password\" value=\"\" />\n </object>\n ";
}
$users .= "</array>";
$this->assertComplexIdenticalStr($myUsersLDAP, $users);
for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
$this->assertTrue(jAuth::removeUser("testldap usr {$i}"));
}
$myUsersLDAP = jAuth::getUserList('testldap usr*');
$this->assertFalse(count($myUsersLDAP) > 0);
}
示例11: update
/**
*
*/
function update()
{
$id = $this->param('id');
$pwd = $this->param('pwd');
$pwdconf = $this->param('pwd_confirm');
$rep = $this->getResponse('redirect');
if (trim($pwd) == '' || $pwd != $pwdconf) {
jMessage::add(jLocale::get('crud.message.bad.password'), 'error');
$rep->action = 'password:index';
$rep->params['id'] = $id;
return $rep;
}
if (jAuth::changePassword($id, $pwd)) {
jMessage::add(jLocale::get('crud.message.change.password.ok', $id), 'notice');
if ($this->personalView) {
$rep->action = 'user:index';
} else {
$rep->action = 'default:view';
}
$rep->params['id'] = $id;
return $rep;
} else {
jMessage::add(jLocale::get('crud.message.change.password.notok'), 'error');
$rep->action = 'password:index';
$rep->params['id'] = $id;
}
return $rep;
}
示例12: getRight
/**
* return the value of the right on the given subject (and on the optional resource)
* @param string $subject the key of the subject
* @param string $resource the id of a resource
* @return array list of values corresponding to the right
*/
public function getRight($subject, $resource = null)
{
if ($resource === null && isset(self::$acl[$subject])) {
return self::$acl[$subject];
} elseif (isset(self::$aclres[$subject][$resource])) {
return self::$aclres[$subject][$resource];
}
if (!jAuth::isConnected()) {
// not authificated = no rights
return array();
}
$groups = jAclDbUserGroup::getGroups();
if (count($groups) == 0) {
self::$acl[$subject] = array();
self::$aclres[$subject][$resource] = array();
return array();
}
// recupère toutes les valeurs correspondant aux groupes auquel appartient le user,
// avec le sujet et ressource indiqué
$values = array();
$dao = jDao::get('jelix~jaclrights', jAclDb::getProfile());
$list = $dao->getAllGroupRights($subject, $groups);
foreach ($list as $right) {
$values[] = $right->value;
}
self::$acl[$subject] = $values;
if ($resource !== null) {
$list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
foreach ($list as $right) {
$values[] = $right->value;
}
self::$aclres[$subject][$resource] = $values = array_unique($values);
}
return $values;
}
示例13: _prepareTpl
protected function _prepareTpl()
{
// Get the project and repository params
$project = $this->param('project');
$repository = $this->param('repository');
$auth_url_return = $this->param('auth_url_return');
if (!$auth_url_return) {
$auth_url_return = jUrl::get('view~map:index', array("repository" => $repository, "project" => $project));
}
// Get lizmapProject class
$assign = array('isConnected' => jAuth::isConnected(), 'user' => jAuth::getUserSession(), 'auth_url_return' => $auth_url_return, "externalSearch" => "", "edition" => false, "measure" => false, "locate" => false, "geolocation" => false, "timemanager" => false, "print" => false, "attributeLayers" => false);
try {
$lproj = lizmap::getProject($repository . '~' . $project);
$configOptions = $lproj->getOptions();
if (property_exists($configOptions, 'externalSearch')) {
$assign['externalSearch'] = $configOptions->externalSearch;
}
} catch (UnknownLizmapProjectException $e) {
jLog::logEx($e, 'error');
}
$this->_tpl->assign($assign);
// Get lizmap services
$services = lizmap::getServices();
if ($services->allowUserAccountRequests) {
$this->_tpl->assign('allowUserAccountRequests', True);
}
}
示例14: getRight
/**
* return the value of the right on the given subject (and on the optional resource)
* @param string $subject the key of the subject
* @param string $resource the id of a resource
* @return array list of values corresponding to the right
*/
public function getRight($subject, $resource = null)
{
if ($resource === null && isset(self::$acl[$subject])) {
return self::$acl[$subject];
} elseif (isset(self::$aclres[$subject][$resource])) {
return self::$aclres[$subject][$resource];
}
if (!jAuth::isConnected()) {
// not authificated = no rights
return array();
}
$groups = jAclDbUserGroup::getGroups();
if (count($groups) == 0) {
self::$acl[$subject] = array();
self::$aclres[$subject][$resource] = array();
return array();
}
// get all the values corresponding to the groups which the user has access to,
// with the subject and resource indicated
$values = array();
$dao = jDao::get('jacldb~jaclrights', 'jacl_profile');
$list = $dao->getAllGroupRights($subject, $groups);
foreach ($list as $right) {
$values[] = $right->value;
}
self::$acl[$subject] = $values;
if ($resource !== null) {
$list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
foreach ($list as $right) {
$values[] = $right->value;
}
self::$aclres[$subject][$resource] = $values = array_unique($values);
}
return $values;
}
示例15: beforeAction
/**
* @param array $params plugin parameters for the current action
* @return null or jSelectorAct if action should change
*/
public function beforeAction($params)
{
$notLogged = false;
$badip = false;
$selector = null;
// Check if auth cookie exist and user isn't logged on
jAuth::checkCookieToken();
//Do we check the ip ?
if ($this->config['secure_with_ip']) {
if (!isset($_SESSION['JELIX_AUTH_SECURE_WITH_IP'])) {
$_SESSION['JELIX_AUTH_SECURE_WITH_IP'] = $this->_getIpForSecure();
} else {
if ($_SESSION['JELIX_AUTH_SECURE_WITH_IP'] != $this->_getIpForSecure()) {
session_destroy();
$selector = new jSelectorAct($this->config['bad_ip_action']);
$notLogged = true;
$badip = true;
}
}
}
//Creating the user's object if needed
if (!isset($_SESSION[$this->config['session_name']])) {
$notLogged = true;
$_SESSION[$this->config['session_name']] = new jAuthDummyUser();
} else {
$notLogged = !jAuth::isConnected();
}
if (!$notLogged && $this->config['timeout']) {
if (isset($_SESSION['JELIX_AUTH_LASTTIME'])) {
if (time() - $_SESSION['JELIX_AUTH_LASTTIME'] > $this->config['timeout'] * 60) {
$notLogged = true;
jAuth::logout();
unset($_SESSION['JELIX_AUTH_LASTTIME']);
} else {
$_SESSION['JELIX_AUTH_LASTTIME'] = time();
}
} else {
$_SESSION['JELIX_AUTH_LASTTIME'] = time();
}
}
$needAuth = isset($params['auth.required']) ? $params['auth.required'] == true : $this->config['auth_required'];
$authok = false;
if ($needAuth) {
if ($notLogged) {
if (jApp::coord()->request->isAjax() || $this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) {
throw new jException($this->config['error_message']);
} else {
if (!$badip) {
$selector = new jSelectorAct($this->config['on_error_action']);
}
}
} else {
$authok = true;
}
} else {
$authok = true;
}
return $selector;
}