LongToIPv4TransformationsPlugin.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the transformations interface */
  13. require_once 'libraries/plugins/TransformationsPlugin.class.php';
  14. /**
  15. * Provides common methods for all of the long to IPv4 transformations plugins.
  16. *
  17. * @package PhpMyAdmin
  18. */
  19. abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin
  20. {
  21. /**
  22. * Gets the transformation description of the specific plugin
  23. *
  24. * @return string
  25. */
  26. public static function getInfo()
  27. {
  28. return __(
  29. 'Converts an (IPv4) Internet network address into a string in'
  30. . ' Internet standard dotted format.'
  31. );
  32. }
  33. /**
  34. * Does the actual work of each specific transformations plugin.
  35. *
  36. * @param string $buffer text to be transformed
  37. * @param array $options transformation options
  38. * @param string $meta meta information
  39. *
  40. * @return void
  41. */
  42. public function applyTransformation($buffer, $options = array(), $meta = '')
  43. {
  44. if ($buffer < 0 || $buffer > 4294967295) {
  45. return htmlspecialchars($buffer);
  46. }
  47. return long2ip($buffer);
  48. }
  49. /**
  50. * This method is called when any PluginManager to which the observer
  51. * is attached calls PluginManager::notify()
  52. *
  53. * @param SplSubject $subject The PluginManager notifying the observer
  54. * of an update.
  55. *
  56. * @todo implement
  57. * @return void
  58. */
  59. public function update (SplSubject $subject)
  60. {
  61. ;
  62. }
  63. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  64. /**
  65. * Gets the transformation name of the specific plugin
  66. *
  67. * @return string
  68. */
  69. public static function getName()
  70. {
  71. return "Long To IPv4";
  72. }
  73. }
  74. ?>