PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Oct 23, 2017 12:06 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Wed Dec 04, 2013 9:19 am 
Offline
Forum Newbie

Joined: Wed Dec 04, 2013 9:15 am
Posts: 5
Hello,

I need to know which function could perhaps disabled by my Hoster.
After a Domain Move my Hoster had set some function's to diabled for security reasons. I can talk to my Hoster Support to enable this function's but i need to know what function this are.


Syntax: [ Download ] [ Hide ]
    Warning: stream_set_blocking() expects parameter 1 to be resource, null given in
    /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php on line 265
     
    Warning: stream_set_timeout() expects parameter 1 to be resource, null given in
    /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php on line 269


    Fatal error:
    Uncaught exception 'Swift_TransportException' with message 'Expected response code 220 but got code "", with message ""'
    in /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386
    Stack trace:
    #0 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php(291):
       Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array)
    #1 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php(119):
       Swift_Transport_AbstractSmtpTransport->_readGreeting()
    #2 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Mailer.php(80):
       Swift_Transport_AbstractSmtpTransport->start()
    #3 /var/www/web128032/html/includes/register1.php(203): Swift_Mailer->send(Object(Swift_Message))
   #4 /var/www/web128032/html/index.php(42): include('/var/www/web128...')
   #5 {main} thrown in /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 386



Greetings Jörg.


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 11:45 am 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
Check /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php, line 265 to see what the first argument to the function call is, then find where the variable is assigned. There you'll find one of the functions producing a stream, like fopen or stream_socket_client (there are many various functions that may produce a stream). That function is what's failing.


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 1:10 pm 
Offline
Forum Newbie

Joined: Wed Dec 04, 2013 9:15 am
Posts: 5
Sure had the same thoughts, beetween a figured out that proc_open is disabled.

Syntax: [ Download ] [ Hide ]
echo function_exists('proc_open') ? "Yep, that will work" : "Sorry, that won't work";

Ouput was: "Sorry, that won't work"

Now i have to wait for my Hoster-Support then i can tell you if it now works. Ive seen many Posts an Question with the same Problem and Trace but no solutions (the most of them change the Hoster)

Anyway hier is the StreamBuffer.php:
https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Transport/StreamBuffer.php
I was not able to say for sure which Ressource will be filled in the func stream_set_blocking()
But i think it could be an disabled proc_open()


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 1:58 pm 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
See https://github.com/swiftmailer/swiftmai ... r.php#L257 - it's stream_socket_client that returned null.


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 2:26 pm 
Offline
Forum Newbie

Joined: Wed Dec 04, 2013 9:15 am
Posts: 5
Yes you are right!

hell what did my hoster all disabled? men i wrote him since 3 or 4 days first mail() then other now proc_open and stream_socket_client
Syntax: [ Download ] [ Hide ]
echo function_exists('stream_socket_client') ? "2 Yep, that will work" : "2 Sorry, that won't work";

$fp = stream_socket_client("tcp://www.example.com:80", $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    fwrite($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n");
    while (!feof($fp)) {
        echo fgets($fp, 1024);
    }
    fclose($fp);
}

Output:
2 Sorry, that won't work
Warning: stream_socket_client() has been disabled for security reasons in /var/www/web128032/html/Backend/templates/admin.tpl on line 24


But i wonder why trows not this Errormessage to lines later?
https://github.com/swiftmailer/swiftmai ... r.php#L260

I think the support will hate me soon :D


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 2:52 pm 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
Quote:
But i wonder why trows not this Errormessage to lines later?

That's because it only executes that branch if the function returned false (and you got null, as all disabled function implicitly return null). The code clearly does not expect the function to be disabled.


Top
 Profile  
 
PostPosted: Wed Dec 04, 2013 3:02 pm 
Offline
Forum Newbie

Joined: Wed Dec 04, 2013 9:15 am
Posts: 5
Ah yes ok i thought 0 == false. Ok know i unterstand.
Ok i wait for Request from my Support and will give feedback if solved or not (so can other participate from our Thread).

Thx you between!

greetings Jörg.


Top
 Profile  
 
PostPosted: Thu Dec 05, 2013 5:38 am 
Offline
Forum Newbie

Joined: Wed Dec 04, 2013 9:15 am
Posts: 5
So the Problem is solved.

To solve this trace you have to enable mail() and stream_socket_client()
My Hoster did not enable proc_open() because of Security Risks! But Swiftmailer (i think so) have build a Fallback for this function.

Thank you Weirdan for your Help.

Edit: fsockopen() was also enabled earlier, not sure if swiftmailer works with zhis function.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group