Jump to content
Sign in to follow this  
funkyneil

Google position contribution

Recommended Posts

This contribution causes very specific results to be returned. If you look for thisdomain.com and the Google results are www.thisdomain.com, you will get an answer that it's not in the top 'X' results even if it appears as #1 when you do the search on Google

Perhaps a better way would be to use parse_url or even preg_match ?

 

php.net example:

 

<?php
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i",
  "http://www.php.net/index.html", $matches);
$host = $matches[2];

// get last two segments of host name
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
echo "domain name is: {$matches[0]}\n";
?>


There are people who, instead of listening to what is being said to them, are already listening to what they are going to say themselves. - Albert Guinon

Share this post


Link to post
Share on other sites

Pretty cool contribution. Works fine except for the problem in step 7 that others have already pointed out.

 

Couple things to improve it:

 

1) If your site doesn't show up in the top xx sites, add something at the end that says "Your site is 1,298,000th in the Google listing". That way you know WERE it is at least.

 

2) Maybe a "Tips" link to give clues about how to increase your ranking. Although you can find that elsewhere easy enough.

 

Thanks for the contrib!

Share this post


Link to post
Share on other sites

Stuart -

I've been accused before of making a good point null
LOL. What a difference a period makes. :)

 

Calvin- There is a setting in the php.ini file that will prevent calls like this from happening. You probably do not have access to this file so you will need to contact your host. Ask them if they have this option set as shown in the php.ini file.

allow_url_fopen = On

Draven - I'm not very experineced with preg_match but I think that statement will return the domain name without the www part. Some people have sites registered as www.mysite.com and others just use mysite.com. So I don't think that would work although I could be totally wrong. It would be a simple matter to search for each url but that would be presuming what the user wants.

 

Chris - Thanks for the suggestions. In order to do the first one, all searches would have to be done with a maximum setting. Most hosts, AFAIK, have a timeout value that will cause the script to fail if it takes too long. The time can be changed but sometimes a site is not listed. In that event, the script would time out and make it appear as an error. This might be confusing to the user.

 

I like the tips suggestion and will try to implement it at some point.

 

Jack

Share this post


Link to post
Share on other sites

Hello again, still can't seem to resolve this. I installed and re-installed everything and still the following code is enacted. As it seems to be just me, perhaps it is some other configuration. Any help is appreciated.

 

// Open the search page.

// We are filling in certain variables -

// $query,$hits_per_page and $start.

 

$filename = "http://www.google.com/search?as_q=$query".

"&num={$hits_per_page}&hl=en&ie=UTF-8&btnG=Google+Search".

"&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=".

"&as_qdr=all&as_nlo=&as_nhi=&as_occt=any&as_dt=i".

"&as_sitesearch=&safe=images&start=$i";

 

$file = fopen($filename, "r");

if (!$file)

{

echo "<p>Unable to open remote file $filename.\n";

}

else

{

Share this post


Link to post
Share on other sites

Did you check the php.ini setting I mentioned in my last reply. I made a mistake on who I replied to but it could be causing your problem too.

 

Jack

Share this post


Link to post
Share on other sites
Did you check the php.ini setting I mentioned in my last reply. I made a mistake on who I replied to but it could be causing your problem too.

 

Jack

php.ini is set as follows:

 

;;;;;;;;;;;;;;;;;;

; Fopen wrappers ;

;;;;;;;;;;;;;;;;;;

 

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.

allow_url_fopen = On

 

 

The problem persists :(

 

Any other possibilties?

 

Thanks

Share this post


Link to post
Share on other sites

I can't think of why of any reasons why it is not working. Just for the heck of it, try this: In admin/google_position.php, find the line that says

$file = fopen($filename, "r");

and place

$filename = "http://www.google.com";

right tbefore it.

 

The should isolate whether it is a code problem or a server problem. With the above change, the code should run without getting the "failed to open" message. Of course, it will say that your site cannot be found but that's OK for this test.

 

Jack

Share this post


Link to post
Share on other sites

Hi Jack,

 

there is a problem with google-results that begins with

https

 

My Site is stored in google(google.de) as "https://metall-polish.de/"

and with the right searchwords (edelstahl +klingelplatte +shop +design)

at Position 2

 

The result from google_position.php says:

The site metall-polish.de is not in the top 100 for the term edelstahl +klingelplatte +shop +design

 

and the results are:

1 www.stores.ebay.de

2 https:

3 www.exop.de

4 www.exop.de

5 stores.ebay.de

....

 

My Shop is on Position 2, but not shown because:

// Get the domain name by looking for the first /
 
    	 $x = strpos($out[1],"/");

 

Am i the only one who have this problem, the only one with an Shop on https:// ???

 

Can you help to correct the problem?

 

Patrick

 

PS: Sorry for my not so good english


Captain: I thought you were going to upgrade this.

Trip: That is the upgrade.

Well, if you want, I can change the color.

Share this post


Link to post
Share on other sites

Now i have changed:

 

// Get the domain name by looking for the first /
 
     $x = strpos($out[1],"/");

 

with:

 

// Get the domain name by looking for the first  -
 
     $x = strpos($out[1]," -");

 

because all results of google end with " -"

 

Now the results look like:

1 stores.ebay.de/elwic-edelstahl-design

2 www.exop.de/ps_index6.php

3 www.exop.de/ps_index3.php

4 https://metall-polish.de/ catalog/product_info.php?products_id=101

5 www.yatego.com/online-shop/pce_3_10-10-30_porsche.htm

6 www.yatego.com/online-shop/ pce_3_22-20-06_tor-und-t?r.htm

.....

 

and the result from google_position.php is:

The site metall-polish.de is not in the top 10 for the term edelstahl +shop +klingelplatte +design

 

but i think i am just a step far away

 

anyone an Idea ?

 

Patrick

 

PS: Sorry for my not so good english


Captain: I thought you were going to upgrade this.

Trip: That is the upgrade.

Well, if you want, I can change the color.

Share this post


Link to post
Share on other sites

now it works with https Urls

 

i have changed this:

 

// Get the domain name by looking for the first /
 
     $x = strpos($out[1]," -");
                         

 
 // and get the URL
 
                $url1 = substr($out[1],0,$x);
                              $url2 = strrev($url1);
                              $urlx = strpos($url2,":");
 
                           if ($urlx < 1) 
                          {
                           $url4 = $url1;
                          }
                           else 
                          {
                           $y = strpos($url2,":");
                           $y = $y-2;
                           $url3 = substr($url2,0,$y);
                           $url4 = strrev($url3);
                          }
                              
                              
      $z = strpos($url4,"/");
      $url = substr($url4,0,$z);

 

Sorry for the terrible Code but i dont know very much about php, i have used selfPHP to get this result.

 

If anyone could change the code to get better results then should he/she do it.

 

Patrick

 

PS: Sorry for my not so good english


Captain: I thought you were going to upgrade this.

Trip: That is the upgrade.

Well, if you want, I can change the color.

Share this post


Link to post
Share on other sites

Patrick - give this a try. After the line

   $x = strpos($out[1],"/");

add this:

 if (strstr($out[1], "https"))
{
     $x += 2;
     $x = strpos($out[1],"/", $x);
}

And then replace the line

<td class="main"><?php echo $j. ' ' .'<a   href="' . $siteresults[$i] . '" target="_blank">' . $siteresults[$i] . '</a>'; ?></td>

with

<?php if (substr($siteresults[$i], 'https')) { ?> 
        <td class="main"><?php echo $j. ' ' .'<a   href="' . $siteresults[$i] . '" target="_blank">' . $siteresults[$i] . '</a>'; ?></td>
       <?php } else { ?>
     <td class="main"><?php echo $j. ' ' .'<a   href="' .'http://' . $siteresults[$i] . '" target="_blank">' . $siteresults[$i] . '</a>'; ?></td>
       <?php } ?>

I just did a quick test and it seems to works. I'll look into more later. Please let me know if it works for you.

 

Jack

Share this post


Link to post
Share on other sites
I can't think of why of any reasons why it is not working. Just for the heck of it, try this: In admin/google_position.php, find the line that says
$file = fopen($filename, "r");

and place

$filename = "http://www.google.com";

right tbefore it.

 

The should isolate whether it is a code problem or a server problem. With the above change, the code should run without getting the "failed to open" message. Of course, it will say that your site cannot be found but that's OK for this test.

 

Jack

Unable to open remote file http://www.google.com.

 

Does this mean that it is a code problem or server problem?

 

Thanks

Share this post


Link to post
Share on other sites

I would say it is a server problem. The url is certainly valid yet it cannot be accessed. I suppose there might be some other reason for this to happen but I haven't a clue as to what it would be. Have you contacted your host and asked them if there is any reason why the fopen call would not work? That might be the next thing to do.

 

Can you do a backup using admin->tools->Database Backups? It uses fopen to open a local file so isn't exactly the same but if you can't do that then you definitely have a server problem. Do you have the Links Manager contribution installed? It opens URL's and if it works, then this contribution has a problem. Can't think of anyting else ATM. Maybe someone else has some thoughts on the problem.

 

Jack

Share this post


Link to post
Share on other sites
Patrick - give this a try.

...

Jack

Sorry, but it dont work:

 

The site metall-polish.de is not in the top 10 for the term edelstahl +klingelplatte +shop +design

 

 

Enter total searches: 10

Enter search term: edelstahl +klingelplatte +shop +design

Enter URL to search for: metall-polish.de

 

Show results:     

1 www.stores.ebay.de

2 https://metall-polish.de

3 www.exop.de

4 www.exop.de

5 stores.ebay.de

6 www.milando.de

7 www.yatego.com

8 www.yatego.com

9 www.vcell-wohnaccessoires-shop.de

10 www.online-beschlaege.de

 

What have i done wrong?

I have used your original-code with your changes above, but it dont work.

The result seems the same as the original-code.

 

Patrick


Captain: I thought you were going to upgrade this.

Trip: That is the upgrade.

Well, if you want, I can change the color.

Share this post


Link to post
Share on other sites

I think you have to enter the full url since it uses https. I tried it and here is what I got:

The site https://metall-polish.de is at position 2 ( 2 ) for the term +edelstahl +klingelplatte +shop +design

 

Enter total searches: 3

 

Enter search term: +edelstahl +klingelplatte +shop +design

 

Enter URL to search for: https://metall-polish.de

 

Show results:     

1 www.stores.ebay.de

2 https://metall-polish.de

 

Jack

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Guys

 

Just installed this contribution and shows this error

 

1146 - Table 'db107496661.TABLE_SEO_GOOGLE' doesn't exist

 

select search_url, search_term, rank, sites_searched, date from TABLE_SEO_GOOGLE

 

[TEP STOP]

 

Any ideas please as the table does exist in phpmyadmin

 

regards

 

mark


Regards

 

Mark A Reynolds

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×