예제 #1
0
function checkShuffle()
{
    global $db;
    $sql = 'select * from users';
    $n = getNum();
    $ret = $db->query($sql);
    while ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
        $tab[intval($row['id'])] = intval($row['target']);
    }
    for ($i = 1; $i <= $n; $i++) {
        if ($tab[$i] < 1 || $tab[$i] > $n) {
            //echo $tab[$i].'pas entier';
            return false;
        } else {
            if ($tab[$i] == $i) {
                //echo 'pas dérangement';
                return false;
            }
        }
    }
    for ($i = 1; $i <= $n; $i++) {
        for ($j = 1; $j < $i; $j++) {
            if ($tab[$i] == $tab[$j]) {
                //echo 'pas permutation';
                return false;
            }
        }
    }
    return true;
}
예제 #2
0
function update($tab)
{
    global $db;
    $n = getNum();
    for ($i = 1; $i <= $n; $i++) {
        $statement = $db->prepare('UPDATE users SET target=:target WHERE id=:id;');
        $statement->bindValue(':target', $tab[$i]);
        $statement->bindValue(':id', $i);
        $statement->execute();
    }
    header('Location: admin.php?shuffled=1');
}
예제 #3
0
파일: count.php 프로젝트: boolean-wang/test
function result($a, $b)
{
    if ($a < $b) {
        $tem = $a;
        $a = $b;
        $b = $tem;
    }
    $i = getNum($a + $b);
    $j = getNum($a);
    $k = getNum($b);
    return $a . "个黄球 " . $b . "个红球共有 " . $i / ($j * $k) . " 种组合方式";
}
예제 #4
0
파일: 07_old.php 프로젝트: Ristee/mvctest3
function getWire($string, &$array)
{
    $action = $array[$string]['action'];
    $start = $array[$string]['start'];
    $second = $array[$string]['second'];
    $endwire = $array[$string]['endwire'];
    switch ($action) {
        case 'AND':
            $start = getNum($start, $wires);
            $second = getNum($second, $wires);
            $wires[$endwire] = $start & $second;
            break;
        case 'OR':
            $start = getNum($start, $wires);
            $second = getNum($second, $wires);
            $wires[$endwire] = $start | $second;
            break;
        case 'RSHIFT':
            $start = getNum($start, $wires);
            $second = getNum($second, $wires);
            $wires[$endwire] = $start >> $second;
            break;
        case 'LSHIFT':
            $start = getNum($start, $wires);
            $second = getNum($second, $wires);
            $wires[$endwire] = $start << $second;
            break;
        case 'NOT':
            $second = getNum($second, $wires);
            $bin = substr(decbin(~$second), 16);
            $bindec = bindec($bin);
            $wires[$endwire] = $bindec;
            break;
        case '':
            $second = getNum($second, $wires);
            $wires[$endwire] = $second;
            break;
    }
}
예제 #5
0
파일: fs_list.php 프로젝트: dalinhuang/c2my
            $j = 1;
        }
        $starttime = strtotime($year . "-" . $month . "-1");
        $endtime = strtotime($year . "-" . $j . "-1");
        if ($starttime < time()) {
            $Quartersendordersql = "SELECT sum( Insurancefee +  totalfee ) FROM {$tablepre}sendorder WHERE addtime BETWEEN " . $starttime . " AND " . $endtime;
            $Quarterordersql = "SELECT sum(goodsprice+sendprice) FROM {$tablepre}order WHERE addtime BETWEEN " . $starttime . " AND " . $endtime;
            $Quartersendorderdata = $db->result_first($Quartersendordersql);
            $Quarterorderdata = $db->result_first($Quarterordersql);
            $Quarterdata = $Quartersendorderdata + $Quarterorderdata;
            $serverfeesql = "select sum(serverfee) from {$tablepre}sendorder WHERE addtime BETWEEN " . $starttime . " AND " . $endtime;
            $serverfeedata = $db->result_first($serverfeesql);
            $dataarray[$month]['allmoney'] = getNum($Quarterdata);
            $dataarray[$month]['sendorderdata'] = getNum($Quartersendorderdata);
            $dataarray[$month]['orderdata'] = getNum($Quarterorderdata);
            $dataarray[$month]['servermoney'] = getNum($serverfeedata);
        }
    }
    //$orderway=$orderway=="asc"?"asc":"desc";
    //if(!empty($orderby))$orderstr="{$orderby} {$orderway}";
    //获取当前页码
    //$total=$Table->getcount($wheresql); 							  //总信息数
    //$pagesize=15;												  //一页显示信息数
    //$page = isset($page) ? max(1, intval($page)) : 1;             //处理页码变量
    //$offset=($page-1)*$pagesize;   								  //偏移量
    //$dataarray=$Table->getdata("$offset,$pagesize",$wheresql,$orderstr); //获取团购数据
    //包含后台模板文件
    include "tpl/fs_list.htm";
} else {
    showmsg("未知请求", "-1");
    //出错!
예제 #6
0
    } else {
        echo "<script type='text/javascript'> alert('Already existing')</script>";
    }
}
if (isset($_GET['did'])) {
    $delete = mysql_query("delete from cri_uo_financeteam where id='" . $_GET['did'] . "'");
}
function getNum()
{
    $sql = "select count(user_name) from cri_uo_financeteam where status=1";
    $result = mysql_query($sql);
    $total = mysql_fetch_array($result);
    return $total[0];
}
if (isset($_POST['update'])) {
    $num_uoms = getNum();
    $id = $_POST['edit_id'];
    foreach ($id as $val) {
        $user_name = $_POST['user_name'][$val];
        $sql = "UPDATE cri_uo_financeteam SET is_head='1',user_name='" . $user_name . "' WHERE id='" . $val . "'";
        mysql_query($sql);
        $sql1 = "UPDATE cri_uo_financeteam SET is_head='0' WHERE id='" . $val . "'";
        mysql_query($sql1);
    }
    $sql1 = "UPDATE cri_uo_financeteam SET is_head='1' WHERE id='" . $_POST['is_head'] . "'";
    mysql_query($sql1);
}
?>

<!DOCTYPE html>
<html>
            PS:如果你觉得以上写法需要在脑海里二次翻译,太过于麻烦,那么可以用以下的格式写法:{: 普通php写法 }<br/>
            <?php 
echo md5(mb_substr($user, 0, 3, 'UTF-8'));
?>
<br/><br/>
            
            当传递过来的变量如果没有值的时候,模版提供了默认值输出功能。<br/>
            <?php 
echo isset($nodate) && $nodate !== "" ? $nodate : '没有数据!';
?>
<br/><br/>
            
            我们可以在模版中使用运算符,包括对“+” 、 “-” 、 “*” 、 “/” 、 “%” 、 “--”和“++” 的支持。<br/>
            <?php 
echo $num + 10;
?>
<br/>
            <?php 
echo $num + getNum();
?>
 getNum函数在Weibo/Common/Common/function.php中<br/><br/>
            
            模版还支持三元运算符:
            <?php 
echo $withdata ? '$withdata有值' : '$withdata无值';
?>
<br/>
            
        </div>
    </body>
</html>
예제 #8
0
<html>
<head>
<title>Player</title>
</head>
<body>

<?php 
require "DB.php";
require "util.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$db = DB::connect("mysql://*****:*****@localhost/games");
$name = $_GET['name'];
$name = mysql_real_escape_string($name);
echo "<h1>{$name}</h1>";
echo "<h3>Attendance: " . getNum($db, "select count(*) as num from scores inner join games on games.gameid = scores.gameid where games.number = 1 and scores.name = '{$name}'") . "</h3>";
echo "<h3>Games Played: " . getNum($db, "select count(*) as num from scores where name = '{$name}'") . "</h3>";
echo "<h3>Games Won: " . getNum($db, "select count(*) as num from scores where name = '{$name}' and position=1") . "</h3>";
echo "<h3>ELO: " . getNum($db, "select elo from elo where name = '{$name}' order by eloid desc limit 1") . "</h3>";
echo "<img src=\"graphs/elo.php?name={$name}\">";
doTable("Besties", $db, "select opp, concat(round(p / t * 100,0),'%') as pct from (select scores.name,s.name as opp,count(*) as p from scores inner join scores as s on scores.gameid = s.gameid where scores.name = '{$name}' and s.name <> '{$name}' group by s.name order by p desc) as plays join (select scores.name,count(*) as t from scores where scores.name = '{$name}') as total using (name) order by p/t desc limit 10");
doTable("Wins", $db, "select games.name,count(*) as num from games inner join scores on games.gameid=scores.gameid where scores.name='{$name}' and scores.position=1 group by games.name order by count(*) desc");
doTable("Games Played", $db, "select games.name,count(*) as num from games inner join scores on games.gameid = scores.gameid where scores.name = '{$name}' group by games.name order by num desc");
doPositionTable("Play History", $db, "select games.date,games.name,scores.position from games inner join scores on scores.gameid=games.gameid where scores.name = '{$name}' order by games.date asc, games.number asc");
?>

</body>
</html>
    </div> -->
    <div id="fixed_bag" class="clear_f" style="border:none">
    	<?php 
if (is_array($folder)) {
    $i = 0;
    $__LIST__ = $folder;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $vo) {
            $mod = $i % 2;
            ++$i;
            ?>
<div class="fixed_bag_pic">
         	 <a href="javascript:void(0);" class="pic_icon"><?php 
            echo getNum($vo['id'], $vo['fileid']);
            ?>
</a>
         	 <input type="hidden" name="id" class="id" value="<?php 
            echo $vo["id"];
            ?>
" />
      		 <input type="hidden" name="type" class="type" value="<?php 
            echo $vo["type"];
            ?>
" /></li>
         	 <p class="fixed_bag_text"><?php 
            echo $vo["name"];
            ?>
</p>
        	</div><?php 
예제 #10
0
파일: start.php 프로젝트: zangfenziang/DOJ
}
for ($i = 0; $i < 6; $i++) {
    echo getACNum($recentDates[$i]) . ",";
}
echo getACNum($recentDates[6]);
?>
],
				color: '#66CC66'
			}, {
				name: '总提交',
				data: [<?php 
function getNum($d)
{
    $res = mysql_query("SELECT COUNT(*) FROM `submit` WHERE LEFT(`submit_time`, 10) = '{$d}' ");
    $a = mysql_fetch_array($res);
    mysql_free_result($res);
    return $a[0];
}
for ($i = 0; $i < 6; $i++) {
    echo getNum($recentDates[$i]) . ",";
}
echo getNum($recentDates[6]);
?>
],
				color: '#FFFF66'
			}]
		});
	</script>
</body>
</html>
예제 #11
0
        if (!isset($line[1])) {
            continue;
        }
        $line = array_map("getValue", $line);
        $etab = new CEtabExterne();
        $etab->finess = getNum($line[0]);
        if ($etab->loadMatchingObject()) {
            continue;
        }
        $etab->siret = getNum($line[1]);
        $etab->ape = $line[2];
        $etab->nom = $line[3];
        $etab->raison_sociale = $line[3];
        $etab->adresse = "{$line['4']}\n{$line['5']}\n{$line['6']}";
        $etab->cp = $line[7];
        $etab->ville = $line[8];
        $etab->tel = getNum($line[9]);
        $etab->fax = getNum($line[10]);
        $etab->repair();
        $type = $etab->_id ? "modify" : "create";
        if ($msg = $etab->store()) {
            CAppUI::setMsg($msg, UI_MSG_WARNING);
        } else {
            CAppUI::setMsg("CEtabExterne-msg-{$type}", UI_MSG_OK);
        }
    }
    fclose($fp);
    unlink($_file);
}
CAppUI::callbackAjax('window.parent.$("systemMsg").show().insert', CAppUI::getMsg());
CApp::rip();
예제 #12
0
파일: game.php 프로젝트: FigBug/GamenightEx
<html>
<head>
<title>Game</title>
</head>
<body>

<?php 
require "DB.php";
require "util.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$db = DB::connect("mysql://*****:*****@localhost/games");
$name = $_GET['name'];
echo "<h1>{$name}</h1>";
$name = mysql_real_escape_string($name);
echo "<h3>Times Played: " . getNum($db, "select count(*) as num from games where name = '{$name}'") . "</h3>";
doTable("Plays", $db, "select scores.name,count(*) as num from scores inner join games on games.gameid = scores.gameid where games.name = '{$name}' group by scores.name order by num desc");
doTable("Wins", $db, "select scores.name,count(*) as num from games inner join scores on games.gameid = scores.gameid where games.name='{$name}' and scores.position=1 group by scores.name order by num desc");
doTable("Win %", $db, "SELECT name, w / p * 100 AS win_pct FROM (SELECT scores.name, count(*) w FROM scores inner join games on games.gameid = scores.gameid WHERE position=1 and games.name = '{$name}' GROUP BY scores.name) AS wins JOIN (SELECT scores.name, count(*) p FROM scores inner join games on games.gameid = scores.gameid where games.name = '{$name}' GROUP BY scores.name) AS plays USING (name) ORDER BY win_pct DESC");
echo "<p>";
$sql = "select date,number,name,owner,gameid from games where name='{$name}'  order by date asc, number asc";
$q = $db->query($sql);
echo "<table border=1>";
echo "<tr><th>#<th>Date<th>#<th>Player<th>Score<th>Player<th>Score<th>Player<th>Score<th>Player<th>Score<th>Player<th>Score<th>Player<th>Score<th>Player<th>Score";
$idx = 1;
while ($q->fetchInto($r1)) {
    echo "<tr><td>{$idx}<td>{$r1['0']}<td>{$r1['1']}";
    $idx++;
    $gameid = $r1[4];
    $sql = "select name, points from scores where gameid = {$gameid} order by position asc";
    $q2 = $db->query($sql);
    while ($q2->fetchInto($r2)) {
예제 #13
0
            case 'OR':
                $wires[$out] = $num | $num2;
                break;
            case 'LSHIFT':
                $wires[$out] = $num << $num2;
                break;
            case 'RSHIFT':
                $wires[$out] = $num >> $num2;
                break;
        }
    } elseif ($op == 'NOT') {
        $num = getNum($a);
        if ($num === false) {
            $queue[] = $line;
            continue;
        }
        $wires[$out] = ~$num & 0xffff;
    } elseif ($op == 'ASSIGN') {
        $num = getNum($a);
        if ($num === false) {
            $queue[] = $line;
            continue;
        }
        // part 2: override value of b from input file with result from wire a in part 1
        if ($out == 'b') {
            $num = 956;
        }
        $wires[$out] = $num;
    }
}
echo "wire a: " . $wires['a'] . "\n";
예제 #14
0
<?php

function getNum($action)
{
    while (1) {
        $num = rand(1000, 9999);
        $stored = $action->send($num);
        if ($stored > 500) {
            break;
        }
    }
}
function storage()
{
    $r = 0;
    while (1) {
        $num = (yield $r);
        if ($num) {
            echo $num . "\n";
            file_put_contents("./car.txt", $num . "\n", FILE_APPEND);
            $r++;
        }
    }
}
$S = storage();
getNum($S);
예제 #15
0
<body style="overflow: auto;">
<div id="body">
    <div id="top">
        <h2><b><?php 
echo $test_type . " >> " . $test_title;
?>
</b></h2>
    </div>
    <div id="bottom">
        <?php 
$conn = db_connect();
if (!conn) {
    echo "<script>alert(\"连接数据库失败,请联系管理员!\")</script>";
}
$chapter_id = getNum($test_title);
//获取章节数(数字)  第1章练习->1
$query = "select * from tb_question where type='" . $test_type . "' and chapter_id='" . $chapter_id . "'";
$result = $conn->query($query);
$num = $result->num_rows;
if (!$result) {
    echo "<script>alert(\"查询数据库失败,请联系管理员!\")</script>";
} else {
    if ($num == 0 && !$test_title != '') {
        //-----------这里判断有误-----------
        echo "<p>该章节没有测试题</p>";
    } else {
        $list = array();
        while ($settings = $result->fetch_assoc()) {
            //读取为关联数组,读取一次指针向前移动一位
            array_push($list, $settings);