Create Plugin, Syntax Error?

shwetha17

Member
May 24, 2018
785
0
16
Hello Everyone,

I am having an issue with the create plugin, I am able to browse, and select files/folders for torrent creation, but once I select the file/files, enter the required information, I hit Create at which point it goes through the process of creating the torrent metafile, once the torrent creation process is complete I get the following error in the lower box:

Code:
Warning: file_put_contents(): The 2nd parameter should be either a string or an array in /var/www/html/test3/php/Torrent.php on line 363
In the upperbox the follow message is there:

Code:
mktorrent 1.0 (c) 2007, 2009 Emil Renner Berthing

Hashed 0 of 378 pieces.
Hashed 32 of 378 pieces.
Hashed 71 of 378 pieces.
Hashed 110 of 378 pieces.
Hashed 148 of 378 pieces.
Hashed 187 of 378 pieces.
Hashed 225 of 378 pieces.
Hashed 263 of 378 pieces.
Hashed 301 of 378 pieces.
Hashed 337 of 378 pieces.
Hashed 378 of 378 pieces.
Writing metainfo file... done.
Try to correct torrent file...
Done.
I am using rutorrent v3.0, I have the command line php installed, curl is fine, both are defined in the rutorrent config file. %webdirectory%/conf/config.php

I think this error is a php syntax error as the error states...
"The 2nd parameter should be either a string or an array..."

A look at the code of the page specified 'Torrent.php' the function in question is located on line 363,
'file_put_contents()' It is part of the greater function as show here:

Code:
/** Save torrent file to disk
* @param null|string name of the file (optional)
* @return boolean file has been saved or not
*/
public function save( $filename = null )
{
return file_put_contents( is_null( $filename ) ? $this->info['name'] . '.torrent' : $filename, $this );
}

Taking a look here: http://www.w3schools.com/php/func_filesystem_file_put_contents.asp
We can see that the 2nd parameter would be the parameter specified after the first ","
Which would be:
Code:
( is_null( $filename ) ? $this->info['name'] . '.torrent' : $filename, ----> $this <--- )
My thoughts on the error would be that, the $this variable is either being passed as "NULL" or being passed as a Integer for some reason, I am not a php coding expert, I could be totally wrong, lol.

I have checked all over this forum and people have spoken of the same error, but all the proposed or even closely related solutions have no effect.

Could this error be related to the ability for php to write files over a certain size? I know that the large the file being hashed for torrents the larger the torrent metafile.

Any help in this matter would be greatly appreciated. Thanks
 

somus1735

Member
May 25, 2018
833
0
16
My thoughts on the error would be that, the $this variable is either being passed as "NULL" or being passed as a Integer for some reason, I am not a php coding expert, I could be totally wrong, lol.
http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
Could this error be related to the ability for php to write files over a certain size? I know that the large the file being hashed for torrents the larger the torrent metafile.
http://bugs.php.net/bug.php?id=27792
 

jith45

Member
May 25, 2018
960
0
16
I use PHP v5.1.6

I run a CentOS v5.4 i386 Server w/ 2GB RAM

It happens even when trying to create a torrent for a small file such as a single NFO or a 100MB r01 (RAR part file).
 

somus1735

Member
May 25, 2018
833
0
16
to be fair, php 5.1 is ancient.

CentOS has a REALLY bad habit of having super old packages....It's one reason i prefer FreeBSD.

(btw, that wasn't meant as an insult towards you, i'm just a big FreeBSD fan =))

Even with it being CentOs 5.1 seems kind of old...but alas....it's true...
to install 5.2 on centos:

Code:
Yum repo: http://www.jasonlitka.com/yum-repository/
pecl uninstall apc
mv /etc/php.d/apc.ini /tmp/apc.ini
yum update php
pecl -d memory_limit=16M install apc
mv /tmp/apc.ini /etc/php.d/apc.ini
 

jith45

Member
May 25, 2018
960
0
16
lmao, I didn't take that as an insult man, thats I posted that back in the email just to razz you. tongue.gif
I've got to give BSD a shot I just havn't gotten around to it.

PHP v5.2... That makes sense grin.gif
Thank you for the info on upgrading php, I will give it a shot and let you know how it works.

btw I love rutorrent, keep up the good work. smiley.gif

UPDATE:
I have updated from that repo and run the afformentioned commands. I now have the ability to create torrents. Thank you very much for all you help. I think a number of people have this issue, and pehaps this post should be a sticky.