Baïkal contacts (CardDAV) and calendar (CardDAV) installation package for Synology

Status
Für weitere Antworten geschlossen.

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
DSM 5.0-4482 with non-working Baikal admin UI.
This is the response of 'http://.../baikal/zaza.php':
Rich (BBCode):
Array ( 
[...]
[DOCUMENT_ROOT] => /var/services/web 
[REQUEST_URI] => /baikal/zaza.php 
)

Hmmm, this is looking good too :-/

Can you please move "zaza.php" to the underlying "admin" folder and test again, this time with admin in the path of course:
Rich (BBCode):
http://.../baikal/admin/zaza.php'

:cool: Thanks keyhan for the hint to use <pre> tags, for getting newlines.
The zaza.php file should better be like this indeed:
PHP:
<pre>
<?php
  print_r($_SERVER);
  ?>
</pre>

Thx,
Erik
 

dsmynas

Benutzer
Mitglied seit
11. Feb 2014
Beiträge
74
Punkte für Reaktionen
0
Punkte
12
Hi Eric,

actually I would expect the stated behavior to be correct ... when calling subdomain.domain.tld then /var/services/web/subdomain is the Document_Root and therefore the requested URI is /. So calling the zaza.php in this case would be a mere addition, i.e. Document_Root (/var/services/web/baikal) + Request_URI (/zaza.php) = /var/services/web/baikal/zaza.php.

Other way around ... when calling domain.tld then /var/services/web is the Document_Root, by addressing domain.tld/baikal the Request_URI is /baikal as addition to the Document_Root. So calling the zaza.php in this case would be an addition of Document_Root (/var/services/web) + Request_URI (/baikal/zaza.php) = /var/services/web/baikal/zaza.php.

The received output as I have sated it, is what I received in exactly the order stated.

Best regards,

dsmynas
 

keyhan

Benutzer
Mitglied seit
20. Mai 2012
Beiträge
22
Punkte für Reaktionen
0
Punkte
0
You enabled Web Station only recently, did you retest if you really need your "customisation" after all ?
Ok, I did a check right now. The base href command in the sourcecode of the web admin page looks like this with customization:
Rich (BBCode):
<base href="http://[hostname]/baikal/" />
And without the additional (customized) code it looks like this:
Rich (BBCode):
<base href="http://[hostname]/" />

You can see the web admin frontend under the attached picture as well. On the left with the customized code and on the right without it (the original code):

baikal-web-admin-difference.jpg

Additionally:
Can you please also test in the "admin" folder, as described in the next post #161 ?
Rich (BBCode):
 Array
(
    [USER] => http
    [HOME] => /var/services/web
    [FCGI_ROLE] => RESPONDER
    [REDIRECT_HTTP_AUTHORIZATION] => 
    [REDIRECT_MOD_X_SENDFILE_ENABLED] => yes
    [REDIRECT_HANDLER] => php5-fastcgi
    [REDIRECT_STATUS] => 200
    [MOD_X_SENDFILE_ENABLED] => yes
    [HTTP_HOST] => [hostname]
    [HTTP_USER_AGENT] => [useragent]
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.5
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_COOKIE] => [somecookiestuff]
    [HTTP_CONNECTION] => keep-alive
    [PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache
    [SERVER_NAME] => [hostname]
    [SERVER_ADDR] => [address]
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => [address]
    [DOCUMENT_ROOT] => /var/services/web
    [SERVER_ADMIN] => admin
    [SCRIPT_FILENAME] => /var/services/web/baikal/admin/zaza.php
    [REMOTE_PORT] => 60510
    [REDIRECT_URL] => /baikal/admin/zaza.php
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /baikal/admin/zaza.php
    [SCRIPT_NAME] => /baikal/admin/zaza.php
    [ORIG_SCRIPT_FILENAME] => /php-fpm-handler
    [ORIG_PATH_INFO] => /baikal/admin/zaza.php
    [ORIG_PATH_TRANSLATED] => /var/services/web/baikal/admin/zaza.php
    [ORIG_SCRIPT_NAME] => /php-fpm-handler.fcgi
    [PHP_SELF] => /baikal/admin/zaza.php
    [REQUEST_TIME_FLOAT] => 1400148019.2744
    [REQUEST_TIME] => 1400148019
)
 

grottenolm

Benutzer
Mitglied seit
11. Apr 2013
Beiträge
6
Punkte für Reaktionen
0
Punkte
0
Hi Basalt,

this is the result for 'http://.../baikal/admin/zaza.php':

Rich (BBCode):
Array
(
    [USER] => http
    [HOME] => /var/services/web
    [FCGI_ROLE] => RESPONDER
    [REDIRECT_HTTP_AUTHORIZATION] => 
    [REDIRECT_MOD_X_SENDFILE_ENABLED] => yes
    [REDIRECT_HANDLER] => php5-fastcgi
    [REDIRECT_STATUS] => 200
    [MOD_X_SENDFILE_ENABLED] => yes
    [HTTP_HOST] => nessie
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_ACCEPT_LANGUAGE] => de,en-US;q=0.7,en;q=0.3
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_DNT] => 1
    [HTTP_CONNECTION] => keep-alive
    [PATH] => /bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache
    [SERVER_NAME] => nessie
    [SERVER_ADDR] => 192.168.2.11
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 192.168.2.100
    [DOCUMENT_ROOT] => /var/services/web
    [SERVER_ADMIN] => admin
    [SCRIPT_FILENAME] => /var/services/web/baikal/admin/zaza.php
    [REMOTE_PORT] => 52066
    [REDIRECT_URL] => /baikal/admin/zaza.php
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /baikal/admin/zaza.php
    [SCRIPT_NAME] => /baikal/admin/zaza.php
    [ORIG_SCRIPT_FILENAME] => /php-fpm-handler
    [ORIG_PATH_INFO] => /baikal/admin/zaza.php
    [ORIG_PATH_TRANSLATED] => /var/services/web/baikal/admin/zaza.php
    [ORIG_SCRIPT_NAME] => /php-fpm-handler.fcgi
    [PHP_SELF] => /baikal/admin/zaza.php
    [REQUEST_TIME_FLOAT] => 1400174549.7022
    [REQUEST_TIME] => 1400174549
)
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
actually I would expect the stated behavior to be correct ...
[...]
The received output as I have sated it, is what I received in exactly the order stated.

Yes, I think you are right.

I am really puzzeled now, all $_SERVER strings of you, Grottenolm and Keyhan are looking good, and the similar as under DSM 4.3
Still it doesn't work under DSM 5 :eek:

I have to dive deeper into the code, busy preparing an enhanced "zaza.php" with Baikal code in it for testing...

/Erik
 

Pimpa

Benutzer
Mitglied seit
18. Mai 2014
Beiträge
1
Punkte für Reaktionen
0
Punkte
0
Admin url and DSM 5.0 fix!

Finally I tracked down the problem of the wrong admin urls.

The Core/Frameworks/Flake/Framework.php wrongfully detect the base url of the site. Although the problem is not with the Framework.php but with the php version included with dsm 5.0. There is a problem with a php function named substr_compare which is compares to strings but it always return true even if the searched string not included in the base string. This specific function used for testing the url if it's includes the actual php script's name (mostly index.php) or not to decide to cut it off or not from the request uri. So if you try to access the admin like this http://[hostname]/baikal/admin/index.php it will work until the url has the index.php ending. But if you not specify the index.php at the end it won't.

So to fix this (more precisely to make a workaround) you have to edit the referred php script and replace the endsWith function (line 81) to this one:

PHP:
	public static function endsWith($sString, $sTest) {
		$iTestLen = strlen($sTest);
		if ($iTestLen > strlen($sString)) return false;
		//this is the original line: return substr_compare($sString, $sTest, -$iTestLen) === 0; 
		return substr($sString, -$iTestLen) == $sTest;
	}

After this the admin site will function normally without further modification of admin/index.php

My baikal version is 0.2.7 and DMS version is 5.0-4482. I tested this out on a fresh install of baikal.
 

keyhan

Benutzer
Mitglied seit
20. Mai 2012
Beiträge
22
Punkte für Reaktionen
0
Punkte
0
@Pimpa: Thanks for tracking it down. And yes, you're right, for some reason the substr_compare function does not return the right value in this case.
If your substr-code is doing it right (I just checked and afaik it does) I don't see why we should rely on substr_compare. So maybe you should post your knowledge on this site as well.
 

keyhan

Benutzer
Mitglied seit
20. Mai 2012
Beiträge
22
Punkte für Reaktionen
0
Punkte
0
Alright, now I think I know what's going on. This is what we have:
Rich (BBCode):
return substr_compare($sString, $sTest, -$iTestLen) === 0;
So, if we take a close look here, we'll see that in our case this function "compares $sString from position -$iTestLen with $sTest".
We have no length parameter, so we'll get the "default" value:
The default value is the largest of the length of the str compared to the length of main_str less the offset.
But you'll find a note from a user named "Skyborne" which states, that you'll get unexpected results if you leave this part out. And I think he's right, because the default value (for the length) here is "0", which leads to this issue. So if you set this parameter to a value not equal to zero you get what you want:
Rich (BBCode):
return substr_compare($sString, $sTest, -$iTestLen, 1) === 0;

I'm no PHP expert, so correct me if I'm wrong.
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
Finally I tracked down the problem of the wrong admin urls.

The Core/Frameworks/Flake/Framework.php wrongfully detect the base url of the site. Although the problem is not with the Framework.php but with the php version included with dsm 5.0. There is a problem with a php function named substr_compare which is compares to strings but it always return true even if the searched string not included in the base string. This specific function used for testing the url if it's includes the actual php script's name (mostly index.php) or not to decide to cut it off or not from the request uri. So if you try to access the admin like this http://[hostname]/baikal/admin/index.php it will work until the url has the index.php ending. But if you not specify the index.php at the end it won't.

So to fix this (more precisely to make a workaround) you have to edit the referred php script and replace the endsWith function (line 81) to this one:

PHP:
	public static function endsWith($sString, $sTest) {
		$iTestLen = strlen($sTest);
		if ($iTestLen > strlen($sString)) return false;
		//this is the original line: return substr_compare($sString, $sTest, -$iTestLen) === 0; 
		return substr($sString, -$iTestLen) == $sTest;
	}
After this the admin site will function normally without further modification of admin/index.php
After testing this weekend with my "enhanced zaza.php", the only logical explanation I could come up with was a buggy standard function in the PHP of DSM 5. It seemed very unlikely to me :eek:

Your improved code makes perfectly sense to me.

=> Just to be sure: can someone else test this as well ?

Next steps could be:
- ask the Baikal team to implement the fix and make a new release
- possibly fix this for the current Synology package in advance

Thx,
Erik
 
Zuletzt bearbeitet:

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
Rich (BBCode):
return substr_compare($sString, $sTest, -$iTestLen, 1) === 0;

I'm no PHP expert, so correct me if I'm wrong.
I am not a PHP expert either, but I think this code would only compare the first char, not the whole test string.

/Erik
 

keyhan

Benutzer
Mitglied seit
20. Mai 2012
Beiträge
22
Punkte für Reaktionen
0
Punkte
0
@Basalt:
Yes, that's what I would expect too. I compared the results of this specific "substr_compare" routine on DSM 5 and on this site.
The code i took:
Rich (BBCode):
$sString = "/baikal/admin/";
$sTest = "index.php";
$iTestLen = 9;
echo substr_compare($sString, $sTest, -$iTestLen);
echo " ... ";
echo substr_compare($sString, $sTest, -$iTestLen, 1);
The results are completely different.
On Synology I get 0 (without length) and -5 (with the length parameter).
While the Sandbox gives me -1 in both cases.
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
Very strange indeed.

Do you agree with Pimpa's proposal ?
 

funkfux

Benutzer
Mitglied seit
20. Mai 2014
Beiträge
2
Punkte für Reaktionen
0
Punkte
0
Hey!

The same problem occured to me and google directed me to to Pimpa's solution. I tested it, but it didn't work for me. Instead I changed line 37 in baikal/Core/Frameworks/BaikalAdmin/Framework.php as follows:

Rich (BBCode):
namespace BaikalAdmin;

class Framework extends \Flake\Core\Framework {
	
	public static function bootstrap() {
		define("BAIKALADMIN_PATH_ROOT", PROJECT_PATH_ROOT . "Core/Frameworks/BaikalAdmin/");	# ./
		
		\Baikal\Framework::bootstrap();
		\Formal\Framework::bootstrap();

		// Original code: $GLOBALS["ROUTER"]::setURIPath("admin/");
                $GLOBALS["ROUTER"]::setURIPath("admin/index.php");


		# Include BaikalAdmin Framework config
		require_once(BAIKALADMIN_PATH_ROOT . "config.php");
	}
}
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
The same problem occured to me and google directed me to to Pimpa's solution. I tested it, but it didn't work for me. Instead I changed line 37 in baikal/Core/Frameworks/BaikalAdmin/Framework.php as follows:
[...]
There is no such code in the Baikal 0.2.7 flat package, where this Syno package is based on.
What Baikal version are you using? How did you install?

Shortly, I will release the -002 version of this Syno package. I would appreciate if you could test it.

Best regards,
Erik
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
0.2.7-002 released

I just released the 0.2.7-002 version on SourceForge (see first post for the link), with the fix suggested by Pimpa.
Please check if this solves the issue for you all. See PDF manual for update instructions.

=> Remember that when using SQLite (NOT: MariaDB), appearently you need to enable the mssql extension (see e.g. this post).

:):) Many thanks to atzis77, mausbieber, rwe444, dsmynas, grottenolm, keyhan, Pimpa, funkfux and others for testing, analysing, suggesting improvements, etc, etc :):)

/Erik
 
Zuletzt bearbeitet:

funkfux

Benutzer
Mitglied seit
20. Mai 2014
Beiträge
2
Punkte für Reaktionen
0
Punkte
0
There is no such code in the Baikal 0.2.7 flat package, where this Syno package is based on.
What Baikal version are you using? How did you install?

I'm using Baikal0.2.7 as well. You find the code in your package.tgz and then in /flat/Core/Frameworks/BaikalAdmin/Framework.php.

However, the origin of my problem wasn't in this file, but in the settings of my server. Normally, if you try to access a folder like https://mydomain/baikal/admin/ the server tries to show you the index file of this folder. But my server was configured to show index.html files only, so I had to tell him to look for index.php files as well.
 

Basalt

Benutzer
Mitglied seit
06. Mai 2012
Beiträge
255
Punkte für Reaktionen
0
Punkte
0
You find the code in your package.tgz and then in /flat/Core/Frameworks/BaikalAdmin/Framework.php.
Aha, you are right, I looked in the wrong folder.

I understand that the fix you mentioned was specifically for your situation, not to be generally implemented by others.

Thanks for your feedback,
Erik.
 

grottenolm

Benutzer
Mitglied seit
11. Apr 2013
Beiträge
6
Punkte für Reaktionen
0
Punkte
0
Danke!

Basalt, wir haben zu danken! Für das Package, die ausdauernde Fehlersuche und das schnelle Update.

Viele Grüße,
Grottenolm
 

atsiz77

Benutzer
Mitglied seit
21. Dez 2013
Beiträge
255
Punkte für Reaktionen
10
Punkte
18
Wie bekommen wir denn Update ohne die vorhandenen Daten gelöscht zu bekommen?
 
Status
Für weitere Antworten geschlossen.
 

Kaffeautomat

Wenn du das Forum hilfreich findest oder uns unterstützen möchtest, dann gib uns doch einfach einen Kaffee aus.

Als Dankeschön schalten wir deinen Account werbefrei.

:coffee:

Hier gehts zum Kaffeeautomat