PHP Parse error: syntax error, unexpected '$url'

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Sun Jan 14, 2018 11:53 pm

hi i am having a problem with auto-detected links since upgrading to 3.2.1, appended to the end of each url is the following code....

onclick="window.open(this.href);return false;

i have googled and tried to fix the problem by doing the tutorial below
https://www.phpbb.com/support/docs/en/3 ... w-windows/

after doing the tutorial i get a http error 500

the error in the log file says the following
PHP Parse error: syntax error, unexpected '$url' (T_VARIABLE) in ......./includes/functions_content.php on line 912

this is the corresponding code,the error is with the first "$url"..... can someone help please?

Code: Select all

if ($type == MAGIC_URL_EMAIL)
    {
        $html    = "$whitespace<!-- $tag --><a$class href="$url">$text</a><!-- $tag -->$append";    
    }
    else 
    {
        $html    = "$whitespace<!-- $tag --><a$class href="$url" onclick="window.open(this.href);return false;">$text</a><!-- $tag -->$append";
    } 

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Brf » Mon Jan 15, 2018 12:14 am

That looks like some sort of a "open urls in another window" mod.
functions_content does not have any "ifs" in that area. Everything is handled by a switch/case statement.

User avatar
Lumpy Burgertushie
Registered User
Posts: 66935
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Lumpy Burgertushie » Mon Jan 15, 2018 12:28 am

what version did you update from and exactly how did you do the update.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 12:38 am

Brf wrote:
Mon Jan 15, 2018 12:14 am
That looks like some sort of a "open urls in another window" mod.
functions_content does not have any "ifs" in that area. Everything is handled by a switch/case statement.
the if statement came from this link https://www.phpbb.com/support/docs/en/3 ... w-windows/

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 12:44 am

Lumpy Burgertushie wrote:
Mon Jan 15, 2018 12:28 am
what version did you update from and exactly how did you do the update.


robert
3.0.10 to 3.0.14 then to 3.2.1, it wasn't a straight forward upgrade,was a bit messy because of mods

the upgrades were done by following the instructions in this https://www.phpbb.com/support/docs/en/3 ... /upgrade3/

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10348
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Noxwizard » Mon Jan 15, 2018 12:49 am

Dunnocks wrote:
Sun Jan 14, 2018 11:53 pm
i have googled and tried to fix the problem by doing the tutorial below
https://www.phpbb.com/support/docs/en/3 ... w-windows/
That article is not a fix, that is how to change the existing behavior to make links now open in a new window. Additionally, that article is for 3.0 and should not be used on 3.2. If you have made these changes to your 3.2 board, you need to undo them.
Dunnocks wrote:
Sun Jan 14, 2018 11:53 pm
hi i am having a problem with auto-detected links since upgrading to 3.2.1, appended to the end of each url is the following code....

onclick="window.open(this.href);return false;
From this, it sounds like you had already applied that KB article to your 3.0 board, which is why this problem has shown up.

The fix is here: viewtopic.php?f=466&t=2269196#links_new_window
It hasn't been tested on 3.2, so be sure to back up your database first.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 1:15 am

Noxwizard wrote:
Mon Jan 15, 2018 12:49 am
Dunnocks wrote:
Sun Jan 14, 2018 11:53 pm
i have googled and tried to fix the problem by doing the tutorial below
https://www.phpbb.com/support/docs/en/3 ... w-windows/
That article is not a fix, that is how to change the existing behavior to make links now open in a new window. Additionally, that article is for 3.0 and should not be used on 3.2. If you have made these changes to your 3.2 board, you need to undo them.

Dunnocks wrote:
Sun Jan 14, 2018 11:53 pm
hi i am having a problem with auto-detected links since upgrading to 3.2.1, appended to the end of each url is the following code....

onclick="window.open(this.href);return false;
From this, it sounds like you had already applied that KB article to your 3.0 board, which is why this problem has shown up.

The fix is here: viewtopic.php?f=466&t=2269196#links_new_window
It hasn't been tested on 3.2, so be sure to back up your database first.
i have undone the changes i made ,then i have applied your fix from above but got this message

Successfully disabled execution time

Updates needed: 0
Running updates in batches of 100
Finished processing 0 rows.

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 5:13 pm

so i presume this fix will not work on 3.2?

User avatar
warmweer
Registered User
Posts: 3224
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: PHP Parse error: syntax error, unexpected '$url'

Post by warmweer » Mon Jan 15, 2018 5:57 pm

Dunnocks wrote:
Mon Jan 15, 2018 5:13 pm
so i presume this fix will not work on 3.2?
I should still have a backup of the upgrade I made last week to test your board but I didn't notice the open link in new window problem.
If I have time this evening, I'll have a look in the posts_table.
On my old 3.0.12 board I also had the open link in new window (I can't remember where that change was, ow yes the magic url bit) but I didn't apply that when I updated to 3.0.14. Upgrading to 3.2.1 didn't cause any problems apart from having a few posts with leftovers from those links which I edited manually in the posts_table.
If there'aren't too many posts with that problem, it should be possible to fix that relatively quickly.
The year is 2192. The British Prime Minister visits Brussels to ask for an extension of the Brexit deadline. No one remembers where this tradition originated, but every year it attracts many tourists from all over the world.

User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10348
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Noxwizard » Mon Jan 15, 2018 9:12 pm

This should do it for you:

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
still_on_time();

$batch_size = 100;

$sql = 'SELECT COUNT(post_id) as cnt
    FROM ' . POSTS_TABLE . ' 
    WHERE post_text ' . $db->sql_like_expression($db->get_any_char() . '</URL>" onclick="window.open(this.href);return false;' . $db->get_any_char());
$result = $db->sql_query($sql);
$affected = (int) $db->sql_fetchfield('cnt');

if (set_time_limit(0))
{
    echo 'Successfully disabled execution time<br />';
}
else
{
    echo 'Unable to disable execution time limit. You may need to run this script again.<br />';
}
echo '<br />';
echo 'Updates needed: ' . $affected . '<br />';
echo 'Running updates in batches of ' . $batch_size . '<br />';

flush();

// Counting basically holds the amount of rows processed.
$counting = -1;
$batch_time = 0;

$_sql = 'SELECT post_id, post_text 
    FROM ' . POSTS_TABLE . ' 
    WHERE post_text ' . $db->sql_like_expression($db->get_any_char() . '</URL>" onclick="window.open(this.href);return false;' . $db->get_any_char());

$skip_rows = 0;
while ($counting === -1 || ($counting >= $batch_size && still_on_time()))
{
    $result = $db->sql_query_limit($_sql, $batch_size, $skip_rows);
    
    // Now handle the rows until time is over or no more rows to process...
    $counting = 0;
    while ($counting === 0 || still_on_time())
    {
        $row = $db->sql_fetchrow($result);
        if (!$row)
        {
            // move to the next batch
            break;
        }

        $message = str_replace('</URL>" onclick="window.open(this.href);return false;', '</URL>', $row['post_text']);

        $sql_update = array(
            'post_text'        => $message,
            'post_checksum'    => md5($message),
        );
        
        $sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_update) . ' WHERE post_id = ' . $row['post_id'];
        $db->sql_query($sql);

        $counting++;
        $skip_rows++;
    }
    $db->sql_freeresult($result);
}

if (still_on_time() && $counting < $batch_size)
{
    echo 'Finished processing ' . $skip_rows . ' rows.';
    exit;
}
else
{
    echo 'Rows completed: ' . $skip_rows . '<br />Rows remaining: ' . ($affected - $skip_rows) . '<br /><br />This script will resume in 5 seconds';
    echo '<meta http-equiv="refresh" content="5;" />';
}
Again, make a database backup first.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 9:37 pm

thank you, that fixed it :D

now how do i go about opening auto detected links in new window?

User avatar
janus_zonstraal
Registered User
Posts: 3805
Joined: Sat Aug 30, 2014 1:30 pm

Re: PHP Parse error: syntax error, unexpected '$url'

Post by janus_zonstraal » Mon Jan 15, 2018 9:59 pm

Sorry! My English is bat ;) !!!

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 10:13 pm

im having a problem with extensions and this is probably for another thread

i do have 2 official extensions enabled and running well but since then anytime i upload new extensions they are not showing up in Extensions Manager

anyone know whats up?

User avatar
janus_zonstraal
Registered User
Posts: 3805
Joined: Sat Aug 30, 2014 1:30 pm

Re: PHP Parse error: syntax error, unexpected '$url'

Post by janus_zonstraal » Mon Jan 15, 2018 10:20 pm

Sorry! My English is bat ;) !!!

Dunnocks
Registered User
Posts: 223
Joined: Tue Jul 05, 2011 9:16 pm
Location: Ireland

Re: PHP Parse error: syntax error, unexpected '$url'

Post by Dunnocks » Mon Jan 15, 2018 11:03 pm

janus_zonstraal wrote:
Mon Jan 15, 2018 10:20 pm
Wrong path?
See
https://www.phpbb.com/extensions/installing/
yeah :D

thanks lads

Post Reply

Return to “[3.2.x] Support Forum”