xwmario / rutorrent

Automatically exported from code.google.com/p/rutorrent
0 stars 0 forks source link

http://rutorrent.example.com/php/getsettings.php generates error when /.../rutorrent/share/users/.../settings/uisettings.json does not exist #877

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Reproduce:
1. Fresh 'install' of ruTorrent
2. php-fpm and in php.ini: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
3. goto: http://rutorrent.example.com/

What is the expected output? What do you see instead?
Request fails and ruTorrent returns invalid reponse.

What environment are you using?
1. My ruTorrent version is v3.6 (svn $Rev: 2404 $)
2. My rTorrent version is v0.9.2
3. I use web-server nginx it version is 1.4.3 on OS Debian Linux
4. Browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/31.0.1650.63 Safari/537.36

Are some errors present in the web-server log?
2013/12/07 00:41:46 [error] 26689#0: *185 FastCGI sent in stderr: "PHP message: 
PHP Warning:  
fopen(/data/www/rutorrent/share/users/dipswitch/settings/uisettings.json): 
failed to open stream: No such file or directory in 
/data/www/rutorrent/php/getsettings.php on line 8" while reading response 
header from upstream, client: 0.0.0.0, server: rutorrent.example.com, request: 
"POST /php/getsettings.php HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/php5-fpm.sock:", host: "rutorrent.example.com", 
referrer: "http://rutorrent.example.com/"

dir list:
    dipswitch@epicserver:/data/www/rutorrent/share $ ls -lhR
    .:
    total 12K
    drwxr-xr-x 2 www-data www-data 4.0K Oct 16 13:42 settings
    drwxr-xr-x 2 www-data www-data 4.0K Oct 16 13:42 torrents
    drwxr-xr-x 3 www-data www-data 4.0K Dec  7 00:57 users

    ./settings:
    total 0

    ./torrents:
    total 0

    ./users:
    total 4.0K
    drwxrwxrwx 4 www-data www-data 4.0K Dec  7 00:31 dipswitch

    ./users/dipswitch:
    total 8.0K
    drwxrwxrwx 2 www-data www-data 4.0K Dec  7 00:48 settings
    drwxrwxrwx 2 www-data www-data 4.0K Dec  7 00:31 torrents

    ./users/dipswitch/settings:
    total 4.0K
    -rw-rw-rw- 1 www-data www-data 883 Dec  7 00:48 rtorrent.dat

    ./users/dipswitch/torrents:
    total 0

Are some errors present in the browser error console?
Request:
    Request URL:http://rutorrent.example.com/php/getsettings.php
    Request Method:POST
    Status Code:200 OK
    Request Headersview source
    Accept:application/json, text/javascript, */*; q=0.01
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
    Authorization:Basic bmljazplcGljZXBpY3dpbiE=
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:0
    Content-Type:text/xml; charset=UTF-8

Response:
    Host:rutorrent.example.nl
    Origin:http://rutorrent.example.com
    Referer:http://rutorrent.example.com/
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
    X-Requested-With:XMLHttpRequest
    Response Headersview source
    Connection:keep-alive
    Content-Length:2
    Content-Type:application/json; charset=UTF-8
    Date:Fri, 06 Dec 2013 23:48:36 GMT
    Server:nginx
    X-Powered-By:PHP/5.5.5-1
    X-Server-Timestamp:1386373716

    {

One of both fixes should suffice.
fix1.patch:
    diff -u /data/www/rutorrent/php/getsettings.php /data/www/rutorrent/php/getsettings-fix.php
    --- /data/www/rutorrent/php/getsettings.php     2013-12-07 00:52:16.778016265 +0100
    +++ /data/www/rutorrent/php/getsettings-fix.php 2013-12-07 00:51:40.078015337 +0100
    @@ -5,7 +5,7 @@
     $s = '{}';
     $fname = getSettingsPath()."/uisettings.json";
     $fo = false;
    -$fo = fopen($fname, 'r');
    +$fo = @fopen($fname, 'r');
     if($fo!==false)
     {
            if(flock($fo, LOCK_SH))

fix2.patch:
    diff -u /data/www/rutorrent/php/getsettings.php /data/www/rutorrent/php/getsettings-fix.php
--- /data/www/rutorrent/php/getsettings.php     2013-12-07 00:52:16.778016265 
+0100
+++ /data/www/rutorrent/php/getsettings-fix.php 2013-12-07 01:00:27.095978787 
+0100
@@ -5,7 +5,8 @@
 $s = '{}';
 $fname = getSettingsPath()."/uisettings.json";
 $fo = false;
-$fo = fopen($fname, 'r');
+if (file_exists($fname))
+  $fo = fopen($fname, 'r');
 if($fo!==false)
 {
        if(flock($fo, LOCK_SH))

Original issue reported on code.google.com by nick.de....@gmail.com on 7 Dec 2013 at 12:16

Attachments:

GoogleCodeExporter commented 8 years ago
It doesn't "generates errors". It generates warnings.

>Request fails and ruTorrent returns invalid reponse.

Request doesn't fails and ruTorrent returns a normal response.

Please, don't create issues with an incorrect data.

Original comment by novik65 on 7 Dec 2013 at 6:38