This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/integrations/SockChat.php

80 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/*
* Sakura Sock Chat authentication script
* By Flashwave
*/
2015-04-25 20:08:44 +00:00
// Filesystem path to the _sakura folder WITHOUT an ending /
// This can also be set before an include of this file in case
// you're using git to keep in sync and don't want conflicts
// You can also create a PHP file including this SockChat.php
// file so it's always up-to-date! Don't forget to include the
// variable below in the file __BEFORE__ the include!
if (!isset($sockSakuraPath)) {
$sockSakuraPath = '';
}
/* * * DON'T EDIT ANYTHING BELOW THIS LINE * * */
// Include Sakura
require_once $sockSakuraPath . '/sakura.php';
use Sakura\Permissions;
use Sakura\Session;
use Sakura\User;
use Sakura\Users;
use sockchat\Auth;
if (Auth::getPageType() == AUTH_FETCH) {
// Check if user is logged into the Sakura backend if not deny
if (Users::checkLogin()) {
// If so append the required arguments and accept
2015-04-18 11:35:16 +00:00
Auth::AppendArguments([Session::$userId, Session::$sessionId]);
Auth::Accept();
} else {
Auth::Deny();
}
} else {
2015-04-18 11:35:16 +00:00
// Get arguments
2015-04-25 20:08:44 +00:00
$uid = $_REQUEST['arg1'];
$sid = $_REQUEST['arg2'];
2015-04-18 11:35:16 +00:00
// Check if session is active else deny
if (new Session($uid, $sid)) {
// Check if they can access the chat
if (Permissions::check('SITE', 'DEACTIVATED', $uid, 1) || Permissions::check('SITE', 'RESTRICTED', $uid, 1)) {
2015-04-18 11:35:16 +00:00
Auth::Deny();
Auth::Serve();
exit;
}
// Create a user object
$user = new User($uid);
2015-04-28 15:53:53 +00:00
// Set the user's data
Auth::SetUserData(
$user->data['user_id'],
$user->data['username'],
$user->colour()
);
2015-04-28 15:53:53 +00:00
// Set the common permissions
Auth::SetCommonPermissions(
$user->mainRank['hierarchy'],
Permissions::check('MANAGE', 'USE_MANAGE', $uid, 1) ? 1 : 0,
Permissions::check('SITE', 'CREATE_BACKGROUND', $uid, 1) ? 1 : 0,
Permissions::check('SITE', 'CHANGE_USERNAME', $uid, 1) ? 1 : 0,
Permissions::check('SITE', 'MULTIPLE_GROUPS', $uid, 1) ? 2 : (
Permissions::check('SITE', 'CREATE_GROUP', $uid, 1) ? 1 : 0
)
2015-04-28 15:53:53 +00:00
);
2015-04-18 11:35:16 +00:00
Auth::Accept();
} else {
Auth::Deny();
}
}
// Serve the authentication data
Auth::Serve();