Exemplo n.º 1
0
    foreach ($statuses->data as $status) {
        if ($lastid == -1) {
            $lastid = $__server_time - $status->seconds_since;
        }
        //$status->id;
        $firstid = $__server_time - $status->seconds_since;
        //$status->id;
        $status->PrintAsHTML('');
    }
    $data = ob_get_clean();
    if ($data === false) {
        JSONDie('No data returned', 204);
    }
    JSONAnswer(array('result' => $data, 'lastid' => $lastid, 'firstid' => $firstid, 'amount' => count($statuses->data)));
} elseif ($request_type == 'delete') {
    RetrieveInputGET('id');
    // Removing status
    $id = intval($P['id']);
    $__database->query("DELETE FROM social_statuses WHERE id = " . $id . ($_loginaccount->IsRankOrHigher(RANK_MODERATOR) ? '' : ' AND account_id = ' . $_loginaccount->GetId()));
    if ($__database->affected_rows == 1) {
        JSONAnswer(array('result' => 'The status was successfully deleted.'));
    } else {
        JSONDie('Unable to delete the status.');
    }
} elseif ($request_type == 'post') {
    if (!$_loggedin) {
        JSONDie('Not loggedin', 401);
    }
    RetrieveInputPOST('content', 'reply-to', 'usingface');
    $content = nl2br(htmlentities(trim($P['content']), ENT_QUOTES, 'UTF-8'));
    //Tweet post yo.
Exemplo n.º 2
0
if ($request_type == 'visibility') {
    if (!$_loggedin) {
        JSONDie('Not loggedin');
    }
    RetrieveInputGET('name', 'what', 'shown');
    $internalid = IsOwnCharacter($P['name'], CURRENT_LOCALE);
    if ($internalid === false) {
        JSONDie('No.');
    }
    $q = $_char_db->query("\nINSERT INTO\n\tcharacter_options\nVALUES\n\t(\n\t\t" . $internalid . ",\n\t\t'display_" . $_char_db->real_escape_string($P['what']) . "',\n\t\t" . ($P['shown'] == 'false' ? 0 : 1) . "\n\t)\nON DUPLICATE KEY UPDATE\n\t`option_value` = VALUES(`option_value`)");
    if ($_char_db->affected_rows != 0) {
        JSONAnswer(array('result' => 'okay'));
    } else {
        JSONAnswer(array('result' => 'failure'));
    }
} elseif ($request_type == 'statistics') {
    RetrieveInputGET('name');
    $q = $_char_db->query("\nSELECT \n\tchr.name,\n\tw.world_name,\n\tchr.channel_id AS channel,\n\tchr.level,\n\tchr.job,\n\tchr.fame,\n\tchr.str,\n\tchr.dex,\n\tchr.int,\n\tchr.luk,\n\tchr.exp,\n\tchr.map,\n\tchr.honourlevel AS honorlevel,\n\tchr.honourexp AS honorexp,\n\tmesos,\n\tTIMESTAMPDIFF(SECOND, last_update, NOW()) AS `seconds_since`\nFROM\n\t`characters` chr\nLEFT JOIN \n\tworld_data w\n\tON\n\t\tw.world_id = chr.world_id\nWHERE \n\tchr.name = '" . $_char_db->real_escape_string($P['name']) . "'");
    if ($q->num_rows == 0) {
        JSONDie('Character not found', 404);
    }
    $row = $q->fetch_assoc();
    $percenta = GetExpPercentage($row['level'], $row['exp']);
    $percentb = round($percenta * 100) / 100;
    $job = GetJobname($row['job']);
    $map = GetMapname($row['map'], CURRENT_LOCALE);
    $extra = array('percentage' => $percentb, 'job_name' => $job, 'map_name' => $map);
    $answer = $row + $extra;
    $q->free();
    JSONAnswer(array('result' => $answer));
}