[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
    • 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.

      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>';
    • New

      Zeus wrote:

      can you adapt mimikri for newstar

      Thank you in advance

      I can't show it in the amdin panel
      Ve a tu archivo ShowLogPage.class.php
      Añade luego de

      Source Code

      1. case 'detail':
      2. $this->ShowLogDetail();
      3. break;
      esto

      Source Code

      1. case 'error':
      2. $this->ShowLogError();
      3. break;
      Luego añade la siguiente función

      Source Code

      1. function ShowLogError()
      2. {
      3. // @ for open_basedir
      4. if(@file_exists(ini_get('error_log')))
      5. $Lines = count(file(ini_get('error_log')));
      6. else
      7. $Lines = 0;
      8. $file = file('./includes/error.log');
      9. $file = $file;
      10. $output = array();
      11. $count = 0;
      12. foreach($file as $f){
      13. if(strpos($f,'{main}') !== false){
      14. $output[$count] = "<tr><td>".$output[$count]."</tr></td>";
      15. $count++;
      16. }else{
      17. if($output[$count] === '<div onclick="document.getElementById(\'f'.$count.'\').style.display = \'block\';">'){
      18. $output[$count] .= $count . ".".$f."</div><div id='f".$count."' style='display:none; color:#fff'; onclick=\"this.style.display = 'none';\"><hr>";
      19. }else{
      20. $output[$count] .= $f."<br />";
      21. }
      22. }
      23. }
      24. $output = array_reverse($output);
      25. $this->assign(array(
      26. 'log_errors' => ini_get('log_errors') ? 'Activo' : 'Inactivo',
      27. 'errorlog' => ini_get('error_log'),
      28. 'errorloglines' => $Lines,
      29. 'error' => implode($output),
      30. ));
      31. $this->display('page.logError.default.tpl');
      32. }
      Display All
      Agrega en page.log.default.tpl

      Source Code

      1. <div class="col-md-6">
      2. <div class="card mb-4 shadow-sm">
      3. <img src="./styles/resource/images/admin/log/error.jpg" class="card-img img-thumbnail bg-primary border-primary">
      4. <div class="card-body">
      5. <h5 class="card-title">{$LNG.log_error}</h5>
      6. <p class="card-text overflow-auto" style="max-width: 1000px; max-height: 150px;">{$LNG.log_text_error}</p>
      7. <div style="text-align: right">
      8. <a href="?page=log&type=error">
      9. <button type="button" class="btn btn-primary">{$LNG.button_proceed}</button>
      10. </a>
      11. </div>
      12. </div>
      13. </div>
      14. </div>
      Display All
      Crea un archivo page.logError.default.tpl y agrega dentro

      Source Code

      1. {block name="title" prepend}{$LNG.lm_log_error}{/block}
      2. {block name="script" append}{/block}
      3. {block name="content"}
      4. <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
      5. <div class="card mb-3">
      6. <h5 class="card-header">Error Log || {$errorlog} Line - {$errorloglines} - <b>{$log_errors}</b></h5>
      7. <div class="card-body">
      8. <table class="table table-dark table-hover mb-3">
      9. <tbody>
      10. {$error}
      11. </tbody>
      12. </table>
      13. </div>
      14. </div>
      15. </main>
      16. {/block}
      Display All
      Luego vas a tu panel de administración donde dice Logs ahí lo podrás ver
      ENJOY!!
      VERY SAD :/ :/ :/ :/