PHP Applications
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Applications

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 20th, 2007, 10:03 PM
trenty trenty is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 2 trenty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 40 sec
Reputation Power: 0
Exclamation Help RETRIEVING results from alltheweb!!please

Hi ...
This is my first post in this forum & and am hoping that you can help me with this code:

this is a class witch request ( grabbing audio search results from Alltheweb.com ) this is the code


PHP Code:
<?
class AudioSearch
{
  var 
$m_url 'search?cat=mp3&cs=utf8&q={keyword}&rys=0&itag=crv&_sb_lang=any';
  var 
$m_host "www.alltheweb.com";
  
//var $m_url = '/demo/allweb/?search={keyword}&type=audio';
  //var $m_host = "www.script66.com";
  
var $m_settings;
  var 
$m_total_found_string;
  var 
$m_total_found_int;
  var 
$m_keywords;
  var 
$m_pager;
  var 
$m_is_no_resuls 0;

  function 
AudioSearch($settings,$keywords)
  {
    
$this->m_settings $settings;
    
$this->m_keywords $keywords;
  }
  function 
file_get_contents($url)
  {
    if (
check_if_bad_request($this->m_keywords))
    {
      return 
'';
    }
    
$out "GET /$url HTTP/1.1\r\n";
    
$out .= "Host: {$this->m_host}\r\n";
    
$out .= "User-Agent: Mozilla 4.0\r\n";
    
$out .= "Connection: close\r\n\r\n";
    
    
$h fsockopen($this->m_host,80);
    
fwrite($h,$out);
    for(
$a 0,$r '';!$a;)
    {
       
$b fread($h,8192);
       
$r .= $b;
       
$a = (($b=='') ? 0);
    }
    
fclose($h);
    return 
$r;
  }
  function 
get_url()
  {
    if (
_DEBUG == 1)
      return 
'www/audio.htm';
    else
    {
      
$this->m_url str_replace('{keyword}',$this->m_keywords,$this->m_url);
      
$curr_page = isset($_GET['pos']) ? $_GET['pos'] : 1;
      if (
$curr_page != 1)
      {
         
$curr_page $curr_page 10 10;
         
$this->m_url .= "&o=$curr_page";
       }
      return 
$this->m_url;
    }
  }
  function 
get_total_found_string($content)
  {
    if (
$this->m_is_no_resuls == 1)
      return 
"";
    
preg_match('|(<span class="noFound">.*<span class="ofSoMany">(.*)</span>)|Ui',$content,$ret);
    
$this->m_total_found_int = (int)str_replace(',','',$ret[2]);
    
$string str_replace(' of ',' من ',$ret[1]);
    return 
$string;
  }

  function 
get_results()
  {
    
$url $this->get_url();
    
$content $this->file_get_contents($url);
    
$content str_replace("\r\n"," ",$content);
    
$content str_replace("\n"," ",$content);
    
$content str_replace("<td class=\"colLabel\">Title</td>",'<td class="colLabel"> الموضوع </td>',$content);
    
$content str_replace("<td align=\"center\" class=\"colLabel\">Size</td>",'<td class="colLabel"> الحجم </td>',$content);
    
$content str_replace("<td align=\"center\" class=\"colLabel\">Date</td>",'<td class="colLabel"> التاريخ </td>',$content);
    
//Get total found string
    
$this->m_total_found_string $this->get_total_found_string($content);
    
//Init pager
    
$this->m_pager = new Pager($this->m_total_found_int,10,'audio',$this->m_keywords);

    
$ret_data '
    <div style="padding-left:20px;padding-top:20px;">
    '
;
    
//Get
   
if (preg_match_all('|<DIV class="resultWell">.*<table.*>(.*)</div>|Ui',$content,$ret))
    {
      if (!
preg_match_all('/<a.*href=".*\/\*\*(.*)".*>.*<\/a>/Ui',$ret[1][0],$links))
      {
        
preg_match_all('/<a.*href="(.*)".*>.*<\/a>/Ui',$ret[1][0],$links);
      }
      
$res $ret[1][0];

      foreach(
$links[0] as $index=>$data)
      {
     
$url urldecode($links[1][$index]);
     
//$url = $links[1][$index];
         
$res str_replace($data,"<a href=\"{$url}\" style=\"font-size:12px;\" target=\"_new\"><img src=\"images/audio2.gif\" alt=\"Go to this file\" border=\"0\" /></a>",$res);
       }
      
$ret_data .=  '<table width="100%" class="mp3" cellpadding="10">'.$res;
    }
    else
     {
        
$this->m_is_no_resuls 1;
        return 
$this->m_settings->get_noresults_string();
     }
    
$pager $this->m_pager->get_pager();
    
$ret_data .= '
    </div>
    <div style="padding-left:20px;padding-top:10px;">
    <DIV class=rnav>
        <p align="center"><SPAN class=rnavLabel>الصفحات :&nbsp;'
.$pager.'</span></div>
    </div>
    '
;
    return 
$ret_data;
  }
}
?>


How can I shift between the Two variables randomly?

between
Code:
  var $m_url = 'search?cat=mp3&cs=utf8&q={keyword}&rys=0&itag=crv&_sb_lang=any';
  var $m_host = "www.alltheweb.com";


and this
Code:
 var $m_url = '/demo/allweb/?search={keyword}&type=audio';
 var $m_host = "www.script66.com";


please if you can Reply ASAP

REgards

thanks In ADvance

Reply With Quote
  #2  
Old January 1st, 2008, 06:24 PM
trippleweb's Avatar
trippleweb trippleweb is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Victoria, BC, Canada
Posts: 702 trippleweb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 25 m 54 sec
Reputation Power: 2
php Code:
Original - php Code
  1. $url_array[0] = 'search?cat=mp3&cs=utf8&q={keyword}&rys=0&itag=crv&_sb_lang=any';
  2. $host_array[0] = "www.alltheweb.com";
  3. $url_arry[1] = '/demo/allweb/?search={keyword}&type=audio';
  4. $host_array[1] = "www.script66.com";
  5. $random=rand(0, 1);
  6. $m_url = $url_array[$random];
  7. $m_host=$host_array[$random];
__________________
Conan, what is best in life?

Conan: To crush your enemies,
see them driven before you, and to hear the lamentation of the women!

Reply With Quote
  #3  
Old January 2nd, 2008, 03:35 AM
trenty trenty is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 2 trenty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 40 sec
Reputation Power: 0
Thank you for your reply

but Igot this Error

Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in C:\AppServ\www\includes\classes\audio_search_class .php on line 4



please help

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Applications > Help RETRIEVING results from alltheweb!!please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway