Advertisement
Guest User

Page.class.php

a guest
Jun 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <?php
  2. /*
  3. * Written by Lazcano
  4. */
  5. include $_SERVER['DOCUMENT_ROOT'].'./System/Classes/bitwise.class.php';
  6.  
  7. /*
  8. * Page File
  9. */
  10.  
  11. class Page extends BitwiseFlag
  12. {
  13. /* Flags */
  14. const PAGE_PRESENT = 1;
  15. const PAGE_EXECUTABLE = 2;
  16. const PAGE_NOT_PRESENT = 4;
  17. const PAGE_NOT_EXECUTABLE = 8;
  18.  
  19. /* Constants */
  20. const BUFFER_SIZE = 4096 * 3;
  21.  
  22. /* Members */
  23. public $className;
  24. private $access;
  25. private $buffer;
  26. private $cached;
  27. private $log;
  28. private $content;
  29.  
  30. /*
  31. * Method constructor - Prepares page
  32. * @Parameters: string $className, string $source, array $params
  33. */
  34.  
  35. public function __construct($className, $source, $attributes, $params = null)
  36. {
  37. $this->className = $className;
  38.  
  39. if(array_key_exists('PRESENT', $attributes) && $attributes['PRESENT'] != false)
  40. $this->setFlag(self::PAGE_PRESENT, $attributes['PRESENT']);
  41. if(array_key_exists('EXECUTABLE', $attributes) && $attributes['EXECUTABLE'] != false)
  42. $this->setFlag(self::PAGE_EXECUTABLE, $attributes['EXECUTABLE']);
  43.  
  44. if($params != null)
  45. {
  46. $access = $params['options']['access'];
  47. $cached = $params['options']['cached'];
  48. $log = $params['options']['log'];
  49.  
  50. $this->access = $access;
  51. $this->cached = $cached;
  52. $this->log = $log;
  53. }
  54.  
  55. $this->buffer = file_get_contents($source);
  56. }
  57.  
  58. /*
  59. * Method Display - Display Template
  60. * @Parameters: string $content_replace
  61. */
  62.  
  63. public function display($content_replace)
  64. {
  65.  
  66. if(!$this->isFlagSet(self::PAGE_PRESENT))
  67. die('Page not Present');
  68. if(!$this->isFlagSet(self::PAGE_EXECUTABLE))
  69. die('Page not Executable');
  70. $this->content = strtr($this->buffer, $content_replace);
  71. echo $this->content;
  72.  
  73. exit(0);
  74. }
  75. }
  76.  
  77. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement