TinyPortal

Development => Resources => Topic started by: tino on June 09, 2018, 06:34:35 PM

Title: TinyPortal Standalone
Post by: tino on June 09, 2018, 06:34:35 PM
Not sure where this should go...

If you want to have your TinyPortal index on a different page/url to the main forum then you can do the following.


<?php

$ssi_path       
'/path/to/SSI.php';
$forum_path     '/forum';

require_once(
$ssi_path);

ob_start('tp_url_rewrite');

loadTheme();

TPortal_init();
writeLog();

call_user_func(whichTPAction());

obExit(true);

function 
tp_url_rewrite($buffer)
{
        global 
$forum_path;
        if (!empty(
$buffer) && stripos($buffer$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) !== false) {
                
$buffer str_replace($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'], $_SERVER['SERVER_NAME'].$forum_path.$_SERVER['REQUEST_URI'], $buffer);
        }       
        
        return 
$buffer;
}       

?>



I couldn't work out why the menu url etc was set to where I was rather than the path of the forum... so I just rewrote it. A bit of a hack but it works... assumes that you are using index.php on the main page.
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 02:11:07 PM
Would this work for 2.1 ? How is it used exactly. Do I need to make a file named index.php and put this in it. ??
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 02:37:33 PM
It does work, lol. Cool.
Title: Re: TinyPortal Standalone
Post by: lurkalot on August 17, 2019, 02:53:36 PM
Quote from: bigguy on August 17, 2019, 02:37:33 PM
It does work, lol. Cool.

Yes t should work.  I haven't tested or tried it myself, I was hoping tino would see this and answer for you as he wrote it for us. But glad you worked it out.

So where did you test this, got an example BG?
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 03:06:03 PM
Here check the url out. If you try to use it without the /index.php it seems as though the style does not load, also there is no forum button but it does show up.
Link removed as this is a test site. (Lurkalot knows it though)
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 03:06:45 PM
Well, I guess there is a forum button but it says home.
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 03:10:03 PM
And I can't login on that page either.
Title: Re: TinyPortal Standalone
Post by: lurkalot on August 17, 2019, 03:17:11 PM
I don't have any answers for you atm.  I'm wondering what would happen if you had your portal front page settings set to, "Go directly to forum index"
Title: Re: TinyPortal Standalone
Post by: bigguy on August 17, 2019, 03:19:59 PM
They are on "Redirect to forum".
Title: Re: TinyPortal Standalone
Post by: bigguy on August 19, 2019, 10:38:30 AM
OK, it was my cookie settings. This works fine now.
Title: Re: TinyPortal Standalone
Post by: Maxxim on May 24, 2020, 02:25:37 PM
Quote from: tino on June 09, 2018, 06:34:35 PM
A bit of a hack but it works... assumes that you are using index.php on the main page.

Thanks a lot for this, @tino! This is exactly what I was looking for.
The code seems to work, but on my localhost WAMP setup (Windows 10, Apache 2.4, MySQL 5.7, PHP 7.1) it also displays the following:
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in <full path to www root>\index.php on line 15

I've got some IT background, but I'm definitely not a coder, so I would appreciate any help in dealing with this.
Title: Re: TinyPortal Standalone
Post by: tino on May 24, 2020, 06:28:39 PM
Can you make sure that the hook which calls this file exists TPassimilate.php

I don't think it's loading properly for that error to appear
Title: Re: TinyPortal Standalone
Post by: Maxxim on May 25, 2020, 09:40:27 AM
TPassimilate.php is in Sources directory where it belongs. I compared it with the one included in TinyPortal-1.6.6.zip, and it's a 100% match.

As for other installed mods, I only have Pretty URLs 2.3. Tried disabling it, but that didn't make the warning go away. I'm running SMF 2.0.17.
Title: Re: TinyPortal Standalone
Post by: tino on May 25, 2020, 12:15:01 PM
Not the file itself the hook in the hooks area should be listed. It's in one of the admin sections, can never remember where mind.

If not SSI.php might not be including TinyPortal correctly.
Title: Re: TinyPortal Standalone
Post by: lurkalot on May 25, 2020, 12:55:53 PM
Quote from: tino on May 25, 2020, 12:15:01 PM
Not the file itself the hook in the hooks area should be listed. It's in one of the admin sections, can never remember where mind.

If not SSI.php might not be including TinyPortal correctly.

Tino, don't think, or at least I haven't seen it in the 2.0.17  It's easily findable in 2.1 in maintenance > Forum Maintenance > Integration Hooks.
Title: Re: TinyPortal Standalone
Post by: vbgamer45 on May 26, 2020, 04:51:57 AM
2.0 requires this mod https://custom.simplemachines.org/mods/index.php?mod=3285
Title: Re: TinyPortal Standalone
Post by: Maxxim on May 26, 2020, 05:31:16 AM
I've installed emanuele's Integration Hooks Report (?mod=3285), and here's what it shows:
(waiting for moderator to approve image attachment :)

PS. sniped by @vbgamer45 XD

PPS. The code seems to work only if I specify
$ssi_path       = './forum/SSI.php';
$forum_path     = '';


If I set $forum_path     = '/forum'; (which makes sense because that's where forum files are located), it fails to apply theming to the output.
Title: Re: TinyPortal Standalone
Post by: lurkalot on May 26, 2020, 07:51:02 AM
Tino, I don't know if this has any relevance.

In your code, first post of this topic, this line,

loadTheme();

I noticed in the included (in package) TP TPStanalone.php file it has this

loadTheme(1, false);
Title: Re: TinyPortal Standalone
Post by: Maxxim on May 26, 2020, 11:10:24 AM
I also noticed that Integration Hooks Report left 38 pages of error messages in my SMF Error Log. Looks like whenever it's called, it produces two errors, "Array to string conversion" and "Undefined variable: Array".

The offender is line 327 in Subs-IntegrationHooks.php (the mod's file):
$sort[] = $$sort_options[0];
I wonder if we can trust the tool's output.

Unfortunately, the mod's authors are not around any more, so chances of getting support are very slim.
Title: Re: TinyPortal Standalone
Post by: tino on May 26, 2020, 07:39:05 PM
The one included might work better, I've not tested it in a while tbf. I had hoped to find some time to look at it this week in a test install but time as always is fleeting atm.
Title: Re: TinyPortal Standalone
Post by: tino on May 29, 2020, 09:57:00 AM
I just tried the one packaged in with TinyPortal 1.6.x with SMF 2.0 and it works ok if I add the $forum_version into the script (otherwise TPShout has a issue)

The one on Github for TinyPortal 2.0.0 also works as expected without any modifications.

The one on the opening post here is out of date.

This is what is needed for TinyPortal 1.6.x

https://github.com/Tinyportal/TinyPortal/blob/1.6.x/TPStandalone.php

Adding the SMF Version before the loadTheme line

$forum_version  = 'SMF 2.0.17';

Title: Re: TinyPortal Standalone
Post by: Maxxim on May 29, 2020, 03:24:06 PM
Thank you, Tino, that seems to work now! :)

However... Either I'm doing something wrong here or it doesn't play nice with custom themes (even with Curve derivatives like Ant's Mutant Curve). It does load the theme I specify in loadTheme(), but it totally mangles the linktree area and the footer. :(
Title: Re: TinyPortal Standalone
Post by: tino on May 29, 2020, 04:50:37 PM
I never tried it with a custom theme. I'll have a look this weekend and see what's causing that.
Title: Re: TinyPortal Standalone
Post by: tino on May 29, 2020, 06:07:29 PM
Try the below


<?php
/**
 * TPStandalone.php
 *
 * @package TinyPortal
 * @version 1.6.7
 * @author tinoest - http://www.tinyportal.net
 * @founder Bloc
 * @license MPL 2.0
 *
 * The contents of this file are subject to the Mozilla Public License Version 2.0
 * (the "License"); you may not use this package except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Copyright (C) 2020 - The TinyPortal Team
 *
 */
ob_start('tp_url_rewrite');
global 
$boardurl$context$txt;

$txt['tp-tphelp']   = 'TinyPortal';

$forum_version      'SMF 2.0.17';
$forum_path         '/var/www/html/forum/';

require_once(
$forum_path '/Settings.php');

$context['TPortal'] = array();
$actual_boardurl    $boardurl;

require_once(
$forum_path '/SSI.php');

TPortal_init();

writeLog();

call_user_func(whichTPAction());

obExit(true);

function 
tp_url_rewrite($buffer) {{{
    global 
$actual_boardurl$boardurl;
    if (!empty(
$buffer) && stripos($buffer$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) !== false) {
        
$buffer str_replace($boardurl$actual_boardurl$buffer);
    }

    return 
$buffer;
}}}

?>

Title: Re: TinyPortal Standalone
Post by: Maxxim on May 30, 2020, 05:46:31 AM
It seems to work flawlessly now with several custom themes and Pretty URLs enabled.  :D
A triple huzzah for Tino! O0 O0 O0
Title: Re: TinyPortal Standalone
Post by: makuta_iii on July 05, 2020, 07:43:49 PM
Hi.
Is such a solution possible (of course, if you make the necessary changes) to display the main page of the portal on a separate page, if you put this code in the file portal.php? My forum is located at forum.wabisabi.by and i would like to see the portal Frontpage with articles at link forum.wabisabi.by/portal. This is now implemented on this forum, but not using your portal, unfortunately.
Sorry if I repeat my question, but this is the only problem that I can not solve to install your portal on my forum.

Thanks.
Title: Re: TinyPortal Standalone
Post by: @rjen on December 27, 2021, 10:11:58 PM
Just tried to get Tpstandalone working but failed miserably. I wanted to see if I can add this to the documentation site.

Can anyone give me a few pointers how to use it?
Title: Re: TinyPortal Standalone
Post by: tino on December 28, 2021, 01:33:49 AM
Quote from: @rjen on December 27, 2021, 10:11:58 PM
Just tried to get Tpstandalone working but failed miserably. I wanted to see if I can add this to the documentation site.

Can anyone give me a few pointers how to use it?

It may be that the current one no longer works. Are you using the one from this thread or the one included with TinyPortal?
Title: Re: TinyPortal Standalone
Post by: @rjen on December 28, 2021, 06:00:50 AM
I tried both on SMF 2.0.19 but I am getting 500 errors
Title: Re: TinyPortal Standalone
Post by: tino on December 28, 2021, 12:58:52 PM
Quote from: @rjen on December 28, 2021, 06:00:50 AM
I tried both on SMF 2.0.19 but I am getting 500 errors

What is showing in the Apache/nginx/lighttpd error log?

Also what version of SMF please.

Below is a version which requires fewer code edits. Should be none if you put it in the same directory as SSI.php

<?php
/**
 * TPStandalone.php
 *
 * @package TinyPortal
 * @version 2.1.0
 * @author tinoest - http://www.tinyportal.net
 * @founder Bloc
 * @license MPL 2.0
 *
 * The contents of this file are subject to the Mozilla Public License Version 2.0
 * (the "License"); you may not use this package except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Copyright (C) - The TinyPortal Team
 *
 */
ob_start('tp_url_rewrite');


global 
$boardurl$context$sourcedir;

require_once(
dirname(__FILE__) . '/Settings.php');

$actual_boardurl    $boardurl;

require_once(
dirname(__FILE__) . '/SSI.php');
require_once(
$sourcedir '/TPortal.php');

TPortal_init();

$context['TPortal']['front_type'] = 'forum_articles';
doTPfrontpage();

writeLog();

TPortalMain();

obExit(true);

function 
tp_url_rewrite($buffer) {{{
    global 
$actual_boardurl$boardurl;
    if (!empty(
$buffer) && stripos($buffer$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']) !== false) {
        
$buffer str_replace($boardurl$actual_boardurl$buffer);
    }

    return 
$buffer;
}}}

?>
Title: Re: TinyPortal Standalone
Post by: @rjen on December 28, 2021, 06:59:23 PM
I put the latest file in the root of my test forum (2.0.19) and it works for me when logged in.
However when a guest accesses the page he gets a white page ( try: https://test.fjr-club.nl/TPstandalone.php)

Then there are two observations:

1. When accessing TPstandalone the Tinyportal menu option is missing...

2. There are some encoding issues on the page: see example

Is this the intended install option? I thought it was also intended to be able to put the file in a different folder / location?

What is needed to make that work?


Title: Re: TinyPortal Standalone
Post by: @rjen on December 28, 2021, 07:08:57 PM
On SMF2.1 it works for guests (try: https://test2.fjr-club.nl/TPstandalone.php)

But when I am logged in as admin it takes 30 seconds to load, where all other pages load fine...
Title: Re: TinyPortal Standalone
Post by: tino on December 28, 2021, 08:32:48 PM
The menu option is missing due to the way it loads, well TinyPortal loads.

Encoding issues, I don't know what's causing that as it's the same calls as SMF makes, unless there is a section of code where the encoding type is set not called.

What error's do you get for the guest access?

To put it where ever you like you need to include Settings.php and TPortal.php correctly. Whatever that path is.
Title: Re: TinyPortal Standalone
Post by: tino on December 28, 2021, 08:53:01 PM
If you add this after the require_once('Settings.php') line then it loads the TinyPortal Menu



$txt['tp-tphelp']   = 'TinyPortal';
$context['TPortal'] = array();
Title: Re: TinyPortal Standalone
Post by: @rjen on December 28, 2021, 10:05:12 PM
Quote from: tino on December 28, 2021, 08:53:01 PM
If you add this after the require_once('Settings.php') line then it loads the TinyPortal Menu



$txt['tp-tphelp']   = 'TinyPortal';
$context['TPortal'] = array();


that worked on 2.1, but not on 2.0.19
Title: Re: TinyPortal Standalone
Post by: @rjen on December 28, 2021, 10:09:01 PM
Quote from: tino on December 28, 2021, 08:32:48 PM
What error's do you get for the guest access?


Just checked the website error log: no errors logged that I can find
Title: Re: TinyPortal Standalone
Post by: tino on December 30, 2021, 10:32:47 AM
Quote from: @rjen on December 28, 2021, 10:09:01 PM
Quote from: tino on December 28, 2021, 08:32:48 PM
What error's do you get for the guest access?


Just checked the website error log: no errors logged that I can find

I can't recreate this one, loads fine as a guest or user.