public static function sendToGCM($headers, $fields) { $url = 'https://android.googleapis.com/gcm/send'; // Open connection $ch = curl_init(); // Set the url curl_setopt($ch, CURLOPT_URL, $url); // Set request method to POST curl_setopt($ch, CURLOPT_POST, true); // Set custom headers curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Get response back as string curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Set post data curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); // cacert curl_setopt($ch, CURLOPT_CAINFO, DOCROOT . 'assets/cacert.pem'); // Send the request $result = curl_exec($ch); $err = curl_error($ch); if (!empty($err)) { Log::debug($err); } else { Log::debug($result); } Log::debug(print_r($headers, 1)); Log::debug(print_r($fields, 1)); Log::debug(print_r(json_encode($fields), 1)); // Close connection curl_close($ch); // Debug GCM response return $result; }
public static function get_list() { $fieldList = array('ID', 'Name', 'Email', 'Phone', 'Sex', 'Major', 'DoB', 'PoB', 'PoO', 'Address'); try { /** @var Database_Query $dbObj */ $dbObj = DB::select_array($fieldList)->from(self::$TABLE); $dbResult = $dbObj->execute(); return count($dbResult) > 0 ? $dbResult->as_array() : []; } catch (\Exception $e) { Log::debug($e); return []; } $dbResult = DB::select_array($fieldList)->from(Staff::$TABLE)->execute(); $dbData = $dbResult->as_array(); return $dbData; }
public function action_confirm() { $val = $this->forge_validation(); Log::debug('バリデーション前'); if ($val->run()) { Log::debug('バリデーションOK'); $data['input'] = $val->validated(); $this->template->title = 'コンタクトフォーム:確認'; $this->template->content = View::forge('form/confirm', $data); $this->template->footer = View::forge('form/footer'); } else { Log::debug('バリデーションNG'); $this->template->title = 'コンタクトフォーム:エラー'; $this->template->content = View::forge('form/index'); $this->template->content->set_safe('html_error', $val->show_errors()); $this->template->footer = View::forge('form/footer'); } }
public function deleteStory($id) { try { $dbObj = DB::delete($this->TABLE)->where('ID', $id); $dbObj->execute(); return true; } catch (\Exception $e) { Log::debug($e); return false; } }
/** * check redirect * * @return void */ public function check_redirect() { if ($this->__skip === true) { return; } // check added www in production env if (\Fuel\Core\Fuel::$env === \Fuel\Core\Fuel::PRODUCTION) { if (!preg_match('/^' . \Config::get('seo.subdomain') . '\\./', $_SERVER['HTTP_HOST'])) { $new_uri = \Fuel\Core\Input::protocol() . '://' . \Config::get('seo.subdomain') . '.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; \Fuel\Core\Response::redirect($new_uri, 'location', 301); } } // init $redirect_flg = false; $redirect_uri = $this->_current_uri . $this->_current_get; // reverse routing $check_uri = Route::reverse_route($this->_routed_uri); if ($check_uri !== $this->_routed_uri or $check_uri !== $this->_current_uri) { $redirect_flg = true; $redirect_uri = $check_uri . $this->_current_get; } // page=1 check (301 redirect) if (\Fuel\Core\Input::get('page') === '1') { $redirect_flg = true; $redirect_uri = preg_replace('/[&?](page=1&?)/', '$1', $redirect_uri); } // last &, ? check (301 redirect) if (empty(\Input::get()) and preg_match('/[&\\?]$/', $redirect_uri)) { $redirect_flg = true; $redirect_uri = preg_replace('/[&\\?]$/', '', $redirect_uri); } // do 301 redirect if ($redirect_flg) { \Fuel\Core\Session::keep_flash(); // before redirect, if env is development and posted, set notify if (\Fuel\Core\Fuel::$env === \Fuel\Core\Fuel::DEVELOPMENT and \Fuel\Core\Input::post()) { \Fuel\Core\Session::set_flash('error', 'Redirect occured, please check post url'); } \Fuel\Core\Log::debug($this->_current_uri . $this->_current_get . ': redirect to ' . $redirect_uri); \Fuel\Core\Response::redirect($redirect_uri, 'location', 301); } }