function sendiOSPushMessage() { $device_tokens = explode("\n", trim($this->input->post('device_token'))); $message = trim($this->input->post('message')); $service = $this->input->post('service'); $pem_file_path = $this->input->server('DOCUMENT_ROOT') . '/bin/'; if ($service == 1) { $apnsHost = 'gateway.push.apple.com'; $apnsCert = $pem_file_path . 'apns-product-DungeonHearts.pem'; } else { $apnsHost = 'gateway.sandbox.push.apple.com'; $apnsCert = $pem_file_path . 'apns_dev_devolver.pem'; } $apnsPort = 2195; $payload = array('aps' => array('alert' => $message, 'badge' => 0, 'sound' => 'default')); $payload = json_encode($payload); $streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert); $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext); if ($apns) { foreach ($device_tokens as $device_token) { $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace('%', '', $device_token)) . chr(0) . chr(strlen($payload)) . $payload; fwrite($apns, $apnsMessage); } fclose($apns); js_alert_back('Send message success!'); } else { js_alert_back('Server connect failed!'); } }
public function checkLevelRedirect($level) { if (!$this->CI->session->userdata('LEVEL')) { js_redirect(site_url(array('manager', 'login'))); } else { if ($this->CI->session->userdata('LEVEL') < $level) { js_alert_back('Permission error!'); } } }
public function execLogin() { $data = array('EMAIL' => $this->input->post('email'), 'PASSWORD' => $this->input->post('password')); $managerRow = $this->Manager_data->selectManager($data); if (!isset($managerRow['MANAGER_ID'])) { js_alert_back('Invalid member.'); } else { if ($managerRow['PASSWORD'] != md5($data['PASSWORD'])) { js_alert_back('You have entered an invalid password.'); } } $data = array('MANAGER_ID' => $managerRow['MANAGER_ID'], 'IS_LOGIN' => true); $this->Manager_data->updateManager($data); $this->auth->createSession($managerRow['MANAGER_ID'], $managerRow['EMAIL'], $managerRow['NAME'], $managerRow['LEVEL']); js_redirect('/'); }
public function execAddPoint($user_id = 0) { $amount = $this->input->post('amount'); $point_type = $this->input->post('point_type'); $memo = $this->input->post('memo'); $data = array('USER_ID' => $user_id); if ($amount == 0) { js_alert_back('Invalid amount.'); } else { if ($amount > 0) { $category = 99; } else { $category = -99; } } if ($point_type == 'MONEY') { $this->Shop_data->updateUserPoint(1, $amount, $category, $user_id, $memo); } else { if ($point_type == 'CASH') { $this->Shop_data->updateUserPoint(2, $amount, $category, $user_id, $memo); } else { if ($point_type == 'LOTTERY_POINT') { $this->Shop_data->updateUserPoint(3, $amount, $category, $user_id, $memo); } else { if ($point_type == 'LOTTERY_COUPON') { $this->Shop_data->updateUserPoint(4, $amount, $category, $user_id, $memo); } else { if ($point_type == 'LOTTERY_HIGH_COUPON') { $this->Shop_data->updateUserPoint(5, $amount, $category, $user_id, $memo); } else { $this->Shop_data->updateUserPoint($data); } } } } } js_alert_redirect('처리가 완료 되었습니다.', site_url(array('user', 'view', $user_id))); }
function execAddHeart($user_id = 0) { $value = $this->input->post('value'); $add_type = $this->input->post('add_type'); $memo = $this->input->post('memo'); if ($add_type == 'plus') { $heart = '+' . $value; } else { if ($add_type == 'minus') { $heart = '-' . $value; } } $data = array('USER_ID' => $user_id, 'HEART' => $heart); if ($this->User_data->setUserRow($data)) { js_alert_redirect('처리가 완료 되었습니다.', site_url(array('user', 'view', $user_id))); } else { js_alert_back('처리하지 못하였습니다.'); } }