settings.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. if(!empty($args['conf_change_type'])) {
  3. $conf = $conf_obj->get($args['conf_change_type']);
  4. if($args['conf_change_type'] == 'users' ) {
  5. $real_conf = $conf;
  6. $conf = $real_conf[$args['name']];
  7. }
  8. $model = $conf_obj->get_config_model($args['conf_change_type']);
  9. $saved = false;
  10. foreach( $model as $key => $item ) {
  11. if(!empty($args[$key])) {
  12. if($key == 'password') {
  13. # Hash it, save to correct param
  14. $conf['auth_hash'] = password_hash( $args[$key], PASSWORD_DEFAULT );
  15. } else {
  16. $conf[$key] = $args[$key];
  17. }
  18. }
  19. }
  20. if($args['conf_change_type'] == 'users' ) {
  21. unset($conf['name']);
  22. $real_conf[$args['name']] = $conf;
  23. $conf = $real_conf;
  24. }
  25. $conf_obj->set($args['conf_change_type'], $conf);
  26. $saved = $conf_obj->save($args['conf_change_type']);
  27. if($saved) {
  28. echo "<p>Successfully saved $saved bytes to " . $conf_obj->get_conf_dir() . '/' . $args['conf_change_type'] . ".json</p>";
  29. } else {
  30. echo '<p style="color:red;">Failed to save to ' . $conf_obj->get_conf_dir() . '/' . $args['conf_change_type'] . '.json!</p>';
  31. }
  32. }
  33. ?>
  34. <p class="title">
  35. General settings:
  36. </p>
  37. <hr />
  38. <form id="mainConfig" method="post" action="index.php">
  39. <input type="hidden" name="conf_change_type" value="main" />
  40. <table>
  41. <?php
  42. $conf = $conf_obj->get('main');
  43. $model = $conf_obj->get_config_model('main');
  44. $line = '';
  45. foreach ( $model as $key => $item ) {
  46. $line .= '<tr>';
  47. $line .= '<td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  48. if($item['form_field'] == 'select') {
  49. $line .= '<td><select class="cooltext" name="' . $key . '" id="' . $key . '">';
  50. foreach ( $item['select_opts'] as $option ) {
  51. $line .= '<option value="' . $option . '">' . $option . '</option>';
  52. }
  53. $line .= '</select></td>';
  54. } elseif($item['form_field'] == 'input') {
  55. $val = !empty($conf[$key]) ? $conf[$key] : '';
  56. $line .= '<td><input type="text" class="cooltext" name="' . $key . '" id="' . $key . '" placeholder="'.$item['default'].'" value="'.$val.'" />';
  57. }
  58. $line .= '</tr>';
  59. }
  60. echo "$line\n";
  61. ?>
  62. </table>
  63. <br />
  64. <input type="submit" class="coolbutton" value="Commit Changes" />
  65. </form>
  66. <hr />
  67. <p class="title">
  68. User management:
  69. </p>
  70. <hr />
  71. <form id="userConfig" method="post" action="index.php">
  72. <input type="hidden" name="conf_change_type" value="users" />
  73. <?php
  74. $conf = $conf_obj->get('users');
  75. $model = $conf_obj->get_config_model('users');
  76. $line = '';
  77. foreach ( $conf as $user => $data ) {
  78. $line .= "<table class='manageUserEntry'><tr><td><em>Manage user '$user'</em></td>";
  79. $line .= "<td style='text-align: right;'><label for='delete_$user'>Delete user?</label>";
  80. $line .= "<input id='delete_$user' type='checkbox' />";
  81. $line .= "</td></tr>";
  82. foreach ( $model as $key => $item ) {
  83. $line .= '<tr><td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  84. $val = "";
  85. if( array_key_exists( $key, $data ) ) {
  86. $val = $data[$key];
  87. } else if( array_key_exists( 'masks', $item ) && $item['masks'] == 'parent' ) {
  88. $val = $user;
  89. }
  90. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="' . $val . '" /></td></tr>';
  91. }
  92. $line .= '</table>';
  93. }
  94. echo "$line\n";
  95. ?>
  96. <br />
  97. <input type="submit" class="coolbutton" value="Commit Changes" />
  98. </form>
  99. <br />
  100. <p class="title">
  101. Add User:
  102. </p>
  103. <form id="addUser" method="post" action="index.php">
  104. <input type="hidden" name="conf_change_type" value="user" />
  105. <table>
  106. <?php
  107. $line = '';
  108. foreach ( $model as $key => $item ) {
  109. $line .= '<td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  110. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="" /></td></tr>';
  111. }
  112. echo "$line\n";
  113. ?>
  114. </table>
  115. <br />
  116. <input type="submit" class="coolbutton" value="Commit Changes" />
  117. </form>
  118. <hr />
  119. <p class="title">
  120. Theme cloner:
  121. </p>
  122. <hr />
  123. <p>
  124. Want to write your own theme?
  125. Clone a theme here then see the <a href="https://tcms.troglodyne.net/index.php?nav=5&post=fileshare/manual/Chapter 03-Customization.post" title="GET UR MIND RITE">styling guide</a>
  126. for information on how tCMS' templates, image sets and CSS work in the theming system.
  127. </p>
  128. INSERT FORM HERE