CURLOPT_PROXY = $proxy; $this->CURLOPT_REFERER = $referer; if ( !empty( $cookiejar ) ) $this->CURLOPT_COOKIEJAR = getcwd() . '/' . basename( $cookiejar ); if ( !empty( $cookiefile ) ) $this->CURLOPT_COOKIEFILE = getcwd() . '/' . basename( $cookiefile ); if ( !empty( $decode_charset ) ) $this->DECODE_CHARSET = $decode_charset; } /** * function Get - Возвращает ресурс методом GET * * @param in string $url - урл ресурса которого надо скачать. * @param in string $referer - реферер * @return string - Возвращает результат то есть содержимое ресурса. */ function Get( $url, $referer = '' ) { if ( empty( $url ) || !preg_match( '`(?:https?://)?([^/]+)/?`si', $url, $p ) ) { $this->error = 'URL is empty'; return ''; } //Если кэш врублен $cache_file_name = md5( $url ); if ( $this->USE_CACHE ) if ( file_exists( $this->CACHE_DIR . '/' . $cache_file_name ) && filesize( $this->CACHE_DIR . '/' . $cache_file_name ) ) if ( $this->DECODE_CHARSET == 'utf-8' ) return $this->u2w( file_get_contents( $this->CACHE_DIR . '/' . $cache_file_name ) ); else return file_get_contents( $this->CACHE_DIR . '/' . $cache_file_name ); $this->HEADERS['Host'] = $p[1]; if ( !empty( $referer ) ) $this->CURLOPT_REFERER = $referer; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_FAILONERROR, $this->CURLOPT_FAILONERROR ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, $this->CURLOPT_FOLLOWLOCATION ); curl_setopt( $ch, CURLOPT_TIMEOUT, $this->CURLOPT_TIMEOUT ); curl_setopt( $ch, CURLOPT_REFERER, $this->CURLOPT_REFERER ); curl_setopt( $ch, CURLOPT_USERAGENT, $this->CURLOPT_USERAGENT ); curl_setopt( $ch, CURLOPT_HEADER, $this->CURLOPT_HEADER ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, $this->CURLOPT_SSL_VERIFYPEER ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, $this->CURLOPT_SSL_VERIFYHOST ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $this->HEADERS ); curl_setopt( $ch, CURLINFO_HEADER_OUT, $this->CURLINFO_HEADER_OUT ); if ( !empty( $this->CURLOPT_USERPWD ) ) { curl_setopt( $ch, CURLOPT_USERPWD, $this->CURLOPT_USERPWD ); curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); } if ( !empty( $this->CURLOPT_COOKIEJAR ) ) curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->CURLOPT_COOKIEJAR ); if ( !empty( $this->CURLOPT_COOKIEFILE ) ) curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->CURLOPT_COOKIEFILE ); if ( $this->CURLOPT_PROXY ) curl_setopt( $ch, CURLOPT_PROXY, $this->CURLOPT_PROXY ); if ( $this->CURLOPT_RETURNTRANSFER ) curl_setopt( $ch, CURLOPT_RETURNTRANSFER, $this->CURLOPT_RETURNTRANSFER ); $res = NULL; if ( $this->CURLOPT_RETURNTRANSFER ) $res = curl_exec( $ch ); else curl_exec( $ch ); $this->error = curl_error( $ch ); $this->info = curl_getinfo( $ch ); if ( ( $res != NULL ) && !empty( $res ) && $this->SAVE_CACHE ) { if ( !is_dir( $this->CACHE_DIR ) ) @mkdir( $this->CACHE_DIR, 0777 ); if ( $res ) { $fid = fopen( $this->CACHE_DIR . '/' . $cache_file_name, 'w' ); fwrite( $fid, $res ); fclose( $fid ); } } if ( $this->DECODE_CHARSET == 'utf-8' ) return $this->u2w( $res ); else return $res; } /** * function Post - Отправка данных на сервер методом Post. * * @param in string $url - урл ресурса которого надо скачать. * @param in array $data - данные которые надо передать методом Post * @param in string $referer - реферер * @return string - Возвращает результат то есть содержимое ресурса. */ function Post( $url, $data, $referer = '' ) { if ( empty( $url ) || !preg_match( '`(?:https?://)?([^/]+)/?`si', $url, $p ) ) { $this->error = 'URL is empty'; return ''; } //Если кэш врублен $cache_file_name = md5( $url . serialize( $data ) ); if ( $this->ALLOW_POST_CACHE && $this->USE_CACHE ) if ( file_exists( $this->CACHE_DIR . '/' . $cache_file_name ) && filesize( $this->CACHE_DIR . '/' . $cache_file_name ) ) if ( $this->DECODE_CHARSET == 'utf-8' ) return $this->u2w( file_get_contents( $this->CACHE_DIR . '/' . $cache_file_name ) ); else return file_get_contents( $this->CACHE_DIR . '/' . $cache_file_name ); $this->HEADERS['Host'] = $p[1]; if ( !empty( $referer ) ) $this->CURLOPT_REFERER = $referer; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_FAILONERROR, $this->CURLOPT_FAILONERROR ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, $this->CURLOPT_FOLLOWLOCATION ); curl_setopt( $ch, CURLOPT_TIMEOUT, $this->CURLOPT_TIMEOUT ); curl_setopt( $ch, CURLOPT_REFERER, $this->CURLOPT_REFERER ); curl_setopt( $ch, CURLOPT_USERAGENT, $this->CURLOPT_USERAGENT ); curl_setopt( $ch, CURLOPT_HEADER, $this->CURLOPT_HEADER ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, $this->CURLOPT_SSL_VERIFYPEER ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, $this->CURLOPT_SSL_VERIFYHOST ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $this->HEADERS ); curl_setopt( $ch, CURLINFO_HEADER_OUT, $this->CURLINFO_HEADER_OUT ); if ( is_string( $data ) ) curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ); else curl_setopt( $ch, CURLOPT_POSTFIELDS, substr( $this->PostDataEncode( $data ), 0, -1 ) ); curl_setopt( $ch, CURLOPT_POST, 1 ); if ( !empty( $this->CURLOPT_USERPWD ) ) { curl_setopt( $ch, CURLOPT_USERPWD, $this->CURLOPT_USERPWD ); curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); } if ( !empty( $this->CURLOPT_COOKIEJAR ) ) curl_setopt( $ch, CURLOPT_COOKIEJAR, $this->CURLOPT_COOKIEJAR ); if ( !empty( $this->CURLOPT_COOKIEFILE ) ) curl_setopt( $ch, CURLOPT_COOKIEFILE, $this->CURLOPT_COOKIEFILE ); if ( $this->CURLOPT_PROXY ) curl_setopt( $ch, CURLOPT_PROXY, $this->CURLOPT_PROXY ); if ( $this->CURLOPT_RETURNTRANSFER ) curl_setopt( $ch, CURLOPT_RETURNTRANSFER, $this->CURLOPT_RETURNTRANSFER ); $res = NULL; if ( $this->CURLOPT_RETURNTRANSFER ) $res = curl_exec( $ch ); else curl_exec( $ch ); $this->error = curl_error( $ch ); $this->info = curl_getinfo( $ch ); if ( ( $res != NULL ) && !empty( $res ) && $this->SAVE_CACHE && $this->ALLOW_POST_CACHE ) { if ( !is_dir( $this->CACHE_DIR ) ) @mkdir( $this->CACHE_DIR, 0777 ); if ( $res ) { $fid = fopen( $this->CACHE_DIR . '/' . $cache_file_name, 'w' ); fwrite( $fid, $res ); fclose( $fid ); } } if ( $this->DECODE_CHARSET == 'utf-8' ) return $this->u2w( $res ); else return $res; } /** * function HostIsLive - проверка на факт сушествования хоста. * * @param in string $url - урл ресурса которого проверить * @return string - Возвращает true если хост живой иначе false */ function HostIsLive( $url ) { if ( empty( $url ) || !preg_match( '`(?:https?://)?([^/]+)/?`si', $url, $p ) ) { $this->error = 'URL is empty'; return ''; } $headers['Host'] = $p[1]; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_FAILONERROR, 1); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt( $ch, CURLOPT_TIMEOUT, $this->CURLOPT_TIMEOUT ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_NOBODY, 1 ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers ); $res = NULL; curl_exec( $ch ); $error = curl_error( $ch ); $info = curl_getinfo( $ch ); return !preg_match( '`^(Could not resolve host|Resolving host timed out|couldn\'t connect to host|Empty reply from server).*`i', $error ); } /** * function PostDataEncode - Кодирует данные перед отправкой пост данных. * * @param in array $data - параметры передаваемые через пост * @return string - Возвразщяет url кодированную строку параметра $data */ function PostDataEncode( $data, $keyprefix = '', $keypostfix = '' ) { assert( is_array( $data ) ); $vars = null; foreach ( $data as $key => $value ) { if( is_array( $value ) ) $vars .= $this->PostDataEncode( $value, $keyprefix . $key . $keypostfix . urlencode( '[' ), urlencode( ']' ) ); else $vars .= $keyprefix . $key . $keypostfix . '=' . urlencode( $value ) . '&'; } return $vars; } /** * function u2w - Перекодирует данные поступившые как utf8 в windows-1251 * * @param in string $str - параметр для перекодировки * @return string - Возвразщяет перекодированную строку параметра $str в кодировке windows-1251 */ function u2w( $str, $to = "w" ) { $outstr = ''; $recode = array(); $recode['k'] = array( 0x2500,0x2502,0x250c,0x2510,0x2514,0x2518,0x251c,0x2524, 0x252c,0x2534,0x253c,0x2580,0x2584,0x2588,0x258c,0x2590, 0x2591,0x2592,0x2593,0x2320,0x25a0,0x2219,0x221a,0x2248, 0x2264,0x2265,0x00a0,0x2321,0x00b0,0x00b2,0x00b7,0x00f7, 0x2550,0x2551,0x2552,0x0451,0x2553,0x2554,0x2555,0x2556, 0x2557,0x2558,0x2559,0x255a,0x255b,0x255c,0x255d,0x255e, 0x255f,0x2560,0x2561,0x0401,0x2562,0x2563,0x2564,0x2565, 0x2566,0x2567,0x2568,0x2569,0x256a,0x256b,0x256c,0x00a9, 0x044e,0x0430,0x0431,0x0446,0x0434,0x0435,0x0444,0x0433, 0x0445,0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e, 0x043f,0x044f,0x0440,0x0441,0x0442,0x0443,0x0436,0x0432, 0x044c,0x044b,0x0437,0x0448,0x044d,0x0449,0x0447,0x044a, 0x042e,0x0410,0x0411,0x0426,0x0414,0x0415,0x0424,0x0413, 0x0425,0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e, 0x041f,0x042f,0x0420,0x0421,0x0422,0x0423,0x0416,0x0412, 0x042c,0x042b,0x0417,0x0428,0x042d,0x0429,0x0427,0x042a ); $recode['w'] = array( 0x0402,0x0403,0x201A,0x0453,0x201E,0x2026,0x2020,0x2021, 0x20AC,0x2030,0x0409,0x2039,0x040A,0x040C,0x040B,0x040F, 0x0452,0x2018,0x2019,0x201C,0x201D,0x2022,0x2013,0x2014, 0x0000,0x2122,0x0459,0x203A,0x045A,0x045C,0x045B,0x045F, 0x00A0,0x040E,0x045E,0x0408,0x00A4,0x0490,0x00A6,0x00A7, 0x0401,0x00A9,0x0404,0x00AB,0x00AC,0x00AD,0x00AE,0x0407, 0x00B0,0x00B1,0x0406,0x0456,0x0491,0x00B5,0x00B6,0x00B7, 0x0451,0x2116,0x0454,0x00BB,0x0458,0x0405,0x0455,0x0457, 0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417, 0x0418,0x0419,0x041A,0x041B,0x041C,0x041D,0x041E,0x041F, 0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427, 0x0428,0x0429,0x042A,0x042B,0x042C,0x042D,0x042E,0x042F, 0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437, 0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,0x043E,0x043F, 0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,0x044E,0x044F ); $recode['i'] = array( 0x0080,0x0081,0x0082,0x0083,0x0084,0x0085,0x0086,0x0087, 0x0088,0x0089,0x008A,0x008B,0x008C,0x008D,0x008E,0x008F, 0x0090,0x0091,0x0092,0x0093,0x0094,0x0095,0x0096,0x0097, 0x0098,0x0099,0x009A,0x009B,0x009C,0x009D,0x009E,0x009F, 0x00A0,0x0401,0x0402,0x0403,0x0404,0x0405,0x0406,0x0407, 0x0408,0x0409,0x040A,0x040B,0x040C,0x00AD,0x040E,0x040F, 0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417, 0x0418,0x0419,0x041A,0x041B,0x041C,0x041D,0x041E,0x041F, 0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427, 0x0428,0x0429,0x042A,0x042B,0x042C,0x042D,0x042E,0x042F, 0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437, 0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,0x043E,0x043F, 0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,0x044E,0x044F, 0x2116,0x0451,0x0452,0x0453,0x0454,0x0455,0x0456,0x0457, 0x0458,0x0459,0x045A,0x045B,0x045C,0x00A7,0x045E,0x045F ); $recode['a'] = array( 0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417, 0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e,0x041f, 0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427, 0x0428,0x0429,0x042a,0x042b,0x042c,0x042d,0x042e,0x042f, 0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437, 0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e,0x043f, 0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0448,0x0449,0x044a,0x044b,0x044c,0x044d,0x044e,0x044f, 0x0401,0x0451,0x0404,0x0454,0x0407,0x0457,0x040e,0x045e, 0x00b0,0x2219,0x00b7,0x221a,0x2116,0x00a4,0x25a0,0x00a0 ); $recode['d'] = $recode['a']; $recode['m'] = array( 0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417, 0x0418,0x0419,0x041A,0x041B,0x041C,0x041D,0x041E,0x041F, 0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427, 0x0428,0x0429,0x042A,0x042B,0x042C,0x042D,0x042E,0x042F, 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x0406, 0x00AE,0x00A9,0x2122,0x0402,0x0452,0x2260,0x0403,0x0453, 0x221E,0x00B1,0x2264,0x2265,0x0456,0x00B5,0x2202,0x0408, 0x0404,0x0454,0x0407,0x0457,0x0409,0x0459,0x040A,0x045A, 0x0458,0x0405,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB, 0x00BB,0x2026,0x00A0,0x040B,0x045B,0x040C,0x045C,0x0455, 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x201E, 0x040E,0x045E,0x040F,0x045F,0x2116,0x0401,0x0451,0x044F, 0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437, 0x0438,0x0439,0x043A,0x043B,0x043C,0x043D,0x043E,0x043F, 0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0448,0x0449,0x044A,0x044B,0x044C,0x044D,0x044E,0x00A4 ); $and = 0x3F; for ( $i = 0; $i < strlen( $str ); $i++ ) { $letter = 0x0; $octet = array(); $octet[0] = ord( $str[$i] ); $octets = 1; $andfirst = 0x7F; if ( ( $octet[0] >> 1 ) == 0x7E ) { $octets = 6; $andfirst = 0x1; } elseif ( ( $octet[0] >> 2 ) == 0x3E ) { $octets = 5; $andfirst = 0x3; } elseif ( ( $octet[0] >> 3 ) == 0x1E ) { $octets = 4; $andfirst = 0x7; } elseif ( ( $octet[0] >> 4 ) == 0xE ) { $octets = 3; $andfirst = 0xF; } elseif ( ( $octet[0] >> 5 ) ==0x6 ) { $octets = 2; $andfirst = 0x1F; } $octet[0] = $octet[0] & $andfirst; $octet[0] = $octet[0] << ( $octets - 1 ) * 6; $letter += $octet[0]; for ( $j = 1; $j < $octets; $j++ ) { $i++; $octet[$j] = ord( $str[$i] ) & $and; $octet[$j] = $octet[$j] << ( $octets - 1 - $j ) * 6; $letter += $octet[$j]; } if ( $letter < 0x80 ) $outstr .= chr( $letter ); else if ( in_array( $letter, $recode[$to] ) ) $outstr .= chr( array_search( $letter, $recode[$to] ) + 128 ); } return $outstr; } /** * function GetResource - Делает попытку(и) возвратить ресурс методом GET * * @param in string $url - урл ресурса которого надо скачать. * @param in string $referer - реферер * @return string - Возвращает результат то есть содержимое ресурса. */ function GetResource( $url, $referer = '' ) { $error = 'error'; $lac = $this->LOAD_ATTEMPTS_COUNT; if ( $lac <= 0 ) $lac = 1; $_clac = -1; $res = ''; while ( $error && ++$_clac < $lac ) { $res = $this->Get( $url, $referer ); $error = $this->error; if ( !empty( $this->USER_FUNC_NAME ) ) if ( !call_user_func( $this->USER_FUNC_NAME ) ) break; if ( $error && $this->show_error ) echo '
' . date( 'Y.m.d H:i:s' ) . ' - Ресурс не скачен. Текст ошибки ' . $error . '.
'; flush(); if ( $error && ( $lac > 1 ) && $this->show_error ) { sleep( $this->INTERVAL_BEETWEN_ATTEMPTS ); echo '' . date( 'Y.m.d H:i:s' ) . ' - Начинаем попытку ' . ( $_clac + 1 ) . ' чтобы скачать ресурс.
'; } flush(); } return $res; } /** * function SendAndGetResource - Делает попытку(и) отправить данные методом POST и возвратить ресурс. * * @param in string $url - урл ресурса которого надо скачать. * @param in array $data - данные каторые надо передать методом Post * @param in string $referer - реферер * @return string - Возвразщяет результат тоесть содержымое ресурса. */ function SendAndGetResource( $url, $data, $referer = '' ) { $error = 'error'; $lac = $this->LOAD_ATTEMPTS_COUNT; if ( $lac <= 0 ) $lac = 1; $_clac = -1; $res = ''; while ( $error && ++$_clac < $lac ) { $res = $this->Post( $url, $data, $referer ); $error = $this->error; if ( !empty( $this->USER_FUNC_NAME ) ) if ( !call_user_func( $this->USER_FUNC_NAME ) ) break; if ( $error && $this->show_error ) echo '
' . date( 'Y.m.d H:i:s' ) . ' - Ресурс не скачен. Текст ошибки ' . $error . '.
'; flush(); if ( $error && ( $lac > 1 ) && $this->show_error ) { sleep( $this->INTERVAL_BEETWEN_ATTEMPTS ); echo '' . date( 'Y.m.d H:i:s' ) . ' - Начинаем попытку ' . ( $_clac + 1 ) . ' чтобы скачать ресурс.
'; } flush(); } return $res; } /** * function GetError - Возвращяет ошибку * * @return string - Возвращяет строку */ function GetError() { return $this->error; } /** * function GetInfo - Возвращяет информацию о запросе * * @return string - Возвращяет строку * Возвращаемый массив содержит следующую информацию: * * “url” * “content_type” * “http_code” * “header_size” * “request_size” * “filetime” * “ssl_verify_result” * “redirect_count” * “total_time” * “namelookup_time” * “connect_time” * “pretransfer_time” * “size_upload” * “size_download” * “speed_download” * “speed_upload” * “download_content_length” * “upload_content_length” * “starttransfer_time” * “redirect_time” * * */ function GetInfo() { return $this->info; } /** * function SetUserFunction - устанваливает имя пользовательской функции * * @param in string $func_name - имя функции * @return; */ function SetUserFunction( $func_name ) { $this->USER_FUNC_NAME = $func_name; } }//end Curl ?> 2014 POLARIS RANGER 900, лот #28255249 — WorldMotoParts

СТИЛЬ САЙТА

Выберите удобный режим просмотра сайта


— день — ночь

2014 POLARIS RANGER 900