php - CURL work on localhost not on server -


i totaly new curl thing . have problem .

i have below script supposed remote files using proxy , trying code on local host machine , working great "done part: .

when run server , keep going "invalid proxy" although same proxy used in local host ..

<?php $dots = ''; include($dots.'classes/config.php'); $wordslimitpercall = 1; $maxattemptstrials = 3; $timeout = 10; // seconds   $proxy = sqlselectrow('proxy', array(     'condition'=>'not_valid=0',     'order'=>'rand()' )); echo '<ul>'; if($proxy)     echo '<li>using proxy: '.$proxy['proxy'].':'.$proxy['port'].'</li>'; $wordsres = sqlselectrows('words', array(     'condition'=>'is_done=0 , trials<'.$maxattemptstrials,     'limit'=>$wordslimitpercall,     'order'=>'created asc' )); while($arr = $wordsres->fetch_assoc()) {      $word = urlencode($arr['word']);      $url = 'http://example.com'.$word;     $callsettings  = array(         'method'=>'curl',          'timeout'=>$timeout     );     if($proxy)         $callsettings['proxy'] = $proxy['proxy'].':'.$proxy['port'];     $result = callremoteurl($url, $callsettings);     $filename = urldecode($word);      $filename = 'file/'.$arr['id'].' - '.$filename.'.mp3';     echo '<li>getting word: '.$word.'</li>';     if($result && strpos($result, '<html')===false) {         if(file_exists($dots.$filename))             unlink($dots.$filename);         filewrite($filename, $result);         $is_done = 1;         echo '<li>done successfully</li>';     }     else {         $is_done = 0;         if($proxy) {             sqlupdate('proxy', array(                 'not_valid'=>0             ), array(                 'condition'=>'id='.$proxy['id']             ));             echo '<li>proxy not valid</li>';          }     }     sqlupdate('words', array(         'trials'=>$arr['trials']+1,         'path'=>$url,         'last_call_date'=>date('y-m-d h:i:s'),         'is_done'=>$is_done     ), array(         'condition'=>'id='.$arr['id']     ));  } echo '</ul>'; ?> 

below function called utils

<? php                    if($set['method']=='curl' && extension_loaded('curl'))                         {                             $ch = curl_init();                             curl_setopt($ch, curlopt_url, $url);                             curl_setopt($ch, curlopt_header, 0);                             curl_setopt($ch, curlopt_followlocation, true);                             curl_setopt($ch, curlopt_ssl_verifypeer, false);                             curl_setopt($ch, curlopt_connecttimeout ,0);                              curl_setopt($ch, curlopt_timeout, $set['timeout']); // seconds                             if($set['proxy'])                                 curl_setopt($ch, curlopt_proxy, $set['proxy']);                             ob_start();                             if(curl_exec($ch) === false)                             {                                 $errorno = curl_errno($ch);                                 if($errorno==28)                                     print_r('the connection took time more '. $set['timeout'].' seconds, disconnected process');                                 else                                 if($errorno!=7)                                     print_r(curl_error($ch));                                 $result=false;                             }                             else                             {                                 $result = ob_get_contents();                             }                             ob_end_clean();                             return $result;                         }         ?> 

sorry if long ... i've spent last couple days tryng find out . idea or shall ?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -