Hello,
I got the following error in my application.
warning: file_get_contents(http://abc.mywebsite.com/?prt=test) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/html/includes/common.inc(1352) : eval()'d code on line 22.
here is content in common.inc near the line 1352:
function drupal_eval($code) { ob_start(); print eval('?>'. $code); //line 1352 here $output = ob_get_contents(); ob_end_clean(); return $output; }
from my web server linux box, wget http://abc.mywebsite.com/?prt=test doesn't work before, connection refused. I later get it works. However, I still keep getting the same error.
I tried to replace the line print eval('?>'. $code); with teh following code. /* print eval('?>'. $code); */ $code = str_replace('<'.'?php','<'.'?',$code); eval('?'.'>'.trim($code).'<'.'?');
and then restart apache web server, and even tried to reboot computer. still the same error message generated, though the line 1352 is a comment line now.
I wonder if there is cache or precomiled code in drupal causing this problem?
Thanks.
I don't think there is anything wrong with function drupal_eval(). It just tries to run some php code which you have written in a post or in a block and fails. The error is in line 22 of your own code, apparently a call to file_get_contents(http://abc.mywebsite.com/?prt=test).
What is your PHP version?
One thing you could try is to add allow_url_fopen = true and allow_url_include = true in php.ini, but I smell a security risk in allowing remote includes.
On Sat, Jul 12, 2008 at 10:53 PM, tom lee freemail168@gmail.com wrote:
Hello,
I got the following error in my application.
warning: file_get_contents(http://abc.mywebsite.com/?prt=test) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/html/includes/common.inc(1352) : eval()'d code on line 22.
here is content in common.inc near the line 1352:
function drupal_eval($code) { ob_start(); print eval('?>'. $code); //line 1352 here $output = ob_get_contents(); ob_end_clean(); return $output; }
from my web server linux box, wget http://abc.mywebsite.com/?prt=test doesn't work before, connection refused. I later get it works. However, I still keep getting the same error.
I tried to replace the line print eval('?>'. $code); with teh following code. /* print eval('?>'. $code); */ $code = str_replace('<'.'?php','<'.'?',$code); eval('?'.'>'.trim($code).'<'.'?');
and then restart apache web server, and even tried to reboot computer. still the same error message generated, though the line 1352 is a comment line now.
I wonder if there is cache or precomiled code in drupal causing this problem?
Thanks.
[ Drupal support list | http://lists.drupal.org/ ]
On Sat, Jul 12, 2008 at 8:41 PM, Cog Rusty cog.rusty@gmail.com wrote:
I don't think there is anything wrong with function drupal_eval().
right, I commented out the full function
function drupal_eval($code) { ob_start(); print eval('?>'. $code); // line 1352 $output = ob_get_contents(); ob_end_clean(); return $output; }
I still get the same error. it looks th line 1352 in /var/www/html/includes/common.inc is incorrectly reported.
It just tries to run some php code which you have written in a post or in a block and fails. The error is in line 22 of your own code, apparently a call to file_get_contents(http://abc.mywebsite.com/?prt=test).
for the following error. warning: file_get_contents(http://abc.mywebsite.com/?prt=test) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/html/includes/common.inc(1352) : eval()'d code on line 22.
which file does "line 22" refer to?
What is your PHP version?
apache version 2.2.8, php 5.2.6.
One thing you could try is to add allow_url_fopen = true and
it is there already.
allow_url_include = true in php.ini,
I tried to turn it on and reloaded httpd, but I get the same error.
Thanks.
tom
On Sun, Jul 13, 2008 at 6:55 AM, tom lee freemail168@gmail.com wrote:
On Sat, Jul 12, 2008 at 8:41 PM, Cog Rusty cog.rusty@gmail.com wrote:
I don't think there is anything wrong with function drupal_eval().
right, I commented out the full function
function drupal_eval($code) { ob_start(); print eval('?>'. $code); // line 1352 $output = ob_get_contents(); ob_end_clean(); return $output; }
I still get the same error. it looks th line 1352 in /var/www/html/includes/common.inc is incorrectly reported.
If you really have commented out the print eval() line and if there is nothing wrong with the line which is now 1352, then I can't explain it. Maybe some weird caching problem. But I don't believe that there is anything wrong with the print eval() line. I would put it back. It just chokes while trying to execute some bad php code which comes from elsewhere,.
It just tries to run some php code which you have written in a post or in a block and fails. The error is in line 22 of your own code, apparently a call to file_get_contents(http://abc.mywebsite.com/?prt=test).
for the following error. warning: file_get_contents(http://abc.mywebsite.com/?prt=test) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/html/includes/common.inc(1352) : eval()'d code on line 22.
which file does "line 22" refer to?
It does not necessarily refer to any file. It may refer to line 22 of a file or of some php code in a page or in a block. Check for any code of yours containing a file_get_contents(http://abc.mywebsite.com/?prt=test) statement.
What is your PHP version?
apache version 2.2.8, php 5.2.6.
One thing you could try is to add allow_url_fopen = true and
it is there already.
allow_url_include = true in php.ini,
I tried to turn it on and reloaded httpd, but I get the same error.
Hmm... If you find where the file_get_contents(http://abc.mywebsite.com/?prt=test) statement. is, try to replace it with the URL of a real file to see what happens.
Thanks.
tom
[ Drupal support list | http://lists.drupal.org/ ]
On Sat, Jul 12, 2008 at 10:37 PM, Cog Rusty cog.rusty@gmail.com wrote:
Hmm... If you find where the file_get_contents(http://abc.mywebsite.com/?prt=test) statement. is, try to replace it with the URL of a real file to see what happens.
Here is the function call containing file_get_conents: any suggestions about how to replace them with a URL?
function drupal_build_css_cache($types, $filename) { $data = '';
// Create the css/ within the files folder. $csspath = file_create_path('css'); file_check_directory($csspath, FILE_CREATE_DIRECTORY);
if (!file_exists($csspath .'/'. $filename)) { // Build aggregate CSS file. foreach ($types as $type) { foreach ($type as $file => $cache) { if ($cache) { $contents = file_get_contents($file); // Remove multiple charset declarations for standards compliance (and fixing Safari problems) $contents = preg_replace('/^@charset\s+['"](\S*)\b['"];/i', '', $contents); // Return the path to where this CSS file originated from, stripping off the name of the file at the end of the path. $path = base_path() . substr($file, 0, strrpos($file, '/')) .'/'; // Wraps all @import arguments in url(). $contents = preg_replace('/@import\s+(?!url)['"]?(\S*)\b['"]?/i', '@import url("\1")', $contents); // Fix all paths within this CSS file, ignoring absolute paths. $data .= preg_replace('/url((['"]?)(?![a-z]+:)/i', 'url(\1'. $path . '\2', $contents); } } }
// @import rules must proceed any other style, so we move those to the top. $regexp = '/@import[^;]+;/i'; preg_match_all($regexp, $data, $matches); $data = preg_replace($regexp, '', $data); $data = implode('', $matches[0]) . $data;
// Perform some safe CSS optimizations. $data = preg_replace('< \s*([@{}:;,]|)\s|\s()\s* | # Remove whitespace around separators, but keep space around parentheses. /*([^*\\]|*(?!/))+*/ | # Remove comments that are not CSS hacks. [\n\r] # Remove line breaks. >x', '\1', $data);
// Create the CSS file. file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE); } return $csspath .'/'. $filename; }
there is another file containing: $data = file_get_contents('php://input');
I think it is not related to this problem.
Thanks.
tom
On Sun, Jul 13, 2008 at 5:12 PM, tom lee freemail168@gmail.com wrote:
On Sat, Jul 12, 2008 at 10:37 PM, Cog Rusty cog.rusty@gmail.com wrote:
Hmm... If you find where the file_get_contents(http://abc.mywebsite.com/?prt=test) statement. is, try to replace it with the URL of a real file to see what happens.
Here is the function call containing file_get_conents: any suggestions about how to replace them with a URL?
Probably this is not the problem either. How could this code produce file_get_contents(http://abc.mywebsite.com/?prt=test) on "line 22"?
function drupal_build_css_cache($types, $filename) { $data = '';
// Create the css/ within the files folder. $csspath = file_create_path('css'); file_check_directory($csspath, FILE_CREATE_DIRECTORY);
if (!file_exists($csspath .'/'. $filename)) { // Build aggregate CSS file. foreach ($types as $type) { foreach ($type as $file => $cache) { if ($cache) { $contents = file_get_contents($file); // Remove multiple charset declarations for standards compliance (and fixing Safari problems) $contents = preg_replace('/^@charset\s+['"](\S*)\b['"];/i', '', $contents); // Return the path to where this CSS file originated from, stripping off the name of the file at the end of the path. $path = base_path() . substr($file, 0, strrpos($file, '/')) .'/'; // Wraps all @import arguments in url(). $contents = preg_replace('/@import\s+(?!url)['"]?(\S*)\b['"]?/i', '@import url("\1")', $contents); // Fix all paths within this CSS file, ignoring absolute paths. $data .= preg_replace('/url((['"]?)(?![a-z]+:)/i', 'url(\1'. $path . '\2', $contents); } } }
// @import rules must proceed any other style, so we move those to the top. $regexp = '/@import[^;]+;/i'; preg_match_all($regexp, $data, $matches); $data = preg_replace($regexp, '', $data); $data = implode('', $matches[0]) . $data;
// Perform some safe CSS optimizations. $data = preg_replace('< \s*([@{}:;,]|)\s|\s()\s* | # Remove whitespace around separators, but keep space around parentheses. /*([^*\\]|*(?!/))+*/ | # Remove comments that are not CSS hacks. [\n\r] # Remove line breaks. >x', '\1', $data);
// Create the CSS file. file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE); } return $csspath .'/'. $filename; }
there is another file containing: $data = file_get_contents('php://input');
I think it is not related to this problem.
Thanks.
tom
[ Drupal support list | http://lists.drupal.org/ ]
On Sun, Jul 13, 2008 at 7:19 PM, Cog Rusty cog.rusty@gmail.com wrote:
Probably this is not the problem either. How could this code produce file_get_contents(http://abc.mywebsite.com/?prt=test) on "line 22"?
here is the complete error message: warning: file_get_contents(http://abc.mywebsite.com/?prt=test) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/html/includes/common.inc(1352) : eval()'d code on line 22.
no idea what file line 22 refers to.
I believe I find the related code for file_get_contents()
function contemplate_get_file($node_type, $field) { $files = contemplate_available_files(); if (isset($files['node-'. $node_type .'-'. $field .'.tpl'])) { $file = $files['node-'. $node_type .'-'. $field .'.tpl']; } elseif (isset($files['node-'. $node_type .'.tpl'])) { $file = $files['node-'. $node_type .'.tpl']; } elseif (isset($files['node.tpl'])) { $file = $files['node.tpl']; }
if ($file) { $file->contents = file_get_contents($file->filename); $return = $file; } else { $return = FALSE; } return $return; }
is there a way to replace file_get_contents() to find more in detail?
thanks.
tom