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); }
$uid = user('id'); if ($_FILES['avatar']['size'] > 0) { import('model/imgutil.php'); make_thumb($_FILES['avatar']['tmp_name'], "data/user/{$uid}/avatar.jpg", 90, 90); } global $_USER; $user = $_USER; unset($user['avatar']); unset($user['id']); $uname = trim($_POST['realname']); if (isset($uname[0])) { $user['name'] = iescape($uname); } $utitle = trim($_POST['title']); if ($user['verified'] && isset($utitle[0])) { $user['title'] = iescape($utitle); } data_save("user/{$uid}/info", json_encode($user)); redirect('/settings'); } elseif ($_GET['action'] == 'password') { 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);
<?php import('model/status.php'); if ($_GET['action'] == 'add') { if (user() && user('verified') && posted('date', 'content')) { $dataitem = 'calendar/' . $_POST['date']; if (data_exists($dataitem)) { $o = json_decode(data_read($dataitem), true); } 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']]); }