/** * @param array $params plugin parameters for the current action * @return null or jSelectorAct if action should change */ public function beforeAction($params) { $selector = null; $aclok = true; if (isset($params['jacl.right'])) { $aclok = jAcl::check($params['jacl.right'][0], $params['jacl.right'][1]); } elseif (isset($params['jacl.rights.and'])) { $aclok = true; foreach ($params['jacl.rights.and'] as $right) { if (!jAcl::check($right[0], $right[1])) { $aclok = false; break; } } } elseif (isset($params['jacl.rights.or'])) { $aclok = false; foreach ($params['jacl.rights.or'] as $right) { if (jAcl::check($right[0], $right[1])) { $aclok = true; break; } } } if (!$aclok) { if (jApp::coord()->request->isAjax() || $this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) { throw new jException($this->config['error_message']); } else { $selector = new jSelectorAct($this->config['on_error_action']); } } return $selector; }
/** * @package jelix * @subpackage jtpl_plugin * @author Lepeltier kévin * @contributor Dominique Papin * @copyright 2008 Lepeltier kévin, 2008 Dominique Papin * @link http://www.jelix.org * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html */ function jtpl_function_html_breadcrumb($tpl, $nb = null, $separator = '') { $plugin = jApp::coord()->getPlugin('history', true); if ($plugin === null) { return; } $config =& $plugin->config; if (!isset($config['session_name']) || $config['session_name'] == '') { $config['session_name'] = 'HISTORY'; } if (!isset($_SESSION[$config['session_name']])) { return; } echo '<ol class="history">'; $leng = count($_SESSION[$config['session_name']]); $nb = $nb !== null ? count($_SESSION[$config['session_name']]) - $nb : 0; $nb = $nb < 0 ? 0 : $nb; for ($i = $nb; $i < $leng; $i++) { $page = $_SESSION[$config['session_name']][$i]; echo '<li' . ($i == $nb ? ' class="first"' : ($i == $leng - 1 ? ' class="end"' : '')) . '>'; if ($i != $leng - 1) { echo '<a href="' . jUrl::get($page['action'], $page['params'], jUrl::XMLSTRING) . '" ' . ($page['title'] != '' ? 'title="' . $page['title'] . '"' : '') . '>'; } echo $_SESSION[$config['session_name']][$i]['label']; if ($i != $leng - 1) { echo '</a>'; } echo ($i == $leng - 1 ? '' : $separator) . '</li>'; } echo '</ol>'; }
protected function getBasePath($requestType, $module = null, $action = null) { if ($this->urlhttps == null) { $this->urlhttps = array(); $selectors = preg_split("/[\\s,]+/", jApp::config()->urlengine['simple_urlengine_https']); foreach ($selectors as $sel2) { $this->urlhttps[$sel2] = true; } } $usehttps = false; if (count($this->urlhttps)) { if ($action && isset($this->urlhttps[$module . '~' . $action . '@' . $requestType])) { $usehttps = true; } elseif ($module && isset($this->urlhttps[$module . '~*@' . $requestType])) { $usehttps = true; } elseif (isset($this->urlhttps['@' . $requestType])) { $usehttps = true; } } if ($usehttps) { return jApp::coord()->request->getServerURI(true) . jApp::config()->urlengine['basePath']; } else { return jApp::config()->urlengine['basePath']; } }
public function outputMetaContent($t) { $resp = jApp::coord()->response; if ($resp === null || $resp->getType() != 'html') { return; } $confUrlEngine =& jApp::config()->urlengine; $www = $confUrlEngine['jelixWWWPath']; $jq = $confUrlEngine['jqueryPath']; $resp->addJSLink($jq . 'jquery.js'); $resp->addJSLink($jq . 'include/jquery.include.js'); $resp->addJSLink($www . 'js/jforms_jquery.js'); $resp->addCSSLink($www . 'design/jform.css'); //we loop on root control has they fill call the outputMetaContent recursively foreach ($this->_form->getRootControls() as $ctrlref => $ctrl) { if ($ctrl->type == 'hidden') { continue; } if (!$this->_form->isActivated($ctrlref)) { continue; } $widget = $this->getWidget($ctrl, $this->rootWidget); $widget->outputMetaContent($resp); } }
/** * handle the search of specific member */ function index() { $title = stripslashes(jApp::config()->havefnubb['title']); $rep = $this->getResponse('html'); $letter = $this->param('letter'); $id_rank = (int) $this->param('id_rank'); $memberSearch = (string) $this->param('member_search'); $page = 0; $page = (int) $this->param('page'); // get the group name of the group id we request $grpid = $this->param('grpid'); $groupname = jLocale::get('havefnubb~member.memberlist.allgroups'); if ($grpid != '__anonymous') { $dao = jDao::get('jacl2db~jacl2group'); $grpname = $dao->get($grpid); $groupname = $grpname->name; } $beginningBy = ''; if (strlen($letter) == 1) { $beginningBy = ' - ' . jLocale::get('havefnubb~member.memberlist.members.beginning.by', array($letter)); } // change the label of the breadcrumb if ($page == 0) { jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list')); $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy; } else { jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list') . ' ' . ($page + 1)); $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy . ' ' . ($page + 1); } $rep->body->assignZone('MAIN', 'memberlist', array('page' => $page, 'grpid' => $grpid, 'letter' => $letter, 'memberSearch' => $memberSearch)); return $rep; }
/** * @param string $sel the selector * @param boolean $enableRequestPart true if the selector can contain the request part * @param boolean $toRetrieveUrl true if the goal to have this selector is to generate an url */ function __construct($sel, $enableRequestPart = false, $toRetrieveUrl = false) { $coord = jApp::coord(); $this->forUrl = $toRetrieveUrl; // jSelectorAct is called by the url engine parser, before // jcoordinator set its properties, so we set a value to avoid a // parameter error on jelix_scan_action_sel. the value doesn't matter // since the parser call jSelectorAct only for 404 page if ($coord->actionName === null) { $coord->actionName = 'default:index'; } if ($this->_scan_act_sel($sel, $coord->actionName)) { if ($this->module == '#') { $this->module = $coord->moduleName; } elseif ($this->module == '') { $this->module = jApp::getCurrentModule(); } if ($this->request == '' || !$enableRequestPart) { $this->request = $coord->request->type; } $this->_createPath(); } else { throw new jExceptionSelector('jelix~errors.selector.invalid.syntax', array($sel, $this->type)); } }
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)); } } } } } }
/** * */ 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; }
public function beforeAction($params) { if (isset($params['traceexec.log_session'])) { $this->config['log_session'] = $params['traceexec.log_session']; } if (isset($params['traceexec.enabled'])) { $this->config['enable_trace'] = $params['traceexec.enabled']; } if (isset($this->config['enable_trace']) && $this->config['enable_trace'] == true) { $coord = jApp::coord(); $moduleName = $coord->moduleName; $actionName = $coord->actionName; $message = $moduleName . '~' . $actionName; //Url $message .= "\nUrl : " . $_SERVER['REQUEST_URI']; //Module & action $message .= "\nModule : " . $moduleName; $message .= "\nAction : " . $actionName; //Params $r_params = $coord->request->params; unset($r_params['module']); unset($r_params['action']); if (empty($r_params)) { $message .= "\nNo params"; } else { $message .= "\nParams : " . var_export($r_params, true); } //Session if (isset($this->config['log_session']) && $this->config['log_session'] == true) { $message .= "\nSession : " . var_export($_SESSION, true); } $message .= "\n"; jLog::log($message, 'trace'); } }
/** * function plugin : Ajax request * * it creates a javascript ajax function * example : * <pre> * {link_to_remote * 'Link', <!-- link label --> * 'result', <!-- id dom for ajax result --> * 'test~default:ajax', array('id'=>'34'), <!-- jurl request --> * array( * 'position'=>'html', <!-- html or append or prepend (default html) --> * 'method'=>'GET', <!-- GET or POST (default POST) --> * 'beforeSend'=>'alert("beforeSend")', <!-- JS script before send (default null) --> * 'complete'=>'alert("complete")', <!-- JS script after send (default null)--> * 'error'=>'alert("error")', <!-- JS if error (default null) --> * )} * <div id="result"></div> * </pre> */ function jtpl_function_html_link_to_remote($tpl, $label, $element_id, $action_selector, $action_parameters, $option) { $resp = jApp::coord()->response; static $id_link_to_remote = 0; if ($resp && $resp->getFormatType() == 'html') { // Add js link $resp->addJSLink(jApp::config()->urlengine['jqueryPath'] . 'jquery.js'); } $id_link_to_remote++; $url = jUrl::get($action_selector, $action_parameters); $position = array_key_exists("position", $option) ? $option['position'] : 'html'; $method = array_key_exists("method", $option) ? $option['method'] : 'GET'; $beforeSend = array_key_exists("beforeSend", $option) ? $option['beforeSend'] : ''; $complete = array_key_exists("complete", $option) ? $option['complete'] : ''; $error = array_key_exists("error", $option) ? $option['error'] : ''; // Link echo '<a href="#" onclick="link_to_remote_' . $id_link_to_remote . '();">' . $label . "</a>\n"; // Script echo ' <script type="text/javascript">//<![CDATA[ function link_to_remote_' . $id_link_to_remote . '() { $.ajax({ type: \'' . $method . "',\n url: '" . $url . "',\n beforeSend: function(){" . $beforeSend . ";},\n complete: function(){" . $complete . ";},\n error: function(){" . $error . ';}, success: function(msg){ $(\'#' . $element_id . "')." . $position . "(msg);\n }\n });\n }; //]]>\n </script>"; }
/** * @param array $params plugin parameters for the current action * @return null or jSelectorAct if action should change */ public function beforeAction($params) { $langDetected = false; $lang = ''; if ($this->config['enableUrlDetection']) { $l = jApp::coord()->request->getParam($this->config['urlParamNameLanguage']); if ($l !== null) { $lang = jLocale::getCorrespondingLocale($l); if ($lang != '') { $langDetected = true; } } } if (!$langDetected) { if (isset($_SESSION['JX_LANG'])) { $lang = $_SESSION['JX_LANG']; } else { if ($this->config['useDefaultLanguageBrowser']) { $lang = jLocale::getPreferedLocaleFromRequest(); } } } if ($lang != '') { $_SESSION['JX_LANG'] = $lang; jApp::config()->locale = $lang; } return null; }
public function outputMetaContent($t) { $resp = jApp::coord()->response; if ($resp === null || $resp->getType() != 'html') { return; } $confUrlEngine =& jApp::config()->urlengine; $confHtmlEditor =& jApp::config()->htmleditors; $confDate =& jApp::config()->datepickers; $confWikiEditor =& jApp::config()->wikieditors; $www = $confUrlEngine['jelixWWWPath']; $jq = $confUrlEngine['jqueryPath']; $bp = $confUrlEngine['basePath']; $resp->addJSLink($jq . 'include/jquery.include.js'); $resp->addJSLink($www . 'js/jforms_jquery.js'); $resp->addCSSLink($www . 'design/jform.css'); foreach ($t->_vars as $k => $v) { if (!$v instanceof jFormsBase) { continue; } foreach ($v->getHtmlEditors() as $ed) { if (isset($confHtmlEditor[$ed->config . '.engine.file'])) { if (is_array($confHtmlEditor[$ed->config . '.engine.file'])) { foreach ($confHtmlEditor[$ed->config . '.engine.file'] as $url) { $resp->addJSLink($bp . $url); } } else { $resp->addJSLink($bp . $confHtmlEditor[$ed->config . '.engine.file']); } } if (isset($confHtmlEditor[$ed->config . '.config'])) { $resp->addJSLink($bp . $confHtmlEditor[$ed->config . '.config']); } $skin = $ed->config . '.skin.' . $ed->skin; if (isset($confHtmlEditor[$skin]) && $confHtmlEditor[$skin] != '') { $resp->addCSSLink($bp . $confHtmlEditor[$skin]); } } $datepicker_default_config = jApp::config()->forms['datepicker']; foreach ($v->getControls() as $ctrl) { if ($ctrl instanceof jFormsControlDate || get_class($ctrl->datatype) == 'jDatatypeDate' || get_class($ctrl->datatype) == 'jDatatypeLocaleDate') { $config = isset($ctrl->datepickerConfig) ? $ctrl->datepickerConfig : $datepicker_default_config; $resp->addJSLink($bp . $confDate[$config]); } } foreach ($v->getWikiEditors() as $ed) { if (isset($confWikiEditor[$ed->config . '.engine.file'])) { $resp->addJSLink($bp . $confWikiEditor[$ed->config . '.engine.file']); } if (isset($confWikiEditor[$ed->config . '.config.path'])) { $p = $bp . $confWikiEditor[$ed->config . '.config.path']; $resp->addJSLink($p . jApp::config()->locale . '.js'); $resp->addCSSLink($p . 'style.css'); } if (isset($confWikiEditor[$ed->config . '.skin'])) { $resp->addCSSLink($bp . $confWikiEditor[$ed->config . '.skin']); } } } }
/** * display the RSS of the forum */ public function read_rss() { $ftitle = jUrl::escape($this->param('ftitle'), true); $id_forum = (int) $this->param('id_forum'); if (!jAcl2::check('hfnu.posts.list', 'forum' . $id_forum)) { $rep = $this->getResponse('redirect'); $rep->action = 'default:index'; return $rep; } if ($id_forum == 0) { $rep = $this->getResponse('redirect'); $rep->action = 'default:index'; return $rep; } $forum = jClasses::getService('havefnubb~hfnuforum')->getForum($id_forum); if (jUrl::escape($forum->forum_name, true) != $ftitle) { $rep = $this->getResponse('redirect'); $rep->action = jApp::config()->urlengine['notfoundAct']; return $rep; } jApp::coord()->getPlugin('history')->change('label', htmlentities($forum->forum_name, ENT_COMPAT, 'UTF-8')); $feed_reader = new jFeedReader(); $feed_reader->setCacheDir(jApp::varPath('feeds')); $feed_reader->setTimeout(2); $feed_reader->setUserAgent('HaveFnuBB - http://www.havefnubb.org/'); $feed = $feed_reader->parse($forum->forum_url); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('feed', $feed); $tpl->assign('forum', $forum); $rep->title = $forum->forum_name; $rep->body->assign('MAIN', $tpl->fetch('havefnubb~forum_rss.view')); return $rep; }
/** * @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; }
protected function getDaoName() { $plugin = jApp::coord()->getPlugin('auth'); if ($plugin === null) { throw new jException('jelix~auth.error.plugin.missing'); } return $plugin->config['Db']['dao']; }
/** * Main page of search */ public function index() { $rep = $this->getResponse('html'); jApp::coord()->getPlugin('history')->change('label', jLocale::get('hfnusearch~search.search.perform')); $rep->title = jLocale::get('hfnusearch~search.search.perform'); $rep->body->assignZone('MAIN', 'hfnusearch~hfnusearch'); return $rep; }
public function outputErrors() { $this->flushContent(); foreach (jApp::coord()->allErrorMessages as $msg) { fwrite(STDERR, $msg->getFormatedMessage() . "\n"); } $this->setExitCode(self::EXIT_CODE_ERROR); }
/** * @package jelix * @subpackage jtpl_plugin * @author Laurent Jouanneau * @contributor Yann (description and keywords), Dominique Papin (ie7 support), Mickaël Fradin (style), Loic Mathaud (title), Olivier Demah (auhor,generator), Julien Issler * @copyright 2005-2012 Laurent Jouanneau, 2007 Dominique Papin, 2008 Mickaël Fradin, 2009 Loic Mathaud, 2010 Olivier Demah * @copyright 2010 Julien Issler * @link http://www.jelix.org * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html */ function jtpl_meta_html_htmlmodule($tpl, $method, $module, $path, $params = array()) { $resp = jApp::coord()->response; if ($resp->getType() != 'html') { return; } if (strpos($method, 'csstheme') === 0) { $url = jUrl::get('jelix~www:getfile', array('targetmodule' => $module, 'file' => 'themes/' . jApp::config()->theme . '/' . $path)); switch ($method) { case 'csstheme': $resp->addCSSLink($url, $params); break; case 'cssthemeie': $resp->addCSSLink($url, $params, true); break; case 'cssthemeie7': case 'cssthemeie8': case 'cssthemeie9': $resp->addCSSLink($url, $params, 'IE ' . substr($method, -1, 1)); break; case 'cssthemeltie7': case 'cssthemeltie8': case 'cssthemeltie9': $resp->addCSSLink($url, $params, 'lt IE ' . substr($method, -1, 1)); break; default: trigger_error("Unknown resource type in meta_htmlmodule", E_USER_WARNING); } } else { $url = jUrl::get('jelix~www:getfile', array('targetmodule' => $module, 'file' => $path)); switch ($method) { case 'js': $resp->addJSLink($url, $params); break; case 'css': $resp->addCSSLink($url, $params); break; case 'jsie': $resp->addJSLink($url, $params, true); break; case 'cssie': $resp->addCSSLink($url, $params, true); break; case 'cssie7': case 'cssie8': case 'cssie9': $resp->addCSSLink($url, $params, 'IE ' . substr($method, -1, 1)); break; case 'cssltie7': case 'cssltie8': case 'cssltie9': $resp->addCSSLink($url, $params, 'lt IE ' . substr($method, -1, 1)); break; default: trigger_error("Unknown resource type in meta_htmlmodule", E_USER_WARNING); } } }
/** * Load the configuration of authentification, stored in the auth plugin config * @return array * @since 1.2.10 */ public static function loadConfig($newconfig = null) { if (self::$config === null || $newconfig) { if (!$newconfig) { $plugin = jApp::coord()->getPlugin('auth'); if ($plugin === null) { throw new jException('jelix~auth.error.plugin.missing'); } $config =& $plugin->config; } else { $config = $newconfig; } if (!isset($config['session_name']) || $config['session_name'] == '') { $config['session_name'] = 'JELIX_USER'; } if (!isset($config['persistant_cookie_path']) || $config['persistant_cookie_path'] == '') { if (jApp::config()) { $config['persistant_cookie_path'] = jApp::urlBasePath(); } else { $config['persistant_cookie_path'] = '/'; } } if (!isset($config['persistant_encryption_key'])) { if (isset(jApp::config()->coordplugin_auth) && isset(jApp::config()->coordplugin_auth['persistant_encryption_key'])) { $config['persistant_encryption_key'] = trim(jApp::config()->coordplugin_auth['persistant_encryption_key']); } else { $config['persistant_encryption_key'] = ''; } } if (!isset($config['persistant_cookie_name'])) { $config['persistant_cookie_name'] = 'jauthSession'; } // Read hash method configuration. If not empty, cryptPassword will use // the new API of PHP 5.5 (password_verify and so on...) $password_hash_method = isset($config['password_hash_method']) ? $config['password_hash_method'] : 0; if ($password_hash_method === '' || !is_numeric($password_hash_method)) { $password_hash_method = 0; } else { $password_hash_method = intval($password_hash_method); } $password_hash_options = isset($config['password_hash_options']) ? $config['password_hash_options'] : ''; if ($password_hash_options != '') { $list = '{"' . str_replace(array('=', ';'), array('":"', '","'), $config['password_hash_options']) . '"}'; $password_hash_options = @json_decode($list, true); if (!$password_hash_options) { $password_hash_options = array(); } } else { $password_hash_options = array(); } $config['password_hash_method'] = $password_hash_method; $config['password_hash_options'] = $password_hash_options; $config[$config['driver']]['password_hash_method'] = $password_hash_method; $config[$config['driver']]['password_hash_options'] = $password_hash_options; self::$config = $config; } return self::$config; }
/** * constructor... */ function __construct($params = array(), $request = '') { $this->params = $params; if ($request == '') { $this->requestType = jApp::coord()->request->type; } else { $this->requestType = $request; } }
/** * Load the configuration of authentification, stored in the auth plugin config * @return array * @since 1.2.10 */ public static function loadConfig($newconfig = null) { if (self::$config === null || $newconfig) { if (!$newconfig) { $plugin = jApp::coord()->getPlugin('auth'); if ($plugin === null) { throw new jException('jelix~auth.error.plugin.missing'); } $config =& $plugin->config; } else { $config = $newconfig; } if (!isset($config['session_name']) || $config['session_name'] == '') { $config['session_name'] = 'JELIX_USER'; } if (!isset($config['persistant_cookie_path']) || $config['persistant_cookie_path'] == '') { if (jApp::config()) { $config['persistant_cookie_path'] = jApp::urlBasePath(); } else { $config['persistant_cookie_path'] = '/'; } } // Read hash method configuration. If not empty, cryptPassword will use // the new API of PHP 5.5 (password_verify and so on...) $password_hash_method = isset($config['password_hash_method']) ? $config['password_hash_method'] : 0; if ($password_hash_method === '' || !is_numeric($password_hash_method)) { $password_hash_method = 0; } else { $password_hash_method = intval($password_hash_method); } if ($password_hash_method > 0) { require_once __DIR__ . '/password.php'; if (!can_use_password_API()) { $password_hash_method = 0; } } else { require_once __DIR__ . '/hash_equals.php'; } $password_hash_options = isset($config['password_hash_options']) ? $config['password_hash_options'] : ''; if ($password_hash_options != '') { $list = '{"' . str_replace(array('=', ';'), array('":"', '","'), $config['password_hash_options']) . '"}'; $json = new jJson(SERVICES_JSON_LOOSE_TYPE); $password_hash_options = @$json->decode($list); if (!$password_hash_options) { $password_hash_options = array(); } } else { $password_hash_options = array(); } $config['password_hash_method'] = $password_hash_method; $config['password_hash_options'] = $password_hash_options; $config[$config['driver']]['password_hash_method'] = $password_hash_method; $config[$config['driver']]['password_hash_options'] = $password_hash_options; self::$config = $config; } return self::$config; }
/** * */ function onmasteradminGetMenuContent($event) { $plugin = jApp::coord()->getPlugin('auth', false); if ($plugin && $plugin->config['driver'] == 'Db' && jAcl2::check('auth.users.list')) { $item = new masterAdminMenuItem('users', jLocale::get('jauthdb_admin~auth.adminmenu.item.list'), jUrl::get('jauthdb_admin~default:index'), 10, 'system'); $item->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/user.png'; $event->add($item); } }
/** * @param string $action action selector where form will be submit * @param array $actionParams parameters for the action */ public function setAction($action, $actionParams) { $this->_action = $action; $this->_actionParams = $actionParams; $this->_name = jFormsBuilderBase::generateFormName($this->_form->getSelector()); if (jApp::coord()->response != null && jApp::coord()->response->getType() == 'html') { $this->_endt = jApp::coord()->response->isXhtml() ? '/>' : '>'; } }
/** * @param jILogMessage $message the message to log */ function logMessage($message) { $type = $message->getCategory(); if (jApp::coord()->request) { $ip = jApp::coord()->request->getIP(); } else { $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; } error_log(date("Y-m-d H:i:s") . "\t" . $ip . "\t{$type}\t" . $message->getFormatedMessage(), 0); }
public function outputErrors() { header("HTTP/1.0 500 Internal Server Error"); header('Content-Type: application/vnd.mozilla.xul+xml;charset=' . jApp::config()->charset); echo '<?xml version="1.0" encoding="' . jApp::config()->charset . '" ?>' . "\n"; echo '<', $this->_root, ' title="Errors" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">'; echo '<vbox>'; $message = jApp::coord()->getGenericErrorMessage(); echo "<description style=\"color:#FF0000;\">" . htmlspecialchars($message, ENT_NOQUOTES, jApp::config()->charset) . "</description>"; echo '</vbox></', $this->_root, '>'; }
public function addSitemap($loc, $lastmod = null) { if (isset($loc[2048]) || count($this->urlSitemap) >= $this->maxSitemap) { return false; } $sitemap = new jSitemapIndex(); $sitemap->loc = jApp::coord()->request->getServerURI() . $loc; if ($timestamp = strtotime($lastmod)) { $sitemap->lastmod = date('c', $timestamp); } $this->urlSitemap[] = $sitemap; }
/** * Display cloud of message from a given tag */ function cloud() { $tag = $this->param('tag'); $title = stripslashes(jApp::config()->havefnubb['title']); $rep = $this->getResponse('html'); $hist = jApp::coord()->getPlugin('history'); $hist->change('label', ucfirst(htmlentities($title, ENT_COMPAT, 'UTF-8')) . ' - ' . jLocale::get('havefnubb~main.cloud')); $hist->getPlugin('history')->change('title', jLocale::get('havefnubb~main.cloud')); $rep->title = jLocale::get('havefnubb~main.cloud.posts.by.tag', $tag); $rep->body->assignZone('MAIN', 'havefnubb~postlistbytag', array('tag' => $tag)); return $rep; }
/** * handle a possible flood protection from the same IP user */ function error() { $resp = $this->getResponse('html'); $title = stripslashes(jApp::config()->havefnubb['title']); $history = jApp::coord()->getPlugin('history'); $history->change('label', ucfirst(htmlentities($title, ENT_COMPAT, 'UTF-8'))); $history->change('title', jLocale::get('havefnubb~main.goto_homepage')); $tpl = new jTpl(); $tpl->assign('message', jLocale::get('havefnubb~flood.detected')); $resp->body->assign('MAIN', $tpl->fetch('havefnubb~flood')); return $resp; }
/** * Page info display to banned users */ function index() { $title = stripslashes(jApp::config()->havefnubb['title']); $hist = jApp::coord()->getPlugin('history'); $hist->change('label', ucfirst(htmlentities($title, ENT_COMPAT, 'UTF-8'))); $hist->change('title', jLocale::get('havefnubb~main.goto_homepage')); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('message', jLocale::get('havefnubb~ban.you.are.banned')); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~banuser')); return $rep; }
/** * @param jResponse $response */ function output($response) { if (!jApp::coord()->request) { return; } $email = jApp::config()->mailLogger['email']; $headers = str_replace(array('\\r', '\\n'), array("\r", "\n"), jApp::config()->mailLogger['emailHeaders']); $message = ''; foreach ($this->messages as $msg) { $message .= "\n\n" . $msg->getFormatedMessage(); } error_log(wordwrap($message, 70), 1, $email, $headers); }