public function generatePassword($entity) { $newPassword = substr(md5(rand() . rand()), 0, 8); $entity->prv_secret = Password::hash($newPassword); Logger::debug("New Password for " . $entity->prv_uid . ": {$newPassword} (hash: {$entity->prv_secret})"); return $newPassword; }
public function login() { $result = Auth::check($this->request->adapter, $this->request); $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/'; if ($result) { # Convert array to identity object if ($this->request->adapter === 'password') { $result = Identities::find($result['_id']); } $session_data = array(); $new_session = uniqid(); if (isset($result['session']['id'])) { $session_data['id'] = (array) $result['session']['id']->data(); } else { $session_data['id'] = array(); } // Remember users for two weeks $session_data['expires'] = time() + \app\util\Config::get('session_length', 7) * 24 * 60 * 60; array_push($session_data['id'], $new_session); setcookie('session.id', $new_session, $session_data['expires'], '/', $_SERVER['HTTP_HOST']); $result->save(array('session' => $session_data)); Auth::set('any', $result); } else { $addendum = ''; // Adapter-specific error messages if ($this->request->adapter == 'phpbb') { if (Session::read('non_linked_phpbb_login')) { Session::delete('non_linked_phpbb_login'); $addendum = 'You are logged into the forums, but there is no leagues account associated with with your forum account.'; } else { $addendum = 'Please ensure that you are logged into the <a href="http://www.afdc.com/forum/">forums</a>.'; } } else { Logger::debug("Failed login for " . $this->request->data['email'] . " with password " . $this->request->data["password"]); } $error_message = 'Your login was unsuccessful. '; if (isset($addendum) and !empty($addendum)) { $error_message .= "<br />{$addendum}`<br />"; } $error_message .= 'If you\'re having trouble, checkout the <a href="/help/login">login instructions</a>.'; $this->flashMessage($error_message, array('alertType' => 'error')); } return $this->redirect($redirectUrl); }
protected function _respond($channels, $responses) { if (empty($responses)) { return; } foreach ($channels as $channel) { Logger::debug('Responding with ' . count($responses) . " message(s) to channel `{$channel}`:"); foreach ((array) $responses as $response) { if ($this->_write('PRIVMSG', $command = "{$channel} :{$response}")) { $this->_process(":{$this->_nick}!@localhost PRIVMSG {$command}\r\n"); } } } }
/** * Dump * * @param mixed $var * @param array $options */ public function dump($var, $options = array()) { $options += self::$defaults + array('split' => false, 'trace' => false); $this->options = $options; $this->current_depth = 0; $this->object_references = array(); if (!$options['trace']) { $options['trace'] = debug_backtrace(); } extract($options); $location = $this->location($trace); $dump = array(); if ($options['split'] && is_array($var)) { $this->current_depth = 0; foreach ($var as $one) { $dump = array_merge($dump, array($this->dump_it($one), ' - ')); } $dump = array_slice($dump, 0, -1); } else { $dump[] = $this->dump_it($var); } switch ($mode) { case 'FirePHP': $locString = \al13_debug\util\adapters\FirePHP::locationString($location); require_once LITHIUM_LIBRARY_PATH . '/FirePHPCore/FirePHP.class.php'; $firephp = \FirePHP::getInstance(true); if (!$firephp) { throw new \Exception('FirePHP not installed'); } $firephp->group($locString, array('Collapsed' => false, 'Color' => '#AA0000')); $f = function ($o) use($firephp, &$f) { if (is_array($o)) { foreach ($o as $r) { $f($r); } } else { $firephp->log($o); } }; $f($dump); $firephp->groupEnd(); return; break; case 'Json': $locString = \al13_debug\util\adapters\Json::locationString($location); $this->output[] = array('location' => $locString, 'dump' => $dump); break; case 'Log': $locString = \al13_debug\util\adapters\Log::locationString($location); \lithium\analysis\Logger::debug($locString . "\n" . implode("\n", $dump)); return; break; case 'Html': default: $locString = \al13_debug\util\adapters\Html::locationString($location); $this->output[] = '<div class="debug-dump"><div class="debug-location">' . $locString . '</div>' . '<div class="debug-content"> ' . implode("<br>\n", $dump) . '</div></div>'; break; } if ($options['echo']) { $this->__out(); } }
public function ipn() { if ($this->request->data) { $paypal_txn_id = $this->request->data['txn_id']; $payment = Payments::first(array('conditions' => array(array('txn_id' => $paypal_txn_id)))); if (!isset($payment)) { Logger::debug('New transaction #' . $paypal_txn_id); # Put the payment in the DB $payment = Payments::create($this->request->data); if ($payment->invoice) { # Map invoices to cart_ids, right now this is direct $payment->shopping_cart_id = $payment->invoice; } $payment->save(); } else { Logger::debug('Transaction play-back (txn #' . $paypal_txn_id . ')'); } Logger::debug('$payment->_id = ' . $payment->_id); $cart = ShoppingCarts::find($payment->invoice); Logger::debug('$cart->_id = ' . $cart->_id); $items = $cart->getItems(); if (strtolower($payment->payment_status) == 'pending' and strtolower($payment->pending_reason) == 'authorization') { $captureAmount = 0; $remainder = 0; Logger::debug('authorization transaction'); foreach ($items as $ci) { Logger::debug('.....cart_item ' . $ci->_id); $refObj = $ci->getReference(); if ($ci->isValid()) { Logger::debug('..........valid purchase -- auto-capture'); $ci->save(array('status' => CartItems::STATUS_CAPT)); // Pass payment status down to referenced object $conditions = array('_id' => $refObj->_id); $query = array('$set' => array('payment_status' => CartItems::STATUS_CAPT, 'payment_timestamps.pending' => $payment->payment_date), '$push' => array('payments' => $payment->_id)); Registrations::update($query, $conditions); $captureAmount += $ci->price; } else { Logger::debug('..........not valid, hold as pending'); $ci->save(array('status' => CartItems::STATUS_AUTH)); // Pass payment status down to referenced object $conditions = array('_id' => $refObj->_id); $query = array('$set' => array('payment_status' => CartItems::STATUS_AUTH, 'payment_timestamps.pending' => $payment->payment_date), '$push' => array('payments' => $payment->_id)); Registrations::update($query, $conditions); $remainder += $ci->price; } $cart->save(array('is_authorized' => true)); } if ($captureAmount > 0) { Logger::debug('Capturing $' . $captureAmount); $result = Paypal::doCapture($payment->auth_id, $captureAmount, $payment->mc_currency, $remainder == 0); Logger::debug(print_r($result, true)); // Log NVP transaction result to the payment $query = array('$push' => array('nvp' => $result)); $conditions = array('_id' => $payment->_id); Payments::update($query, $conditions); Logger::debug('Captured!'); } } else { if (strtolower($payment->payment_status) == 'completed') { $unpaid_items = 0; foreach ($items as $ci) { Logger::debug('.....cart_item ' . $ci->_id); $refObj = $ci->getReference(); if ($ci->status == CartItems::STATUS_CAPT) { Logger::debug('..........PAID!'); $ci->save(array('status' => CartItems::STATUS_PAID)); // Pass payment status down to referenced object // TODO: this stuff should really be handled by the registration object $conditions = array('_id' => $refObj->_id); $query = array('$set' => array('paid' => true, 'payment_status' => CartItems::STATUS_PAID, 'status' => 'active', 'payment_timestamps.completed' => $payment->payment_date), '$push' => array('payments' => $payment->_id)); Registrations::update($query, $conditions); } else { if ($ci->status != CartItems::STATUS_PAID) { $unpaid_items++; } } } if ($unpaid_items == 0) { $cart->save(array('status' => 'closed')); } } else { if (strtolower($payment->payment_status) == 'refunded') { foreach ($items as $ci) { Logger::debug('.....cart_item ' . $ci->_id); $refObj = $ci->getReference(); $conditions = array('_id' => $refObj->_id); $query = array('$set' => array('paid' => false, 'payment_status' => CartItems::STATUS_RFND, 'payment_timestamps.refunded' => $payment->payment_date), '$push' => array('payments' => $payment->_id)); Registrations::update($query, $conditions); Logger::debug('..........refunded.'); } } } } } return $this->render(array('layout' => false)); }
public function perform() { Logger::debug(json_encode($this->args)); Logger::debug('performed'); }
public function create() { // TODO: Use Minerva's access system (li3_access) // Bigger todo: update li3_acess (Nate's changes) and redo Minerva's access system completely. $user = Auth::check('minerva_user'); if ($user['role'] != 'administrator' && $user['role'] != 'content_editor') { $this->redirect('/'); return; } if (!empty($this->request->data['Filedata'])) { //Logger::debug(json_encode($this->request->data)); // IMPORTANT: Use MongoDate() when inside an array/object because $_schema isn't deep $now = new MongoDate(); $data = array(); // IMPORTANT: The current/target gallery id must be passed in order to associate the item. // Otherwise, it'd be stored loose in the system. $gallery_id = $this->request->data['gallery_id']; // If there was only one file uploaded, stick it into a multi-dimensional array. // It's just easier to always run the foreach() and code the processing stuff once and here. // For now...while we're saving to disk. if (!isset($this->request->data['Filedata'][0]['error'])) { $this->request->data['Filedata'] = array($this->request->data['Filedata']); } foreach ($this->request->data['Filedata'] as $file) { // TODO: change. possibly adaptable class $source_base = '/minerva_gallery/img/gallery_items/'; $service = 'file'; // Create an Item object $id = new MongoId(); $document = Item::create(array('_id' => $id, 'created' => $now, 'modified' => $now, 'service' => $service, 'source' => $source_base . $id . '.jpg', 'title' => $file['name'], '_galleries' => array($gallery_id), 'published' => true)); // Save file to disk // TODO: Again, change this...maybe use an adaptable class for storage if ($file['error'] == UPLOAD_ERR_OK) { $upload_dir = LITHIUM_APP_PATH . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'minerva_gallery' . DIRECTORY_SEPARATOR . 'webroot' . DIRECTORY_SEPARATOR . 'img' . DIRECTORY_SEPARATOR . 'gallery_items' . DIRECTORY_SEPARATOR; $ext = substr(strrchr($file['name'], '.'), 1); switch (strtolower($ext)) { case 'jpg': case 'jpeg': case 'png': case 'gif': case 'png': case 'doc': case 'txt': if (move_uploaded_file($file['tmp_name'], $upload_dir . $id . '.jpg')) { Logger::debug('saved file to disk successfully.'); } break; default: //exit(); break; } } //Logger::debug('document _id: ' . (string)$document->_id); if ($document->save($data)) { Logger::debug('saved mongo document successfully.'); } } } //$this->set(compact('document')); }