Changeset 20373 for events/phpframework/codeigniter/trunk/system/application/controllers/friendships.php
- Timestamp:
- 10/01/08 17:35:19 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/codeigniter/trunk/system/application/controllers/friendships.php
r20235 r20373 14 14 } 15 15 16 // Ajax「フォローする」の受信 16 17 function create() 17 18 { 19 $this->session->keep_flashdata('ticket'); 20 header('Content-Type: application/json; charset=UTF-8'); 21 18 22 // CSRF チェック 19 $ticket = $this->session-> userdata('ticket');23 $ticket = $this->session->flashdata('ticket'); 20 24 if ( ! $this->input->post('ticket') 21 25 || $this->input->post('ticket') !== $ticket) 22 26 { 23 27 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Wrong Ticket'); 28 echo json_encode(array('status' => 'ng', 'html' => 'チケットが異なります')); 24 29 exit; 25 30 } … … 29 34 { 30 35 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Not Logged in'); 36 echo json_encode(array('status' => 'ng', 'html' => 'ログインしていません')); 31 37 exit; 32 38 } … … 39 45 { 40 46 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = 0'); 47 echo json_encode(array('status' => 'ng', 'html' => 'ユーザIDが不正です')); 41 48 exit; 42 49 } … … 44 51 { 45 52 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = user_id'); 53 echo json_encode(array('status' => 'ng', 'html' => 'ユーザIDが不正です')); 46 54 exit; 47 55 } … … 51 59 $this->Follower_model->create($user_id, $follow_id); 52 60 53 header('Content-Type: text/html; charset=UTF-8');54 echo '<h1 id="msg">あなたはフォローを開始しました。</h1>';61 $html = '<h1 id="msg">あなたはフォローを開始しました。</h1>'; 62 echo json_encode(array('status' => 'ok', 'html' => $html)); 55 63 } 56 64 65 // Ajax「フォロー解除する」の受信 57 66 function destroy() 58 67 { 68 $this->session->keep_flashdata('ticket'); 69 header('Content-Type: application/json; charset=UTF-8'); 70 59 71 // CSRF チェック 60 $ticket = $this->session-> userdata('ticket');72 $ticket = $this->session->flashdata('ticket'); 61 73 if ( ! $this->input->post('ticket') 62 74 || $this->input->post('ticket') !== $ticket) 63 75 { 64 76 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Wrong Ticket'); 77 echo json_encode(array('status' => 'ng', 'html' => 'チケットが異なります')); 65 78 exit; 66 79 } … … 70 83 { 71 84 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Not Logged in'); 85 echo json_encode(array('status' => 'ng', 'html' => 'ログインしていません')); 72 86 exit; 73 87 } … … 80 94 { 81 95 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = 0'); 96 echo json_encode(array('status' => 'ng', 'html' => 'ユーザIDが不正です')); 82 97 exit; 83 98 } … … 85 100 { 86 101 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = user_id'); 102 echo json_encode(array('status' => 'ng', 'html' => 'ユーザIDが不正です')); 87 103 exit; 88 104 } … … 92 108 $this->Follower_model->destroy($user_id, $follow_id); 93 109 94 header('Content-Type: text/html; charset=UTF-8'); 95 echo '<h1 id="msg">あなたはフォローを解除しました。</h1>'; 96 } 97 98 function destroy2() 99 { 100 // CSRF チェック 101 $ticket = $this->session->userdata('ticket'); 102 if ( ! $this->input->post('ticket') 103 || $this->input->post('ticket') !== $ticket) 104 { 105 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Wrong Ticket'); 106 exit; 107 } 108 109 // ログインチェック 110 if ( ! $this->redux_auth->logged_in()) 111 { 112 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but Not Logged in'); 113 exit; 114 } 115 116 $user_id = intval($this->session->userdata('id')); 117 $follow_id = intval($this->input->post('id')); 118 119 // バリデーション 120 if ($follow_id == 0) 121 { 122 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = 0'); 123 exit; 124 } 125 if ($user_id == $follow_id) 126 { 127 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted but follow_id = user_id'); 128 exit; 129 } 130 131 $this->load->model('Follower_model', '', TRUE); 132 log_message('info', '[class]' . __CLASS__ . '/' . __FUNCTION__ . '(): Posted Follow: ' . $user_id . ' > ' . $follow_id); 133 $this->Follower_model->destroy($user_id, $follow_id); 134 135 header('Content-Type: text/html; charset=UTF-8'); 136 echo '#id' . $follow_id; 110 $html = '<h1 id="msg">あなたはフォローを解除しました。</h1>'; 111 echo json_encode(array('status' => 'ok', 'html' => $html, 'id' => '#id' . $follow_id)); 137 112 } 138 113
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)