Manual to install Swisscenter on Synology DSx07 - 2008/03/10 18:47 UPDATE 2008-10-05: firmware DSM 2.0-0702, SwissCenter 1.21.1
Please find below a manual to install SwissCenter on a Synology DS x0x and CS 407. This manual has been tested and all features of SwissCenter work, except for photo streaming. This part is under progress (see ticket #138).
[1] enable Web Station, PHP and MySQL in the Network Services menu of the DS. The option to enable "register_globals" (related to the PHP configuration) must be unchecked.
[2] copy the SwissCenter files and paste the files in /volume1/web/svr/swiss/. This may be any other directory on /volume1/web/
[3] telnet the DS and log in as root create a virtual host in file httpd.conf-user by cd /usr/syno/apache/conf vi httpd.conf-user after line 394 insert the following (NOTE: the editor starts after giving command: I)
Code:
Listen 8050
<VirtualHost _default_:8050>
DocumentRoot "/volume1/web/svr/swiss"
<Directory "/volume1/web/svr/swiss">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Deny from all
Allow from «« enter first three,two or one octets of your network IP, eg 192.168.1 »»
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
Alias /root/ "/"
</VirtualHost>
close http.conf-user with ESC followed by ZZ
(NOTE: the port in the example is set to 8050, however, it can be anything except for port 8080 which is already in use by the CS/DS)
[4] restart Apache by
Code:
sh /usr/syno/etc.defaults/rc.d/S97apache-user.sh restart
[5] create symbolic links for the commands that SwissCenter uses in the /usr/syno/bin/ directory by
cd /usr/syno/bin/
Code:
ln -s /bin/ls /usr/syno/bin/ls
[6] set the permissions for the SwissCenter-files
cd /volume1/web/svr/
Code:
chown -R admin:users swiss
chmod -R 777 swiss
[7] allow streaming of video files by adjusting the "open_basedir"-function of the PHP.ini file on row 205 by
adding "/:"
cd /usr/syno/etc/
vi php.ini
add on line 205
Code:
/:
(just before "/volume1/web:")
[8] in order to have sound, function exec() needs to be enabled by:
removing /usr/syno/bin/ from line 184: safe_mode_exec_dir = /usr/syno/bin, so change
Code:
safe_mode_exec_dir = /usr/syno/bin
into
Code:
safe_mode_exec_dir =
close php.ini with ESC followed by ZZ
[9] restart Apache by
Code:
sh /usr/syno/etc.defaults/rc.d/S97apache-user.sh restart
[10] store your media files either somewhere on /volume1/ or (eg. /volume1/music/, /volume1/photo/ or /volume1/video/)
[11] enabling the “PLAY NOW”-screen
There are a couple of steps you have to take. First, create within the main SwissCenter directory a sub-directory “/fonts”. In this directory you store so-called GDF fonts. A couple of them can be downloaded from here, unzip the fonts and save them in your SwissCenter directory “/fonts”. In this directory you store so-called GDF fonts. The download contains “arial” fonts for a 624x496 resolution. In case of a different resolution you have to create your own fonts. The logging will report which font size is missing. An instruction how to do this you may find on the same web page.
Now file /base/image.php needs to be edited. Replace line 369-444 with this (replacing function text(), get_text_width() and get_text_height()):
Now file /base/image.php needs to be edited as follows:
Code:
// ------------------------------------------------------------------------------------------------
// Outputs some text onto the image (using truetype fonts).
// NOTE: The font-size given should be specified in pixels.
// -----------------------------------------------------------------------------------------------
--
function text ($text, $x = 0, $y = 0, $colour = 0, $size = 14, $font = '', $angle = 0 )
{
// Exit value of this function.
$result = false;
// Determine the font to use if not specified.
if (empty($font))
$font = get_sys_pref('TTF_FONT');
// Write the text to the image
if ($this->image !== false)
{
// Determine which font type we have
$extension = file_ext($font);
if ($extension == "ttf")
{
// GD version 2 takes the font-size argument in points, whereas this function takes the
// text size in pixels. We therefore need to convert the given value before passing to GD.
if (gd_version() >=3)
$size *= 0.8;
$result = @imagettftext($this->image,$size,$angle,$x,$y,$colour,$font,$text);
if ( $result == false )
{
send_to_log(5,"Unable to use Truetype Font '$font' to display '$text'");
}
}
elseif($extension == "gdf")
{
$font = sprintf($font, $size);
$font_no = @imageloadfont($font);
if ($font_no !== false)
{
// Correct x and y
if($angle == 0)
{
$y -= imagefontheight($font_no);
$result = imagestring($this->image, $font_no, $x, $y, $text, $colour);
if ($result == false)
{
send_to_log(5,"Unable to use GD Font '$font' to display '$text'");
}
}
elseif($angle == 90)
{
$y -= imagefontheight($font_no) * strlen($text);
$result = imagestringup($this->image, $font_no, $x, $y, $text, $colour);
if ($result == false)
{
send_to_log(5,"Unable to use GD Font '$font' to display '$text'");
}
}
}
else
{
send_to_log(5,"Unable to use GD Font '$font' to display '$text'");
}
}
$this->src_fsp = false;
}
return $result;
}
/**
* Returns the width (in pixels) of the text when rendered
*
* @param string $text
* @param integer $size
* @param string $font
* @param integer $angle
* @return integer
*/
function get_text_width( $text, $size = 14, $font = '', $angle = 0)
{
if (empty($font))
$font = get_sys_pref('TTF_FONT');
$extension = file_ext($font);
if ($extension == "ttf")
{
if (gd_version() >=3)
$size *= 0.8;
$box = @imagettfbbox($size, $angle, $font, $text);
return ($box[2] - $box[6]);
}
elseif($extension == "gdf")
{
$font = sprintf($font, $size);
$font_no = imageloadfont($font);
if ($font_no !== false)
{
return (imagefontwidth($font_no) * strlen($text));
}
}
}
/**
* Returns the height (in pixels) of the text when rendered
*
* @param string $text
* @param integer $size
* @param string $font
* @param integer $angle
* @return integer
*/
function get_text_height( $text, $size = 14, $font = '', $angle = 0)
{
if (empty($font))
$font = get_sys_pref('TTF_FONT');
$extension = file_ext($font);
if ($extension == "ttf")
{
if (gd_version() >=3)
$size *= 0.8;
$box = @imagettfbbox($size, $angle, $font, $text);
return ($box[3] - $box[7]);
}
elseif($extension == "gdf")
{
$font = sprintf($font, $size);
$font_no = imageloadfont($font);
if ($font_no !== false)
{
return imagefontheight($font_no);
}
}
}
// ----------------------------------------------------------------------------------
// Truncates a string to the given width (in pixels)
// ----------------------------------------------------------------------------------
function shorten($text, $width, $size = 24)
{
if(empty($text))
return $text;
$short_string = "";
$len = 0;
$text = (string)$text;
$continue = true;
$trimmed = false;
$short_string = $text;
while($continue)
{
$len = $this->get_text_width($short_string, $size);
if ($len < $width)
{
if ($trimmed)
{
// Trim the string back to the last whitespace (max 8 chars will be trimmed)
if ((strlen($short_string) - strrpos($short_string,' ')) <10)
{
$short_string = substr($short_string, 0, strrpos($short_string,' ')+1);
}
}
$continue = false;
}
else
{
// Remove last char
$short_string = substr($short_string, 0, -1);
$trimmed = true;
}
}
return $short_string;
}
File "/base/image.php" can be downloaded from the same place.
[12] optimizing the screen lay-out
As the GDF-fonts differ from the standard fonts used by SwissCenter the code of file /base/image_screens.php adjusted a bit.
For your convenience the “/base/image_screens.php”-file can be retrieved (again) from here.
[14] open the SwissCenter configuration screen by entering http://your_server_ip:8050/config. For further details see "docmentation and FAQ".
[15] after entering your media location you may find the "search for new media"-option does not optimally work;
in stead you can do the media search manually by entering the following URL on your PC:
Code:
http://diskstation:8050/media_search
your web browser starts searching for your media files
when finished, your web browser will mention that the web page cannot be found
[16] add server on ShowCenter
go to the configuration screen of the ShowCenter and select option add server
enter the ip and port of the DS
Code:
diskstation:8050
make the DS server your default
NOTE: ENABLING function exec() IN STEP [8] MAY CAUSE SECURITY RISKS RE YOUR WEB SERVER!!! In my post of 19/08/2008 below, a couple of protection methods are explained
---------------------------------------------------------------------------
SwissCenter SVN 1091
Simese 1.40 / PHP 4.4.4 / MySQL 4.0.21 / Windows XP
Apache 2.2.8 / PHP 5.2.6 / MySQL 5.0.51b / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.0-0702
Pinnacle SC200
| | The administrator has disabled public write access.
hanamail
User
Posts: 14
Re: Manual to install Swisscenter on Synology DSx0 - 2008/03/24 07:21Dear Klaas Vaak,
At step 3 I managed to have the telnet connection working and to log in as root with password. After that I include the lines as mentioned in the manual and the result I get is an explanation of Apache. I do not have any knowledge of Apache and before I do something what I regret, hereby once again a request for help. How do I get to file httpd.conf-user? How I read the manual is that I have first to get into this file to include the lines to create a virtual host. In this file I pressume is the line numbering so I can include the code as mentioned further in step 3 of the manual.
Hope you can help me out with this one.
Thnaks in advance.
hanamail
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/03/24 08:16Hi Hanamail,
Hanamail wrote:How do I get to file httpd.conf-user?go through step 3 using commands cd (change directory) and vi
Hanamail wrote:How I read the manual is that I have first to get into this file to include the lines to create a virtual hostyep, that's correct
Hanamail wrote:In this file I pressume is the line numbering so I can include the code as mentioned further in step 3 of the manualAs soon as you open the "httpd.conf-user"-file with command vi you'll see the line numbers for every row of the file.
regards, Klaas ----------------------------------------- SwissCenter 1.19.2 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/23 17:57Thanks to CryptoKnight the (see here), it’s possible to get the “PLAY NOW”-screen with the DSx07. I copied his code in the manual in order to have the manual as much as possible all inclusive.
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/25 14:59fixed ..
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/25 15:07Well I think I did all that ... and still no play now screens
I'm getting all ok apart from "Not all recommended PHP modules are available. Some non-critical features have been disabled as a result (recommended modules are: zip)."
Any clues on how to debug this? (I am moderate php experience)
I used the files from here well to no avail .. image_and_image_screens.zip as
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/25 15:26Hi Chrisrixon,
Thanks for your note on the missing "-"; I've adjusted the "manual".
Re the "zip-module": this module is not supported by the Synology PHP-version, but it doesn't influence the PLAY NOW screen.
It's odd that you haven't got the PLAY NOW screen yet.
Did you use any of the prepared "image_screens.php"-files. Is so, what language did you use. And I'm not sure I understand your latest remark:
Chrisrixon wrote:I used the files from here well to no avail .. image_and_image_screens.zip as ... regards, Klaas ----------------------------------------- SwissCenter 1.20 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/25 18:33I've tested the english "image_screens.php" and it should be OK. The problem could be the font and/or the path thats points at the font directory.
May I ask you which font you've selected and where you've put the font directory?
regards, Klaas ----------------------------------------- SwissCenter 1.20 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/25 18:38
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/26 08:31Hi Chris,
I tested your uploaded files and they work fine, although there's a difference in the code of the "image.php"-file, where in your file "function z_get_text_width (line 412 through 422) that isn't present the my "image.php"-file. Despite this difference the "PLAY NOW"-screen in not affected.
I had a similar problem as you described which was caused by the property rights of the folder "fonts". In first instance I copied the directory (including the fonts) from outside my network through a FTP-server. This caused property problems, so SwissCenter couldn't access the fonts, although the system check (in the config screen) confirmed the fonts were present. After copying the directory again from inside my network, the "PLAY NOW"-screen appeared. Maybe this could be with you as well. Just give it a try and I'm looking forward to hear the result.
Moreover, due to a small error in the "image_screens.php"-file, the lay-out needed to be adjusted. I did this, so you should download the English version of the file once more.
regards, Klaas ----------------------------------------- SwissCenter 1.20 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/26 11:14all the files are globally readable, but I re-did the: chown -R admin:users swiss chmod -R 777 swiss
commands to be safe and no difference.
I'll try and debug it when I get a moment
Thanks for getting me this far, its totally usable anyway
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/26 14:34One thing I have a Synology DS107 ( no +)
I have started to debug it and
function now_playing_image
is not being called ....
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/26 15:46Well, the difference between DSx07 and DXx07+ is the CPU clock rate (266Mhz against 500 Mhz). As the firmware is (or should be) the same, I don't think that's the reason why function "now_playing_image" fails.
I'll have a look as well, keep up the good spirit.
regards, Kaas ----------------------------------------- SwissCenter 1.20 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/26 18:19
There seems to be two problems, the fonts aren't working .. I proved this by using built in fonts:
and i can see it generating the pics correctly (with tiny fonts ...)
but as to why their not getting displayed in the showcenter ...
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/04/27 03:27My only idea is that my DS is too slow to generate the pics in time and the SC is timing out ... am investigating ...
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 13:15I've had no luck with external fonts. Consider this file:
$f = $font; $f = 5; // comment this line and no text
imagestring($im, $f, 10, 1, "$fh x $fw $font Jackels love my big SPHINX of Quartz 1234567890", $white); imagepng($im); ?>
This works and proves that the font is loaded (because the dimensions are). However comment out $f = 5 and it doesn't work.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 14:48Hi Chris,
My only idea is that my DS is too slow to generate the pics in time and the SC is timing out ... am investigating ... I noticed that too large albumart-images cause failure of the "PLAY NOW"-screen (it simply times out). Maybe you can give it a try whithout albumart to see what's happening.
Furthermore, I tried your script and I see the fonts, but I'm not sure what you're trying to say (my knowlegde re PHP may be not sufficient to get it).
regards, Klaas ----------------------------------------- SwissCenter 1.20.1 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 15:07Well its not all bad news, I have got the now playing screens going by:
Changing this: $image = new CImage(); To: $image = new CImage(convert_x(1000,SCREEN_COORDS), convert_y(1000,SCREEN_COORDS));
And commenting out this: //$image->load_from_file(style_img('NOW_BACKGROUND',true) ); //$image->resize( convert_x(1000,SCREEN_COORDS), convert_y(1000,SCREEN_COORDS), 0, false);
This saves a load and resize speeding things up a lot at the expense of a black background. The black background also helps when saving as a jpeg image as there is a lot less processing to do ....
(My Show centre is running HD)
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 15:55Hi Chris,
I tried your adjustment re file base/image.php and I've seen no difference in output of the "PLAY NOW"-screen, so that's fine for me, but I'm not sure whether you are satified with the "PLAY SCREEN" you're getting right now.
If so, please let me know and I'll include your solution in the "manual".
thanks & regards, Klaas ----------------------------------------- SwissCenter 1.20.1 Simese 1.40 & Apache 2 / PHP 5.2.0 Windows XP & Linux Synology 2.6.15 Synology DS107+ (128) Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 16:50Um well it makes it black so not as pretty as the default. Maybe a note for owners of the slower model.
| | The administrator has disabled public write access.
klaasvaak
User
Posts: 516
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/23 18:16Hi Chris,
When I tried your script change,
Code:
$image = new CImage(convert_x(1000,SCREEN_COORDS), convert_y(1000,SCREEN_COORDS));
the background was still the same as it was before, so what's making the background turn into black.
regards, Klaas -----------------------------------------
SwissCenter 1.20.1
Simese 1.40 & Apache 2 / PHP 5.2.0
Windows XP & Linux Synology 2.6.15
Synology DS107+ (128)
Pinnacle SC200
| | The administrator has disabled public write access.
chrisrixon
User
Posts: 18
Re: Manual to install Swisscenter on Synology DSx0 - 2008/05/24 04:29so what's making the background turn into black. commenting out these lines: