[MOD] Rapid fire 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] Rapid fire editor of DB (v1.8, v2.0)

      Hi~
      There may be errors in translation. :D :D

      Modified to operate in 2.0 by referring to the 1.7 version of the library.

      Produced by referring to the link below.
      [MOD](Edit Rapidfire) Корректировка скорострела %D0%B8%D1%80%D0%BE%D0%B2%D0%BA%D0%B0-%D1%81%D0%BA%D0%BE%D1%80%D0%BE%D1%81% D1%82%D1%80%D0%B5%D0%BB%D0%B0/

      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.

      Function:
      1. You can delete the current row or modify the amount of Rapid fire.
      2. When saving a new rapid fire, it is displayed in order.
      3. Automatically stop on further saves with the same row incorrectly.

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


      PHP Source Code

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




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

      HTML Source Code

      1. {block name="title" prepend}Rapid fire editor{/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. Rapid fire editor
      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. caution!
      20. 1. You can delete the current row or modify the amount of Rapid fire.
      21. 2. When saving a new rapid fire, it is displayed in order.
      22. 3. Automatically stop on further saves with the same row incorrectly.
      23. </pre>
      24. </font>
      25. </th>
      26. </tr>
      27. <tr>
      28. <td><form action="?page=rapidfire&mode=ClearCache" method="post">
      29. After all operations are complete, please clear the cache.
      30. </td>
      31. <td><input type="submit" value="Clear Cache" style="display:block;float:right;background-color: #003F5B;width:120px;color:#fff;height:30px"></td>
      32. </form>
      33. </tr>
      34. </table>
      35. <table border='1' width="100%">
      36. <tr>
      37. <td class="bgco" height="30px">Fleet/Defense</td>
      38. <td class="bgco">Rapid fire item</td>
      39. <td class="bgco">Rapid fire</td>
      40. <td class="bgco">Save</td>
      41. </tr>
      42. <form action="?page=rapidfire&mode=add" method="post">
      43. <tr>
      44. <td>
      45. {html_options name=elemID options=$short style='font-size:1.0em;color:#58FA58'}
      46. </td>
      47. <td>
      48. {html_options name=rapID options=$short style='font-size:1.0em;color:#EE00E6'}
      49. </td>
      50. <td>
      51. <input style="width:60px; color:#FC6;font-size:1.3em" name="shoots" type="number" min="1" onchange="KeyUpBuy('');" onkeyup="KeyUpBuy('');" value="1">
      52. </td>
      53. <td>
      54. <input style="background-color: #48A34B;width:120px;color:#fff;font-size:1.1em;display:block; margin:0 auto; padding:3px 15px;" type="submit" value="Add Save">
      55. </td>
      56. </tr>
      57. </form>
      58. </table>
      59. <table border='1' width="100%">
      60. <tr>
      61. <td colspan="6" height="30px">Rapid Fire in the database</td>
      62. </tr>
      63. <tr>
      64. <td class="bgco">No.</td>
      65. <td class="bgco">Delete</td>
      66. <td class="bgco" height="30px">Fleet/Defense</td>
      67. <td class="bgco">Rapid fire item</td>
      68. <td class="bgco">Rapid fire</td>
      69. <td class="bgco">Edit Rapid fire</td>
      70. </tr>
      71. {foreach $fleet_i as $row}
      72. <tr>
      73. <td width="30px">#{$row@iteration}</td>
      74. <td>
      75. <form action="?page=rapidfire&mode=del&elemID={$row.elementID}&rapID={$row.rapidfireID}" method="post">
      76. <input onclick="return confirm('Delete the rows of items {$row.elementID} and {$row.rapidfireID}?');" type="submit" value="Delete" style="font-size:0.9em;color:red">
      77. </form>
      78. </td>
      79. <td>({$row.elementID})
      80. <a href="#" style="color:#58FA58;padding-left: 3px;" onclick="return Dialog.info({$row.elementID})">{$LNG.tech.{$row.elementID}}</a></td>
      81. <td>({$row.rapidfireID})
      82. <a href="#" style="color:#EE00E6;padding-left: 3px;" onclick="return Dialog.info({$row.rapidfireID})">{$LNG.tech.{$row.rapidfireID}}</a></td>
      83. <td><span style="color:#FC6;">{$row.shoots}</span></td>
      84. <td>
      85. <form action="?page=rapidfire&mode=edits&elemID={$row.elementID}&rapID={$row.rapidfireID}" method="post">
      86. <input style="font-size:1.3em;width:50px;height:20px" name="newshoots" type="number" min="1" onchange="KeyUpBuy('');" onkeyup="KeyUpBuy('');" value="{$row.shoots}">
      87. <input onclick="return confirm('Modify the rows of items {$row.elementID} and {$row.rapidfireID}?');" style="font-size:1.0em;background-color: #003F5B;width:120px;color:#fff;" type="submit" value="Modify">
      88. </form>
      89. </td>
      90. </tr>
      91. {/foreach}
      92. </table>
      93. <br><br><br><br><br><br><br>
      94. </div>
      95. {/block}
      Display All




      3. Add link.

      HTML Source Code

      1. {if $authlevel > 0} <a href="game.php?page=rapidfire">RapidFire Editor</a> {/if}


      End.....
      Thanks.
      ^^ ^^
      Images
      • rapidfireEditor.JPG

        181.29 kB, 949×963, viewed 942 times
      • popupRF.jpg

        261.92 kB, 911×1,026, viewed 384 times
      • 003.JPG

        74.51 kB, 898×446, viewed 405 times
      --------------------------------------------------------------------------------------

      The post was edited 1 time, last by noonn ().

    • Zeus wrote:

      hello, there is integration for newstar, this code you gave works in newstar

      thank you for your sharing
      It works well for New Stars too.

      have a nice day ^^
      --------------------------------------------------------------------------------------
    • noonn wrote:

      3. Add link.
      <a href="game.php?page=rapidfire">RapidFire Editor</a>
      Agrega la verificación a la vista, así los usuario comunes no lo ven

      HTML Source Code

      1. {if $authlevel > 0}<a href="game.php?page=rapidfire">RapidFire Editor</a>{/if}
      VERY SAD :/ :/ :/ :/
    • Very well done noon
      Ive done a bit similar for the game i am working on it as i truncated the rapidfire and requirements table to scratch from 0.

      if i might give you one little advice, add filtering option/pagination. The page might became very long at the end, but its just extra improvements,
      Try the new Deployment module: More info
      V1.1.9 has been rolled out <3
    • Well I'm doing it again but directly in the administration with a more optimized code. As soon as it's finished I'll put it here.
      Jbaukens to mention filtering and paging so I will do those as well.


      The post was edited 1 time, last by Danter14 ().

    • Danter14 wrote:

      Well I'm doing it again but directly in the administration with a more optimized code. As soon as it's finished I'll put it here.
      Jbaukens to mention filtering and paging so I will do those as well.



      Can you make it compatible in newstar because 2moons 2.0 versions are compatible
    • Zeus wrote:

      Can you make it compatible in newstar because 2moons 2.0 versions are compatible
      It will be compatible because new star goes through version 1.8 of 2moons. knowing that the code is made with version 2.0.

      search good

      The post was edited 2 times, last by Danter14 ().

    • As promised here is a version for the admin panel with the code redone and optimized as much as possible
      • The code is fully documented
      • Adding a pagination
      • Added a search bar by IDs
      • Works under versions 1.8, 1.9, 2.0, new star
      A like and a return is always a pleasure ^^
      Files
    • Danter14 wrote:

      As promised here is a version for the admin panel with the code redone and optimized as much as possible
      • The code is fully documented
      • Adding a pagination
      • Added a search bar by IDs
      • Works under versions 1.8, 1.9, 2.0, new star
      A like and a return is always a pleasure ^^
      Thank you Danter14
      Nice works.
      Thanks for sharing the mod.
      :thumbsup: :thumbsup:
      --------------------------------------------------------------------------------------