當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseManager::makeRoom方法代碼示例

本文整理匯總了PHP中DatabaseManager::makeRoom方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseManager::makeRoom方法的具體用法?PHP DatabaseManager::makeRoom怎麽用?PHP DatabaseManager::makeRoom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DatabaseManager的用法示例。


在下文中一共展示了DatabaseManager::makeRoom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fail

require_once '../autoload.php';
$user = Auth::user();
if (count($_GET) === 0 or !(isset($_GET['name']) && isset($_GET['description']))) {
    // header("Location: ".$config['app_link']);
} else {
    $name = $_GET['name'];
    $description = $_GET['description'];
    $password = $_GET['password'];
    if (stristr($description, "<") or stristr($description, "/>")) {
        fail("< and > are disallowed for security reasons.");
    }
    if (stristr($name, "<") or stristr($name, "/>")) {
        fail("< and > are disallowed for security reasons.");
    }
    $clean_name = strtolower(str_replace(" ", "-", preg_replace("/[^0-9a-zA-Z ]/", "", $name)));
    if (strlen($clean_name) > 30) {
        fail("Room name is too long.");
    }
    if (strlen($clean_name) < 3) {
        fail("Room name is too short.");
    }
    $dbManager = new DatabaseManager();
    if ($dbManager->getRoom($clean_name)) {
        fail("A room by that name already exists.");
    }
    if (count($rooms = $dbManager->getRoomsOwnedBy($user->id())) > 0) {
        fail("There is currently a limit of one room per account. You can see or delete your room <a href=\"javascript:joinRoom('" . $rooms[0]->id . "')\">here</a>.");
    }
    $dbManager->makeRoom($clean_name, $name, $description, $user->id(), $password);
    echo $_GET['callback'] . "(" . json_encode(array('success' => true, 'room_id' => $clean_name)) . ")";
}
開發者ID:williamtdr,項目名稱:totem-api,代碼行數:31,代碼來源:create.php


注:本文中的DatabaseManager::makeRoom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。