本文整理汇总了PHP中Auth::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::getInstance方法的具体用法?PHP Auth::getInstance怎么用?PHP Auth::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processValid
protected function processValid()
{
global $cfg;
$db = Database::getInstance($cfg['DPS']['dsn']);
$dir = pg_escape_string($this->fieldData['rootdir']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
if (is_numeric($dir)) {
$sql_update['name'] = $this->fieldData['dirtext'];
$swhere = "id = " . pg_escape_string($dir);
$db->update('dir', $sql_update, $swhere, true);
$sql = "SELECT count(*) FROM v_tree_dir\n\t\t\t\tWHERE id = {$dir}\n\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileO'] . "' = '" . $cfg['DPS']['fileO'] . "'";
if ($db->getOne($sql) > 0) {
$where = "dirid = {$dir} AND groupid = " . $cfg['DPS']['allusersgroupid'];
$db->delete('dirgroups', $where, $true);
if ($this->fieldData['dirperm'] == 'pubrw') {
$dirI['dirid'] = $dir;
$dirI['groupid'] = $cfg['DPS']['allusersgroupid'];
$dirI['permissions'] = $cfg['DPS']['fileRW'];
$db->insert('dirgroups', $dirI, false);
} elseif ($this->fieldData['dirperm'] == 'pubr') {
$dirI['dirid'] = $dir;
$dirI['groupid'] = $cfg['DPS']['allusersgroupid'];
$dirI['permissions'] = $cfg['DPS']['fileR'];
$db->insert('dirgroups', $dirI, false);
} else {
$dirI['dirid'] = $dir;
$dirI['groupid'] = $cfg['DPS']['allusersgroupid'];
$dirI['permissions'] = $cfg['DPS']['file'];
$db->insert('dirgroups', $dirI, false);
}
}
}
}
示例2: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$auth = Auth::getInstance();
$ID = $this->fieldData['guid'];
$realmID = substr($this->fieldData['id'], 3);
$type = $this->fieldData['treeUser'];
if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) {
header("Content-type: application/xhtml+xml");
} else {
header("Content-type: text/xml");
}
if ($type == 'group') {
$treeInfo = AuthSubRealmViewer::singleRealmTree($realmID, $ID, true);
} else {
$treeInfo = AuthSubRealmViewer::singleRealmTree($realmID, $ID, false);
}
echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
if ($realmID == 0) {
$realmID = 0;
} else {
$realmID = "rlm" . $realmID;
}
$treeInfo = '<tree id="' . $realmID . '">' . $treeInfo . '</tree>';
echo $treeInfo;
}
示例3: init
public function init()
{
$data = $_REQUEST;
if (isset($data[Profile::GET_CHANGE_PASSWORD_BUTTON])) {
if (strlen($data[Profile::GET_CHANGE_PASSWORD]) > 0) {
if (!User::passwordIsValid($data[Profile::GET_CHANGE_PASSWORD])) {
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=0');
} else {
$user = Auth::getInstance()->getUser();
$user->password = User::getHashPassword(trim(strip_tags($data[Profile::GET_CHANGE_PASSWORD])), $user->login);
$user->save();
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1');
return true;
}
}
if (strlen($data[Profile::GET_CHANGE_PHONE]) > 0) {
if (!User::validatePhone(trim($data[Profile::GET_CHANGE_PHONE]))) {
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=2');
} else {
$user = Auth::getInstance()->getUser();
$user->number = trim($data[Profile::GET_CHANGE_PHONE]);
$user->save();
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1');
return true;
}
}
}
}
示例4: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$audioID = pg_escape_string($this->fieldData['audioID']);
$sql = "SELECT jinglepkgid FROM audiojinglepkgs WHERE audioid = {$audioID}";
$jinglepkgID = $db->getOne($sql);
$sql = "SELECT name FROM jinglepkgs WHERE id = {$jinglepkgID}";
$currentpkg = $db->getOne($sql);
if ($currentpkg == '') {
$currentpkg = 'Default';
}
$sql = "SELECT title FROM audio WHERE id = {$audioID}";
$jinglename = $db->getOne($sql);
$sql = "SELECT name, id FROM jinglepkgs";
$jinglepkgs = $db->getAll($sql);
$this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
$this->assign('access_sue', AuthUtil::getDetailedUserrealmAccess(array(24, 20, 3), $userID));
$this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
$this->assign('jinglepkgs', $jinglepkgs);
$this->assign('currentpkg', $currentpkg);
$this->assign('currentpkgid', $jinglepkgID);
$this->assign('jinglename', $jinglename);
$this->assign('jingleID', $audioID);
}
示例5: action_edit
public function action_edit($id)
{
if (!Auth::getInstance()->getRights($this->getName(), 'view')) {
// тут можно смотреть, но редактирование(запуск) проверяется в виде(view)
return $this->view->getMessage('Нет прав на редактирование');
}
$rec = $this->model->getRecord($id);
if ($rec[mp]) {
$rec[mp][mplink] = $this->actUri('masterplate', $id)->url();
}
if ($rec[zadel] > 0) {
$rec[zadellink] = $this->actUri('zadel', $id)->url();
// создать AJAX ссылку для кнопки
}
$mpp = false;
for ($i = 0; $i < $rec[parties]; $i++) {
if ($rec[party][$i][party]) {
// в дозапуске указываем количество запуска и меняем его если надо скриптом см. ниже
$rec[party][$i][sllink] = $this->actUri('sl', $id, $rec[party][$i][party], $rec[block][boardinorder])->url();
}
$mpp = $rec[party][$i][type] == "mpp" || $mpp;
}
if ($mpp) {
$rec[block][boardinorder] = "<input type='text' value='{$rec[block][boardinorder]}' size='4' id='boardinorder'/><script>\n \$('#boardinorder').change(function(){ \n var sstr = \$(this).val();\n \$('.partybuttonlink').each(function(){\n var str=\$(this).attr('href');\n str = str.replace(new RegExp('lanch_nzap%5Bsl%5D%5B2%5D=[0-9]+'),'lanch_nzap%5Bsl%5D%5B2%5D='+sstr); \n \$(this).attr('href',str);\n });\n });\n </script>";
}
return $this->getMessage($this->view->showrec($rec));
}
示例6: init
public function init()
{
$data = $_REQUEST;
if (isset($data[Profile::GET_CHANGE_PASSWORD_BUTTON])) {
$user = Auth::getInstance()->getUser();
if (strlen(trim($data[Profile::GET_CHANGE_MAIL])) > 0) {
if ($user->email != trim($data[Profile::GET_CHANGE_MAIL])) {
if (User::validEmail(trim(strip_tags($data[Profile::GET_CHANGE_MAIL])))) {
$user->email = trim(strip_tags($data[Profile::GET_CHANGE_MAIL]));
$user->password = User::getHashPassword($user->password, strtolower($user->email));
} else {
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=2');
}
}
}
if (strlen(trim($data[Profile::GET_CHANGE_PASSWORD])) > 0) {
if (!User::passwordIsValid($data[Profile::GET_CHANGE_PASSWORD])) {
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=0');
} else {
$user->password = User::getHashPassword(trim(strip_tags($data[Profile::GET_CHANGE_PASSWORD])), strtolower($user->email));
}
}
$user->save();
Flight::redirect($_SERVER['REDIRECT_URL'] . '?success=1');
return true;
}
}
示例7: isValid
/**
*
* The username to be logged in is taken from the $fieldData class
* variable
*/
public function isValid(&$password)
{
$user = $this->fieldData['authUser'];
$auth = Auth::getInstance();
$flag = false;
BasicLogger::logMessage("checking login for '{$user}'", self::module, 'debug');
if ($auth->attemptLogin($user, $password)) {
BasicLogger::logMessage("successful login for '{$user}'", self::module, 'debug');
$flag = true;
} else {
BasicLogger::logMessage("failed login for '{$user}'", self::module, 'debug');
$flag = "Invalid username or password";
}
if (is_null($auth->getUserID())) {
$Nuser = array();
$Nuser['username'] = $auth->getUser();
$Nuser['enabled'] = 't';
$Nuser['id'] = "#id#";
$db = Database::getInstance($cfg['Auth']['dsn']);
$userID = $db->insert('users', $Nuser, true);
if (isset($cfg['Auth']['defaultNewUserGroup'])) {
$group = array();
$group['groupid'] = $cfg['Auth']['defaultNewUserGroup'];
$group['userid'] = $userID;
$db->insert('usersgroups', $group, true);
}
$auth->attemptLogin();
BasicLogger::logMessage("new user created for for '{$user}'", self::module, 'debug');
}
return $flag;
}
示例8: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$scriptID = pg_escape_string($this->fieldData['scriptID']);
if (!is_numeric($scriptID)) {
$this->assign('permError', 't');
} else {
$sql = "SELECT count(*) FROM v_tree_script\n\t\t\t\tWHERE id = {$scriptID}\n\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
if ($db->getOne($sql) > 0) {
$sql = "SELECT dirid FROM scriptsdir\n\t\t\t\t\tWHERE scriptid = {$scriptID}";
$dirID = $db->getOne($sql);
"SELECT count(*) FROM v_tree_dir\n\t\t\t\t\tWHERE id = {$dirID}\n\t\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
if ($db->getOne($sql) > 0) {
$flag = true;
}
}
if ($flag) {
$sql = "SELECT * FROM scripts WHERE id = {$scriptID}";
$script = $db->getRow($sql);
$sql = "SELECT count(*) FROM v_tree_script\n\t\t\t\t\tWHERE id = {$scriptID}\n\t\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileO'] . "' = '" . $cfg['DPS']['fileO'] . "'";
$check = $db->getOne($sql);
if ($check > 0) {
$this->assign('own', 't');
}
$this->assign('script', $script);
$this->assign('treeType', '');
} else {
$this->assign('permError', 't');
}
}
}
示例9: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$trackIDs = explode(";", $this->fieldData['trackID']);
$tracksDetails = array();
foreach ($trackIDs as $trackID) {
$sql = "SELECT audio.*, albums.name AS album \n\t\t\tFROM audio, albums \n\t\t\tWHERE audio.music_album = albums.id \n\t\t\t\tAND audio.id = " . pg_escape_string($trackID);
$trackDetails = $db->getRow($sql);
$sql = "SELECT DISTINCT artists.name AS name \n\t\t\tFROM artists, audioartists \n\t\t\tWHERE audioartists.audioid = " . pg_escape_string($trackID) . " \n\t\t\t\tAND audioartists.artistid = artists.id";
$trackDetails['artist'] = $db->getColumn($sql);
$sql = "SELECT DISTINCT keywords.name AS name \n\t\t\tFROM keywords, audiokeywords \n\t\t\tWHERE audiokeywords.audioid = " . pg_escape_string($trackID) . " \n\t\t\t\tAND audiokeywords.keywordid = keywords.id";
$trackDetails['keywords'] = $db->getColumn($sql);
$samples = $trackDetails['length_smpl'];
$trackDetails['length'] = $tracksLen = round($samples / 44100 / 60) . "mins " . $samples / 44100 % 60 . "secs.";
$sql = "SELECT * FROM audiocomments \n\t\t\tWHERE audioid = " . pg_escape_string($trackID) . " \n\t\t\tORDER BY creationdate ASC";
$trackDetails['comments'] = $db->getAll($sql);
foreach ($trackDetails['comments'] as &$comment) {
$comment['username'] = AuthUtil::getUsername($comment['userid']);
$comment['comment'] = str_replace("\n", "<br>", $comment['comment']);
$comment['ctime'] = substr($comment['creationdate'], 0, 10);
}
$tracksDetails[] = $trackDetails;
}
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$this->assign('RequestTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 29), $userID));
$this->assign('Access_CommentTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 34), $userID));
$this->assign('Access_EditTrack', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 27), $userID));
$this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
$this->assign('tracksDetails', $tracksDetails);
}
示例10: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$scriptID = pg_escape_string($this->fieldData['scriptID']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$date = time();
if (is_numeric($scriptID)) {
$script_query = "SELECT bit_or(permissions) \n\t\t\t\tFROM v_tree_script\n\t\t\t\tWHERE id = {$scriptID}\n\t\t\t\t\tAND userid = {$userID}";
$checkScripts = $db->getOne($script_query);
if (substr($checkScripts, 0, 1) == "1") {
if (substr($checkScripts, 1, 1) == "1") {
$this->assign('write', 't');
} else {
$this->assign('write', 'f');
}
$script_sql = "SELECT * FROM scripts WHERE id = " . $scriptID;
$script = $db->getRow($script_sql);
$script['m'] = (int) ($script['length'] / 60);
$script['s'] = $script['length'] - $script['m'] * 60;
$script['niceProducer'] = AuthUtil::getUsername($script['creator']);
$this->assign('script', $script);
} else {
$this->assign('error', 'You do not have permission to edit that script.');
}
} else {
$this->assign('error', 'Invalid Show ID supplied');
}
$this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
}
示例11: action_edit
public function action_edit($id)
{
if (!Auth::getInstance()->getRights($this->getName(), 'edit')) {
return $this->view->getMessage('Нет прав на редактирование');
}
extract($_SESSION[Auth::$lss]);
// тут данные выбранных до сих пор заказа и тз
if (empty($id)) {
// добавить плату в ТЗ
if (empty($tz_id)) {
return $this->getMessage('Не известно куда добавлять выбери ТЗ!');
} else {
return parent::action_edit($id);
}
} else {
// выбрана плата - вывести предложение создать рассчет
$url = $this->model->getFileLinkForRaschet(array(id => $id));
if ($url) {
$rec[rasslink] = $url;
} else {
$rec[createlink] = $this->actUri('createras', $id)->url();
}
return $this->getMessage($this->view->showbutton($rec));
}
}
示例12: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$loc = 1;
$sql = "SELECT v_tree_aw_sets.*, aw_sets_users.user_id AS userid\n from v_tree_aw_sets LEFT OUTER JOIN aw_sets_users\n ON aw_sets_users.set_id = v_tree_aw_sets.id\n\t\t\tWHERE v_tree_aw_sets.userid = " . $cfg['DPS']['systemUserID'] . " \n\t\t\t\tAND v_tree_aw_sets.permissions & B'" . $cfg['DPS']['fileR'] . "' = '" . $cfg['DPS']['fileR'] . "'";
// station awsets
$awsets = $db->getAll($sql);
$sql = "SELECT val FROM configuration \n\t\t\tWHERE location = {$loc} \n\t\t\t\tAND parameter = 'station_aw_set'";
$userset = $db->getOne($sql);
foreach ($awsets as &$awset) {
if ($userset == $awset['id']) {
$awset['active'] = 't';
} else {
$awset['active'] = 'f';
}
$sql = "SELECT BIT_OR(permissions) \n\t\t\t\tFROM v_tree_dir \n\t\t\t\tWHERE v_tree_dir.id = {$awset['parent']}\n\t\t\t\t\tAND v_tree_dir.userid = {$cfg['DPS']['systemUserID']}";
$awset['parentperm'] = $db->getOne($sql);
$awset['userid'] = AuthUtil::getUsername($awset['userid']);
}
$this->assign('access_playlist', AuthUtil::getDetailedUserrealmAccess(array(3, 21, 33), $userID));
$this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
$this->assign('awsets', $awsets);
}
示例13: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$dirID = pg_escape_string($this->fieldData['rootdir']);
if (!is_numeric($dirID)) {
$this->assign('permError', 't');
} else {
$flag = false;
$sql = "SELECT count(*) FROM v_tree_dir\n\t\t\t\tWHERE id = {$dirID}\n\t\t\t\t\tAND\tuserid = {$userID}\n\t\t\t\t\tAND permissions & B'" . $cfg['DPS']['fileW'] . "' = '" . $cfg['DPS']['fileW'] . "'";
if ($db->getOne($sql) > 0) {
$flag = true;
}
if ($flag) {
$sql = "SELECT * FROM dir WHERE id = {$dirID}";
$folder = $db->getRow($sql);
$this->assign('folder', $folder);
} else {
$this->assign('permError', 't');
}
}
}
示例14: delete
public function delete()
{
if ($this->show->itemID != 1) {
Auth::getInstance()->deleteUser($this->show->itemID);
}
redirect(BASE_PATH . 'admin/user');
}
示例15: setupTemplate
protected function setupTemplate()
{
global $cfg;
parent::setupTemplate();
$db = Database::getInstance($cfg['DPS']['dsn']);
//Sue playing now/next
$query = "SELECT audio.title AS title, audio.id AS id \n\t\t\tFROM sustschedule, audio \n\t\t\tWHERE sustschedule.audioid = audio.id \n\t\t\tORDER BY sustschedule.id asc";
$suePlaylist = $db->getAll($query);
foreach ($suePlaylist as $key => &$track) {
$sql = "SELECT DISTINCT artists.name AS name \n\t\t\t\tFROM artists, audioartists \n\t\t\t\tWHERE audioartists.audioid = " . $track['id'] . " \n\t\t\t\t\tAND audioartists.artistid = artists.id";
$artists = $db->getAll($sql);
foreach ($artists as $artist) {
$track['artist'] = $track['artist'] . $artist['name'] . " & ";
}
$track['artist'] = rtrim($track['artist'], " & ");
}
$auth = Auth::getInstance();
$userID = $auth->getUserID();
$this->assign('Access_ViewSue', AuthUtil::getDetailedUserrealmAccess(array(58, 60, 3), $userID));
$this->assign('Access_EditSue', AuthUtil::getDetailedUserrealmAccess(array(58, 60, 66), $userID));
$this->assign('Access_SueStats', AuthUtil::getDetailedUserrealmAccess(array(58, 60, 2), $userID));
$this->assign('Admin', AuthUtil::getDetailedUserrealmAccess(array(1), $userID));
$this->assign('storedTracks', $systemTracks);
$this->assign('sueLastTrack', $suePlaylist[0]);
$this->assign('sueNextTrack', $suePlaylist[1]);
}