本文整理汇总了PHP中Kit::CheckToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Kit::CheckToken方法的具体用法?PHP Kit::CheckToken怎么用?PHP Kit::CheckToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kit
的用法示例。
在下文中一共展示了Kit::CheckToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
function modify()
{
$db =& $this->db;
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$refer = Kit::GetParam('refer', _POST, _STRING);
$usertype = Kit::GetParam('usertype', _SESSION, _INT);
$ids = Kit::GetParam('id', _POST, _ARRAY);
$values = Kit::GetParam('value', _POST, _ARRAY);
$size = count($ids);
if ($usertype != 1) {
setMessage(__("Only admin users are allowed to modify settings"));
return $refer;
}
// Get the SettingId for LIBRARY_LOCATION
$SQL = sprintf("SELECT settingid FROM setting WHERE setting = '%s'", 'LIBRARY_LOCATION');
if (!($result = $db->query($SQL))) {
trigger_error($db->error());
trigger_error(__('Cannot find the Library Location Setting - this is serious.'), E_USER_ERROR);
}
if ($db->num_rows($result) == 0) {
trigger_error(__('Cannot find the Library Location Setting - this is serious.'), E_USER_ERROR);
}
$row = $db->get_row($result);
$librarySettingId = $row[0];
// Loop through and modify the settings
for ($i = 0; $i < $size; $i++) {
$value = Kit::ValidateParam($values[$i], _STRING);
$id = $ids[$i];
// Is this the library location setting
if ($id == $librarySettingId) {
// Check for a trailing slash and add it if its not there
$value = rtrim($value, '/') . '/';
// Attempt to add the directory specified
if (!file_exists($value . 'temp')) {
// Make the directory with broad permissions recursively (so will add the whole path)
mkdir($value . 'temp', 0777, true);
}
if (!is_writable($value . 'temp')) {
trigger_error(__('The Library Location you have picked is not writable'), E_USER_ERROR);
}
}
$SQL = sprintf("UPDATE setting SET value = '%s' WHERE settingid = %d ", $db->escape_string($value), $id);
if (!$db->query($SQL)) {
trigger_error($db->error());
trigger_error(__('Update of settings failed.'), E_USER_ERROR);
}
}
$response = new ResponseManager();
$response->SetFormSubmitResponse(__('Settings Updated'), false);
$response->Respond();
}
示例2: login
function login()
{
$db =& $this->db;
$user =& $this->user;
global $session;
// this page must be called from a form therefore we expect POST variables
$username = Kit::GetParam('username', _POST, _USERNAME);
$password = Kit::GetParam('password', _POST, _PASSWORD);
$referingpage = rawurldecode(Kit::GetParam('referingPage', _GET, _STRING));
// Check the token
if (!Kit::CheckToken()) {
// We would usually issue a HALT error here - but in the case of login we should redirect instead
trigger_error('Token does not match');
// Split on & and rejoin with &
$params = explode('&', $referingpage, 3);
unset($params['message']);
$referingpage = implode('&', $params) . '&message=Token Error';
header('Location:index.php?' . $referingpage);
exit;
}
if ($user->login($username, $password)) {
$userid = Kit::GetParam('userid', _SESSION, _INT);
$username = Kit::GetParam('username', _SESSION, _USERNAME);
setMessage($username . ' logged in');
$session->set_user(session_id(), $userid, 'user');
}
Debug::LogEntry('audit', 'Login with refering page: ' . $referingpage);
if ($referingpage == '') {
header('Location:index.php?p=index');
} else {
// Split on & and rejoin with &
$params = explode('&', $referingpage, 3);
unset($params['message']);
$referingpage = implode('&', $params);
header('Location:index.php?' . $referingpage);
}
exit;
}
示例3: Register
/**
* Register a new application with OAuth
*/
public function Register()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
$userid = Kit::GetParam('userid', _SESSION, _INT);
$message = '';
try {
$store = OAuthStore::instance();
$key = $store->updateConsumer($_POST, $userid);
$c = $store->getConsumer($key, $userid);
$message .= sprintf(__('Your consumer key is: %s'), $c['consumer_key']) . '<br />';
$message .= sprintf(__('Your consumer secret is: %s'), $c['consumer_secret']) . '<br />';
} catch (OAuthException $e) {
trigger_error('Error: ' . $e->getMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse($message, false);
$response->Respond();
}
示例4: ManualRegionPosition
function ManualRegionPosition()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
$layoutid = Kit::GetParam('layoutid', _POST, _INT);
$regionid = Kit::GetParam('regionid', _POST, _STRING);
$regionName = Kit::GetParam('name', _POST, _STRING);
$top = Kit::GetParam('top', _POST, _INT);
$left = Kit::GetParam('left', _POST, _INT);
$width = Kit::GetParam('width', _POST, _INT);
$height = Kit::GetParam('height', _POST, _INT);
$scale = Kit::GetParam('scale', _POST, _DOUBLE);
$zoom = Kit::GetParam('zoom', _POST, _DOUBLE);
// Adjust the dimensions
// For version 2 layouts and above, the scale will always be 1.
// Version 1 layouts need to use scale because the values in the XLF should be scaled down
$top = $top / $scale;
$left = $left / $scale;
$width = $width / $scale;
$height = $height / $scale;
// Transitions?
$transitionType = Kit::GetParam('transitionType', _POST, _WORD);
$duration = Kit::GetParam('transitionDuration', _POST, _INT, 0);
$direction = Kit::GetParam('transitionDirection', _POST, _WORD, '');
$region = new region($db);
$ownerId = $region->GetOwnerId($layoutid, $regionid);
$regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutid, $regionid, true);
if (!$regionAuth->edit) {
trigger_error(__('You do not have permissions to edit this region'), E_USER_ERROR);
}
Debug::LogEntry('audit', sprintf('Layoutid [%d] Regionid [%s]', $layoutid, $regionid), 'layout', 'ManualRegionPosition');
// Remove the "px" from them
$width = str_replace('px', '', $width);
$height = str_replace('px', '', $height);
$top = str_replace('px', '', $top);
$left = str_replace('px', '', $left);
// Create some options
$options = array(array('name' => 'transOut', 'value' => $transitionType), array('name' => 'transOutDuration', 'value' => $duration), array('name' => 'transOutDirection', 'value' => $direction), array('name' => 'loop', 'value' => Kit::GetParam('loop', _POST, _CHECKBOX)));
// Edit the region
if (!$region->EditRegion($layoutid, $regionid, $width, $height, $top, $left, $regionName, $options, Kit::GetParam('zindex', _POST, _INT, NULL))) {
trigger_error($region->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse('Region Resized', true, "index.php?p=layout&modify=true&layoutid={$layoutid}&zoom={$zoom}");
$response->Respond();
}
示例5: Delete
/**
* Deletes a Group
* @return
*/
function Delete()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$response = new ResponseManager();
$displayProfile = new DisplayProfile();
$displayProfile->displayProfileId = Kit::GetParam('displayprofileid', _POST, _INT);
if (!$displayProfile->Load()) {
trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR);
}
if ($this->user->usertypeid != 1 && $this->user->userid != $displayProfile->userId) {
trigger_error(__('You do not have permission to edit this profile'), E_USER_ERROR);
}
if (!$displayProfile->Delete($displayProfile->displayProfileId)) {
trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('Display Profile Deleted'), false);
$response->Respond();
}
示例6: LogoutUser
/**
* Logs out a user
* @return
*/
function LogoutUser()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
}
$db =& $this->db;
//ajax request handler
$response = new ResponseManager();
$userID = Kit::GetParam('userid', _POST, _INT);
$SQL = sprintf("UPDATE session SET IsExpired = 1 WHERE userID = %d", $userID);
if (!$db->query($SQL)) {
trigger_error($db->error());
trigger_error(__("Unable to log out this user"), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('User Logged Out.'));
$response->Respond();
}
示例7: Permissions
/**
* Set this templates permissions
*/
public function Permissions()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
$templateId = Kit::GetParam('templateid', _POST, _INT);
if ($templateId == 0) {
trigger_error(__('No template selected'), E_USER_ERROR);
}
// Is this user allowed to delete this template?
$auth = $this->user->TemplateAuth($templateId, true);
$groupIds = Kit::GetParam('groupids', _POST, _ARRAY);
// Unlink all
Kit::ClassLoader('templategroupsecurity');
$security = new TemplateGroupSecurity($db);
if (!$security->UnlinkAll($templateId)) {
trigger_error(__('Unable to set permissions'), E_USER_ERROR);
}
// Some assignments for the loop
$lastGroupId = 0;
$first = true;
$view = 0;
$edit = 0;
$del = 0;
// List of groupIds with view, edit and del assignments
foreach ($groupIds as $groupPermission) {
$groupPermission = explode('_', $groupPermission);
$groupId = $groupPermission[0];
if ($first) {
// First time through
$first = false;
$lastGroupId = $groupId;
}
if ($groupId != $lastGroupId) {
// The groupId has changed, so we need to write the current settings to the db.
// Link new permissions
if (!$security->Link($templateId, $lastGroupId, $view, $edit, $del)) {
trigger_error(__('Unable to set permissions'), E_USER_ERROR);
}
// Reset
$lastGroupId = $groupId;
$view = 0;
$edit = 0;
$del = 0;
}
switch ($groupPermission[1]) {
case 'view':
$view = 1;
break;
case 'edit':
$edit = 1;
break;
case 'del':
$del = 1;
break;
}
}
// Need to do the last one
if (!$first) {
if (!$security->Link($templateId, $lastGroupId, $view, $edit, $del)) {
trigger_error(__('Unable to set permissions'), E_USER_ERROR);
}
}
$response->SetFormSubmitResponse(__('Permissions Changed'));
$response->Respond();
}
示例8: DeleteTemplate
/**
* Deletes a template
* @return
*/
function DeleteTemplate()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
$templateId = Kit::GetParam('templateId', _POST, _INT);
if ($templateId == 0) {
trigger_error(__('No template selected'), E_USER_ERROR);
}
// Is this user allowed to delete this template?
$auth = $this->user->TemplateAuth($templateId, true);
if (!$auth->del) {
trigger_error(__('Access denied'), E_USER_ERROR);
}
// Use the data class
$template = new Layout();
// Delete the template
if (!$template->Delete($templateId)) {
trigger_error($template->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('The Template has been Deleted'));
$response->Respond();
}
示例9: WakeOnLan
/**
* Wake on LAN
*/
public function WakeOnLan()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$response = new ResponseManager();
$displayObject = new Display($db);
$displayId = Kit::GetParam('DisplayId', _POST, _INT);
if (!$displayObject->WakeOnLan($displayId)) {
trigger_error($displayObject->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('Wake on Lan command sent.'));
$response->Respond();
}
示例10: Permissions
public function Permissions()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
Kit::ClassLoader('datasetgroupsecurity');
$dataSetId = Kit::GetParam('datasetid', _POST, _INT);
$groupIds = Kit::GetParam('groupids', _POST, _ARRAY);
$auth = $this->user->DataSetAuth($dataSetId, true);
if (!$auth->modifyPermissions) {
trigger_error(__('You do not have permissions to edit this dataset'), E_USER_ERROR);
}
// Unlink all
$security = new DataSetGroupSecurity($db);
if (!$security->UnlinkAll($dataSetId)) {
trigger_error(__('Unable to set permissions'));
}
// Some assignments for the loop
$lastGroupId = 0;
$first = true;
$view = 0;
$edit = 0;
$del = 0;
// List of groupIds with view, edit and del assignments
foreach ($groupIds as $groupPermission) {
$groupPermission = explode('_', $groupPermission);
$groupId = $groupPermission[0];
if ($first) {
// First time through
$first = false;
$lastGroupId = $groupId;
}
if ($groupId != $lastGroupId) {
// The groupId has changed, so we need to write the current settings to the db.
// Link new permissions
if (!$security->Link($dataSetId, $lastGroupId, $view, $edit, $del)) {
trigger_error(__('Unable to set permissions'), E_USER_ERROR);
}
// Reset
$lastGroupId = $groupId;
$view = 0;
$edit = 0;
$del = 0;
}
switch ($groupPermission[1]) {
case 'view':
$view = 1;
break;
case 'edit':
$edit = 1;
break;
case 'del':
$del = 1;
break;
}
}
// Need to do the last one
if (!$first) {
if (!$security->Link($dataSetId, $lastGroupId, $view, $edit, $del)) {
trigger_error(__('Unable to set permissions'), E_USER_ERROR);
}
}
$response->SetFormSubmitResponse(__('Permissions Changed'));
$response->Respond();
}
示例11: Truncate
/**
* Truncate the Log
*/
public function Truncate()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
}
$db =& $this->db;
if ($this->user->usertypeid != 1) {
trigger_error(__('Only Administrator Users can truncate the log'), E_USER_ERROR);
}
$db->query("TRUNCATE TABLE log");
$response = new ResponseManager();
$response->SetFormSubmitResponse('Log Truncated');
$response->Respond();
}
示例12: MenuItemSecurityAssign
/**
* Menu Item Security Assignment to Groups
* @return
*/
function MenuItemSecurityAssign()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$groupid = Kit::GetParam('groupid', _POST, _INT);
$pageids = $_POST['pageids'];
foreach ($pageids as $menuItemId) {
$row = explode(",", $menuItemId);
$menuItemId = $row[1];
// If the ID is 0 then this menu item is not currently assigned
if ($row[0] == "0") {
//it isnt assigned and we should assign it
$SQL = sprintf("INSERT INTO lkmenuitemgroup (GroupID, MenuItemID) VALUES (%d, %d)", $groupid, $menuItemId);
if (!$db->query($SQL)) {
trigger_error($db->error());
Kit::Redirect(array('success' => false, 'message' => __('Can\'t assign this menu item to this group')));
}
} else {
//it is already assigned and we should remove it
$SQL = sprintf("DELETE FROM lkmenuitemgroup WHERE groupid = %d AND MenuItemID = %d", $groupid, $menuItemId);
if (!$db->query($SQL)) {
trigger_error($db->error());
Kit::Redirect(array('success' => false, 'message' => __('Can\'t remove this menu item from this group')));
}
}
}
// Response
$response = new ResponseManager();
$response->SetFormSubmitResponse(__('User Group Menu Security Edited'));
$response->keepOpen = true;
$response->Respond();
}
示例13: Edit
/**
* Edit Transition
*/
public function Edit()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$response = new ResponseManager();
// Can we edit?
if (Config::GetSetting('TRANSITION_CONFIG_LOCKED_CHECKB') == 'Checked') {
trigger_error(__('Transition Config Locked'), E_USER_ERROR);
}
$transitionId = Kit::GetParam('TransitionID', _POST, _INT);
$enabledForIn = Kit::GetParam('EnabledForIn', _POST, _CHECKBOX);
$enabledForOut = Kit::GetParam('EnabledForOut', _POST, _CHECKBOX);
// Validation
if ($transitionId == 0 || $transitionId == '') {
trigger_error(__('Transition ID is missing'), E_USER_ERROR);
}
// Deal with the Edit
$SQL = "UPDATE `transition` SET AvailableAsIn = %d, AvailableAsOut = %d WHERE TransitionID = %d";
$SQL = sprintf($SQL, $enabledForIn, $enabledForOut, $transitionId);
if (!$db->query($SQL)) {
trigger_error($db->error());
trigger_error(__('Unable to update transition'), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('Transition Edited'), false);
$response->Respond();
}
示例14: Delete
public function Delete()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$response = new ResponseManager();
$helpId = Kit::GetParam('HelpID', _POST, _INT);
// Deal with the Edit
Kit::ClassLoader('help');
$helpObject = new Help($db);
if (!$helpObject->Delete($helpId)) {
trigger_error($helpObject->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse(__('Help Link Deleted'), false);
$response->Respond();
}
示例15: ManualRegionPosition
function ManualRegionPosition()
{
// Check the token
if (!Kit::CheckToken()) {
trigger_error('Token does not match', E_USER_ERROR);
}
$db =& $this->db;
$user =& $this->user;
$response = new ResponseManager();
$layoutid = Kit::GetParam('layoutid', _POST, _INT);
$regionid = Kit::GetParam('regionid', _POST, _STRING);
$regionName = Kit::GetParam('name', _POST, _STRING);
$top = Kit::GetParam('top', _POST, _INT);
$left = Kit::GetParam('left', _POST, _INT);
$width = Kit::GetParam('width', _POST, _INT);
$height = Kit::GetParam('height', _POST, _INT);
$scale = Kit::GetParam('scale', _POST, _DOUBLE);
// Adjust the dimensions
$top = $top / $scale;
$left = $left / $scale;
$width = $width / $scale;
$height = $height / $scale;
// Transitions?
$transitionType = Kit::GetParam('transitionType', _POST, _WORD);
$duration = Kit::GetParam('transitionDuration', _POST, _INT, 0);
$direction = Kit::GetParam('transitionDirection', _POST, _WORD, '');
Kit::ClassLoader('region');
$region = new region($db);
$ownerId = $region->GetOwnerId($layoutid, $regionid);
$regionAuth = $this->user->RegionAssignmentAuth($ownerId, $layoutid, $regionid, true);
if (!$regionAuth->edit) {
trigger_error(__('You do not have permissions to edit this region'), E_USER_ERROR);
}
Debug::LogEntry('audit', sprintf('Layoutid [%d] Regionid [%s]', $layoutid, $regionid), 'layout', 'ManualRegionPosition');
// Remove the "px" from them
$width = str_replace('px', '', $width);
$height = str_replace('px', '', $height);
$top = str_replace('px', '', $top);
$left = str_replace('px', '', $left);
// Create some options
$options = array(array('name' => 'transOut', 'value' => $transitionType), array('name' => 'transOutDuration', 'value' => $duration), array('name' => 'transOutDirection', 'value' => $direction));
// Edit the region
if (!$region->EditRegion($layoutid, $regionid, $width, $height, $top, $left, $regionName, $options)) {
trigger_error($region->GetErrorMessage(), E_USER_ERROR);
}
$response->SetFormSubmitResponse('Region Resized', true, "index.php?p=layout&modify=true&layoutid={$layoutid}");
$response->Respond();
}