This topic is locked

Custom server action when download starts

7/5/2017 3:39:14 AM
PHPRunner General questions
C
christou author

First of all, I have 2 ultimate goals:

  1. Provide the user the download file with filename depends on their levels, i.e.: admin with get the original filename, while normal user will get a patterned filename (based on values of other fields).
  2. Record a log in my DB when a user download a file (log what and when being downloaded)
    I'm using PHPRunner 9.8 while the project was build using 9.7, my first approach is to use the 'field event - on click' function apply to the file field. But the function seems not working at all.

    Once I write my custom SQL query in the server code page in the field event and test it, the browser report errors:

SyntaxError: JSON.parse: unexpected character at line 2 column 2 of the JSON data[Learn More] pageevents_mytbl.js:3:629



No code of the 'field event' has been executed (neither JS or PHP). And then I have no idea what to do about.
My second approach is to write my own plugin for view page. When I dig into mfhandler.php, I saw some encryption/authentication/chiper in it. Since my knowledge on security is so poor, I give up on this option.
So is there any other option good to me?

Or wait for PHPRunner to patch the bugs?

Sergey Kornilov admin 7/5/2017

This error is coming from your event. You need to fix your event code and here are articles that shows troubleshooting steps:

https://xlinesoft.com/phprunner/docs/troubleshooting_javascript_errors.htm

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Personally I think that View plugin will be required to create such kind of functionality. I would not suggest making changed to mfhandler.php file.

C
christou author 7/5/2017



This error is coming from your event. You need to fix your event code and here are articles that shows troubleshooting steps:

https://xlinesoft.com/phprunner/docs/troubleshooting_javascript_errors.htm

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
Personally I think that View plugin will be required to create such kind of functionality. I would not suggest making changed to mfhandler.php file.


Sadly but I've tried to remove all codes in 'client before', 'server', and 'client after' page, the same error occurs.

Neither I've also tried to use the template code (generated by PHPRunner once I create a new event), result is the same.

Sergey Kornilov admin 7/5/2017

pageevents_mytbl.js is the file that stores Javascript events for 'mytbl'. If you saying you removed all events for this table and exactly the same error is happening - it is simply not possible. There are either some events left or error is different.