can someone help me out, please

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
As soon as I want to open up my website it tells me this failure:
"Fatal error: Cannot redeclare http_get() in /home/florian/public_html/inc.functions.php on line 138"

Can anyone help me out with this problem?

Already thanks,

Florian
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Your script or one written by somebody else?
 

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
still stuck with the problem.
Really nobody who knows how to fix the problem??
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
Not without seeing the code. The chances are high that a file has been included or required more than once (using include_once() or require_once() instead of include() or require() will fix that problem), but that's just a guess at best.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Sorry for the delay.
The writer of the code did not require or include the file twice. The error message would state where the function was declared before.

http_get is defined in this version/installation of PHP. It is not always defined. Seems like the developer assumed the name was not used.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
In particular, florian, your best bet is to contact the script maintainer. The http_get function defined in the script may need to be renamed, or may need to be defined conditionally; which depends on whether the script's implementation is compatible with the PHP version. The current maintainer will be familiar enough with the design to know which is the best course. Besides, if the problem affects you, it likely affects others, so the issue should be fixed in the source master copy.
 
Last edited:

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
Uh guys,

I have to excuse myself for the late reply, at first.
Second, My stupid head forgot something to say that may make the solution totally different.
In the past I've used an other cms program (online) and that had this templates as one of the standards.
It is originally from templates.com (or something like that) and I have modified this to my personal website by uploading some pictures and some texts.
Maybe this, possibly, could make the solution alot diffrent.

Nevertheless, I have to thank you guys and the total community for all the great help you guys are offering.
Continue like that!
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Without seeing the code, nobody can help you.
 

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
I can show you guys,

Is that the index.php, style.css or something totally diffrent?
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
It should be a minimal sample, one that has just enough code to reproduce the issue but no more. "Complete" and "concise" are the watchwords. Since the error is reported as arising in inc.functions.php, start there. I'm not sure why you mention a CSS file. Unless the CSS is generated by PHP, there's no way it can have anything to do with the error message.
 
Last edited:

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
Here I have the inc.functons.php script, can someone see the problem?:

<?php

function parse_uri() {
global $home_page, $pages, $base_url;

$nh = preg_replace('#^http*://[^/]+/#i', '/', $base_url);
$nh = preg_replace('#/[^/]+/\.\./#i', '/', $nh);
$ru = trim(isset($_SERVER['REQUEST_URI']) ? urldecode($_SERVER['REQUEST_URI']) : '/');
$ru = str_replace($nh, '', $ru);
$ru = preg_split('#[\ \t]*[/]+[\ \t]*#i', $ru, -1, PREG_SPLIT_NO_EMPTY);
$ru = array_map('trim', $ru);

if (!count($ru))
return $home_page;
$ru = implode('/', $ru);
if (isset($pages[$ru]))
return $ru;
if (!$ru)
return $home_page;

foreach ($pages as $id => $pi)
if ($ru == $pi['alias']) return $id;

return $home_page;
}

function is_mail($mail) {
if (preg_match("/^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-\_]+\.[0-9a-zA-Z\.\-\_]+$/is", trim($mail)))
return $mail;
return "";
}

function mini_text($text) {
return trim(substr(strip_tags($text), 0, 100), " \n\r\t\0\x0B.").'...';
}

$Wildfire_header_sent = false;
$Wildfire_msg_idx = false;

function wf_log($msg, $type = 'LOG') {
global $Wildfire_header_sent, $Wildfire_msg_idx;
$types = Array('LOG', 'INFO', 'WARN', 'ERROR');
$type = in_array(strtoupper($type), $types) ? strtoupper($type) : $types[0];
$escape = "\"\0\n\r\t\\";

$trs = debug_backtrace();
$last = Array();
foreach ($trs as $li) {
if (isset($li['class']) && $li['class'] == __CLASS__) { $last = $li; continue; }
$last = $li;
break;
}

$message = '[{"Type":"'.$type.'","File":"'.addcslashes($last['file'], $escape).'",'.
'"Line":'.$last['line'].'},"'.addcslashes($msg, $escape).'"]';
if ($Wildfire_msg_idx === false) $Wildfire_msg_idx = 0;
if (!$Wildfire_header_sent) {
$Wildfire_header_sent = true;
header('X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
header('X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3');
header('X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
}
$count = ceil(strlen($message) / 5000);
for ($i = 0; $i < $count; $i++) {
$Wildfire_msg_idx++;
$part = substr($message, ($i * 5000), 5000);
header('X-Wf-1-1-1-'.$Wildfire_msg_idx.': '.(($i == 0) ? strlen($message) : '').
'|'.$part.'|'.(($i < ($count - 1)) ? '\\' : ''));
}
}

function trace($var, $return = false) {
$code = '';
if (is_array($var) || is_object($var)) {
$code .= '<pre style="margin: 0;">'.print_r($var, true).'</pre>';
} else {
$code .= $var;
}
if (is_bool($var)) $code = '<span style="color: #0000ff; font-weight: bold; font-style: normal; font-family: Courier New; font-size: 12px;">'.($var ? 'TRUE' : 'FALSE').'</span>';
if (is_null($var)) $code = '<span style="color: #0000ff; font-weight: bold; font-style: normal; font-family: Courier New; font-size: 12px;">NULL</span>';

$code = '<div style="padding: 0px; margin: 4px 0; position: relative; float: none; clear: both; border: 1px dashed #e5e09b;">'.
'<a style="display: block; position: absolute; right: 3px; top: 2px; font-weight: bold; text-decoration: none; line-height: 14px; color: #676767; font-family: arial,sans-serif; font-size: 19px;" href="#" onclick="this.parentNode.style.display = \'none\'; return false;" title="Hide">'.
'&times;'.
'</a>'.
'<div id="FormMessages_message" style="padding: 17px 20px; margin: 0; float: none; background: #fffde0; color: #000000; font-family: Arial; font-size: 13px; font-style: italic;">'.$code.'</div>'.
'</div>';
if ($return) return $code; else echo $code;
}

function http_get($url, $post_vars = false) {
$post_contents = '';
if ($post_vars)
{
if (is_array($post_vars))
{
foreach($post_vars as $key => $val)
$post_contents .= ($post_contents ? '&' : '').urlencode($key).'='.urlencode($val);
}
else
$post_contents = $post_vars;
}

$uinf = parse_url($url);
$host = $uinf['host'];
$path = $uinf['path'];
$path .= (isset($uinf['query']) && $uinf['query']) ? ('?'.$uinf['query']) : '';
$headers = Array(
($post_contents ? 'POST' : 'GET')." $path HTTP/1.1",
"Host: $host",
);
if ($post_contents)
{
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Content-Length: '.strlen($post_contents);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

if ($post_contents)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_contents);
}

$data = curl_exec($ch);
if (curl_errno($ch))
return false;
curl_close($ch);

return $data;
}

function post_comment($postId, $name, $message) {
global $user_key, $user_hash, $blog_callback;
if( !function_exists("curl_init") ) return false;
return http_get($blog_callback, Array(
"key" => $user_key,
"hash" => $user_hash,
"id" => intval($postId),
"name" => base64_encode($name),
"message" => base64_encode($message)
));
}

if (!function_exists('file_put_contents')) {
if (!defined('FILE_USE_INCLUDE_PATH'))
define('FILE_USE_INCLUDE_PATH', 1);
if (!defined('FILE_APPEND'))
define('FILE_APPEND', 8);
if (!defined('LOCK_EX'))
define('LOCK_EX', 2);
function file_put_contents($filename, $data, $flags = 0, $context = false) {
if (is_array($data))
$data = implode('', $data);
$res = false;
if ($fh = fopen($filename, ($flags & FILE_APPEND) ? 'a' : 'w',
($flags & FILE_USE_INCLUDE_PATH) ? true : false)) {
$res = fwrite($fh, $data);
fclose($fh);
}
return $res;
}
}

if (!function_exists('json_decode')) {
require_once dirname(__FILE__).'/class.json.php';
global $_json_service;
$_json_service = new Services_JSON();
function json_decode($json, $assoc = false) {
global $_json_service;
$_json_service->use = $assoc ? SERVICES_JSON_LOOSE_TYPE : 0;
return $_json_service->decode($json);
}
function json_encode($data, $assoc = false) {
global $_json_service;
$_json_service->use = $assoc ? SERVICES_JSON_LOOSE_TYPE : 0;
return $_json_service->encode($data);
}
}

?>

I don't have much knowledge about this kind of things, so hopefully somebody knows where to look at.

Thanks in Advance!
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
You can try...

Find

function http_get($url, $post_vars = false) {

Change to

function http_get_new($url, $post_vars = false) {

ie, just add _new

then find and change

function post_comment($postId, $name, $message) {
global $user_key, $user_hash, $blog_callback;
if( !function_exists("curl_init") ) return false;
return http_get($blog_callback, Array(

to

function post_comment($postId, $name, $message) {
global $user_key, $user_hash, $blog_callback;
if( !function_exists("curl_init") ) return false;
return http_get_new($blog_callback, Array(
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
@florianvrs29 - Please remember to wrap code in your posts with [PHP] and [/PHP] - it keeps the forums more tidier :)
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
That's supposed to be a minimal sample, not a dump of the entire file. Read my sig.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
That's supposed to be a minimal sample, not a dump of the entire file. Read my sig.

How is he supposed to know what a "minimal sample" is?
 
Last edited:

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Bumped into this during the early days of coding a Job Vacancy 'scraper' and if I recall the problem is that a script cannot call a second instance of curl_exec during the main scripts execution.

So the cURL functions of content retrieval or posting has to be a seperate script that's looped just getting one url at time, storing any incoming data in a database or flat file that the main script can access as needed.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
How is he supposed to know what a "minimal sample" is?
By reading the link from the first time I mentioned it, which is why I said to read my sig in my previous post.
 

florianvrs29

New Member
Messages
10
Reaction score
0
Points
0
[/COLOR]
You can try...<br>
<br>
Find <br>
<br>
function http_get($url, $post_vars = false) {<br>
<br>
Change to <br>
<br>
function http_get<strong>_new</strong>($url, $post_vars = false) {<br>
<br>
ie, just add _new<br>
<br>
then find and change<br>
<br>
function post_comment($postId, $name, $message) {<br>
global $user_key, $user_hash, $blog_callback;<br>
if( !function_exists("curl_init") ) return false;<br>
return http_get($blog_callback, Array(<br>
<br>
to<br>
<br>
function post_comment($postId, $name, $message) {<br>
global $user_key, $user_hash, $blog_callback;<br>
if( !function_exists("curl_init") ) return false;<br>
return http_get<strong>_new</strong>($blog_callback, Array(
This did the trick!
It is now working!
Thank you for the help guys!
I love this community, but i am still stunned about how you guys know how to fix such a problem in such a strange code.
Wish is could do that too.
Thanks a Million!

Florian

_______________________________________-
well,

now that i'm on my site. When i click on a tab e.g. home or contact,... it automatically redirects to the old cms site i used before.
talking about the website: websitesforeveryone.x10.mx

Regards
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Most CMS have a setting for the URL of the site. Sounds like you have to go to your Admin section and change the option.
 
Top