FAQ  •  Register  •  Login

Web UI in PHP

<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Sat Jan 08, 2011 12:20 am

Web UI in PHP

Hello, I wrote a small web UI in PHP (requires Java console for POST actions),
so if anybody interested http://blog.tolik.org/2011/01/serviio-web-interface.html
v0.2b update http://blog.tolik.org/2011/01/serviio-web-interface-updates-v02b.html
v0.3b update http://blog.tolik.org/2011/01/serviio-web-interface-updates-v03b.html
v0.4b update http://blog.tolik.org/2011/01/serviio-web-interface-updates-v04b.html
v0.5b update http://blog.tolik.org/2011/02/serviio-web-interface-updates-v05b.html
v0.5.1b update http://blog.tolik.org/2011/03/serviio-web-interface-updates-v051b.html
v0.5.2b update http://blog.tolik.org/2011/03/serviio-web-interface-updates-v052b.html
v0.5.2.1b update http://blog.tolik.org/2011/04/serviio-web-interface-updates-v0521b.html
v0.6b update http://blog.tolik.org/2011/09/serviio-web-interface-updates-v06b.html (patched by Mark Pemberton)

This is serviio web frontend v 0.5 beta - it mimics native configuration console.
From now on I plan on numbering versions the same as serviio to avoid confusion.
The code is quick & dirty (couple of hours) - tons of bugs included.

Requirements: HTTP server, PHP5 (with XML simple and cURL), JavaScript-enabled web browser.

TODO:
    Suggestions?
CHANGELOG:
    Version 0.6 beta - Patched code by Mark Pemberton to work with 0.6 changes.
    Version 0.5.2.1 beta - Fixed issue #1700 Update metadata through interface doesn't work. Fixed on the 'transcoding' tab, setting 'Keep original' keeps reverting to 'Downmix to stereo'.
    Version 0.5.2 beta - Updated existing translations and added new from serviio client. Added server version check - won't operate with the other version. Edit config.php to override this check.
    0.5.1 beta - fixed background color to show correctly under Explorer and Firefox. Extended "Metadata", "Presentation" to work with new options/rest interface. Updated existing translations and added new from serviio client. Fixed "status" tab javascripts. Fixed "metadata" tab "Retrieve DVD cover image or poster if available" bug.
    0.5 beta - removed org.restlet.jar and org.restlet.ext.xstream.jar - no restlet bug with @Post annotated actions in v2.0.4. Added translation from serviio-console. Updated to support serviio v 0.5: Added "Presentation" and "Console settings". Extended "Status", "Library", "Metadata" and "Transcoding" to work with new options/rest interface. Translation is incomplete: no javascript transaltion, no status messages translation - I have no capacity :)
    0.4 beta - added org.restlet.jar and org.restlet.ext.xstream.jar from the new restlet-jse-2.0.4 - suggested by zip to workaround restlet 2.0.0 bug with @Post annotated actions. Removed serviio-0.4.2-cli workaround.
    0.3 beta - added serviio-0.4.2-cli - a java module to POST RESTfull actions - see lib/serviio-0.4.2-cli/README.txt
    This module is a minimal serviio-console distribution with modified serviio-client.jar to allow command-line processing.
    serviio-cli.sh can execute the following actions: stopServer, startServer, forceLibraryRefresh and forceOnlineVideoFilesUpdate
    0.2 beta - added AJAX File Browser from http://gscripts.net/free-php-scripts/Listing_Script/AJAX_File_Browser/details.html
    and GreyBox from http://orangoo.com/labs/GreyBox/ to select server's local path for media library & transcoded files location.
    0.1 beta - base functionality. Does not work: Transcoding:Browse... & Library:Add local... buttons to select a directory - not implemented.
    POST actions do not work due to a nasty bug in restlet v2.0.0 used in serviio.

0. Translation:

Image

1. Status tab - you can see status, select renderer profile & set bound IP address:

Image

2. Library tab - you can add/remove path, set path content type, change settings:

Image

3. Metadata tab - you can change settings (something may be messed up in Video section):

Image

4. Transcoding tab - pretty much works, except for "Browse...":

Image

5. About - same as native console, Serviio version loaded from server:

Image

AJAX File Browser - to pick a directory on the server side (NOTE: it has the same viewing permissions as the HTTP server):

Image

OBSOLETE: Until restlet POST workaround found, the error is caught to present it nicely:

Image

Restlet bug workaround - use serviio-cli.sh a minimal distribution of serviio-console with modified serviio-client.jar:

OBSOLETE: Removed in 0.4b The following are development notes - end users do not need to do it.
From the lib/serviio-client.jar remove files org/serviio/console/ServiioConsole*
Compile src/org/serviio/console/ServiioConsole.java and put compiled ServiioConsole.class in lib/serviio-client.jar at org/serviio/console/
use bin/serviio-cli.sh wrapper to POST a action:

serviio-cli.sh <IP ADDRESS><ACTION>
<IP ADDRESS> - Server's IP, eg. 127.0.0.1
<ACTION> - Action to execute

Please note: it is a minimal distribution of the serviio-console to reproduce/verify blobs just use ServiioConsole.java & serviio-cli.sh and take the rest from the original serviio distribution.
Also you can verify individual jars with any check-summing, serviio-client.jar is the only modified module - described above.

Minimal ServiioConsole cli:
Image

Available for download at http://labs.softjourn.com/projects/serviioweb/files
Last edited by AcidumIrae on Mon Sep 26, 2011 7:20 am, edited 10 times in total.
// WBR, Tolik aka AcidumIrae
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sat Jan 08, 2011 11:58 am

Re: Web UI in PHP

Brilliant!!! I'll upgrade to the latest Restlet as soon as it's available. Adding link to this topic to FAQ.

Also there are a lot of updates in 0.5, to the console and the RESTful interface, you might ask for the beta if you'd like to implement the changes upfront.
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Sat Jan 08, 2011 3:00 pm

Re: Web UI in PHP

I have posted an update with the server AJAX folder browsing.

zip wrote:Also there are a lot of updates in 0.5, to the console and the RESTful interface, you might ask for the beta if you'd like to implement the changes upfront.

It would be nice to have RESTful interface published somewhere.

Thank you for the great work!
// WBR, Tolik aka AcidumIrae
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sat Jan 08, 2011 4:09 pm

Re: Web UI in PHP

It'll be published as soon as the last beta is out.
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Sat Jan 08, 2011 6:08 pm

Re: Web UI in PHP

Great!

Posted the restlet workaround - a bit ugly: using a minimal serviio-console distribution overriding ServiioConsole class to call POST actions.
It uses PHP system() function to call serviio-cli.sh script to execute RESTfull POST actions :?
// WBR, Tolik aka AcidumIrae
<<

bassmadrigal

Serviio lover

Posts: 50

Joined: Fri Mar 26, 2010 6:33 pm

Location: Ramstein Air Base, Germany

Post Mon Jan 10, 2011 1:37 pm

Re: Web UI in PHP

Sweet! I will have to check this out when I get home.

@Zip, any possibility in embedding a mini-webserver into serviio so you don't have to have a separate one running somewhere down the line? I am thinking kinda like the torrent clients have. The main thing I am looking for is just the ability to manually update the library while I am sitting on the couch with my phone. There are enough times that I know a file finished since the last time I updated, and so then I have to go into the computer room to get serviio to start searching again (having it do it automatically had bad effects while gaming).
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Jan 10, 2011 2:43 pm

Re: Web UI in PHP

I cannot find it now, but there is a topic on the forum with a html page attachment which invokes library refresh. There is no need for a embedded web server, some Ajax-aware static HTML pages set would work.
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Tue Jan 11, 2011 8:24 am

Re: Web UI in PHP

Thanks for the hint.

You mean something like this from HTML should work?

  Code:
<script>
function postAction(action) {
  var req    = new XMLHttpRequest();
  req.onload = postHandler;
  req.open("POST", "/rest/action", true);
  req.send('<?xml version="1.0" encoding="UTF-8" ?><action><name>'+action+'</name></action>');
}
function postHandler() {
  // something
}
</script>

PS: I'll try that, but the serviio REST interface listens to localhost by default, right?
// WBR, Tolik aka AcidumIrae
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Jan 11, 2011 9:34 am

Re: Web UI in PHP

AcidumIrae wrote:PS: I'll try that, but the serviio REST interface listens to localhost by default, right?

It does, you can bind it to another IP by useing

  Code:
-Dserviio.remoteHost=<IP>


startup property (have a look at FAQ for details)
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Wed Jan 12, 2011 4:32 pm

Re: Web UI in PHP

Thanks, I understand - I wrote "by default" as I wanted it to work OOB :)

I tried posting with AJAX script - the result is the same:

HTTP/1.1 405 Method Not Allowed:
  Code:
HTTP/1.1 405 Method Not Allowed
Date: Wed, 12 Jan 2011 16:25:36 GMT
Accept-Ranges: bytes
Allow: POST
Server: Restlet-Framework/2.0.0
Content-Length: 323
Content-Type: text/html; charset=UTF-8

:(

Also Safari makes something weird - doing OPTIONS instead of the POST (Chrome is the same, so I assume it is WebKit's fault):
  Code:
OPTIONS /rest/action HTTP/1.1
Host: localhost:23423
Access-Control-Request-Method: POST
Origin: http://upc
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Referer: http://upc/serviio/test.html
Access-Control-Request-Headers: Content-Type
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Length: 0
Connection: keep-alive

Firefox acts as expected - doing POST, but also no go with the same error:
  Code:
POST /rest/action HTTP/1.1
Host: localhost:23423
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
Referer: http://upc/serviio/test.html
Content-Length: 79
Content-Type: text/plain; charset=UTF-8
Origin: http://upc
Pragma: no-cache
Cache-Control: no-cache

<?xml version="1.0" encoding="UTF-8" ?><action><name>stopServer</name></action>

So, AJAX is not an option here as it works differently in different browsers (and it does not work anyways).
// WBR, Tolik aka AcidumIrae
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Jan 12, 2011 4:42 pm

Re: Web UI in PHP

to fix the error, you can try to replace restlet jars in the lib folder with these (will be in 0.5): http://www.restlet.org/downloads/2.0/re ... -2.0.4.zip
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Thu Jan 13, 2011 10:42 am

Re: Web UI in PHP

zip wrote:to fix the error, you can try to replace restlet jars in the lib folder with these (will be in 0.5): http://www.restlet.org/downloads/2.0/re ... -2.0.4.zip

Thanks a lot, it works! :D

I only needed to add header "Content-Type: application/xml; charset=UTF-8" to cURL POST request.
So I have removed my Java cli workaround and just added org.restlet.jar and org.restlet.ext.xstream.jar from the new restlet-jse-2.0.4 into my zip with instructions.
I have updated the root post of this thread with a new version explanations and the link to download.
// WBR, Tolik aka AcidumIrae
<<

tombert

User avatar

DLNA master

Posts: 217

Joined: Wed Oct 13, 2010 8:01 pm

Post Fri Jan 14, 2011 11:48 pm

Re: Web UI in PHP

nice work ...
<<

mchristian

Streaming enthusiast

Posts: 23

Joined: Fri Nov 12, 2010 5:46 pm

Post Sat Jan 22, 2011 5:24 pm

Re: Web UI in PHP

I hope you guys dont mind if I ask a question. I am your typical end user and a lot of the discussions on this board are way over my head. Hopefully, my perspective gives you a clue into how the average person will look at the things you do. With all that being said, Serviio works quite seamlessly for me as it is, what is the advantage of a Web UI? Not being a pain in the butt, just ignorant to what is probably obvious to you guys. The screenshots look great, I just dont know why I need it. Can I assume it is for people that are even less computer literate than I am?

Thanks in advance.
Sony S570 BDP
Ubuntu 10.10
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Mon Jan 24, 2011 1:45 pm

Re: Web UI in PHP

mchristian wrote:I hope you guys dont mind if I ask a question. I am your typical end user and a lot of the discussions on this board are way over my head. Hopefully, my perspective gives you a clue into how the average person will look at the things you do. With all that being said, Serviio works quite seamlessly for me as it is, what is the advantage of a Web UI? Not being a pain in the butt, just ignorant to what is probably obvious to you guys. The screenshots look great, I just dont know why I need it. Can I assume it is for people that are even less computer literate than I am?

Thanks in advance.

I wrote it as I use serviio on the headless Linux server - there is no UI.
// WBR, Tolik aka AcidumIrae
<<

matten

Streaming enthusiast

Posts: 24

Joined: Mon Jan 10, 2011 1:38 pm

Post Sat Jan 29, 2011 6:57 pm

Re: Web UI in PHP

Hello there..

I am using WEBGUI 0.4.2 with servio 0.5 and I cannot add any thing to the library: Cannot put repository

Is there a solution?

Ciao,
Matthias
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16904

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Feb 01, 2011 4:55 pm

Re: Web UI in PHP

It's working with 0.4.2. You'll have to wait for the dev to update it or take it on yourself ;-)
<<

AcidumIrae

User avatar

Serviio newbie

Posts: 14

Joined: Sat Jan 08, 2011 12:03 am

Location: Ivano-Frankivs'k, Ukraine

Post Thu Feb 03, 2011 6:17 pm

Re: Web UI in PHP

I have updated the root post of this topic with the new version information - it is now compatible with the serviio v0.5 :D

Thanks.
// WBR, Tolik aka AcidumIrae
<<

Cerberus

User avatar

DLNA master

Posts: 4116

Joined: Sun Jan 02, 2011 5:20 pm

Location: Reading, UK

Post Thu Feb 03, 2011 6:18 pm

Re: Web UI in PHP

weldone bro :) great addition to the serviio family :)
Phil Bennett
Beta Tester Group
Wiki | FAQ

Samsung LE40C750 LCD | Samsung BD-C5900 | Sony PS3 | Windows 7 |
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

patters

User avatar

DLNA master

Posts: 1264

Joined: Sat Oct 09, 2010 3:51 pm

Location: London, UK

Post Fri Feb 04, 2011 8:51 am

Re: Web UI in PHP

Thanks so much for this! I put it on my Synology NAS last night. The real beauty on a Synology running DSM 3.0 is that it's already running PHP. All you need to do is go to Control Panel -> Web Services > Web Applications > Enable Web Station. This creates the folder /volume1/web. Use the root account to put the extracted Web UI files in say /volume1/web/serviio and browse to http://yourNASip/serviio and it just works - no configuration required at all. So simple! The AJAX file browser fails with an error though, because the web user has no access to the filesystem root, but that's not critical to have anyway.
PS4 | Bravia KDL-32V5500 | Xbox One S | Synology DS214play
Serviio 1.9.2 package for Synology NAS - with hardware transcoding support!
Next

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 5 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.