Guest User

Watchtower.php

a guest
Apr 30th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit( 0 );
  4. ini_set( 'user_agent', 'Safari' );
  5.  
  6. $json = json_decode( file_get_contents( $_SERVER['HOME'] . '/Library/Application Support/1Password 4/3rd Party Integration/bookmarks-default.json' ) );
  7.  
  8. for( $i=0,$len=count($json); $i<$len; ++$i ){
  9.   echo '* ' . ( $i + 1 ) . '/' . $len . ': ' . $json[$i][1] . PHP_EOL;
  10.   $domain = parse_url( $json[$i][2], PHP_URL_HOST );
  11.   echo '  - ' . $domain . PHP_EOL;
  12.  
  13.   $response = file_get_contents( 'http://watchtower.agilebits.com/check?h=' . urlencode( $domain ) . '&port=443' );
  14.   if( preg_match( '/<h3>Status<\/h3>\s*(<div.+?<\/div>)/s', $response, $matches ) ){
  15.     $r_status = trim( strip_tags( $matches[1] ) );
  16.     echo '  - Status: ' . $r_status . PHP_EOL;
  17.   }
  18.   if( preg_match( '/<h3>Recommended Action<\/h3>\s*(<div.+?<\/p>)/s', $response, $matches ) ){
  19.     $r_first_recommendation = trim( strip_tags( $matches[1] ) );
  20.     echo '  - Recommendation: ' . $r_first_recommendation . PHP_EOL;
  21.   }
  22.   if( preg_match( '/<h3>Special Notes<\/h3>\s*(<div.+?<\/div>)/s', $response, $matches ) ){
  23.     $r_special_notes = trim( strip_tags( $matches[1] ) );
  24.     echo '  - Special Notes: ' . $r_special_notes . PHP_EOL;
  25.   }
  26.  
  27.   echo PHP_EOL;
  28. }
  29.  
  30. ?>
Add Comment
Please, Sign In to add comment