Kodi Community Forum
MediaFrontPage - Web interface with widget type architecture to control multiple apps - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116)
+--- Thread: MediaFrontPage - Web interface with widget type architecture to control multiple apps (/showthread.php?tid=83304)



- gugahoi - 2011-06-01

drunkendragon Wrote:1. Do I edit the size of the scrollbar in scrollbar.css ?
2. When i've time i'll check the authorisation page, because an htacces solution was already on my todo list, because im using MFP more and more. Also from outside my LAN.
3. I'll check the play function in recent Tv, movies $results = jsonmethodcall("XBMC.Play", '"file":'.escapeshellarg($videoInfo['file']).'"');
4. The new config.php is really nice. Should be in the master!
5. A PHP widget to connect to the Youtube Api for searching video's would be nice! I use greasymonkey to play them remotely on my htpc

We have a national holiday comming up, but im painting my living room. So don't know when i give some feed back, but i'm always into some testing on a user level Smile

1. Yep
4. Just did!
5. Will look into it after v1.0. If you want, create a ticket in mediafrontpage.lighthouseapp.com so we can keep it in our todo list.
niietzshe Wrote:Just a quick example, I have my sickbeard widget on the left showing comingEpisodes. If I click on one I get this error page:

Code:
This web page is not available
The web page at [url]http://****:****@localhost:8081/home/displayShow?show=78804[/url] might be temporarily down or it may have moved permanently to a new web address.

*From outside my network. Inside would work I think, maybe not actually, unless I change localhost to the IP of my htpc...

So really what I'm saying is, I need it to look at the htpc's localhost, not the localhost of the computer I'm currently using.

What you should have is http://USER:[email protected]:8081/

Also remember you will have to tell your router which computer it should direct calls to that port (port forwarding). If you have multiple computers in your network then the router would not know which computer is supposed to be called when it is accessed through that port.

You should have most of your links with your DynDNS url. It should work from both internal and external network. Otherwise the entire concept of IP would not work.

_Mikie_ Wrote:I used the merge upstream master and it seems to have worked. My repo should be the same as the master but with authentication added. I updated the new config to work. Please could you check that my if statement for global is correct. Not 100% about that one. Also using your config it says logging out and then takes an age to actually log out. Don't quite know why. Possibly the if (session_id()=='') session_start(); being so low down in the config? I don't know though. Also don't know if the way session start is being used is ideal.

In general please just look over everything and see that its all alright. If anyone wants to test it out

https://github.com/Mikie-Ghost/mediafrontpage

Great! I think you're right. session start is supposed to be one of the first things. Maybe it should be started in the top of the login page? Or maybe the Auth page? Not the config, specially since it is not directly accessed?


- _Mikie_ - 2011-06-01

gugahoi Wrote:1. Yep
4. Just did!
5. Will look into it after v1.0. If you want, create a ticket in mediafrontpage.lighthouseapp.com so we can keep it in our todo list.


What you should have is http://USER:[email protected]:8081/

Also remember you will have to tell your router which computer it should direct calls to that port (port forwarding). If you have multiple computers in your network then the router would not know which computer is supposed to be called when it is accessed through that port.

You should have most of your links with your DynDNS url. It should work from both internal and external network. Otherwise the entire concept of IP would not work.



Great! I think you're right. session start is supposed to be one of the first things. Maybe it should be started in the top of the login page? Or maybe the Auth page? Not the config, specially since it is not directly accessed?

Well all the pages access the config so maybe that's why it needs to be in there. I'll play around and see if I can find a solution.


- _Mikie_ - 2011-06-01

_Mikie_ Wrote:Well all the pages access the config so maybe that's why it needs to be in there. I'll play around and see if I can find a solution.

EDIT: So the session has to be started before any headers are sent. Every page that needs to use the session needs to be linked to the session hence it being put in the config file.


- DejaVu - 2011-06-01

Is the default-config-new.php active on the official repo yet? Have the variable case name changes been implemented?


- CoinTos - 2011-06-01

SleepyP Wrote:CoinTos, what branch are you running? I committed a version of this widget recently that should work regardless of what version of XBMC you use and regardless of what database back-end you use (meaning nightly, stable, MySQL, and SQLite should all work). Can you test my XBMC Library widgets?
https://github.com/DivinityCycle/mediafrontpage is my repo
You would need to pull xbmcjsonlib.php, functions.php, /Widgets/wXBMCLibrary.php, and /Widgets/libXBMCLibrary.php from there for testing purposes.
I run a custom version of gugahoi's branch currently, but for xbmc I use XBMC4Xbox, so there are limits currently as the remote api is the httpapi and the backend db is only available via ftp.
gugahoi Wrote:I got it now but from my testing it didn't seem to work... I'm on a mac using chrome and it said it was an unknown browser....
Not a problem, print/echo your $userAgent string and post/message it then I will fix it, I was depending on a third party site for browser agent strings for testing so I didn't expect it to be prefect. Smile

Edit @niietzshe:

You gonna have to edit your config where you have localhost remove it and put this in its place ".$_SERVER["HTTP_HOST"]."
Example:
Code:
$sickbeardcomingepisodes = 'http://user:password@".$_SERVER["HTTP_HOST"].":PORT/sickbeard/comingEpisodes/'
What this does is replace your localhost with whatever url or ip or hostname that is calling it. So if it is http://192.168.1.1/ it will be 192.168.1.1 or http://dyn.dns/ it will be dyn.dns in that variable. With reverse proxy I don't know if you will need the port, you will have to trial and error on that.


- gugahoi - 2011-06-02

_Mikie_ Wrote:With regard to sickbeard asking for authentication all the time I think chrome must store the username and password or handle it differently. The only way I can think of solving the issue entirely alone with the user and pass being show is to in a sense create a proxy to sickbeard. So not only the initial request is curled but all requests are curled thus using the curl authentication method for everything and not having user/pass in url. Its quite a major overall though that is beyond my knowledge so unless someone else wants to try it will have to stay as is.

I think this is more of a sickbeard problem. Remember the coming episodes widget is nothing more of a hack. The page is in fact the original page, but stripped to fit MFP's styling. I believe we would have to wait till they have an API to get the sickbeard related features working appropriately, in the same way that we have been waiting for a CP API.

DejaVu Wrote:Is the default-config-new.php active on the official repo yet? Have the variable case name changes been implemented?

It is active, should all be working. I would advise you to backup your current config page and try using the new one from scratch, if you run into any problems, just report them (or if you know how to, fix them! Big Grin)


- SleepyP - 2011-06-02

I was able to get a pretty thorough testing done of a configuration that should work for somebody using reverse proxies who wants to access MFP from outside the LAN. From my findings, you generally should be using the domain name version of your addresses if you plan to access your MFP from outside your LAN. What do I mean by that? I'm going to use IRuleYou.no-ip.org as my example domain name. In this setup, IRuleYou.no-ip.org is pointing at some public IP address, which is your home public IP provided by your ISP. Like others have said, if you're using a dynamic DNS provider, the domain name should point correctly at your house even if your IP changes.

Assuming your ISP does not block inbound port 80 (some do), and you forward port 80 to your server, and you are using Apache on port 80, you will be able to reach Apache from anywhere by going to
http://iruleyou.no-ip.org
You do NOT have to specify a port # in that address because 80 is the worldwide default port for HTTP. I'm gonna refer to http://iruleyou.no-ip.org as the "public URL". Note, if you are using an alternate port for this, then your "public URL" will actually be
http://iruleyou.no-ip.org:9999
or whatever port it is. For a non-standard port like that, you MUST use that port in that format everywhere. I mean in your web browser, in your config, etc.

What the reverse proxying does is let you connect up your services to nice & easy directories. In this context, you just slap those directories onto the end of your "public URL". So like if you have set up your reverse proxy so that Sick Beard is accessible at "/tv", then with the above example, you could access Sick Beard by going to
http://iruleyou.no-ip.org/tv
Notice that there's no port # in here. This is because from the internet we are connecting to just port 80, which for your setup connects us to Apache. Apache's proxy set up is what handles the internal communications to / from the weird port numbers and addresses your services are actually running on. Of course, if you are using a different port for Apache, you must specify it even if you're getting to Sick Beard, so it would look like this:
http://iruleyou.no-ip.org:9999/tv

Once you have your public address set up, you should use it for pretty much all of your config.php settings. This is especially important for anything that serves up images. For the widgets that serve images up, you can actually usually get away with a "local" address from the perspective of the server, so like 192.168.1.x or even localhost will work. This is because in PHP, the server itself is running the scripts, so the server itself is talking to those addresses and retrieving info from them. However, if you use "local" addresses for widgets that return images, you will end up with the image source being like "http://192.168.1.x/tv/comingepisodes/somecrap.jpg". When you are outside your local network, such addresses will NOT mean anything and your MFP widgets will have broken images in them. Just make it easier on yourself and use your public URL for everything in your config.php if you plan on accessing MFP from outside your LAN.

Please also note: if you are using a smart phone and aren't connected to your WiFi, you are going to be accessing MFP from outside your LAN, even if you're sitting in your house when you do it.


- SleepyP - 2011-06-02

Hey Gugahoi, I'm working through your revised config.php. It's really nice. My item-specific thoughts:
-$GLOBAL_IP is a confusing variable name, since anyone wishing to access MFP from the internet will not be typing in an IP address here. I worked it out from trial & error. Would it be possible to rename it $GLOBAL_URL or something like that? Just my $.02
-Really good documentation for the Search Widget section!
-The "XBMC MySQL Connections" section is at this point not needed or used by any widgets, unless I am wrong. At present all the XBMC Library widgets talk to XBMC's JSON interface to get their info.

The Reverse Proxy section didn't make any sense to me, but I may have misinterpreted how I was supposed to do the variables. I re-wrote that section. Here's portions of my config.php so you can see what I did:
Code:
$GLOBAL_MACHINE      = true;
     $GLOBAL_USER_PASS    = true;
     $GLOBAL_IP           = 'home.houseofgeeks.org';
     $GLOBAL_USER         = 'xxx';
     $GLOBAL_PASS         = 'xxx';
    
     $REVERSE_PROXY       = true;
     $XBMC_WEBROOT        = 'xbmc';
     $SICKBEARD_WEBROOT   = 'tv';
     $COUCHPOTATO_WEBROOT = 'couchpotato';
     $SABNZBD_WEBROOT     = 'sabnzbd';
     $UTORRENT_WEBROOT    = '';
     $JDOWNLOADER_WEBROOT = '';
     $TRANSMISSION_WEBROOT= 'transmission';

And then at the bottom
Code:
if($REVERSE_PROXY){
    if(!empty($XBMC_WEBROOT)){
        $xbmcjsonservice = 'http://'.$GLOBAL_IP.'/'.$XBMC_WEBROOT.'/jsonrpc';
        $xbmcimgpath     = 'http://'.$GLOBAL_IP.'/'.$XBMC_WEBROOT.'/vfs/';
    }
    if(!empty($SICKBEARD_WEBROOT)){
        $sickbeardcomingepisodes = 'http://'.$GLOBAL_IP.'/'.$SICKBEARD_WEBROOT.'/comingEpisodes/';
        $sickbeardurl = 'http://'.$GLOBAL_IP.'/'.$SICKBEARD_WEBROOT.'/home/';
    }
    if(!empty($COUCHPOTATO_WEBROOT)){
        $cp_url = 'http://'.$GLOBAL_IP.'/'.$COUCHPOTATO_WEBROOT.'/';
    }
    if(!empty($UTORRENT_WEBROOT)){
        $utorrent_url = 'http://'.$GLOBAL_IP.'/'.$UTORRENT_WEBROOT.'/';
    }
    if(!empty($SABNZBD_WEBROOT)){
        $saburl = 'http://'.$GLOBAL_IP.'/'.$SABNZBD_WEBROOT.'/';
    }
    if(!empty($TRANSMISSION_WEBROOT)){
        $transmission_url = 'http://'.$GLOBAL_IP.'/'.$TRANSMISSION_WEBROOT.'/rpc';
    }
    if(!empty($JDOWNLOADER_WEBROOT)){
        $jd_url = 'http://'.$GLOBAL_IP.'/'.$JDOWNLOADER_WEBROOT.'/';
    }
}

This setup is working perfectly for me Smile


- SleepyP - 2011-06-02

A couple bugs I caught tonight:
-The XBMC Message widget has a graphic that will not load correctly for me, as pictured here:
Image
The image of the arrow doesn't load. Why not? Well, the address for the image is:
http://home.houseofgeeks.org/media/arrow.png
should be:
http://home.houseofgeeks.org/mfp/media/arrow.png
I believe I have fixed it.
widgets/wMessage.php, insert @ line 56 (right before the big echo)
Code:
$path=substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'/'));

then, @ line 58, I inserted that variable.
Code:
<input type='button' value='Send' onclick='paramsMsg();'> More... <img src='[b]$path[/b]/media/arrow.png' onclick=\"$('#extras').toggle();\">
That makes it work correctly for me.

The other error I noticed is in the Search widget. It's causing error output similar to what the Transmission widget used to do. I will sort that out tomorrow.


- CoinTos - 2011-06-02

SleepyP Wrote:Just make it easier on yourself and use your public URL for everything in your config.php if you plan on accessing MFP from outside your LAN.

Great tutorial SleepyP, the only thing I would suggest is with your solution there is one problem. Situation: Your internet is down, you use your internal ip to connect to your mfp, you can't resolve the domain name you used for your config.

My solution, let the server decide.
Code:
$GLOBAL_IP = $_SERVER["HTTP_HOST"];
As I explained a couple post back in an edit. What this does, since the services and webserver are all on the same server, is take what was fed to the server whether local ip, intranet address or internet address and uses it as the variable.
Example request:

ip -> http://192.168.1.11/ -> $_SERVER["HTTP_HOST"] = 192.168.1.11
intranet -> http://yourserver/ -> $_SERVER["HTTP_HOST"] = yourserver
internet -> http://bob.yourdyndn.com/ -> $_SERVER["HTTP_HOST"] = bob.yourdyndn.com

Only one of these use offsite dns so only one would fail on down internet.


- gugahoi - 2011-06-02

CoinTos Wrote:Great tutorial SleepyP, the only thing I would suggest is with your solution there is one problem. Situation: Your internet is down, you use your internal ip to connect to your mfp, you can't resolve the domain name you used for your config.

My solution, let the server decide.
Code:
$GLOBAL_IP = $_SERVER["HTTP_HOST"];
As I explained a couple post back in an edit. What this does, since the services and webserver are all on the same server, is take what was fed to the server whether local ip, intranet address or internet address and uses it as the variable.
Example request:

ip -> http://192.168.1.11/ -> $_SERVER["HTTP_HOST"] = 192.168.1.11
intranet -> http://yourserver/ -> $_SERVER["HTTP_HOST"] = yourserver
internet -> http://bob.yourdyndn.com/ -> $_SERVER["HTTP_HOST"] = bob.yourdyndn.com

Only one of these use offsite dns so only one would fail on down internet.

That's a great idea, hadn't thought of it. But I just use my dyndns address and it always works perfectly. If it so happens that my internet is down I just use the server's IP to access MFP and it still works anyway. It is highly unlikely for the internet to be down.

SleepyP Wrote:A couple bugs I caught tonight:
-The XBMC Message widget has a graphic that will not load correctly for me, as pictured here:
Image
The image of the arrow doesn't load. Why not? Well, the address for the image is:
http://home.houseofgeeks.org/media/arrow.png
should be:
http://home.houseofgeeks.org/mfp/media/arrow.png
I believe I have fixed it.
widgets/wMessage.php, insert @ line 56 (right before the big echo)
Code:
$path=substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'/'));

then, @ line 58, I inserted that variable.
Code:
<input type='button' value='Send' onclick='paramsMsg();'> More... <img src='[b]$path[/b]/media/arrow.png' onclick=\"$('#extras').toggle();\">
That makes it work correctly for me.

Wouldn't it be easier to use relative paths?

It's weird that that's happening, specially since most other images are using the same kind of path, so they should have a similar problem.


- CoinTos - 2011-06-02

gugahoi Wrote:It is highly unlikely for the internet to be down.
Oh, what I wouldn't give for that kind of faith in my local provider. It may not happen often but in my neck of the woods it does happen. :-)

Just like power outages/brown outs, hence the ups widget. :-)


- SleepyP - 2011-06-02

CoinTos, that's the cool thing about the flexible config Gugahoi made: you can do something like that without it requiring changes elsewhere Smile

About the Xbmc message widget, I agree that it should be using relative paths and should be working. It's really weird, which is why I posted about it. I will see if I can figure out why it's happening tonight.

About the config.php, did I do it completely wrong or what? I wasn't sure if I interpreted it correctly.


- DejaVu - 2011-06-02

Sorry I've been darting in and out lately, a lot going on in my neck of the woods.

To be honest, I could do with an update on the current projects and what's going on. I'll read back through the thread and attempt to help with any of the easy answers of what's happening.

Noticed some subtle changes, but no major additions. I've been trying to setup Reverse Proxy so I can keep up with you fella's, but it keeps going pear-shaped.


- _Mikie_ - 2011-06-03

So with new users in mind and a little bit of boredom I create a check for config and curl just so it doesn't throw errors and scare people on first load. If you wanna test it out download my repo and run it without touching the config. ie. New user who doesn't know whats plotting.

https://github.com/Mikie-Ghost/mediafrontpage