Page 45 of 52

Re: [RC] Custom Code

Posted: Sun Nov 15, 2015 6:09 am
by martti
John connor wrote:
martti wrote:
John connor wrote:Hey Martti, you made this code for me to play audio to banned members, but now it seems it won't work. Perhaps this is a 3.1.6 issue? It played before and now I just noticed this trying 4 browsers and changing the audio from MP3 to Ogg. Nothing worked. Not sure what to make of this. The code is in the overall_footer_after.html.

Code: Select all

<!-- play requiem for the banned -->

<!-- IF SCRIPT_NAME == 'ucp' and CUSTOMCODE_PARAM_MODE == 'login' -->

<audio src="https://mysite.com/images/banned.mp3"></audio>

<script>
$(document).ready( function() {
  window.setTimeout( function() {
    if ($('div#message > div.inner > p > em').text().indexOf('A ban has been issued') >= 0){
      $('audio')[0].play();
    }
  }, 100);
});

</script>

<!-- ENDIF -->
  • Is the language in your board still English? See that the script searches for the string 'A ban has been issued'
  • Do you see that the page tries to load the audio? For example you can inspect this with Firebug in Firefox.
The script can be improved, by the way, because you're not limited anymore to certain events. When you use event overall_footer_body_after.html you can forget about the SetTimeout function, because the event is located after jQuery:

Edit : overall_footer_body_after.html

Code: Select all

<!-- play requiem for the banned -->

<!-- IF SCRIPT_NAME == 'ucp' and CUSTOMCODE_PARAM_MODE == 'login' -->

<audio src="https://mysite.com/images/banned.mp3"></audio>

<script>
$(document).ready( function() {
    if ($('div#message > div.inner > p > em').text().indexOf('A ban has been issued') >= 0){
      $('audio')[0].play();
    }
});

</script>

<!-- ENDIF -->
Okay, I had the code in overall_footer_after.html so I added it to overall_footer_body_after.html and delted from the other file, cleared the cache and all I see load is the following:

Code: Select all

<!-- append to quickreply -->


<!-- append to posting box -->

<!-- play requiem for the banned -->
No audio. Yes, my board is still in English. I'm wondering if an extension is interfering? I used Firebug, but not sure how to see if there are errors.
Ok, I see what is happening. You use the template variable CUSTOMCODE_PARAM_MODE, that was generated by the Custom Code extension. I wrote the Parameter Template Variables extension to replace this functionality
(as I wrote at the bottom of this post)
Upload and enable this extension and replace CUSTOMCODE_PARAM_MODE == 'login' with PARAMTEMPVARS_MODE == 'login'

Re: [RC] Custom Code

Posted: Mon Nov 16, 2015 12:21 am
by John connor
That worked! Thanks again! :D 8-)

Re: [RC] Custom Code

Posted: Wed Nov 18, 2015 5:58 pm
by GoBieN
I'm confused, I updated a testforum to 3.1.6 (from 3.1.5) and all the customcode is still working it seems.
I did clear the cache.

Re: [RC] Custom Code

Posted: Sun Nov 22, 2015 7:11 pm
by John connor
Hey Martti. I seem to have a problem...I think. I was going through my server logs and I see this person get the banned sound file, but they are not banned and are a full fledged user. Could it be the UCP text or due to their iPad? I don't get this my self and never seen anyone else get this either in the server logs. I'll look over them again going back a few days, but I don't recall anyone getting the banned audio on login.

Here's what I see in the log:

"GET /images/banned.mp3 HTTP/1.1" 206 2 "https://myforum.net/ucp.php?mode=login&sid=30254cf775a17c576de704e4671bd6a8" "Mozilla/5.0 (iPad; CPU OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12D508 Safari/600.1.4"

Edit-

This is a 206, not a 200. Not sure what this means. This is what Google says:
This Partial Content code (206) may be sent from the server when the client has asked for a range (e.g. "give me the first 2MB of video data"). It is vital for downloading data in chunks which avoids fetching unused resources. (I seldom watch a full video online.) Look at the outgoing request for a Range header.
So are they hearing the audio and why are they retrieving the audio?

Edit2-

I am seeing others get this as well as me in the logs, but it doesn't play. Also, some logs show a 200, not just a 206. Since this is my second forum I will have to ban a test account and see what happens.

Edit3-

Okay, I banned a test account and the audio does play on login. What seems to happen here is that to normal users the audio is cached. If the audio is in the cache the browser doesn't retrieve the banned.mp3 clip. But if your browser never retrieved the banned audio it will fetch it. It's just interesting that on login all users pull the banned audio when they are not banned. The audio doesn't play though to regular users, just retrieves it. It will play on a ban.

Re: [RC] Custom Code

Posted: Sun Nov 22, 2015 8:22 pm
by martti
John connor wrote:Hey Martti. I seem to have a problem...I think. I was going through my server logs and I see this person get the banned sound file, but they are not banned and are a full fledged user. Could it be the UCP text or due to their iPad? I don't get this my self and never seen anyone else get this either in the server logs. I'll look over them again going back a few days, but I don't recall anyone getting the banned audio on login.

Here's what I see in the log:

"GET /images/banned.mp3 HTTP/1.1" 206 2 "https://myforum.net/ucp.php?mode=login&sid=30254cf775a17c576de704e4671bd6a8" "Mozilla/5.0 (iPad; CPU OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12D508 Safari/600.1.4"

Edit-

This is a 206, not a 200. Not sure what this means. This is what Google says:
This Partial Content code (206) may be sent from the server when the client has asked for a range (e.g. "give me the first 2MB of video data"). It is vital for downloading data in chunks which avoids fetching unused resources. (I seldom watch a full video online.) Look at the outgoing request for a Range header.
So are they hearing the audio and why are they retrieving the audio?

Edit2-

I am seeing others get this as well as me in the logs, but it doesn't play. Also, some logs show a 200, not just a 206. Since this is my second forum I will have to ban a test account and see what happens.
https://developer.mozilla.org/en-US/doc ... _and_video

That's probably browser specific. The specified behaviour is the file doesn't preload. To be sure nothing (pre)loads you could insert the audio tag entirely by javascript (jQuery).

Edit : overall_footer_body_after.html

Code: Select all

<!-- play requiem for the banned -->

<!-- IF SCRIPT_NAME == 'ucp' and CUSTOMCODE_PARAM_MODE == 'login' -->

<script>
$(document).ready( function() {
    if ($('div#message > div.inner > p > em').text().indexOf('A ban has been issued') >= 0){
      var $audio = $('<audio></audio>').attr('src', 'https://mysite.com/images/banned.mp3').appendTo('body');
      $audio.play();
    }
});

</script>

<!-- ENDIF -->
(not tested)

Re: [RC] Custom Code

Posted: Wed Nov 25, 2015 9:04 am
by John connor
Ah, I think I'll leave it as is.

So you are saying it IS preloading I guess? That's what seems to happen, but it doesn't play or anything unless you've been banned.

Re: [RC] Custom Code

Posted: Fri Nov 27, 2015 6:54 am
by John connor
NM, got it working.

Re: [RC] Custom Code

Posted: Fri Dec 18, 2015 5:54 pm
by Astro86

Code: Select all

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "../../../../../../store/customcode/overall_header_head_append.html" (looked into: ./styles/se_square_left/template, ./styles/se_square_left/theme, ./styles/prosilver/template, ./styles/prosilver/theme) in "@marttiphpbb_customcode/event/overall_header_head_append.html" at line 5.' in /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:195 Stack trace: #0 /membri/ddgames/phpbb/template/twig/loader.php(107): Twig_Loader_Filesystem->findTemplate('../../../../../...') #1 /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(138): phpbb\template\twig\loader->findTemplate('../../../../../...') #2 /membri/ddgames/vendor/twig/twig/lib/Twig/Environment.php(266): Twig_Loader_Filesystem->getCacheKey('../../../../../...') #3 /membri/ddgames/vendor/twig/twig/lib/Twig/Environment.php(324): Twig_Environment->getTemplateClass('../../../../../...', NULL) #4 /membri/ddgames/phpbb/template/twig/environment.php(151): Twig_Environme in /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 195
how do I resolve this?

Re: [RC] Custom Code

Posted: Fri Dec 18, 2015 6:00 pm
by martti
Astro86 wrote:

Code: Select all

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'Unable to find template "../../../../../../store/customcode/overall_header_head_append.html" (looked into: ./styles/se_square_left/template, ./styles/se_square_left/theme, ./styles/prosilver/template, ./styles/prosilver/theme) in "@marttiphpbb_customcode/event/overall_header_head_append.html" at line 5.' in /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php:195 Stack trace: #0 /membri/ddgames/phpbb/template/twig/loader.php(107): Twig_Loader_Filesystem->findTemplate('../../../../../...') #1 /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(138): phpbb\template\twig\loader->findTemplate('../../../../../...') #2 /membri/ddgames/vendor/twig/twig/lib/Twig/Environment.php(266): Twig_Loader_Filesystem->getCacheKey('../../../../../...') #3 /membri/ddgames/vendor/twig/twig/lib/Twig/Environment.php(324): Twig_Environment->getTemplateClass('../../../../../...', NULL) #4 /membri/ddgames/phpbb/template/twig/environment.php(151): Twig_Environme in /membri/ddgames/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 195
how do I resolve this?
You shouldn't use this extension anymore from phpBB 3.1.6 on. See the first post of this topic.

Re: [RC] Custom Code

Posted: Mon Dec 21, 2015 7:08 pm
by GoBieN
What I find strange is that I have upgraded 2 boards to 3.1.6. Only one of them gave the TWIG template error. That one I switched to insert template code extension. The other is running fine with all the custome template code working as expected without the insert template code even installed. Very strange, maybe I should run the installer again to check if it did upgrade all the files.

Re: [RC] Custom Code

Posted: Mon Dec 21, 2015 7:19 pm
by RMcGirr83
GoBieN wrote:What I find strange is that I have upgraded 2 boards to 3.0.6.
Uhmmm, you may want to fix that.

Re: [RC] Custom Code

Posted: Mon Dec 21, 2015 7:23 pm
by GoBieN
Thanks, funny mistake, now corrected :D
I do remember 3.0.6 quite well :) or 2.0.6 on which I started.

Re: [RC] Custom Code

Posted: Mon Dec 21, 2015 8:57 pm
by GoBieN
Nevermind, Was probably a caching thing. Now it showed me a blank page on index.
I disabled customcode and switched to insert template code just to be sure.

Re: [RC] Custom Code

Posted: Mon Feb 29, 2016 9:29 am
by tony kiteboarder
Hi

I totally missed this and upgraded from 3.5 to 3.8 without disabling the extension, I tried deleting it, but obviously that dosen't work.

I'm now getting the following error as I deleted the file

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/class_loader.php on line 160: require(./ext/marttiphpbb/customcode/event/listener.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/class_loader.php on line 160: require(./ext/marttiphpbb/customcode/event/listener.php): failed to open stream: No such file or directory
If I put it back in and get a bunch of different errors related to its incompatibility with 3.8

Am I right in thinking that I can use one of the workarounds for the extension, put the files back in and my board will start working again?

Many Thanks

Tony

Re: [RC] Custom Code

Posted: Mon Feb 29, 2016 11:42 am
by Solidjeuh
tony kiteboarder wrote:Hi

I totally missed this and upgraded from 3.5 to 3.8 without disabling the extension, I tried deleting it, but obviously that dosen't work.

I'm now getting the following error as I deleted the file

Code: Select all

[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/class_loader.php on line 160: require(./ext/marttiphpbb/customcode/event/listener.php): failed to open stream: No such file or directory
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/class_loader.php on line 160: require(./ext/marttiphpbb/customcode/event/listener.php): failed to open stream: No such file or directory
If I put it back in and get a bunch of different errors related to its incompatibility with 3.8

Am I right in thinking that I can use one of the workarounds for the extension, put the files back in and my board will start working again?

Many Thanks

Tony
Delete the extension, and install this "workaround' extension
viewtopic.php?f=456&t=2275361&p=14199116#p14199116
Works great! :)