1 rosab Feb 22, 2010 01:39
3 sam2kb Feb 22, 2010 17:38
Welcome to the forums.
Please post the content of hacks.php here. Remove any personal info from it ;)
4 rosab Feb 23, 2010 00:56
Hi Sam, thanks!
<?php
if( (!empty($_SERVER['HTTP_REFERER'])) && (strpos( $_SERVER['HTTP_REFERER'],$baseurl) !== 0) && (strpos( $ReqURI , '&hack=autoforward' ) == 0) )
{
$pos = strpos( $ReqURI, $baseurl );
// echo "ReqURI = $ReqURI <br />";
$path_string = substr( $ReqURI, $pos );
// echo "path=$path_string <br />";
$path_elements = explode( '/', $path_string, 20 ); // slice it
$i=1;
// echo $path_elements[$i];
if( isset( $path_elements[$i] ) && ($path_elements[$i] == 'index.php') )
{ // Ignore index.html
$i++;
}
// echo "path_element[$i] = $path_elements[$i] <br />";
if( isset( $path_elements[$i] ) )
{
//echo "query = select blog_ID from $tableblogs where blog_stub like '".$path_elements[$i]."'";
$db_blog_id = $DB->get_row("select blog_ID from $tableblogs where blog_stub like '".$path_elements[$i]."'");
if( $db_blog_id )
{ // Ignore stub file
$i++;
}
}
// echo $path_elements[$i];
if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
{ // We'll consider this to be the year
$m = $path_elements[$i++];
// echo "m = $m <br />";
// echo "path_element[$i] = $path_elements[$i] <br />";
if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
{ // We'll consider this to be the month
$m .= $path_elements[$i++];
if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
{ // We'll consider this to be the day
$m .= $path_elements[$i++];
if( isset( $path_elements[$i] ) && (!empty( $path_elements[$i] )) )
{ // We'll consider this to be a ref to a post
// We are accessing a post by permalink
// Set a lot of defaults as if we had received a complex URL:
$m = '';
$more = 1; // Display the extended entries' text
$c = 1; // Display comments
$tb = 1; // Display trackbacks
$pb = 1; // Display pingbacks
if( preg_match( "#^p([0-9]+)$#", $path_elements[$i], $req_post ) )
{ // The last param is of the form p000
// echo 'post number';
$p = $req_post[1]; // Post to display
}
else
{ // Last param is a string, we'll consider this to be a post urltitle
$title = $path_elements[$i];
// echo 'post title : ', $title;
}
}
}
}
elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' )
{ // We consider this a week number
$w = substr( $path_elements[$i], 1, 2 );
}
}
if( (empty($p)) && (empty($title)) && (empty($preview)) )
{
$ref = $_SERVER['HTTP_REFERER'];
if( ($pos_question = strpos( $ref, '?' )) == false )
{
//echo '[', T_('not a query - no params!'), ']';
}
else
{
$ref_params = explode( '&', substr( $ref, $pos_question+1 ) );
foreach( $ref_params as $ref_param )
{
$param_parts = explode( '=', $ref_param );
if( $param_parts[0] == 'q' or $param_parts[0] == 'query' or $param_parts[0] == 'p' or $param_parts[0] == 'kw' or $param_parts[0] == 'qs' )
{ // found "q" query parameter
$q = urldecode($param_parts[1]);
if( strpos( $q, 'Ã' ) !== false )
{ // Probability that the string is UTF-8 encoded is very high, that'll do for now…
//echo "[UTF-8 decoding]";
$q = utf8_decode( $q );
}
$qwords = explode( ' ', $q );
foreach( $qwords as $qw )
{
if( strlen( $qw ) > 30 ) $qw = substr( $qw, 0, 30 )."…"; // word too long, crop it
$kwout .= $qw.'+';
}
$blog = 2;
//log_hit();
echo "<a href=http:". $_SERVER['SERVER_NAME']. "/index.php?s=" . $kwout . "&sentence=AND&submit=Search&blog=1&hack=autoforward >Possible issue with redirection, please click here for article</a>";
Header("Location: http://". $_SERVER['SERVER_NAME']. "/index.php?s=" . $kwout . "&sentence=AND&submit=Search&blog=1&hack=autoforward");
die();
}
}
}
}
}
?>
I´m sorry I can´t remember. It was at the very beginning of the installation some days ago. I just created the hack.php file and copied the code.
Cheers. Rosa
5 sam2kb Feb 23, 2010 05:08
This script was written 5 years ago :)
http://www.plack.net/index.php/2005/08/24/auto_search_in_b2evolution
I don't think you need it at all. You can either delete the file or comment out the code.
6 rosab Feb 23, 2010 18:02
Thanks Sam, I got the problem solved as I said, when I deleted the file.
It´s a little bit messy for begginers to deal with the different versions.
Cheers. Rosa
Hi again, I found the problem.
I had installed a hack.php file which I copied from "somewhere" here, and I don´t even remember what it was supposed to do.
It´s the only file the has this line:
select blog_ID from
This file was also causing the same problem with links in twitter, but I thought it was just me and twitter "affair"... I don´t use it.
I don´t know if I should post the code here.
Well, if somebody is interested...
Bye. Rosa