document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. // Opens a connection to a MySQL server
  4.  
  5. $connection=mysql_connect(\'localhost\', \'database_username\', \'database_password\');
  6. if (!$connection) {  die(\'Not connected : \' . mysql_error());}
  7.  
  8. // Set the active MySQL database
  9.  
  10. $db_selected = mysql_select_db(\'database_name\', $connection);
  11.  
  12.  
  13. if (!$db_selected) {
  14.   die (\'Can\\\'t use db : \' . mysql_error());
  15. }
  16.  
  17. // Select all the rows in the location table
  18.  
  19. $query = "SELECT * FROM nodes";
  20.  
  21. $result = mysql_query($query);
  22.  
  23. if (!$result){
  24.  
  25.     die(\'Invalid query: \' . mysql_error());
  26.  
  27. }
  28.  
  29. while($location = mysql_fetch_array($result)){
  30.    
  31.     //$img[]=\'http://maps.googleapis.com/maps/api/staticmap?center=\'.$location[\'lat\'].\',\'.$location[\'lng\'].\'&zoom=19&size=600x600&maptype=hybrid&sensor=false\';
  32.     $img[]=\'http://cbk0.google.com/cbk?output=thumbnail&w=400&h=218&ll=\'.$location[\'lat\'].\',\'.$location[\'lng\'];
  33.  
  34. }
  35.  
  36. foreach($img as $i){
  37.     save_image($i);
  38.    
  39.     if(basename($i)){
  40.         echo \'<h3 style="color: green;">Image \' .basename($i) . \'Downloaded OK </h3>\';
  41.         }
  42.     else{
  43.         echo \'<h3 style="color: red;">Image \' .basename($i) . \' Download Failed</h3>\';
  44.         }
  45.        
  46. }
  47.  
  48.  
  49. function save_image($img,$fullpath=\'basename\'){
  50.  
  51.     if($fullpath == \'basename\'){
  52.         $fullpath = basename($img);
  53.     }
  54.  
  55.     $ch = curl_init($img);
  56.     curl_setopt($ch, CURLOPT_HEADER, 0);
  57.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  58.     curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  59.    
  60.     $rawdata = curl_exec($ch);
  61.     curl_close($ch);
  62.    
  63.     if(file_exists($fullpath)){
  64.         unlink($fullpath);
  65.     }
  66.     $fp = fopen($fullpath.\'.png\',\'x\');
  67.     fwrite($fp, $rawdata);
  68.     fclose($fp);
  69.    
  70. }
  71.  
  72.  
  73. error_reporting(E_ALL);
  74. ini_set(\'display_errors\', 1);
  75.  
  76.  
  77.  
  78. ?>
');