Added function to update the cty db tables
这个提交包含在:
		
							父节点
							
								
									633b270f13
								
							
						
					
					
						当前提交
						cfd307364c
					
				
					共有  5 个文件被更改,包括 154222 次插入 和 3 次删除
				
			
		|  | @ -16,7 +16,7 @@ $config['app_name'] = "Cloudlog"; | ||||||
| $config['app_version'] = "0.1"; | $config['app_version'] = "0.1"; | ||||||
| $config['directory'] = "logbook"; | $config['directory'] = "logbook"; | ||||||
| 
 | 
 | ||||||
| $config['callbook'] = "hamio"; // Options are hamio or qrz
 | $config['callbook'] = "qrz"; // Options are hamio or qrz
 | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
| |-------------------------------------------------------------------------- | |-------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | @ -8,6 +8,9 @@ class adif extends CI_Controller { | ||||||
| 	{ | 	{ | ||||||
| 		parent::__construct(); | 		parent::__construct(); | ||||||
| 		$this->load->helper(array('form', 'url')); | 		$this->load->helper(array('form', 'url')); | ||||||
|  | 		 | ||||||
|  | 		$this->load->model('user_model'); | ||||||
|  | 		if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Shows Export Views */ | 	/* Shows Export Views */ | ||||||
|  | @ -138,5 +141,4 @@ class adif extends CI_Controller { | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* End of file welcome.php */ | /* End of file adif.php */ | ||||||
| /* Location: ./application/controllers/welcome.php */ |  | ||||||
							
								
								
									
										113
									
								
								application/controllers/update.php
									
									
									
									
									
										普通文件
									
								
							
							
						
						
									
										113
									
								
								application/controllers/update.php
									
									
									
									
									
										普通文件
									
								
							|  | @ -0,0 +1,113 @@ | ||||||
|  | <?php | ||||||
|  | class Update extends CI_Controller { | ||||||
|  | 
 | ||||||
|  | 	/* | ||||||
|  | 		Controls Updating Elements of Cloudlog | ||||||
|  | 		Functions: | ||||||
|  | 			dxcc | ||||||
|  | 			dxcc_exceptions | ||||||
|  | 	*/ | ||||||
|  | 	 | ||||||
|  | 	public function index() | ||||||
|  | 	{ | ||||||
|  | 		echo 'show fancy html page'; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	// Updates the DXCC
 | ||||||
|  | 	public function dxcc() { | ||||||
|  | 		// Set timeout to unlimited
 | ||||||
|  | 		set_time_limit(0); | ||||||
|  | 	 | ||||||
|  | 		// Load Database connectors
 | ||||||
|  | 		$this->load->model('dxcc'); | ||||||
|  | 
 | ||||||
|  | 		// Load the cty file
 | ||||||
|  | 		$xml_data = simplexml_load_file("updates/cty.xml"); | ||||||
|  | 		 | ||||||
|  | 		$this->dxcc->empty_table("dxcc"); | ||||||
|  | 		 | ||||||
|  | 		echo "<h2>Prefix List</h2>"; | ||||||
|  | 		foreach ($xml_data->prefixes as $prefixs) { | ||||||
|  | 			foreach ($prefixs->prefix as $callsign) { | ||||||
|  | 				echo $callsign->call." ".$callsign->entity; | ||||||
|  | 				 | ||||||
|  | 				if(!$callsign->cqz) { | ||||||
|  | 					$data = array( | ||||||
|  | 					   'prefix' => (string)  $callsign->call, | ||||||
|  | 					   'name' =>  (string) $callsign->entity, | ||||||
|  | 					); | ||||||
|  | 				} else { | ||||||
|  | 					$data = array( | ||||||
|  | 					   'prefix' => (string)  $callsign->call, | ||||||
|  | 					   'name' =>  (string) $callsign->entity, | ||||||
|  | 					   'cqz' => $callsign->cqz, | ||||||
|  | 					   'ituz' => $callsign->ituz, | ||||||
|  | 					   'cont' => (string) $callsign->cont, | ||||||
|  | 					   'long' => $callsign->long, | ||||||
|  | 					   'lat' => $callsign->lat | ||||||
|  | 					);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				$this->db->insert('dxcc', $data);  | ||||||
|  | 
 | ||||||
|  | 				echo " Inserted <br />"; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function dxcc_exceptions() | ||||||
|  | 	{ | ||||||
|  | 		set_time_limit(0); | ||||||
|  | 		// Load Database connectors
 | ||||||
|  | 		$this->load->model('dxcc'); | ||||||
|  | 
 | ||||||
|  | 		// Load the cty file
 | ||||||
|  | 		$xml_data = simplexml_load_file("updates/cty.xml"); | ||||||
|  | 
 | ||||||
|  | 		// empty table
 | ||||||
|  | 		$this->dxcc->empty_table("dxccexceptions"); | ||||||
|  | 		 | ||||||
|  | 		echo "<h2>Exceptions</h2>"; | ||||||
|  | 		foreach ($xml_data->exceptions as $exceptions) { | ||||||
|  | 			foreach ($exceptions->exception as $callsign) { | ||||||
|  | 				echo $callsign->call." ".$callsign->entity; | ||||||
|  | 			 | ||||||
|  | 				 | ||||||
|  | 				if(!$callsign->start) { | ||||||
|  | 					$data = array( | ||||||
|  | 					   'prefix' => (string)  $callsign->call, | ||||||
|  | 					   'name' =>  (string) $callsign->entity, | ||||||
|  | 					   'cqz' => $callsign->cqz, | ||||||
|  | 					   'ituz' => $callsign->ituz, | ||||||
|  | 					   'cont' => (string) $callsign->cont, | ||||||
|  | 					   'long' => $callsign->long, | ||||||
|  | 					   'lat' => $callsign->lat | ||||||
|  | 					);	 | ||||||
|  | 				} else { | ||||||
|  | 				 | ||||||
|  | 					$start = date('Y-m-d h:i', $timestamp); | ||||||
|  | 					$end = date('Y-m-d h:i', $timestamp); | ||||||
|  | 				 | ||||||
|  | 					$data = array( | ||||||
|  | 					   'prefix' => (string) $callsign->call, | ||||||
|  | 					   'name' =>  (string) $callsign->entity, | ||||||
|  | 					   'cqz' => $callsign->cqz, | ||||||
|  | 					   'ituz' => $callsign->ituz, | ||||||
|  | 					   'cont' => (string) $callsign->cont, | ||||||
|  | 					   'long' => $callsign->long, | ||||||
|  | 					   'lat' => $callsign->lat, | ||||||
|  | 					   'start' => $start, | ||||||
|  | 					   'end' => $end | ||||||
|  | 					);	 | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				$this->db->insert('dxccexceptions', $data);  | ||||||
|  | 
 | ||||||
|  | 				echo " Inserted <br />"; | ||||||
|  | 				 | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | ?>
 | ||||||
|  | @ -36,5 +36,9 @@ class DXCC extends CI_Model { | ||||||
| 			return $query; | 			return $query; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	 | ||||||
|  | 	function empty_table($table) { | ||||||
|  | 		$this->db->empty_table($table);  | ||||||
|  | 	} | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
							
								
								
									
										154100
									
								
								updates/cty.xml
									
									
									
									
									
										普通文件
									
								
							
							
						
						
									
										154100
									
								
								updates/cty.xml
									
									
									
									
									
										普通文件
									
								
							
										
											
												文件差异内容过多而无法显示
												加载差异
											
										
									
								
							
		正在加载…
	
		在新工单中引用