LongToIPv4TransformationsPlugin.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the long to IPv4 transformations plugins
  5. *
  6. * @package PhpMyAdmin-Transformations
  7. * @subpackage LongToIPv4
  8. */
  9. namespace PhpMyAdmin\Plugins\Transformations\Abs;
  10. use PhpMyAdmin\Plugins\TransformationsPlugin;
  11. /**
  12. * Provides common methods for all of the long to IPv4 transformations plugins.
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin
  17. {
  18. /**
  19. * Gets the transformation description of the specific plugin
  20. *
  21. * @return string
  22. */
  23. public static function getInfo()
  24. {
  25. return __(
  26. 'Converts an (IPv4) Internet network address stored as a BIGINT'
  27. . ' into a string in Internet standard dotted format.'
  28. );
  29. }
  30. /**
  31. * Does the actual work of each specific transformations plugin.
  32. *
  33. * @param string $buffer text to be transformed
  34. * @param array $options transformation options
  35. * @param string $meta meta information
  36. *
  37. * @return string
  38. */
  39. public function applyTransformation($buffer, array $options = array(), $meta = '')
  40. {
  41. if ($buffer < 0 || $buffer > 4294967295) {
  42. return htmlspecialchars($buffer);
  43. }
  44. return long2ip($buffer);
  45. }
  46. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  47. /**
  48. * Gets the transformation name of the specific plugin
  49. *
  50. * @return string
  51. */
  52. public static function getName()
  53. {
  54. return "Long To IPv4";
  55. }
  56. }