Supernetting PHP 實做-2

asdf
<?php
asdf

sfdfd

<?php $time_start = microtime(true);

/**  * Initial  *  * */ $start = $_POST[“start"]; $Origin = $_POST[“Origin"]; $Join = $_POST[“Join"]; $Percentage = $_POST[“Percentage"]; $masktype = $_POST[“masktype"]; $is_debug = $_POST[“is_debug"]; $testType = $_GET[“testType"]; $TFile[“default"][“O"] = “./example/Origin.txt"; $TFile[“default"][“J"] = “./example/Join.simple.txt"; $TFile[“mask"][“O"] = “./example/Origin_mask.txt"; $TFile[“mask"][“J"] = “./example/Join.simple_mask.txt"; $TFile[“full"][“O"] = “./example/Origin.txt"; $TFile[“full"][“J"] = “./example/Join.full.txt"; $TFile[“waste"][“O"] = “./example/origin-waste.txt"; $TFile[“waste"][“J"] = “./example/join-waste.txt";

include(“./libs/supernetting_func.php");

if(trim($start) == NULL) {  if($testType == NULL) $testType = “default";    $TestFile = $TFile[$testType];    $fp = fopen($TestFile[“O"], “r");  $Origin =  fread($fp, filesize($TestFile[“O"]));    $fp = fopen($TestFile[“J"], “r");  $Join =  fread($fp, filesize($TestFile[“J"]));    } else {  $OriginList = explode(“\r\n", $Origin);  $JoinList = explode(“\r\n", $Join);    $Supernetting = new Supernetting();  $Supernetting->setMaskType($masktype);  if($is_debug == “yes") $Supernetting->enableDebug();  $Supernetting->start($OriginList, $JoinList, $Percentage / 100);  //$Supernetting->aggregateSupernetting($OriginList, $JoinList, $Percentage / 100);      $Origin = $Supernetting->getOrigin();  $Join = $Supernetting->getJoin();  $ResultList = $Supernetting->getResultList();  $AddList = $Supernetting->getAddList();  $DeleteList = $Supernetting->getDeleteList();

$AddMessage = $Supernetting->AddMessage;  $DeleteMessage = $Supernetting->DeleteMessage; }

$time_end = microtime(true);

?>

<html> <head> <title>Supernetting</title> <link type="text/css" href="./css/supernetting.css" rel="stylesheet" />     </head> <body>

<form method=POST action="<?php echo $_SERVER[“PHP_SELF"]; ?>"> <table> <tr>  <th colspan=6 style="color:#F00;"><?php echo $Supernetting->errorMessage; ?></th> </tr> <tr>  <th colspan=6>Supernetting.    Use Case:   {    <a href="./supernetting.php?testType=default">Default</a>,    <a href="./supernetting.php?testType=full">Full</a>,    <a href="./supernetting.php?testType=waste">IP waste</a>,    <a href="./supernetting.php?testType=mask">Mask</a>   }  </th> </tr> <tr>  <td>Origin</td>  <td>Join</td>  <td style="background-color: #BAD2BA" rowspan=2></td>  <td>Result</td>  <td>Add</td>  <td>Delete</td> </tr> <tr>  <td><textarea name="Origin" cols=32 rows=30><?php echo (!is_array($Origin))?$Origin:implode(“\n", $Origin); ?></textarea></td>  <td><textarea name="Join" cols=32 rows=30><?php echo (!is_array($Join))?$Join:implode(“\n", $Join); ?></textarea></td>  <td><textarea cols=32 rows=30><?php echo (!is_array($ResultList))?"":implode(“\n", $ResultList); ?></textarea></td>  <td><textarea cols=32 rows=30><?php echo (!is_array($AddList))?"":implode(“\n", $AddList); ?></textarea></td>  <td><textarea cols=32 rows=30><?php echo (!is_array($DeleteList))?"":implode(“\n", $DeleteList); ?></textarea></td> </tr> <tr>  <th colspan=6>   Convert mask:    <input type=radio name="masktype" value=cidr <?php echo ($masktype == “cidr" or empty($masktype))?"checked":"" ?> > CIDR    <input type=radio name=masktype value=mask <?php echo ($masktype == “mask")?"checked":"" ?> > Mask  </th> </tr> <tr>  <th colspan=6>Percentage: <input type=text name="Percentage" value="<?php echo ($Percentage < 1)?20:$Percentage; ?>" >% </th> </tr> <tr>  <th colspan=6>   Spend Time(sec): <?php echo round($time_end – $time_start, 3); ?>   Debug: <input type="checkbox" name="is_debug" value="yes" <?php echo ($is_debug == “yes")?"checked":"" ?>>    </th> </tr><tr>  <th colspan=6> <input type=submit name=start value=Go> </th> </tr> </table>

<?php

if($is_debug != “yes")  ; else {  //echo json_encode($AddMessage);  //echo json_encode($DeleteMessage);  echo “<hr />"   ."<table>"    ."<tr>"     ."<td colspan=\"2\" style=\"font-weight:bold;text-align:center;\">Debug Information</td>"    ."</tr>";    if($masktype != NULL AND $masktype != “cidr")   echo “<tr>"     ."<td colspan=\"2\" style=\"font-weight:bold;text-align:center;color:#F00;\">Debug mode only support CIDR. </td>"    ."</tr>";   else  {   echo  “<tr>"        ."<td style=\"font-weight:bold;text-align:center;\">Add List</td>"      ."<td style=\"font-weight:bold;text-align:center;\">Delete List</td>"     ."</tr>"     ."<tr>";       echo “<td style=\"text-align:left;\">";   @reset($AddList);   while(list($key, $thisValue) = @each($AddList))   {    echo “[“.$thisValue."]<br />";    @ksort($AddMessage[$thisValue], SORT_NATURAL);    @reset($AddMessage[$thisValue]);    while(list($key2, $Value2) = @each($AddMessage[$thisValue]))    {     echo " … from “.$key2."<br />";    }     }   echo “</td>";      echo “<td style=\"text-align:left;\">";   @reset($DeleteList);   while(list($key, $thisValue) = @each($DeleteList))   {    echo “[“.$thisValue."]<br />";    @ksort($DeleteMessage[$thisValue], SORT_NATURAL);    @reset($DeleteMessage[$thisValue]);    while(list($key2, $Value2) = @each($DeleteMessage[$thisValue]))    {     echo " … to “.$key2."<br />";    }   }   echo “</td>";  }    echo “</tr></table>"; }

?>

</body> </html>


	

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

w

連結到 %s