Example #1
0
 function chkLogin()
 {
     $u = $_POST['username'];
     if (!data_exists("user/{$u}/pwd")) {
         return LANG('No such user');
     }
     $p = password($_POST['password']);
     if ($p != data_read("user/{$u}/pwd")) {
         return LANG('Password wrong');
     }
     $_SESSION[USER_SESSION] = $u;
     return false;
 }
Example #2
0
function list_status($start = NULL, $limit = 50)
{
    $last = last_post_id();
    if ($limit > 0) {
        if (!$start) {
            $start = $last + 1;
        }
        $step = -1;
    } else {
        $limit = -$limit;
        if (!$start) {
            $start = $last - $limit;
        }
        if ($start < 0) {
            $start = 0;
        }
        $n = $last - $start;
        if ($limit > $n) {
            $limit = $n;
        }
        $step = 1;
    }
    $start += $step;
    $ret = array();
    $id = $start;
    while ($limit > 0 && $id > 0 && $id <= $last) {
        if (data_exists("status/post_{$id}")) {
            $item = json_decode(data_read("status/post_{$id}"), true);
            $item['id'] = $id;
            $item['type_lang'] = LANG($item['type']);
            $item['human_time'] = human_time($item['date']);
            $ret[] = $item;
            $limit--;
        }
        $id += $step;
    }
    if ($step > 0) {
        $ret = array_reverse($ret);
    }
    return $ret;
}
Example #3
0
<?php

$data = array();
$data['list'] = array();
$list =& $data['list'];
foreach (data_list('user') as $k => $v) {
    if (data_exists($k . '/info')) {
        $item = json_decode(data_read($k . '/info'), true);
        if (file_exists("data/user/{$v}/avatar.jpg")) {
            $item['avatar'] = BASE . "data/user/{$v}/avatar.jpg";
        } else {
            $item['avatar'] = BASE . 'res/images/default-avatar.jpg';
        }
        $item['o'] = iconv('utf-8', 'gbk', $item['name']);
        $list[] = $item;
    }
}
function sortFunc($a, $b)
{
    return strcmp($b['o'], $a['o']);
}
usort($list, 'sortFunc');
die(tpl('team', $data));
Example #4
0
        $item = json_decode(data_read($k), true);
        $item['content'] = $item['content'][0];
        $item['id'] = $v;
        $ret[] = $item;
        $c++;
        if ($c >= 10) {
            break;
        }
    }
    die(json_encode($ret));
} elseif (isset($_POST['rmtag'])) {
    data_remove('ticket/tag/' . base64_encode($_POST['rmtag']));
    die;
} elseif (isset($_GET['id'])) {
    if (!data_exists('ticket/t_' . $_GET['id'])) {
        die(tpl('404', array('hehe' => '123')));
    }
    $tags = data_list('ticket/tag');
    foreach ($tags as &$v) {
        $v = base64_decode($v);
    }
    $item = json_decode(data_read('ticket/t_' . $_GET['id']), true);
    $item['id'] = $_GET['id'];
    die(tpl('show-ticket', array('tags' => $tags, 'ticket' => $item)));
} else {
    $tags = data_list('ticket/tag');
    foreach ($tags as &$v) {
        $v = base64_decode($v);
    }
    die(tpl('ticket', array('tags' => $tags)));
}
Example #5
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']));
    }
}
Example #6
0
    $days[] = array('year' => $prevyear, 'month' => $prevmonth, 'day' => $prevlastday - $i + 1);
}
for ($i = 1; $i <= $lastday; $i++) {
    $days[] = array('active' => true, 'year' => $year, 'month' => $month, 'day' => $i);
}
$j = 1;
for ($i = count($days); $i < 42; $i++) {
    $days[] = array('year' => $nextyear, 'month' => $nextmonth, 'day' => $j++);
}
$ny = date('Y', time()) * 1;
$nm = date('m', time()) * 1;
$nd = date('d', time()) * 1;
foreach ($days as &$day) {
    $y = $day['year'];
    $m = $day['month'];
    $d = $day['day'];
    if ($y == $ny && $m == $nm && $d == $nd) {
        $day['istoday'] = true;
    }
    if (data_exists("calendar/{$y}-{$m}-{$d}")) {
        $day['mark'] = json_decode(data_read("calendar/{$y}-{$m}-{$d}"), true);
    }
}
$ret['days'] = $days;
$ret['year'] = $year;
$ret['month'] = $month;
$ret['prevyear'] = $prevyear;
$ret['prevmonth'] = $prevmonth;
$ret['nextyear'] = $nextyear;
$ret['nextmonth'] = $nextmonth;
die(json_encode($ret));
Example #7
0
}
if (isset($qpath)) {
    if (isset($qpath[1])) {
        unset($qpath[count($qpath) - 1]);
        $parent = implode('/', $qpath);
    } else {
        $parent = '';
    }
    $index = data_list("wiki/{$parent}", 'wiki_');
    foreach ($index as $k => &$v) {
        $v = array('path' => substr(str_replace('/wiki_', '/', $k), 5), 'name' => $v, 'child' => array(), 'active' => false);
        if ($v['path'] == $pquery) {
            $v['child'] = $childs;
            $v['active'] = true;
        }
    }
    if (isset($parent[0])) {
        $name = substr($qpath[count($qpath) - 1], 5);
        $index = array(array('path' => substr(str_replace('/wiki_', '/', $parent), 5), 'name' => $name, 'child' => $index, 'active' => false));
    }
} else {
    $index = $childs;
}
$content = data_read("wiki/{$query}/content");
if (!user('verified')) {
    $content = preg_replace('/\\{\\{\\{.*?\\}\\}\\}/s', '<span class="verified-only">' . LANG('Visible to verified user only') . '</span>', $content);
} elseif (!isset($_GET['edit'])) {
    $content = preg_replace('/\\{\\{\\{(.*?)\\}\\}\\}/s', '$1', $content);
}
$data = array('query' => $pquery, 'title' => $title, 'path' => $path, 'index' => $index, 'content' => $content, 'isedit' => isset($_GET['edit']), 'attachments' => json_decode(data_read("wiki/{$query}/attachments"), true));
die(tpl('wiki', $data));
Example #8
0
function getUser($u)
{
    if (data_exists("user/{$u}/pwd")) {
        $id = $u;
        if (!data_exists("user/{$u}/info")) {
            $u = array('name' => $u, 'title' => LANG('Unidentified'), 'verified' => false);
        } else {
            $u = json_decode(data_read("user/{$u}/info"), true);
        }
        $u['id'] = $id;
        if (file_exists("data/user/{$id}/avatar.jpg")) {
            $u['avatar'] = BASE . "data/user/{$id}/avatar.jpg";
        } else {
            $u['avatar'] = BASE . 'res/images/default-avatar.jpg';
        }
        return $u;
    }
    return NULL;
}
Example #9
0
<?php

$add = isset($_POST['url']) && trim($_POST['url']);
$delete = isset($_GET['delete']);
$edit = isset($_GET['chron']) || user('verified') && ($add || $delete);
if ($edit) {
    sync_begin();
}
$data = json_decode(data_read('chron'), true);
if (!$data || !is_array($data)) {
    $data = array();
}
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;
        }