예제 #1
0
 public function actionWrite()
 {
     if (isset($_GET["reply"])) {
         $reply = Mail::model()->with("buddy")->findByPk((int) $_GET["reply"], "t.user_id = :user_id", array(":user_id" => Yii::app()->user->id));
         $reply->setSeen();
     } else {
         $reply = null;
     }
     $message = new Mail();
     if ($reply) {
         $message->sendTo = $reply->buddy->login;
         if (preg_match('/^Re: (.*)$/', $reply->subj, $res)) {
             $subj = "Re[1]: {$res[1]}";
         } elseif (preg_match('/^Re\\[(\\d+)\\]: (.*)$/', $reply->subj, $res)) {
             $subj = "Re[" . ($res[1] + 1) . "]: " . $res[2];
         } else {
             $subj = "Re: {$reply->subj}";
         }
         $message->subj = $subj;
     } elseif (isset($_GET["to"])) {
         $message->sendTo = trim(strip_tags($_GET["to"]));
     }
     if (isset($_POST["Mail"])) {
         $message->setAttributes($_POST["Mail"]);
         if ($message->send()) {
             Yii::app()->user->setFlash("success", "Письмо отправлено " . $message->buddy->ahref);
             $this->redirect("/my/mail");
         }
     }
     if (!$reply) {
         $buddies = User::model()->findAll(array("select" => array("t.id", "t.login", "t.sex", "t.upic"), "join" => "RIGHT JOIN mail ON t.id = mail.buddy_id", "condition" => "mail.user_id = :user_id", "group" => "t.id", "order" => "COUNT(*) DESC", "limit" => 20, "params" => array(":user_id" => Yii::app()->user->id)));
         $this->side_view = array("write_side" => array("message" => $message, "buddies" => $buddies));
     }
     $this->render("write", array("message" => $message, "reply" => $reply));
 }
예제 #2
0
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest or Yii::app()->user->access_level < Config::get('access_level_admin')) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $this->pageTitle = Yii::t('title', 'Send mail');
     $model = new Mail();
     if (isset($_POST['Mail'])) {
         $model->attributes = $_POST['Mail'];
         $player_id = Players::model()->find('name = "' . $model->player_name . '"');
         if ($player_id->online == 1) {
             Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Error - You must first log out of the game server.') . '</div>');
         }
         $criteria = new CDbCriteria();
         $criteria->select = 'MAX(mail_unique_id) as mail_unique_id';
         $last_mail_id = Mail::model()->find($criteria);
         $model->mail_unique_id = $last_mail_id->mail_unique_id + 1;
         $model->mail_recipient_id = $player_id->id;
         $model->sender_name = 'ServerWebsite';
         $model->mail_title = $model->mail_title;
         $model->mail_message = $model->mail_message . "\n\nThis has been sent via our server website.  Please, do not reply.";
         $model->unread = 1;
         // Fallenfate - Add function to send kinah to players.
         if ($model->item_count != NULL || $model->item_count != "") {
             $model->attached_item_id = 0;
             $model->attached_kinah_count = $model->item_count;
         }
         $model->express = 1;
         if ($model->save(false)) {
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('main', 'Mail sent!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('/admin/mail', array('model' => $model));
 }
예제 #3
0
 public function init()
 {
     parent::init();
     // Create new field in your users table for store dashboard preference
     // Set table name, user ID field name, user preference field name
     $this->setTableParams('dashboard_page', 'user_id', 'title');
     // set array of portlets
     $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos cr&iacute;ticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
     //set content BEFORE dashboard
     $this->setContentBefore();
     // uncomment the following to apply jQuery UI theme
     // from protected/components/assets/themes folder
     $this->applyTheme('ui-lightness');
     // uncomment the following to change columns count
     //$this->setColumns(4);
     // uncomment the following to enable autosave
     $this->setAutosave(true);
     // uncomment the following to disable dashboard header
     $this->setShowHeaders(false);
     // uncomment the following to enable context menu and add needed items
     /*
     $this->menu = array(
         array('label' => 'Index', 'url' => array('index')),
     );
     */
 }
예제 #4
0
 public function actionIndex()
 {
     $condition = '';
     // $count = Mail::model()->countByAttributes(array(
     // 	'sent'=>1,
     // ), array(
     // 	'condition'=>'update_time>' . strtotime('today'),
     // ));
     // if ($count >= 200) {
     // 	$condition = '0';
     // } elseif ($count >= 185) {
     // 	$condition = 'subject LIKE "%注册%" OR subject LIKE "%密码%"';
     // }
     $mails = Mail::model()->findAllByAttributes(array('sent' => 0), array('condition' => $condition, 'order' => 'subject LIKE "%注册%" DESC , subject LIKE "%密码%" DESC , subject LIKE "%报名%" DESC , update_time ASC', 'limit' => 30));
     $mailer = Yii::app()->mailer;
     foreach ($mails as $key => $mail) {
         $result = $mailer->send($mail);
         $mail->update_time = time();
         if ($result == true) {
             $mail->sent_time = time();
             $mail->sent = 1;
         } elseif ($mail->update_time - $mail->add_time > 86400) {
             $mail->sent = 2;
         }
         $mail->save();
         sleep(1);
     }
 }
예제 #5
0
 public function actionListApi($is_system = FALSE, $mail_id = NULL)
 {
     $c = new CDbCriteria();
     $c->compare('is_system', $is_system);
     $c->compare('is_deleted', 0);
     $c->compare('usr_id', $this->usr_id);
     $c->limit = 30;
     $c->order = 'mail_id DESC';
     if (isset($mail_id)) {
         $c->compare('mail_id', '<' . $mail_id);
     }
     $mails = Mail::model()->findAll($c);
     Yii::app()->db->createCommand('UPDATE dc_mail SET is_read=1 WHERE usr_id=:usr_id')->bindValue(':usr_id', $this->usr_id)->execute();
     $this->echoJsonData(array($mails));
 }
예제 #6
0
	public function actionsetEmail()
	{
		$model = Mail::model()->findByPk(1);
		
		if(isset($_POST['Mail'])){
			$model->host = $_POST['Mail']['host'];
			$model->port = $_POST['Mail']['port'];
			$model->username = $_POST['Mail']['username'];
			$model->password = $_POST['Mail']['password'];
			if($model->save()){
				Yii::app()->user->setFlash('success','保存成功!');
			}else{
				Yii::app()->user->setFlash('error','保存失败!');
			}
		}
		
		$this->render('setEmail',array(
				'model'=>$model,
				));
	}
예제 #7
0
파일: Mail.php 프로젝트: FranHurtado/hotels
 public function Top($num)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "UserID = :userid";
     $criteria->params = array(':userid' => Yii::app()->user->ID);
     $criteria->limit = $num;
     $model = Mail::model()->findAll($criteria);
     $result = "";
     $result .= "<table cellpadding='5' cellspacing='0' border='0' style='border-collapse: collapse;'>";
     $result .= "<tr><td><b>Fecha</b></td><td><b>Boletin</b></td><td><b>Lista</b></td></tr>";
     foreach ($model as $customer) {
         $result .= "";
         $result .= "<tr>";
         $result .= "<td><a href='" . Yii::app()->createURL('/mail/mail/update/', array('id' => $customer->ID)) . "'>";
         $result .= date("d-m-Y", strtotime($customer->Date)) . "</a></td>";
         $result .= "<td><a href='" . Yii::app()->createURL('/mail/mail/update/', array('id' => $customer->ID)) . "'>";
         $result .= Functions::stringCut($customer->Name, 20) . "</td>";
         $result .= "<td><a href='" . Yii::app()->createURL('/mail/mail/update/', array('id' => $customer->ID)) . "'>";
         $result .= Functions::stringCut($customer->list->Name, 20) . "</td>";
         $result .= "</tr>";
     }
     $result .= "</table>";
     return $result;
 }
예제 #8
0
	private function sendEmail($to_address,$data)
	{
		$conf = Mail::model()->findByPk(1);
		
		$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
		//Yii::import('application.extendsions.mailer.Emailer');
		//$mailer = new Emailer;
		$mailer->IsSMTP();
		$mailer->IsHTML();
		$mailer->CharSet = 'UTF-8';
		$mailer->Host = $conf->host.':'.$conf->port;
		$mailer->SMTPAuth = true;
		//$mailer->SMTPSecure = "ssl";
		$mailer->Username = $conf->username;
		$mailer->Password = $conf->password;
		$mailer->SetFrom($conf->username);
		$mailer->Subject = '莱斯旅游网订单';
		$mailer->getView('myorder',array('data'=>$data),'email');
		$mailer->AddAddress($to_address);
		if($mailer->Send()){
			return true;
		}else{
			return false;
		}
	}
예제 #9
0
 public function actionCategory($name)
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $id = WebshopCategory::model()->find('alt_name = "' . $name . '"');
     $this->pageTitle = Yii::t('title', 'Webshop') . ': ' . $id->name;
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     $criteria->condition = 'category_id = ' . $id->category_id;
     $pages = new CPagination(Webshop::model()->count($criteria));
     $pages->pageSize = Config::get('page_shop');
     $pages->applyLimit($criteria);
     $model = Webshop::model()->findAll($criteria);
     $form = new Inventory();
     $form->scenario = 'buy';
     if (isset($_POST['Inventory'])) {
         $form->attributes = $_POST['Inventory'];
         if ($form->validate()) {
             $criteria = new CDbCriteria();
             $criteria->select = '*';
             $criteria->condition = 'item_id = ' . $form->item_id;
             $item = Webshop::model()->find($criteria);
             $real_price = ceil($form->new_amount * ($item->price / $item->amount));
             $account = AccountData::model()->findByPk(Yii::app()->user->id);
             if ($account[Yii::app()->params->money] < $real_price) {
                 Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Insufficient funds.') . '</div>');
                 $this->refresh();
             }
             $criteria = new CDbCriteria();
             $criteria->condition = 'id = ' . $form->item_owner . ' AND online = 1';
             $online = Players::model()->count($criteria);
             if ($online == 1) {
                 Yii::app()->user->setFlash('message', '<div class="flash_error">' . Yii::t('webshop', 'Log-out') . '</div>');
                 $this->refresh();
             }
             $criteria = new CDbCriteria();
             $criteria->select = 'MAX(mail_unique_id) as mail_unique_id';
             $last_mail_id = Mail::model()->find($criteria);
             $mail = new Mail();
             $mail->mail_unique_id = $last_mail_id->mail_unique_id + 1;
             $mail->mail_recipient_id = $form->item_owner;
             $mail->sender_name = 'Admin';
             $mail->mail_title = Yii::t('webshop', 'Delivery');
             $mail->mail_message = Yii::t('webshop', 'Your purchase has been successful.  Thank you, and we hope you enjoy the game!');
             $mail->unread = 1;
             if ($form->item_id == 182400001) {
                 $mail->attached_item_id = 0;
                 $mail->attached_kinah_count = $form->new_amount;
             } else {
                 $mail->attached_item_id = $this->add_item($form->item_id, $form->item_owner, $form->new_amount);
                 $mail->attached_kinah_count = 0;
             }
             $mail->express = 1;
             $mail->save(false);
             $account[Yii::app()->params->money] = $account[Yii::app()->params->money] - $real_price;
             $account->save(false);
             $log = new LogWebshop();
             $log->player_id = $form->item_owner;
             $log->item = $form->item_id;
             $log->amount = $form->new_amount;
             $log->price = $real_price;
             $log->save(false);
             Yii::app()->user->setFlash('message', '<div class="flash_success">' . Yii::t('webshop', 'Purchase successful!') . '</div>');
             $this->refresh();
         }
     }
     $this->render('category', array('model' => $model, 'id' => $id, 'form' => $form, 'players' => Players::getPlayers(), 'pages' => $pages));
 }
예제 #10
0
 public function actionSend($id)
 {
     $model = Mail::model()->findByPK($id);
     $modelList = CustomerList::model()->findAllByAttributes(array("ListID" => $model->ListID));
     foreach ($modelList as $receiver) {
         //echo $receiver->customer->Email;
         Functions::sendMail("*****@*****.**", $receiver->customer->Email, $model->Name, $model->Text);
     }
     $model->LastSent = date("Y-m-d");
     $model->save();
 }
예제 #11
0
	private function sendEmail($to_address,$data)
	{
		$conf = Mail::model()->findByPk(1);
		
		$mailer = Yii::createComponent('application.extensions.mailer.EMailer');
		//Yii::import('application.extendsions.mailer.Emailer');
		//$mailer = new Emailer;
		$mailer->IsSMTP();
		$mailer->IsHTML();
		$mailer->CharSet = 'UTF-8';
		$mailer->Host = $conf->host.':'.$conf->port;
		$mailer->SMTPAuth = true;
		//$mailer->SMTPSecure = "ssl";
		$mailer->Username = $conf->username;
		$mailer->Password = $conf->password;
		$mailer->SetFrom($conf->username);
		$mailer->Subject = '谢谢注册莱斯旅游网';
		$mailer->getView('signup',array('data'=>$data),'email');
		$mailer->AddAddress($to_address);
		if($mailer->Send()){
			return true;
		}else{
			return false;
		}
		
		
		
		
		
		
		
		
		/* $mail = Yii::createComponent('application.extensions.mailer.EMailer');
		$mail->IsSMTP();
		$mail->CharSet = 'utf-8';
		$mail->From = '*****@*****.**';
		$mail->FromName = '';
		$mail->Host = "smtp.163.com";
		$mail->Port = 25;
		$mail->SMTPAuth = true;
		$mail->Username = '******';
		$mail->Password = '******';
		$mail->AddAddress($to_address, $to_name);
		$mail->AddReplyTo('*****@*****.**', "Please reply to this email!");
		$mail->WordWrap = 50;
		if (!empty($attach))
			$mail->AddAttachment($attach);
		$mail->IsHTML(false);
		$mail->Subject = $subject;
		$mail->Body = $message;
		$mail->AltBody = 'Think you!';
	
		if($mail->Send())
		{
			return true;
		}else{
			return false;
		} */
	}