voucher_unlink_db($roll); unlock($voucherlck); write_config(); header("Roll {$id} deleted", false, 204); break; case POST: # print "POST"; // print $_SERVER['PATH_INFO']; if (preg_match('/^\\/roll\\/(\\w+)\\/?$/', $_SERVER['PATH_INFO'], $matches)) { $cpzone = strtolower($matches[1]); } else { header("Not found", false, 404); print "Not found"; return; } $a_roll = load_cfg(); if (!valid_post()) { return; } $voucherlck = lock("voucher{$cpzone}"); $rollent['zone'] = $cpzone; $rollent['number'] = $_POST['number']; $rollent['minutes'] = $_POST['minutes']; $rollent['comment'] = $_POST['comment']; $rollent['count'] = $_POST['count']; $len = ($rollent['count'] >> 3) + 1; // count / 8 +1 $rollent['used'] = base64_encode(str_repeat("", $len)); // 4 bitmask $rollent['active'] = array(); voucher_write_used_db($rollent['number'], $rollent['used']);
/** * @name InitMemCache * @author Melon * @desc 初始化MemCached连接 * @param array $keys 需要初始化哪些MemCache * @return void * */ public static function InitMemdCache($keys = array()) { load_cfg('Mem'); //load configure $p =& Core::$configs['memd']; if (empty($keys)) { foreach ($p as $k => &$v) { if (isset(Core::$mem[$k])) { continue; } Core::$mem[$k] = new Memd($v['server'], $v['option']); } } else { if (is_array($keys)) { foreach ($keys as $v) { if (isset(Core::$mem[$v]) || !isset($p[$v])) { continue; } Core::$mem[$v] = new Memd($p[$v]['server'], $p[$v]['option']); } } else { if (is_string($keys) && !isset(Core::$mem[$keys])) { if (!isset($p[$keys])) { return; } Core::$mem[$keys] = new Memd($p[$keys]['server'], $p[$keys]['option']); } } } }