api.ubconfig.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Basic Ubilling configs abstraction class
  4. */
  5. class UbillingConfig {
  6. //stores system configs
  7. protected $alterCfg = array();
  8. protected $billingCfg = array();
  9. protected $photoCfg = array();
  10. protected $ymapsCfg = array();
  11. public function __construct() {
  12. $this->loadAlter();
  13. $this->loadBilling();
  14. }
  15. /**
  16. * loads system wide alter.ini to private alterCfg prop
  17. *
  18. * @return void
  19. */
  20. protected function loadAlter() {
  21. $this->alterCfg = parse_ini_file(CONFIG_PATH . 'alter.ini');
  22. }
  23. /**
  24. * getter of private alterCfg prop
  25. *
  26. * @return array
  27. */
  28. public function getAlter() {
  29. return ($this->alterCfg);
  30. }
  31. /**
  32. * Parameter getter for alterCfg
  33. * Returns $parameter from alter.ini or FALSE if parameter not defined
  34. * May return $retValIfParamEmptyOrNotExists value, instead of searched $parameter
  35. * if searched $parameter is FALSE (but NOT NULL) or not defined
  36. *
  37. * @param mixed $param
  38. * @param mixed $retValIfParamEmptyOrNotExists
  39. *
  40. * @return mixed
  41. */
  42. public function getAlterParam($param = false, $retValIfParamEmptyOrNotExists = null) {
  43. $alterParam = ($param and isset($this->alterCfg[$param])) ? $this->alterCfg[$param] : false;
  44. if ($alterParam === false and ! is_null($retValIfParamEmptyOrNotExists)) {
  45. $alterParam = $retValIfParamEmptyOrNotExists;
  46. }
  47. return ($alterParam);
  48. }
  49. /**
  50. * loads system wide billing.ini to private alterCfg prop
  51. *
  52. * @return void
  53. */
  54. protected function loadBilling() {
  55. $this->billingCfg = parse_ini_file(CONFIG_PATH . 'billing.ini');
  56. }
  57. /**
  58. * getter of private billingCfg prop
  59. *
  60. * @return array
  61. */
  62. public function getBilling() {
  63. return ($this->billingCfg);
  64. }
  65. /**
  66. * loads system ymaps.ini to private ymapsCfg prop
  67. *
  68. * @return void
  69. */
  70. protected function loadYmaps() {
  71. $this->ymapsCfg = parse_ini_file(CONFIG_PATH . 'ymaps.ini');
  72. }
  73. /**
  74. * getter of private ymapsCfg prop
  75. *
  76. * @return array
  77. */
  78. public function getYmaps() {
  79. if (empty($this->ymapsCfg)) {
  80. $this->loadYmaps();
  81. }
  82. return ($this->ymapsCfg);
  83. }
  84. /**
  85. * loads system photostorage.ini to private photoCfg prop
  86. *
  87. * @return void
  88. */
  89. protected function loadPhoto() {
  90. $this->photoCfg = parse_ini_file(CONFIG_PATH . 'photostorage.ini');
  91. }
  92. /**
  93. * getter of private photoCfg prop
  94. *
  95. * @return array
  96. */
  97. public function getPhoto() {
  98. if (empty($this->photoCfg)) {
  99. $this->loadPhoto();
  100. }
  101. return ($this->photoCfg);
  102. }
  103. }
  104. ?>