1 damondamore Mar 18, 2007 22:15
3 damondamore Mar 19, 2007 10:44
I havn't contacteed them yet, but let's say they did. Is there some other way I could do trackbacks?
(like using another function or somting, ovously I'd need to re-write at least part if not all of the code)
4 yabba Mar 19, 2007 11:14
You might be able to use [url=http://uk.php.net/manual/en/ref.curl.php]curl[/url] instead.
¥
5 damondamore Mar 19, 2007 11:21
Thanks. I'll let you know how it goes when my webserver responds.
6 damondamore Mar 20, 2007 02:30
My server told me to do the exact same thing. Just use curl. Thanks!
7 inm Aug 22, 2007 16:37
Hi, i am having the same problem as above... what is a curl?
Thanks,
-n
8 stk Aug 22, 2007 22:38
INM,
You might want to read the link that ¥åßßå
put in [url=http://forums.b2evolution.net/viewtopic.php?p=52750#52750]his post[/url]. ;)
PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies, and user+password authentication.
These functions have been added in PHP 4.0.2.
9 sopur Jan 08, 2008 15:55
¥åßßå wrote:
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration
I'd say that your host has disallowed fopen() so the chances are you'd need to contact them.
¥
Hello!
I have the same problem. Couldn't I change that myself?
Regards
Sopur
10 stk Jan 08, 2008 18:19
Sopur,
What I would do would be to first [url=http://www.mirrorimages.net/mi_faq.php?do=a&cid=4&id=48]make a PHPINFO file[/url] and verify under "Configuration" that "allow_url_fopen" is set to OFF.
Most hosts will allow you to change PHP values for just your web site. You do this by creating a php.ini file in the main folder of your site (it's just a plain text file, which you will likely need to create). Once this is done, simply put in the necessary lines in order to alter the troublesome variables (i.e., allow_url_fopen = on -or- allow_url_fopen = 1).
In this way you will overwrite the settings of the server only for your website.
IF you wanted to override the default php settings for just a single script, rather than your whole site, you can do this in the script by using the ini_set() function:
<?php
ini_set('allow_url_fopen', true);
Note: Some values can only be set/changed/overridden in certain locations ... see [url=http://ca.php.net/manual/en/ini.php]php.ini directives[/url] for more information [allow_url_fopen appears to be one that can be set "anywhere" (php.ini, .htaccess, httpd.conf or user scripts)]
[url=http://ca.php.net/manual/en/function.phpinfo.php]more about phpinfo[/url]
[url=http://ca.php.net/filesystem]More about filesystems[/url]
[url=http://ca.php.net/manual/en/function.ini-set.php]more about ini_set[/url]
11 sopur Jan 09, 2008 10:56
Hello stk
Thank you! My provider said the same to me, but he told, for security reasons it would be better to use curl. That would be installed by default.
But how do I implement curl to the trackback-funktion?
Regards
Sopur
12 stk Jan 09, 2008 18:09
Sopur,
I've never done it before, so I'm just postulating, but *I think* you'd just need to find the fopen() part of the trackback script that's failing (because fopen isn't allowed on your server) and change it to use the PHP curl() function.
(Apparently, curl offers more "options" than fopen, which is the good news. The bad news is that it because it allows more options, it requires a bit more code than fopen.)
After a quick googling I found [url=http://www.phpit.net/article/using-curl-php/]this page[/url] which is what I would use, to start on my path to hanging 10 on a big California trackback curl. ;)
Two other thoughts -
1) If you can somehow get ¥åßßå's attention, he'd be able to "open the door" a tad wider than me.
2) Trackbacks? - bleck (IMO ... just a door for SPAM. I seldom received any, I never used them and I finally just shut them off on our own blog.)
13 sopur Jan 10, 2008 10:55
So, I tried, just to change the fopen into curl - but it did not work.
I do not know php - so I have no idea what to do...
Since I like the trackback function, I would be very happy to get i work :-)
Perhaps ¥åßßå will read this thread ;-)
Regards
Sopur
14 sopur Jan 25, 2008 14:12
Hello again!
Doesn't anybody know, how I can change the trackback-funktion into curl?
Best regards and many thanks!
Sopur
15 yabba Jan 26, 2008 16:04
Hi there,
You'd need to amend this function ( inc/comments/_trackback.funcs.php approx 57 - 181 ) to use curl instead of fopen and fsockopen
/**
* Send Trackback to single URL
*
* trackback(-)
*
* @todo add autodiscovery
*/
function trackback(
$trackback_url,
$title,
$excerpt,
$ID) // post ID
{
global $app_name, $app_version, $Blog, $Messages;
$trackback_message = T_('Sending trackback to:').' '.htmlspecialchars($trackback_url).' ';
$title = rawurlencode($title);
$excerpt = rawurlencode($excerpt);
$blog_name = rawurlencode($Blog->get( 'name' ));
$ItemCache = & get_Cache( 'ItemCache' );
$Item = & $ItemCache->get_by_ID( $ID );
$url = rawurlencode( $Item->get_permanent_url('', '', '&') );
// dis is the trackback stuff to be sent:
$query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
// echo "url:$trackback_url<br>$sending:$query_string<br />";
$result = '';
if (strstr($trackback_url, '?'))
{
$Messages->add( $trackback_message.'[get]', 'note' );
$trackback_url .= "&".$query_string;;
flush();
if( $fp = fopen($trackback_url, 'r') )
{
// blueyed>> why do we here just read the first 4kb, but in the POSTed response everything?
// fp>> this is dirty code... I've never really reviewed it entirely. Feel free to refactor as much as needed.
$result = fread($fp, 4096);
fclose($fp);
/* debug code
$debug_file = 'trackback.log';
$fp = fopen($debug_file, 'a');
fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
fwrite($fp, $result);
fwrite($fp, "\n\n");
fclose($fp);
*/
}
}
else
{
$Messages->add( $trackback_message.'[post]', 'note' );
$trackback_url = parse_url($trackback_url);
if( ! empty($trackback_url['host']) && ! empty($trackback_url['path']) )
{ // Only try trackback if we have host and path:
$port = isset($trackback_url['port']) ? $trackback_url['port'] : 80;
$http_request = 'POST '.$trackback_url['path']." HTTP/1.0\r\n";
$http_request .= 'Host: '.$trackback_url['host']."\r\n";
$http_request .= 'Content-Type: application/x-www-form-urlencoded'."\r\n";
$http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
$http_request .= "User-Agent: $app_name/$app_version\r\n";
$http_request .= "\r\n";
$http_request .= $query_string;
flush();
if( $fs = @fsockopen($trackback_url['host'], $port, $errno, $errst, 20) ) // this timeout is just for setting up the socket
{
// Set timeout for data:
if( function_exists('stream_set_timeout') )
{
stream_set_timeout( $fs, 20 ); // PHP 4.3.0
}
else
{
socket_set_timeout( $fs, 20 ); // PHP 4
}
fputs($fs, $http_request);
$result = '';
while(!feof($fs))
{
$result .= fgets($fs, 4096);
}
/* debug code
$debug_file = 'trackback.log';
$fp = fopen($debug_file, 'a');
fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n$result");
while(!@feof($fs)) {
fwrite($fp, @fgets($fs, 4096));
}
fwrite($fp, "\n\n");
fclose($fp);
*/
fclose($fs);
}
}
}
// extract the error code and message, then make the error code readable
if ( preg_match("/<error>[\r\n\t ]*(\d+)[\r\n\t ]*<\/error>/", $result, $error) )
{
preg_match("/<message>(.*?)<\/message>/", $result, $error_message);
$message = isset($error_message[1]) ? $error_message[1] : '';
switch ($error[1]) {
case '0':
$result_message = '[' . T_('Succeeded') . '] ' . $message;
break;
case '1':
$result_message = '[' . T_('Failed') . '] ' . $message;
break;
default:
$result_message = '[' . T_('Unknown error') . ' (' . $error[1] . ')] ' . $message;
break;
}
}
else
{
$result_message = T_('No valid trackback response. Maybe the given url is not a Trackback url.') . ' "' . $result . '"';
}
$Messages->add( T_('Response:').' '.strip_tags($result_message), 'note' );
return $result;
}
¥
16 sopur Jan 28, 2008 20:08
Hello!
I tried to amend this function by replacing all fopen and fsockopen into curl - but that did not work.
Do I have to rebuilt the whole function?
Many thanks and regards
Sopur
17 yabba Jan 28, 2008 20:13
Sorry I don't use trackbacks and I haven't played with curl much. You basically need to replace just the middle section of the code where it makes the requests
¥
18 sopur Jan 28, 2008 20:22
Thank you, I will try :-)
Regards
Sopur
19 thedreamer May 11, 2008 21:36
Well, I discovered trackbacks from my site weren't working. I never noticed when I first moved to dreamhost, because I had turned off trackback on my blog because I was getting too much spam.
But, having upgrade 2.4.1 and then 2.4.2, and having other options to control trackback spam... I decided to try turning the feature back on....
Today, I tried to send a trackback...and it wasn't working. Since it was to another 2.4.2 b2evolution of mine...it took some work to figure out which end the problem was on.
Eventually, I found that it is because Dreamhost's php doesn't allow fopen and I don't have the option to build my own php to circumvent this (I guess if I upgrade to VPS, I could). Seemed strange, because I was sure I had run into this problem a long time ago....but I just realized it was when I moved a different website to 1&1, and not the (same) problem I was running into here.
After find this posting....I went looking for how to do it as easily as possible using Curl.
What I did was:
find a Curl wrapper -- http://github.com/shuber/curl/tree/master
I put it in 'inc'.
Insert "require_once 'inc/curl.php';" into 'inc/comments/_trackback.func.php'.
And, then replace the fopen call with something like this:
$curl = new Curl;
$response = $curl->get($trackback_url);
$result = $response->body;
Haven't looked at the post method.....perhaps when I encounter that problem....or perhaps somebody else will contribute that ;)
The Dreamer
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration
I'd say that your host has disallowed fopen() so the chances are you'd need to contact them.
¥