本文整理汇总了PHP中Security::requirePermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Security::requirePermission方法的具体用法?PHP Security::requirePermission怎么用?PHP Security::requirePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Security
的用法示例。
在下文中一共展示了Security::requirePermission方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PrintUploadedFileInfo
// | Boston, MA 02111-1307, USA gnu@gnu.org |
// | |
// +-------------------------------------------------------------------+
/**
* @package WiFiDogAuthServer
* @copyright 2004-2006 Technologies Coeus inc.
* @version Subversion $Id$
* @link http://www.wifidog.org/
*/
/**
* Load common include file
*/
require_once 'admin_common.php';
require_once 'classes/MainUI.php';
require_once 'classes/Server.php';
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), Server::getServer());
$db = AbstractDb::getObject();
$html = '';
/** Affiche les informations sur le fichier envoy� par le client
*/
function PrintUploadedFileInfo($form_name_file)
{
$html .= "Nom du fichier envoy�:" . $_FILES[$form_name_file]['name'] . "<br>";
$html .= "Taille: " . $_FILES[$form_name_file]['size'] . " octets" . "<br>";
$html .= "Mime type: " . $_FILES[$form_name_file]['type'] . "<br>";
$html .= "Nom du fichier temporaire sur le serveur: " . $_FILES[$form_name_file]['tmp_name'] . "<br>";
$html .= "Erreurs au cours du transfert: " . $_FILES[$form_name_file]['error'] . "<br>";
}
$html .= "<fieldset class=\"pretty_fieldset\">";
$html .= "<legend>" . _("NoCat user database import") . "</legend>";
if (empty($_REQUEST['action'])) {
示例2: delete
/**
* Delete this Object form the it's storage mechanism
*
* @param string &$errmsg Returns an explanation of the error on failure
*
* @return bool true on success, false on failure or access denied
*
* @access public
*/
public function delete(&$errmsg)
{
// Init values
$retval = false;
Security::requirePermission(Permission::P('NETWORK_PERM_DELETE_NETWORK'), $this);
if ($this->isDefaultNetwork() === true) {
$errmsg = _('Cannot delete default network, create another one and select it before you remove this one.');
} else {
$db = AbstractDb::getObject();
$id = $db->escapeString($this->getId());
if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) {
$errmsg = _('Could not delete network!');
} else {
parent::_delete($errmsg);
$retval = true;
}
}
return $retval;
}
示例3: processAdminUI
public function processAdminUI()
{
$db = AbstractDb::getObject();
$currentUser = self::getCurrentUser();
if (Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
/* Account status */
$name = "user_" . $this->getId() . "_accountstatus";
$status = FormSelectGenerator::getResult($name, null);
$this->setAccountStatus($status);
}
if ($this == $currentUser || Security::requirePermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
/* Username */
$name = "user_" . $this->getId() . "_username";
$this->setUsername($_REQUEST[$name]);
/* Change password */
$nameOldpassword = "user_" . $this->getId() . "_oldpassword";
$nameNewpassword = "user_" . $this->getId() . "_newpassword";
$nameNewpasswordAgain = "user_" . $this->getId() . "_newpassword_again";
if ($_REQUEST[$nameNewpassword] != null) {
if ($this == $currentUser && $this->getPasswordHash() != User::passwordHash($_REQUEST[$nameOldpassword])) {
throw new Exception(_("Wrong password."));
}
if ($_REQUEST[$nameNewpassword] != $_REQUEST[$nameNewpasswordAgain]) {
throw new Exception(_("Passwords do not match."));
}
$this->setPassword($_REQUEST[$nameNewpassword]);
}
// Pretend there is only one
$profiles = $this->getAllProfiles();
if (!empty($profiles)) {
$current_profile = $profiles[0];
if ($current_profile != null) {
$current_profile->processAdminUI();
$name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId();
if (!empty($_REQUEST[$name])) {
$errmsg = null;
$current_profile->delete($errmsg);
}
}
} else {
$name = "user_" . $this->getId() . "_add_profile";
if (!empty($_REQUEST[$name])) {
// Get the list of profile templates for the users' network
$profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork());
if (!empty($profile_templates)) {
// Create a blank profile and link it to the user
$current_profile = Profile::createNewObject(null, $profile_templates[0]);
$this->addProfile($current_profile);
}
}
}
}
}
示例4: processAdminUI
/**
* Process admin interface of this object
*
* @return void
*/
public function processAdminUI()
{
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_ROLES'), Server::getServer());
$db = AbstractDb::getObject();
$errmsg = "";
// role_id
$value = htmlspecialchars($this->getId(), ENT_QUOTES);
// role_description_content_id
if (empty($this->_row['role_description_content_id'])) {
$name = "role_{$this->id}_description_new";
$description = Content::processNewContentUI($name);
if ($description != null) {
$description_id = $description->GetId();
$db->execSqlUpdate("UPDATE roles SET role_description_content_id = '{$description_id}' WHERE role_id = '{$this->id}'", FALSE);
}
} else {
$description = Content::getObject($this->_row['role_description_content_id']);
$name = "role_{$this->id}_description_erase";
if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
$db->execSqlUpdate("UPDATE roles SET role_description_content_id = NULL WHERE role_id = '{$this->id}'", FALSE);
$description->delete($errmsg);
} else {
$description->processAdminUI();
}
}
// Permissions
$permissionsArray = Permission::getPermissions(array('stakeholderTypeId' => $this->_row['stakeholder_type_id']));
$idStr = $db->escapeString($this->getId());
$stakeholderTypeIdStr = $db->escapeString($this->_row['stakeholder_type_id']);
$sql = "SELECT permissions.permission_id, stakeholder_type_id, role_id FROM permissions LEFT JOIN role_has_permissions ON (role_has_permissions.permission_id = permissions.permission_id AND role_id = '{$idStr}') WHERE stakeholder_type_id='{$stakeholderTypeIdStr}'";
$db->execSql($sql, $permission_rows, false);
$sql = null;
if ($permission_rows) {
foreach ($permission_rows as $row) {
$permissionIdStr = $db->escapeString($row['permission_id']);
$name = "role_{$this->id}_permission_" . htmlspecialchars($row['permission_id'], ENT_QUOTES) . "_included";
if (empty($row['role_id']) && !empty($_REQUEST[$name]) && $_REQUEST[$name] == 'included') {
$sql = "INSERT INTO role_has_permissions (permission_id, role_id) VALUES ('{$permissionIdStr}','{$idStr}');\n";
} else {
if (!empty($row['role_id']) && empty($_REQUEST[$name])) {
$sql = "DELETE FROM role_has_permissions WHERE permission_id='{$permissionIdStr}' AND role_id='{$idStr}';\n";
} else {
//echo "Do nothing for {$row['permission_id']}<br/>";
}
}
}
}
if ($sql) {
$db->execSqlUpdate("BEGIN;\n{$sql}COMMIT;", false);
}
$this->refresh();
}
示例5: processAdminUI
/**
* Process admin interface of this object
*
* @return void
*/
public function processAdminUI()
{
require_once 'classes/User.php';
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), $this);
// Authentication
if (isset($_REQUEST['use_global_auth'])) {
$this->setUseGlobalUserAccounts($_REQUEST['use_global_auth']);
} else {
$this->setUseGlobalUserAccounts(false);
}
// Access rights
require_once 'classes/Stakeholder.php';
Stakeholder::processAssignStakeholdersUI($this, $errMsg);
if (!empty($errMsg)) {
echo $errMsg;
}
}
示例6: USING
// | |
// +-------------------------------------------------------------------+
/**
* @package WiFiDogAuthServer
* @author Philippe April
* @copyright 2004-2006 Philippe April
* @version Subversion $Id$
* @link http://www.wifidog.org/
*/
/**
* Load common include file
*/
require_once 'admin_common.php';
require_once 'classes/Node.php';
require_once 'classes/MainUI.php';
Security::requirePermission(Permission::P('NETWORK_PERM_VIEW_ONLINE_USERS'), Network::getCurrentNetwork());
$db = AbstractDb::getObject();
$smarty = SmartyWifidog::getObject();
$online_users = null;
$db->execSql("SELECT connections.user_id, name, username, account_origin, timestamp_in, incoming, outgoing FROM users,nodes,connections JOIN tokens USING (token_id) WHERE token_status='" . TOKEN_INUSE . "' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id ORDER BY account_origin, timestamp_in DESC", $online_users);
$smarty->assign("users_array", $online_users);
$ui = MainUI::getObject();
$ui->addContent('main_area_middle', $smarty->fetch("admin/templates/online_users.html"));
$ui->display();
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* c-hanging-comment-ender-p: nil
* End:
*/
示例7: processAdminUI
/**
* Process admin interface of this object
*
* @return void
*/
public function processAdminUI()
{
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_PROFILE_TEMPLATES'), Server::getServer());
require_once 'classes/User.php';
$errmsg = "";
// label
$_name = "profile_template_" . $this->getId() . "_label";
$this->setLabel($_REQUEST[$_name]);
foreach ($this->getFields() as $field) {
$name = "profile_template_" . $this->id . "_field_" . $field->GetId() . "_erase";
if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
$field->delete($errmsg);
} else {
$field->processAdminUI();
}
}
ProfileTemplateField::processCreateFieldUI("profile_template_{$this->id}_new_field", $this);
}
示例8: processAdminUI
//.........这里部分代码省略.........
// Country
$name = "node_" . $node_id . "_country";
$this->setCountry($_REQUEST[$name]);
// Public phone #
$name = "node_" . $node_id . "_public_phone";
$this->setTelephone($_REQUEST[$name]);
// Public mail
$name = "node_" . $node_id . "_public_email";
$this->setEmail($_REQUEST[$name]);
// Mass transit info
$name = "node_" . $node_id . "_mass_transit_info";
$this->setTransitInfo($_REQUEST[$name]);
// GIS data
// Get a geocoder for a given country
if (!empty($_REQUEST['geocode_only'])) {
if ($geocoder = AbstractGeocoder::getGeocoder($this->getCountry()) != null) {
$geocoder = AbstractGeocoder::getGeocoder($this->getCountry());
} else {
$geocoder = AbstractGeocoder::getGeocoder('Earth');
}
if ($geocoder != null) {
$geocoder->setCivicNumber($this->getCivicNumber());
$geocoder->setStreetName($this->getStreetName());
$geocoder->setCity($this->getCity());
$geocoder->setProvince($this->getProvince());
$geocoder->setPostalCode($this->getPostalCode());
if ($geocoder->validateAddress() == true) {
if (($point = $geocoder->getGisLocation()) !== null) {
$this->setGisLocation($point);
} else {
$this->_warningMessage = _("It appears that the Geocoder could not be reached or could not geocode the given address.");
}
} else {
$this->_warningMessage = _("You must enter a valid address.");
}
} else {
$this->_warningMessage = _("Unable to create geocoder. Are you sure you set the country?");
}
} else {
// Use what has been set by the user.
$gis_lat_name = "node_" . $node_id . "_gis_latitude";
$gis_long_name = "node_" . $node_id . "_gis_longitude";
$this->setGisLocation(new GisPoint($_REQUEST[$gis_lat_name], $_REQUEST[$gis_long_name], 0.0));
}
$name = "node_" . $node_id . "_show_on_map";
$this->setShowOnMap(empty($_REQUEST[$name]) ? false : true);
// Statistics
$name = "node_{$this->id}_get_stats";
if (!empty($_REQUEST[$name])) {
header("Location: stats.php?" . urlencode("selected_nodes[]") . "=" . urlencode($this->getId()));
}
$permArray = null;
$permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network);
$permArray[] = array(Permission::P('NODE_PERM_ALLOW_GENERATING_PUBLIC_STATS'), $this);
if (Security::hasAnyPermission($permArray)) {
if (isset($_REQUEST['allows_public_stats'])) {
$this->setAllowsPublicStats($_REQUEST['allows_public_stats'] == 'on');
} else {
$this->setAllowsPublicStats(false);
}
}
// Node configuration section
$network = $this->getNetwork();
// Deployment status
$name = "node_" . $node_id . "_deployment_status";
$this->setDeploymentStatus(self::processSelectDeploymentStatus($name));
// Network selection
$name = "node_" . $node_id . "_network_id";
$new_network = Network::processSelectUI($name);
if ($new_network != $this->getNetwork()) {
Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODE'), $new_network);
$this->setNetwork($new_network);
}
// is_splash_only_node
if ($network->getSplashOnlyNodesAllowed()) {
$name = "node_" . $node_id . "_is_splash_only_node";
$this->setIsConfiguredSplashOnly(empty($_REQUEST[$name]) ? false : true);
}
// custom_portal_redirect_url
if ($network->getCustomPortalRedirectAllowed()) {
$name = "node_" . $node_id . "_custom_portal_redirect_url";
$this->setCustomPortalRedirectUrl($_REQUEST[$name]);
}
// allow_original_URL_redirect
if ($network->getPortalOriginalUrlAllowed()) {
$name = "node_" . $node_id . "_allow_original_URL_redirect";
$this->setPortalOriginalUrlAllowed(empty($_REQUEST[$name]) ? false : true);
}
// End Node configuration section
parent::processGraphAdminUI($errMsg, $network);
if (!empty($errMsg)) {
echo $errMsg;
$errMsg = null;
}
// Access rights
Stakeholder::processAssignStakeholdersUI($this, $errMsg);
if (!empty($errMsg)) {
echo $errMsg;
}
}
示例9: processAdminUI
/**
* Process admin interface of this object
*
* @return void
*/
public function processAdminUI()
{
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_CONTENT_TYPE_FILTERS'), Server::getServer());
require_once 'classes/User.php';
// label
$name = "content_type_filter_" . $this->getId() . "_label";
$this->setLabel($_REQUEST[$name]);
// rules
$name = "content_type_filter_" . $this->getId() . "_rules";
$new_rules_array = self::parseScalarArray($_REQUEST[$name]);
if (is_array($new_rules_array)) {
$this->setRules($new_rules_array);
} else {
echo _("The rules must be given as a PHP array declaration.");
}
}
示例10: processCreateNewObjectUI
/**
* Process the new object interface.
*
* Will return the new object if the user has the credentials and the form was fully filled.
* @return the node object or null if no new node was created.
*/
public static function processCreateNewObjectUI()
{
// Init values
$retval = null;
$name = "new_node_group_name";
if (!empty($_REQUEST[$name])) {
$ng_name = $_REQUEST[$name];
} else {
$ng_name = null;
}
$name = "new_node_group_network_id";
if (!empty($_REQUEST[$name])) {
$network = Network::getObject($_REQUEST[$name]);
} else {
$network = Network::processSelectUI('new_node_group');
}
if ($network) {
Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODEGROUP'), $network);
$retval = self::createNewObject($ng_name, $network);
}
return $retval;
}
示例11: processAdminUI
/**
* Process admin interface of this object
*
* @return void
*/
public function processAdminUI()
{
require_once 'classes/User.php';
Security::requirePermission(Permission::P('SERVER_PERM_EDIT_ANY_VIRTUAL_HOST'), Server::getServer());
// hostname
$name = "server_" . $this->getId() . "_hostname";
$this->setHostname($_REQUEST[$name]);
// default_network
$name = "vhost_" . $this->getId() . "_default_network";
$this->setDefaultNetwork(Network::processSelectUI($name));
// is_default_server
$name = "vhost_" . $this->getId() . "_is_default_vhost";
if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == 'on') {
$server = Server::getServer();
$server->setDefaultVirtualHost($this);
}
// ssl_available
$name = "server_" . $this->getId() . "_ssl_available";
if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == 'on') {
$this->setSSLAvailable(true);
} else {
$this->setSSLAvailable(false);
}
// gmaps_api_key
if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
$name = "server_" . $this->getId() . "_gmaps_api_key";
$this->setGoogleAPIKey($_REQUEST[$name]);
}
}