我创建了一个快速简单的Affiliate Refer脚本,用于检查会员ID,如果是注册ID,则会检查数据库中是否有来自的IP,如果它不在列表中则会奖励会员1分。
然而,当我检查了超过30个不同IP地址的测试版本时,并非所有IP地址都已存储,并且似乎已经停止在某个点之后保存它们。
数据库只是一个常规的mysql数据库。
您将如何存储知识产权并授予关联公司?
编辑:代码
function awardAffiliate() {
global $wpdb;
//get the affliateID from the url.
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$affiliateID = basename(parse_url($url, PHP_URL_PATH));
//get the IP address.
$ipAddress = $_SERVER['REMOTE_ADDR'];
/
$checkAffiliate = $wpdb->get_results( $wpdb->prepare("SELECT user_id, user_count FROM affiliate_members WHERE user_id = '$affiliateID'"));
foreach ($checkAffiliate as $affiliate) {
$regAffiliateID = $affiliate->user_id;
$regAffiliateCount = $affiliate->user_count;
}
// ammend them so that the count is +1 and the ip address is pushed into the array. add ',' before new ipaddress
$newCount = $regAffiliateCount + 1;
$updateffiliate = $wpdb->get_results( $wpdb->prepare("UPDATE affiliate_members SET user_count = '$newCount' WHERE user_id = '$affiliateID'"));
$checkIpaddresses = $wpdb->get_results( $wpdb->prepare("SELECT affiliateID, source FROM affiliate_ip WHERE affiliateID = '$affiliateID'"));
foreach ($checkIpaddresses as $ipaddress) {
$ipSource = $ipaddress->source;
}
$addIP = "," .$ipAddress;
$ipSource .= $addIP;
$updateIpAddress = $wpdb->get_results( $wpdb->prepare("UPDATE affiliate_ip SET source = '$ipSource' WHERE affiliateID = $affiliateID"));
}