/** * * 建树 * @param unknown_type $item * @param unknown_type $name * @param unknown_type $full_key * @param unknown_type $is_last * @param unknown_type $return_html */ private function _create_key_tree($item, $name, $full_key, $is_last, &$return_html) { $this->_nowLevel = $full_key !== '' ? count(explode(SEPERATOR, $full_key)) : 0; $this->_create_key_tree_head($item, $name, $full_key, $is_last, $return_html); if (count($item) > 0) { $tree_sub2 = array(); if ($full_key != $this->_sub_key) { //因为dom的ID不能包含冒号: 所以将:替换为___ $tree_sub2[] = '<li class="folder' . (empty($full_key) ? '' : ' collapsed') . ($is_last ? ' last' : '') . '" title="' . urlencode($full_key) . '" id="keyid_' . str_replace(SEPERATOR, '___', $full_key) . '">'; $tree_sub2[] = '<div class="icon">' . format_html($name) . ' <span class="info">(' . count($item) . ')</span>'; $tree_sub2[] = !empty($full_key) ? '<a href="#" class="refresh" onclick="return refreshTree(this)"><img src="' . base_url('static/images/refresh.png') . '" width="10" height="10" title="刷新当前节点" alt="[X]"></a>' : ''; $tree_sub2[] = !empty($full_key) ? '<a href="' . manager_site_url('export', 'index', 'key=' . urlencode($full_key) . ':*') . '" class="export"><img src="' . base_url('static/images/export.png') . '" width="10" height="10" title="导出当前节点" alt="[X]"></a>' : ''; $tree_sub2[] = !empty($full_key) ? '<a href="' . manager_site_url('delete', 'index', 'tree=' . urlencode($full_key) . ':') . '" class="deltree"><img src="' . base_url('static/images/delete.png') . '" width="10" height="10" title="删除整个树" alt="[X]"></a>' : ''; $tree_sub2[] = '</div>'; } $tree_sub2[] = '<ul>'; $return_html[] = implode(PHP_EOL, $tree_sub2); if ($this->_nowLevel < $this->_auto_build_tree_level && is_array($item)) { $l = count($item); foreach ($item as $childname => $childitem) { if (empty($full_key)) { $childfullkey = $childname; } else { $childfullkey = $full_key . SEPERATOR . $childname; } $this->_create_key_tree($childitem, $childname, $childfullkey, --$l == 0, $return_html); } } $return_html[] = '</ul>'; if ($full_key != $this->_sub_key) { $return_html[] = '</li>'; } } }
private function _do_index() { $username = $this->input->post('username'); $password = $this->input->post('password'); $username = get_post_arg('username'); $password = get_post_arg('password'); if (empty($username) || empty($password)) { Header('Location:' . manager_site_url('login', 'index', 'error=1')); exit; } if (SECCODE_ENABLE) { $seccode = get_post_arg('seccode'); $sess_seccode = isset($_SESSION['seccode']) ? $_SESSION['seccode'] : NULL; //读出来后就要删掉 unset($_SESSION['seccode']); if (empty($seccode) || empty($sess_seccode) || strtoupper($seccode) !== strtoupper($sess_seccode)) { Header('Location:' . manager_site_url('login', 'index', 'error=1')); exit; } } $success = $this->_do_login($username, $password); if ($success) { $goto = isset($_COOKIE['goto']) ? $_COOKIE['goto'] : manager_site_url('index', 'index'); Header('Location:' . $goto); exit; } else { Header('Location:' . manager_site_url('login', 'index', 'error=1')); exit; } }
public function index() { $key = get_arg('key'); $type = strtolower(get_arg('type')); $allow_type = array('', 'string', 'hash', 'list', 'set', 'zset'); $tree = get_arg('tree'); if ($key !== NULL && $key !== '' && in_array($type, $allow_type)) { $this->_delete_key($type, $key); $url = manager_site_url('view', 'index', 'key=' . urlencode($key)); die($url); } elseif ($tree !== NULL && $this->is_post()) { $this->_delete_tree($tree); } $url = manager_site_url('index', 'overview'); die($url); }
private function _info() { $redis = $this->redis_model->get_redis_instance(); $reset = get_arg('reset', 0, 'intval'); $can_reset = method_exists($redis, 'resetStat'); if ($reset && $can_reset) { $redis->resetStat(); $url = manager_site_url('info', 'index'); header('Location: ' . $url); exit; } $info = $redis->info(); $page_data = $this->get_default_page_data(); $page_data['info'] = $info; $page_data['can_reset'] = $can_reset; $page_data['title'] = '统计信息'; $this->load->view('info', $page_data); }
private function _do_index() { $key = get_post_arg('key'); $redis = $this->redis_model->get_redis_instance(); $key_exists = $redis->exists($key); if (!$key_exists) { show_error('Key[' . $key . ']不存在'); } $ttl = get_post_arg('ttl'); if ($ttl == '-1') { $redis->persist($key); } else { $redis->expire($key, $ttl); } $url = manager_site_url('view', 'index', 'key=' . urlencode($key)); Header('Location:' . $url); exit; }
private function _do_index() { $key = get_post_arg('key'); $old_key = get_post_arg('old'); if ($key === NULL || $key === '') { show_error('没有找到新键名参数key'); } if (strlen($key) > MAX_KEY_LEN) { show_error('Key长度[' . strlen($key) . ']超过限制,当前限制为[' . MAX_KEY_LEN . ']'); } $redis = $this->redis_model->get_redis_instance(); $key_exists = $redis->exists($old_key); if (!$key_exists) { show_error('Key[' . $old_key . ']不存在'); } $redis->rename($old_key, $key); $url = manager_site_url('view', 'index', 'key=' . urlencode($key)); Header('Location:' . $url); exit; }
public function build_report() { if (!$this->is_post()) { header('Location:' . manager_site_url(strtolower(__CLASS__), 'index')); exit; } $cnt = get_arg('cnt', 10, 'intval'); $cnt = $cnt <= 0 ? 10 : $cnt; $redis = $this->redis_model->get_redis_instance(); $keys = $redis->keys('*'); $head = IdleQueue::factory(-1, $cnt); foreach ($keys as $key) { if ($key == $this->_idle_key) { continue; } $d = $redis->object('idletime', $key); $tmp =& $head; while ($tmp !== NULL && $d >= $tmp->idle_time) { $tmp =& $tmp->next; } if ($tmp === $head) { continue; } $head->idle_time = $d; $head->key = $key; if ($tmp != $head->next) { $t = $head; $head = $head->next; $t->next = is_null($tmp) ? NULL : $tmp; $tmp = $t; } } $report = IdleQueue::result($head); $this->_set_idle_report($report); die('操作已完成! <a href="' . manager_site_url('idle', 'index') . '">返回</a>'); }
var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } var goPrefix = function() { var prefix = $("#prefix").val(); var url = '<?php echo manager_site_url('index', 'index'); ?> '; var params = GetRequest(); params['m'] = params['c']; params['c'] = 'index'; var href = location.protocol + '\/\/' + location.host + location.pathname; var separator = '?'; for(var key in params) { if ( key == 'prefix' ) { continue; } href += separator + key + '=' + params[key]; separator = '&'; }
private function _do_index() { $key = get_post_arg('key', NULL, 'trim'); if ($key === FALSE || $key === '') { show_error('Key不能为空'); } if (strlen($key) > MAX_KEY_LEN) { show_error('Key长度[' . strlen($key) . ']超过限制,当前限制为[' . MAX_KEY_LEN . ']'); } $type = strtolower(get_post_arg('type', NULL, 'trim')); $allow_type = array('string', 'list', 'hash', 'set', 'zset'); if (!in_array($type, $allow_type)) { show_error('未知的数据类型'); } $value = get_post_arg('value'); $redis = $this->redis_model->get_redis_instance(); if ($type == 'string') { //string $result = $redis->set($key, $value); if (!$result) { show_error('操作失败'); } } elseif ($type == 'hash') { //hash $hkey = get_post_arg('hkey'); //只有当hkey存在的时候才操作 if ($hkey !== NULL) { if (strlen($hkey) > MAX_KEY_LEN) { show_error('Hash Key长度[' . strlen($key) . ']超过限制,当前限制为[' . MAX_KEY_LEN . ']'); } //指定读取$_GET中的hkey $old_hkey = get_arg('hkey', NULL, 'trim', 'get'); if ($old_hkey !== NULL && !$redis->hExists($key, $hkey)) { //如果新的hkey不存在的话 //删掉用来的旧KEY $redis->hDel($key, $old_hkey); } $redis->hSet($key, $hkey, $value); } } elseif ($type == 'list') { //list $size = $redis->lSize($key); $index = get_post_arg('index', NULL, 'trim'); $index === NULL && ($index = ''); if ($index == '' || $index == $size) { //加到list最后面 $redis->rPush($key, $value); } elseif ($index == '-1') { //加到list最前面 $redis->lPush($key, $value); } elseif ($index >= 0 && $index < $size) { //直接修改原list的值 $redis->lSet($key, $index, $value); } else { show_error('index值越界(Out of bounds index)'); } } elseif ($type == 'set') { //set $old_value = get_post_arg('oldvalue'); if ($value != $old_value) { $redis->sRem($key, $old_value); $redis->sAdd($key, $value); } } elseif ($type == 'zset') { //zset $old_value = get_post_arg('oldvalue'); $old_score = get_post_arg('oldscore'); $score = get_post_arg('score'); $score === NULL && ($score = ''); if ($value != $old_value || $score != $old_score) { $redis->zDelete($key, $old_value); $redis->zAdd($key, $score, $value); } } $url = manager_site_url('view', 'index', 'key=' . urlencode($key)); Header('Location:' . $url); exit; }
<td> <div> <a href="<?php echo manager_site_url('edit', 'index', 'key=' . urlencode($key) . '&type=string'); ?> "> <img src="<?php echo base_url('static/images/edit.png'); ?> " width="16" height="16" title="编辑" alt="编辑" /> </a> </div> </td> <td> <div> <a href="<?php echo manager_site_url('delete', 'index', 'key=' . urlencode($key) . '&type=string'); ?> " class="delval"> <img src="<?php echo base_url('static/images/delete.png'); ?> " width="16" height="16" title="删除" alt="删除" /> </a> </div> </td> </tr> </table> <?php PagerWidget::footer();
?> " width="16" height="16" title="编辑" alt="编辑" /> </a> </div> </td> <td> <div> <a href="<?php echo manager_site_url('delete', 'index', 'key=' . urlencode($key) . '&type=' . $type . '&hkey=' . urlencode($hkey)); ?> " class="delval"> <img src="<?php echo base_url('static/images/delete.png'); ?> " width="16" height="16" title="删除" alt="删除" /> </a> </div> </td> </tr> <?php $alt = !$alt; } ?> </table> <p> <a href="<?php echo manager_site_url('edit', 'index', 'key=' . urlencode($key) . '&type=' . $type); ?> " class="add">新增一个值</a> </p> <?php PagerWidget::footer();
<td><div>上次保存:</div></td> <?php $last_save_time = NULL; if (isset($info[$i]['rdb_last_save_time'])) { $last_save_time = $info[$i]['rdb_last_save_time']; } elseif (isset($info[$i]['last_save_time'])) { $last_save_time = $info[$i]['last_save_time']; } ?> <td> <div><?php echo $last_save_time === NULL ? '未知' : format_ago(time() - $last_save_time, true); ?> <a href="<?php echo manager_site_url('save', 'index'); ?> "> <img src="<?php echo base_url('static/images/save.png'); ?> " width="16" height="16" title="立刻保存" alt="立刻保存" class="imgbut" /> </a> </div> </td> </tr> <?php } ?> </table> </div>
<p>密 码:<input type="password" name="password" /></p> <?php if ($seccode_enable) { ?> <p> 验证码:<input type="text" id="seccode" name="seccode" /> </p> <p> <img src="about:blank" style="border:0; margin-left:5px;" onerror="document.getElementById('login_secImgTag').src='<?php echo manager_site_url('login', 'seccode'); ?> &'+Math.random();" title="换一个" id="login_secImgTag" onClick="document.getElementById('login_secImgTag').src='<?php echo manager_site_url('login', 'seccode'); ?> &'+Math.random();" /> </p> <?php } ?> <p><input type="submit" value="登录" /></p> <?php if ($error) { ?> <p>账号名或密码错!</p> <?php } ?> </form>
protected function _auth_check() { if (!isset($_SESSION['username']) || empty($_SESSION['username'])) { $cur_url = get_cur_url(); if ($cur_url) { $goto = '&goto=' . rawurlencode($cur_url); } else { $goto = ''; } header('location:' . manager_site_url('login', 'index', $goto)); exit; } }
</div> </td> <td> <div><?php echo nl2br(format_html($arr['key'])); ?> </div> </td> <td> <div><?php echo nl2br(format_html($arr['idle_time'])); ?> </div> </td> <td> <div> <a href="<?php echo manager_site_url('view', 'index', 'key=' . urlencode($arr['key'])); ?> ">查看</a> </div> </td> </tr> <?php $alt = !$alt; } ?> </table> <?php } PagerWidget::footer();
<?php PagerWidget::header(); ?> <h2><?php echo $title; ?> </h2> <?php if ($can_reset) { ?> <p> <a href="<?php echo manager_site_url('info', 'index', 'reset=1'); ?> " class="reset" onclick="return confirm('确认要重置统计吗?')">重置统计</a> </p> <?php } ?> <table> <tr> <th><div>Key</div></th> <th><div>Value</div></th> </tr> <?php $alt = FALSE; foreach ($info as $key => $value) { if ($key == 'allocation_stats') { $value = str_replace(',', ",\n", $value); }