Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

File() Function alert for updating

edited May 2006 in Vanilla 1.0 Help
Besically, if your host has disabled the PHP file() function, you won't be able to check for updates. You'll get an error like this: Warning: file() [function.file]: URL file-access is disabled in the server configuration in ---/library/Framework/Framework.Control.UpdateCheck.php on line 49 Warning: file(http://lussumo.com/updatecheck/vanilla.php?Application=Vanilla&Version=1&Language=English) [function.file]: failed to open stream: no suitable wrapper could be found in ---/library/Framework/Framework.Control.UpdateCheck.php on line 49 Warning: implode() [function.implode]: Bad arguments. in ---/library/Framework/Framework.Control.UpdateCheck.php on line 54 In a future Vanilla 1 update could it also have error reporting for that please?
«1

Comments

  • MarkMark Vanilla Staff
    Thanks for the report. I've already got that captured in the repository version - it was one of the first bugs reported when the pre-release came out :) I can't really do anything about it if that fails. All I can do is capture the error and explain why it failed. So, you'll now get a pretty verbose error message if it fails.
  • Why not just use sockets?
  • i actually tried to hack this one a bit on my own forum. is there a way to force it to use cURL (which is enabled on my host) rather than the standard fopen (which is not)?
  • MarkMark Vanilla Staff
    SirNot: Please exlpain. jsanders: I considered using curl by default, but it's not a standard php feature and therefore won't be supported by all servers. fopen is included in php, although it can be switched off in the php.ini (and that can't be overridden, of course).
  • http://www.php.net/sockets Then just act as a simple HTTP client to retrieve the file from the server.
  • MarkMark Vanilla Staff
    sirnot: do you have any example code for how to retrieve a file with that? I'm really busy now, but I'd like to try it.

    Also, are you sure that even socket connections won't be limited by the php.ini?

    ;;;;;;;;;;;;;;;;;; ; Fopen wrappers ; ;;;;;;;;;;;;;;;;;; ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = Off
  • NickENickE New
    edited May 2006
    Fopen wrappers
    That applies to the wrapper for fopen/file/file_get_contents/whatever that allows urls to be treated like normal files when reading them, not a setting for actual socket functions. In fact, according to php.net:
    Runtime Configuration
    This extension has no configuration directives defined in php.ini
    I'm afraid it's sort of late at the moment so I can't make an example for you myself, but there are plenty online. A simple google search will give you lots of classes and libraries to achieve this type of thing; even that php.net page has a simplistic HTTP client example on it.
  • ithcyithcy New
    edited May 2006
    generic sockets code from php.net:
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET / HTTP/1.1\r\n"; $out .= "Host: www.example.com\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); }

    it's very easy to use.

    //edit: or, what SirNot said. but i don't like to refresh before posting. i like to live on the edge.
  • MarkMark Vanilla Staff
    ithcy: what you've got there is almost exactly what I've written in the update check and it doesn't work if allow_url_fopen is disabled.

    SirNot is talking about something entirely different.

    And SirNot: I looked at that page and didn't find any decent examples in the comments below. Maybe I'm daft.
  • I think the major difference between the two, is that fsockopen() only has the ability to read up to a certain ammount of data as the author specifies along with accessing a server and passing an agent string if necessary, while fopen() will retrieve all of it. It had totally slipped my mind until I recalled of a little script I wrote to snag info from 7.htm on shoutcast servers. While I can't verify the exact difference(s), we already know that one will work without having to enable anything in php.ini.
  • MarkMark Vanilla Staff
    Hmmm. Maybe I'm wrong. I'm gonna try ithcy's code and see what gives....
  • MarkMark Vanilla Staff
    Okay, it wasn't quite so simple, but I got 'er figured. It's all done and up in svn.
  • I'll turn off the earlier file() changes I made, toss an SVN copy up and report what happens.
  • ok, Just tossed revision 434 from the SVN onto my server after turning the allow_url_fopen paramater to "off" and recieved the following error:
    Notice: Undefined index: port in /var/www/...domain.../docs/forum/library/Framework/Framework.Functions.php on line 469
  • lechlech
    edited May 2006
    unless my editor is reporting the wrong line numbers, line 469 reads:
    $Port = $ParsedUrl['port'];
    and I see nothing wrong with that at first glance, I'll have a run through this in a bit and see if I can hack it into shape.
  • MarkMark Vanilla Staff
    Yeah, this was my first time trying out php's parse_url function, and of course it fucked up.

    So, I've dummy proofed it. Get the latest svn and it should work.
  • ok, that works flawlessly now and doesn't appear to hang anymore upon update checks. before it was returning:
    Bad Request Your browser sent a request that this server could not understand. Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.1.4 PHP/4.3.10-16 mod_ssl/2.0.54 OpenSSL/0.9.7e Server at (removed).linode.com Port 80
  • Either way, yeah, it looks foolproof at the moment from what I can tell, wewt.
  • ithcyithcy New
    edited May 2006
    i'll just sit here and await mark's apology.
  • MarkMark Vanilla Staff
    hahaha - sorry ithcy. you were right and I was wrong.

    there.

    are you happy now?

    ARE YOU @#@#!NG HAPPY NOW?!
This discussion has been closed.