[Clublog] Updated script (cron job) to work for all users with a username and password set
这个提交包含在:
		
							父节点
							
								
									b5fc571e2e
								
							
						
					
					
						当前提交
						e00aacc96c
					
				
					共有  3 个文件被更改,包括 53 次插入 和 29 次删除
				
			
		|  | @ -12,9 +12,20 @@ class Clublog extends CI_Controller { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Upload ADIF to Clublog
 | 	// Upload ADIF to Clublog
 | ||||||
| 	public function upload($username) { | 	public function upload() { | ||||||
|  | 		$this->load->model('clublog_model'); | ||||||
| 
 | 
 | ||||||
|  | 		$users = $this->clublog_model->get_clublog_users(); | ||||||
|  | 
 | ||||||
|  | 		foreach ($users as $user) { | ||||||
|  | 			$this->uploadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	function uploadUser($userid, $username, $password) { | ||||||
| 		$clean_username = $this->security->xss_clean($username); | 		$clean_username = $this->security->xss_clean($username); | ||||||
|  | 		$clean_passord = $this->security->xss_clean($password); | ||||||
|  | 		$clean_userid = $this->security->xss_clean($userid); | ||||||
| 
 | 
 | ||||||
| 		$this->config->load('config'); | 		$this->config->load('config'); | ||||||
| 		ini_set('memory_limit', '-1'); | 		ini_set('memory_limit', '-1'); | ||||||
|  | @ -24,27 +35,15 @@ class Clublog extends CI_Controller { | ||||||
| 
 | 
 | ||||||
| 		$this->load->helper('file'); | 		$this->load->helper('file'); | ||||||
| 
 | 
 | ||||||
| 		$this->load->model('logbook_model'); |  | ||||||
| 
 |  | ||||||
| 		$this->load->model('stations'); |  | ||||||
| 
 |  | ||||||
| 		$this->load->model('clublog_model'); | 		$this->load->model('clublog_model'); | ||||||
| 
 | 
 | ||||||
| 		$clublog_info = $this->clublog_model->get_clublog_auth_info($clean_username); | 		$station_profiles = $this->clublog_model->all_with_count($clean_userid); | ||||||
| 
 |  | ||||||
| 		if(!isset($clublog_info['user_name'])) { |  | ||||||
| 			echo "Username unknown"; |  | ||||||
| 			exit; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 		$station_profiles = $this->stations->all_with_count(); |  | ||||||
| 
 | 
 | ||||||
| 		if($station_profiles->num_rows()){ | 		if($station_profiles->num_rows()){ | ||||||
| 			foreach ($station_profiles->result() as $station_row) | 			foreach ($station_profiles->result() as $station_row) | ||||||
| 			{ | 			{ | ||||||
| 				if($station_row->qso_total > 0) { | 				if($station_row->qso_total > 0) { | ||||||
| 					$data['qsos'] = $this->logbook_model->get_clublog_qsos($station_row->station_id); | 					$data['qsos'] = $this->clublog_model->get_clublog_qsos($station_row->station_id); | ||||||
| 
 | 
 | ||||||
| 					if($data['qsos']->num_rows()){ | 					if($data['qsos']->num_rows()){ | ||||||
| 						$string = $this->load->view('adif/data/clublog', $data, TRUE); | 						$string = $this->load->view('adif/data/clublog', $data, TRUE); | ||||||
|  | @ -79,8 +78,8 @@ class Clublog extends CI_Controller { | ||||||
| 							    $request, | 							    $request, | ||||||
| 							    CURLOPT_POSTFIELDS, | 							    CURLOPT_POSTFIELDS, | ||||||
| 							    array( | 							    array( | ||||||
| 							      'email' => $clublog_info['user_clublog_name'], | 							      'email' => $clean_username, | ||||||
| 							      'password' => $clublog_info['user_clublog_password'], | 							      'password' => $clean_passord, | ||||||
| 							      'callsign' => $station_row->station_callsign, | 							      'callsign' => $station_row->station_callsign, | ||||||
| 							      'api' => "a11c3235cd74b88212ce726857056939d52372bd", | 							      'api' => "a11c3235cd74b88212ce726857056939d52372bd", | ||||||
| 							      'file' => $cFile | 							      'file' => $cFile | ||||||
|  |  | ||||||
|  | @ -2,6 +2,14 @@ | ||||||
| 
 | 
 | ||||||
| class Clublog_model extends CI_Model { | class Clublog_model extends CI_Model { | ||||||
| 
 | 
 | ||||||
|  | 	function get_clublog_users() { | ||||||
|  | 		$this->db->select('user_clublog_name, user_clublog_password, user_id'); | ||||||
|  | 		$this->db->where('coalesce(user_clublog_name, "") != ""'); | ||||||
|  | 		$this->db->where('coalesce(user_clublog_password, "") != ""'); | ||||||
|  | 		$query = $this->db->get($this->config->item('auth_table')); | ||||||
|  | 		return $query->result(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	function get_clublog_auth_info($username) { | 	function get_clublog_auth_info($username) { | ||||||
| 		$this->db->select('user_name, user_clublog_name, user_clublog_password'); | 		$this->db->select('user_name, user_clublog_name, user_clublog_password'); | ||||||
| 		$this->db->where('user_name', $username); | 		$this->db->where('user_name', $username); | ||||||
|  | @ -53,6 +61,35 @@ class Clublog_model extends CI_Model { | ||||||
| 		$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", "Y"); | 		$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", "Y"); | ||||||
| 		$this->db->update($this->config->item('table_name'), $data); | 		$this->db->update($this->config->item('table_name'), $data); | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	function get_clublog_qsos($station_id){ | ||||||
|  | 		$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); | ||||||
|  | 		$this->db->where($this->config->item('table_name').'.station_id', $station_id); | ||||||
|  | 		$this->db->group_start(); | ||||||
|  | 		$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null); | ||||||
|  | 		$this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", ""); | ||||||
|  | 		$this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", "N"); | ||||||
|  | 		$this->db->group_end(); | ||||||
|  | 	 | ||||||
|  | 		$query = $this->db->get($this->config->item('table_name')); | ||||||
|  | 
 | ||||||
|  | 		return $query; | ||||||
|  | 	  } | ||||||
|  | 
 | ||||||
|  | 	  function all_with_count($userid) { | ||||||
|  | 		$this->db->select('station_profile.station_id, station_profile.station_callsign, count('.$this->config->item('table_name').'.station_id) as qso_total'); | ||||||
|  |         $this->db->from('station_profile'); | ||||||
|  |         $this->db->join($this->config->item('table_name'),'station_profile.station_id = '.$this->config->item('table_name').'.station_id','left'); | ||||||
|  |        	$this->db->group_by('station_profile.station_id'); | ||||||
|  | 		$this->db->where('station_profile.user_id', $userid); | ||||||
|  | 		$this->db->group_start(); | ||||||
|  | 		$this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null); | ||||||
|  | 		$this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", ""); | ||||||
|  | 		$this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", "N"); | ||||||
|  | 		$this->db->group_end(); | ||||||
|  | 		 | ||||||
|  |         return $this->db->get(); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ?>
 | ?>
 | ||||||
|  | @ -1045,18 +1045,6 @@ class Logbook_model extends CI_Model { | ||||||
|     return $this->db->get(); |     return $this->db->get(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function get_clublog_qsos($station_id){ |  | ||||||
|     $this->db->where($this->config->item('table_name').'.station_id', $station_id); |  | ||||||
|     $this->db->where("COL_CLUBLOG_QSO_UPLOAD_STATUS", null); |  | ||||||
|     $this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", ""); |  | ||||||
|     $this->db->or_where("COL_CLUBLOG_QSO_UPLOAD_STATUS", "N"); |  | ||||||
|     $this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id'); |  | ||||||
| 
 |  | ||||||
|     $query = $this->db->get($this->config->item('table_name')); |  | ||||||
| 
 |  | ||||||
|     return $query; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|     /* |     /* | ||||||
|      * Function returns the QSOs from the logbook, which have not been either marked as uploaded to qrz, or has been modified with an edit |      * Function returns the QSOs from the logbook, which have not been either marked as uploaded to qrz, or has been modified with an edit | ||||||
|      */ |      */ | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用