public static function init($username, $password, $database, $host) { if (empty($username) || empty($database) || empty($host)) { throw new Exception("Please configure your database connection properly", 1); } $connections = array('development' => 'mysql://' . $username . ':' . $password . '@' . $host . '/' . $database); self::$conn = ActiveRecord\Config::instance(); self::$conn->set_model_directory(AR::$model_directories); self::$conn->set_connections($connections); }
/** * Функция которая сбрасывает пароль на новый * @param String $username Имя пользователя * @param String $key Ключ для сброса пароля, который был выслан ему по почте * @return */ public function actionResetPassword($username, $key) { $criteria = new SDbCriteria(); $criteria->compare('username', $username); $criteria->compare('is_social_user', Buyer::SOCIAL_BUYER_NO); $criteria->compare('reset_key', $key); $model = AR::model($this->model)->find($criteria); if (!$model) { exception(404); } $model->scenario = 'resetPassword'; $model->password = ''; $this->performAjaxValidation($model); if (isset($_POST[$this->model])) { $model->attributes = $_POST; //save new password and salt if ($model->save()) { //set flash message setFlash('password-changed', 'password-change-success'); } } $this->pageTitle = t('user', 'Смена пароля'); $this->render('forgotpassword', compact('model')); }
<?php require_once 'funcs.php'; $libraries = array('AR', 'Config', 'Validate', 'Html', 'Session', 'Response'); $models = array('Task'); $configuration_files = array('application' => 'inc/conf/application.php', 'database' => 'inc/conf/database.php', 'email' => 'inc/conf/email.php'); foreach ($libraries as $key => $value) { require_once 'inc/lib/utilities/' . $value . '.php'; } foreach ($models as $key => $value) { require_once 'inc/models/' . $value . '.php'; } Config::loads($configuration_files); // connect to database AR::$conn = connect(Config::read('database', 'username'), Config::read('database', 'password'), Config::read('database', 'server'), Config::read('database', 'database')); // AR::$conn->debug = 1; // turn on / off debug message ADOdb_Active_Record::SetDatabaseAdapter(AR::$conn); // set minimum length of password Validate::$min_length = 8; Session::init(); safe_post_data(); header("Content-Type: application/json; charset=utf-8");
/** * After delete */ public function afterDelete() { parent::afterDelete(); if ($this->bcategory) { $this->bcategory->changeCountProduct(ProductCategory::DECREASE); } }