/php/so/octopus/diff.php
PHP | 418 lines | 362 code | 14 blank | 42 comment | 53 complexity | f8f92df5bb6fd8d8fe23e1c39f5d9ac7 MD5 | raw file
Possible License(s): MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-3.0, AGPL-1.0
- <?php
- #Timo Seven (timoqi@sohu-inc.com)
- #2010-10-08
- include("header.php");
- include("cidr2range.php");
-
- function echoColAvgInfo($avginfo) {
- if ($avginfo <= 50) {
- echo "<p style=\"background-color:#FF0000\">$avginfo</p>";
- }
- else if ($avginfo > 50 && $avginfo <= 55) {
- echo "<p style=\"background-color:#FA9601\">$avginfo</p>";
- }
- else if ($avginfo > 55 && $avginfo <= 60) {
- echo "<p style=\"background-color:#F4D745\">$avginfo</p>";
- }
- else if ($avginfo > 60 && $avginfo <= 65) {
- echo "<p style=\"background-color:#D4F36F\">$avginfo</p>";
- }
- else if ($avginfo > 65 && $avginfo <= 70) {
- echo "<p style=\"background-color:#8AF36F\">$avginfo</p>";
- }
- else if ($avginfo > 70 && $avginfo <= 75) {
- echo "<p style=\"background-color:#15E9B8\">$avginfo</p>";
- }
- else {
- echo "<p style=\"background-color:#0A74ED\">$avginfo</p>";
- }
- }
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>??????</title>
- </head>
- <body>
- <form id="form1" name="form1" method="post" action="<? $_SERVER['PHP_SELF']?>">
- <table width="996" height="127" border="1">
- <tr>
- <td width="184"><div align="center">???</div></td>
- <td width="169"><div align="center">??</div></td>
- <td width="211"><div align="center">IP?</div></td>
- <td width="199"><div align="center">???1</div></td>
- <td width="199"><div align="center">???2</div></td>
- </tr>
- <tr>
- <td>
- <label>
- <div align="center">?????
- <select name="ISP">
- <?php
- $sql="SELECT distinct ISP from iplist";
- $result = mysql_query($sql);
- if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
- $subisp = $_REQUEST['ISP'];
- echo "<option value=\"$subisp\">$subisp</option>";
- $sql1 = "SELECT distinct ISP from iplist where ISP <> '$subisp'";
- $result1 = mysql_query($sql1);
- while($record = mysql_fetch_array($result1)) {
- echo "<option value=\"$record[ISP]\">$record[ISP]</option>";
- }
- }
- else {
- while($record = mysql_fetch_array($result)) {
- echo "<option value=\"$record[ISP]\">$record[ISP]</option>";
- }
- }
- ?>
- </select>
- </div>
- </label>
- </td>
- <td>
- <label>
- <div align="center">????
- <select name="area[]" multiple="multiple">
- <?php
- $sql="SELECT distinct province from iplist order by province";
- $result = mysql_query($sql);
- while($record = mysql_fetch_array($result)) {
- echo "<option value=\"$record[province]\">$record[province]</option>";
- }
- ?>
- </select>
- </div>
- </label>
- </td>
- <td>
- <label>
- <div align="center">
- <input type="submit" name="submit" value="??????">
- <p><input type="submit" name="sort1" value="?????1????"></p>
- <p><input type="submit" name="sort2" value="?????2????"></p>
- </div>
- </label>
- </td>
- <td>
- <label>
- <div align="center">?????
- <select name="test1">
- <?php
- $sql="select distinct bestregion from stat order by bestregion";
- $result = mysql_query($sql);
- if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
- $subtest1 = $_REQUEST['test1'];
- echo "<option value=\"$subtest1\">$subtest1</option>";
- $sql1="select distinct bestregion from stat where bestregion <> '$subtest1' order by bestregion";
- $result1 = mysql_query($sql1);
- while($record = mysql_fetch_array($result1)) {
- echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
- }
- }
- else {
- while($record = mysql_fetch_array($result)) {
- echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
- }
- }
- ?>
- </select>
- </div>
- </label>
- </td>
- <td>
- <label>
- <div align="center">?????
- <select name="test2">
- <?php
- $sql="select distinct bestregion from stat order by bestregion";
- $result = mysql_query($sql);
- if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
- $subtest2 = $_REQUEST['test2'];
- echo "<option value=\"$subtest2\">$subtest2</option>";
- $sql1="select distinct bestregion from stat where bestregion <> '$subtest2' order by bestregion";
- $result1 = mysql_query($sql1);
- while($record = mysql_fetch_array($result1)) {
- echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
- }
- }
- else {
- while($record = mysql_fetch_array($result)) {
- echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
- }
- }
- ?>
- </select>
- </div>
- </label>
- </td>
- </tr>
- <tr>
- <td>
- <div align="center">
- <?php
- if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
- echo $_REQUEST['ISP'];
- $subisp = $_REQUEST['ISP'];
- }
- ?>
- </div>
- </td>
- <td>
- <div align="center">
- <?php
- /* if (isset($_POST['submit'])) {
- $subarea = $_REQUEST['area'];
- echo "<br>";
- echo "<br>";
- foreach($subarea as $subareas) {
- echo "<p>$subareas</p>";
- }
- }
- */
- if (isset($_POST['sort1']) || isset($_POST['sort2']) || isset($_POST['submit'])) {
- $subtest1 = $_REQUEST['test1'];
- $subtest2 = $_REQUEST['test2'];
- $subisp = $_REQUEST['ISP'];
- $subarea = $_REQUEST['area'];
- $arrayAvg1 = array();
- $arrayAvg2 = array();
- $allarray = array();
- $allNewarray = array();
- global $arrayAvg1;
- global $arrayAvg2;
- global $allarray;
- global $allNewarray;
- global $rowNum;
- global $colNum;
- echo "<br>";
- foreach($subarea as $subareas) {
- #echo "<p>$subareas</p>";
- $sql="select info from stat as a left join iplist as b on a.netname=b.NETNAME where b.ISP='$subisp' and b.province='$subareas'";
- $result = mysql_query($sql);
- $infoarray1 = array();
- $infoarray2 = array();
-
-
- while($record = mysql_fetch_assoc($result)) {
- preg_match("/$subtest1:([.0-9]+)/", $record[info],$arr);
- $subinfo1 = $arr[1];
- array_push($infoarray1,"$subinfo1");
- preg_match("/$subtest2:([.0-9]+)/", $record[info],$arr);
- $subinfo2 = $arr[1];
- array_push($infoarray2,"$subinfo2");
- }
-
- $countinfo1 = count($infoarray1);
- $suminfo1 = array_sum($infoarray1);
- $avginfo1 = round($suminfo1/$countinfo1,2);
- #echo $avginfo1;
- array_push($arrayAvg1,"$avginfo1");
-
- $countinfo2 = count($infoarray2);
- $suminfo2 = array_sum($infoarray2);
- $avginfo2 = round($suminfo2/$countinfo2,2);
- array_push($arrayAvg2,"$avginfo2");
-
-
- }
- $allarray = array($subarea,$arrayAvg1,$arrayAvg2);
- # print_r($allarray);
-
- $rowNum = count($allarray);
- $colNum = count($subarea);
- # echo $rowNum;
- # echo $colNum;
- for($i=0;$i<$rowNum;$i++){
- for($j=0;$j<$colNum;$j++){
- $allNewarray[$j][$i] = $allarray[$i][$j];
- }
- }
- }
- if (isset($_POST['submit'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($area, SORT_ASC, $allNewarray);
- # print_r($allNewarray);
- for($i=0;$i<$colNum;$i++){
- $temp = $allNewarray[$i][0];
- echo "<p>$temp</p>";
- }
- }
-
- if (isset($_POST['sort1'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test1, SORT_DESC, $allNewarray);
- # print_r($allNewarray);
- for($i=0;$i<$colNum;$i++){
- $temp = $allNewarray[$i][0];
- echo "<p>$temp</p>";
- }
- }
- if (isset($_POST['sort2'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test2, SORT_DESC, $allNewarray);
- # print_r($allNewarray);
- for($i=0;$i<$colNum;$i++){
- $temp = $allNewarray[$i][0];
- echo "<p>$temp</p>";
- }
- }
- ?>
- </div>
- </td>
- <td>
- <div align="center">
- <?php
- $count = sizeof($subarea);
- if ($count < 2) {
- foreach($subarea as $subareas) {
- $sql="select subnet from iplist where province='$subareas' and ISP='$subisp' order by subnet";
- $result = mysql_query($sql);
- while($record = mysql_fetch_array($result)) {
- echo "<br>$record[subnet]";
- }
- }
- }
- else {
- echo "????[$count]???????";
- }
- ?>
- </div>
- </td>
- <td>
- <div align="center">
- <?php
- if (isset($_POST['submit'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($area, SORT_ASC, $allNewarray);
- # print_r($allNewarray);
- echo $_REQUEST['test1'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][1];
- echoColAvgInfo($avginfo);
- }
- }
- if (isset($_POST['sort1'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test1, SORT_DESC, $allNewarray);
- echo $_REQUEST['test1'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][1];
- echoColAvgInfo($avginfo);
- }
- }
- if (isset($_POST['sort2'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test2, SORT_DESC, $allNewarray);
- echo $_REQUEST['test1'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][1];
- echoColAvgInfo($avginfo);
- }
- }
- ?>
- </div>
- </td>
- <td>
- <div align="center">
- <?php
- if (isset($_POST['submit'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($area, SORT_ASC, $allNewarray);
- # print_r($allNewarray);
- echo $_REQUEST['test2'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][2];
- echoColAvgInfo($avginfo);
- }
- }
- if (isset($_POST['sort1'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test1, SORT_DESC, $allNewarray);
- # print_r($allNewarray);
- echo $_REQUEST['test2'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][2];
- echoColAvgInfo($avginfo);
- }
- }
- if (isset($_POST['sort2'])) {
- foreach ($allNewarray as $key => $row) {
- $area[] = $row[0];
- $test1[] = $row[1];
- $test2[] = $row[2];
- }
- array_multisort($test2, SORT_DESC, $allNewarray);
- # print_r($allNewarray);
- echo $_REQUEST['test2'];
- for($i=0;$i<$colNum;$i++){
- $avginfo = $allNewarray[$i][2];
- echoColAvgInfo($avginfo);
- }
- }
- # if (isset($_POST['sort1']) || isset($_POST['sort2']) || isset($_POST['submit'])) {
- # foreach ($allNewarray as $key => $row) {
- # $area[] = $row[0];
- # $test1[] = $row[1];
- # $test2[] = $row[2];
- # }
- # for($i=0;$i<$colNum;$i++){
- # $avginfo = $allNewarray[$i][2];
- # $mysqlArea = $allNewarray[$i][0];
- # $sql = "insert into `region_score` (`province`,`isp`,`region`,`score`) values ('{$mysqlArea}','{$subisp}','{$subtest2}',{$avginfo})";
- # mysql_query($sql);
- # }
- # for($i=0;$i<$colNum;$i++){
- # $avginfo = $allNewarray[$i][1];
- # $mysqlArea = $allNewarray[$i][0];
- # $sql = "insert into `region_score` (`province`,`isp`,`region`,`score`) values ('{$mysqlArea}','{$subisp}','{$subtest1}',{$avginfo})";
- # mysql_query($sql);
- # }
- # }
- ?>
- </td>
- </tr>
- </table>
- </form>
- </body>
- </html>
- <?php
- include("footer.php");
- ?>