Recent Topics

1 Sep 03, 2005 18:18    

I'm trying the Auto Search plugin/hack from Plack.net but as I do I get this error:

Parse error: parse error, unexpected '=' in /home/******/public_html/conf/hacks.php on line 3

The code to that Hack is:

<?php
if( (!empty($_SERVER[’HTTP_REFERER’])) && (strpos( $_SERVER[’HTTP_REFERER’],$baseurl) !== 0) && (strpos( $ReqURI , ‘&hack=autoforward’ ) == 0) )
{
// This first part of code is copied from _main_blog.php
// Getting current blog info:
$Blog = Blog_get_by_ID( 2 );

$blog_baseurl = substr( $Blog->get( ‘baseurl’ ), strlen( $baseurlroot ) );
if( ($pos = strpos( $ReqPath, $blog_baseurl )) !== false )
{ // note: $pos will typically be 0
$path_string = substr( $ReqPath, $pos+strlen( $blog_baseurl ) );
$path_elements = explode( ‘/’, $path_string, 20 ); // slice it
$i=0;
if( isset( $path_elements[$i] ) && $path_elements[$i] == ‘index.php’ )
{ // Ignore index.html
$i++;
}

if( isset( $path_elements[$i] ) && preg_match( ‘#^’.$Blog->get( ’stub’ ).’(\.php)?$#’, $path_elements[$i] ) )
{ // Ignore stub file
$i++;
}

if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
{ // We’ll consider this to be the year
$m = $path_elements[$i++];

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
$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];
}
}
}
}
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 );
}
}
}

// Check if they are requesting a single item, if not, bump them to the search
if( (empty($p)) && (empty($title)) && (empty($preview)) )
{
$ref = $_SERVER[’HTTP_REFERER’];

if( ($pos_question = strpos( $ref, ‘?’ )) == false )
{
// Not a query, no params
return;
}
$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…
$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 = 1;
//log_hit();
Header("Location: http://". $_SERVER[’SERVER_NAME’]. “/index.php?s=” . $kwout . “&sentence=AND&submit=Search&blog=1&hack=autoforward");
die();
}
}

}
}
?>

Does anybody know why?

2 Sep 03, 2005 19:21

Isn't it easier to implement that [url=http://blog.lesperlesduchat.com/dev.php/2005/07/31/b2evolution_search_engines_optimization]b2evolution: Search Engines Optimization[/url] (discussed in the [url=http://forums.b2evolution.net/viewtopic.php?t=4459]Search Engines Optimization (SEO)[/url] thread) skin update that makes search engines indexing single posts?

Since I haven't (yet?) implemented the [url=http://www.plack.net/index.php/2005/08/24/auto_search_in_b2evolution]Plack.net Autosearch in b2evolution hack[/url], I can't talk about it...

3 Sep 04, 2005 02:40

kwa, in yor blog you suggest adding the code below to the favourite skin. I suppose you have to add that to the_main.php file and only there, right?:

<meta name="robots" content="<?php if( ( $disp!='posts' && $disp!='single' ) || ( $disp=='posts' && ( $paged>1 || $cat!='' || $m!=0 || ( is_array( $catsel ) && count( $catsel )>0 ) || $w >=0 || $s != '' ) ) ) echo( 'no' ); ?>index,follow"/>

Thanks whoo

4 Sep 05, 2005 00:47

gcasanova wrote:

kwa, in yor blog you suggest adding the code below to the favourite skin. I suppose you have to add that to the_main.php file and only there, right?:

<meta name="robots" content="<?php if( ( $disp!='posts' && $disp!='single' ) || ( $disp=='posts' && ( $paged>1 || $cat!='' || $m!=0 || ( is_array( $catsel ) && count( $catsel )>0 ) || $w >=0 || $s != '' ) ) ) echo( 'no' ); ?>index,follow"/>

You're right. My [url=http://blog.lesperlesduchat.com/dev.php/2005/07/31/b2evolution_search_engines_optimization]explaination[/url] wasn't clear enough. I've just updated it. (The above code asks search engines to index the blog homepage and each single post only, excluding any day, week, month, year and category summaries as well as other stat or profile pages.)

In order to speed up the update of your blog in the main three search engines, use the following links:

5 Sep 05, 2005 05:31

kwa, What would happen if I use your hack and also placks.net, at the same time? Same question for Tony froom plack.net?
Would it be like using two antivirus at the same time, that is very conficting and useless?

6 Sep 05, 2005 10:08

gcasanova wrote:

kwa, What would happen if I use your hack and also placks.net, at the same time? Same question for Tony froom plack.net?
Would it be like using two antivirus at the same time, that is very conficting and useless?

When applying the [url=http://www.plack.net/index.php/2005/08/24/auto_search_in_b2evolution]Plack.net Autosearch in b2evolution hack[/url] hack, you consider something like:

    Hey! a stupid search engine sends people to my blog's year summary page where hundreds of posts appear! The guy who's going to see that page won't read anything and will leave my site. That's a waste of time for him and a waste of bandwith and CPU for my server! Now he's there, why not trying to keep him on my nice blog? Let's be smart and search a post on my blog with the requested keywords.[/list:u]When applying my own [url=http://blog.lesperlesduchat.com/dev.php/2005/07/31/b2evolution_search_engines_optimization]b2evolution: Search Engines Optimization[/url] robots meta hack:
    <meta name="robots" content="<?php if( ( $disp!='posts' && $disp!='single' ) || ( $disp=='posts' && ( $paged>1 || $cat!='' || $m!=0 || ( is_array( $catsel ) && count( $catsel )>0 ) || $w >=0 || $s != '' ) ) ) echo( 'no' ); ?>index,follow"/>
    you consider something like:
      Hey! a stupid search engine sends people to my blog's year summary page where hundreds of posts appear! The guy who's going to see that page won't read anything and will leave my site. That's a waste of time for him and a waste of bandwith and CPU for my server! Before he comes there, why not trying to help search engines to index my blog correctly? Let's be smart and show search engine robots which pages to index. I believe the right pages to index are the blog's homepage and each single post page (permalink).[/list:u]When applying my own [url=http://blog.lesperlesduchat.com/dev.php/2005/07/31/b2evolution_search_engines_optimization]b2evolution: Search Engines Optimization[/url] redirect hack:
      // Avoid useless heavy CPU and bandwith external links
      if( !empty( $m ) && $m != 0 && strlen( $m ) <= 6 )
      {
         // A large selection of posts has been requested and the
         // visitor comes from an external URI or a direct link
      
         // Is it an external URI?
         global $blog, $BlogCache;
         $current_Blog = $BlogCache->get_by_ID( $blog );
         $blogurl = $current_Blog->gen_blogurl();
         $pos = stristr( $_SERVER[ 'HTTP_REFERER' ], $blogurl );
         if( $pos === FALSE || $pos > 9 )
         {
            // A year or month summary have been requested coming
            // from an external site.
      
            // Since this is a heavy page to display and often
            // useless for externally driven visitors, we redirect
            // them to the blog's homepage.
            header( 'Location: ' . $blogurl );
            die();
         }
      }
      you consider something like:
        Hey! a stupid search engine sends people to my blog's year summary page where hundreds of posts appear! The guy who's going to see that page won't read anything and will leave my site. That's a waste of time for him and a waste of bandwith and CPU for my server! Whatever I do to make my blog indexed correctly, some search engines (espacially Google Images and AOL Images) still indexing those huge pages. Let's redirect those people to my blog's homepage.[/list:u] In a perfect world, where search engines index all the web pages in real time, you can consider my robots meta hack being enough and implementing anything else would be a waste of time. However, since search engines take days to months to update (especially Google Images and AOL Images), it is interesting to consider the [url=http://www.plack.net/index.php/2005/08/24/auto_search_in_b2evolution]Plack.net Autosearch in b2evolution hack[/url] as well. My redirect hack becomes then useless. However, when using the [url=http://www.plack.net/index.php/2005/08/24/auto_search_in_b2evolution]Plack.net Autosearch in b2evolution hack[/url], consider there might be no post in your whole blog including all of the originally requested keywords... Finally, after implementing my robots meta hack, you can consider using Google or Yahoo as your blog default search engine with pertinent results. (Google needs a couple of days to index a new post after [url=http://www.google.com/addurl/?continue=/addurl]submission[/url]. I don't know indexing performance using [url=http://forums.b2evolution.net/viewtopic.php?t=4466]Google Sitemaps[/url].)

7 Sep 05, 2005 17:41

Best explanation in the whole forum! Thank You


Form is loading...

Photo gallery software – This forum is powered by b2evolution CMS, a complete engine for your website.