本文整理汇总了PHP中Chat::getUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::getUsers方法的具体用法?PHP Chat::getUsers怎么用?PHP Chat::getUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::getUsers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$response = array();
// Handling the supported actions:
switch ($_GET['action']) {
case 'login':
$response = Chat::login($_POST['name'], $_POST['email']);
break;
case 'checkLogged':
$response = Chat::checkLogged();
break;
case 'logout':
$response = Chat::logout();
break;
case 'submitChat':
$response = Chat::submitChat($_POST['chatText']);
break;
case 'getUsers':
$response = Chat::getUsers();
break;
case 'getChats':
$response = Chat::getChats($_GET['lastID']);
break;
default:
throw new Exception('Wrong action');
}
echo json_encode($response);
} catch (Exception $e) {
die(json_encode(array('error' => $e->getMessage())));
}
?>
示例2: time
$userdata = $auth->getUserDataById($_COOKIE['id']);
if ($userdata['hash'] !== $_COOKIE['hash'] or $userdata['id'] !== $_COOKIE['id']) {
/* setcookie("id", "", time() - 3600*24*30*12, "/");
setcookie("hash", "", time() - 3600*24*30*12, "/");
print "Хм, что-то не получилось";*/
// header("Location: {ROOT_PATH} login.php"); exit();
include $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'chat/auth/login.php';
exit;
} else {
// require_once '../PHP/vendor/twig/twig/lib/Twig/Autoloader.php';
// require_once '..\PHP\Twig-1.23.3\lib\Twig\Autoloader.php';
include_once $TWIG_AUTOLOADER_PATH;
include_once "UserEvents.class.php";
$userEvents = new UserEvents();
$userEvents->deleteEvent($userdata['id']);
Twig_Autoloader::register();
// указываем где хранятся шаблоны
$loader = new Twig_Loader_Filesystem('templates');
// инициализируем Twig
$twig = new Twig_Environment($loader);
// подгружаем шаблон
$template = $twig->loadTemplate('main.tmpl');
$chat = new Chat();
$users = $chat->getUsers($userdata['id']);
$context = array("users" => $users, "userName" => $userdata["name"], "avatarUrl" => $userdata["avatar_url"]);
echo $template->render($context);
}
} else {
header('Location: /chat/auth/login.php');
}
示例3: Chat
<?php
include 'chat.class.php';
$action = $_POST['action'];
if (!isset($action)) {
echo "Params are not setted";
exit;
}
//test2
// $mysqli = $mysqli = new mysqli("mysql.main-hosting.com", "u277145571_admin", "pass_word", "u277145571_db");
// $mysqli = new mysqli($hostName, "root", "pass_word", "dev_schema");
// test xxx
$chat = new Chat();
if ($action == "getUsers") {
// $users = getUsers();
$users = $chat->getUsers();
echo json_encode($users);
} else {
$fromUser = $_POST['fromUser'];
$toUser = $_POST['toUser'];
if (!(isset($fromUser) and isset($toUser))) {
echo "Params are not setted";
exit;
}
}
switch ($action) {
case "getHistory":
if (isset($_POST['historyPageIndex'])) {
$historyPageIndex = $_POST['historyPageIndex'];
$history = $chat->getHistory($fromUser, $toUser, $historyPageIndex);
} else {
$history = $chat->getHistory($fromUser, $toUser);
示例4: Chat
<?php
require_once "chat.class.php";
$chat = new Chat();
if (isset($_POST['json_requestUser'])) {
$chat->CreateTable();
//$json_decode = json_decode($_POST['json_requestNewMessages']);
//$id = $json_decode->id;
}
if (ob_get_length()) {
ob_clean();
}
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/xml');
echo $chat->getUsers();
示例5: array
$new_files = $chat->getNewFiles();
if (is_array($new_files)) {
$generated_files = array();
foreach ($new_files as $new_file) {
$blocks = array();
foreach ($new_file as $k => $v) {
$blocks[] = $k . ' : ' . var_export($v, true);
}
// foreach
$generated_files[] = $new_file['id'] . ' : { ' . implode(",\n", $blocks) . '}';
}
// foreach
print 'App.Chat.refresh_files({' . implode(",\n", $generated_files) . "});";
}
// if
// Print new users commands if any
$new_users = $chat->getUsers();
if (is_array($new_users)) {
$generated_users = array();
foreach ($new_users as $new_user) {
$blocks = array();
foreach ($new_user as $k => $v) {
$blocks[] = $k . ' : ' . var_export($v, true);
}
// foreach
$generated_users[] = $new_user['id'] . ' : { ' . implode(",\n", $blocks) . '}';
}
// foreach
print 'App.Chat.refresh_users({' . implode(",\n", $generated_users) . "});";
}
// if