Ejemplo n.º 1
0
 public static function feed_fb($token, $data)
 {
     $data = json_decode(base64_decode($data));
     if (!empty($data->id)) {
         if (!defined('_PATH_PRODUCT_')) {
             define('_PATH_PRODUCT_', Config::get('base_url') . Config::get('app.path.product'));
         }
         $product = \Model_Base_Product::get_one($data->id);
         $tmp = "\r\n\r\n--------------------------------------------------\r\n\r\n";
         $message = $product['product_name'] . $tmp . $product['product_description'] . $tmp . $product['product_info'];
         $groups = \Model_Base_GroupFb::get_all();
         foreach ($groups as $group) {
             try {
                 \OpauthStrategy::serverPost('https://graph.facebook.com/v2.5/' . $group['group_id'] . '/feed', array('access_token' => $token, 'message' => strip_tags(html_entity_decode($message, ENT_QUOTES)), 'link' => Uri::create('/product/' . $product['code']), 'caption' => 'WJ-SHOP', 'name' => html_entity_decode($product['product_name'], ENT_QUOTES), 'description' => html_entity_decode($product['product_description'], ENT_QUOTES), 'picture' => _PATH_PRODUCT_ . $product['product_photo']), null, $headers);
             } catch (\Exception $e) {
                 Log::error($e->getMessage());
             }
             sleep(5);
         }
     } elseif (!empty($data->message) && !empty($data->link)) {
         $groups = \Model_Base_GroupFb::get_all();
         foreach ($groups as $group) {
             try {
                 \OpauthStrategy::serverPost('https://graph.facebook.com/v2.5/' . $group['group_id'] . '/feed', array('access_token' => $token, 'message' => html_entity_decode($data->message, ENT_QUOTES), 'link' => $data->link), null, $headers);
             } catch (\Exception $e) {
                 Log::error($e->getMessage());
             }
             sleep(5);
         }
     }
 }
Ejemplo n.º 2
0
 public static function feed_fb($token, $data)
 {
     $data = base64_encode(json_encode($data));
     $oil_path = str_replace('\\', '/', realpath(APPPATH . '/../../'));
     $command = "env FUEL_ENV=" . Fuel::$env . " php {$oil_path}/oil r tool:feed_fb '{$token}' '{$data}' > /dev/null &";
     try {
         exec($command);
     } catch (Exception $e) {
         Log::error($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 public function select($searchKey)
 {
     try {
         $modelInstance = Model_Members::forge();
         $result = Model_Members::query()->where('namefull', 'like', '%' . $searchKey . '%')->or_where('email', 'like', '%' . $searchKey . '%')->or_where('point', 'like', '%' . $searchKey . '%')->get();
         return $result;
     } catch (Exception $error) {
         Log::error("MemberDao.select() : ", $error->getMessage());
         return false;
     }
 }
Ejemplo n.º 4
0
 public static function load_highlight()
 {
     try {
         $dbResult = DB::SELECT('ID', 'Title', 'Description')->from('News')->where('Type', 2)->order_by('DateCreate', 'dsc')->limit(1)->execute();
         $dbData = $dbResult->as_array();
         return $dbData;
     } catch (\Exception $e) {
         Log::error($e);
         // Redirect to 500 server error;
         return Response::redirect(500);
     }
 }
Ejemplo n.º 5
0
 public static function send_mail($option = null)
 {
     $option = base64_encode(json_encode($option));
     $oil_path = str_replace('\\', '/', realpath(APPPATH . '/../../'));
     $command = "php {$oil_path}/oil r tool:send_mail '{$option}' ";
     try {
         exec($command);
     } catch (Exception $e) {
         Log::error($e->getMessage());
     }
     return true;
 }
Ejemplo n.º 6
0
 public static function in_pages($page, $section_id)
 {
     // Start query with main section ID
     try {
         $dbResult = DB::SELECT('ID', 'Title', 'Description')->from('News')->where('Type', $section_id)->order_by('DateCreate', 'dsc')->limit(5)->offset($page * 5)->execute();
         $dbData = $dbResult->as_array();
         return $dbData;
     } catch (\Exception $e) {
         Log::error($e);
         // Redirect to 500 server error;
         return Response::redirect(500);
     }
 }
Ejemplo n.º 7
0
 /**
  * Auth request
  */
 public function request()
 {
     $params = array('oauth_callback' => $this->strategy['oauth_callback']);
     $results = $this->_request('POST', $this->strategy['request_token_url'], $params);
     Log::error('$param:' . var_export($params, true));
     Log::error('rt_url:' . $this->strategy['request_token_url']);
     Log::error('oauth:' . $results['oauth_token']);
     Log::error('oauth_secret:' . $results['oauth_token_secret']);
     Log::error('$results:' . var_export($results, true));
     if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
         session_start();
         $_SESSION['_opauth_twitter'] = $results;
         $this->_authorize($results['oauth_token']);
     }
 }
Ejemplo n.º 8
0
 public function action_send()
 {
     //CSRF対策
     if (!Security::check_token()) {
         throw new HttpInvalidInputException('ページの遷移が正しくありません');
     }
     $val = $this->forge_validation();
     if (!$val->run()) {
         $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');
         return;
     }
     $post = $val->validated();
     $data = $this->build_mail($post);
     //メールの送信
     try {
         //$this->sendmail($data);
         Package::load('email');
         $email = Email::forge();
         $email->from($data['from'], $data['from_name']);
         $email->to($data['to'], $data['to_name']);
         $email->subject($data['subject']);
         $email->body($data['body']);
         $email->send();
         $this->template->title = 'コンタクトフォーム:送信完了';
         $this->template->content = View::forge('form/send');
         $this->template->footer = View::forge('form/footer');
         return;
     } catch (EmailValidationFailedException $e) {
         Log::error('メール検証エラー:' . $e->getmesseage(), __METHOD__);
         $html_error = '<p>メールアドレスに誤りがあります</p>';
     } catch (EmailSendingFailedException $e) {
         Log::error('メール送信エラー:' . $e->getmesseage(), __METHOD__);
         $html_error = '<p>メールを送信できませんでした</p>';
     }
     $this->template->title = 'コンタクトフォーム:送信エラー';
     $this->template->content = View::forge('form/index');
     $this->template->content->set_safe('html_error', $html_error);
     $this->template->footer = View::forge('form/footer');
 }
Ejemplo n.º 9
0
 /**
  * Goes and try's to create a connection to the MongoClient through the Monga Connection class. If a connection
  * cannot be made it tries to attempt a new connection until it has reached its maximum retry's. If this is the
  * case the function throws an exception stating that it cannot currently connect to the MongoDB Client. This code
  * is based off of an issue in the PHP Legacy driver, issue PHP-854. The URL to that issue is:
  *
  * 		https://jira.mongodb.org/browse/PHP-854
  *
  * The workaround to the issue was posted on Nov 14 2013 07:21:18 PM GMT+0000 by Hannes Magnusson.
  *
  * @param 	string 			$dsn		The Information for what mongo client(s) to connect to.
  * @param   array 			$options    All of the options for creating the MongoClient
  * @param   int				$retry		How many times we should try and retry creating a connection
  * @return  \League\Monga\Connection			The connection for the Monga object.
  * @throws \Exception
  */
 protected static function get_connection($dsn, $options, $retry = self::MAX_CONNECTION_RETRY_COUNT)
 {
     try {
         $instance = Monga::connection($dsn, $options);
         return $instance;
     } catch (\Exception $e) {
         Log::error('Exception thrown: (' . __FILE__ . '#' . __LINE__ . '): ' . $e->getMessage());
     }
     if ($retry > 0) {
         $retry--;
         return static::get_connection($dsn, $options, $retry);
     } else {
         throw new \Exception(self::CANNOT_CONNECT_EXCEPTION);
     }
 }