本文整理汇总了PHP中SecurityUtil类的典型用法代码示例。如果您正苦于以下问题:PHP SecurityUtil类的具体用法?PHP SecurityUtil怎么用?PHP SecurityUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SecurityUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_securityutil_checkpermission
/**
* Example:
* {securityutil_checkpermission component='Users::' instance='.*' level='ACCESS_ADMIN' assign='auth'}
*
* true/false will be returned.
*
* This file is a plugin for Zikula_View, the Zikula implementation of Smarty
* @param array $params All attributes passed to this function from the template
* @param object $smarty Reference to the Smarty object
* @return boolean authorized?
*/
function smarty_function_securityutil_checkpermission($params, $smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('securityutil_checkpermission', 'checkpermission')), E_USER_DEPRECATED);
if (!isset($params['component'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'component')));
return false;
}
if (!isset($params['instance'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'instance')));
return false;
}
if (!isset($params['level'])) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('securityutil_checkpermission', 'level')));
return false;
}
$result = SecurityUtil::checkPermission($params['component'], $params['instance'], constant($params['level']));
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $result);
} else {
return $result;
}
}
示例2: smarty_function_selector_user_category
/**
* User category selector.
*
* Available parameters:
* - btnText: If set, the results are assigned to the corresponding variable instead of printed out
* - cid: category ID
*
* Example
* {selector_user_category cid="1" assign="category"}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string HTML code of the selector.
*/
function smarty_function_selector_user_category($params, Zikula_View $view)
{
$field = isset($params['field']) ? $params['field'] : 'id';
$selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0;
$defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0;
$defaultText = isset($params['defaultText']) ? $params['defaultText'] : '';
$lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode();
$name = isset($params['name']) ? $params['name'] : 'defautlselectorname';
$recurse = isset($params['recurse']) ? $params['recurse'] : true;
$relative = isset($params['relative']) ? $params['relative'] : true;
$includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false;
$includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true;
$all = isset($params['all']) ? $params['all'] : false;
$displayPath = isset($params['displayPath']) ? $params['displayPath'] : false;
$attributes = isset($params['attributes']) ? $params['attributes'] : null;
$assign = isset($params['assign']) ? $params['assign'] : null;
$editLink = isset($params['editLink']) ? $params['editLink'] : true;
$submit = isset($params['submit']) ? $params['submit'] : false;
$multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1;
$doReplaceRootCat = false;
$userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative));
$html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize);
if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) {
$url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser');
$html .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>';
}
if ($assign) {
$view->assign($assign, $html);
} else {
return $html;
}
}
示例3: smarty_function_secauthaction
/**
* Example:
* {secauthaction comp="Stories::" inst=".*" level="ACCESS_ADMIN" assign="auth"}
*
* true/false will be returned.
*
* This file is a plugin for Zikula_View, the Zikula implementation of Smarty
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @return boolean authorized?
*/
function smarty_function_secauthaction($params, &$smarty)
{
LogUtil::log(__f('Warning! Template plugin {%1$s} is deprecated, please use {%2$s} instead.', array('secauthaction', 'checkpermission')), E_USER_DEPRECATED);
$assign = isset($params['assign']) ? $params['assign'] : null;
$comp = isset($params['comp']) ? $params['comp'] : null;
$inst = isset($params['inst']) ? $params['inst'] : null;
$level = isset($params['level']) ? $params['level'] : null;
if (!$comp) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'comp')));
return false;
}
if (!$inst) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'inst')));
return false;
}
if (!$level) {
$smarty->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_function_secauthaction', 'level')));
return false;
}
$result = SecurityUtil::checkPermission($comp, $inst, constant($level));
if ($assign) {
$smarty->assign($assign, $result);
} else {
return $result;
}
}
示例4: uninstall
/**
* Desinstal·lació del mòdul Cataleg
*
* @return bool true si ha anat tot bé, false en qualsevol altre cas.
*/
public function uninstall()
{
if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Esborrar taules del mòdul
if (!DBUtil::dropTable('cataleg')||
!DBUtil::dropTable('cataleg_eixos')||
!DBUtil::dropTable('cataleg_prioritats')||
!DBUtil::dropTable('cataleg_unitatsImplicades')||
!DBUtil::dropTable('cataleg_subprioritats')||
!DBUtil::dropTable('cataleg_activitats')||
!DBUtil::dropTable('cataleg_activitatsZona')||
!DBUtil::dropTable('cataleg_unitats')||
!DBUtil::dropTable('cataleg_responsables')||
!DBUtil::dropTable('cataleg_contactes')||
!DBUtil::dropTable('cataleg_auxiliar')||
!DBUtil::dropTable('cataleg_centresActivitat')||
!DBUtil::dropTable('cataleg_centres')||
!DBUtil::dropTable('cataleg_gestioActivitatDefaults')||
!DBUtil::dropTable('cataleg_importTaules')||
!DBUtil::dropTable('cataleg_importAssign')||
!DBUtil::dropTable('cataleg_gtafEntities')||
!DBUtil::dropTable('cataleg_gtafGroups')
)
return false;
//Esborrar variables del mòdul
$this->delVars();
// unregister hook handlers
HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
return true;
}
示例5: mediashare_mediahandlerapi_scanMediaHandlers
function mediashare_mediahandlerapi_scanMediaHandlers()
{
// Check access
if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
$dom = ZLanguage::getModuleDomain('mediashare');
// Clear existing handler table
if (!DBUtil::truncateTable('mediashare_mediahandlers')) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.scanMediaHandlers', __f("Could not clear the '%s' table.", 'mediahandlers', $dom)), $dom));
}
// Scan for handlers APIs
$files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
foreach ($files as $file) {
if (preg_match('/^pnmedia_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
$handlerName = $matches[1];
$handlerApi = "media_{$handlerName}";
// Force load - it is used during pninit
pnModAPILoad('mediashare', $handlerApi, true);
if (!($handler = pnModAPIFunc('mediashare', $handlerApi, 'buildHandler'))) {
return false;
}
$fileTypes = $handler->getMediaTypes();
foreach ($fileTypes as $fileType) {
$fileType['handler'] = $handlerName;
$fileType['title'] = $handler->getTitle();
if (!pnModAPIFunc('mediashare', 'mediahandler', 'addMediaHandler', $fileType)) {
return false;
}
}
}
}
return true;
}
示例6: getlinks
/**
* get available Admin panel links
*
* @return array Array of admin links
*/
public function getlinks()
{
$links = array();
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_READ)) {
$links[] = array('url' => ModUtil::url($this->name, 'user', 'main'), 'text' => $this->__('Frontend'), 'title' => $this->__('Switch to user area.'), 'class' => 'z-icon-es-home');
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'category')), 'text' => $this->__('Categories'), 'title' => $this->__('Category list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'forum')), 'text' => $this->__('Forums'), 'title' => $this->__('Forum list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'posting')), 'text' => $this->__('Postings'), 'title' => $this->__('Posting list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'abo')), 'text' => $this->__('Abos'), 'title' => $this->__('Abo list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'user')), 'text' => $this->__('Users'), 'title' => $this->__('User list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'view', array('ot' => 'rank')), 'text' => $this->__('Ranks'), 'title' => $this->__('Rank list'));
}
if (SecurityUtil::checkPermission($this->name . '::', '::', ACCESS_ADMIN)) {
$links[] = array('url' => ModUtil::url($this->name, 'admin', 'config'), 'text' => $this->__('Configuration'), 'title' => $this->__('Manage settings for this application'));
}
return $links;
}
示例7: initialize
public function initialize(Zikula_Form_View $view)
{
if (!SecurityUtil::checkPermission('Content::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
$catoptions = array( array('text' => $this->__('Use 2 category levels (1st level single, 2nd level multi selection)'), 'value' => '1'),
array('text' => $this->__('Use 2 category levels (both single selection)'), 'value' => '2'),
array('text' => $this->__('Use 1 category level'), 'value' => '3'),
array('text' => $this->__("Don't use Categories at all"), 'value' => '4') );
$this->view->assign('catoptions', $catoptions);
$this->view->assign('categoryusage', 1);
$activeoptions = array( array('text' => $this->__('New pages will be active and available in the menu'), 'value' => '1'),
array('text' => $this->__('New pages will be inactive and available in the menu'), 'value' => '2'),
array('text' => $this->__('New pages will be active and not available in the menu'), 'value' => '3'),
array('text' => $this->__('New pages will be inactive and not available in the menu'), 'value' => '4') );
$this->view->assign('activeoptions', $activeoptions);
$pageinfolocationoptions = array( array('text' => $this->__('Top of the page, left of the page title'), 'value' => 'top'),
array('text' => $this->__('Bottom of the page'), 'value' => 'bottom') );
$this->view->assign('pageinfolocationoptions', $pageinfolocationoptions);
// Assign all module vars
$this->view->assign('config', ModUtil::getVar('Content'));
return true;
}
示例8: mediashare_sourcesapi_scanSources
function mediashare_sourcesapi_scanSources()
{
// Check access
if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
$dom = ZLanguage::getModuleDomain('mediashare');
// Clear existing sources table
if (!DBUtil::truncateTable('mediashare_sources')) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.scanSources', __f("Could not clear the '%s' table.", 'sources', $dom)), $dom));
}
// Scan for sources APIs
$files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
foreach ($files as $file) {
if (preg_match('/^pnsource_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
$sourceName = $matches[1];
$sourceApi = "source_{$sourceName}";
// Force load - it is used during pninit
pnModAPILoad('mediashare', $sourceApi, true);
if (!($title = pnModAPIFunc('mediashare', $sourceApi, 'getTitle'))) {
return false;
}
if (!pnModAPIFunc('mediashare', 'sources', 'addSource', array('title' => $title, 'name' => $sourceName))) {
return false;
}
}
}
return true;
}
示例9: setstatus
/**
* This function sets active/inactive status.
*
* @param eid
*
* @return mixed true or Ajax error
*/
public function setstatus()
{
$this->checkAjaxToken();
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Ephemerides::', '::', ACCESS_ADMIN));
$eid = $this->request->request->get('eid', 0);
$status = $this->request->request->get('status', 0);
$alert = '';
if ($eid == 0) {
$alert .= $this->__('No ID passed.');
} else {
$item = array('eid' => $eid, 'status' => $status);
$res = DBUtil::updateObject($item, 'ephem', '', 'eid');
if (!$res) {
$alert .= $item['eid'] . ', ' . $this->__f('Could not change item, ID %s.', DataUtil::formatForDisplay($eid));
if ($item['status']) {
$item['status'] = 0;
} else {
$item['status'] = 1;
}
}
}
// get current status to return
$item = ModUtil::apiFunc($this->name, 'user', 'get', array('eid' => $eid));
if (!$item) {
$alert .= $this->__f('Could not get data, ID %s.', DataUtil::formatForDisplay($eid));
}
return new Zikula_Response_Ajax(array('eid' => $eid, 'status' => $item['status'], 'alert' => $alert));
}
示例10: edit
/**
* Create or edit record.
*
* @return string|boolean Output.
*/
public function edit()
{
if (!SecurityUtil::checkPermission('ExampleDoctrine::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError(ModUtil::url('ExampleDoctrine', 'user', 'index'));
}
$id = $this->request->query->getInt('id');
if ($id) {
// load user with id
$user = $this->entityManager->find('ExampleDoctrine_Entity_User', $id);
if (!$user) {
return LogUtil::registerError($this->__f('User with id %s not found', $id));
}
} else {
$user = new ExampleDoctrine_Entity_User();
}
/* @var $form Symfony\Component\Form\Form */
$form = $this->serviceManager->getService('symfony.formfactory')->create(new ExampleDoctrine_Form_UserType(), $user);
if ($this->request->getMethod() == 'POST') {
$form->bindRequest($this->request);
if ($form->isValid()) {
$data = $form->getData();
$this->entityManager->persist($data);
$this->entityManager->flush();
return $this->redirect(ModUtil::url('ExampleDoctrine', 'user', 'view'));
}
}
return $this->view->assign('form', $form->createView())->fetch('exampledoctrine_user_edit.tpl');
}
示例11: display
/**
* display block
*
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
*/
public function display($blockinfo)
{
// Security check
if (!SecurityUtil::checkPermission('Searchblock::', "{$blockinfo['title']}::", ACCESS_READ)) {
return;
}
// Get current content
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// set some defaults
if (!isset($vars['displaySearchBtn'])) {
$vars['displaySearchBtn'] = 0;
}
if (!isset($vars['active'])) {
$vars['active'] = array();
}
// assign the block vars array
$this->view->assign('vars', $vars);
// set a title if one isn't present
if (empty($blockinfo['title'])) {
$blockinfo['title'] = __('Search');
}
// return the rendered block
$blockinfo['content'] = $this->view->fetch('search_block_search.tpl');
return BlockUtil::themeBlock($blockinfo);
}
示例12: initialize
public function initialize(Zikula_Form_View $view)
{
if (!SecurityUtil::checkPermission('Content::', '::', ACCESS_ADMIN)) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
$catoptions = array(array('text' => $this->__('Use 2 category levels (1st level single, 2nd level multi selection)'), 'value' => '1'), array('text' => $this->__('Use 2 category levels (both single selection)'), 'value' => '2'), array('text' => $this->__('Use 1 category level'), 'value' => '3'), array('text' => $this->__("Don't use Categories at all"), 'value' => '4'));
$this->view->assign('catoptions', $catoptions);
$this->view->assign('categoryusage', 1);
$activeoptions = array(array('text' => $this->__('New pages will be active and available in the menu'), 'value' => '1'), array('text' => $this->__('New pages will be inactive and available in the menu'), 'value' => '2'), array('text' => $this->__('New pages will be active and not available in the menu'), 'value' => '3'), array('text' => $this->__('New pages will be inactive and not available in the menu'), 'value' => '4'));
$this->view->assign('activeoptions', $activeoptions);
$pageinfolocationoptions = array(array('text' => $this->__('Top of the page, left of the page title'), 'value' => 'top'), array('text' => $this->__('Bottom of the page'), 'value' => 'bottom'));
$this->view->assign('pageinfolocationoptions', $pageinfolocationoptions);
// get all module variables
$modvars = ModUtil::getVar('Content');
// Prepare list of layout options that are displayed for new pages
$layoutdisplayoptions = array();
$layoutDisplaySelection = array();
foreach ($modvars['layoutDisplay'] as $layout) {
$layoutdisplayoptions[] = array('text' => $layout['description'], 'value' => $layout['name']);
if ($layout['display']) {
$layoutDisplaySelection[] = $layout['name'];
}
}
$this->view->assign('layoutdisplayoptions', $layoutdisplayoptions);
$this->view->assign('layoutDisplaySelection', $layoutDisplaySelection);
// Assign all module vars
$this->view->assign('config', $modvars);
return true;
}
示例13: getContent
public function getContent($args)
{
switch ($args['pluginid']) {
case 1:
//$uid = $args['uid'];
// Get matching news stories published since last newsletter
// No selection on categories made !!
$items = ModUtil::apiFunc('News', 'user', 'getall',
array('numitems' => $this->getVar('itemsperpage'),
'status' => 0,
'from' => DateUtil::getDatetime($args['last']),
'filterbydate' => true));
if ($items != false) {
if ($args['contenttype'] == 't') {
$counter = 0;
$output.="\n";
foreach ($items as $item) {
$counter++;
$output .= $counter . '. ' . $item['title'] . " (" . $this->__f('by %1$s on %2$s', array($item['contributor'], DateUtil::formatDatetime($item['from'], 'datebrief'))) . ")\n";
}
} else {
$render = Zikula_View::getInstance('News');
$render->assign('readperm', SecurityUtil::checkPermission('News::', "::", ACCESS_READ));
$render->assign('articles', $items);
$output = $render->fetch('mailz/listarticles.tpl');
}
} else {
$output = $this->__f('No News publisher articles since last newsletter on %s.', DateUtil::formatDatetime($args['last'], 'datebrief')) . "\n";
}
return $output;
}
return '';
}
示例14: authenticate
private function authenticate($column, $loginstr, $password)
{
$fromTable = $this->_websoccer->getConfig('db_prefix') . '_user';
// get user data
$columns = 'id, passwort, passwort_neu, passwort_salt';
$wherePart = $column . ' = \'%s\' AND status = 1';
$parameter = $loginstr;
$result = $this->_db->querySelect($columns, $fromTable, $wherePart, $parameter);
$userdata = $result->fetch_array();
$result->free();
// user does not exist
if (!$userdata['id']) {
return FALSE;
}
// check password
$inputPassword = SecurityUtil::hashPassword($password, $userdata['passwort_salt']);
if ($inputPassword != $userdata['passwort'] && $inputPassword != $userdata['passwort_neu']) {
return FALSE;
}
// update password after a generated one
if ($userdata['passwort_neu'] == $inputPassword) {
$columns = array('passwort' => $inputPassword, 'passwort_neu_angefordert' => 0, 'passwort_neu' => '');
$whereCondition = 'id = %d';
$parameter = $userdata['id'];
$this->_db->queryUpdate($columns, $fromTable, $whereCondition, $parameter);
}
return $userdata['id'];
}
示例15: dispatch
/**
* Dispatch a module view request.
*
* @return mixed
*/
public function dispatch()
{
if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Get input.
$moduleName = $this->request->getGet()->filter('_module', null, FILTER_SANITIZE_STRING);
$pluginName = $this->request->getGet()->filter('_plugin', null, FILTER_SANITIZE_STRING);
$action = $this->request->getGet()->filter('_action', null, FILTER_SANITIZE_STRING);
// Load plugins.
if (!$moduleName) {
$type = 'SystemPlugin';
PluginUtil::loadAllSystemPlugins();
} else {
$type = 'ModulePlugin';
PluginUtil::loadAllModulePlugins();
}
if ($moduleName) {
$serviceId = PluginUtil::getServiceId("{$type}_{$moduleName}_{$pluginName}_Plugin");
} else {
$serviceId = PluginUtil::getServiceId("{$type}_{$pluginName}_Plugin");
}
$this->throwNotFoundUnless($this->serviceManager->hasService($serviceId));
$this->plugin = $this->serviceManager->getService($serviceId);
// Sanity checks.
$this->throwNotFoundUnless($this->plugin->isInstalled(), __f('Plugin "%s" is not installed', $this->plugin->getMetaDisplayName()));
$this->throwForbiddenUnless($this->plugin instanceof Zikula_Plugin_ConfigurableInterface, __f('Plugin "%s" is not configurable', $this->plugin->getMetaDisplayName()));
$this->pluginController = $this->plugin->getConfigurationController();
$this->throwNotFoundUnless($this->pluginController->getReflection()->hasMethod($action));
return $this->pluginController->{$action}();
}