misc_promotion.php
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: misc_promotion.php 25889 2011-11-24 09:52:20Z monkey $
 */
if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
global $_G;
if(!empty($_GET['fromuid'])) {
	$fromuid = intval($_GET['fromuid']);
	$fromuser = '';
} else {
	$fromuser = $_GET['fromuser'];
	$fromuid = '';
}
if(!$_G['uid'] || !($fromuid == $_G['uid'] || $fromuser == $_G['username'])) {
	if($_G['setting']['creditspolicy']['promotion_visit']) {
		if(!C::t('forum_promotion')->fetch($_G['clientip'])) {
			C::t('forum_promotion')->insert(array('ip' => $_G['clientip'], 'uid' => $fromuid, 'username' => $fromuser), false, true);
			updatecreditbyaction('promotion_visit', $fromuid);
		}
	}
	if($_G['setting']['creditspolicy']['promotion_register']) {
		if(!empty($fromuser) && empty($fromuid)) {
			if(empty($_G['cookie']['promotion'])) {
				$fromuid = C::t('common_member')->fetch_uid_by_username($fromuser);
			} else {
				$fromuid = intval($_G['cookie']['promotion']);
			}
		}
		if($fromuid) {
			dsetcookie('promotion', ($_G['cookie']['promotion'] = $fromuid), 1800);
		}
	}
}
?>