Exemple #1
0
    static function checkGameDates(&$message)
    {
        if (APIHelpers::$FHQSESSION != NULL) {
            if (!isset(APIHelpers::$FHQSESSION['game'])) {
                $message = 'Select game please';
                return false;
            }
        } else {
            if (!isset($_SESSION['game'])) {
                $message = 'Select game please';
                return false;
            }
        }
        if (APISecurity::isAdmin() || APISecurity::isTester()) {
            return true;
        }
        $date_start = new DateTime();
        date_timestamp_set($date_start, strtotime($_SESSION['game']['date_start']));
        $date_stop = new DateTime();
        date_timestamp_set($date_stop, strtotime($_SESSION['game']['date_stop']));
        $date_restart = new DateTime();
        date_timestamp_set($date_restart, strtotime($_SESSION['game']['date_restart']));
        $date_current = new DateTime();
        date_timestamp_set($date_current, time());
        $di_start = $date_current->diff($date_start);
        $di_stop = $date_current->diff($date_stop);
        $di_restart = $date_current->diff($date_restart);
        $bWillBeStarted = $di_start->invert == 0;
        $bWillBeRestarted = $di_stop->invert == 1 && $di_restart->invert == 0;
        // echo date_diff($date_current, $date_start)."<br>";
        if ($bWillBeStarted || $bWillBeRestarted) {
            $label = $bWillBeStarted ? 'Game will be started after: ' : 'Game will be restarted after: ';
            $di = $bWillBeStarted ? $di_start : $di_restart;
            $message = $label . '<br>
				<div class="fhq_timer" id="days">' . $di->d . '</div> day(s) 
				<div class="fhq_timer" id="hours">' . $di->h . '</div> hour(s) 
				<div class="fhq_timer" id="minutes">' . $di->i . '</div> minute(s)
				<div class="fhq_timer" id="seconds">' . $di->s . '</div> second(s)<br>
				<div id="reload_content" onclick="startTimer();"/></div> <br><br>
			';
            return false;
        }
        return true;
    }
Exemple #2
0
include_once $curdir_users_get . "/../api.lib/api.base.php";
include_once $curdir_users_get . "/../api.lib/api.game.php";
include_once $curdir_users_get . "/../../config/config.php";
$response = APIHelpers::startpage($config);
APIHelpers::checkAuth();
$response['profile'] = array();
$response['access'] = array();
$conn = APIHelpers::createConnection($config);
/*if (!APIHelpers::issetParam('userid'))
	APIHelpers::showerror(1177, 'Not found parameter userid');*/
$userid = APIHelpers::getParam('userid', APISecurity::userid());
if (!is_numeric($userid)) {
    APIHelpers::showerror(1181, 'Parameter userid must be integer');
}
$userid = intval($userid);
$bAllow = APISecurity::isAdmin() || APISecurity::isTester() || APISecurity::userid() == $userid;
$response['access']['edit'] = $bAllow;
$response['currentUser'] = APISecurity::userid() == $userid;
$columns = array('id', 'email', 'dt_last_login', 'uuid', 'status', 'role', 'nick', 'logo');
$query = '
		SELECT ' . implode(', ', $columns) . ' FROM
			users
		WHERE id = ?
';
$result['userid'] = $userid;
// $result['query'] = $query;
try {
    $stmt = $conn->prepare($query);
    $stmt->execute(array($userid));
    if ($row = $stmt->fetch()) {
        $response['data']['userid'] = $row['id'];