/** * Getting stuff from remote systems * * @param type $url * @param type $post * @return type */ private function curl($url, $post = '') { $sUserAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 Yulai Federation Website API Fetcher http://yulaifederation.net'; $cUrlChannel = \curl_init(); $data = false; if(!empty($post)) { \curl_setopt($cUrlChannel, \CURLOPT_POST, 1); \curl_setopt($cUrlChannel, \CURLOPT_POSTFIELDS, \http_build_query($post, \PHP_QUERY_RFC3986)); } // END if(!empty($post)) \curl_setopt($cUrlChannel, \CURLOPT_URL, $url); if(\ini_get('open_basedir') === '' && \ini_get('safe_mode' === 'Off')) { \curl_setopt ($cUrlChannel, \CURLOPT_FOLLOWLOCATION, 1); } // END if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) \curl_setopt($cUrlChannel, \CURLOPT_SSL_VERIFYPEER, false); \curl_setopt($cUrlChannel, \CURLOPT_RETURNTRANSFER, 1); \curl_setopt($cUrlChannel, \CURLOPT_USERAGENT, $sUserAgent); if($this->ping($url)) { $data = \curl_exec($cUrlChannel); \curl_close($cUrlChannel); } // END if($this->ping($url)) return $data; } // END private function curl($url, $post = '') /** * Ping a remote server address * * @param string $host * @param number $port * @param number $timeout * @return boolean */ private function ping($host, $port = 80, $timeout = 3) { if(\preg_match('/http|https/', $host)) { $host = \parse_url($host, \PHP_URL_HOST); } // END if(preg_match('/http|https/', $host)) $fsock = \fsockopen($host, $port, $errno, $errstr, $timeout); if(!$fsock) { return false; } else { return true; } // END if(!$fsock) } // END private function ping($host, $port = 80, $timeout = 3)