Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to fix Parser Error

edited April 2016 in Vanilla 2.0 - 2.8

How can I fix this error?

I have downloaded PHP jsConnect client library, and I have a test URL that is only a link that redirects to (http://myforum.com/?p=/sso/index.php)

This is my code of index.php ,

<?php
header('Content-Type: application/javascript');
$message = "This alert tests if connection is successful";
echo "alert('$message');";
require_once('/functions.jsconnect.php');
//require_once dirname(FILE).'/functions.jsconnect.php';
// 1. Get your client ID and secret here. These must match those in your jsConnect settings.
$clientID = "1122334455";
$secret = "abcdefghi";
// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder
// YOUR CODE HERE.
// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();
if ($signedIn) {
// CHANGE THESE FOUR LINES.
$user['uniqueid'] = '44556677';
$user['name'] = 'John MARTIN';
$user['email'] = 'john.martin@gmail.com';
$user['photourl'] = '';
}
// 4. Generate the jsConnect string.
// This should be true unless you are testing.
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
$secure = true;
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);


PHP Version: 5.3**
**Vanilla Version: 2.2****

I need to log on with the user "John Martin", but when I press the link redirects me to my forum I got Parser Error

oet.png 160.5K
«1

Comments

  • Anyone please?

  • hgtonighthgtonight ∞ · New Moderator

    What does the url look like that gives you the parse error?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • edited April 2016

    Like this, @hgtonight http://myforum.com/index.php?p=/entry/jsconnect/error

    Actually, I placed an alert as you see on my code to test if my index.php runs but does not, so I think that my problem is on that file
    I did what you suggest placing $secure = false instead of $secure = true but the Parser Error is still active

  • @hgtonight
    And this is how I configured Jsconnect on my forum

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    why are you not using pretty urls?

    Please try to fix this by fixing your htaccess file and also check you have Rewrite Url enabled in the config.php

    Not using pretty Urls is the cause of many many many issues. Plus it looks ugly ..

  • edited April 2016

    @vrijvlinder
    I did what do you suggest me to enable "Rewrite URL" in the config.php $Configuration['Garden']['RewriteUrls'] = TRUE;

    But when I try to access Discussions my forum breaks out....

    It gives me the following: ## ¡Object not found! Error 404 and the url shows this: http://myforum.com/discussions

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2016

    But when I try to access Discussions my forum breaks out….

    That may be because the htaccess file rewrite module needs to also be enabled. Please post the contents of the htaccess
    file .

  • hgtonighthgtonight ∞ · New Moderator

    Pretty urls is something you should fix, but not the cause of this issue. Go to your sso endpoint on your server (whatever url will load your custom index.php file). It isn't outputting json, which is causing your parse error. Test it out.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight
    Ok, I got it.. the reason is that json is not outputting, but what do you mean about going to my sso endpoint? I think that you are talking about index.php, which main code I post it at the beginning of this discussion and I really don't know what I need to modify

  • hgtonighthgtonight ∞ · New Moderator

    You need to get to the output of the index.php file. This should be somewhere outside of the forum software.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight
    I google for my problem as "JSON not responding" and one user said that he deactivated some plug ins and for some reason json worked, this is the discussion https://vanillaforums.org/discussion/23766/json-sso-not-working

    And gets a kind of sense cause the vanilla debug shows me this messages:
    Undefined property: DiscussionsController::$Offset in /www/htdocs/plugins/MFCDiscussionPagination/class.MFCDiscussionPagination.plugin.php line 41
    Undefined variable: Limit in /www/htdocs/plugins/MFCDiscussionPagination/class.MFCDiscussionPagination.plugin.php line 30

  • hgtonighthgtonight ∞ · New Moderator

    You can try disabling the MFCDiscussionPagination plugin, but I don't think that is the issue.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • edited April 2016

    @hgtonight said:
    You need to get to the output of the index.php file. This should be somewhere outside of the forum software.

    @hgtonight
    Ok I think that I'm starting to find the light at the end of the tunnel, and this might be hard to explain..

    I have /www that contains htdocs , old , and vanilla as you see here

    /htdocs , besides other folders, contains test.php (This file have a simple url that redirects to http://myforum.com/?p=/sso/index.php)

    Then, on /vanilla it's all my forum and also there is /sso folder that contains PHP jsConnect client library files as I show you here

    I don't know if this is what you mean about getting output of the index.php file ?

    Still online waiting for your help, THANKS!

  • hgtonighthgtonight ∞ · New Moderator

    You should be able to see the output of your index.php at http://forums.example.com/vanilla/sso/index.php.

    I would suggest you move the entire sso folder out of the vanilla folder and into a separate area. It is generally put somewhere convenient for the connecting software.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • edited April 2016

    @hgtonight
    Please tell me that this is a good notice...

    I move my /sso folder outside /vanilla and I place it on /htdocs

    And when I'm on test.php and try to access to index.php it gives me this

    I think that it is a good notice, because Parser Error disappeared, but I have a new one, nothing of my index.php runs, only the alert that I put but it only shows as text not as an alert as I want

    Still online

    EDIT:

    I don't know if this helps , it is the /htdocs

  • hgtonighthgtonight ∞ · New Moderator

    Change your require once line to not be an absolute path:

    require_once('functions.jsconnect.php');
    

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight

    I really think that I have good news, I modified my code of index.php as you said in your last reply like this:
    <?php
    header('Content-Type: application/javascript');
    require('functions.jsconnect.php'); <--- I ONLY MODIFIED THIS LINE
    ...
    ...
    Same code

    And when I go to test.php and press my URL that redirects to my forum I get this:

    Looking at functions.jsconnect.php I found this

    So my conclutions are:
    1) Having all in /www/htdocs was right
    2) I think that I am very close to find my problem because functions.jsconnect.php executes a little, but it does
    3) Again, Parser Error disappeared :pleased:

    Thanks thanks thanks for your help hgtonight, If we are very close to the solution I will be grateful forever

  • @hgtonight

    Modified this line

    $secure = true;
    WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

    to this:
    $secure = false;
    WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

    And then I got this

    ¿I'm more close to the solution?

  • hgtonighthgtonight ∞ · New Moderator

    You have verified that your sso endpoint is executing and spitting out JSON via the jsconnect php library.

    You still need to modify that file to load the user information from your other connecting software. Once that is done and working, set secure back to true and you should be good to go.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight
    I think you mean index.php to find where it can load the user info

    I'm gonna try and I will inform you when everything executes correctly, Thanks for your help

Sign In or Register to comment.