server.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * Load Server Data
  55. *
  56. * @author Michal Czech <michael@modulesgarden.com>
  57. * @param int $id
  58. * @param array $data
  59. */
  60. function __construct($id = false,$data = array()) {
  61. if($id !== false && empty($data))
  62. {
  63. $data = main\mgLibs\MySQL\query::select(
  64. self::fieldDeclaration()
  65. , self::tableName()
  66. ,array(
  67. 'id' => $id
  68. )
  69. )->fetch();
  70. if(empty($data))
  71. {
  72. throw new main\mgLibs\exceptions\system('Unable to find Item with ID:'.$id);
  73. }
  74. }
  75. if(isset($data['passwordEncrypted']))
  76. {
  77. $data['password'] = decrypt($data['passwordEncrypted']);
  78. }
  79. if(!empty($data))
  80. {
  81. $this->fillProperties($data);
  82. }
  83. }
  84. function save($data = array()){
  85. parent::save(array(
  86. 'password' => encrypt($this->password)
  87. ));
  88. }
  89. }