Example #1
0
function post_status($content, $type = 'did', $escape = true)
{
    if (!user()) {
        return;
    }
    if ($escape) {
        $content = iescape($content, true);
    }
    $uid = user('id');
    if ($type == 'did') {
        $c = md5($content);
        if ($c == data_read("user/{$uid}/lastdid")) {
            return;
        }
        data_save("user/{$uid}/lastdid", $c);
    }
    $data = array('user' => $uid, 'date' => time(), 'type' => $type, 'content' => $content);
    $data = json_encode($data);
    sync_begin();
    $id = last_post_id() + 1;
    data_save('status/id', $id);
    sync_end();
    data_save("status/post_{$id}", $data);
}
Example #2
0
<?php

if (isset($_POST['ticket']) || isset($_POST['tag'])) {
    if (!user()) {
        header('location: login');
        die;
    }
    sync_begin();
    $ticketID = isset($_POST['id']) ? 1 * $_POST['id'] : time() . rand(10, 99);
    $dataF = 'ticket/t_' . $ticketID;
    if (data_exists($dataF)) {
        $data = json_decode(data_read($dataF), true);
    } else {
        $data = array('user' => user('id'), 'type' => $_POST['type'], 'tag' => array(), 'status' => 'pending', 'content' => array());
    }
    if (isset($_POST['ticket'])) {
        $data['content'][] = array('user' => user('id'), 'time' => time(), 'text' => $_POST['ticket']);
        if (isset($_POST['status'])) {
            $data['status'] = $_POST['status'];
        }
    }
    if (isset($_POST['tag'])) {
        $data['tag'] = array();
        foreach (preg_split('/\\s+/', $_POST['tag']) as $t) {
            if (!$t) {
                continue;
            }
            $t = strtolower($t);
            $data['tag'][] = $t;
            data_save('ticket/tag/' . base64_encode($t), '');
        }