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; } }
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; }
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; }