示例#1
0
 public function sendEmail(Ticket $model)
 {
     $config = Yii::app()->settings->get('core');
     $request = Yii::app()->request;
     $user = Yii::app()->user;
     $browser = CMS::detectBrowser(CMS::getagent());
     $platform = CMS::detectPlatform(CMS::getagent());
     $body = "\n            \n\n\n<p>Тема: {$model->name}</p>\n<p>Сообщение: {$model->text}</p>\n\n    <br><br>\n<center><a style=\"font-size:24px;text-decoration:none;color:#fff;padding:10px;border:1px solid #333;background-color:#999;\" href=\"http://builshop.net/admin/support/?view={$model->id}\">Перейки к обращению</a></center>\n<hr />\n<p>Пользователь: {$user->login} #{$user->id}</p>\n<p>Браузер: {$browser}</p>\n<p>ПО: {$platform}</p>\n<p>IP: {$request->userHostAddress}</p>\n\n";
     $mailer = Yii::app()->mail;
     $mailer->From = 'noreply@' . $request->serverName;
     $mailer->FromName = $request->serverName;
     $mailer->Subject = 'Обращение в техподдержку';
     $mailer->Body = $body;
     foreach (Yii::app()->params['support_email'] as $email) {
         $mailer->AddAddress($email);
     }
     $mailer->AddReplyTo($config['admin_email']);
     $mailer->isHtml(true);
     $mailer->Send();
     $mailer->ClearAddresses();
 }
示例#2
0
 /**
  * Авторизация на форуме
  * @param string $login
  * @param string $password
  * @return boolean
  */
 public function log_in($login, $password)
 {
     $password = md5($password);
     $member = $this->FDB->createCommand("SELECT * FROM {$this->tbl_prefix}members WHERE name='" . $login . "'")->queryRow();
     if ($member['members_pass_hash'] != self::generateCompiledPasshash(str_replace("\\\\", '\\', $member['members_pass_salt']), $password)) {
         return false;
     }
     $sid = md5(uniqid(microtime()));
     $expire = time() + intval(84600 * Yii::app()->settings->get('core', 'cookie_time'));
     $pass_hash_set = $member['member_login_key'];
     $this->stronghold_set_cookie($member['member_id'], $member['member_login_key']);
     Yii::app()->request->enableCookieValidation = false;
     Yii::app()->request->cookies['member_id'] = new CHttpCookie('member_id', $member['member_id'], array('expire' => $expire));
     Yii::app()->request->cookies['pass_hash'] = new CHttpCookie('pass_hash', $pass_hash_set, array('expire' => $expire));
     Yii::app()->request->cookies['session_id'] = new CHttpCookie('session_id', $sid, array('expire' => $expire));
     $this->FDB->createCommand("UPDATE {$this->tbl_prefix}members SET ip_address='" . $_SERVER['REMOTE_ADDR'] . "' WHERE member_id='" . $member['member_id'] . "'")->execute();
     $this->FDB->createCommand("DELETE FROM {$this->tbl_prefix}sessions WHERE ip_address='" . $_SERVER['REMOTE_ADDR'] . "'")->execute();
     $userag = CMS::getagent();
     $browser = substr($userag, 0, 64);
     $ip = substr($_SERVER['REMOTE_ADDR'], 0, 16);
     $this->FDB->createCommand("INSERT INTO {$this->tbl_prefix}sessions (id, member_name, seo_name, member_id, running_time, ip_address, browser, login_type, member_group) VALUES ('{$sid}', '" . $member['name'] . "','" . $member['name'] . "', '" . $member['member_id'] . "',  '" . time() . "', '{$ip}', '{$browser}', '0', '" . $member['member_group_id'] . "')")->execute();
     return true;
 }
示例#3
0
 public function log_in($login, $password)
 {
     $expire = time() + intval(84600 * Yii::app()->settings->get('core', 'cookie_time'));
     $user_name = strtolower(str_replace('|', '&#124;', $login));
     $user_password = md5($password);
     $member = $this->FDB->createCommand("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM {$this->tbl_prefix}user WHERE LOWER(username) = '" . $user_name . "'")->queryRow();
     if (isset($member)) {
         if ($member['password'] != md5($user_password . $member['salt'])) {
             return false;
         }
         // $ip = substr($_SERVER['REMOTE_ADDR'], 0, 16);
         $ip = implode('.', array_slice(explode('.', $ip), 0, 4 - 1));
         $userag = CMS::getagent();
         $session_idhash = md5($userag . $ip);
         $scriptpath = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : $_ENV['REQUEST_URI'];
         $sessionhash = md5(time() . $scriptpath . $session_idhash . $ip . mt_rand(1, 1000000));
         //$GENsessionhash = md5(uniqid(microtime(), true));
         //  die($sessionhash);
         $browser = substr($userag, 0, 64);
         $old_s_id = Html::text($_COOKIE[$this->cookieprefix . "sessionhash"]);
         Yii::app()->request->enableCookieValidation = false;
         if ($old_s_id != "") {
             $this->FDB->createCommand("DELETE FROM {$this->tbl_prefix}session WHERE sessionhash = '" . $old_s_id . "'")->execute();
         }
         $this->FDB->createCommand("INSERT INTO {$this->tbl_prefix}session (sessionhash, userid, host, idhash, lastactivity, location, useragent, loggedin) VALUES ('{$sessionhash}', '" . $member['userid'] . "', '{$ip}', '{$session_idhash}', '" . time() . "', '{$scriptpath}', '{$browser}', '1')")->execute();
         setcookie($this->cookieprefix . "userid", $member['userid'], $expire);
         //setcookie($this->cookieprefix . "password", md5($member['password'] . $this->fcookiesalt), $expire);
         setcookie($this->cookieprefix . "password", md5($user_password . $member['salt']), $expire);
         setcookie($this->cookieprefix . "sessionhash", $sessionhash, $expire);
     } else {
         return false;
     }
 }