Previous Thread
Next Thread
Print Thread
Hop To
Custom Islands Adding ?> Tags #262237 02/03/2019 11:07 PM
Joined: Jun 2008
Posts: 81
mmem700 Offline OP
Journeyman
OP Offline
Journeyman
Joined: Jun 2008
Posts: 81
Edit Custom Portal Island

Not a big deal, but...

When editing the code for a custom portal island, I find that each time the form is submitted, it adds an additional PHP-end tag:

So eventually the code ends up looking like this if you don't manually get rid of them:

PHP Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
....some code here........
/* DO NOT CHANGE THE LINE ABOVE */

?>
?>
?>
?>
?>
?> 


Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Express Hosting
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262241 02/03/2019 11:17 PM
Joined: Jun 2006
Posts: 15,851
Gizmo Online Tapedshut
UBB.threads Developer
Online Tapedshut
UBB.threads Developer
Joined: Jun 2006
Posts: 15,851
I am unable to replicate this on my v7.7.1 test site under PHP 7.2.10. Additionally, I was unable to replicate this at UBBDev on v7.7.2 and PHP 5.4.45.

Steps:
1 Open the custom code page in the control panel and save
2 open the file via FTP (cache_builders/custom/) and see the code properly displayed
3 save the custom code via the CP again
4 open the file again and it still appears as expected

What version of UBB.threads are you running? Is your custom island coding following the example formatting, including the body eof lines? Do you have any modifications installed? What version of UBB.threads are you running? What is the content of the Custom Island that keeps being updated with additional coding?


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Need to Upgrade?
Forums: A Gardeners Forum Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262250 02/04/2019 4:11 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
One key item missing is the eof tags that should be in the portal box and preserved.

From ubb 7.6

Quote
]/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
Body of the custom box here

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



Noted in red should not be deleted or edited.

Also note as I recall extra blank line feeds outside of the EOF tags could also cause the issue or break the portal island.

Check the WIKI for examples

You may need to restore the EOF tag lines on existing custom islands you have edited.

Last but not least a complete copy of your portal box code would help

Last edited by Ruben; 02/04/2019 5:15 PM. Reason: Added comment.

Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262255 02/05/2019 12:44 PM
Joined: Jun 2008
Posts: 81
mmem700 Offline OP
Journeyman
OP Offline
Journeyman
Joined: Jun 2008
Posts: 81
OK, interesting.

It's no big deal as PHP ignores those extra closing tags.

I had this behavior in v 5.x up to now 7. 7.1.

I'm not using an EOF feature of PHP here. I'm using a few lines of PHP code and it seems to working well (other than the repeating PHP closing tags).

Attached is a screen shot of the cache_builders/custom/portal_box_1.php file showing the multiple PHP end tags creeping in.

Attached Files portal.png

Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262256 02/05/2019 12:53 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
The eof tags are required by the ubb scripts not php persay.
The eof tags have nothing to do with php.
That is the reason for the comment line to not change them.

And yes you can use php and or html between the eof tags.

If you would just insert them back in and clean up the extra php close tags . Save and close.
I think it would resolve your delimma.

PS,
don't forget to make sure all the extra blank line feeds outside of the eof tags are deleted also

Last edited by Ruben; 02/05/2019 1:03 PM. Reason: Added comment

Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262264 02/05/2019 2:40 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
If you continue to ignore the required format to leave the EOF tags intact.
Then this would not be considered a bug.

Probably the reason you have had this issue since v5.x is due to deleting the eof tags. Thinking that it was just a php tag. Where it is not.


Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262369 02/18/2019 1:00 PM
Joined: Jun 2008
Posts: 81
mmem700 Offline OP
Journeyman
OP Offline
Journeyman
Joined: Jun 2008
Posts: 81
See the attached image to see what I'm talking about please. It's not EOF tags. It's closing PHP tags. A new one gets added each time you view and save so you end up with this situation shown in the image.

Hmmm I don't see the ability to attach an image here. I'll use a link to an image then...

[Linked Image]


Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262372 02/18/2019 4:43 PM
Joined: Jun 2006
Posts: 15,851
Gizmo Online Tapedshut
UBB.threads Developer
Online Tapedshut
UBB.threads Developer
Joined: Jun 2006
Posts: 15,851
I can only reproduce this error WHEN the $body EOF declaration is missing, which is required for any custom island to work; if you restore your file and follow the guidelines within the file, as Ruben suggested (and as the system states to NOT change the lines) and it'll process the file properly.
Originally Posted by Gizmo
Is your custom island coding following the example formatting, including the body eof lines?

The issue is that you've removed coding that clearly states not to remove (/* DO NOT CHANGE THE LINE BELOW */ and /* DO NOT CHANGE THE LINE ABOVE */; both of which being the EOF lines). As $body is a requirement for Custom Islands to parse, this is not a bug. A stock Custom Island generates coding as:
Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

Body of the custom box here

EOF;
/* DO NOT CHANGE THE LINE ABOVE */


w3schools: PHP feof() Function


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Need to Upgrade?
Forums: A Gardeners Forum Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262373 02/18/2019 5:33 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
Originally Posted by mmem700
See the attached image to see what I'm talking about please. It's not EOF tags. It's closing PHP tags. A new one gets added each time you view and save so you end up with this situation shown in the image.

Hmmm I don't see the ability to attach an image here. I'll use a link to an image then...

[Linked Image]

It happens because the eof tags are missing.
Again this has nothing to do with actual php tags.
The script looks for the eof tags when saving and creates a proper php file. Without the extra php closing tags.
But you will need to clean them up after you restore the default code with the eof tags as noted above.
You may need to save it twice after edits to clean it completely.

I don't understand why it is so difficult for you to at least try it as suggested.
It is still missing the required format.
It will save you and everyone else headaches.

It will continue to add a closing tag every time you save it till you add back the default code completely period.

Last edited by Ruben; 02/18/2019 5:56 PM. Reason: Added comment.

Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262374 02/19/2019 4:06 AM
Joined: Jul 2006
Posts: 99
Philipp Offline
Journeyman
Offline
Journeyman
Joined: Jul 2006
Posts: 99
This is a bug because of two reasons:

1) There are no longer the "DO NOT CHANGE THE LINE BELOW" and "DO NOT CHANGE THE LINE ABOVE" lines in UBBthreads 7.7:
Code
/* PHP CODE HERE */

/* BODY HERE */
$body = <<<EOF

EOF;


2) It will try to fix the code only if you edit the custom island (editcustomisland.php) but there are not any attempts to fix the code while updating the island with doeditcustomisland.php. So basically, you can publish any broken code you want with doeditcustomisland.php.

A possible solution:

Replace the entire code that cause this problem (editcustomisland.php):
PHP Code
$boxfd = file("{$config['FULL_PATH']}/cache_builders/custom/portal_box_$portal_id.php");
$portal_body = "";
$eof_found = false;
foreach ($boxfd as $linenum => $line) {
	$line = rtrim($line);
	if ($line == "<?php") continue;
	if ($line == "?>" && $eof_found) continue;
	if ($line == "EOF;") $eof_found = true;
	$line = ubbchars($line);
	$portal_body .= "$line\n";
}

$portal_body = trim($portal_body); 


with:
PHP Code
$boxfd = file_get_contents("{$config['FULL_PATH']}/cache_builders/custom/portal_box_$portal_id.php");
$portal_body = ubbchars( str_replace( array( "<?php\n", "?>" ), "", trim($boxfd) ) ); 

So it will no longer try to "fix" the code there

Then add a basic check for $body in doeditcustomisland.php after:
PHP Code
$admin->doAuth(); 

The following code will check for $body = <<<BODY and automatically close it if EOF; is missing. It will also reformat the code if $body is missing:
PHP Code
if( strpos( $portal_body, "\$body = <<<EOF" ) and ( !strpos( $portal_body, "EOF;" ) ) ) $portal_body .= "\nEOF;\n";
if( strpos( $portal_body, "\$body" ) === false ) $portal_body = "/* PHP CODE HERE */\n\n/* BODY HERE */\n\$body = <<<EOF\n" . $portal_body . "\nEOF;\n";
 

Re: Custom Islands Adding ?> Tags [Re: mmem700] #262375 02/19/2019 1:03 PM
Joined: Jun 2006
Posts: 15,851
Gizmo Online Tapedshut
UBB.threads Developer
Online Tapedshut
UBB.threads Developer
Joined: Jun 2006
Posts: 15,851
Actually, it looks like they've shipped as:
Code
/* PHP CODE HERE */

/* BODY HERE */
$body = <<<EOF
EOF;


Since at least 753 (oldest build I have loaded on my file server); the system generates new islands as the expected:
Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

Body of the custom box here

EOF;
/* DO NOT CHANGE THE LINE ABOVE */


Note that this would only affect new installs, as a basic upgrade step is to not upload the folder.

All examples of the Custom Islands at UBBDev or on UBBWiki all reference the later. But, as previously mentioned, you'll still need to add the body eof coding to your CI.

We'll look at updating the default comments on the stock Custom Islands, to bring them in line with how the system generates new entries.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Need to Upgrade?
Forums: A Gardeners Forum Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Re: Custom Islands Adding ?> Tags [Re: mmem700] #262376 02/19/2019 2:06 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
I just went through all the versions.
It appears the notation about don't delete was omitted after version 7.3.1 going forward..
Starting with version 7.4 October 16, 2008

In fact version 7.3.1 only has the notation in portal box 1.php.
I only looked in the default 10 portal box files so I assume that is when this started.

Last edited by Ruben; 02/19/2019 2:36 PM. Reason: Added comment

Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Re: Custom Islands Adding ?> Tags [Re: Gizmo] #262377 02/20/2019 3:54 AM
Joined: Jul 2006
Posts: 99
Philipp Offline
Journeyman
Offline
Journeyman
Joined: Jul 2006
Posts: 99
I did a little more research and found out that the EOF; and ?> issue was introduced in UBB.threads 7.2.0

UBB.threads 7.0/7.1 used this cleanup code:
PHP Code
 $line = trim($line);
	if ($line == "<?php") continue;
	if ($line == "?>") continue;
	$line = htmlentities($line); 

Basically, it goes through each line of the island and ignores lines with "<?php" and "?>".

However, the updated 7.2 code makes not much sense:
PHP Code
 $line = trim($line);
	if ($line == "<?php") continue;
	if ($line == "?>" && $eof_found) continue;
	if ($line == "EOF;") $eof_found = true;
	$line = htmlentities($line); 

This look like some unfinished change. It still ignores "<?php" but ignores "?>" only if there was previously ($eof_found = true;) a line with "EOF;".

Originally Posted by Gizmo
But, as previously mentioned, you'll still need to add the body eof coding to your CI.

This is working as well:
Code
$body = "Some output here";

after the format of $body doesn't matter. The only difference is that $body = <<<EOF .... EOF; is easier after there is no need to escape " with \". The problem here is the code in editcustomisland.php that was introduced in 7.2+

Re: Custom Islands Adding ?> Tags [Re: mmem700] #262552 03/18/2019 2:22 PM
Joined: Dec 2003
Posts: 5,944
Ruben Offline
Offline
Joined: Dec 2003
Posts: 5,944
Never heard back from the OP if this is resolved or not.


Blue Man Group
There is no such thing as stupid questions. Just stupid answers

Forum Search
ShoutChat Box
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
visual accessibility issues.v7.7.3
by Ruben - 08/21/2019 1:50 PM
Holy grail to fix compatibility bewteen browsers
by Ruben - 08/20/2019 4:25 PM
File Manager and Image Uploads
by Ty Griffin - 08/19/2019 4:48 PM
Minimum Post Character Count
by M4TT - 08/19/2019 1:58 PM
[FIXED for 7.7.4] Strange Merge Issue
by Baldeagle - 08/16/2019 3:37 PM
Who's Online Now
2 registered members (isaac, Gizmo), 44 guests, and 191 spiders.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Photos
Stones
Amusing Terain Scenics
Sky places
Work spaces
Powered by UBB.threads™ PHP Forum Software 7.7.3