function extract_columns(&$columns, $file, $length) { $fp = fopen($file, 'r'); $index = 0; $z = 0; $mu = 0; $dmu = 0; while ($cols = fgetcsv($fp, 1024, ",")) { if (empty($cols[0])) { continue; } $pm_count = substr_count($cols[0], "±"); if ($pm_count > 1) { $index += $pm_count - 1; $cols[0] = trim(skip($cols[0], " ", 4 * ($pm_count - 1))); echo $cols[0] . "\n"; } if ($index == 1) { $z = $cols[0]; } if ($index == 6) { $mu = (double) $cols[0]; $dmu = trim(substr($cols[0], strpos($cols[0], "±") + 2)); } if ($index >= $length - 1) { $index = 0; $columns[] = array($z, $mu, $dmu); } else { ++$index; } } }
function test_skip_one() { $input = [0, 1, 2]; $expect = [1 => 1, 2 => 2]; $skip = skip(1); $actual = iterator_to_array($skip($input)); $this->assertEquals($expect, $actual); }
function setup() { if (!extension_loaded('apc')) { skip('apc required.'); } if (!ini_get('apc.enable_cli')) { skip('apc.enable_cli required'); } }
function setUp() { if (!extension_loaded('geoip')) { skip('geoip extension is required.'); } if (!dns_get_record('www.hinet.net')) { skip('networking is required.'); } }
public function testDetectProcessorNumber() { $machine = new MachineForTest(); if (!$machine->detectProcessorNumber()) { skip(); } ok($machine->detectProcessorNumber() > 0); is($machine->detectProcessorNumber(), $machine->detectProcessorNumberByNproc() || $machine->detectProcessorNumberByGrep()); }
function test_skip_all() { $skip = skip(function ($value) { return $value % 2 > 0; }); $input = [1, 3, 5]; $expect = []; $actual = iterator_to_array($skip($input)); $this->assertEquals($expect, $actual); }
public function test() { if (!TputConsoleInfo::hasSupport()) { skip('tput is not supported.'); } $info = new TputConsoleInfo(); ok($info); ok($info->getColumns()); ok($info->getRows()); }
public function test() { if (!EnvConsoleInfo::hasSupport()) { skip('env console info is not supported.'); } $info = new EnvConsoleInfo(); ok($info); ok($info->getColumns()); ok($info->getRows()); }
/** * 注册 */ public function _registerAct() { if (empty($_POST) || empty($_POST['mobile']) || empty($_POST['pwd'])) { return 0; } $phone = V('mobile'); $pwd = $_POST['pwd']; $rec = V('recommended'); $telcode = V('telcode'); $data = array('sname' => 'user.reg', 'mobile' => $phone, 'passwd' => $pwd, 'recommended' => $rec, 'telcode' => $telcode); $data = transferAPI($data); if ($data['code'] != 0) { $this->view->assign('n', $phone); $this->view->assign('msg', $data['msg']); } else { skip('/user/login'); } }
function zpm_postamble($ggame) { if (skip()) { return; } global $zpm_utime; $end_t = microtime(true); $time_t = floor(($end_t - $zpm_utime) * 1000000); $start_t_f = floor($zpm_utime); $name = basename($_SERVER['SCRIPT_NAME']); if (isset($ggame) && $ggame != "") { $name = $ggame . "^" . $name; } log_entry($name, $time_t, $start_t_f); zperfmon_disable(); $zpm_utime = ZPM_INIT_VAL; return; }
public function _loginAct() { $phone = V('mobile'); $pas = $_POST['pwd']; if (empty($phone) || empty($pas)) { return 0; } $data = array('sname' => 'user.login', 'mobile' => $phone, 'passwd' => $pas); core::Singleton('comm.remote.remote'); $result = remote::send($data); setcookie("version", remote::$session_id, time() + 3600 * 12, '/', 'cailai.com'); $data = json_decode($result, TRUE); if ($data['code'] != 0) { $this->view->assign('tipMsg', $data['msg']); } setcookie("uid", md5(uniqid()) . $data['data']['mobile'], time() + 3600 * 12, '/', 'cailai.com'); if (empty(remote::$session_id)) { $this->view->assign('n', $phone); return 0; } else { skip(); } }
include_once 'inc/config.inc.php'; include_once 'inc/mysql.inc.php'; include_once 'inc/tool.inc.php'; $link = connect(); if (!($member_id = is_login($link))) { skip('login.php', 'error', '请登录之后再发帖!'); } if (isset($_POST['submit'])) { include 'inc/check_publish.inc.php'; $_POST = escape($link, $_POST); $query = "insert into cfc_content(module_id,title,content,time,member_id) values({$_POST['module_id']},'{$_POST['title']}','{$_POST['content']}',now(),{$member_id})"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip('publish.php', 'ok', '发布成功!'); } else { skip('publish.php', 'error', '发布失败,请重试!'); } } $template['title'] = '帖子发布页'; $template['css'] = array('style/public.css', 'style/publish.css'); include 'inc/header.inc.php'; ?> <div id="position" class="auto"> <a href="index.php">首页</a> > 发布帖子 </div> <div id="publish"> <form method="post"> <select name="module_id"> <option value='-1'>请选择一个子版块</option> <?php $where = '';
$result_memebr = execute($link, $query); $data_member = mysqli_fetch_assoc($result_memebr); if (isset($_POST['submit'])) { $save_path = 'uploads' . date('/Y/m/d/'); //写上服务器上文件系统的路径,而不是url地址 $upload = upload($save_path, '8M', 'photo'); if ($upload['return']) { $query = "update cfc_member set photo='{$upload['save_path']}' where id={$member_id}"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip("member.php?id={$member_id}", 'ok', '头像设置成功!'); } else { skip('member_photo_update.php', 'error', '头像设置失败,请重试'); } } else { skip('member_photo_update.php', 'error', $upload['error']); } } //SUB_URL. ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <style type="text/css"> body { font-size:12px; font-family:微软雅黑;
public function setUp() { if (!extension_loaded('pdo')) { return skip('pdo extension is required'); } // XXX: check pdo driver # if( ! extension_loaded('pdo_pgsql') ) # return skip('pdo pgsql required'); if ($driverType = $this->getCurrentDriverType()) { $this->pdo = $this->createConnection($driverType); } else { throw new Exception("Please define driver type for testing."); } if (!$this->pdo) { throw new Exception("Can not create PDO connection: " . get_class($this)); } // throw Exception on Error. $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->setupSchema(); ok($this->pdo); }
skip('index.php', 'ok', '您已经登录,请不要重复登录!'); } if (isset($_POST['submit'])) { include_once 'inc/check_login.inc.php'; $_POST = escape($link, $_POST); $query = "select * from cfc_manage where name='{$_POST['name']}' and pw=md5('{$_POST['pw']}')"; $result = execute($link, $query); if (mysqli_num_rows($result) == 1) { $data = mysqli_fetch_assoc($result); $_SESSION['manage']['name'] = $data['name']; $_SESSION['manage']['pw'] = sha1($data['pw']); $_SESSION['manage']['id'] = $data['id']; $_SESSION['manage']['level'] = $data['level']; skip('index.php', 'ok', '登录成功!'); } else { skip('login.php', 'error', '用户名或者密码错误,请重试!'); } } ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title>后台登录</title> <meta name="keywords" content="后台登录" /> <meta name="description" content="后台登录" /> <style type="text/css"> body { background:#f7f7f7; font-size:14px; }
include_once 'inc/tool.inc.php'; $link = connect(); $member_id = is_login($link); if ($member_id) { skip('index.php', 'error', '你已经登录,请不要重复注册!'); } if (isset($_POST['submit'])) { include 'inc/check_register.inc.php'; $query = "insert into cfc_member(name,pw,register_time,photo,last_time) values('{$_POST['name']}',md5('{$_POST['pw']}'),now(),'',now())"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { setcookie('sfk[name]', $_POST['name']); setcookie('sfk[pw]', sha1(md5($_POST['pw']))); skip('index.php', 'ok', '注册成功!'); } else { skip('register.php', 'eror', '注册失败,请重试!'); } } $template['title'] = '会员注册页'; $template['css'] = array('style/public.css', 'style/register.css'); include 'inc/header.inc.php'; ?> <div id="register" class="auto"> <h2>欢迎注册成为 CFC-bbs会员</h2> <form method="post"> <label>用户名:<input type="text" name="name" /><span>*用户名不得为空,并且长度不得超过32个字符</span></label> <label>密码:<input type="password" name="pw" /><span>*密码不得少于6位</span></label> <label>确认密码:<input type="password" name="confirm_pw" /><span>*请输入与上面一致</span></label> <label>验证码:<input name="vcode" name="vocode" type="text" /><span>*请输入下方验证码</span></label> <img class="vcode" src="show_code.php" /> <div style="clear:both;"></div>
<?php if (empty($_POST['name'])) { skip('login.php', 'error', '用户名不得为空!'); } if (mb_strlen($_POST['name']) > 32) { skip('login.php', 'error', '用户名长度不要超过32个字符!'); } if (empty($_POST['pw'])) { skip('login.php', 'error', '密码不得为空!'); } if (strtolower($_POST['vcode']) != strtolower($_SESSION['vcode'])) { skip('login.php', 'error', '验证码输入错误!'); } if (empty($_POST['time']) || is_numeric($_POST['time']) || $_POST['time'] > 2592000) { $_POST['time'] = 2592000; }
<?php $lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php'; require_once $lib; plan(2); skip("Test: Skip one", 1); fail("Gets skipped"); pass("Gets run ok");
$result = execute($link, $query); if (mysqli_num_rows($result) == 0) { skip('son_module_add.php', 'error', '所属父版块不存在!'); } if (empty($_POST['module_name'])) { skip('son_module_add.php', 'error', '子版块名称不得为空!'); } if (mb_strlen($_POST['module_name']) > 66) { skip('son_module_add.php', 'error', '子版块名称不得多余66个字符!'); } $_POST = escape($link, $_POST); switch ($check_flag) { case 'add': $query = "select * from cfc_son_module where module_name='{$_POST['module_name']}'"; break; case 'update': $query = "select * from cfc_son_module where module_name='{$_POST['module_name']}' and id!={$_GET['id']}"; break; default: skip('son_module', 'error', '$check_flag参数错误!'); } $result = execute($link, $query); if (mysqli_num_rows($result)) { skip('son_module_add.php', 'error', '这个子版块已经有了!'); } if (mb_strlen($_POST['info']) > 255) { skip('son_module_add.php', 'error', '子版块简介不得多于255个字符!'); } if (!is_numeric($_POST['sort'])) { skip('son_module_add.php', 'error', '排序只能是数字!'); }
skip('index.php', 'error', '您要回复的帖子id参数不合法!'); } $query = "select sc.id,sc.title,sm.name from cfc_content sc,cfc_member sm where sc.id={$_GET['id']} and sc.member_id=sm.id"; $result_content = execute($link, $query); if (mysqli_num_rows($result_content) != 1) { skip('index.php', 'error', '您要回复的帖子不存在!'); } if (isset($_POST['submit'])) { include 'inc/check_reply.inc.php'; $_POST = escape($link, $_POST); $query = "insert into cfc_reply(content_id,content,time,member_id) values({$_GET['id']},'{$_POST['content']}',now(),{$member_id})"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip("show.php?id={$_GET['id']}", 'ok', '回复成功!'); } else { skip($_SERVER['REQUEST_URI'], 'error', '回复失败,请重试!'); } } $data_content = mysqli_fetch_assoc($result_content); $data_content['title'] = htmlspecialchars($data_content['title']); $template['title'] = '帖子回复页'; $template['css'] = array('style/public.css', 'style/publish.css'); include 'inc/header.inc.php'; ?> <div id="position" class="auto"> <a>首页</a> > 回复帖子 </div> <div id="publish"> <div>回复:由 <?php echo $data_content['name']; ?>
<?php include_once '../inc/config.inc.php'; include_once '../inc/mysql.inc.php'; include_once '../inc/tool.inc.php'; $link = connect(); include_once 'inc/is_manage_login.inc.php'; //验证管理员是否登录 if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { skip('father_module.php', 'error', 'id参数错误!'); } $query = "select * from cfc_son_module where father_module_id={$_GET['id']}"; $result = execute($link, $query); if (mysqli_num_rows($result)) { skip('father_module.php', 'error', '该父版块下面存在子版块,请先将对应的子版块先删掉!'); } $query = "delete from cfc_father_module where id={$_GET['id']}"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip('father_module.php', 'ok', '恭喜你删除成功!'); } else { skip('father_module.php', 'error', '对不起删除失败,请重试!'); }
} $query = "select * from cfc_father_module where id={$_GET['id']}"; $result = execute($link, $query); if (!mysqli_num_rows($result)) { skip('father_module.php', 'error', '这条版块信息不存在!'); } if (isset($_POST['submit'])) { //验证 $check_flag = 'update'; include 'inc/check_father_module.inc.php'; $query = "update cfc_father_module set module_name='{$_POST['module_name']}',sort={$_POST['sort']} where id={$_GET['id']}"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip('father_module.php', 'ok', '修改成功!'); } else { skip('father_module.php', 'error', '修改失败,请重试!'); } } $data = mysqli_fetch_assoc($result); $template['title'] = '父版块-修改'; $template['css'] = array('style/public.css'); include 'inc/header.inc.php'; ?> <div id="main"> <div class="title" style="margin-bottom:20px;">修改父版块 - <?php echo $data['module_name']; ?> </div> <form method="post"> <table class="au"> <tr>
function mWS() { try { $_type = PolyLexer::$WS; $_channel = PolyLexer::$DEFAULT_TOKEN_CHANNEL; // Poly.g:25:6: ( ' ' | '\\t' | '\\r' | '\\n' )+ $cnt3 = 0; //loop3: do { $alt3 = 2; $LA3_0 = $this->input->LA(1); if ($LA3_0 >= $this->getToken('9') && $LA3_0 <= $this->getToken('10') || $LA3_0 == $this->getToken('13') || $LA3_0 == $this->getToken('32')) { $alt3 = 1; } switch ($alt3) { case 1: if ($this->input->LA(1) >= $this->getToken('9') && $this->input->LA(1) <= $this->getToken('10') || $this->input->LA(1) == 13 || $this->input->LA(1) == 32) { $this->input->consume(); } else { $mse = new MismatchedSetException(null, $this->input); $this->recover($mse); throw $mse; } break; default: if ($cnt3 >= 1) { break 2; } //loop3; $eee = new EarlyExitException(3, $this->input); throw $eee; } $cnt3++; } while (true); skip(); $this->state->type = $_type; $this->state->channel = $_channel; } catch (Exception $e) { throw $e; } }
<?php require_once __DIR__ . '/vendor/autoload.php'; deftests(['run_test1' => function ($n) { return count(func_get_args()) !== 1; }, 'run_test2' => function ($a, $b, $c) { return is_int($a) && is_int($b) && is_int($c) ? 0 : dump(get_defined_vars()); }, 'sample1' => function ($n) { return sample('id', 4) !== upto(4); }, 'sample2' => function ($n) { return sample('id', $n % 100) !== upto($n % 100); }, 'skip1' => function ($x) { return skip(1, 'id', $x, false); }, 'skip2' => function () { return array_map(skip(1, 'id'), ['a', 'b', 'c'], ['x', 'y', 'z']) !== ['x', 'y', 'z']; }, 'curry' => function () { return id('plus', 5, 3) !== 8; }, 'curry_n' => function () { return curry_([], 3, 'array_merge', [1], [2], [3]) !== [1, 2, 3]; }, 'nary' => function () { $n = mt_rand(2, 50); return uncurry(nary(function () { return sum(func_get_args()); }, $n), range(1, $n)) !== sum(range(1, $n)); }, 'arity1' => function () { return arity(function ($a, $b) { }) !== 2; }, 'arity2' => function ($n) { return arity(nary(function () { }, $n % 100)) !== $n % 100; }, 'arity3' => function () {
<?php include_once '../inc/config.inc.php'; include_once '../inc/mysql.inc.php'; include_once '../inc/tool.inc.php'; $link = connect(); include_once 'inc/is_manage_login.inc.php'; //验证管理员是否登录 if (isset($_POST['submit'])) { include 'inc/check_manage.inc.php'; $query = "insert into cfc_manage(name,pw,create_time,level) values('{$_POST['name']}',md5({$_POST['pw']}),now(),{$_POST['level']})"; execute($link, $query); if (mysqli_affected_rows($link) == 1) { skip('manage.php', 'ok', '恭喜你,添加成功!'); } else { skip('manage.php', 'error', '对不起,添加失败,请重试!'); } } $template['title'] = '管理员添加页'; $template['css'] = array('style/public.css'); include 'inc/header.inc.php'; ?> <div id="main"> <div class="title" style="margin-bottom:20px;">添加管理员</div> <form method="post"> <table class="au"> <tr> <td>管理员名称</td> <td><input name="name" type="text" /></td> <td> 名称不得为空,不得超过32个字符
include_once '../inc/mysql.inc.php'; include_once '../inc/tool.inc.php'; $link = connect(); include_once 'inc/is_manage_login.inc.php'; //验证管理员是否登录 if (isset($_POST['submit'])) { foreach ($_POST['sort'] as $key => $val) { if (!is_numeric($val) || !is_numeric($key)) { skip('son_module.php', 'error', '排序参数错误!'); } $query[] = "update cfc_son_module set sort={$val} where id={$key}"; } if (execute_multi($link, $query, $error)) { skip('son_module.php', 'ok', '排序修改成功!'); } else { skip('son_module.php', 'error', $error); } } $template['title'] = '子版块列表页'; $template['css'] = array('style/public.css'); include 'inc/header.inc.php'; ?> <div id="main"> <div class="title">子版块列表</div> <form method="post"> <table class="list"> <tr> <th>排序</th> <th>版块名称</th> <th>所属父版块</th> <th>版主</th>
<?php if (!is_manage_login($link)) { header('Location:login.php'); exit; } if (basename($_SERVER['SCRIPT_NAME']) == 'manage_delete.php' || basename($_SERVER['SCRIPT_NAME']) == 'manage_add.php') { if ($_SESSION['manage']['level'] != '0') { if (!isset($_SERVER['HTTP_REFERER'])) { $_SERVER['HTTP_REFERER'] = 'index.php'; } skip($_SERVER['HTTP_REFERER'], 'error', '对不起您权限不足!'); } }
$is_manage_login = is_manage_login($link); $member_id = is_login($link); if (!$member_id && !$is_manage_login) { skip('login.php', 'error', '您没有登录!'); } if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { skip('index.php', 'error', '帖子id参数不合法!'); } $query = "select member_id from cfc_content where id={$_GET['id']}"; $result_content = execute($link, $query); if (mysqli_num_rows($result_content) == 1) { $data_content = mysqli_fetch_assoc($result_content); if (check_user($member_id, $data_content['member_id'], $is_manage_login)) { $query = "delete from cfc_content where id={$_GET['id']}"; execute($link, $query); if (isset($_GET['return_url'])) { $return_url = $_GET['return_url']; } else { $return_url = "member.php?id={$member_id}"; } if (mysqli_affected_rows($link) == 1) { skip($return_url, 'ok', '恭喜你,删除成功!'); } else { skip($return_url, 'error', '对不起删除失败!'); } } else { skip('index.php', 'error', '这个帖子不属于你,你没有权限!'); } } else { skip('index.php', 'error', '帖子不存在!'); }
alert($dnsApi->errorMsg); } } elseif ($action == 'domainlist') { $dns = getRequest('dns', 'get'); $dnsApi = Dnsapi::getApi($dns); if ($dns == 'dnspod') { if (is_null(config('DnspodTokenID')) || is_null(config('DnspodToken'))) { skip('apiConfig.php', '请先配置DnsPod Token'); } } elseif ($dns == 'aliyun') { if (is_null(config('AliyunAccessKeyId')) || is_null(config('AliyunAccessKeySecret'))) { skip('apiConfig.php', '请先配置AliYun AccessKey'); } } elseif ($dns == 'cloudxns') { if (is_null(config('CloudXnsSecretKey')) || is_null(config('CloudXnsSecretKey'))) { skip('apiConfig.php', '请先配置CloudXNS API KEY'); } } else { alert('暂时没有' . $dns . '平台的API'); } if ($row = $dnsApi->getDomainList()) { $list = array(); foreach ($row as $value) { $list["{$value['id']}"] = $value['name']; } //过滤已经添加的域名 $stmt = $db->prepare('SELECT domain_id as id FROM `kldns_domains` WHERE dns=:dns'); //获取域名列表 $stmt->execute(array(':dns' => $dns)); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if (isset($list["{$row['id']}"])) {
public function setUp() { if (!extension_loaded('memcache')) { skip('memcache extension is required.'); } }