Strict Standards: Declaration of action_plugin_blog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/blog/action.php on line 13

Strict Standards: Declaration of action_plugin_indexmenu::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/indexmenu/action.php on line 13

Strict Standards: Declaration of action_plugin_importoldchangelog::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/importoldchangelog/action.php on line 8

Strict Standards: Declaration of action_plugin_importoldindex::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/importoldindex/action.php on line 8

Strict Standards: Declaration of action_plugin_include::register() should be compatible with DokuWiki_Action_Plugin::register($controller) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/lib/plugins/include/action.php on line 19

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 208

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 211

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 421

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/parserutils.php on line 594

Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/cache.php on line 291

Deprecated: Function split() is deprecated in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/inc/auth.php on line 154

Strict Standards: Only variables should be passed by reference in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/doku.php on line 73
stepmail [開発チーム]
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/9/97bfd755e223bc09e5dca7babb2fcc6c.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/9/97bfd755e223bc09e5dca7babb2fcc6c.i failed
Unable to save cache file. Hint: disk full; file permissions; safe_mode setting.
Writing /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/data/cache/9/97bfd755e223bc09e5dca7babb2fcc6c.xhtml failed

LINK

流れとしては
メールを1,3,5,7,9,11日ごとにメール配信する。
配信内容でリード広告を出す。

Linkとしてクリックすると、下記のURLを

http://www.fideli.com/lead/m/lgaSelect/me/1051856/lc/88_86_87_14/index.html

memo

9/03 追加

ALTER TABLE lostep_mail_master ADD smm_lc_uniqnums  TEXT   NULL ;
 
CREATE TABLE step_mail_master ( 
	smm_uniqnum SERIAL  NOT NULL 
	,smm_reg_time  TIMESTAMP  NOT NULL  DEFAULT now()
	,smm_click_time  TIMESTAMP  NOT NULL  DEFAULT now()
	,smm_click_flag  INTEGER  NOT NULL  DEFAULT 0
	,smm_lga_pattern TEXT   NULL 
	,smm_step_mail_number  INTEGER  NOT NULL  DEFAULT 0
	,smm_me_uniqnum   INTEGER  NOT NULL  DEFAULT 0
	,smm_check_lga_count   INTEGER  NOT NULL  DEFAULT 0
 
);

関連しているクラス

配信システムは
fideli\crons\stepMailLga.php

受け側システムは
fideli\html\lead\classes\lgaSelectClass.php

テンプレートは

fideli\templates\lead\include\lead_client_list_select.html
fideli\templates\lead\lga_select_login.html
fideli\templates\lead\lga_select_detail.html
fideli\templates\lead\lga_select_comp.html

<?php

require_once ("/home/fideli/etc/configure.inc");
require_once (COMMON_CLASS_DIR."PearDB.php");
require_once ("Smarty.class.php");
require_once(COMMON_CLASS_DIR."leadClientManagementClass.php");
require_once(COMMON_CLASS_DIR."leadClientManagementClass.php");
require_once (COMMON_CLASS_DIR.'MailClass.php');

//	本日
	define("TODAY",strtotime(date("Y-m-d")));


	$sml = new StepMailLga();
	if($sml->checkGekkin(date("w",TODAY))){
		$sml->send();
	}
	exit();
	

class StepMailLga{

	private $_db = null;
	private $_lga = null;

	const LGA_TEMP = 8131;
	const LGA_HEAD = 6;
	const LGA_FOOT = 1;

	const STEP_1 = 1;
	const TEMP_1 = 8132;
	const STEP_2 = 3;
	const TEMP_2 = 8134;
	const STEP_3 = 5;
	const TEMP_3 = 8135;
	const STEP_4 = 7;
	const TEMP_4 = 8136;
	const STEP_5 = 9;
	const TEMP_5 = 8137;
	const STEP_6 = 11;
	const TEMP_6 = 8138;

	const TEST_MAIL = 'sysad@e-classis.co.jp';
//	const TEST_MAIL = '20090806test6@e-classis.co.jp';

	private $_targetAgo = array();

	private $_targetTemplate = array();

	private $_lgaTemp = "";
	
	private $_Number = array();

	public function __construct(){
		$this->_db =& new PearDB;
		$this->_lga =& new leadClientManagementClass;

	//	初期化
		$this->init();
	}

	private function init(){
		$this->_targetAgo = array(
								//	何日前メールを出すか?
									self::STEP_1,
									self::STEP_2,
									self::STEP_3,
									self::STEP_4,
									self::STEP_5,
									self::STEP_6,
								);
		$this->_targetTemplate = array(
								//	何日目メールか? => 雛形番号
									self::STEP_1 => self::TEMP_1,
									self::STEP_2 => self::TEMP_2,
									self::STEP_3 => self::TEMP_3,
									self::STEP_4 => self::TEMP_4,
									self::STEP_5 => self::TEMP_5,
									self::STEP_6 => self::TEMP_6,
								);
		$this->_Number = array(
									self::STEP_1 => 1,
									self::STEP_2 => 2,
									self::STEP_3 => 3,
									self::STEP_4 => 4,
									self::STEP_5 => 5,
									self::STEP_6 => 6,
								);
		$this->setLgaTemplate();
	}

	private function getTargetTime($ago){
		$time = TODAY;
		while($ago){
			$time = strtotime("-1 day",$time);
			if($this->checkGekkin(date("w",$time))){
				$ago--;
			}
		}
		return $time;
	}


	public function send(){
		foreach($this->_targetAgo as $ago){
		//	抽出対象の日を設定
			$target = date("Y-m-d",$this->getTargetTime($ago));
//print_r($target);
			if($list = $this->getTargetMeUniqnums($target)){
//print_r($list);
			//	配信対象者あり
				foreach($list as $k => $me_uniqnum){
					sleep(1);
					$this->step($ago,$me_uniqnum);
				}
//$listArray [] = $list;
			}
		}
//print_r($listArray);
	}
	
#########################################################
#		メールの配信
#########################################################
	private function step($ago,$me_uniqnum){
		if($lga = $this->getLgaAndMe($me_uniqnum,$ago)){
//print_r($lga);
			$bodyTemplate = $this->_targetTemplate[$ago];
			$ML = new MailClass();
			$ML->ToName[0] = $lga["me"]["me_name"]. "様";
			$ML->ToMail[0] = $lga["me"]["me_mail"];
			$assgin = $lga["me"];
			$assgin["date"] = date("Y年m月d日 H時i分");
			$assgin["LGA"] = $lga["lga"];
//print_r($assgin);
//			echo($ML->ToName[0]."\n");
//			echo($ML->ToMail[0]."\n");
			if(self::TEST_MAIL == $ML->ToMail[0]){
				$ML->MailSend($this->_targetTemplate[$ago],self::LGA_HEAD,self::LGA_FOOT,$assgin);
			}
		}
	}

#########################################################
#		メールひな形の用意(6パターン)
#########################################################
	private function setLgaTemplate(){
		$sql = "SELECT
					mtb_text
				FROM
					mail_template_body
				WHERE
					mtb_uniqnum = ".self::LGA_TEMP;
		if($res = $this->_db->DBSelect($sql)){
			$this->_lgaTemp = $res[0]["mtb_text"];
			return;
		}
	//	LGAの枠を取得できなかったので強制終了
		die();
	}
	
#########################################################
#		リード広告をメールで出す。
#########################################################
	private function getLgaAndMe($me_uniqnum,$ago){
		$smarty = new Smarty();
		$contents = "";
		if($session = $this->_lga->getMeCoData2($me_uniqnum)){
//print_r($session);
			#ログインした会員にたいして、リード広告を重複出さないように
			$session["lead_member_flag"] = 1;
			if($lead = $this->_lga->setLeadListSelect($me_uniqnum)){
//print_r($lead);
				#ME情報のアサイン
				foreach($session as $key => $value){
					$smarty->assign($key,$value);
				}
				#メールのURLの作成
				foreach($lead as $key => $value){
					$leadUniqArray[] = $value["lc_uniqnum"];
				}
				$urlNumber = $this->setLgaUrlNumber($me_uniqnum,$leadUniqArray,$ago);
				if(!$urlNumber){
					$urlNumber = "0";
				}
//print_r($urlNumber);
				$smarty->assign("urlNumber",$urlNumber);
				#リード広告をアサイン
				$smarty->assign("LEADLIST",$lead);
				$compiled = null;
				$smarty->_compile_source('null',$this->_lgaTemp, $compiled);
				ob_start();
				$smarty->_eval('?>' . $compiled);
				$contents = ob_get_contents();
				ob_end_clean();
			}
			return array("me" => $session,"lga" => $contents);
		}
		return false;
	}
	
	private function setLgaUrlNumber($me_uniqnum,$leadUniqArray,$ago){
		if($me_uniqnum && is_array($leadUniqArray)){
			$hash = array();
			
			$hash["smm_me_uniqnum"] = $me_uniqnum;
			$hash["smm_lga_pattern"] = join("_",$leadUniqArray);
			$hash["smm_step_mail_number"] = $this->_Number[$ago];
			$hash["smm_reg_time"] = date("Y-m-d H:i:s");
			$hash["smm_click_time"] = date("Y-m-d H:i:s");
			if($this->_db->DBInsert("step_mail_master",$hash)){
				$res = $this->_db->DBSelect("select currval('step_mail_master_smm_uniqnum_seq')");
				return $res[0]['currval'];
			}
			
		}
	}

#########################################################
#		日にちに合っている会員情報を取り出す
#########################################################
	private function getTargetMeUniqnums($target){

		$sql = "SELECT
					me_uniqnum
				FROM
					me
				WHERE
				--	me_mail = '".self::TEST_MAIL."' AND
					date_trunc('day',me_reg_time) = ? AND
					me_reg_time >= ? AND
					me_withdraw_flag = 1 AND
					me_admail_flag = 1";

		$me = array();
		$startTime = "2009-09-08";
		if($res = $this->_db->DBSelect($sql,array($target,$startTime,))){
			foreach($res as $k => $v){
				$me[$v["me_uniqnum"]] = $v["me_uniqnum"];
			}
		}

		return $me;
	}

	public function checkGekkin($w){
		return in_array($w,array(0,6))?false:true;
	}

	private function getMe($me_uniqnum){
		return $this->_lga->getMeCoData2($me_uniqnum);
	}

}

<?php

define('DF_NOW', time());
define('DF_TODAY', mktime(0, 0, 0, date('n', DF_NOW), date('j', DF_NOW), date('Y', DF_NOW)));
//define('OUTPUT_ENCODING', 'UTF-8');
define('OUTPUT_ENCODING', 'SJIS');

$neko = new Ice_Neko();
$st = $neko->subDay(30);
$ed = $neko->addDay(30);

//========================================
// 登録日別
//========================================
$nyan = $neko->run($st, $ed);
$neko->render($nyan);

//========================================
// 配信日別
//========================================
$tyuu = $neko->search($nyan, DF_TODAY);
$neko->render2($tyuu);

$tyuu = $neko->search($nyan, $neko->addDay(1));
$neko->render2($tyuu);

$tyuu = $neko->search($nyan, $neko->addDay(2));
$neko->render2($tyuu);

$tyuu = $neko->search($nyan, $neko->addDay(3));
$neko->render2($tyuu);

$tyuu = $neko->search($nyan, $neko->addDay(4));
$neko->render2($tyuu);

$tyuu = $neko->search($nyan, $neko->addDay(5));
$neko->render2($tyuu);

class Ice_Neko
{

    protected $target = array(1 => 1, 2 => 3, 3 => 5, 4 => 7, 5 => 9, 6 => 11);

    public function run($st, $ed)
    {
        $output = array();
        $ts = $st;
        while ($ts <= $ed) {
            foreach ($this->target as $key => $value) {
                $deliveryDay = $this->addDay($value, $ts);
                if (date('w', $deliveryDay) == 6) {
                    //土
                    $deliveryDay = $this->addDay($value + 2, $ts);
                } elseif (date('w', $deliveryDay) == 0) {
                    //日
                    $deliveryDay = $this->addDay($value + 1, $ts);
                }
                $output[$ts][$key] = $deliveryDay;
            }
            $ts += 60 * 60 * 24;
        }
        return $output;
    }
    public function render($data)
    {
        $output = array();
        foreach ($data as $key => $value) {
            foreach ($value as $k => $v) {
                $output[$this->_b($key).$this->_w($key)][$k] = $this->_b($v).$this->_w($v);
            }
        }
        print_r($output);
    }

    public function render2($data)
    {
        $output = array();
        foreach ($data as $key => $value) {
            foreach ($value as $ke => $va) {
                foreach ($va as $k => $v) {
                    $output[$this->_b($key).$this->_w($key)][$this->_b($ke).$this->_w($ke)][$k] = $this->_b($v).$this->_w($v);
                }
            }
        }
        print_r($output);
    }

    public function search($data, $dt)
    {
        $output = array();
        foreach ($data as $key => $value) {
            foreach ($value as $k => $v) {
                if ($v == $dt) {
                    $output[$v][$key][$k] = $key;
                }
            }
        }
        return $output;
    }

    protected function _w($ts)
    {
        $w = array('日', '月', '火', '水', '木', '金', '土');
        return '('.mb_convert_encoding($w[date('w', $ts)], OUTPUT_ENCODING, 'UTF-8').')';
    }

    //YYYYMMDD形式
    protected function _a($ts)
    {
        return date('Ymd', $ts);
    }

    //YYYY-MM-DD形式
    protected function _b($ts)
    {
        return date('Y-m-d', $ts);
    }

    public function addDay($n, $ts = null)
    {
        if ($ts === null) {
            $ts = DF_TODAY;
        }
        $y = date('Y', $ts);
        $m = date('n', $ts);
        $d = date('j', $ts);
        return mktime(0, 0, 0, $m, $d + $n, $y);
    }

    public function subDay($n, $ts = null)
    {
        return $this->addDay($n * -1, $ts);
    }

}
stepmail.txt · 最終更新: 2010/07/27 15:47 (外部編集)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0

Strict Standards: Only variables should be passed by reference in /var/www/vhosts/w629.ws.domainking.cloud/enjoy-lei.com/dokuwiki/doku.php on line 81