Exemple #1
0
 function checkPwd()
 {
     if (!isset($_POST['password'][2])) {
         return LANG('Password must be at least 3 charaters long');
     }
     if ($_POST['password'] !== $_POST['retype']) {
         return LANG('Password retype doesn\'t match');
     }
     $p = password($_POST['password']);
     $u = user('id');
     data_save("user/{$u}/pwd", $p);
     return false;
 }
Exemple #2
0
 function chkRegister()
 {
     if (!preg_match('/^[0-9a-zA-Z_]+$/', $_POST['username'])) {
         return LANG('Username must only contain English alphabets, underscore and numbers');
     }
     $u = $_POST['username'];
     if (data_exists("user/{$u}/pwd")) {
         return LANG('User exists');
     }
     if (!isset($_POST['password'][2])) {
         return LANG('Password must be at least 3 charaters long');
     }
     if ($_POST['password'] != $_POST['retype']) {
         return LANG('Password retype doesn\'t match');
     }
     $p = password($_POST['password']);
     data_save("user/{$u}/pwd", $p);
     $_SESSION[USER_SESSION] = $u;
 }
Exemple #3
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);
}
 function data_save_media($media_data = array(), $userid = '', $config = array())
 {
     $err = '';
     if (!$err) {
         $type = empty($media_data['type']) ? '' : $media_data['type'];
         if (!$type) {
             $err = 'media must contain type key';
         }
     }
     if (!$err) {
         $err = data_save($type, $media_data, $userid, $config);
     }
     return $err;
 }
Exemple #5
0
        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), '');
        }
    }
    data_save($dataF, json_encode($data));
    sync_end();
    header('location: ticket?id=' . $ticketID);
    die;
}
if (isset($_GET['list'])) {
    $list = data_list('ticket', 't_');
    $list = array_reverse($list);
    $max = $_GET['list'] * 1;
    if (!$max) {
        $max = 0x7ffffffffffff;
    }
    $c = 0;
    $ret = array();
    foreach ($list as $k => &$v) {
        $v *= 1;
Exemple #6
0
        } else {
            $o = array();
        }
        $c = iescape($_POST['content']);
        $lines = explode("\n", $c);
        $t = $lines[0];
        unset($lines[0]);
        $c = implode('</br>', $lines);
        $o[] = array('title' => $t, 'content' => $c, 'user' => user('id'));
        data_save($dataitem, json_encode($o));
        post_status(LANG('modify the calendar at %%', $_POST['date']));
    }
} elseif ($_GET['action'] == 'delete') {
    if (user() && user('verified') && posted('date', 'key')) {
        $dataitem = 'calendar/' . $_POST['date'];
        if (data_exists($dataitem)) {
            $o = json_decode(data_read($dataitem), true);
        } else {
            $o = array();
        }
        if (isset($o[$_POST['key']])) {
            unset($o[$_POST['key']]);
        }
        if (count($o) <= 0) {
            data_remove($dataitem);
        } else {
            data_save($dataitem, json_encode($o));
        }
        post_status(LANG('modify the calendar at %%', $_POST['date']));
    }
}
Exemple #7
0
<?php

if (user() && user('verified') && posted('content')) {
    data_save('announcement', $_POST['content']);
}
Exemple #8
0
    die;
}
/********************
 * Upload attachment
 ********************/
if (isset($_GET['upload']) && user('verified')) {
    $xdata = json_decode($_SERVER['HTTP_X_DATA'], true);
    $id = $_GET['upload'];
    sync_begin();
    if (data_exists("wiki/{$query}/attachments")) {
        $odata = json_decode(data_read("wiki/{$query}/attachments"), true);
    } else {
        $odata = array();
    }
    $odata[$id] = array('name' => urldecode($xdata['name']), 'size' => $xdata['size']);
    data_save("wiki/{$query}/attachments", json_encode($odata));
    sync_end();
    file_put_contents("data/wiki/{$query}/att_{$id}", file_get_contents('php://input'));
    die;
}
/*****************
 * Get Attachment
 *****************/
if (isset($_GET['x'])) {
    $id = $_GET['x'];
    while ($id[0] == '/') {
        $id = substr($id, 1);
    }
    $odata = json_decode(data_read("wiki/{$query}/attachments"), true);
    if (isset($odata[$id])) {
        $att = $odata[$id];
Exemple #9
0
if (isset($_GET['chron'])) {
    $t = time();
    header('Content-type:text/plain; charset=utf-8');
    foreach ($data as &$item) {
        if ($item['last'] * 1 + $item['interval'] * 1 < $t) {
            echo $item['url'] . "\n";
            $item['last'] = $t;
        }
    }
    data_save('chron', json_encode($data));
    sync_end();
    die;
}
if ($edit) {
    if ($add) {
        $ndata = array('url' => trim($_POST['url']), 'interval' => isset($_POST['interval']) ? $_POST['interval'] * 10 : 10, 'last' => time());
        if ($ndata['interval'] < 10) {
            $ndata['interval'] = 10;
        }
        $data[time() . rand(100, 999)] = $ndata;
    } else {
        if ($delete) {
            unset($data[$_GET['delete']]);
        }
    }
    data_save('chron', json_encode($data));
    sync_end();
    redirect('dev');
    die;
}
die(tpl('dev', array('chron' => $data)));