本文整理匯總了PHP中module_build_privileges函數的典型用法代碼示例。如果您正苦於以下問題:PHP module_build_privileges函數的具體用法?PHP module_build_privileges怎麽用?PHP module_build_privileges使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了module_build_privileges函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: uni_group_check
function uni_group_check()
{
global $_W;
$uniacid = $_W['uniacid'];
$settings = uni_setting($uniacid, array('groupdata'));
$groupdata = $settings['groupdata'] ? $settings['groupdata'] : array();
if ($_W['account']['groupid'] != 0 && $groupdata['isexpire'] == 1 && $groupdata['endtime'] < TIMESTAMP) {
pdo_update('uni_account', array('groupid' => 0), array('uniacid' => $uniacid));
pdo_update('uni_settings', array('groupdata' => iserializer(array('isexpire' => 1, 'endtime' => $groupdata['endtime'], 'oldgroupid' => $_W['account']['groupid']))), array('uniacid' => $uniacid));
$_W['account']['groupid'] = 0;
load()->model('module');
module_build_privileges();
return true;
}
return false;
}
示例2: pdo_insert
$multi['styleid'] = $styleid;
pdo_insert('site_multi', $multi);
$multi_id = pdo_insertid();
$unisettings['creditnames'] = array('credit1' => array('title' => '積分', 'enabled' => 1), 'credit2' => array('title' => '餘額', 'enabled' => 1));
$unisettings['creditnames'] = iserializer($unisettings['creditnames']);
$unisettings['creditbehaviors'] = array('activity' => 'credit1', 'currency' => 'credit2');
$unisettings['creditbehaviors'] = iserializer($unisettings['creditbehaviors']);
$unisettings['uniacid'] = $uniacid;
$unisettings['default_site'] = $multi_id;
$unisettings['sync'] = iserializer(array('switch' => 0, 'acid' => ''));
pdo_insert('uni_settings', $unisettings);
pdo_insert('mc_groups', array('uniacid' => $uniacid, 'title' => '默認會員組', 'isdefault' => 1));
$account_users = array('uniacid' => $uniacid, 'uid' => 1, 'role' => 'manager');
pdo_insert('uni_account_users', $account_users);
load()->model('module');
module_build_privileges();
$insert['account'] = trim($_GPC['account']);
$insert['name'] = trim($_GPC['name']);
$insert['level'] = 1;
$insert['type'] = 1;
if (empty($account)) {
$acid = account_create($uniacid, $insert);
if (!empty($_FILES['qrcode']['tmp_name'])) {
$_W['uploadsetting'] = array();
$_W['uploadsetting']['image']['folder'] = $acid;
//file be save in attachment/$acid
$_W['uploadsetting']['image']['extentions'] = array('jpg', 'jpeg', 'png');
$_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
$upload = file_upload($_FILES['qrcode'], 'image', "qrcode_{$acid}");
}
if (!empty($_FILES['headimg']['tmp_name'])) {
示例3: buy_package
function buy_package($user, $package_id, $total = 1)
{
if (empty($user) || empty($user["uid"])) {
return error(-1, "用戶不存在");
}
if ($total <= 0) {
return error(-1, "購買數必須大於1");
}
if (empty($user["credit2"]) || doubleval($user["credit2"]) < 0) {
return error(-1, "用戶餘額為0無法購買套餐.");
}
$group = kim_get_uni_group($package_id);
if (empty($group)) {
return error(-1, "模塊不存在.");
}
$price = doubleval($group["price"]);
if (intval($user['groupid']) > 0) {
list($price, $discount) = check_price($price, intval($user['groupid']));
}
if (doubleval($user["credit2"]) < $price * $total) {
return error(-1, "用戶餘額不足.");
}
$st = get_settings();
$day = 30;
if (intval($st[package_day]) > 0) {
$day = intval($st[package_day]);
}
$package_price = $price * $total;
$package_time = $total * $day * 24 * 60 * 60;
load()->model("account");
$account = uni_fetch();
if (empty($account)) {
return error(-1, "公眾號不存在.");
}
$settings = uni_setting($account["uniacid"], array('groupdata'));
$groupData = $settings['groupdata'] ? $settings['groupdata'] : array("endtime" => TIMESTAMP);
$package_endTime = $package_time;
if ($groupData["endtime"] - TIMESTAMP > 0) {
$package_endTime = $groupData["endtime"] - TIMESTAMP + $package_time;
}
$old_package = kim_get_uni_group($account["groupid"]);
try {
pdo_begin();
$endtime = date("Y-m-d", TIMESTAMP + $package_endTime);
load()->model('user');
$record = array();
$record['uid'] = $user["uid"];
$record['endtime'] = $endtime;
user_update($record);
$order_record = array("uniacid" => $account["uniacid"], "uid" => $user["uid"], "package" => $package_id, "buy_time" => TIMESTAMP, "expiration_time" => TIMESTAMP + $package_endTime);
pdo_insert("users_packages", $order_record);
$record_id = pdo_insertid();
if ($record_id <= 0) {
throw new Exception("保存記錄失敗");
}
//VIP時間同步
$groupData["endtime"] = $groupData["endtime"] < TIMESTAMP ? TIMESTAMP : $groupData["endtime"];
$old_over_time = date("Y-m-d", $groupData["endtime"]);
$new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
$log = array(0, sprintf("自動續費: %s 套餐續費,續費前:%s 到期; 續費後:%s 到期", $group["name"], $old_over_time, $new_over_time));
if (intval($account["groupid"]) != intval($package_id)) {
$surplus_price = $old_package["price"] * round(($groupData["endtime"] - TIMESTAMP) / 86400);
$surplus_price = $surplus_price / $day;
$surplus_time = round($surplus_price / $group["price"]) * $day;
$package_endTime = $surplus_time * 24 * 60 * 60 + $package_time;
$new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime);
$log_text = sprintf("套餐變更: <p>A、原套餐: %s , %s 到期</p><p>B、變更後: %s , %s 到期.</p>", $old_package["name"], $old_over_time, $group["name"], $new_over_time);
$log = array(0, $log_text);
if (pdo_update('uni_account', array('groupid' => $package_id), array('uniacid' => $account["uniacid"])) <= 0) {
throw new Exception("更新套餐失敗.");
}
}
$new_groupdata = array('groupdata' => iserializer(array('isexpire' => 1, 'endtime' => TIMESTAMP + $package_endTime, 'oldgroupid' => $old_package['id'], 'is_auto' => 1)));
if (pdo_update('uni_settings', $new_groupdata, array('uniacid' => $account["uniacid"])) <= 0) {
throw new Exception("更新套餐失敗!");
}
$result = user_credits_update($user["uid"], "credit2", -$package_price, $log);
if (is_error($result)) {
throw new Exception($result["message"]);
}
$_W['account']['groupid'] = $account["uniacid"];
load()->model('module');
module_build_privileges();
pdo_update("users_packages", array("record_id" => $record_id, "status" => 1), array("id" => $record_id));
pdo_commit();
return true;
} catch (Exception $e) {
pdo_rollback();
return error(-1, $e->getMessage());
}
return error(-1, "錯誤操作.");
}