function runtime_append($k, $v) { $arr = kv_get('runtime_append'); empty($arr) and $arr = array(); $arr[$k] = $v; kv_set('runtime_append', $arr); }
function badword_filter($s, &$badword) { global $conf; if (!$conf['badword_on'] || !$s) { return $s; } static $badwords = NULL; if ($badwords === NULL) { $badwords = (array) kv_get('badwords'); } foreach ($badwords as $k => $v) { if (strpos($s, $k) !== FALSE) { if (isset($v)) { $badword = $k; if ($v == '#') { return FALSE; } $s = str_replace($k, $v, $s); } else { $s = str_replace($k, '', $s); } } } return $s; }
function qq_login_link($return_url) { $qqlogin = kv_get('qq_login'); $appid = $qqlogin['appid']; $appkey = $qqlogin['appkey']; $return_url = urlencode($return_url); $scope = "get_user_info,add_share,list_album,add_album,upload_pic,add_topic,add_one_blog,add_weibo"; $state = md5(uniqid(rand(), TRUE)); //CSRF protection $login_url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id={$appid}&redirect_uri={$return_url}&state={$state}&scope={$scope}"; return $login_url; }
function get_last_version($stat) { global $conf, $time; $last_version = kv_get('last_version'); if ($time - $last_version > 86400) { kv_set('last_version', $time); $sitename = urlencode($conf['sitename']); $sitedomain = urlencode(http_url_path()); $version = urlencode($conf['version']); return '<script src="http://custom.xiuno.com/version.htm?sitename=' . $sitename . '&sitedomain=' . $sitedomain . '&users=' . $stat['users'] . '&threads=' . $stat['threads'] . '&posts=' . $stat['posts'] . '&version=' . $version . '"></script>'; } else { return ''; } }
// 应用的名称 define('APP_PATH', '../../'); // 应用的路径 chdir(APP_PATH); $conf = (include './conf/conf.php'); include './xiunophp/xiunophp.php'; include './xiunophp/form.func.php'; include './model.inc.php'; $user = user_token_get('', 'bbs'); $user['gid'] != 1 and message(-1, '需要管理员权限才能设置。'); // 检测浏览器 $browser = get__browser(); check_browser($browser); $runtime = runtime_init(); if ($method == 'GET') { $sphinx = kv_get('sphinx'); !isset($sphinx['enable']) && ($sphinx['enable'] = 0); !isset($sphinx['sphinx_host']) && ($sphinx['sphinx_host'] = ''); !isset($sphinx['sphinx_port']) && ($sphinx['sphinx_port'] = ''); !isset($sphinx['sphinx_datasrc']) && ($sphinx['sphinx_datasrc'] = ''); !isset($sphinx['sphinx_deltasrc']) && ($sphinx['sphinx_deltasrc'] = ''); $input['enable'] = form_radio_yes_no('enable', $sphinx['enable']); $input['sphinx_host'] = form_text('sphinx_host', $sphinx['sphinx_host'], 300); $input['sphinx_port'] = form_text('sphinx_port', $sphinx['sphinx_port'], 100); $input['sphinx_datasrc'] = form_text('sphinx_datasrc', $sphinx['sphinx_datasrc'], 300); $input['sphinx_deltasrc'] = form_text('sphinx_deltasrc', $sphinx['sphinx_deltasrc'], 300); $header = array(); $header['title'] = 'Sphinx 搜索服务设置'; include './plugin/xn_sphinx/setting.htm'; } else { $enable = param('enable', 0);
define('APP_PATH', '../../'); // 应用的路径 chdir(APP_PATH); $conf = (include './conf/conf.php'); include './xiunophp/xiunophp.php'; include './xiunophp/form.func.php'; include './model.inc.php'; include './plugin/xn_qq_login/qq_login.func.php'; $user = user_token_get('', 'bbs'); $user['gid'] != 1 and message(-1, '需要管理员权限才能设置。'); // 检测浏览器 $browser = get__browser(); check_browser($browser); $runtime = runtime_init(); if ($method == 'GET') { $qq = kv_get('qq_login'); !isset($qq['enable']) && ($qq['enable'] = 0); !isset($qq['meta']) && ($qq['meta'] = ''); !isset($qq['appid']) && ($qq['appid'] = ''); !isset($qq['appkey']) && ($qq['appkey'] = ''); $input['enable'] = form_radio_yes_no('enable', $qq['enable']); $input['meta'] = form_text('meta', htmlspecialchars($qq['meta']), 600); $input['appid'] = form_text('appid', $qq['appid'], 300); $input['appkey'] = form_text('appkey', $qq['appkey'], 300); $header = array(); $header['title'] = 'QQ 登陆设置'; include './plugin/xn_qq_login/setting.htm'; } else { $enable = param('enable', 0); $meta = param('meta', '', FALSE); $appid = param('appid');
if ($path[0] != '/') { exit_print('Incorrect path.'); } $dir = substr($path, 0, strrpos($path, '/') + 1); $name = substr(strrchr($path, '/'), 1); } $kv = kv_init(); $node = unserialize(kv_get($kv, $dir)) or exit_print('No such item.'); if ($name != '') { foreach ($node['R'] as $f) { if (!strcasecmp($f['N'], $name)) { header('Content-Type: application/octet-stream'); header('Content-Length: ' . $f['S']); header('Content-Disposition: attachment; filename=' . $f['N']); for ($i = 0; $i * 3145728 < $f['S']; $i++) { echo kv_get($kv, $f['I'] . ':' . $i); } //echo kv_get($kv, $path . ':' . $i); exit; } } /* without much usage */ foreach ($node['D'] as $f) { if (!strcasecmp($f['N'], $name)) { exit_redirect('home.php?path=' . $path . '/'); } } exit_print('No such item. ' . $name); } ?> <!DOCTYPE html>
$dest = $_REQUEST['dest']; $node2 = unserialize(kv_get($kv, $dest)) or exit_print("No such directory"); var_dump($node2); foreach ($name as $n) { foreach ($node['R'] as $k => $v) { if (!strcasecmp($v['N'], $n)) { $node2['R'][] = $v; unset($node['R'][$k]); break; } } /* ERROR */ foreach ($node['D'] as $k => $v) { if (!strcasecmp($v['N'], $n)) { $node2['D'][] = $v; $tmp = kv_get($kv, $dir . $v['N'] . '/'); kv_set($kv, $dest . $v['N'] . '/', $tmp); kv_delete($kv, $dir . $v['N'] . '/'); unset($node['D'][$k]); break; } } } kv_set($kv, $dir, serialize($node)); kv_set($kv, $dest, serialize($node2)); break; case 'list': echo '<ul ' . ($dir == '/' ? 'class="root"' : '') . ' id="' . urlencode($dir) . '">'; foreach ($node['D'] as $f) { echo '<li><span id="' . urlencode($dir . $f['N'] . '/') . '" class="expand"></span><input type="checkbox" />' . $f['N'] . '</li>'; }
<?php !defined('DEBUG') and exit('Access Denied.'); include './xiunophp/form.func.php'; $action = param(1); if ($action == 'base') { $conffile = './conf/conf.php'; $readable = is_writeable($conffile); if ($method == 'GET') { $input = array(); $input['sitename'] = form_text('sitename', $conf['sitename']); $input['runlevel'] = form_radio('runlevel', array(0 => '站点关闭', 1 => '管理员可读写', 2 => '会员可读', 3 => '会员可读写', 4 => '所有人只读', 5 => '所有人可读写'), $conf['runlevel']); $setting = kv_get('setting'); // 首页数据 empty($setting) and $setting = array('sitebrief' => '', 'seo_title' => '', 'seo_keywords' => '', 'seo_description' => '', 'footer_code' => ''); $sitebrief = $setting['sitebrief']; // 站点介绍 $input['seo_title'] = form_text('seo_title', $setting['seo_title'], '100%'); $input['seo_keywords'] = form_text('seo_keywords', $setting['seo_keywords'], '100%'); $input['seo_description'] = form_text('seo_description', $setting['seo_description'], '100%'); $input['footer_code'] = form_textarea('footer_code', $setting['footer_code'], '100%', '50px'); include './admin/view/setting.htm'; } else { $sitebrief = param('sitebrief', '', FALSE); $seo_title = param('seo_title', '', FALSE); $seo_keywords = param('seo_keywords', '', FALSE); $seo_description = param('seo_description', '', FALSE); $footer_code = param('footer_code', '', FALSE); $setting = array('sitebrief' => $sitebrief, 'seo_title' => $seo_title, 'seo_keywords' => $seo_keywords, 'seo_description' => $seo_description, 'footer_code' => $footer_code); kv_set('setting', $setting); cache_delete('setting');
function cache_get($k, $fromkv = FALSE) { global $cache, $db; if (!$cache) { return $db ? kv_get($k) : FALSE; } $r = $cache->get($k); if ($r === FALSE && $cache->errno != 0) { message(-1, $cache->errstr); } elseif ($r === NULL && $fromkv) { $r = kv_get($k); cache_set($k, $r); return $r; } return $r; }
<?php !defined('DEBUG') and exit('Access Denied.'); include './xiunophp/form.func.php'; $action = param(1); if ($method == 'GET') { $badwords = kv_get('badwords'); $input_badword_on = form_radio_yes_no('badword_on', $conf['badword_on']); $badwords = badword_implode(':', ' ', $badwords); include './admin/view/badword.htm'; } elseif ($method == 'POST') { $badwords = param('badwords'); $badword_on = param('badword_on', 0); $badwords = str_replace(" ", ' ', $badwords); $badwords = str_replace(":", ':', $badwords); $badwords = str_replace(": ", ':', $badwords); $badwords = preg_replace('#\\s+#is', ' ', $badwords); $badwordarr = badword_explode(':', ' ', $badwords); kv_set('badwords', $badwordarr); conf_set('badword_on', $badword_on); message(0, '保存成功'); }
<?php #this file is the entrance for user, it first check the authority status and detect #whether to init kvdb or just login(msg may be received from session). include 'base.php'; session_start(); $_SESSION['error'] == ''; if ($_SESSION['auth'] == 'OK') { exit_redirect('home.php'); } $kv = kv_init(); $type = kv_get($kv, ':account'); /* wheather the KBDB has been initilized */ ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>KVDB-MemStorage - Use MemStorage From SaeKVDB To Save Files</title> <style type="text/css"> body { font: 13px verdana, tahoma, sans-serif; color: #333; } a { text-decoration: none; color: #2323E4; } form { width: 235px; margin: 140px auto; padding: 20px 13px; border: 1px #ddd solid; background: #f7f7f7; margin-bottom: 40px;} li { list-style: none; margin-bottom: 28px; clear: both; padding: 0 8px; } li input { float: right; margin-right: 6px; margin-top: -3px; font-family: verdana, tahoma, sans-serif; } #title { text-align: center; font-size: 16px; color: #2db033; margin-top: 10px; } #msg { text-align: center; font-size: 12px; color:#D00; margin: 0 15px 20px 7px; border: 1px dotted #999; padding: 4px 0; } #submit{ margin: 28px 0 8px 0; } #submit input { width: 82px; height: 23px; border: 0px; background-color:#3cb43c; color: #fff; border-radius: 2px; margin-top: -4px; } input[type=text], input[type=password] { width: 130px; height: 19px; border: 1px #ccc solid; background-color: #faffbd; } .hidden { display: none; }
$temp[$it[0]]['X'] = $index; echo json_encode(array('code' => 0, 'size' => strlen($raw))); } } } } kv_set($kv, ':temp', serialize($temp)); exit; break; case "finish": for (reset($temp); $it = each($temp);) { $f = $it[1]; if ($f['D'] == $dir && $f['N'] == $name) { $num = (int) ($f['S'] / 3145728) + ($f['S'] % 3145728 == 0 ? 0 : 1); if ($f['X'] != $num - 1) { exit_json(5, 'Not complete. ' . $f['X'] . '/' . ($num - 1)); } $node = unserialize(kv_get($kv, $dir)); $node['R'][] = array('N' => $f['N'], 'T' => time(), 'A' => $node['A'], 'S' => $f['S'], 'I' => $f['I']); kv_set($kv, $dir, serialize($node)); unset($temp[$it[0]]); kv_set($kv, ':temp', serialize($temp)); exit_json(0, 'OK'); } } exit_json(6, 'No such item'); break; default: exit_json(7, 'Unkown action.'); break; }
<?php # This file is to start the web disk, attention: it will delete permanently # all the files exist. And login, logout, reset service. # # name -> ('T' - time, 'A' - public, 'R' - regular, 'D' - directory) # regular file == [('N' - name, 'T' - time, 'A' - access, 'S' - size)] # directory == [('N' - name, 'T' - time, 'A' - access)] include "base.php"; session_start(); $_SESSION['error'] == ''; $kv = kv_init(); $account = unserialize(kv_get($kv, ':account')); $email = $_REQUEST['email']; $username = $_REQUEST['username']; $password = $_REQUEST['password']; $verified = false; switch ($_REQUEST['action']) { case 'start': check_field('email', 'username', 'password'); if ($account) { exit_print('KVDB-MemStorage has been started.'); } $account = array('email' => $email, 'username' => $username, 'password' => md5($password)); kv_set($kv, ':account', serialize($account)); $temp = array(); kv_set($kv, ':temp', serialize($temp)); $root = array('T' => time(), 'A' => false, 'R' => array(), 'D' => array()); kv_set($kv, '/', serialize($root)); $_SESSION['auth'] = 'OK'; exit_redirect('home.php');