Previous Thread
Next Thread
Print Thread
Hop To
#262237 02/03/2019 11:07 PM
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
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".
Joined: Jun 2006
Posts: 16,292
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,292
Likes: 116
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.
Do you need Forum Install or Upgrade Services?
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!
Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
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.
Attachments
portal.png


Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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
Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
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 from media.orbisvitae.com]


Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Joined: Jun 2006
Posts: 16,292
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,292
Likes: 116
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.
Do you need Forum Install or Upgrade Services?
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!
Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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 from media.orbisvitae.com]
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
Joined: Jul 2006
Posts: 116
Likes: 4
P
Member
Member
P Offline
Joined: Jul 2006
Posts: 116
Likes: 4
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";
 

Joined: Jun 2006
Posts: 16,292
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,292
Likes: 116
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.
Do you need Forum Install or Upgrade Services?
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!
Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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
Joined: Jul 2006
Posts: 116
Likes: 4
P
Member
Member
P Offline
Joined: Jul 2006
Posts: 116
Likes: 4
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+

Joined: Dec 2003
Posts: 6,560
Likes: 78
Joined: Dec 2003
Posts: 6,560
Likes: 78
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

Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
spam issues
by ECNet - 03/19/2024 11:45 PM
Looking for a forum
by azr - 03/15/2024 11:26 PM
Editing Links in Post
by Outdoorking - 03/15/2024 9:31 AM
Question on barkrowler and the like
by Mors - 02/29/2024 6:51 PM
Member Permissions Help
by domspeak - 02/27/2024 6:31 PM
Who's Online Now
2 members (Gizmo, Nightcrawler), 553 guests, and 186 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)