[MOD] errorlogs in adminpanel

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

    • [MOD] errorlogs in adminpanel

      since it's a pain to always manualy look for errors in the includes/error.log file
      this makes things a bit easier.


      create this file

      PHP Source Code: includes\pages\adm\ShowErrorlogsPage.php

      1. <?php
      2. if (!allowedTo(str_replace(array(dirname(__FILE__), '\\', '/', '.php'), '', __FILE__))) throw new Exception("Permission error!");
      3. function ShowErrorlogsPage()
      4. {
      5. echo '<style>
      6. td{
      7. border:.2vw solid #666;
      8. color: #f90;
      9. font-family: Verdana;
      10. background:black;
      11. }
      12. body{
      13. background:rgb(33, 37, 43);
      14. }
      15. div{
      16. color:#f90;
      17. cursor:pointer;
      18. max-width: 97vw;
      19. }
      20. </style><table style="word-wrap: break-word;"><tr><td>errorlogs</td></tr><tr><td>';
      21. $file = file('./includes/error.log');
      22. $file = $file;
      23. $output = array();
      24. $count = 0;
      25. foreach($file as $f){
      26. if(strpos($f,'{main}') !== false){
      27. $output[$count] = $output[$count] . $f . "</div></td></tr><tr><td>";
      28. $count++;
      29. $output[$count] = '<div onclick="document.getElementById(\'f' . $count. '\').style.display = \'block\';">';
      30. }else{
      31. if($output[$count] === '<div onclick="document.getElementById(\'f' . $count. '\').style.display = \'block\';">'){
      32. $output[$count] .= $count . ".".$f."</div><div id='f" . $count . "' style='display:none; color:#fff'; onclick=\"this.style.display = 'none';\"><hr>";
      33. }else{
      34. $output[$count] .= $f."<br />";
      35. }
      36. }
      37. }
      38. $output = array_reverse($output);
      39. echo implode($output);
      40. echo '</td></tr></table>';
      41. }
      Display All



      add in this file

      PHP Source Code: admin.php

      1. case 'Errorlogs':
      2. include_once('includes/pages/adm/ShowErrorlogsPage.php');
      3. ShowErrorlogsPage();
      4. break;
      add in this file

      Smarty-Template: styles\templates\adm\ShowMenuPage.tpl

      1. {if allowedTo('ShowErrorlogsPage')}<li class="tools"><a href="?page=Errorlogs" target="Hauptframe">errorLOGS</a></li>{/if}

      it should now look like this(by clicking on an error the whol message opens)







      additional feature
      this saves the name of the user who caused the error (replace this "file_put_contents('includes/error.log', $errorText, FILE_APPEND);" with following)

      PHP Source Code: includes\GeneralFunctions.php

      1. global $USER;
      2. if(isset($USER['username'])){
      3. $User = $USER['username'];
      4. }else{
      5. $User = 'unbekannt';
      6. }
      7. file_put_contents('includes/error.log', '[' . $User . ']' . $errorText, FILE_APPEND);
    • You can also receive ticket directly from the player with the error and contact him if needed.

      PHP Source Code: includes\GeneralFunctions.php

      1. $ErrSource = isset($USER) ? $USER['id'] : 1;
      2. $ErrName = isset($USER) ? $USER['username'] : 'System';
      3. $ticketObj = new SupportTickets;
      4. $ticketID = $ticketObj->createTicket($ErrSource, '1', $errorType[$errno]);
      5. $ticketObj->createAnswer($ticketID, $ErrSource, $ErrName, $errorType[$errno], $errorText, 0);


      Don't forget to require class.SupportTicket.php
      Looking for good VPS to host your game? Use DigitalOcean and get 100$ bonus credit for 2 months!

      Stellaron Reborn - new summer update

      I can build any mod. Need my service? Contact me via PM
    • XenQen wrote:

      Abyss wrote:

      where to add this
      Are you dumb? The file names stand there, what the fuck? Why does a guy tries to develop at 2Moons if he cant even read right?
      What a dickhead you are, so we didn't get there, we ask, why are you attacking everything like a new bride?
    • the files and paths are written in the head of each codeblock.
      the mod is written for 2moons 1.8 files,
      if you have a modifyed version the line-numbers may differ.
      to find the right line in a alreay modified file use github.com/jkroepke/2Moons to look at the original files,
      like this you can conclude where to put the code in a modified version of 2moons.
    • Qwa wrote:

      You can also receive ticket directly from the player with the error and contact him if needed.

      PHP Source Code: includes\GeneralFunctions.php

      1. $ErrSource = isset($USER) ? $USER['id'] : 1;
      2. $ErrName = isset($USER) ? $USER['username'] : 'System';
      3. $ticketObj = new SupportTickets;
      4. $ticketID = $ticketObj->createTicket($ErrSource, '1', $errorType[$errno]);
      5. $ticketObj->createAnswer($ticketID, $ErrSource, $ErrName, $errorType[$errno], $errorText, 0);

      Don't forget to require class.SupportTicket.php
      Bad idea, you can get tickets spam , just error log page better
    • Kaizoku wrote:

      Qwa wrote:

      You can also receive ticket directly from the player with the error and contact him if needed.

      PHP Source Code: includes\GeneralFunctions.php

      1. $ErrSource = isset($USER) ? $USER['id'] : 1;
      2. $ErrName = isset($USER) ? $USER['username'] : 'System';
      3. $ticketObj = new SupportTickets;
      4. $ticketID = $ticketObj->createTicket($ErrSource, '1', $errorType[$errno]);
      5. $ticketObj->createAnswer($ticketID, $ErrSource, $ErrName, $errorType[$errno], $errorText, 0);
      Don't forget to require class.SupportTicket.php
      Bad idea, you can get tickets spam , just error log page better
      True, but it's just an idea for those who forgets to check errors,aren't aware of any issue or can't find/reproduce their own bugs.

      A quick delete button for duplicate errors would just take 5 minutes to be done.
      Looking for good VPS to host your game? Use DigitalOcean and get 100$ bonus credit for 2 months!

      Stellaron Reborn - new summer update

      I can build any mod. Need my service? Contact me via PM

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

    • showOverviewPage.php

      Source Code

      1. if(is_writable('./includes/error.log')) {
      2. $file = file('./includes/error.log');
      3. $files = count($file);
      4. }
      5. if(is_writable('./includes/error.log'))
      6. $Message[] = 'The file '. $Files.' menstrual error appears. To see <a href="admin.php?page=error" target="Hauptframe">Click here</a>';