Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Log attachment downloads

Hi,
Im looking for a way to log the click (download) of an attachment, in ticket view. In admin->system, i have set logging to DEBUG. I have added the following code in ticket-view.inc.php but when i test it by clicking on an attachment in the ticket, i dont see any records in the log with title "File click", just the cronjobs and logins.

<?php   
if(isset($_GET['file.php'])){
            george_logclick();
            }
        function george_logclick(){
                $ost->logDebug(_S('File Click'),
                    sprintf(_S("%s logged in [%s], clicked file %s"), $staff->getUserName(),
                    $_SERVER['REMOTE_ADDR'], $handler . '?' . http_build_query($args))); //Debug.
                }
?>

Regards
George

Comments

  • Thanks for the link. I moved code
    $ost->logDebug(_S('File Click'),
                        sprintf(_S("%s logged in [%s], clicked file %s"), $staff->getUserName(),
                        $_SERVER['REMOTE_ADDR'], $file)); //Debug.

    under line 
    $file->download(@$_GET['disposition'] ?: false, $_GET['expires']);

    but still no record in log.

    Regards
    George
  • edited February 21
    I have added javascript to footer.php
    <script>
    $('.filename').click(function() {
        $.ajax({
            url: 'log_download.php',
            success: function(){
                 alert('download done');
            }
        });
        return false;
    });
    </script>

    log_download.php code:
    <?php
    require(INCLUDE_DIR.'class.osticket.php');
    $ost->logDebug(__('File log'),__('File is downloaded').' ['.$_SERVER['REMOTE_ADDR'].']'); //Debug.
    ?>

    I tested it and I get the 500 error

    If anyone have a solution, please let me know.

  • moving thread to mods and customizations.
  • under line  
    $file->download(@$_GET['disposition'] ?: false, $_GET['expires']);

    but still no record in log.

    There's your problem.

    Put it before it. 

    You want the log to run before the file is sent, $file->download() ends with the script exiting.
  • You are correct, thank you very much for the information :). Problem solved!
Sign In or Register to comment.