Merge pull request #852 from AndreasK79/dok_sota_autoupdate
Added autoupdate for DOK and SOTA file used for autocompletion
这个提交包含在:
		
						当前提交
						9dab00b979
					
				
					共有  1 个文件被更改,包括 69 次插入 和 0 次删除
				
			
		|  | @ -289,6 +289,75 @@ class Update extends CI_Controller { | ||||||
|         fclose($f); |         fclose($f); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /* | ||||||
|  |      * Used for autoupdating the DOK file which is used in the QSO entry dialog for autocompletion. | ||||||
|  |      */ | ||||||
|  |     public function update_dok() { | ||||||
|  |         $contents = file_get_contents('https://www.df2et.de/cqrlog/dok.txt', true); | ||||||
|  | 
 | ||||||
|  |         if($contents === FALSE) { | ||||||
|  |             echo "Something went wrong with fetching the DOK file."; | ||||||
|  |         } else { | ||||||
|  |             $file = './assets/json/dok.txt'; | ||||||
|  | 
 | ||||||
|  |             file_put_contents($file, $contents);     // Save our content to the file.
 | ||||||
|  | 
 | ||||||
|  |             if (file_exists($file)) | ||||||
|  |             { | ||||||
|  |                 $nCount = count(file($file)); | ||||||
|  |                 if ($nCount > 0) | ||||||
|  |                 { | ||||||
|  |                     echo "DONE: " . number_format($nCount) . " DOK's saved"; | ||||||
|  |                 } else { | ||||||
|  |                     echo"FAILED: Empty file"; | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 echo"FAILED: Could not create dok.txt file locally"; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /* | ||||||
|  |      * Used for autoupdating the SOTA file which is used in the QSO entry dialog for autocompletion. | ||||||
|  |      */ | ||||||
|  |     public function update_sota() { | ||||||
|  |         $csvfile = 'https://www.sotadata.org.uk/summitslist.csv'; | ||||||
|  | 
 | ||||||
|  |         $sotafile = './assets/json/sota.txt'; | ||||||
|  | 
 | ||||||
|  |         if($csvfile === FALSE) { | ||||||
|  |             echo "Something went wrong with fetching the SOTA file"; | ||||||
|  |         } else { | ||||||
|  |             $csvhandle = fopen($csvfile,"r"); | ||||||
|  | 
 | ||||||
|  |             $data = fgetcsv($csvhandle,1000,","); // Skip line we are not interested in
 | ||||||
|  |             $data = fgetcsv($csvhandle,1000,","); // Skip line we are not interested in
 | ||||||
|  |             $data = fgetcsv($csvhandle,1000,","); | ||||||
|  |             $sotafilehandle = fopen($sotafile, 'w'); | ||||||
|  | 
 | ||||||
|  |             do { | ||||||
|  |                 if ($data[0]) { | ||||||
|  |                     fwrite($sotafilehandle, $data[0].PHP_EOL); | ||||||
|  |                 } | ||||||
|  |             } while ($data = fgetcsv($csvhandle,1000,",")); | ||||||
|  | 
 | ||||||
|  |             fclose($csvhandle); | ||||||
|  |             fclose($sotafilehandle); | ||||||
|  |             if (file_exists($sotafile)) | ||||||
|  |             { | ||||||
|  |                 $nCount = count(file($sotafile)); | ||||||
|  |                 if ($nCount > 0) | ||||||
|  |                 { | ||||||
|  |                     echo "DONE: " . number_format($nCount) . " SOTA's saved"; | ||||||
|  |                 } else { | ||||||
|  |                     echo"FAILED: Empty file"; | ||||||
|  |                 } | ||||||
|  |             } else { | ||||||
|  |                 echo"FAILED: Could not create sota.txt file locally"; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用