[ABD] Custom Code

Any abandoned Extensions will be moved to this forum.

WARNING: Extensions in this forum are not currently being supported or maintained by the original Extension author. Proceed at your own risk.
Forum rules
IMPORTANT: Extension Development Forum rules

WARNING: Extensions in this forum are not currently being supported nor updated by the original Extension author. Proceed at your own risk.
Locked
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post 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'
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

That worked! Thanks again! :D 8-)
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post 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.
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

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.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post 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)
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

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.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
User avatar
2600
I've Been Banned!
Posts: 2567
Joined: Fri Nov 14, 2014 5:14 pm
Location: Area-51

Re: [RC] Custom Code

Post by 2600 »

NM, got it working.
Morpheus: Unfortunately, no one can be told what The Matrix is. You'll have to see it for yourself.
Hack me.
Consider a canary token.
The nature of my chosen username
:ugeek:
Astro86
Registered User
Posts: 18
Joined: Fri Aug 13, 2010 1:28 pm

Re: [RC] Custom Code

Post 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?
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Custom Code

Post 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.
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post 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.
Last edited by GoBieN on Mon Dec 21, 2015 7:23 pm, edited 2 times in total.
User avatar
RMcGirr83
Former Team Member
Posts: 22016
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: [RC] Custom Code

Post 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.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beer Image
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post by GoBieN »

Thanks, funny mistake, now corrected :D
I do remember 3.0.6 quite well :) or 2.0.6 on which I started.
User avatar
GoBieN
Registered User
Posts: 546
Joined: Fri Mar 05, 2004 5:22 pm
Location: Belgium
Contact:

Re: [RC] Custom Code

Post 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.
tony kiteboarder
Registered User
Posts: 32
Joined: Sat Feb 27, 2016 11:37 am

Re: [RC] Custom Code

Post 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
User avatar
Solidjeuh
Registered User
Posts: 522
Joined: Wed Oct 06, 2010 11:20 pm
Location: Aalst / Belgium
Name: Andy Dm
Contact:

Re: [RC] Custom Code

Post 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! :)
I don't suffer from insanity. I enjoy every minute of it.
Locked

Return to “Abandoned Extensions”