Published by shopzz on July 21, 2007
under PHP
Solution:
- function GetData($url, $proxy='', $vars=''){
- $ch=curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
-
- if($vars!=''){
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
- }
-
- if($proxy!='')
- curl_setopt($ch, CURLOPT_PROXY, $proxy);
-
- $str=curl_exec($ch);
- curl_close($ch);
-
- return $str;
- }
How to use this:
- $url='http://site.com/some-url.php';
- $proxy='255.255.255.255:80';
-
- // post variables
- $vars='var1=1&var2=text';
-
- $txt=GetData($url, $proxy, $vars);
- echo $txt;
Tags: PHP,
curl,
php,
proxy
Published by shopzz on July 21, 2007
under SEO, PHP
Sometimes we need to detect mistypes 
We can use google-search to make sure if given word is a mistype, here my solution:
- if($_GET['key']!=''){
- $key=$_GET['key'];
- $s=GetData('http://www.google.com/search?q='.urlencode($key));
- if(strstr($s, '&spell=1 class=p><b><i>')){
- $s=substr($s, strpos($s, '&spell=1 class=p><b><i>')+strlen('&spell=1 class=p><b><i>'));
- $s=substr($s, 0, strpos($s, '</a>'));
- $key=strip_tags($s);
- }
-
- echo $key;
- }
-
- function GetData($url){
- $ch=curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 15);
- $out=curl_exec($ch);
- curl_close($ch);
-
- return $out;
- }
Using:
http://site.com/detypo.php?key=wordl
Tags: SEO,
PHP,
detypo,
mistype,
php
Published by shopzz on July 20, 2007
under SEO, PHP
Sometimes you need to show another text to crawlers 
This script check serfer User-Agent and if this UA is listed in variable $bot_lst - so, it’s bot…
- // List of bots:
- $bot_lst=array(
- 'google',
- 'msn',
- 'yahoo'
- );
-
- $is_bot=0;
- for($i=0; $i<sizeof($bot_lst); $i++)
- if(strstr(strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']), strtolower($bot_lst[$i])))
- $is_bot=1;
-
- if($is_bot) echo 'Hello bot :)';
- else echo 'Hi user :]';
-
- echo '<p>Your UserAgent: '.$HTTP_SERVER_VARS['HTTP_USER_AGENT'].'</p>';
Tags: SEO,
PHP,
cloaking,
php,
scripts,
search engines,
server
Published by shopzz on June 26, 2007
under PHP
Hey, I found a pretty-nice curl ftp wrapper
Read more »
Tags: PHP,
curl,
ftp,
php,
wrappers