示例#1
0
 *
 * @param userName - The user's name.
 * @param password - The user's password.
 * @param passwordEncrypt - The method of encryption used to send the password. 'sha256' indicates sha256(password), 'sha256-salt' indicates sha256(sha256(password) . passwordSalt). 'sha256-salt' is discouraged, since it prevents the system from using an unstored salt that prevents against bruteforcing if the database is hacked.
 * @param passwordSalt - The salt used for encrypting the password, if it is encrypted using 'sha256-salt' or 'sha256-salt'. Any salt can be used, though long ones will be truncated to 50 characters, and only certain characters are allowed.
 * @param email - The email of the user.
 * @param birthdate - The date-of-birth of the user (unix timestamp).
 *
 * TODO: Captcha Support, IP Limits, Email Restricted/Allowed Domains, Birthdate Filter, Censor Names
 */
$apiRequest = true;
$ignoreLogin = true;
require '../global.php';
require '../functions/fim_uac_vanilla.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('userName' => array('default' => ''), 'password' => array('default' => ''), 'passwordEncrypt' => array('valid' => array('plaintext', 'sha256', 'sha256-salt'), 'default' => ''), 'passwordSalt' => array('cast' => 'ascii128'), 'email' => array('default' => ''), 'birthdate' => array('cast' => 'int')));
$userAge = fim_dobToAge($request['birthdate']);
// Generate the age in years of the user.
/* Start Processing */
if ($continue) {
    if ($loginConfig['method'] != 'vanilla') {
        $errStr = 'notSupported';
        $errDesc = 'This script only works for servers using vanilla logins.';
    } elseif ($user['userId'] && ($config['anonymousUserId'] && $user['userId'] != $config['anonymousUserId'] || !$config['anonymousUserId'])) {
        $errStr = 'loggedIn';
        $errDesc = 'You are already logged-in.';
    } elseif (count($slaveDatabase->getUsers(array('userNames' => $request['userName']))->getAsArray(true)) > 0) {
        $errStr = 'userExists';
        $errDesc = 'That user specified already exists.';
    } elseif (!$request['userName']) {
        $errStr = 'noUserName';
/**
 * Obtain a roomId corresponding with a private room between the provided userIds and, if not included, the active userId.
 * @internal This API, unlike most get*() APIs, will create a new room if one does not alredy exist. This is automatic and can not be controlled.
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 * @param string users - JSONList of userIds (the active user may be omitted).
 *
 * TODO -- Ignore List
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('userIds' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true)));
/* Data Predefine */
$xmlData = array('getPrivateRoom' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'room' => array()));
if (!$user['userDefs']['privateRoomsFriends']) {
    $errStr = 'noPerm';
} else {
    /** TODO: FREINDLIST **/
    /* Get Rooms From Database */
    if (!in_array($user['userId'], $request['userIds'])) {
        $request['userIds'][] = $user['userId'];
    }
    // The active user is automatically added if not specified. This is to say, this API can _not_ be used to obtain a private room that doesn't involve a user (for administrative purposes, for instance). getRooms.php can be used for this by querying roomAlias.
    if (count($request['userIds']) < 2) {
        $errStr = 'noUsers';
    } else {
        $privateAlias = fim_getPrivateRoomAlias($request['userIds']);
示例#3
0
<?php

$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('list' => array('valid' => array('users', 'rooms'), 'require' => true), 'search' => array('cast' => 'string', 'require' => true)));
switch ($request['list']) {
    case 'users':
        $entries = $slaveDatabase->getUsers(array('userNameSearch' => $request['search']))->getColumnValues('userName');
        break;
    case 'rooms':
        $entries = $slaveDatabase->getRooms(array('roomNameSearch' => $request['search']))->getColumnValues('roomName');
        break;
}
/* Data Predefine */
$xmlData = array('acHelper' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'entries' => $entries));
/* Output Data */
echo fim_outputApi($xmlData);
示例#4
0
/**
 * Get Data on One or More Users
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string [users] - A comma-seperated list of user IDs to get. If not specified, all users will be retrieved.
 * @param string [sort=userId] - How to sort the users, either by userId or userName.
 * @param string [showOnly] - A specific filter to apply to users that may be used for certain special tasks. "banned" specifies to show only users who have been banned. Prepending a bang ("!") to any value will reverse the filter - thus, "!banned" will only show users who have not been banned. It is possible to apply multiple filters by comma-seperating values.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('users' => array('cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true, 'default' => ''), 'userNames' => array('cast' => 'jsonList', 'filter' => 'string', 'default' => ''), 'showOnly' => array('cast' => 'jsonList', 'valid' => array('banned', '!banned', '!friends', 'friends', '!ignored', 'ignored', ''), 'default' => ''), 'sort' => array('valid' => array('userId', 'userName'), 'default' => 'userId'), 'info' => array('cast' => 'jsonList', 'valid' => array('profile', 'groups', 'self'), 'default' => '["profile", "groups", "self"]')));
/* Data Predefine */
$xmlData = array('getUsers' => array('activeUser' => array('userId' => (int) $user->id, 'userName' => $user->name), 'users' => array()));
/* Get Users from Database */
$users = $slaveDatabase->getUsers(array('userIds' => $request['users'], 'userNames' => $request['userNames']), array($request['sort'] => 'asc'))->getAsUsers();
/* Run Seperate Queries for Integration Methods
 * TODO: These should, long term, probably be plugins.
 * TODO: vB and PHPBB both broken. */
/*switch ($loginConfig['method']) {
  case 'vbulletin3': case 'vbulletin4':
  $userDataForums = $integrationDatabase->select(
    array(
      $sqlUserTable => array(
        'joindate' => 'joinDate',
        'posts' => 'posts',
        'usertitle' => 'userTitle',
 * Performs a Maintenance Action
 * The user must be an administrator with maintenance priviledges, or the action will fail.
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string action - The maintenance action to perform.
 * @param int offset - The ID offset to be used on the task at hand.
 * @param int limit - The maximum number of results to process in this cycle.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('action' => array('require' => true, 'valid' => array('disableSystem', 'enableSystem', 'updatePostFormatCache', 'updatePostCountCache')), 'offset' => array('default' => 0, 'context' => 'int'), 'limit' => array('default' => 0, 'context' => 'int')));
/* Data Predefine */
$xmlData = array('maintenance' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'response' => array()));
/* Start Processing */
if ($user['adminDefs']['modPrivs']) {
    switch ($request['action']) {
        case 'disableSystem':
            if (file_exists('.tempStop')) {
                echo container('Error', 'FIM has already been stopped.');
            } else {
                modLog('disable', '');
                touch('.tempStop');
                echo container('', 'FIM has been stopped.');
            }
            break;
        case 'enableSystem':
 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Deletes or Undeletes a Message
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 * @todo - Document.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('action' => array('valid' => array('delete', 'undelete', 'edit')), 'messageId' => array('cast' => 'int')));
/* Data Predefine */
$xmlData = array('editMessage' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'response' => array()));
$messageData = $slaveDatabase->getMessage($request['messageId']);
/* Start Processing */
if (!$messageData) {
    $errStr = 'invalidMessage';
    $errDesc = 'The message specified is invalid.';
} elseif ($continue) {
    switch ($request['action']) {
        case 'delete':
            $roomData = $generalCache->getRooms($messageData['roomId']);
            if (fim_hasPermission($roomData, $user, 'moderate', true)) {
                $database->update("{$sqlPrefix}messages", array('deleted' => 1), array("messageId" => (int) $request['messageId']));
                $database->update("{$sqlPrefix}messagesCached", array('deleted' => 1), array("messageId" => (int) $request['messageId']));
                $database->createEvent('deletedMessage', $user['userId'], $roomData['roomId'], $messageData['messageId'], false, false, false);
示例#7
0
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Get Rooms from the Server
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 * @param bool [showDeleted=false] - Will attempt to show deleted rooms, assuming the user has access to them (that is, is an administrator). Defaults to false.
 * @param string [order=roomId] - How the rooms should be ordered (either roomId or roomName).
 * @param string [rooms] - If specified, only specific rooms are listed. By default, all rooms are listed.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('permFilter' => array('default' => 'view', 'valid' => array('post', 'view', 'moderate', 'alter', 'admin', 'own'), 'require' => false), 'roomIds' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'roomNames' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'string', 'evaltrue' => true), 'search' => array('cast' => 'string'), 'sort' => array('valid' => array('roomId', 'roomName'), 'default' => 'roomId'), 'showDeleted' => array('cast' => 'bool', 'default' => false)));
/* Data Predefine */
$xmlData = array('getRooms' => array('activeUser' => array('userId' => $user->id, 'userName' => $user->name), 'rooms' => array()));
$permFilterMatches = array('post' => ROOM_PERMISSION_POST, 'view' => ROOM_PERMISSION_VIEW, 'moderate' => ROOM_PERMISSION_MODERATE, 'alter' => ROOM_PERMISSION_PROPERTIES, 'admin' => ROOM_PERMISSION_GRANT, 'own' => ROOM_PERMISSION_VIEW);
$rooms = $database->getRooms(array('roomIds' => $request['roomIds'], 'roomNames' => $request['roomNames'], 'showDeleted' => $request['showDeleted'], 'roomNameSearch' => $request['search'], 'ownerIds' => $request['permFilter'] === 'own' ? array($user->id) : array()), array($request['sort'] => 'asc'))->getAsRooms();
foreach ($rooms as $roomId => $room) {
    $permissions = $database->hasPermission($user, $room);
    //  if (!($permissions & $permFilterMatches[$request['permFilter']])) continue;
    $xmlData['getRooms']['rooms']['room ' . $roomId] = array('roomId' => $room->id, 'roomName' => $room->name, 'ownerId' => $room->ownerId, 'defaultPermissions' => $room->defaultPermissions, 'parentalFlags' => new apiOutputList($room->parentalFlags), 'parentalAge' => $room->parentalAge, 'official' => $room->official, 'archived' => $room->archived, 'hidden' => $room->hidden, 'deleted' => $room->deleted, 'permissions' => array('view' => (bool) ($permissions & ROOM_PERMISSION_VIEW), 'post' => (bool) ($permissions & ROOM_PERMISSION_POST), 'topic' => (bool) ($permissions & ROOM_PERMISSION_TOPIC), 'moderate' => (bool) ($permissions & ROOM_PERMISSION_MODERATE), 'alter' => (bool) ($permissions & ROOM_PERMISSION_PROPERTIES), 'admin' => (bool) ($permissions & ROOM_PERMISSION_GRANT)));
    if ($permissions[0]['view']) {
        // These are not shown to users who are not allowed to access the room.
        $xmlData['getRooms']['rooms']['room ' . $roomId]['roomTopic'] = $roomData['roomTopic'];
        $xmlData['getRooms']['rooms']['room ' . $roomId]['owner'] = $roomData['owner'];
        $xmlData['getRooms']['rooms']['room ' . $roomId]['lastMessageId'] = $roomData['lastMessageId'];
        $xmlData['getRooms']['rooms']['room ' . $roomId]['lastMessageTime'] = $roomData['lastMessageTime'];
        $xmlData['getRooms']['rooms']['room ' . $roomId]['messageCount'] = $roomData['messageCount'];
示例#8
0
    $ignoreLogin = false;
}
// pages without login
if (!isset($apiRequest)) {
    $apiRequest = false;
}
// /api/ functions
if (!isset($streamRequest)) {
    $streamRequest = false;
}
// /apiRequest/ functions
if (!isset($hookLogin)) {
    $hookLogin = false;
}
// pages with custom login
$request = fim_sanitizeGPC('r', array('userId' => array('cast' => 'int'), 'userName' => array(), 'password' => array(), 'passwordEncrypt' => array('valid' => array('base64', 'plaintext', 'md5')), 'apiVersions' => array('cast' => 'jsonList', 'filter' => 'string', 'evaltrue' => true), 'fim3_sessionHash' => array(), 'fim3_userId' => array('cast' => 'int')));
///* Some Pre-Stuff *///
$sessionHash = '';
$loginMethod = false;
$goodVersion = false;
$loginDefs['syncMethods'] = array('phpbb', 'vbulletin3', 'vbulletin4');
/* Default user object.
 * Note: As of now, this object should never be used. In all cases the script either quits or the user object is filled with anonymous information or information corresponding with a real user. However, this object is useful for dev purposes, and if a script wants to use $ignoreLogin. */
$user = array('userId' => 0, 'userName' => 'MISSINGNO.', 'privs' => 0);
///* Determine How to Verify the Login in the Next Section *///
if (is_array($hookLogin)) {
    if (isset($hookLogin['userName'], $hookLogin['password'])) {
        $request['userName'] = $hookLogin['userName'];
        $request['password'] = $hookLogin['password'];
        $loginMethod = 'credentials';
    }
/**
 * Get All Censor Lists, Optionally With the Active Status in One or More Rooms
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string rooms - A comma-seperated list of room IDs to query for whether or not the list is active in that room.
 * @param string lists - A comma-seperated list of list IDs to filter by. If not specified all lists will be retrieved.
 *
 * @todo Implement room status.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('listIds' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'roomIds' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'includeWords' => array('default' => false, 'filter' => 'bool')));
//; die($censorLists->sourceQuery); //
/* Data Predefine */
$xmlData = array('getCensorLists' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'lists' => array()));
/* Get Censor Lists from Slave Database */
$censorLists = $slaveDatabase->getCensorLists(array('listIds' => $request['listIds'], 'roomIds' => $request['roomIds']))->getAsArray(array('listId', 'roomId'));
if ($request['includeWords']) {
    $censorWords = $slaveDatabase->getCensorWords(array('listIds' => $request['listIds']))->getAsArray(array('listId', 'wordId'));
}
/* Start Processing */
foreach ($censorLists as $listId => $lists) {
    // Run through each censor list retrieved.
    foreach ($lists as $roomId => $list) {
        if (!isset($xmlData['getCensorLists']['lists']['list ' . $list['listId']])) {
            $xmlData['getCensorLists']['lists']['list ' . $list['listId']] = array('listId' => (int) $list['listId'], 'listName' => $list['listName'], 'listType' => $list['listType'], 'listOptions' => (int) $list['options'], 'words' => array(), 'roomStatuses' => array());
            if ($request['includeWords']) {
示例#10
0
 *
 * =Response=
 * @return APIOBJ:
 ** editRoom
 *** activeUser
 **** userId
 **** userName
 *** errStr
 *** errDesc
 *** response
 **** insertId - If creating a room, the ID of the created room.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('action' => array('valid' => array('create', 'edit', 'delete', 'undelete'), 'require' => true), 'roomId' => array('cast' => 'int'), 'roomName' => array('require' => false, 'trim' => true), 'defaultPermissions' => array('default' => 0, 'cast' => 'int'), 'moderators' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'allowedUsers' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'allowedGroups' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'censor' => array('cast' => 'array', 'filter' => 'bool', 'evaltrue' => false), 'parentalAge' => array('cast' => 'int', 'valid' => $config['parentalAges'], 'default' => $config['parentalAgeDefault']), 'parentalFlags' => array('default' => $config['parentalFlagsDefault'], 'cast' => 'csv', 'valid' => $config['parentalFlags']), 'allowViewing' => array('cast' => 'bool', 'default' => false)));
/* Data Predefine */
$xmlData = array('editRoom' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'response' => array()));
if ($action !== 'create') {
    $room = $slaveDatabase->getRoom($request['roomId']);
    if (!fim_hasPermission($room, $user, 'admin', true)) {
        $errStr = 'noPerm';
    }
}
/* Start Processing */
if (!$errStr) {
    switch ($request['action']) {
        case 'create':
        case 'edit':
            $data = $slaveDatabase->getRooms(array('roomNames' => array($request['roomName'])))->getAsArray(false);
            if ($request['action'] === 'create') {
示例#11
0
 * Works with both private and normal rooms.
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param int roomId - The room ID.
 * @param string message - The message text, properly URLencoded.
 * @param string flag - A message content-type/context flag, used for sending images, urls, etc.
 * @param bool ignoreBlock - If true, the system will ignore censor warnings. You must pass this to resend a message that was denied because of a censor warning.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('roomId' => array('require' => true), 'message' => array(), 'flag' => array('valid' => array('image', 'video', 'url', 'email', 'html', 'audio', 'text', 'source', '')), 'ignoreBlock' => array('default' => false, 'cast' => 'bool')));
$ip = $_SERVER['REMOTE_ADDR'];
// Get the IP address of the user.
/* Get Room for DB */
$room = $database->getRoom($request['roomId']);
/* Censor Fun */
$blockedWord = false;
$blockedWordText = false;
$blockedWordReason = false;
$blockedWordSeverity = false;
$blockWordApi = array('word' => '', 'severity' => '', 'reason' => '');
if ($censorWordsCache['byWord']) {
    foreach ($censorWordsCache['byWord'] as $word) {
        if ($request['ignoreBlock'] && $word['severity'] === 'confirm') {
            continue;
        }
示例#12
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
require 'global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('do' => array('cast' => 'string', 'valid' => array('register'), 'require' => false)));
$redirectPage = '';
// This will contain the page to redirect to.
switch ($request['do']) {
    case 'register':
        // Register for an account to post.
        switch ($loginConfig['method']) {
            // Different methods for each forum system.
            case 'phpbb':
                $redirectPage = $loginConfig['url'] . 'ucp.php?mode=register';
                break;
            case 'vbulletin':
                $redirectPage = $loginConfig['url'] . 'register.php';
                break;
            case 'vanilla':
                $redirectPage = 'register/index.php';
示例#13
0
 * @throws invalidFile - The 'fileId' parameter sent does not correspond to an existing file.
 * @throws noPerm - The active user does not have permission to perform the action requested.
 * @throws noOrphanFiles - A valid room was not provided, and the server requires that all files are associated with a room.
 *
 * =Reponse=
 * @return APIOBJ:
 ** editFile
 *** activeUser
 **** userId
 **** userName
 *** response [[TODO]]
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('action' => array('require' => true, 'valid' => array('create', 'edit', 'delete', 'undelete', 'flag')), 'uploadMethod' => array('default' => 'raw', 'valid' => array('raw', 'put')), 'fileName' => array('require' => true, 'trim' => true), 'fileData' => array('default' => ''), 'fileSize' => array('cast' => 'int'), 'fileMd5hash' => array(), 'fileSha256hash' => array(), 'roomId' => array('default' => 0, 'cast' => 'int'), 'dataEncode' => array('require' => true, 'valid' => array('base64', 'binary')), 'parentalAge' => array('cast' => 'int', 'valid' => $config['parentalAges'], 'default' => $config['parentalAgeDefault']), 'parentalFlags' => array('default' => $config['parentalFlagsDefault'], 'cast' => 'csv', 'valid' => $config['parentalFlags']), 'fileId' => array('default' => 0, 'cast' => 'int')));
/* Data Predefine */
$xmlData = array('editFile' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'response' => array()));
$database->startTransaction();
/* Start Processing */
switch ($request['action']) {
    case 'edit':
    case 'create':
        $parentalFileId = 0;
        if ($request['action'] === 'create') {
            /* Get Room Data, if Applicable */
            if ($request['roomId']) {
                $roomData = $slaveDatabase->getRoom($request['roomId']);
            } else {
                $roomData = false;
            }
示例#14
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
if (!defined('WEBPRO_INMOD')) {
    die;
} else {
    $request = fim_sanitizeGPC('r', array('directive' => array('cast' => 'string'), 'newDirective' => array('cast' => 'bool'), 'value' => array('cast' => 'string'), 'type' => array('cast' => 'string', 'valid' => array('integer', 'bool', 'string', 'float', 'array', 'associative'))));
    if ($user['adminDefs']['modPrivs']) {
        switch ($_GET['do2']) {
            case 'view':
            case false:
                $config3 = $database->getConfigurations()->getAsArray(true);
                foreach ($config3 as $config2) {
                    if ($config2['type'] == 'array' || $config2['type'] == 'associative') {
                        $config2['value'] = str_replace(',', ', ', $config2['value']);
                    }
                    $rows .= "<tr><td>{$config2['directive']}</td><td>{$config2['type']}</td><td>{$config2['value']}</td><td><a href=\"./moderate.php?do=config&do2=edit&directive={$config2['directive']}\"><img src=\"./images/document-edit.png\" /></a></td></tr>";
                }
                echo container('Configurations<a href="./moderate.php?do=config&do2=edit"><img src="./images/document-new.png" style="float: right;" /></a>', '<table class="page rowHover">
  <thead>
    <tr class="ui-widget-header">
      <td>Directive</td>
/**
 * Sets a User's Activity Status
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param int roomId - A comma-seperated list of room IDs to get.
 * @param string statusType - The type of status.
 * @param string statusValue - The value of the status type.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('roomIds' => array('cast' => 'jsonList', 'filter' => 'int'), 'status' => array('valid' => array('away', 'busy', 'available', 'invisible', 'offline')), 'type' => array('cast' => 'bool')));
/* Get Room Data */
$rooms = $slaveDatabase->getRooms(array('roomIds' => $request['roomIds']))->getAsArray('roomId');
if (!count($rooms)) {
    throw new Exception('invalidRooms');
} else {
    foreach ($rooms as $room) {
        if (!fim_hasPermission($room, $user, 'view', true)) {
            continue;
        }
        $database->setUserStatus($room['roomId']);
    }
}
$xmlData = array('setUserStatus' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName'])));
/* Output Data */
echo fim_outputApi($xmlData);
 ***** status - true or false
 ***** newValue
 ***** errStr
 ***** errDesc
 **** parentalFlags
 ***** status - true or false
 ***** newValue
 *
 * Notes
 * This API should ideally be possible to represent using these REST requests:
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('p', array('defaultRoomId' => array('cast' => 'int'), 'avatar' => array('trim' => true), 'profile' => array('trim' => true), 'defaultFontface' => array('trim' => true), 'defaultColor' => array('trim' => true), 'defaultHighlight' => array('trim' => true), 'defaultFormatting' => array('cast' => 'int'), 'parentalAge' => array('cast' => 'int'), 'parentalFlags' => array('cast' => 'csv', 'valid' => $config['parentalFlags'])));
$sRequest = fim_sanitizeGPC('pgd', array('watchRooms' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true, 'default' => array()), 'favRooms' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true, 'default' => array()), 'friendsList' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true, 'default' => array()), 'ignoreList' => array('cast' => 'csv', 'filter' => 'int', 'evaltrue' => true, 'default' => array())));
/* Data Predefine */
$xmlData = array('editUserOptions' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'response' => array()));
/* Start Processing */
if ($loginConfig['method'] === 'vanilla') {
    /* Avatar */
    if (isset($request['avatar'])) {
        // TODO: Add regex policy.
        $imageData = getimagesize($request['avatar']);
        if ($imageData[0] <= $config['avatarMinimumWidth'] || $imageData[1] <= $config['avatarMinimumHeight']) {
            $xmlData['editUserOptions']['response']['avatar']['status'] = false;
            $xmlData['editUserOptions']['response']['avatar']['errStr'] = 'smallSize';
            $xmlData['editUserOptions']['response']['avatar']['errDesc'] = 'The avatar specified is too small.';
        } elseif ($imageData[0] >= $config['avatarMaximumWidth'] || $imageData[1] >= $config['avatarMaximumHeight']) {
            $xmlData['editUserOptions']['response']['avatar']['status'] = false;
            $xmlData['editUserOptions']['response']['avatar']['errStr'] = 'bigSize';
示例#17
0
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Get All Usergroups
 * USES INTEGRATION
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string groups - A comma-seperated list of group IDs to filter by. If not specified all groups will be retrieved.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('groups' => array('default' => '', 'cast' => 'csv', 'filter' => 'int', 'evaltrue' => true)));
/* Data Predefine */
$xmlData = array('getGroups' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'groups' => array()));
$queryParts['groupsSelect']['columns'] = array("{$sqlUserGroupTable}" => array("{$sqlUserGroupTableCols['groupId']}" => 'groupId', "{$sqlUserGroupTableCols['groupName']}" => 'groupName'));
$queryParts['groupsSelect']['conditions'] = array('both' => array());
$queryParts['groupsSelect']['sort'] = array('groupId' => 'asc');
$queryParts['groupsSelect']['limit'] = false;
/* Modify Query Data for Directives */
if (count($request['groups']) > 0) {
    $queryParts['groupsSelect']['conditions']['both']['groupId'] = $database->type('array', $request['groups'], 'in');
}
/* Get Groups from Database */
if ($continue) {
    $groups = $integrationDatabase->select($queryParts['groupsSelect']['columns'], $queryParts['groupsSelect']['conditions'], $queryParts['groupsSelect']['sort'], $queryParts['groupsSelect']['limit']);
    $groups = $groups->getAsArray('groupId');
}
示例#18
0
 * Get Rooms from the Server
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 * @param bool [showDeleted=false] - Will attempt to show deleted rooms, assuming the user has access to them (that is, is an administrator). Defaults to false.
 * @param string [order=roomId] - How the rooms should be ordered (either roomId or roomName).
 * @param string [rooms] - If specified, only specific rooms are listed. By default, all rooms are listed.
 */
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$requestG = fim_sanitizeGPC('g', array('action' => array('valid' => array('get', 'create', 'edit', 'delete', 'undelete'), 'require' => true), 'permFilter' => array('default' => 'view', 'valid' => array('post', 'view', 'moderate', 'alter', 'admin', 'own'), 'require' => false), 'showDeleted' => array('cast' => 'bool', 'default' => false), 'info' => array('default' => array(), 'cast' => 'jsonList', 'valid' => array('permissions')), 'sort' => array('valid' => array('roomId', 'roomName'), 'default' => 'roomId'), 'roomIds' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'roomNames' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'string', 'evaltrue' => true), 'search' => array('cast' => 'string')));
/* Get Post Data */
$requestP = fim_sanitizeGPC('p', array('defaultPermissions' => array('valid' => array('view', 'post', 'topic'), 'cast' => 'jsonList'), 'moderators' => array('cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'userPermissions' => array('cast' => 'json'), 'groupPermissions' => array('cast' => 'json'), 'censor' => array('cast' => 'json', 'filter' => 'bool', 'filterKey' => 'int'), 'parentalAge' => array('cast' => 'int', 'valid' => $config['parentalAges'], 'default' => $config['parentalAgeDefault']), 'parentalFlags' => array('cast' => 'jsonList', 'valid' => $config['parentalFlags'], 'default' => $config['parentalFlagsDefault'])));
/* Manual Formatting for Some of the Request Variables */
$requestP['defaultPermissions'] = getPermissionsField($requestP['defaultPermissions']);
if ($requestG['action'] === 'create' || $requestG['action'] === 'edit') {
    if (!strlen($request['roomName'])) {
        new fimError('noName', 'A room name was not supplied.');
    } elseif (strlen($request['roomName']) < $config['roomLengthMinimum']) {
        new fimError('shortName', 'The room name specified is too short.', array('roomLengthMinimum' => $config['roomLengthMinimum']));
    } elseif (strlen($request['roomName']) > $config['roomLengthMaximum']) {
        new fimError('longName', 'The room name specified is too long.', array('roomLengthMinimum' => $config['roomLengthMaximum']));
    }
}
$permFilterMatches = array('post' => ROOM_PERMISSION_POST, 'view' => ROOM_PERMISSION_VIEW, 'topic' => ROOM_PERMISSION_TOPIC, 'moderate' => ROOM_PERMISSION_MODERATE, 'properties' => ROOM_PERMISSION_PROPERTIES, 'grant' => ROOM_PERMISSION_GRANT, 'own' => ROOM_PERMISSION_VIEW);
/* Helper Functions */
function getPermissionsField($permissionsArray)
{
示例#19
0
 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Displays an Database-Stored File
 * Though it follows much of the same logic, this is not part of the standard API as it does not return data in the standard way, and thus some global directives do not work.
 *
 * @param timestamp time
 * @param string md5hash
 * @param string sha256hash
 * @param string fileId
*/
$ignoreLogin = true;
require 'global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('md5hash' => array('cast' => 'string', 'require' => false, 'default' => ''), 'sha256hash' => array('cast' => 'string', 'require' => false, 'default' => ''), 'fileId' => array('cast' => 'int', 'require' => false, 'default' => ''), 'vfileId' => array('cast' => 'int', 'require' => false, 'default' => ''), 'parentalAge' => array('cast' => 'int', 'valid' => $config['parentalAges'], 'default' => $config['parentalAgeDefault']), 'parentalFlags' => array('cast' => 'jsonList', 'valid' => $config['parentalFlags'])));
/*$file = $database->select(
  $queryParts['fileSelect']['columns'],
  $queryParts['fileSelect']['conditions'],
  false,
  1);
$file = $file->getAsArray(false);*/
$file = $database->getFiles(array('sha256hashes' => $request['sha256hash'] ? array($request['sha256hash']) : array(), 'md5hashes' => $request['md5hash'] ? array($request['md5hash']) : array(), 'fileIds' => $request['fileId'] ? array($request['fileId']) : array(), 'vfileIds' => $request['vfileId'] ? array($request['vfileId']) : array(), 'includeContent' => true))->getAsArray(false);
/* Start Processing */
if ($config['parentalEnabled']) {
    if (isset($request['parentalAge'])) {
        $user['parentalAge'] = $request['parentalAge'];
    }
    if (isset($request['parentalFlags'])) {
        $user['parentalFlags'] = implode(',', $request['parentalFlags']);
    }
示例#20
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
if (!defined('WEBPRO_INMOD')) {
    die;
} else {
    $request = fim_sanitizeGPC('r', array('listId' => array('cast' => 'int'), 'wordId' => array('cast' => 'int'), 'word' => array('cast' => 'string'), 'param' => array('cast' => 'string'), 'severity' => array('valid' => array('replace', 'warn', 'confirm', 'block'), 'default' => 'replace'), 'options' => array('cast' => 'int'), 'listName' => array('cast' => 'string'), 'listType' => array('valid' => array('black', 'white'), 'default' => 'white'), 'candis' => array('cast' => 'bool'), 'privdis' => array('cast' => 'bool'), 'mature' => array('cast' => 'bool')));
    if ($user['adminDefs']['modCensor']) {
        switch ($_GET['do2']) {
            case false:
            case 'viewLists':
                $lists = $database->getCensorLists(array('includeStatus' => false))->getAsArray(true);
                foreach ($lists as $list) {
                    $options = array();
                    if (!$list['options'] & 1) {
                        $options[] = "Inactive";
                    }
                    if ($list['options'] & 2) {
                        $options[] = "Disableable";
                    }
                    if ($list['options'] & 4) {
                        $options[] = "Hidden";
示例#21
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
if (!defined('WEBPRO_INMOD')) {
    die;
} else {
    $request = fim_sanitizeGPC('r', array('templateName' => array('cast' => 'string'), 'data' => array('cast' => 'string'), 'do2' => array('cast' => 'string')));
    $json = json_decode(file_get_contents('client/data/templates.json'), true);
    if ($user['adminDefs']['modTemplates']) {
        switch ($request['do2']) {
            case 'view':
            case false:
                foreach (array_keys($json) as $template) {
                    $rows .= "<tr><td>{$template}</td><td><a href=\"./moderate.php?do=templates&do2=edit&templateName={$template}\"><img src=\"./images/document-edit.png\" alt=\"Edit\" /></td></tr>";
                }
                echo container('Edit Templates', '<table class="page rowHover">
  <thead>
    <tr class="ui-widget-header">
      <td width="80%">Template</td>
      <td width="20%">Actions</td>
    </tr>
  </thead>
示例#22
0
}
$streamRequest = true;
define('FIM_EVENTSOURCE', true);
require 'global.php';
if (!$config['serverSentEvents']) {
    die('Not Supported');
} else {
    /* Send Proper Headers */
    header('Content-Type: text/event-stream');
    //  header('Content-Type: text/plain');
    header('Cache-Control: no-cache');
    // recommended to prevent caching of event data.
    set_time_limit($config['serverSentTimeLimit']);
    $serverSentRetries = 0;
    /* Get Request Data */
    $request = fim_sanitizeGPC('g', array('queryId' => array('require' => true, 'cast' => 'int', 'evaltrue' => true), 'streamType' => array('require' => true, 'valid' => array('messages', 'user', 'room')), 'lastEvent' => array('require' => false, 'default' => 0, 'cast' => 'int', 'evaltrue' => false)));
    if (isset($_SERVER['HTTP_LAST_EVENT_ID'])) {
        $request['lastEvent'] = $_SERVER['HTTP_LAST_EVENT_ID'];
        // Get the message ID used for keeping state data; e.g. 1-2-3
    }
    while ($serverSentRetries < $config['serverSentMaxRetries']) {
        $serverSentRetries++;
        switch ($request['streamType']) {
            case 'messages':
                $request['lastEvent'] = stream_messages($request['queryId'], $request['lastEvent']);
                break;
            case 'user':
                $request['lastEvent'] = stream_event('user', $request['queryId'], $request['lastEvent']);
                break;
            case 'room':
                $request['lastEvent'] = stream_event('room', $request['queryId'], $request['lastEvent']);
示例#23
0
 * the use of indexes is a must for any reliable message retrieval. As such, a standard "SELECT * WHERE roomId = xxx ORDER BY messageId DESC LIMIT 10" (the easiest way of getting the last 10 messages) is simply impossible. Instead, a few alternatives are recommended:
 ** Specify a "messageIdEnd" as the last message obtained from the room.
 * similarly, the messageLimit and messageHardLimit directives are applied for the sake of scalibility. messageHardLimit is after results have been retrieved and filtered by, say, the roomId, and messageLimit is a limit on messages retrieved from all rooms, etc.
 * a message cache is maintained, and it is the default means of obtaining messages. Specifying archive will be far slower, but is required for searching, and generally is recommended at other times as well (e.g. getting initial posts).
 *
 * -- TODO --
 * We need to use internal message boundaries via the messageIndex and messageDates table. Using these, we can approximate message dates for individual rooms. Here is how that will work:
 ** Step 1: Identify Crtiteria. If a criteria is date based (e.g. what was said in this room on this date?), we will rely on messageDates. If it is ID-based, we will rely on messageIndex.
 ** Step 2: If using date-based criteria, we lookup the approximate post ID that corresponds to the room and date. At this point, we are basically done. Simply set the messageIdStart to the date that occured before and mesageIdEnd to the date that occured after.
 ** If, however, we are using ID-based criteria, we will instead look into messageIndex. Here, we correlate room and ID, and try to find an approprimate messageIdEnd and messageIdStart.
 ** Step 3: Use a more narrow range if neccessary. The indexes we used may be too large. In this case, we need to do our best to approximate.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('roomId' => array('require' => true), 'userIds' => array('default' => '', 'cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'messageIds' => array('default' => '', 'cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'sortBy' => array('valid' => array('messageId'), 'default' => 'messageId'), 'sortOrder' => array('valid' => array('desc', 'asc'), 'default' => 'asc'), 'showDeleted' => array('default' => false, 'cast' => 'bool'), 'archive' => array('default' => false, 'cast' => 'bool'), 'noping' => array('default' => false, 'cast' => 'bool'), 'messageDateMax' => array('default' => 0, 'cast' => 'int'), 'messageDateMin' => array('default' => 0, 'cast' => 'int'), 'messageIdStart' => array('default' => 0, 'cast' => 'int'), 'messageIdEnd' => array('default' => 0, 'cast' => 'int'), 'messageLimit' => array('default' => $config['defaultMessageLimit'], 'max' => $config['maxMessageLimit'], 'min' => 1, 'cast' => 'int'), 'messageHardLimit' => array('default' => $config['defaultMessageHardLimit'], 'max' => $config['maxMessageHardLimit'], 'min' => 1, 'cast' => 'int'), 'search' => array('default' => false), 'encode' => array('default' => 'plaintext', 'valid' => array('plaintext', 'base64'))));
if ($config['longPolling'] && $request['longPolling'] === true) {
    $config['longPolling'] = true;
    $longPollingRetries = 0;
    set_time_limit(0);
    ini_set('max_execution_time', 0);
} else {
    $config['longPolling'] = false;
}
/* Get the roomdata. */
$room = $database->getRoom($request['roomId']);
/* Data Predefine */
$xmlData = array('getMessages' => array('messages' => array()));
if (!$room->id) {
    new fimError('badRoom', 'The specified room does not exist.');
} elseif (!($database->hasPermission($user, $room) & ROOM_PERMISSION_VIEW)) {
示例#24
0
/**
 * Obtains User Post Counts in Specified Rooms
 * Only works with normal rooms.
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string rooms - A comma-seperated list of room IDs to get.
 * @param int [number = 10] - The number of top posters to obtain.
*/
$apiRequest = true;
require '../global.php';
/* Get Request */
$request = fim_sanitizeGPC('g', array('rooms' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'users' => array('default' => '', 'cast' => 'jsonList', 'filter' => 'int', 'evaltrue' => true), 'number' => array('default' => 10, 'cast' => 'int')));
/* Data Predefine */
$xmlData = array('getStats' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'roomStats' => array()));
/* Start Processing */
$totalPosts = $database->getPostStats(array('roomIds' => $request['rooms']))->getAsArray(array('roomId', 'userId'), false);
//var_dump($totalPosts);
foreach ($totalPosts as $room) {
    foreach ($room as $roomId => $totalPoster) {
        if (!fim_hasPermission($totalPoster, $totalPoster, 'view', true)) {
            // Users must be able to view the room to see the respective post counts.
            continue;
        }
        if (!isset($xmlData['getStats']['roomStats']['room ' . $totalPoster['roomId']])) {
            $xmlData['getStats']['roomStats']['room ' . $totalPoster['roomId']] = array('roomData' => array('roomId' => (int) $totalPoster['roomId'], 'roomName' => $totalPoster['roomName']), 'users' => array());
        }
        $xmlData['getStats']['roomStats']['room ' . $totalPoster['roomId']]['users']['user ' . $totalPoster['userId']] = array('userData' => array('userId' => (int) $totalPoster['userId'], 'userName' => $totalPoster['userName'], 'userNameFormat' => $totalPoster['userNameFormat']), 'messageCount' => (int) $totalPoster['messages']);
示例#25
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
if (!defined('WEBPRO_INMOD')) {
    die;
} else {
    $request = fim_sanitizeGPC('r', array('do2' => array('cast' => 'string'), 'data' => array('cast' => 'string'), 'languageCode' => array('cast' => 'string'), 'phraseName' => array('cast' => 'string')));
    $config = json_decode(file_get_contents('client/data/config.json'), true);
    if ($user['adminDefs']['modTemplates']) {
        switch ($request['do2']) {
            case 'lang':
            case false:
                foreach ($config['languages'] as $code => $language) {
                    $languageLinks .= "<a href=\"moderate.php?do=phrases&do2=view&languageCode={$code}\">{$language}</a><br />";
                }
                echo container('Choose a Language', $languageLinks);
                break;
            case 'view':
                $phrases = json_decode(file_get_contents('client/data/language_' . $request['languageCode'] . '.json'), true);
                foreach ($phrases as $phrase => $text) {
                    if (strlen($text) > 80) {
                        $text = substr($text, 0, 77) . '...';
示例#26
0
 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Obtains One or More User's Uploads
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 *
 * @param string users - A comma-seperated list of user IDs to get.
*/
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('users' => array('default' => array($user['userId']), 'cast' => 'csv', 'filter' => 'int', 'evaltrue' => true)));
/* Data Pre-Define */
$xmlData['getFiles'] = array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'errDesc' => $errDesc, 'files' => array());
/* Get Uploads from Database */
$files = $database->getFiles(array('userIds' => $request['users']))->getAsArray('fileId');
/* Start Processing */
foreach ($files as $file) {
    // Only show if the user has permission.
    if ($file['roomIdLink'] && $file['userId'] != $user['userId']) {
        /* TODO: Test */
        if (!fim_hasPermission($database->getRoom($file['roomIdLink']), $user, 'view', true)) {
            continue;
        }
    }
    $xmlData['getFiles']['files']['file ' . $file['fileId']] = array('fileSize' => (int) $file['size'], 'fileSizeFormatted' => fim_formatSize($file['size']), 'fileName' => $file['fileName'], 'mime' => $file['mime'], 'parentalAge' => $file['fileParentalAge'], 'parentalFlags' => explode(',', $file['fileParentalFlags']), 'md5hash' => $file['md5hash'], 'sha256hash' => $file['sha256hash']);
}
示例#27
0
 * This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
if (!defined('WEBPRO_INMOD')) {
    die;
} else {
    $request = fim_sanitizeGPC('r', array('do2' => array('cast' => 'string')));
    if ($user['adminDefs']['modPrivs']) {
        switch ($request['do2']) {
            case 'view':
            case false:
                $users = $database->getUsers(array('hasAdminPrivs' => array(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192)))->getAsArray('userId');
                foreach ($users as $user2) {
                    $adminPrivs = array();
                    if ($user2['adminPrivs'] & ADMIN_GRANT) {
                        $adminPrivs[] = 'Grant';
                    }
                    if ($user2['adminPrivs'] & ADMIN_PROTECTED) {
                        $adminPrivs[] = '<abbr title="This user cannot be altered by any user other than themself and the site owner.">Protected</abbr>';
                    }
                    if ($user2['adminPrivs'] & ADMIN_ROOMS) {
                        $adminPrivs[] = 'Global Room Moderator';
示例#28
0
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
/**
 * Get Rooms from the Server
 *
 * @package fim3
 * @version 3.0
 * @author Jospeph T. Parsons <*****@*****.**>
 * @copyright Joseph T. Parsons 2014
 * @param string [listIds] - If specified, only specific room lists are listed. By default, all of the user's roomLists are listed.
 */
$apiRequest = true;
require '../global.php';
/* Get Request Data */
$request = fim_sanitizeGPC('g', array('listIds' => array('default' => '', 'cast' => 'csv', 'filter' => 'int', 'evaltrue' => true), 'permissionCheck' => array('cast' => 'bool')));
/* Data Predefine */
$xmlData = array('getRoomLists' => array('activeUser' => array('userId' => (int) $user['userId'], 'userName' => $user['userName']), 'errStr' => $errStr, 'roomLists' => array()));
/* Query */
$roomLists = $database->getRoomLists($user, $request['roomLists'])->getAsArray(true);
/* Process Room Lists Obtained from Database */
foreach ($roomLists as $roomList) {
    $xmlData['getRoomLists']['roomLists'][$roomList['listId']][] = $roomList['roomId'];
}
/* Errors */
$xmlData['getRooms']['errStr'] = $errStr;
/* Output Data Structure */
echo fim_outputApi($xmlData);