@
raysonx 找到了,非常感谢!
1412 switch ($pdval) {
1413 // For PD sizes of /60 through /64, the user must do the math!
1414 case 60:
1415 case 62:
1416 case 63:
1417 case 64: // 3&4th bytes on 4th array
1418 $pd_prefix_from_array_out[3] = sprintf("%04s", $ifcfgipv6arr[3]); // make it 4 bytes
1419 $pd_prefix_from_array_out[3] = substr($pd_prefix_from_array_out[3], 0, 2) . $pd_prefix_from_array[2];
1420 $pd_prefix_to_array_out[3] = sprintf("%04s", $ifcfgipv6arr[3]); // make it 4 bytes
1421 $pd_prefix_to_array_out[3] = substr($pd_prefix_to_array_out[3], 0, 2) . $pd_prefix_to_array[2];
1422 break;
1423 case 56: // 1st&2nd bytes on 4th array
1424 $pd_prefix_from_array[2] = str_pad($pd_prefix_from_array[2], 4, "0");
1425 $pd_prefix_from_array_out[3] = sprintf("%s", $pd_prefix_from_array[2]); // make it 4 bytes
1426 $pd_prefix_to_array[2] = str_pad($pd_prefix_to_array[2], 4, "0");
1427 $pd_prefix_to_array_out[3] = sprintf("%s", $pd_prefix_to_array[2]); // make it 4 bytes
1428 break;
1429 case 52: // 1st byte on 4th array only, 0 to f, we only want one byte, but lookout for the user entering more
1430 $len = strlen($pd_prefix_from_array[2]);
1431 $pd_prefix_from_array[2] = substr($pd_prefix_from_array[2], $len - 1, 1);
1432 $pd_prefix_from_array_out[3] = sprintf("%s000", substr($pd_prefix_from_array[2], 0, 1)); // first byte from entered value
1433 $len = strlen($pd_prefix_to_array[2]);
1434 $pd_prefix_to_array[2] = substr($pd_prefix_to_array[2], $len - 1, 1);
1435 $pd_prefix_to_array_out[3] = sprintf("%s000", substr($pd_prefix_to_array[2], 0, 1));
1436 break;
1437 case 48: // 4th byte on 2nd array
1438 $pd_prefix_from_array[2] = substr($pd_prefix_from_array[2], 0, 1);
1439 $pd_prefix_from_array_out[1] = substr(sprintf("%03s", $ifcfgipv6arr[1]), 0, 3) . $pd_prefix_from_array[2]; // get 1st 3 byte + nibble
1440 $pd_prefix_to_array[2] = substr($pd_prefix_to_array[2], 0, 1);
1441 $pd_prefix_to_array_out[1] = substr(sprintf("%03s", $ifcfgipv6arr[1]), 0, 3) . $pd_prefix_to_array[2]; // get 1st 3 byte + nibble
1442 break;
1443 }