123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- namespace Cas\Module;
- use KIF\Data\Convert;
- use KIF\Data\ResultWrapper;
- use KIF\Db\Transaction;
- use KIF\Cache\Memcached;
- use Cas\Dao\LotteryEventsLog;
- use Cas\Dao\LotteryUserParticipateLog;
- use KIF\Url;
- use KIF\Cookie;
- use Cas\Dao\LotteryDeliveryChannels;
- use KIF\Core\Request;
- use KIF\Core\Config;
- class Count {
- private $keyName;
- private $objDLotteryDeliveryChannels;
-
-
- public function __construct() {
- $this->keyName = 'FromKey';
- $this->objDLotteryDeliveryChannels = new LotteryDeliveryChannels ();
- }
-
-
- public function setPassLog( $event_id,$platform_id) {
- $objDLotteryDeliveryChannels = new LotteryDeliveryChannels();
- $from_id = Request::g('from');
- if($from_id){
- Cookie::set('cas_from', $from_id,60*60*24*29,'.'.$_SERVER['HTTP_HOST']);
- }else{
- $from_id = Cookie::get('cas_from');
- }
- if($from_id){
- $data = $objDLotteryDeliveryChannels -> get($from_id);
-
- if($data['events_id'] == $event_id ){
-
- }
- $objDLotteryDeliveryChannels -> addOnePV($from_id);
- }else{
- $objDLotteryDeliveryChannels ->addDefaultEventOnePV(Request::schemeDomain(),$event_id,$platform_id);
- }
-
-
-
-
- $info = array();
- $info['ip'] = Request::ip();
- $info['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
- $info['event_id'] = $event_id;
- $info['time'] = time();
- $logStr = serialize($info);
-
- $this->writePassLog($logStr,'pass_log');
- }
-
-
- public function DeliveryChannelsCount() {
-
- $id = Request::g ( 'from' );
- if (! $id) {
-
- $id = Cookie::get ( $this->keyNam );
- }
-
- if ($id) {
-
- $this->objDLotteryDeliveryChannels->addOnePV ( $id );
- Cookie::set ( $this->keyName, $id, 60 * 60 * 24 * 10 ,'.'.$_SERVER['HTTP_HOST']);
- }
- }
-
- public static function writePassLog($log_message, $log_type = 'log') {
- $log_size = 1024 * 1024 * 5;
- $dir =Config::getInstance ()->get ( 'Log_Path' ).DIRECTORY_SEPARATOR.date('Y',time()).DIRECTORY_SEPARATOR;
- if (! is_dir ( $dir )) {
- if (! mkdir ( $dir )) {
- return false;
- }
- }
- if (! is_writable ( $dir )){
- exit ( 'LOG_PATH is not writeable !' );
- }
-
- $dir .= date('m',time()).DIRECTORY_SEPARATOR;
- if (! is_dir ( $dir )) {
- if (! mkdir ( $dir )) {
- return false;
- }
- }
- if (! is_writable ( $dir )){
- exit ( 'LOG_PATH is not writeable !' );
- }
-
- $s_now_time = date ( '[Y-m-d H:i:s]' );
- $log_now_day = date ( 'Y_m_d' );
-
- $log_path = $dir;
- switch ($log_type) {
- case 'debug' :
- $log_path .= 'Out_' . $log_now_day . '.log';
- break;
- case 'error' :
- $log_path .= 'Err_' . $log_now_day . '.log';
- break;
- case 'pass_log' :
- $log_path .= 'Pass_log_' . $log_now_day . '.log';
- break;
- default :
- $log_path .= 'Log_' . $log_now_day . '.log';
- break;
- }
-
- if (file_exists ( $log_path ) && $log_size <= filesize ( $log_path )) {
- $s_file_name = substr ( basename ( $log_path ), 0, strrpos ( basename ( $log_path ), '.log' ) ) . '_' . time () . '.log';
- rename ( $log_path, dirname ( $log_path ) . DS . $s_file_name );
-
- }
-
- return error_log ( "$log_message\n", 3, $log_path );
- }
- }
|