PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/php/so/octopus/control/diff.php

http://timoseven.googlecode.com/
PHP | 418 lines | 362 code | 14 blank | 42 comment | 53 complexity | f1440c2b1094fd838223de0455f12dba MD5 | raw file
Possible License(s): MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-3.0, AGPL-1.0
  1. <?php
  2. #Timo Seven (timoqi@sohu-inc.com)
  3. #2010-10-08
  4. include("header.php");
  5. include("cidr2range.php");
  6. function echoColAvgInfo($avginfo) {
  7. if ($avginfo <= 50) {
  8. echo "<p style=\"background-color:#FF0000\">$avginfo</p>";
  9. }
  10. else if ($avginfo > 50 && $avginfo <= 55) {
  11. echo "<p style=\"background-color:#FA9601\">$avginfo</p>";
  12. }
  13. else if ($avginfo > 55 && $avginfo <= 60) {
  14. echo "<p style=\"background-color:#F4D745\">$avginfo</p>";
  15. }
  16. else if ($avginfo > 60 && $avginfo <= 65) {
  17. echo "<p style=\"background-color:#D4F36F\">$avginfo</p>";
  18. }
  19. else if ($avginfo > 65 && $avginfo <= 70) {
  20. echo "<p style=\"background-color:#8AF36F\">$avginfo</p>";
  21. }
  22. else if ($avginfo > 70 && $avginfo <= 75) {
  23. echo "<p style=\"background-color:#15E9B8\">$avginfo</p>";
  24. }
  25. else {
  26. echo "<p style=\"background-color:#0A74ED\">$avginfo</p>";
  27. }
  28. }
  29. ?>
  30. <html>
  31. <head>
  32. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  33. <title>??????</title>
  34. </head>
  35. <body>
  36. <form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>">
  37. <table width="996" height="127" border="1">
  38. <tr>
  39. <td width="184"><div align="center">???</div></td>
  40. <td width="169"><div align="center">??</div></td>
  41. <td width="211"><div align="center">IP?</div></td>
  42. <td width="199"><div align="center">???1</div></td>
  43. <td width="199"><div align="center">???2</div></td>
  44. </tr>
  45. <tr>
  46. <td>
  47. <label>
  48. <div align="center">?????
  49. <select name="ISP">
  50. <?php
  51. $sql="SELECT distinct ISP from iplist";
  52. $result = mysql_query($sql);
  53. if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
  54. $subisp = $_REQUEST['ISP'];
  55. echo "<option value=\"$subisp\">$subisp</option>";
  56. $sql1 = "SELECT distinct ISP from iplist where ISP <> '$subisp'";
  57. $result1 = mysql_query($sql1);
  58. while($record = mysql_fetch_array($result1)) {
  59. echo "<option value=\"$record[ISP]\">$record[ISP]</option>";
  60. }
  61. }
  62. else {
  63. while($record = mysql_fetch_array($result)) {
  64. echo "<option value=\"$record[ISP]\">$record[ISP]</option>";
  65. }
  66. }
  67. ?>
  68. </select>
  69. </div>
  70. </label>
  71. </td>
  72. <td>
  73. <label>
  74. <div align="center">????
  75. <select name="area[]" multiple="multiple">
  76. <?php
  77. $sql="SELECT distinct province from iplist order by province";
  78. $result = mysql_query($sql);
  79. while($record = mysql_fetch_array($result)) {
  80. echo "<option value=\"$record[province]\">$record[province]</option>";
  81. }
  82. ?>
  83. </select>
  84. </div>
  85. </label>
  86. </td>
  87. <td>
  88. <label>
  89. <div align="center">
  90. <input type="submit" name="submit" value="??????">
  91. <p><input type="submit" name="sort1" value="?????1????"></p>
  92. <p><input type="submit" name="sort2" value="?????2????"></p>
  93. </div>
  94. </label>
  95. </td>
  96. <td>
  97. <label>
  98. <div align="center">?????
  99. <select name="test1">
  100. <?php
  101. $sql="select distinct bestregion from stat order by bestregion";
  102. $result = mysql_query($sql);
  103. if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
  104. $subtest1 = $_REQUEST['test1'];
  105. echo "<option value=\"$subtest1\">$subtest1</option>";
  106. $sql1="select distinct bestregion from stat where bestregion <> '$subtest1' order by bestregion";
  107. $result1 = mysql_query($sql1);
  108. while($record = mysql_fetch_array($result1)) {
  109. echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
  110. }
  111. }
  112. else {
  113. while($record = mysql_fetch_array($result)) {
  114. echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
  115. }
  116. }
  117. ?>
  118. </select>
  119. </div>
  120. </label>
  121. </td>
  122. <td>
  123. <label>
  124. <div align="center">?????
  125. <select name="test2">
  126. <?php
  127. $sql="select distinct bestregion from stat order by bestregion";
  128. $result = mysql_query($sql);
  129. if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
  130. $subtest2 = $_REQUEST['test2'];
  131. echo "<option value=\"$subtest2\">$subtest2</option>";
  132. $sql1="select distinct bestregion from stat where bestregion <> '$subtest2' order by bestregion";
  133. $result1 = mysql_query($sql1);
  134. while($record = mysql_fetch_array($result1)) {
  135. echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
  136. }
  137. }
  138. else {
  139. while($record = mysql_fetch_array($result)) {
  140. echo "<option value=\"$record[bestregion]\">$record[bestregion]</option>";
  141. }
  142. }
  143. ?>
  144. </select>
  145. </div>
  146. </label>
  147. </td>
  148. </tr>
  149. <tr>
  150. <td>
  151. <div align="center">
  152. <?php
  153. if (isset($_POST['submit']) || isset($_POST['sort1']) ||isset($_POST['sort2'])) {
  154. echo $_REQUEST['ISP'];
  155. $subisp = $_REQUEST['ISP'];
  156. }
  157. ?>
  158. </div>
  159. </td>
  160. <td>
  161. <div align="center">
  162. <?php
  163. /* if (isset($_POST['submit'])) {
  164. $subarea = $_REQUEST['area'];
  165. echo "<br>";
  166. echo "<br>";
  167. foreach($subarea as $subareas) {
  168. echo "<p>$subareas</p>";
  169. }
  170. }
  171. */
  172. if (isset($_POST['sort1']) || isset($_POST['sort2']) || isset($_POST['submit'])) {
  173. $subtest1 = $_REQUEST['test1'];
  174. $subtest2 = $_REQUEST['test2'];
  175. $subisp = $_REQUEST['ISP'];
  176. $subarea = $_REQUEST['area'];
  177. $arrayAvg1 = array();
  178. $arrayAvg2 = array();
  179. $allarray = array();
  180. $allNewarray = array();
  181. global $arrayAvg1;
  182. global $arrayAvg2;
  183. global $allarray;
  184. global $allNewarray;
  185. global $rowNum;
  186. global $colNum;
  187. echo "<br>";
  188. foreach($subarea as $subareas) {
  189. #echo "<p>$subareas</p>";
  190. $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'";
  191. $result = mysql_query($sql);
  192. $infoarray1 = array();
  193. $infoarray2 = array();
  194. while($record = mysql_fetch_assoc($result)) {
  195. preg_match("/$subtest1:([.0-9]+)/", $record[info],$arr);
  196. $subinfo1 = $arr[1];
  197. array_push($infoarray1,"$subinfo1");
  198. preg_match("/$subtest2:([.0-9]+)/", $record[info],$arr);
  199. $subinfo2 = $arr[1];
  200. array_push($infoarray2,"$subinfo2");
  201. }
  202. $countinfo1 = count($infoarray1);
  203. $suminfo1 = array_sum($infoarray1);
  204. $avginfo1 = round($suminfo1/$countinfo1,2);
  205. #echo $avginfo1;
  206. array_push($arrayAvg1,"$avginfo1");
  207. $countinfo2 = count($infoarray2);
  208. $suminfo2 = array_sum($infoarray2);
  209. $avginfo2 = round($suminfo2/$countinfo2,2);
  210. array_push($arrayAvg2,"$avginfo2");
  211. }
  212. $allarray = array($subarea,$arrayAvg1,$arrayAvg2);
  213. # print_r($allarray);
  214. $rowNum = count($allarray);
  215. $colNum = count($subarea);
  216. # echo $rowNum;
  217. # echo $colNum;
  218. for($i=0;$i<$rowNum;$i++){
  219. for($j=0;$j<$colNum;$j++){
  220. $allNewarray[$j][$i] = $allarray[$i][$j];
  221. }
  222. }
  223. }
  224. if (isset($_POST['submit'])) {
  225. foreach ($allNewarray as $key => $row) {
  226. $area[] = $row[0];
  227. $test1[] = $row[1];
  228. $test2[] = $row[2];
  229. }
  230. array_multisort($area, SORT_ASC, $allNewarray);
  231. # print_r($allNewarray);
  232. for($i=0;$i<$colNum;$i++){
  233. $temp = $allNewarray[$i][0];
  234. echo "<p>$temp</p>";
  235. }
  236. }
  237. if (isset($_POST['sort1'])) {
  238. foreach ($allNewarray as $key => $row) {
  239. $area[] = $row[0];
  240. $test1[] = $row[1];
  241. $test2[] = $row[2];
  242. }
  243. array_multisort($test1, SORT_DESC, $allNewarray);
  244. # print_r($allNewarray);
  245. for($i=0;$i<$colNum;$i++){
  246. $temp = $allNewarray[$i][0];
  247. echo "<p>$temp</p>";
  248. }
  249. }
  250. if (isset($_POST['sort2'])) {
  251. foreach ($allNewarray as $key => $row) {
  252. $area[] = $row[0];
  253. $test1[] = $row[1];
  254. $test2[] = $row[2];
  255. }
  256. array_multisort($test2, SORT_DESC, $allNewarray);
  257. # print_r($allNewarray);
  258. for($i=0;$i<$colNum;$i++){
  259. $temp = $allNewarray[$i][0];
  260. echo "<p>$temp</p>";
  261. }
  262. }
  263. ?>
  264. </div>
  265. </td>
  266. <td>
  267. <div align="center">
  268. <?php
  269. $count = sizeof($subarea);
  270. if ($count < 2) {
  271. foreach($subarea as $subareas) {
  272. $sql="select subnet from iplist where province='$subareas' and ISP='$subisp' order by subnet";
  273. $result = mysql_query($sql);
  274. while($record = mysql_fetch_array($result)) {
  275. echo "<br>$record[subnet]";
  276. }
  277. }
  278. }
  279. else {
  280. echo "????[$count]???????";
  281. }
  282. ?>
  283. </div>
  284. </td>
  285. <td>
  286. <div align="center">
  287. <?php
  288. if (isset($_POST['submit'])) {
  289. foreach ($allNewarray as $key => $row) {
  290. $area[] = $row[0];
  291. $test1[] = $row[1];
  292. $test2[] = $row[2];
  293. }
  294. array_multisort($area, SORT_ASC, $allNewarray);
  295. # print_r($allNewarray);
  296. echo $_REQUEST['test1'];
  297. for($i=0;$i<$colNum;$i++){
  298. $avginfo = $allNewarray[$i][1];
  299. echoColAvgInfo($avginfo);
  300. }
  301. }
  302. if (isset($_POST['sort1'])) {
  303. foreach ($allNewarray as $key => $row) {
  304. $area[] = $row[0];
  305. $test1[] = $row[1];
  306. $test2[] = $row[2];
  307. }
  308. array_multisort($test1, SORT_DESC, $allNewarray);
  309. echo $_REQUEST['test1'];
  310. for($i=0;$i<$colNum;$i++){
  311. $avginfo = $allNewarray[$i][1];
  312. echoColAvgInfo($avginfo);
  313. }
  314. }
  315. if (isset($_POST['sort2'])) {
  316. foreach ($allNewarray as $key => $row) {
  317. $area[] = $row[0];
  318. $test1[] = $row[1];
  319. $test2[] = $row[2];
  320. }
  321. array_multisort($test2, SORT_DESC, $allNewarray);
  322. echo $_REQUEST['test1'];
  323. for($i=0;$i<$colNum;$i++){
  324. $avginfo = $allNewarray[$i][1];
  325. echoColAvgInfo($avginfo);
  326. }
  327. }
  328. ?>
  329. </div>
  330. </td>
  331. <td>
  332. <div align="center">
  333. <?php
  334. if (isset($_POST['submit'])) {
  335. foreach ($allNewarray as $key => $row) {
  336. $area[] = $row[0];
  337. $test1[] = $row[1];
  338. $test2[] = $row[2];
  339. }
  340. array_multisort($area, SORT_ASC, $allNewarray);
  341. # print_r($allNewarray);
  342. echo $_REQUEST['test2'];
  343. for($i=0;$i<$colNum;$i++){
  344. $avginfo = $allNewarray[$i][2];
  345. echoColAvgInfo($avginfo);
  346. }
  347. }
  348. if (isset($_POST['sort1'])) {
  349. foreach ($allNewarray as $key => $row) {
  350. $area[] = $row[0];
  351. $test1[] = $row[1];
  352. $test2[] = $row[2];
  353. }
  354. array_multisort($test1, SORT_DESC, $allNewarray);
  355. # print_r($allNewarray);
  356. echo $_REQUEST['test2'];
  357. for($i=0;$i<$colNum;$i++){
  358. $avginfo = $allNewarray[$i][2];
  359. echoColAvgInfo($avginfo);
  360. }
  361. }
  362. if (isset($_POST['sort2'])) {
  363. foreach ($allNewarray as $key => $row) {
  364. $area[] = $row[0];
  365. $test1[] = $row[1];
  366. $test2[] = $row[2];
  367. }
  368. array_multisort($test2, SORT_DESC, $allNewarray);
  369. # print_r($allNewarray);
  370. echo $_REQUEST['test2'];
  371. for($i=0;$i<$colNum;$i++){
  372. $avginfo = $allNewarray[$i][2];
  373. echoColAvgInfo($avginfo);
  374. }
  375. }
  376. # if (isset($_POST['sort1']) || isset($_POST['sort2']) || isset($_POST['submit'])) {
  377. # foreach ($allNewarray as $key => $row) {
  378. # $area[] = $row[0];
  379. # $test1[] = $row[1];
  380. # $test2[] = $row[2];
  381. # }
  382. # for($i=0;$i<$colNum;$i++){
  383. # $avginfo = $allNewarray[$i][2];
  384. # $mysqlArea = $allNewarray[$i][0];
  385. # $sql = "insert into `region_score` (`province`,`isp`,`region`,`score`) values ('{$mysqlArea}','{$subisp}','{$subtest2}',{$avginfo})";
  386. # mysql_query($sql);
  387. # }
  388. # for($i=0;$i<$colNum;$i++){
  389. # $avginfo = $allNewarray[$i][1];
  390. # $mysqlArea = $allNewarray[$i][0];
  391. # $sql = "insert into `region_score` (`province`,`isp`,`region`,`score`) values ('{$mysqlArea}','{$subisp}','{$subtest1}',{$avginfo})";
  392. # mysql_query($sql);
  393. # }
  394. # }
  395. ?>
  396. </td>
  397. </tr>
  398. </table>
  399. </form>
  400. </body>
  401. </html>
  402. <?php
  403. include("footer.php");
  404. ?>