You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

database-structure.inc.php 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <?php
  2. $def_tables = array(
  3. array(
  4. 'table_name' => 'perm_items',
  5. 'options' => array('type' => 'innodb'),
  6. 'fields' => array(
  7. 'id' => array(
  8. 'type' => 'integer',
  9. 'notnull' => 1,
  10. 'unsigned' => 0,
  11. 'autoincrement' => 1,
  12. 'name' => 'id',
  13. 'table' => 'perm_items',
  14. 'flags' => 'primary_keynot_null'
  15. ),
  16. 'name' => array(
  17. 'type' => 'text',
  18. 'notnull' => 1,
  19. 'length' => 64,
  20. 'fixed' => 0,
  21. 'default' => 0,
  22. 'name' => 'name',
  23. 'table' => 'perm_items',
  24. 'flags' => 'not_null'
  25. ),
  26. 'descr' => array(
  27. 'type' => 'text',
  28. 'length' => 1024,
  29. 'notnull' => 1,
  30. 'fixed' => 0,
  31. 'default' => 0,
  32. 'name' => 'descr',
  33. 'table' => 'perm_items',
  34. 'flags' => 'not_null'
  35. )
  36. )
  37. ),
  38. array(
  39. 'table_name' => 'perm_templ',
  40. 'options' => array('type' => 'innodb'),
  41. 'fields' => array(
  42. 'id' => array(
  43. 'type' => 'integer',
  44. 'notnull' => 1,
  45. 'unsigned' => 0,
  46. 'default' => 0,
  47. 'autoincrement' => 1,
  48. 'name' => 'id',
  49. 'table' => 'perm_templ',
  50. 'flags' => 'primary_keynot_null'
  51. ),
  52. 'name' => array(
  53. 'type' => 'text',
  54. 'notnull' => 1,
  55. 'length' => 128,
  56. 'fixed' => 0,
  57. 'default' => 0,
  58. 'name' => 'name',
  59. 'table' => 'perm_templ',
  60. 'flags' => 'not_null'
  61. ),
  62. 'descr' => array(
  63. 'notnull' => 1,
  64. 'fixed' => 0,
  65. 'default' => 0,
  66. 'type' => 'text',
  67. 'length' => 1024,
  68. 'name' => 'descr',
  69. 'table' => 'perm_templ',
  70. 'flags' => 'not_null'
  71. )
  72. )
  73. ),
  74. array(
  75. 'table_name' => 'perm_templ_items',
  76. 'options' => array('type' => 'innodb'),
  77. 'fields' => array(
  78. 'id' => array(
  79. 'notnull' => 1,
  80. 'unsigned' => 0,
  81. 'default' => 0,
  82. 'autoincrement' => 1,
  83. 'type' => 'integer',
  84. 'name' => 'id',
  85. 'table' => 'perm_templ_items',
  86. 'flags' => 'primary_keynot_null'
  87. ),
  88. 'templ_id' => array(
  89. 'notnull' => 1,
  90. 'length' => 4,
  91. 'unsigned' => 0,
  92. 'default' => 0,
  93. 'type' => 'integer',
  94. 'name' => 'templ_id',
  95. 'table' => 'perm_templ_items',
  96. 'flags' => 'not_null'
  97. ),
  98. 'perm_id' => array(
  99. 'notnull' => 1,
  100. 'length' => 4,
  101. 'unsigned' => 0,
  102. 'default' => 0,
  103. 'type' => 'integer',
  104. 'name' => 'perm_id',
  105. 'table' => 'perm_templ_items',
  106. 'flags' => 'not_null'
  107. )
  108. )
  109. ),
  110. array(
  111. 'table_name' => 'users',
  112. 'options' => array('type' => 'innodb'),
  113. 'fields' => array(
  114. 'id' => array
  115. (
  116. 'notnull' => 1,
  117. 'unsigned' => 0,
  118. 'default' => 0,
  119. 'autoincrement' => 1,
  120. 'type' => 'integer',
  121. 'name' => 'id',
  122. 'table' => 'users',
  123. 'flags' => 'primary_keynot_null'
  124. ),
  125. 'username' => array
  126. (
  127. 'notnull' => 1,
  128. 'length' => 64,
  129. 'fixed' => 0,
  130. 'default' => 0,
  131. 'type' => 'text',
  132. 'name' => 'username',
  133. 'table' => 'users',
  134. 'flags' => 'not_null'
  135. ),
  136. 'password' => array
  137. (
  138. 'notnull' => 1,
  139. 'length' => 128,
  140. 'fixed' => 0,
  141. 'default' => 0,
  142. 'type' => 'text',
  143. 'name' => 'password',
  144. 'table' => 'users',
  145. 'flags' => 'not_null'
  146. ),
  147. 'fullname' => array
  148. (
  149. 'notnull' => 1,
  150. 'length' => 255,
  151. 'fixed' => 0,
  152. 'default' => 0,
  153. 'type' => 'text',
  154. 'name' => 'fullname',
  155. 'table' => 'users',
  156. 'flags' => 'not_null'
  157. ),
  158. 'email' => array
  159. (
  160. 'notnull' => 1,
  161. 'length' => 255,
  162. 'fixed' => 0,
  163. 'default' => 0,
  164. 'type' => 'text',
  165. 'name' => 'email',
  166. 'table' => 'users',
  167. 'flags' => 'not_null'
  168. ),
  169. 'description' => array
  170. (
  171. 'notnull' => 1,
  172. 'fixed' => 0,
  173. 'default' => 0,
  174. 'type' => 'text',
  175. 'length' => 1024,
  176. 'name' => 'description',
  177. 'table' => 'users',
  178. 'flags' => 'not_null'
  179. ),
  180. 'perm_templ' => array
  181. (
  182. 'notnull' => 1,
  183. 'length' => 1,
  184. 'unsigned' => 0,
  185. 'default' => 0,
  186. 'type' => 'integer',
  187. 'name' => 'perm_templ',
  188. 'table' => 'users',
  189. 'flags' => 'not_null'
  190. ),
  191. 'active' => array
  192. (
  193. 'notnull' => 1,
  194. 'length' => 1,
  195. 'unsigned' => 0,
  196. 'default' => 0,
  197. 'type' => 'integer',
  198. 'name' => 'active',
  199. 'table' => 'users',
  200. 'flags' => 'not_null'
  201. ),
  202. 'use_ldap' => array
  203. (
  204. 'notnull' => 1,
  205. 'length' => 1,
  206. 'unsigned' => 0,
  207. 'default' => 0,
  208. 'type' => 'integer',
  209. 'name' => 'use_ldap',
  210. 'table' => 'users',
  211. 'flags' => 'not_null'
  212. )
  213. )
  214. ),
  215. array(
  216. 'table_name' => 'zones',
  217. 'options' => array('type' => 'innodb'),
  218. 'fields' => array(
  219. 'id' => array
  220. (
  221. 'notnull' => 1,
  222. 'length' => 4,
  223. 'unsigned' => 0,
  224. 'default' => 0,
  225. 'autoincrement' => 1,
  226. 'type' => 'integer',
  227. 'name' => 'id',
  228. 'table' => 'zones',
  229. 'flags' => 'primary_keynot_null'
  230. ),
  231. 'domain_id' => array
  232. (
  233. 'notnull' => 1,
  234. 'length' => 4,
  235. 'unsigned' => 0,
  236. 'default' => 0,
  237. 'type' => 'integer',
  238. 'name' => 'domain_id',
  239. 'table' => 'zones',
  240. 'flags' => 'not_null'
  241. ),
  242. 'owner' => array
  243. (
  244. 'notnull' => 1,
  245. 'length' => 4,
  246. 'unsigned' => 0,
  247. 'default' => 0,
  248. 'type' => 'integer',
  249. 'name' => 'owner',
  250. 'table' => 'zones',
  251. 'flags' => 'not_null'
  252. ),
  253. 'comment' => array
  254. (
  255. 'notnull' => 0,
  256. 'length' => 1024,
  257. 'fixed' => 0,
  258. 'default' => 0,
  259. 'type' => 'text',
  260. 'name' => 'comment',
  261. 'table' => 'zones',
  262. 'flags' => ''
  263. ),
  264. 'zone_templ_id' => array
  265. (
  266. 'notnull' => 1,
  267. 'length' => 4,
  268. 'unsigned' => 0,
  269. 'type' => 'integer',
  270. 'name' => 'zone_templ_id',
  271. 'table' => 'zones',
  272. 'flags' => ''
  273. ),
  274. )
  275. ),
  276. array(
  277. 'table_name' => 'zone_templ',
  278. 'options' => array('type' => 'innodb'),
  279. 'fields' => array(
  280. 'id' => array
  281. (
  282. 'notnull' => 1,
  283. 'length' => 11,
  284. 'unsigned' => 0,
  285. 'default' => 0,
  286. 'autoincrement' => 1,
  287. 'type' => 'integer',
  288. 'name' => 'id',
  289. 'table' => 'zone_templ',
  290. 'flags' => 'primary_keynot_null'
  291. ),
  292. 'name' => array
  293. (
  294. 'notnull' => 1,
  295. 'length' => 128,
  296. 'fixed' => 0,
  297. 'default' => 0,
  298. 'type' => 'text',
  299. 'name' => 'name',
  300. 'table' => 'zone_templ',
  301. 'flags' => 'not_null'
  302. ),
  303. 'descr' => array
  304. (
  305. 'notnull' => 1,
  306. 'length' => 1024,
  307. 'fixed' => 0,
  308. 'default' => 0,
  309. 'type' => 'text',
  310. 'name' => 'descr',
  311. 'table' => 'zone_templ',
  312. 'flags' => 'not_null'
  313. ),
  314. 'owner' => array
  315. (
  316. 'notnull' => 1,
  317. 'length' => 11,
  318. 'fixed' => 0,
  319. 'default' => 0,
  320. 'type' => 'integer',
  321. 'name' => 'owner',
  322. 'table' => 'zone_templ',
  323. 'flags' => 'not_null'
  324. )
  325. )
  326. ),
  327. array(
  328. 'table_name' => 'zone_templ_records',
  329. 'options' => array('type' => 'innodb'),
  330. 'fields' => array(
  331. 'id' => array
  332. (
  333. 'notnull' => 1,
  334. 'length' => 11,
  335. 'unsigned' => 0,
  336. 'default' => 0,
  337. 'autoincrement' => 1,
  338. 'type' => 'integer',
  339. 'name' => 'id',
  340. 'table' => 'zone_templ_records',
  341. 'flags' => 'primary_keynot_null'
  342. ),
  343. 'zone_templ_id' => array
  344. (
  345. 'notnull' => 1,
  346. 'length' => 11,
  347. 'fixed' => 0,
  348. 'default' => 0,
  349. 'type' => 'integer',
  350. 'name' => 'zone_templ_id',
  351. 'table' => 'zone_templ_records',
  352. 'flags' => 'not_null'
  353. ),
  354. 'name' => array
  355. (
  356. 'notnull' => 1,
  357. 'length' => 255,
  358. 'fixed' => 0,
  359. 'default' => 0,
  360. 'type' => 'text',
  361. 'name' => 'name',
  362. 'table' => 'zone_templ_records',
  363. 'flags' => ''
  364. ),
  365. 'type' => array
  366. (
  367. 'notnull' => 1,
  368. 'length' => 6,
  369. 'fixed' => 0,
  370. 'default' => 0,
  371. 'type' => 'text',
  372. 'name' => 'type',
  373. 'table' => 'zone_templ_records',
  374. 'flags' => ''
  375. ),
  376. 'content' => array
  377. (
  378. 'notnull' => 1,
  379. 'length' => 255,
  380. 'fixed' => 0,
  381. 'default' => 0,
  382. 'type' => 'text',
  383. 'name' => 'content',
  384. 'table' => 'zone_templ_records',
  385. 'flags' => ''
  386. ),
  387. 'ttl' => array
  388. (
  389. 'notnull' => 1,
  390. 'length' => 11,
  391. 'fixed' => 0,
  392. 'default' => 0,
  393. 'type' => 'integer',
  394. 'name' => 'ttl',
  395. 'table' => 'zone_templ_records',
  396. 'flags' => ''
  397. ),
  398. 'prio' => array
  399. (
  400. 'notnull' => 1,
  401. 'length' => 11,
  402. 'fixed' => 0,
  403. 'default' => 0,
  404. 'type' => 'integer',
  405. 'name' => 'prio',
  406. 'table' => 'zone_templ_records',
  407. 'flags' => ''
  408. )
  409. )
  410. ),
  411. array(
  412. 'table_name' => 'records_zone_templ',
  413. 'options' => array('type' => 'innodb'),
  414. 'fields' => array(
  415. 'domain_id' => array
  416. (
  417. 'notnull' => 1,
  418. 'length' => 11,
  419. 'fixed' => 0,
  420. 'default' => 0,
  421. 'type' => 'integer',
  422. 'name' => 'domain_id',
  423. 'table' => 'records_zone_templ',
  424. 'flags' => 'not_null'
  425. ),
  426. 'record_id' => array
  427. (
  428. 'notnull' => 1,
  429. 'length' => 11,
  430. 'fixed' => 0,
  431. 'default' => 0,
  432. 'type' => 'integer',
  433. 'name' => 'record_id',
  434. 'table' => 'records_zone_templ',
  435. 'flags' => 'not_null'
  436. ),
  437. 'zone_templ_id' => array
  438. (
  439. 'notnull' => 1,
  440. 'length' => 11,
  441. 'fixed' => 0,
  442. 'default' => 0,
  443. 'type' => 'integer',
  444. 'name' => 'zone_templ_id',
  445. 'table' => 'records_zone_templ',
  446. 'flags' => 'not_null'
  447. )
  448. )
  449. ),
  450. array(
  451. 'table_name' => 'migrations',
  452. 'options' => array('type' => 'innodb'),
  453. 'fields' => array(
  454. 'domain_id' => array
  455. (
  456. 'notnull' => 1,
  457. 'length' => 255,
  458. 'fixed' => 0,
  459. 'default' => 0,
  460. 'type' => 'text',
  461. 'name' => 'version',
  462. 'table' => 'migrations',
  463. 'flags' => 'not_null'
  464. ),
  465. 'record_id' => array
  466. (
  467. 'notnull' => 1,
  468. 'length' => 11,
  469. 'fixed' => 0,
  470. 'default' => 0,
  471. 'type' => 'integer',
  472. 'name' => 'apply_time',
  473. 'table' => 'migrations',
  474. 'flags' => 'not_null'
  475. )
  476. )
  477. )
  478. );
  479. // Tables from PowerDNS
  480. $grantTables = array('supermasters', 'domains', 'records');
  481. // Include PowerAdmin tables
  482. foreach ($def_tables as $table) {
  483. $grantTables[] = $table['table_name'];
  484. }
  485. // For PostgreSQL you need to grant access to sequences
  486. $grantSequences = array('domains_id_seq', 'records_id_seq');
  487. foreach ($def_tables as $table) {
  488. // ignore tables without primary key
  489. if ($table['table_name'] == 'migrations') { continue; }
  490. if ($table['table_name'] == 'records_zone_templ') { continue; }
  491. $grantSequences[] = $table['table_name'] . '_id_seq';
  492. }
  493. $def_permissions = array(
  494. array(41, 'zone_master_add', 'User is allowed to add new master zones.'),
  495. array(42, 'zone_slave_add', 'User is allowed to add new slave zones.'),
  496. array(43, 'zone_content_view_own', 'User is allowed to see the content and meta data of zones he owns.'),
  497. array(44, 'zone_content_edit_own', 'User is allowed to edit the content of zones he owns.'),
  498. array(45, 'zone_meta_edit_own', 'User is allowed to edit the meta data of zones he owns.'),
  499. array(46, 'zone_content_view_others', 'User is allowed to see the content and meta data of zones he does not own.'),
  500. array(47, 'zone_content_edit_others', 'User is allowed to edit the content of zones he does not own.'),
  501. array(48, 'zone_meta_edit_others', 'User is allowed to edit the meta data of zones he does not own.'),
  502. array(49, 'search', 'User is allowed to perform searches.'),
  503. array(50, 'supermaster_view', 'User is allowed to view supermasters.'),
  504. array(51, 'supermaster_add', 'User is allowed to add new supermasters.'),
  505. array(52, 'supermaster_edit', 'User is allowed to edit supermasters.'),
  506. array(53, 'user_is_ueberuser', 'User has full access. God-like. Redeemer.'),
  507. array(54, 'user_view_others', 'User is allowed to see other users and their details.'),
  508. array(55, 'user_add_new', 'User is allowed to add new users.'),
  509. array(56, 'user_edit_own', 'User is allowed to edit their own details.'),
  510. array(57, 'user_edit_others', 'User is allowed to edit other users.'),
  511. array(58, 'user_passwd_edit_others', 'User is allowed to edit the password of other users.'), // not used
  512. array(59, 'user_edit_templ_perm', 'User is allowed to change the permission template that is assigned to a user.'),
  513. array(60, 'templ_perm_add', 'User is allowed to add new permission templates.'),
  514. array(61, 'templ_perm_edit', 'User is allowed to edit existing permission templates.')
  515. );
  516. $def_remaining_queries = array(
  517. "INSERT INTO users (username, password, fullname, email, description, perm_templ, active, use_ldap) VALUES ('admin'," . $db->quote(md5($pa_pass), 'text') . ",'Administrator','admin@example.net','Administrator with full rights.',1,1,0)",
  518. "INSERT INTO perm_templ (name, descr) VALUES ('Administrator','Administrator template with full rights.')",
  519. "INSERT INTO perm_templ_items (templ_id, perm_id) VALUES (1,53)"
  520. );