[MOD] Tech tree editor of DB (v1.8, v2.0)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • [MOD] Tech tree editor of DB (v1.8, v2.0)

      Hi friends...

      There may be errors in translation. ;) ;)

      This MOD is a function to modify, delete, or add tech tree conditions.

      It has been perfectly implemented so that anyone can use it, and i made it very easy to use.

      A screenshot is attached.
      I hope this helps a lot.

      Reference!
      1. You can delete the row you want or modify the condition.
      2. When a new tech tree is saved, it will be sorted and displayed.
      3. Displayed by group.
      4. Automatically block on further saves with the same row incorrectly.


      1. Create a php file.
      includes/game/ShowRequriementsPage.class.php

      PHP Source Code

      1. <?php
      2. #by noonn
      3. /*
      4. Tech Tree Editor
      5. */
      6. class ShowRequriementsPage extends AbstractGamePage
      7. {
      8. public static $requireModule = 0;
      9. function __construct()
      10. {
      11. parent::__construct();
      12. }
      13. function show()
      14. {
      15. global $USER, $LNG;
      16. $db = Database::get();
      17. if($USER['authlevel'] != 3){
      18. $this->printMessage("Page not found<br>", array(array(
      19. 'label' => "MOVE",
      20. 'url' => 'game.php'
      21. )));
      22. }
      23. $sql = "SELECT requireLevel, requireID, elementID FROM %%VARS_REQUIRE%% WHERE elementID IN
      24. (SELECT elementID FROM %%VARS_REQUIRE%% GROUP BY elementID HAVING COUNT(*) >= 1) ORDER BY elementID, requireID ASC;" ;
      25. $Startowne = Database::get()->select($sql, array(
      26. ));
      27. $fleet_i = array();
      28. foreach ($Startowne as $Data) {
      29. if(!isset($fleet_i[$Data['elementID']]))
      30. $fleet_i[$Data['elementID']] = array();
      31. $Data['elementID'] = $Data['elementID'];
      32. $Data['requireID'] = $Data['requireID'];
      33. $Data['requireLevel'] = $Data['requireLevel'];
      34. $fleet_i[$Data['elementID']][$Data['requireID']] = $Data;
      35. }
      36. $this->assign(array(
      37. 'fleet_i' => $fleet_i,
      38. 'requireLv' => $LNG['tech'],
      39. ));
      40. $this->display('page.requriements.tpl');
      41. }
      42. function del()
      43. {
      44. global $USER;
      45. if($USER['authlevel'] != 3){
      46. $this->printMessage("Page not found<br>", array(array(
      47. 'label' => "MOVE",
      48. 'url' => 'game.php'
      49. )));
      50. }
      51. $db = Database::get();
      52. $elemID = HTTP::_GP('elemID', '');
      53. $requireID = HTTP::_GP('requireID', '');
      54. $sql = 'DELETE FROM %%VARS_REQUIRE%% WHERE elementID = :elemID AND requireID = :requireID ;';
      55. $db->delete($sql, array(
      56. ':elemID' => $elemID,
      57. ':requireID' => $requireID,
      58. ));
      59. $this->redirectTo('game.php?page=requriements');
      60. }
      61. function edits()
      62. {
      63. global $USER;
      64. if($USER['authlevel'] != 3){
      65. $this->printMessage("Page not found<br>", array(array(
      66. 'label' => "MOVE",
      67. 'url' => 'game.php'
      68. )));
      69. }
      70. $db = Database::get();
      71. $elemID = HTTP::_GP('elemID', '');
      72. $requireID = HTTP::_GP('requireID', '');
      73. $newlevel = HTTP::_GP('newlevel', '');
      74. // Check no same elemID and requireID
      75. $sql = "SELECT COUNT(*) as count FROM %%VARS_REQUIRE%% WHERE elementID = :elemID AND requireID = :requireID ;";
      76. $checkID = $db->selectSingle($sql, array(
      77. ':elemID' => $elemID,
      78. ':requireID' => $requireID,
      79. ), 'count');
      80. if(empty($checkID) || $checkID > 1){
      81. $this->printMessage("<span style=font-size:1.3em;color:#EE00E6><br>Error: Item does not exist or an identical row exists. !!<br><br></span>", array(array(
      82. 'label' => "MOVE",
      83. 'url' => '?page=requriements'
      84. )));
      85. }
      86. $sql = "UPDATE %%VARS_REQUIRE%% SET requireLevel = :requireLevel WHERE elementID = :elemID AND requireID = :requireID ;";
      87. $db->update($sql, array(
      88. ':requireLevel' => $newlevel,
      89. ':elemID' => $elemID,
      90. ':requireID' => $requireID,
      91. ));
      92. $this->redirectTo('game.php?page=requriements');
      93. }
      94. function add()
      95. {
      96. global $USER;
      97. if($USER['authlevel'] != 3){
      98. $this->printMessage("Page not found<br>", array(array(
      99. 'label' => "MOVE",
      100. 'url' => 'game.php'
      101. )));
      102. }
      103. $db = Database::get();
      104. $elemID = HTTP::_GP('elemID', '');
      105. $requireID = HTTP::_GP('requireID', '');
      106. $newlevel = HTTP::_GP('newlevel', '');
      107. // Check same elemID and requireID
      108. $sql = "SELECT COUNT(*) as count FROM %%VARS_REQUIRE%% WHERE elementID = :elemID AND requireID = :requireID ;";
      109. $checkID = $db->selectSingle($sql, array(
      110. ':elemID' => $elemID,
      111. ':requireID' => $requireID,
      112. ), 'count');
      113. if($checkID == 1){
      114. $this->printMessage("<span style=font-size:1.3em;color:#EE00E6><br>ERROR: Same item exists. !!<br><br></span>", array(array(
      115. 'label' => "MOVE",
      116. 'url' => '?page=requriements'
      117. )));
      118. }
      119. // INSERT data
      120. $sql = 'INSERT INTO %%VARS_REQUIRE%% SET elementID = :elemID, requireID = :requireID, requireLevel = :newlevel ;';
      121. $db->insert($sql, array(
      122. ':elemID' => $elemID,
      123. ':requireID' => $requireID,
      124. ':newlevel' => $newlevel,
      125. ));
      126. $this->redirectTo('game.php?page=requriements');
      127. }
      128. function ClearCache()
      129. {
      130. global $USER, $LNG;
      131. if($USER['authlevel'] != 3){
      132. $this->printMessage("Page not found<br>", array(array(
      133. 'label' => "MOVE",
      134. 'url' => 'game.php'
      135. )));
      136. }
      137. ClearCache();
      138. $this->redirectTo('game.php?page=requriements');
      139. }
      140. }
      141. ?>
      Display All






      2. Create a tpl file.
      templates/game/page.requriements.tpl


      HTML Source Code

      1. {block name="title" prepend}Tech Tree Settings{/block}
      2. {block name="content"}
      3. <style>
      4. td{
      5. font-size:1.2em;
      6. }
      7. .bgco{
      8. background-color:#003851;
      9. }
      10. </style>
      11. <div class="content_page">
      12. <div class="title" style="font-size:1.2em">
      13. Tech Tree Settings
      14. </div>
      15. <table border='1' width="100%">
      16. <tr>
      17. <th colspan="2"><font color="red" style="font-size:1.3em;color:#9BC800;">
      18. <pre>
      19. Reference!
      20. 1. You can delete the row you want or modify the condition.
      21. 2. When a new tech tree is saved, it will be sorted and displayed.
      22. 3. Displayed by group.
      23. 4. Automatically block on further saves with the same row incorrectly.
      24. </pre>
      25. </font>
      26. </th>
      27. </tr>
      28. <tr>
      29. <td><form action="?page=requriements&mode=ClearCache" method="post">
      30. After all operations are complete, please clear the cache.
      31. </td>
      32. <td><input type="submit" value="Clear Cache" style="display:block;float:right;background-color: #00568B;color: white;width:100px;padding: 10px 6px;"></td>
      33. </form>
      34. </tr>
      35. </table>
      36. <table border='1' width="100%">
      37. <tr>
      38. <td class="bgco" height="30px">ITEM</td>
      39. <td class="bgco">Tech requir</td>
      40. <td class="bgco">Level</td>
      41. <td class="bgco">save</td>
      42. </tr>
      43. <form action="?page=requriements&mode=add" method="post">
      44. <tr>
      45. <td>
      46. {html_options name=elemID options=$requireLv style='font-size:1.0em;color:#58FA58'}
      47. </td>
      48. <td>
      49. {html_options name=requireID options=$requireLv style='font-size:1.0em;color:#EE00E6'}
      50. </td>
      51. <td>
      52. <input style="width:60px; color:#FC6;font-size:1.3em" name="newlevel" type="number" min="1" onchange="KeyUpBuy('');" onkeyup="KeyUpBuy('');" value="1">
      53. </td>
      54. <td>
      55. <input style="color:#fff;font-size:1.1em;display:block; margin:0 auto; padding:3px 15px;" type="submit" value="ADD SAVE">
      56. </td>
      57. </tr>
      58. </form>
      59. </table>
      60. <table border='1' width="100%">
      61. <tr>
      62. <td colspan="5" height="30px">Tech tree in Database</td>
      63. </tr>
      64. <tr>
      65. <td class="bgco" height="30px">ITEM</td>
      66. <td class="bgco">Tech requir</td>
      67. <td class="bgco">Level</td>
      68. <td class="bgco">Edit TechTree</td>
      69. <td class="bgco">DELETE</td>
      70. </tr>
      71. {foreach $fleet_i as $elemID => $ids}
      72. <tr>
      73. <td rowspan="{count($ids)}">({$elemID})
      74. <a href="#" style="color:#58FA58;padding-left: 3px;" onclick="return Dialog.info({$elemID})">{$LNG.tech.{$elemID}}</a>
      75. </td>
      76. {foreach $ids as $ID => $id}
      77. <td>({$id.requireID})
      78. <a href="#" style="color:#EE00E6;padding-left: 3px;" onclick="return Dialog.info({$id.requireID})">{$LNG.tech.{$id.requireID}}</a></td>
      79. <td><span style="color:#FC6;">{$id.requireLevel}</span></td>
      80. <td>
      81. <form action="?page=requriements&mode=edits&elemID={$elemID}&requireID={$id.requireID}" method="post">
      82. <input style="font-size:1.3em;width:50px;height:20px" name="newlevel" type="number" min="1" onchange="KeyUpBuy('');" onkeyup="KeyUpBuy('');" value="{$id.requireLevel}">
      83. <input onclick="return confirm('Modify the rows of item {$elemID}, {$id.requireID} ?');" style="font-size:1.0em;background-color: #003A68;color: white;width:50px;padding: 2px 2px;" type="submit" value="Modify">
      84. </form>
      85. </td>
      86. <td>
      87. <form action="?page=requriements&mode=del&elemID={$elemID}&requireID={$id.requireID}" method="post">
      88. <input onclick="return confirm('Delete the rows of item {$elemID}, {$id.requireID} ?');" type="submit" value="DELETE" style="color:red">
      89. </form>
      90. </td>
      91. </tr>{if !$id@last}<tr>{/if}
      92. {/foreach}
      93. {/foreach}
      94. </table>
      95. <br><br><br><br><br><br><br>
      96. </div>
      97. {/block}
      Display All





      3. Add link.

      HTML Source Code

      1. {if $authlevel == 3} <a href="game.php?page=requriements">Tech tree Editor</a> {/if}



      End.....
      Thanks.


      --------------------------------------------------------------------------------------

      The post was edited 3 times, last by noonn ().

    • one thing that I don't understand why you don't make these mods directly in the admin panel knowing that it affects the configuration of the game.
    • Danter14 wrote:

      one thing that I don't understand why you don't make these mods directly in the admin panel knowing that it affects the configuration of the game.
      When the time comes, I'll make it run in the admin panel.
      Thanks for the advice.
      --------------------------------------------------------------------------------------
    • noonn wrote:

      Danter14 wrote:

      one thing that I don't understand why you don't make these mods directly in the admin panel knowing that it affects the configuration of the game.
      When the time comes, I'll make it run in the admin panel.Thanks for the advice.
      I find it clearer, knowing that in the game part only what is possible by the player must be in it, the rest for the management part of the universe must be in an admin panel. It's just my point of view for everyone to do what they want :)
    • thanks can you do it in fleet and buildings? also in addition to this building research fleet defense

      Can you make a mod for these base places that we can create ourselves so we can add new buildings so we can add new fleet defense research?
    • Zeus wrote:

      thanks can you do it in fleet and buildings? also in addition to this building research fleet defense

      Can you make a mod for these base places that we can create ourselves so we can add new buildings so we can add new fleet defense research?
      Only all buildings, research, fleets, and defense facilities officer that are currently implemented can be modified, del, or added.
      --------------------------------------------------------------------------------------
    • noonn wrote:

      Zeus wrote:

      thanks can you do it in fleet and buildings? also in addition to this building research fleet defense

      Can you make a mod for these base places that we can create ourselves so we can add new buildings so we can add new fleet defense research?
      Only all buildings, research, fleets, and defense facilities officer that are currently implemented can be modified, del, or added.
      I added correctly but
      i am getting an error the error i get says Page not found ? bro
    • if you are not an administrator you do not have access to the page

      to turn in the condition the || $USER["username"] == "admin" because it will block you if you have another nickname

      if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){}
    • Danter14 wrote:

      if you are not an administrator you do not have access to the page

      to turn in the condition the || $USER["username"] == "admin" because it will block you if you have another nickname

      if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){}
      sorry what exactly should i do

      My account is at level 3, so I have logins with full authorization, which code should I change here?
    • Zeus wrote:

      Danter14 wrote:

      if you are not an administrator you do not have access to the page

      to turn in the condition the || $USER["username"] == "admin" because it will block you if you have another nickname

      if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){}
      sorry what exactly should i do
      My account is at level 3, so I have logins with full authorization, which code should I change here?
      Remplaza

      PHP Source Code

      1. if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){
      por

      PHP Source Code

      1. if($USER['authlevel'] != 3){
      VERY SAD :/ :/ :/ :/
    • Aunque comparto con @Danter14 de mantenerlo de parte del panel, creo que seria mucho mas seguro poner esta regla

      PHP Source Code

      1. if($USER['id'] != ROOT_USER)
      Porque con esta te garantiza que tu solo puedas acceder hacer dicho cambios, ya que son un poco complicado que alguien que no tenga conocimiento manipule estas tablas
      VERY SAD :/ :/ :/ :/
    • yamilrh wrote:

      Zeus wrote:

      Danter14 wrote:

      if you are not an administrator you do not have access to the page

      to turn in the condition the || $USER["username"] == "admin" because it will block you if you have another nickname

      if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){}
      sorry what exactly should i doMy account is at level 3, so I have logins with full authorization, which code should I change here?
      Remplaza

      PHP Source Code

      1. if($USER['authlevel'] != 3 || $USER['username'] != 'admin'){
      por

      PHP Source Code

      1. if($USER['authlevel'] != 3){
      I changed it as you said but I got a page fault

      NOTICE
      Message: Undefined offset: 48
    • Source Code

      1. function show()
      2. {
      3. global $USER, $LNG;
      4. $db = Database::get();
      5. if($USER['authlevel'] != 3){
      6. $this->printMessage("Page not found<br>", array(array(
      7. 'label' => "MOVE",
      8. 'url' => 'game.php'
      9. )));
      10. }
      I'm doing it in show, am I doing it wrong? same error because
    • Zeus wrote:

      Source Code

      1. function show()
      2. {
      3. global $USER, $LNG;
      4. $db = Database::get();
      5. if($USER['authlevel'] != 3){
      6. $this->printMessage("Page not found<br>", array(array(
      7. 'label' => "MOVE",
      8. 'url' => 'game.php'
      9. )));
      10. }
      I'm doing it in show, am I doing it wrong? same error because
      Probare en una instalación limpia
      VERY SAD :/ :/ :/ :/
    • Zeus wrote:

      Source Code

      1. function show()
      2. {
      3. global $USER, $LNG;
      4. $db = Database::get();
      5. if($USER['authlevel'] != 3){
      6. $this->printMessage("Page not found<br>", array(array(
      7. 'label' => "MOVE",
      8. 'url' => 'game.php'
      9. )));
      10. }
      I'm doing it in show, am I doing it wrong? same error because
      Algo en tu código, acabo de probar y me funciona bien

      Remplaza por el tuyo
      Files
      VERY SAD :/ :/ :/ :/
    • Source Code

      1. NOTICE
      2. Message: Undefined offset: 48
      3. File: /cache/templates/tr_nsc^2b9768ad6802b4472c11f68028e0219040301a33.page.requriements.tpl.php
      4. Line: 1304
      5. URL: https://xxxxxxx/game.php?page=requriements
      6. PHP-Version: 7.4.33
      7. PHP-API: cgi-fcgi
      8. Version: 2.8.1
      9. Debug Backtrace:
      10. #0 /cache/templates/tr_nsc^2b9768ad6802b4472c11f68028e0219040301a33.page.requriements.tpl.php(1304): errorHandler()
      11. #1 /includes/libs/Smarty/sysplugins/smarty_template_resource_base.php(123): content_64e5270633da35_48897052()
      12. #2 /includes/libs/Smarty/sysplugins/smarty_template_cached.php(137): Smarty_Template_Resource_Base->getRenderedTemplateCode()
      13. #3 /includes/libs/Smarty/sysplugins/smarty_internal_template.php(211): Smarty_Template_Cached->render()
      14. #4 /includes/libs/Smarty/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template->render()
      15. #5 /includes/libs/Smarty/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute()
      16. #6 /includes/classes/class.template.php(148): Smarty_Internal_TemplateBase->display()
      17. #7 /includes/pages/game/AbstractGamePage.class.php(531): template->display()
      18. #8 /includes/pages/game/ShowRequriementsPage.class.php(50): AbstractGamePage->display()
      19. #9 /game.php(59): ShowRequriementsPage->show()
      20. #10 {main}
      Display All
      I don't understand, it's giving me an error like this, it's weird :huh: :huh: || :/