settings.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. <table>
  74. <?php
  75. $conf = $conf_obj->get('users');
  76. $model = $conf_obj->get_config_model('users');
  77. $line = '';
  78. foreach ( $conf as $user => $data ) {
  79. $line .= "<tr><td colspan=2><em>Manage user '$user'</em></td></tr>";
  80. foreach ( $model as $key => $item ) {
  81. $line .= '<tr><td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  82. $val = "";
  83. if( array_key_exists( $key, $data ) ) {
  84. $val = $data[$key];
  85. } else if( array_key_exists( 'masks', $item ) && $item['masks'] == 'parent' ) {
  86. $val = $user;
  87. }
  88. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="' . $val . '" /></td></tr>';
  89. }
  90. }
  91. echo "$line\n";
  92. ?>
  93. </table>
  94. <br />
  95. <input type="submit" class="coolbutton" value="Commit Changes" />
  96. </form>
  97. <br />
  98. <p class="title">
  99. Add User:
  100. </p>
  101. <form id="addUser" method="post" action="index.php">
  102. <input type="hidden" name="conf_change_type" value="user" />
  103. <table>
  104. <?php
  105. $line = '';
  106. foreach ( $model as $key => $item ) {
  107. $line .= '<td><label for="' . $key . '">' . $item['label'] . '</label></td>';
  108. $line .= '<td><input class="cooltext" name="' . $key . '" id="' . $key . '" type="' . $item['field_type'] . '" placeholder="' . $item['placeholder'] . '" value="" /></td></tr>';
  109. }
  110. echo "$line\n";
  111. ?>
  112. </table>
  113. <br />
  114. <input type="submit" class="coolbutton" value="Commit Changes" />
  115. </form>
  116. <hr />
  117. <p class="title">
  118. Theme cloner:
  119. </p>
  120. <hr />
  121. <p>
  122. Want to write your own theme?
  123. 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>
  124. for information on how tCMS' templates, image sets and CSS work in the theming system.
  125. </p>
  126. INSERT FORM HERE