public static function send($option = null) { try { $email = Email::forge(); $email->from(Config::get('email.defaults.from.email'), Config::get('email.defaults.from.name')); $to = $option->to; if (is_string($to)) { $email->to($to); } elseif (is_array($to)) { $email->to(Config::get('email.defaults.from.email'), Config::get('email.defaults.from.name')); $email->bcc($to); } $email->subject(html_entity_decode($option->subject, ENT_QUOTES)); if (!empty($option->attach)) { $email->attach(DOCROOT . $option->attach); } $email->html_body(View::forge('email/' . $option->view, $option->content)); $email->send(); } catch (\EmailSendingFailedException $e) { Log::write('ERROR', $e->getMessage(), 'Send_email'); return false; } catch (\EmailValidationFailedException $e) { Log::write('ERROR', $e->getMessage(), 'Validation_email'); return false; } catch (Exception $e) { Log::write('ERROR', $e->getMessage(), 'Exception'); return false; } return true; }
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); } } }
public static function _init() { static::$crypter = new Crypt_AES(); static::$hasher = new Crypt_Hash('sha256'); // load the config \Config::load('crypt', true); static::$config = \Config::get('crypt', array()); // generate random crypto keys if we don't have them or they are incorrect length $update = false; foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) { if (empty(static::$config[$key]) or strlen(static::$config[$key]) % 4 != 0) { $crypto = ''; for ($i = 0; $i < 8; $i++) { $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff))); } static::$config[$key] = $crypto; $update = true; } } // update the config if needed if ($update === true) { // load the file config \Config::load('file', true); try { \Config::save('crypt', static::$config); chmod(APPPATH . 'config' . DS . 'crypt.php', \Config::get('file.chmod.files', 0666)); } catch (\FileAccessException $e) { // failed to write the config file, inform the user echo \View::forge('errors/crypt_keys', array('keys' => static::$config)); die; } } static::$crypter->enableContinuousBuffer(); static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac'])); }
/** * initialisation and auto configuration */ public static function _init() { $crypter = new Crypt_AES(); $hasher = new Crypt_Hash('sha256'); // load the config \Config::load('crypt', true); static::$defaults = \Config::get('crypt', array()); // generate random crypto keys if we don't have them or they are incorrect length $update = false; foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) { if (empty(static::$defaults[$key]) or strlen(static::$defaults[$key]) % 4 != 0) { $crypto = ''; for ($i = 0; $i < 8; $i++) { $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff))); } static::$defaults[$key] = $crypto; $update = true; } } // update the config if needed if ($update === true) { try { \Config::save('crypt', static::$defaults); } catch (\FileAccessException $e) { // failed to write the config file, inform the user echo \View::forge('errors/crypt_keys', array('keys' => static::$defaults)); die; } } }
public function mysendmail($person, $type) { foreach ($person as $k => $v) { $arr_mail = array(); if ($v['order_id'] == null) { $arr_mail[] = self::get_email_user($v['user_id']); } else { if ($type == 1 or $type == 2 or $type == 3 or $type == 4) { $arr_mail[] = self::get_email_user($v['business_user_id']); $arr_mail[] = self::get_email_user($v['interview_user_id']); } if ($type == 5 or $type == 6 or $type == 7) { $arr_mail[] = self::get_email_user($v['business_user_id']); $arr_mail[] = self::get_email_user($v['agreement_user_id']); } if ($type == 8) { $arr_mail[] = self::get_email_user($v['business_user_id']); } if ($type == 9) { $arr_mail[] = self::get_email_user($v['business_user_id']); $arr_mail[] = self::get_email_user($v['training_user_id']); } } $data = array('person_id' => $v['person_id'], 'uri_base' => Uri::base(), 'uosbo_url' => \Fuel\Core\Config::get('uosbo_url'), 'ss_name' => $v['ss_name'], 'name_kana' => Utility::crop_string($v['name_kana'], 4), 'nametitle' => self::$nametitle[$type]); if (array_filter($arr_mail)) { Utility::sendmail($arr_mail, '求人管理システム', $data, 'email/sendmailperson'); } } }
/** * set common data to template * * @author Luvina * @access public * * @return void */ public function before() { parent::before(); $aryMenuList = Model_Category::find('all'); $this->template->menu = $aryMenuList; $this->template->base_url = Config::get('base_url'); }
public static function _init() { static::$crypter = new Crypt_AES(); static::$hasher = new Crypt_Hash('sha256'); // load the config \Config::load('crypt', true); static::$config = \Config::get('crypt', array()); // generate random crypto keys if we don't have them or they are incorrect length $update = false; foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) { if (empty(static::$config[$key]) || strlen(static::$config[$key]) % 4 != 0) { $crypto = ''; for ($i = 0; $i < 8; $i++) { $crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff))); } static::$config[$key] = $crypto; $update = true; } } // update the config if needed if ($update === true) { try { \Config::save('crypt', static::$config); } catch (\File_Exception $e) { throw new \Exception('Crypt keys are invalid or missing, and app/config/crypt.php could not be written.'); } } static::$crypter->enableContinuousBuffer(); static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac'])); }
public static function generate($uri = null, $variables = array(), $get_variables = array(), $secure = null) { $language = Config::get('language'); if (!empty($uri)) { $language .= '/'; } return Uri::create($language . $uri, $variables, $get_variables, $secure); }
public function action_index() { $pagination = \Fuel\Core\Pagination::forge('projecttasknames', array('pagination_url' => \Fuel\Core\Config::get('pagination.pagination_url', '') . 'admin/projecttasknames/index/', 'total_items' => Model_Projecttaskname::count(), 'per_page' => \Fuel\Core\Config::get('pagination.per_page', 10), 'num_links' => \Fuel\Core\Config::get('pagination.num_links', 10), 'show_first' => \Fuel\Core\Config::get('pagination.show_first', false), 'show_last' => \Fuel\Core\Config::get('pagination.show_last', false), 'uri_segment' => \Fuel\Core\Config::get('pagination.uri_segment', 4))); $data['projecttasknames'] = Model_Projecttaskname::find('all', array('order_by' => array('name' => 'asc'), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)); $data['pagination'] = $pagination; $this->template->title = "Task Types"; $this->template->content = View::forge('admin/projecttasknames/index', $data, false); }
public function post_add() { $model = Model_Blog::forge(); $model->set(Input::post()); $model->set(BLOG_CREATED_DATE, DB::expr('now()')); $model->set(DELETE_FLG, '0'); $model->save(); Response::redirect(Config::get('base_url')); }
public static function get_app_config($name, $option = array()) { $data = array(); $config = Config::get('app.' . $name); foreach ($option as $key) { $data[$key] = $config[$key]; } return !empty($option) ? $data : $config; }
public static function getQRCodeUrl($name, $secret) { $config = \Fuel\Core\Config::load('g2fa', true); $urlencoded_str = urlencode('otpauth://totp/' . $name . '?secret=' . $secret); if (isset($config['title'])) { $urlencoded_str .= urlencode('&issuer=' . urlencode($config['title'])); } return 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=' . $urlencoded_str; }
public function action_index() { $config = \Fuel\Core\Config::get('pagination'); $pagination = \Fuel\Core\Pagination::forge('user_types', $config); $pagination->total_items = Model_User_Type::count(); $data['pagination'] = $pagination; $data['user_types'] = Model_User_Type::find('all', array('order_by' => array(array('name', 'asc')), 'offset' => $pagination->offset, 'limit' => $pagination->per_page)); $this->template->title = "Employee Types » Listing"; $this->template->content = View::forge('admin/user/types/index', $data); }
public function action_index() { $config = \Fuel\Core\Config::get('pagination'); $pagination = \Fuel\Core\Pagination::forge('inventory.units', $config); $pagination->total_items = Model_Inventory_Unit::count(); $data['pagination'] = $pagination; $data['inventory_units'] = Model_Inventory_Unit::find('all', array('order_by' => array(array('name', 'asc')), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)); $this->template->title = "Inventory Units » Listing"; $this->template->content = View::forge('admin/inventory/units/index', $data); }
public function action_index() { $config = \Fuel\Core\Config::get('pagination'); $pagination = \Fuel\Core\Pagination::forge('customers', $config); $pagination->total_items = Model_Customer::count(); $data['customers'] = Model_Customer::find('all', array('limit' => $pagination->per_page, 'offset' => $pagination->offset)); $data['pagination'] = $pagination; $this->template->title = "Customers » Listing"; $this->template->content = View::forge('admin/customers/index.twig', $data); }
public function action_index() { $config = \Fuel\Core\Config::get('pagination'); $pagination = \Fuel\Core\Pagination::forge('settings', $config); $pagination->total_items = Model_Setting::count(); $settings = Model_Setting::find('all', array('order_by' => array(array('setting_title', 'asc')), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)); $data_types = Model_Setting_Data_Type::find('all', array('order_by' => array(array('name', 'asc')))); $this->template->title = "Settings"; $this->template->content = View::forge('admin/settings/index', array('pagination' => $pagination, 'settings' => $settings, 'data_types' => $data_types)); }
/** * */ public function before() { View::set_global('BASE_URL', Config::get('base_url')); // Check if is in maintenance mode if (Config::get('global.MAINTENANCE_MODE')) { // Open maintenance page return Response::redirect('page/maintenance'); } return parent::before(); }
public function action_index() { $config = \Fuel\Core\Config::get('pagination'); $pagination = \Fuel\Core\Pagination::forge('suppliers', $config); $pagination->total_items = Model_Supplier::count(); $data['pagination'] = $pagination; $data['suppliers'] = Model_Supplier::find('all', array('order_by' => array(array('description', 'asc')), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)); $this->template->title = "Suppliers"; $this->template->content = View::forge('admin/suppliers/index', $data); }
public static function fetch($item, $default = null) { if (strpos($item, '.') !== false) { $parts = explode('.', $item); $file = array_shift($parts); self::load($file, $file); return parent::get($item, $default); } else { return parent::get($item, $default); } }
public function getVenueMapping($lat, $lon, $venue_name) { $query = array(); $query['client_id'] = Config::get('foursquare_client_id'); $query['client_secret'] = Config::get('foursquare_client_secret'); $query['v'] = date('Ymd'); $query['intent'] = 'match'; $query['ll'] = $lat . ',' . $lon; $query['query'] = $venue_name; return $this->runRequest('venues/search', $query); }
public function get_highlight_list() { $highlightArr = Config::get('storysetting.highlight'); $sliderArr = [20, 24, 30, 33]; $respArr = []; foreach ($sliderArr as $storyID) { $storyObj = $this->getStoryBaseID($storyID); array_push($respArr, $storyObj->getShort()); } return $respArr; }
public function setUp() { $files = \Fuel\Core\File::read_dir(APPPATH . 'tests/files', 1); foreach ($files as $file => $val) { \Fuel\Core\File::delete_dir(APPPATH . 'tests/files' . DS . $file); } $this->pass = Model_Pass::forge(array('name' => 'test name', 'description' => 'desc', 'logo_text' => 'sample', 'barcode_message' => 'message', 'barcode_format' => 0, 'foreground_color' => 'rgb(0,0,0)', 'background_color' => 'rgb(1,1,1)', 'label_color' => 'rgb(2,2,2)')); $this->pass->save(); \Fuel\Core\Config::set('pass.files_dir', APPPATH . 'tests/files'); $this->path = \Fuel\Core\Config::get('pass.files_dir'); \Fuel\Core\Config::set('pass.pkpasses_dir', APPPATH . 'tests/passes'); }
public static function bootstrap() { //Make sure orm is loaded first as we need this \Fuel\Core\Package::load('orm'); //For fuel v1 add to the finder path if (class_exists('\\Fuel\\Core\\Finder')) { \Fuel\Core\Finder::instance()->add_path(__DIR__ . DS . '..' . DS . '..'); } \Fuel\Core\Config::load('ethanol', true); \Fuel\Core\Config::load('ethanol_permissions', true); \Fuel\Core\Lang::load('ethanol', 'ethanol'); Auth::instance()->register_driver(array('database', 'facebook')); }
public function setUp() { $files = \Fuel\Core\File::read_dir(APPPATH . 'tests/files', 1); foreach ($files as $file => $val) { \Fuel\Core\File::delete_dir(APPPATH . 'tests/files' . DS . $file); } $this->pass = Model_Pass::forge(array('name' => 'test name', 'description' => 'desc', 'logo_text' => 'sample', 'barcode_message' => 'message', 'barcode_format' => 0, 'offer_label' => 'samaplelabel', 'offer_value' => 'samplevalue')); $this->pass->save(); \Fuel\Core\Config::set('pass.files_dir', APPPATH . 'tests/files'); $this->path = \Fuel\Core\Config::get('pass.files_dir'); $this->manager = new Pass_File_Manager($this->pass); \Fuel\Core\File::copy(APPPATH . 'tests/certificate.p12', $this->manager->file_path('certificate.p12')); }
public function set_path() { $path_config = Config::get('app.path'); $base_url = Config::get('base_url'); if (!defined('_PATH_NO_ICON_')) { define('_PATH_NO_ICON_', $base_url . $path_config['no_icon']); define('_PATH_NO_IMAGE_', $base_url . $path_config['no_image']); define('_PATH_ICON_', $base_url . $path_config['icon']); define('_PATH_CATEGORY_', $base_url . $path_config['category']); define('_PATH_PRODUCT_', $base_url . $path_config['product']); define('_PATH_ROOT_PHOTO_', $base_url . $path_config['root_photo']); define('_PATH_PHOTO_', $base_url . $path_config['photo']); } }
public function action_index() { $pagination = \Fuel\Core\Pagination::forge('userprojects', array('pagination_url' => \Fuel\Core\Config::get('pagination.pagination_url', '') . 'user/projects/index/', 'total_items' => Model_Project::count(array('related' => array('customer', 'project_members'), 'where' => array(array('project_members.user_id', $this->current_user->id)))), 'per_page' => \Fuel\Core\Config::get('pagination.per_page', 10), 'num_links' => \Fuel\Core\Config::get('pagination.num_links', 10), 'uri_segment' => \Fuel\Core\Config::get('pagination.uri_segment', 4), 'show_first' => \Fuel\Core\Config::get('pagination.show_first', false), 'show_last' => \Fuel\Core\Config::get('pagination.show_last', false))); $view = Fuel\Core\View::forge('user/projects/index'); $view->set_global('user_is_admin', false); $view->set_global('projects', Model_Project::find('all', array('related' => array('customer', 'project_members'), 'order_by' => array('customer.name' => 'asc', 'name' => 'asc'), 'where' => array(array('project_members.user_id', $this->current_user->id)), 'limit' => $pagination->per_page, 'offset' => $pagination->offset))); $view->set_global('customers', \Fuel\Core\Arr::assoc_to_keyval(Model_Customer::find('all', array('order_by' => array('name' => 'asc'))), 'id', 'name')); $view->set_global('project_statuses', Model_Projectstatus::find('all', array('order_by' => array(array('description', 'asc'))))); $view->set_global('selected_status_id', \Fuel\Core\Config::get('projects.default_status_id', 0)); $view->set_global('user_is_admin', $this->check_user_is_admin()); $view->set_global('project_status_id', 0); $view->set_global('selected_status_id', 0); $view->set_global('pagination', $pagination, false); $view->set_global('admin', false); $this->template->title = 'My Projects'; $this->template->content = $view; }
public function get() { $arguments = func_get_args(); $requestName = array_shift($arguments); if (array_key_exists($requestName, $this->apiCalls)) { $config = $this->apiCalls[$requestName]; $query = array(); $query['oauth_token'] = Config::get('eventbrite_access_token'); $query['v'] = Config::get('eventbrite_v'); foreach ($arguments as $key => $argument) { $query[$config['args'][$key]] = $argument; } return $this->runRequest($config['path'], $query); } else { die('Invalid API request: ' . $requestName); } }
public static function routes() { $route = '_status'; Router::add($route, new Route($route, function ($request) { // ignore this transaction Transaction::ignore(); // load a config $conf = Config::load('newrelic-ping'); // ping the urls $pinger = new Pinger($conf['urls'], $conf['base_host']); $res = $pinger->ping(); // add path to lookup view Finder::instance()->add_path(realpath(rtrim(__DIR__, '/') . '/../')); // build a response and return it return new Response(View::forge('_newrelic-status', ['result' => $res]), $res->getResultStatusCode()); })); }
public function signature($manifest_path, $signature_path) { $private_key = openssl_pkey_get_private($this->certs['pkey'], $this->cert_password); if (file_exists(\Fuel\Core\Config::get('pass.WWDR_cert'))) { try { openssl_pkcs7_sign($manifest_path, $signature_path, $this->cert_data, $private_key, array(), PKCS7_BINARY | PKCS7_DETACHED, \Fuel\Core\Config::get('pass.WWDR_cert')); } catch (Exception $e) { $this->error = 'Certificate error.'; return null; } } else { $this->error = 'WWDR Intermediate Certificate does not exist.'; return false; } $signature = file_get_contents($signature_path); $signature = $this->convert_PEM2DER($signature); return $signature; }
public function __construct($request) { parent::__construct($request); // Using Native PHP Session. If there's ANY problem with those sessions (bug, security breach, etc), see Sébastien Juroszek. session_start(); // Taking the lang frm the URL and removing it from the URL $this->lang = $request->method_params[0]; unset($request->route->segments[2]); $request->route->segments = array_values($request->route->segments); unset($request->route->method_params[0]); $request->route->method_params = array_values($request->route->method_params); unset($request->method_params[0]); $request->method_params = array_values($request->method_params); // Setting the current language if (Lang::get_lang() != $this->lang) { Config::set("language", $this->lang); } }