public function saveSearch($conditions = array(), $values = array(), $results = 0) { $data = array('search_id' => text_helper::random(8), 'user_id' => session::item('user_id'), 'conditions' => json_encode($conditions), 'values' => json_encode($values), 'results' => $results, 'post_date' => date_helper::now()); if (!session::item('user_id')) { $data['ip_address'] = input::ipaddress(); } $this->db->insert('core_search', $data); return $data['search_id']; }
public function saveTransaction($transactionID, $gatewayID, $invoiceID, $receiptID, $userID, $amount) { $transaction = array('user_id' => $userID, 'invoice_id' => $invoiceID, 'gateway_id' => $gatewayID, 'receipt_id' => $receiptID ? $receiptID : text_helper::random(10), 'amount' => $amount); // Is this a new transaction? if (!$transactionID) { $transaction['post_date'] = date_helper::now(); // Save transaction $transactionID = $this->db->insert('billing_transactions', $transaction); // Action hook hook::action('billing/transactions/insert', $transactionID, $transaction); } else { // Save transaction $this->db->update('billing_transactions', $transaction, array('transaction_id' => $transactionID), 1); // Action hook hook::action('billing/transactions/update', $transactionID, $transaction); } return $transactionID; }
public function upload($filename, $extensions, $maxsize, $maxdimensions = '') { if ($maxdimensions && !is_array($maxdimensions)) { $maxdimensions = explode('x', $maxdimensions); } // Upload path $suffix = implode('/', str_split(text_helper::random(4, 'numeric'))); $path = $this->relativePath . '/' . $suffix; // Does upload path exist? if (!$this->createPath($this->relativePath, $suffix)) { return false; } // Uploader configuration $config = array('upload_path' => BASEPATH . $path, 'allowed_types' => str_replace(',', '|', $extensions), 'max_size' => $maxsize * 1024, 'max_width' => isset($maxdimensions[0]) ? $maxdimensions[0] : 0, 'max_height' => isset($maxdimensions[1]) ? $maxdimensions[1] : 0, 'encrypt_name' => true, 'clean_name' => false, 'overwrite' => true); // Load uploader library loader::library('uploader', $config); if (!$this->uploader->run($filename)) { $this->setError($this->uploader->getError()); return false; } $file = $this->uploader->getData(); $file['path_suffix'] = $suffix; return $file; }
public function newpass() { // Get vars $userID = (int) uri::segment(4); $hash = uri::segment(5); // Validate user ID if (!$userID) { view::setError(__('user_id_invalid', 'users_signup')); router::redirect('users/login'); } // Loader loader::library('email'); loader::model('system/requests'); // Validate hash if (!$hash || !$this->requests_model->validateRequest($hash)) { view::setError(__('request_hash_invalid', 'system')); router::redirect('users/login'); } // Get user if (!($user = $this->users_model->getUser($userID))) { view::setError(__('request_hash_invalid', 'system')); router::redirect('users/login'); } // Get request if (!($request = $this->requests_model->getRequest('lostpass', $hash, $userID))) { view::setError(__('request_hash_expired', 'system')); router::redirect('users/login'); } // Is user already active? if (!$user['verified']) { view::setError(__('user_not_verified', 'users_signup')); router::redirect('users/login'); } // Generate new password $password = text_helper::random(10); // Update user's verification status $this->users_model->savePassword($userID, $password); // Replace tags $user['password'] = $password; // Send activation email $this->email->sendTemplate('users_password_new', $user['email'], $user, $user['language_id']); // Remove verification request $this->requests_model->deleteRequest('lostpass', $hash, $userID); // Success view::setInfo(__('request_newpass_sent', 'users_signup')); router::redirect('users/login/index/lostpass'); }
public function encryptPassword($password, $salt = '') { if ($password == '') { return ''; } // Do we have salt? if ($salt == '') { $salt = text_helper::random(8); } // Encrypt password $password = sha1($password . $salt); $password .= $salt; return $password; }
public function saveRequest($keyword, $userID, $itemID = 0, $value = '') { $data = array('hash' => text_helper::random(16), 'ip_address' => input::ipaddress(), 'post_date' => date_helper::now(), 'keyword' => $keyword, 'user_id' => $userID, 'item_id' => $itemID, 'val' => $value); $this->db->insert('core_requests', $data); return $data['hash']; }
public function generateSesshash($ipaddress, $useragent) { $salt = text_helper::random(8); $sesshash = sha1($ipaddress . $useragent . $salt); return $sesshash; }