Скрипт для обновления FlashPlayer-а
20.10.2013 15:00
0Скачивается вариант для установки в виде плагина (FF), но не сложно переделать под любой другой вариат.
Кроме того, последнюю версию FlashPlayer-а для двух разных вартантов (в виде плагина нет) можно получить перейдя вот по этим ссылкам:
download.macromedia.com/pub/flashplayer/current/support/install_flash_player.exe
download.macromedia.com/pub/flashplayer/current/support/install_flash_player_ax.exe
Сам скрипт:
echo( "\n" ); exec( 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Flash Player Plugin" /v DisplayVersion', $out ); $cur_version = null; if ( $out && preg_match( "~DisplayVersion\\s+REG_SZ\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)~i", join( $out ), $m ) ) $cur_version = $m[1]; echo( "Current installed Adobe Flash Player version is \"" . ( $cur_version ? $cur_version : "unknown" ) . "\"\n" ); echo( "\n" ); $dst = dirname( __FILE__ ); define( "TIMEOUT", 60 * 15 ); $last_len = 0; $last_err = null; function getFile( $url, $fname = null ) { global $last_len, $last_err; $last_len = 0; $last_err = null; $ch = curl_init(); echo( "Download \"{$url}\" ... " ); if ( $fname ) { $fp = fopen( $fname, "w" ); curl_setopt( $ch, CURLOPT_FILE, $fp ); } else curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_BINARYTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 ); curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookies.txt" ); //initiates cookie file if needed curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookies.txt" ); // Uses cookies from previous session if exist curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, TIMEOUT ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT_MS, TIMEOUT * 1000 ); curl_setopt( $ch, CURLOPT_TIMEOUT, TIMEOUT ); curl_setopt( $ch, CURLOPT_TIMEOUT_MS, TIMEOUT * 1000 ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $ch, CURLOPT_SSLVERSION, 3 ); curl_setopt( $ch, CURLOPT_AUTOREFERER, 1 ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language: ru,en-us;q=0.7,en;q=0.3', 'User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)' ) ); curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, "progress" ); curl_setopt( $ch, CURLOPT_NOPROGRESS, false ); curl_setopt( $ch, CURLOPT_POST, 0 ); curl_setopt( $ch, CURLOPT_REFERER, $url ); curl_setopt( $ch, CURLOPT_URL, $url ); $data = curl_exec( $ch ); echo( "\n" ); if ( $data === false ) { $last_err = curl_error( $ch ); if ( !$last_err ) $last_err = "unknown error"; } curl_close( $ch ); if ( $fname ) { fclose( $fp ); if ( $data !== false ) $data = null; } return $data; } function progress( $download_size, $downloaded, $upload_size, $uploaded ) { global $last_len; if ( $download_size > 0 ) { echo( str_repeat( Chr(8), $last_len ) ); $str = number_format( ( $downloaded / $download_size * 100 ), 1 ). "%"; $last_len = strlen( $str ); echo $str; } @ob_flush(); flush(); } $vp = getFile( "http://www.adobe.com/software/flash/about/" ); if ( $last_err ) echo( "Can't get page content: {$last_err}\n" ); if ( preg_match( "~<strong>Windows<\\/strong>.*?Firefox.*?<td>(\\d+\\.\\d+\\.\\d+\\.\\d+)<\\/td>~is", $vp, $m ) ) { $last_fp_version = $m[1]; echo( "\n" ); echo( "Last Flash Player version is \"{$last_fp_version}\"\n" ); echo( "\n" ); $fp = getFile( "http://fpdownload.macromedia.com/get/flashplayer/pdc/{$last_fp_version}/install_flash_player.exe", "{$dst}/flashPlayer.exe" ); if ( $last_err ) echo( "Can't get page content: {$last_err}\n" ); } else echo( "Can't get last flashplayer version!\n" );
20.10.2013, Protocoder