server.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace MGModule\DNSManager2\models\whmcs\servers;
  3. use MGModule\DNSManager2 as main;
  4. /**
  5. * Server Model
  6. * @Table(name=tblservers,preventUpdate,prefixed=false)
  7. * @author Michal Czech <michael@modulesgarden.com>
  8. */
  9. class server extends main\mgLibs\models\orm {
  10. /**
  11. * @Column()
  12. * @var int
  13. */
  14. public $id;
  15. /**
  16. * @Column()
  17. * @var string
  18. */
  19. public $hostname;
  20. /**
  21. * @Column(name=ipaddress)
  22. * @var string
  23. */
  24. public $ip;
  25. /**
  26. *
  27. * @Column()
  28. * @var string
  29. */
  30. public $username;
  31. /**
  32. *
  33. * @Column(as=passwordEncrypted)
  34. * @var string
  35. */
  36. public $password;
  37. /**
  38. *
  39. * @Column()
  40. * @var string
  41. */
  42. public $accesshash;
  43. /**
  44. * @Column()
  45. * @var string
  46. */
  47. public $secure;
  48. /**
  49. * @Column(notRequired)
  50. * @var string
  51. */
  52. public $disabled;
  53. /**
  54. * @Column(notRequired)
  55. * @var string
  56. */
  57. public $assignedips;
  58. /**
  59. * Load Server Data
  60. *
  61. * @author Michal Czech <michael@modulesgarden.com>
  62. * @param int $id
  63. * @param array $data
  64. */
  65. function __construct($id = false,$data = array()) {
  66. if($id !== false && empty($data))
  67. {
  68. $data = main\mgLibs\MySQL\query::select(
  69. self::fieldDeclaration()
  70. , self::tableName()
  71. ,array(
  72. 'id' => $id
  73. )
  74. )->fetch();
  75. if(empty($data))
  76. {
  77. throw new main\mgLibs\exceptions\system('Unable to find Item with ID:'.$id);
  78. }
  79. }
  80. if(isset($data['passwordEncrypted']))
  81. {
  82. $data['password'] = decrypt($data['passwordEncrypted']);
  83. }
  84. if(!empty($data))
  85. {
  86. $this->fillProperties($data);
  87. }
  88. }
  89. function save($data = array()){
  90. parent::save(array(
  91. 'password' => encrypt($this->password)
  92. ));
  93. }
  94. }