<?php session_start(); require 'common/function.php'; global $system_config; $data['meta_title'] = 'Redis操作小工具'; $data['group'] = arrayItem($_GET, 'group', 'string'); $data['instruction_syntx'] = $system_config['instruction_syntx'][$system_config['instruction'][$data['group']][0]]; $data['connect'] = arrayItem($_SESSION, 'connect'); $data['description'] = $system_config['instruction_description'][$system_config['instruction'][$data['group']][0]]; display('index', $data);
<?php require 'common/function.php'; global $system_config; $instruction = arrayItem($_POST, 'instruction'); $instruction_syntx = isset($system_config['instruction_syntx'][$instruction]) ? $system_config['instruction_syntx'][$instruction] : array(); if (empty($instruction_syntx)) { echo json_encode(['status' => 0]); exit; } $html = ''; foreach ($instruction_syntx as $key => $value) { $value['default'] = isset($value['default']) ? $value['default'] : ''; $html .= '<div class="am-u-sm-6 am-u-md-2 input-text">'; $html .= '<input type="' . $value['type'] . '" class="am-input-sm" placeholder="' . $value['title'] . '" name="' . $value['name'] . '" value="' . $value['default'] . '" >'; $html .= '</div>'; } $number = 12 - (count($instruction_syntx) + 1) * 2 >= 2 ? 12 - (count($instruction_syntx) + 1) * 2 : 12; $return = ['status' => 1, 'html' => $html, 'number' => $number, 'description' => $system_config['instruction_description'][$instruction]]; echo json_encode($return); exit;
<?php session_start(); require 'common/function.php'; require 'common/MyRedis.php'; global $system_config; $return = ['status' => 0, 'info' => '']; $con = arrayItem($_SESSION, 'connect'); $redis = connectRedis($con); $instruction = arrayItem($_POST, 'instruction'); $return['post_info'] = $instruction; foreach ($system_config['instruction_syntx'][$instruction] as $key => $value) { $data[$key] = trim(arrayItem($_POST, $value['name'])); $return['post_info'] .= ' | ' . $value['name'] . ' : ' . $data[$key]; if ($data[$key] === FALSE) { $return['info'] = $value['name'] . '不存在~'; exit(json_encode($return)); } if ($data[$key] == '' && $value['require']) { $return['info'] = $value['name'] . '不能为空~'; exit(json_encode($return)); } # 判断是否需要把该值转为数组形式 if (!isset($value['value_type'])) { continue; } switch ($value['value_type']) { case 1: $data[$key] = explode('|', $data[$key]); break; case 2:
<?php session_start(); require 'common/function.php'; $return = ['status' => 0, 'info' => '', 'url' => '']; $ip = arrayItem($_POST, 'ip'); $port = arrayItem($_POST, 'port'); $password = arrayItem($_POST, 'password'); $db = arrayItem($_POST, 'db'); if (empty($ip) || empty($port) || $db == '') { $return['info'] = 'ip地址 端口号 连接库不能为空~'; exit(json_encode($return)); } $redis = new Redis(); $re = $redis->connect($ip, $port); if ($re === false) { $return['info'] = '连接redis服务失败~'; exit(json_encode($return)); } $re = $redis->select($db); if ($re === false) { $return['info'] = '连接redis指定库失败~'; exit(json_encode($return)); } $con['ip'] = $ip; $con['port'] = $port; $con['password'] = $password; $con['db'] = $db; $_SESSION['connect'] = $con; $return['status'] = 1; $return['info'] = 'redis连接成功~';