- Timestamp:
- 10/01/08 17:35:19 (2 months ago)
- Location:
- events/phpframework/codeigniter/trunk/system/application
- Files:
-
- 5 modified
-
controllers/friendships.php (modified) (9 diffs)
-
controllers/status.php (modified) (2 diffs)
-
controllers/user.php (modified) (2 diffs)
-
views/user/main.php (modified) (2 diffs)
-
views/user/main_friends.php (modified) (1 diff)
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 -
events/phpframework/codeigniter/trunk/system/application/controllers/status.php
r20315 r20373 14 14 } 15 15 16 // Ajax つぶやき投稿の受信 16 17 function update() 17 18 { … … 21 22 // CSRF チェック 22 23 $ticket = $this->session->flashdata('ticket'); 23 24 24 if ( ! $this->input->post('ticket') 25 25 || $this->input->post('ticket') !== $ticket) -
events/phpframework/codeigniter/trunk/system/application/controllers/user.php
r20318 r20373 56 56 // CSRF 対策のワンタイムチケット 57 57 $data->ticket = md5(uniqid(mt_rand(), TRUE)); 58 $this->session->set_ userdata('ticket', $data->ticket);58 $this->session->set_flashdata('ticket', $data->ticket); 59 59 60 60 $this->load->model('User_model'); … … 137 137 // CSRF 対策のワンタイムチケット 138 138 $data->ticket = md5(uniqid(mt_rand(), TRUE)); 139 $this->session->set_ userdata('ticket', $data->ticket);139 $this->session->set_flashdata('ticket', $data->ticket); 140 140 141 141 $this->load->model('Status_model'); -
events/phpframework/codeigniter/trunk/system/application/views/user/main.php
r20311 r20373 3 3 $(function(){ 4 4 $('#follow_button').click(function(){ 5 $.post('<?=site_url('friendships/create')?>', {id: $('#follow_id').val(), ticket: $('#ticket').val()}, followMsg, ' html');5 $.post('<?=site_url('friendships/create')?>', {id: $('#follow_id').val(), ticket: $('#ticket').val()}, followMsg, 'json'); 6 6 return false; 7 7 }); 8 8 }); 9 9 function followMsg(data){ 10 $('div[class="main"]').prepend(data); 10 if (data.status == 'ok') { 11 $('div[class="main"]').prepend(data.html); 11 12 $('#follow_button').hide(); 12 13 $('#remove_button').show(); 13 14 $('#msg').fadeOut(3000); 15 count = parseInt($('#side_count_follow').text()) + 1; 16 $('#side_count_follow').text(count); 17 } 18 else { 19 alert(data.html); 20 } 14 21 } 15 22 … … 17 24 $(function(){ 18 25 $('#remove_button').click(function(){ 19 $.post('<?=site_url('friendships/destroy')?>', {id: $('#follow_id').val(), ticket: $('#ticket').val()}, removeMsg, ' html');26 $.post('<?=site_url('friendships/destroy')?>', {id: $('#follow_id').val(), ticket: $('#ticket').val()}, removeMsg, 'json'); 20 27 return false; 21 28 }); 22 29 }); 23 30 function removeMsg(data){ 24 $('div[class="main"]').prepend(data); 31 if (data.status == 'ok') { 32 $('div[class="main"]').prepend(data.html); 25 33 $('#follow_button').show(); 26 34 $('#remove_button').hide(); 27 35 $('#msg').fadeOut(3000); 36 count = parseInt($('#side_count_follow').text()) - 1; 37 $('#side_count_follow').text(count); 38 } 39 else { 40 alert(data.html); 41 } 28 42 } 29 43 </script> -
events/phpframework/codeigniter/trunk/system/application/views/user/main_friends.php
r20237 r20373 1 <script >1 <script type="text/javascript"> 2 2 /* 削除 */ 3 3 function removeFollow(id){ 4 4 if (confirm('削除してもよいですか?取り消しできません!')){ 5 $.post('<?=site_url('friendships/destroy 2')?>', {id: id, ticket: $('#ticket').val()}, removeLine, 'html');5 $.post('<?=site_url('friendships/destroy')?>', {id: id, ticket: $('#ticket').val()}, removeLine, 'json'); 6 6 }; 7 7 } 8 function removeLine(id){ 9 $('tr').remove(id); 10 count = $('span#count').text() - 1; 11 $('#count').text(count); 12 $('#side_count_friend').text(count); 8 function removeLine(data){ 9 if (data.status == 'ok') { 10 $('tr').remove(data.id); 11 count = $('span#count').text() - 1; 12 $('#count').text(count); 13 $('#side_count_friend').text(count); 14 } 15 else { 16 alert(data.html); 17 } 13 18 } 14 19 </script>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)