Exemple #1
0
<?php

require_once __DIR__ . '/core.php';
$roomlist = Onset::getRoomlist();
$i = 0;
foreach ($roomlist as $room => $data) {
    $dir = RoomSavepath . $data->path . "/";
    $leftTime = filemtime($dir);
    if (time() - $leftTime > RoomDelTime) {
        try {
            Onset::removeRoomData($dir);
            unset($roomlist->{$room});
            if (!Onset::saveRoomlist($roomlist)) {
                throw new Exception("部屋インデックスデータの保存に失敗しました");
            }
        } catch (Exception $e) {
            echo Onset::jsonMessage($e->getMessage(), -1);
            die;
        }
        $i += 1;
    }
}
echo $i > 0 ? Onset::jsonMessage($i . '部屋削除しました') : Onset::jsonMessage('ok');
Exemple #2
0
<?php

require_once __DIR__ . '/core.php';
session_start();
try {
    if ($_POST['rand'] != $_SESSION['onset_rand']) {
        throw new Exception('不正なアクセス。');
    }
    $room = Onset::varidate($_POST['room']);
    $pass = Onset::varidate($_POST['pass']);
    if ($room === false || $pass === false) {
        throw new Exception('ルーム名かパスワードがセットされていません');
    }
    $room = htmlspecialchars($room, ENT_QUOTES);
    $roomlist = Onset::getRoomlist();
    if (!isset($roomlist->{$room})) {
        throw new Exception('部屋が存在しません');
    }
    $roompath = $roomlist->{$room}->path;
    Onset::removeRoomData(RoomSavepath . $roompath . "/");
    unset($roomlist->{$room});
    if (!Onset::saveRoomlist($roomlist)) {
        throw new Exception('部屋インデックスデータの保存に失敗しました');
    }
} catch (Exception $e) {
    echo Onset::jsonMessage($e->getMessage(), -1);
    die;
}
echo Onset::jsonMessage('ok');