/** * Setup the test */ public function setup() { \Package::load('hybrid'); \Config::load('autho', 'autho'); \Config::set('autho.hash_type', 'sha1'); \Config::set('autho.salt', '12345'); }
public function before() { parent::before(); // Load Exchange package \Package::load('Skills'); $this->skills = \Skills\Skills::forge(); }
/** * */ public function action_index() { Package::load('oil'); \Oil\Generate_Scaffold::forge(['page1', 'title:string', 'content:text'], "orm"); $this->title = 'Backend Dashboard'; $this->template->content = Presenter::forge('backend/page'); }
public static function sendEmail(EmailOptions $emailOptions) { // Load FuelPHP Email Package \Package::load("email"); // Create an Email instance $email = \Email\Email::forge(); // Set the "email to" foreach ($emailOptions->to as $to) { $email->to($to); } // Set the subject $email->subject($emailOptions->subject); // And set the body. $view = \View::forge('emails/' . $emailOptions->emailTypeName, $emailOptions->vars); $email->html_body($view); // Try sending the email try { $response = $email->send(); } catch (\EmailValidationFailedException $e) { $response = false; } catch (\EmailSendingFailedException $e) { $response = false; } catch (\Exception $e) { $response = false; } return $response; }
public function post_parse_payments() { $config = array('path' => DOCROOT . 'uploads/csv', 'randomize' => true, 'ext_whitelist' => array('csv')); Upload::process($config); if (Upload::is_valid()) { //Upload::save(); $file = Upload::get_files(); $uploaded_file = $file[0]['file']; Package::load("excel"); $excel = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')->setEnclosure('"')->setLineEnding("\n")->setSheetIndex(0)->load($uploaded_file); $objWorksheet = $excel->setActiveSheetIndex(0); $highestRow = $objWorksheet->getHighestRow(); $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); //read from file for ($row = 1; $row <= $highestRow; ++$row) { $file_data = array(); for ($col = 0; $col <= $highestColumnIndex; ++$col) { $value = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); $file_data[$col] = trim($value); } $result[] = $file_data; } print_r($result); } else { print "Invalid uploads"; } }
function logger($level, $msg, $method = null) { static $labels = array(100 => 'DEBUG', 200 => 'INFO', 250 => 'NOTICE', 300 => 'WARNING', 400 => 'ERROR', 500 => 'CRITICAL', 550 => 'ALERT', 600 => 'EMERGENCY', 700 => 'ALL'); // make sure $level has the correct value if (is_int($level) and !isset($labels[$level]) or is_string($level) and !array_search(strtoupper($level), $labels)) { throw new \FuelException('Invalid level "' . $level . '" passed to logger()'); } // get the levels defined to be logged $loglabels = \Config::get('log_threshold'); // bail out if we don't need logging at all if ($loglabels == \Fuel::L_NONE) { return false; } // if profiling is active log the message to the profile if (\Config::get('profiling')) { \Console::log($method . ' - ' . $msg); } // if it's not an array, assume it's an "up to" level if (!is_array($loglabels)) { $a = array(); foreach ($labels as $l => $label) { $l >= $loglabels and $a[] = $l; } $loglabels = $a; } // do we need to log the message with this level? if (!in_array($level, $loglabels)) { return false; } !class_exists('Log') and \Package::load('log'); return \Log::instance()->log($level, (empty($method) ? '' : $method . ' - ') . $msg); }
/** * Initialize class and forge a Sprockets Instance */ public function __construct() { !\Package::loaded('sprockets') and \Package::load('sprockets'); // When in console mode, DOCROOT is the path to the project root, not the public/ $config = array('asset_compile_dir' => DOCROOT . 'public/assets/', 'force_minify' => true); static::$sprockets = \Sprockets::forge('default', $config); }
public function create_user($userdata) { $password = \Arr::get($userdata, 'password', null); $email = \Arr::get($userdata, 'email', null); if (is_null($password) || is_null($email)) { Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email); throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid')); } $user = Auth_Driver::get_core_user($email); $security = new Model_User_Security(); //Generate a salt $security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random()); $security->password = Hasher::instance()->hash($password, $security->salt); if (\Config::get('ethanol.activate_emails', false)) { $keyLength = \Config::get('ethanol.activation_key_length'); $security->activation_hash = Random::instance()->random($keyLength); $user->activated = 0; //Send email \Package::load('email'); //Build an array of data that can be passed to the email template $emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash))); $email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send(); } else { $user->activated = 1; $security->activation_hash = ''; } $user->security = $security; $user->save(); $user->clean_security(); return $user; }
public function before() { parent::before(); // Load Slills package \Package::load('Skills'); $this->skillsPackage = \Skills\Skills::forge(); }
public function before() { parent::before(); $this->template->title = "Rodasnet.com"; $this->template->pageTitle = "Get in contact with Daniel."; // Load Contacts package \Package::load('Contacts'); $this->ServiceContacts = \Contacts\Contacts::forge(); }
public function action_recover($hash = null) { if (Input::Method() === "POST") { if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) { // generate a recovery hash $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id; // and store it in the user profile \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username); // send an email out with a reset link \Package::load('email'); $email = \Email::forge(); $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>'; // use a view file to generate the email message $email->html_body($html); // give it a subject $email->subject(\Settings::Get('site_name') . ' Password Recovery'); // GET ADMIN EMAIL FROM SETTINGS? $admin_email = Settings::get('admin_email'); if (empty($admin_email) === false) { $from = $admin_email; } else { $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false))); } $email->from($from); $email->to($user->email, $user->fullname); // and off it goes (if all goes well)! try { // send the email $email->send(); Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!'); } catch (\Exception $e) { Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email); \Response::redirect_back(); } } else { Session::Set('error', 'Sorry there is not a matching email!'); } } elseif (empty($hash) === false) { $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current()); $user = substr($hash, 44); if ($user = \Model\Auth_User::find_by_id($user)) { // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) { // invalidate the hash \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username); // log the user in and go to the profile to change the password if (\Auth::instance()->force_login($user->id)) { Session::Set('current_password', Auth::reset_password($user->username)); Response::Redirect(Uri::Create('user/settings')); } } } Session::Set('error', 'Invalid Hash!'); } $this->template->content = View::forge('login/recover'); }
/** * Overrides uc_product_handler_field_weight::render(). */ public function render($values) { $package = Package::load($values->{$this->aliases['package_id']}); if ($this->options['format'] == 'numeric') { return $package->weight; } if ($this->options['format'] == 'uc_weight') { return uc_weight_format($package->weight, $package->weight_units); } }
protected function 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(); }
public function __construct($order) { \Package::load('email'); // Load email addresses from config (these will be bcc receivers) \Config::load('auto_response_emails', 'autoresponders'); $bcc = \Config::get('autoresponders.order_emails', false); if (!$bcc) { $bcc = \Config::get('autoresponders.default_emails', false); } $this->emailData = $this->createEmailData($order, $bcc); }
public function action_get_one($id = 1) { $timeStart = microtime(true); $memoryStart = memory_get_usage(); Package::load('orm'); $post = Model_Fuel_Orm_Post::find($id); echo $post->title . '<br>' . "\n"; $comment = array_shift($post->comments); echo $comment->body . '<br>' . "\n"; echo microtime(true) - $timeStart . " secs<br>\n"; echo (memory_get_usage() - $memoryStart) / 1024 . " KB\n"; }
public function action_view($slug = null) { is_null($slug) and Response::redirect('blog/post'); $related = in_array('post', \Config::get('comment')) ? array('published_comments', 'author', 'category') : array('author', 'category'); $data['post'] = Model_Post::find('first', array('where' => array(array('slug' => $slug)), 'related' => $related)); if (!$data['post']) { Session::set_flash('error', 'Could not find post with slug: ' . $slug); Response::redirect('blog/post'); } // Is the user sending a comment? If yes, process it. if (Input::method() == 'POST') { $val = \Comment\Model_Comment::validate('create'); if ($val->run()) { $comment = \Comment\Model_Comment::forge(array('name' => Input::post('name'), 'email' => Input::post('email'), 'content' => Input::post('content'), 'status' => 'pending', 'post_id' => $data['post']->id)); if ($comment and $comment->save()) { // Manually loading the Email package \Package::load('email'); // Sending an email to the post's author $email = \Email::forge(); $email->to($data['post']->author->email, $data['post']->author->username); $email->subject('New comment'); $email->body(\View::forge('comment/email', array('comment' => $comment))->render()); $email->send(); unset($email); if ($data['post']->published_comments) { // Sending an email for all commenters $email = \Email::forge(); $emails = array(); foreach ($data['post']->published_comments as $published_comment) { $emails[$published_comment->email] = '\'' . $published_comment->name . '\''; } $email->to($emails); $email->subject('New comment'); $email->body(\View::forge('comment/email_other', array('comment' => $comment, 'post' => $data['post']), false)->render()); $email->send(); unset($email); } Session::set_flash('success', e('Your comment has been saved, it will' . ' be reviewed by our administrators')); } else { Session::set_flash('error', e('Could not save comment.')); } } else { Session::set_flash('error', $val->error()); } } $this->template->title = "Post"; $this->template->content = View::forge('post/view', $data); $this->template->content->set('post_content', $data['post']->content, false); }
/** * Setup the test */ public function setup() { \Package::load('hybrid'); $acl = Acl::make('mock'); $acl->add_roles('guest'); $acl->add_resources(array('blog', 'forum', 'news')); $acl->allow('guest', array('blog'), 'view'); $acl->deny('guest', 'forum'); try { \Database_Connection::instance(\Config::get('db.active'))->connect(); } catch (\Database_Exception $e) { // in case when list table is not supported by Database Connection $this->markTestSkipped('User table is not available'); } }
public static function sendmail($data) { Package::load('email'); $items = array('from_address', 'from_name', 'to_address', 'to_name', 'subject'); foreach ($items as $item) { if (isset($data[$item]) && preg_match('/[\\r\\n]/u', $data[$item]) === 1) { throw new EmailValidationFailedException('One or more email headers did not pass validation: ' . $item); } } $email = Email::forge(); $email->from($data['from_address'], isset($data['from_name']) ? $data['from_name'] : null); $email->to($data['to_address'], isset($data['to_name']) ? $data['to_name'] : null); $email->subject($data['subject']); $email->body($data['body']); $email->send(); }
/** * Bootstrap the fuel environment and load the cmf package */ protected static function bootstrap() { $dir = rtrim(realpath(__DIR__ . '/../../../../../../'), '/') . '/'; error_reporting(-1); ini_set('display_errors', 1); define('DOCROOT', $dir . 'public/'); define('APPPATH', $dir . 'fuel/app/'); define('PKGPATH', $dir . 'fuel/packages/'); define('COREPATH', $dir . 'fuel/core/'); // Get the start time and memory for use later defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true)); defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage()); // Boot the app and the CMF require APPPATH . 'bootstrap.php'; \Package::load(array('oil', 'cmf')); // Instantiate CMF's fuel task class include CMFPATH . 'tasks/cmf.php'; static::$task = new \Fuel\Tasks\Cmf(); }
private function createGeoJsonData($code) { Package::load('Foursquare'); $this->FoursquareClient = new \Foursquare\Client(); // get locations surrounding lat/lng geo point. $response = $this->FoursquareClient->get('getAccessToken', $code, 'authorization_code', 'https://cartodbfoursquareheatmap.herokuapp.com/'); if (!isset($response->access_token)) { return false; } // create a cache filename based on user access token $cache_filename = substr(md5($response->access_token), 0, 32) . '.json'; // load data from cache if possible try { $data = Cache::get($cache_filename); return $cache_filename; } catch (\CacheNotFoundException $e) { /* Catching the CacheNotFoundException exception will catch both CacheNotFoundException and CacheExpiredException. Use this when catching the exception. */ return $this->loadCheckins($cache_filename, $response->access_token); } }
/** * @param string|array $names * @param boolean $footer * @return boolean */ public static function package($names, $footer = FALSE) { if (!is_array($names)) { $names = [$names]; } foreach ($names as $name) { $package = Package::load($name); if ($package === NULL) { continue; } foreach ($package as $item) { switch ($item['type']) { case 'css': static::$css[$item['handle']] = $item; break; case 'js': $item['footer'] = (bool) $footer; static::$js[$item['handle']] = $item; break; } } } return TRUE; }
<?php /** * Access: role based permissions library for FuelPHP - depends on Warden. * * @package Access * @subpackage Access * @version 2.0 * @author Jordan Kapelner * @license MIT License * @copyright (c) 2013 Jordan Kapelner */ /* * Make sure the dependency packages are loaded. */ Package::load(array('warden')); Autoloader::add_core_namespace('Access'); Autoloader::add_classes(array('Access\\Access' => __DIR__ . '/classes/access.php')); Config::load('access', true);
/** * Change user password * * @access public * @return void */ public function action_password() { \View::set_global('title', 'Forgot Password'); if (\Input::post('forgot')) { $val = \User\Controller_Validate::forge('forgot_password'); if ($val->run()) { // Get POST values $identity = \Input::post('identity', ''); if (\Sentry::user_exists($identity)) { try { // reset the password $reset = \Sentry::reset_password($identity); if ($reset) { $customer_email = $reset['email']; // Load email package \Package::load('email'); // Load email addresses from config (these will be bcc receivers) \Config::load('auto_response_emails', true); $bcc = \Config::get('autoresponders.forgot_password_emails'); if (!$bcc) { $bcc = \Config::get('autoresponders.default_emails'); } $settings = \Config::load('autoresponder.db'); $email_data = array('site_title' => $settings['company_name'], 'customer_identity' => $identity, 'reset_link' => \Uri::front_create('user/reset_password/' . $reset['link'])); $email = \Email::forge(); $email->to($customer_email); $email->from(\Config::get('auto_response_emails.autoresponder_from_email'), $settings['company_name']); if ($bcc) { $email->bcc($bcc); } $email->subject($email_data['site_title'] . ' - Forgot Password'); $email_html = \Theme::instance()->view('views/_email/forgot_password')->set('email_data', $email_data, false); $email->html_body($email_html); try { $email->send(); \Messages::success('You have been sent an email to reset your password.'); } catch (\EmailValidationFailedException $e) { \Messages::error('Error while sending email.'); } catch (\EmailSendingFailedException $e) { \Messages::error('Error while sending email.'); } \Response::redirect(\Input::referrer(\Uri::front_create('/'))); } else { \Messages::error('There was a problem while trying to change your password. Please try again.'); } } catch (\Sentry\SentryException $e) { // show validation errors //\Messages::error('<h4>There was an error while trying to create user</h4>'); $errors = $e->getMessage(); \Messages::error($errors); } } else { \Messages::error('There doesn`t appear to be an account associated with this email address. Try a different email address or register for a new account on the homepage.'); } } else { if ($val->error() != array()) { // show validation errors //\Messages::error('<h4>There was an error while trying to create user</h4>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } if (\Input::is_ajax()) { echo \Theme::instance()->view($this->view_dir . 'forgot_password'); } else { if (isset($val)) { \View::set_global('validation', $val, false); } \Theme::instance()->set_partial('content', $this->view_dir . 'single_forgot_password'); } }
public function action_recover($hash = null) { /* * https://myturbotax.intuit.com/account-recovery?offering_id=Intuit.cg.myturbotax&username=daniel.rodas1&locale=en-Us&offering_env=prd&confirmation_id=910855&namespace_id=50000003 */ //email use a link // was the lostpassword form posted? if (\Input::method() == 'POST') { // do we have a posted email address? if ($email = \Input::post('email')) { // do we know this user? if ($user = \Model\Auth_User::find_by_email($email)) { // generate a recovery hash $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id; // and store it in the user profile \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username); \Package::load('email'); $email = \Email::forge(); $data = array(); $hash = Crypt::encode($hash, 'R@nd0mK~Y'); $data['url'] = \Uri::create('user/password/recover/' . $hash); $data['user'] = $user; // use a view file to generate the email message $email->html_body(View::forge('user/password/email', $data)); // give it a subject $email->subject('RN | WJS Password Recovery'); // $email->subject(__('user.login.password-recovery')); // add from- and to address // $from = \Config::get('application.email-addresses.from.website'); // $from = array('email' => '*****@*****.**', 'name' => 'RN | Wall Street Journal'); // $email->from($from['email']); $email->from('*****@*****.**'); $email->to($user->email); // and off it goes (if all goes well)! try { // send the email // $email->send(); \Messages::success('Please check your email for instructions to reset your password'); // \Messages::success(__('user.login.recovery-email-send')); \Response::redirect('user/password/confirm/' . $user->id); } catch (\EmailValidationFailedException $e) { \Messages::error('INVALID EMAIL !'); \Messages::error($e->getMessage()); // \Messages::error(__('user.login.invalid-email-address')); \Response::redirect_back(); } catch (\Exception $e) { // log the error so an administrator can have a look logger(\Fuel::L_ERROR, '*** Error sending email (' . __FILE__ . '#' . __LINE__ . '): ' . $e->getMessage()); // \Messages::error($e->getMessage()); \Messages::error('ERROR SENDING EMAIL !'); // \Messages::error(__('user.login.error-sending-email')); } } } else { // inform the user and fall through to the form \Messages::error(__('user.login.error-missing-email')); } // inform the user an email is on the way (or not ;-)) \Messages::info(__('user.login.recovery-email-send')); \Response::redirect_back(); } elseif ($hash !== null) { $hash = Crypt::decode($hash, 'R@nd0mK~Y'); // get the userid from the hash $user = substr($hash, 44); // and find the user with this id if ($user = \Model\Auth_User::find_by_id($user)) { // do we have this hash for this user, and hasn't it expired yet (we allow for 24 hours response)? if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) { // invalidate the hash \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username); // log the user in and go to the profile to change the password if (\Auth::instance()->force_login($user->id)) { // \Messages::info('LOGGED IN'); $tempPass = \Auth::instance()->reset_password($user->username); if ($tempPass) { // \Messages::info(__('user.login.password-recovery-accepted')); \Messages::info("Your temporary password is : {$tempPass} "); \Response::redirect('backend/account/index/password'); } else { return 'Something went wrong resetting password'; // something wrong with the hash // \Messages::error(__('user.login.recovery-hash-invalid')); // \Response::redirect_back(); } } } } // something wrong with the hash \Messages::error(__('user.login.recovery-hash-invalid')); \Response::redirect_back(); } else { // display the login page $this->template->content = View::forge('user/password/recover'); } }
<?php /** * Part of the Sentry package for FuelPHP. * * @package Sentry * @version 1.0 * @author Cartalyst LLC * @license MIT License * @copyright 2011 Cartalyst LLC * @link http://cartalyst.com */ namespace Fuel\Migrations; \Package::load('sentry'); class Install_Sentry_Auth { public function up() { \Config::load('sentry', true); \DBUtil::create_table(\Config::get('sentry.table.users'), array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'username' => array('constraint' => 50, 'type' => 'varchar'), 'email' => array('constraint' => 50, 'type' => 'varchar'), 'password' => array('constraint' => 81, 'type' => 'varchar'), 'password_reset_hash' => array('constraint' => 81, 'type' => 'varchar'), 'temp_password' => array('constraint' => 81, 'type' => 'varchar'), 'remember_me' => array('constraint' => 81, 'type' => 'varchar'), 'activation_hash' => array('constraint' => 81, 'type' => 'varchar'), 'last_login' => array('constraint' => 11, 'type' => 'int'), 'ip_address' => array('constraint' => 50, 'type' => 'varchar'), 'updated_at' => array('constraint' => 11, 'type' => 'int'), 'created_at' => array('constraint' => 11, 'type' => 'int'), 'status' => array('constraint' => 1, 'type' => 'tinyint'), 'activated' => array('contsraint' => 1, 'type' => 'tinyint')), array('id')); \DBUtil::create_table(\Config::get('sentry.table.users_metadata'), array('user_id' => array('constraint' => 11, 'type' => 'int'), 'first_name' => array('constraint' => 50, 'type' => 'varchar'), 'last_name' => array('constraint' => 50, 'type' => 'varchar')), array('user_id')); \DBUtil::create_table(\Config::get('sentry.table.groups'), array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'name' => array('constraint' => 200, 'type' => 'varchar'), 'level' => array('constraint' => 11, 'type' => 'int'), 'is_admin' => array('constraint' => 1, 'type' => 'tinyint')), array('id')); \DBUtil::create_table(\Config::get('sentry.table.users_suspended'), array('id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true), 'login_id' => array('constraint' => 50, 'type' => 'varchar'), 'attempts' => array('constraint' => 50, 'type' => 'int'), 'ip' => array('constraint' => 25, 'type' => 'varchar'), 'last_attempt_at' => array('constraint' => 11, 'type' => 'int'), 'suspended_at' => array('constraint' => 11, 'type' => 'int'), 'unsuspend_at' => array('constraint' => 11, 'type' => 'int')), array('id')); \DBUtil::create_table(\Config::get('sentry.table.users_groups'), array('user_id' => array('constraint' => 11, 'type' => 'int'), 'group_id' => array('constraint' => 11, 'type' => 'int'))); } public function down() { \Config::load('sentry', true); \DBUtil::drop_table(\Config::get('sentry.table.users')); \DBUtil::drop_table(\Config::get('sentry.table.groups'));
/** * Send email * * @access public * @param object $order = Order object * @param array of objects $products = Products from order * @param string $type = Type of email to send * @return void */ public function send_email($order = false, $products = false, $type = 'job') { // Send email to user \Package::load('email'); // Load email addresses from config (these will be bcc receivers) \Config::load('auto_response_emails', 'autoresponders'); $bcc = \Config::get('autoresponders.order_emails', false); if (!$bcc) { $bcc = \Config::get('autoresponders.default_emails', false); } $email_data = array('order' => $order, 'products' => $products, 'site_title' => \Config::get('site_title')); $email = \Email::forge(); $email->to($order['email'], ucwords($order['first_name'] . ' ' . $order['last_name'])); if ($bcc) { $email->bcc($bcc); } $email->subject($email_data['site_title'] . ' - Your Order'); // Set correct email view $email_view = $type == 'credits' ? 'order_credits' : 'order'; $email_html = \Theme::instance()->view('views/_email/' . $email_view)->set('email_data', $email_data, false); $email->html_body($email_html); try { $email->send(); \Messages::success('A copy of your request has been sent to ' . $order['email'] . ' for your own reference.'); } catch (\EmailValidationFailedException $e) { \Messages::error('Error while sending email.'); } catch (\EmailSendingFailedException $e) { \Messages::error('Error while sending email.'); } }
/** * Catch IPN response from PayPal * * @access public * @return void */ public function action_ipn() { \Package::load('paypalipn'); $post = \Input::post(); $admin_email = '*****@*****.**'; if (isset($post['invoice']) || is_numeric($post['invoice'])) { if ($order = \Order\Model_Order::find_one_by_id($post['invoice'])) { $order_info = $this->order_info($post['invoice']); //$validate_order['mc_currency'] = strtoupper($order['currency']); $validate_order['mc_currency'] = "AUD"; $validate_order['mc_gross'] = $order_info['grand_total_price']; $response = \PaypalIpn::forge()->validate($validate_order); $response_check = $response !== false; // @mail($admin_email, \Config::get('site_title', 'Giant Invitation Australia') . ' Pre response ' . $response['invoice'], // 'Order id : ' . $response['invoice'] . "\n" . // 'Response:' . print_r($response, true) . "\n" . // 'Check:' . $response_check); $payment = \Payment\Model_Payment::forge(); /* [mc_gross] => 527.00 [invoice] => 9 [protection_eligibility] => Eligible [address_status] => confirmed [item_number1] => [tax] => 0.00 [item_number2] => [payer_id] => 2AY578XVRY42G [address_street] => 1 Main St [payment_date] => 05:19:51 Dec 20, 2012 PST [payment_status] => Completed [charset] => windows-1252 [address_zip] => 95131 [mc_shipping] => 0.00 [mc_handling] => 0.00 [first_name] => Djordje [mc_fee] => 20.90 [address_country_code] => US [address_name] => Djordje Dimitrijev [notify_version] => 3.7 [custom] => [payer_status] => verified [business] => s01_1354717870_biz@eximius-solutions.com [address_country] => United States [num_cart_items] => 2 [mc_handling1] => 0.00 [mc_handling2] => 0.00 [address_city] => San Jose [verify_sign] => Amjz0My6wXvXmjP5pfTStQO3QZ2QA4.Ti6ln42PKcmRKuS-ZegoVx6nF [payer_email] => b01_1354717574_per@eximius-solutions.com [mc_shipping1] => 0.00 [mc_shipping2] => 0.00 [tax1] => 0.00 [tax2] => 0.00 [txn_id] => 3AR12649JA9996934 [payment_type] => instant [last_name] => Dimitrijev [address_state] => CA [item_name1] => Fujiyama [receiver_email] => s01_1354717870_biz@eximius-solutions.com [item_name2] => Musala [payment_fee] => [quantity1] => 2 [quantity2] => 1 [receiver_id] => W4MYKU8N4SVHS [txn_type] => cart [mc_gross_1] => 398.00 [mc_currency] => EUR [mc_gross_2] => 129.00 [residence_country] => US [test_ipn] => 1 [transaction_subject] => Shopping CartFujiyamaMusala [payment_gross] => [ipn_track_id] => 72c4d71c8638a */ if ($response !== false) { $json_response = json_encode($response); $payment->order_id = $response['invoice']; $payment->total_price = $response['mc_gross']; $payment->method = 'paypal'; $payment->status = $response['payment_status']; $payment->response = $json_response; if (isset($response['pending_reason'])) { $payment->status_detail = $response['pending_reason']; } if (strtolower($response['payment_status']) == 'completed') { // Send email /*$emailer = new \PaymentProccess\PaymentEmailer($order); $emailer->send();*/ $emailer = new \Autorespondertrigger\Trigger(); $emailer->sendOrderPaymentReceivedPaypalCredit($order); $order->total_price = $order_info['total_price']; $order->paymentmethod = 'N/A'; if (isset($order->payments[0]->method)) { $order->paymentmethod = $order->payments[0]->method; } // Create redemption code ( if order is sample order - this will be checked in RedemptionCodeSaverClass) $redemptionCodeSaver = new \DiscountCodeApplier\RedemptionCodeSaver($order); $redemptionCodeSaver->save(); } else { logger(\Fuel::L_INFO, 'PayPal IPN - Pending order. Order ID: ' . $response['invoice'] . '. - ' . $json_response); @mail($admin_email, \Config::get('site_title', 'Giant Invitation Australia') . ' | PayPal IPN - Pending order. Order ID: ' . $response['invoice'], 'PayPal IPN - Pending order. Order ID: ' . $response['invoice'] . "\n" . print_r($response, true)); } } else { $payment->order_id = $post['invoice']; $payment->total_price = $post['mc_gross']; $payment->method = 'paypal'; $payment->status = 'Pending'; $payment->response = json_encode($post); // Log order as failed logger(\Fuel::L_INFO, 'PayPal IPN - Failed order. Order ID: ' . $response['invoice'] . '. - ' . $json_response); @mail($admin_email, \Config::get('site_title', 'Giant Invitation Australia') . ' | PayPal IPN - Failed order. Order ID: ' . $response['invoice'], 'PayPal IPN - Failed order. Order ID: ' . $response['invoice'] . "\n" . print_r($response, true)); } // Save payment to database try { $payment->save(); } catch (\Database_Exception $e) { logger(\Fuel::L_INFO, 'PayPal IPN - error during inserting data into the database. Order ID: ' . $response['invoice'] . '. - ' . $json_response); @mail($admin_email, \Config::get('site_title', 'My Shortlist') . ' | PayPal IPN - DB error. Order ID: ' . $response['invoice'], 'PayPal IPN - error during inserting data into the database. Order ID: ' . $response['invoice'] . "\n" . print_r($response, true)); } } else { logger(\Fuel::L_INFO, 'PayPal IPN - error. There is no order with ID: ' . $post['invoice'] . '. - ' . json_encode($post)); @mail($admin_email, \Config::get('site_title', 'My Shortlist') . ' | PayPal IPN - error. There is no order with ID: ' . $post['invoice'], 'PayPal IPN - there is no order with ID: ' . $post['invoice'] . "\n" . print_r($post, true)); } } else { logger(\Fuel::L_INFO, 'PayPal IPN - error. Missing Order ID. - ' . json_encode($post)); @mail($admin_email, \Config::get('site_title', 'My Shortlist') . ' | PayPal IPN - error. Missing Order ID.', 'PayPal IPN - Missing Order ID.' . "\n" . print_r($post, true)); } }
/** * Always load packages, modules, classes, config & language files set in always_load.php config * * @param * array what to autoload */ public static function always_load($array = null) { is_null($array) and $array = \Config::get('always_load', array()); isset($array['packages']) and \Package::load($array['packages']); isset($array['modules']) and \Module::load($array['modules']); if (isset($array['classes'])) { foreach ($array['classes'] as $class) { if (!class_exists($class = \Str::ucwords($class))) { throw new \FuelException('Class ' . $class . ' defined in your "always_load" config could not be loaded.'); } } } /** * Config and Lang must be either just the filename, example: array(filename) * or the filename as key and the group as value, example: array(filename => some_group) */ if (isset($array['config'])) { foreach ($array['config'] as $config => $config_group) { \Config::load(is_int($config) ? $config_group : $config, is_int($config) ? true : $config_group); } } if (isset($array['language'])) { foreach ($array['language'] as $lang => $lang_group) { \Lang::load(is_int($lang) ? $lang_group : $lang, is_int($lang) ? true : $lang_group); } } }
/** * send reset password email * * @param array $data * @return mixed */ public static function sendResetPasswordEmail(array $data = array()) { if (!isset($data['account_email'])) { return false; } $query = static::query()->where('account_email', $data['account_email']); if ($query->count() > 0) { $row = $query->get_one(); unset($query); if ($row->account_status == '0') { return \Lang::get('account_was_disabled') . ' : ' . $row->account_status_text; } $cfg_member_confirm_wait_time = \Model_Config::getval('member_confirm_wait_time') * 60; // check confirm wait time. you need to wait until 'wait time' passed to send reset password request again. if ($row->account_confirm_code != null && time() - $row->account_confirm_code_since <= $cfg_member_confirm_wait_time) { return \Lang::get('account_reset_password_please_wait_until', array('wait_til_time' => date('d F Y H:i:s', $row->account_confirm_code_since + \Model_Config::getval('member_confirm_wait_time') * 60))); } $account_new_password = \Str::random('alnum', 10); $account_confirm_code = \Str::random('alnum', 5); $account_confirm_code_since = time(); $email_content = \Extension\EmailTemplate::readTemplate('reset_password1.html'); $email_content = str_replace("%username%", \Security::htmlentities($row->account_username), $email_content); $email_content = str_replace("%link_confirm%", \Uri::create('account/resetpw/' . $row->account_id . '/' . $account_confirm_code . '/reset'), $email_content); $email_content = str_replace("%link_cancel%", \Uri::create('account/resetpw/' . $row->account_id . '/' . $account_confirm_code . '/cancel'), $email_content); $email_content = str_replace("%confirm_until%", date('d F Y H:i:s', time() + $cfg_member_confirm_wait_time), $email_content); \Package::load('email'); $config = \Extension\Email::getConfig(); $email = \Email::forge($config); $email->from(\Model_Config::getval('mail_sender_email')); $email->to($data['account_email']); $email->subject(\Lang::get('account_email_reset_password_request')); $email->html_body($email_content); $email->alt_body(str_replace("\t", '', strip_tags($email_content))); if ($email->send() == false) { unset($account_confirm_code, $account_confirm_code_since, $account_new_password, $cfg_member_confirm_wait_time, $config, $email, $email_content, $query, $row); return \Lang::get('account_email_could_not_send'); } unset($cfg_member_confirm_wait_time, $config, $email, $email_content); // update to db. //$row->account_new_password = static::instance()->hashPassword($account_new_password); $row->account_confirm_code = $account_confirm_code; $row->account_confirm_code_since = $account_confirm_code_since; $row->save(); unset($account_confirm_code, $account_confirm_code_since, $account_new_password, $row); return true; } // account not found. return \Lang::get('account_didnot_found_entered_email'); }
function load($id = 0) { global $xoopsDB; if ($id) { $res = $xoopsDB->query("SELECT * FROM " . UPDATE_PKG . " WHERE pkgid=" . $id); $vars = $xoopsDB->fetchArray($res); } else { $id = $this->getVar('pkgid'); $res = true; $vars = $this->vars; } if ($res) { // get parent information $pid = $vars['parent']; if ($pid && !parent::load($pid)) { return false; } $this->dirname = $this->getVar('vcheck'); $res = $xoopsDB->query("SELECT hash, path FROM " . UPDATE_FILE . " WHERE pkgref=" . $id); // override modify information $files =& $this->files; $vars['origin'] = $this->getVar('pversion'); $mods = array(); while (list($hash, $path) = $xoopsDB->fetchRow($res)) { switch ($hash) { case 'options': $this->options[$path] = true; break; case 'no-options': $this->options[$path] = false; break; case 'altroot': $this->altroot[] = trim($path); break; default: if (isset($files[$path])) { $mods[$path] = $files[$path]; } $files[$path] = $hash; } } $this->init_checkroot(); $pattern = $this->regIgnore(); if ($pattern) { foreach ($files as $path => $hash) { if (preg_match($pattern, $path)) { $mods[$path] = $hash; unset($files[$path]); } } } $this->modifies = $mods; $this->vars = $vars; } return $res; }