Example #1
0
function mc_notice_init()
{
    global $_W;
    if (empty($_W['account'])) {
        $_W['account'] = uni_fetch($_W['uniacid']);
    }
    if (empty($_W['account'])) {
        return error(-1, '创建公众号操作类失败');
    }
    if ($_W['account']['level'] < 3) {
        return error(-1, '公众号没有经过认证,不能使用模板消息和客服消息');
    }
    $acc = WeAccount::create();
    if (is_null($acc)) {
        return error(-1, '创建公众号操作对象失败');
    }
    $setting = uni_setting();
    $noticetpl = $setting['tplnotice'];
    $acc->noticetpl = $noticetpl;
    if (!is_array($acc->noticetpl)) {
        return error(-1, '微信通知参数错误');
    }
    return $acc;
}
Example #2
0
if (empty($id)) {
    $id = intval($_GPC['id']);
}
if (!empty($id)) {
    $_W['account'] = account_fetch($id);
}
if (empty($_W['account'])) {
    exit('initial error hash or id');
}
if (empty($_W['account']['token'])) {
    exit('initial missing token');
}
$_W['acid'] = $_W['account']['acid'];
$_W['from'] == 'api';
$_W['uniacid'] = $_W['account']['uniacid'];
$_W['uniaccount'] = uni_fetch($_W['uniacid']);
$_W['account']['groupid'] = $_W['uniaccount']['groupid'];
$_W['account']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}";
$_W['account']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}";
$_W['modules'] = uni_modules();
$engine = new WeEngine();
$settings = setting_load('copyright');
if (!empty($settings['copyright']['status'])) {
    $engine->died('抱歉,站点已关闭,关闭原因:' . $settings['copyright']['reason']);
}
if ($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 1) {
    $engine->encrypt();
}
if ($_W['isajax'] && $_W['ispost'] && $_GPC['flag'] == 2) {
    $engine->decrypt();
}
    $shortcut_navs = app_navs('shortcut', $setting['id']);
    $quickmenu = iunserializer($setting['quickmenu']);
    $quickmenu = !empty($quickmenu) ? $quickmenu : array();
    $slides = pdo_fetchall("SELECT * FROM " . tablename('site_slide') . " WHERE uniacid = '{$_W['uniacid']}' AND multiid = {$default_site}  ORDER BY displayorder DESC, id DESC ");
    foreach ($slides as $key => $value) {
        $slides[$key]['thumb'] = tomedia($value['thumb']);
    }
}
if ($do == 'mc') {
    $title = '会员功能概况';
    $accounts = uni_accounts($_W['uniacid']);
    foreach ($accounts as $acid => &$account) {
        $num = pdo_fetchcolumn('SELECT COUNT(fanid) FROM ' . tablename('mc_mapping_fans') . ' WHERE acid=:acid AND follow=1 ', array(':acid' => $acid));
        $account['fansnum'] = intval($num);
    }
    $uniaccount = uni_fetch();
    $num = pdo_fetchcolumn('SELECT COUNT(fanid) FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid=:uniacid AND follow=1', array(':uniacid' => $_W['uniacid']));
    $uniaccount['fansnum'] = intval($num);
    $num = pdo_fetchcolumn('SELECT COUNT(uid) FROM ' . tablename('mc_members') . ' WHERE uniacid=:uniacid ', array(':uniacid' => $_W['uniacid']));
    $uniaccount['membernum'] = intval($num);
    $coupons = pdo_fetchall('SELECT * FROM ' . tablename('activity_coupon') . " WHERE uniacid = '{$_W['uniacid']}' AND type = 1 ORDER BY couponid DESC ");
    $tokens = pdo_fetchall('SELECT * FROM ' . tablename('activity_coupon') . " WHERE uniacid = '{$_W['uniacid']}' AND type = 2 ORDER BY couponid DESC ");
}
if ($do == 'setting') {
    $title = '功能参数概况';
}
if ($do == 'ext') {
    $title = '扩展功能概况';
    if (!empty($_W['setting']['permurls']['urls'])) {
        foreach ($_W['setting']['permurls']['urls'] as $url) {
            if (strexists($url, 'c=home&a=welcome&do=ext')) {
Example #4
0
function uni_modules($enabledOnly = true)
{
    global $_W;
    $account = uni_fetch();
    $groupid = $account['groupid'];
    if (empty($groupid)) {
        $modules = pdo_fetchall("SELECT * FROM " . tablename('modules') . " WHERE issystem = 1 ORDER BY issystem DESC, mid ASC", array(), 'name');
    } elseif ($groupid == '-1') {
        $modules = pdo_fetchall("SELECT * FROM " . tablename('modules') . " ORDER BY issystem DESC, mid ASC", array(), 'name');
    } else {
        $wechatgroup = pdo_fetch("SELECT `modules` FROM " . tablename('uni_group') . " WHERE id = :id", array(':id' => $groupid));
        $ms = '';
        if (!empty($wechatgroup['modules'])) {
            $wechatgroup['modules'] = iunserializer($wechatgroup['modules']);
            $ms = implode("','", $wechatgroup['modules']);
            $ms = " OR `name` IN ('{$ms}')";
        }
        $modules = pdo_fetchall("SELECT * FROM " . tablename('modules') . " WHERE issystem = 1{$ms} ORDER BY issystem DESC, mid ASC", array(), 'name');
    }
    foreach ($modules as $k => $v) {
        if ($v['issolution'] && $v['target'] != $_W['uniacid']) {
            unset($modules[$k]);
        }
    }
    if (!empty($modules)) {
        $ms = implode("','", array_keys($modules));
        $ms = "'{$ms}'";
        $mymodules = pdo_fetchall("SELECT `module`, `enabled`, `settings` FROM " . tablename('uni_account_modules') . " WHERE uniacid = '{$_W['uniacid']}' AND `module` IN ({$ms}) ORDER BY enabled DESC", array(), 'module');
    }
    if (!empty($mymodules)) {
        foreach ($mymodules as $name => $row) {
            if ($enabledOnly && !$modules[$name]['issystem']) {
                if ($row['enabled'] == 0 || empty($modules[$name])) {
                    unset($modules[$name]);
                    continue;
                }
            }
            if (!empty($row['settings'])) {
                $modules[$name]['config'] = iunserializer($row['settings']);
            }
            $modules[$name]['enabled'] = $row['enabled'];
        }
    }
    foreach ($modules as $name => &$row) {
        if ($row['issystem'] == 1) {
            $row['enabled'] = 1;
        } elseif (!isset($row['enabled'])) {
            $row['enabled'] = 1;
        }
        if (empty($row['config'])) {
            $row['config'] = array();
        }
        if (!empty($row['subscribes'])) {
            $row['subscribes'] = iunserializer($row['subscribes']);
        }
        if (!empty($row['handles'])) {
            $row['handles'] = iunserializer($row['handles']);
        }
        unset($modules[$name]['description']);
    }
    return $modules;
}
Example #5
0
 protected function extend_W()
 {
     global $_W;
     if (!empty($_W['openid'])) {
         load()->model('mc');
         $_W['member'] = mc_fetch($_W['openid']);
     }
     if (empty($_W['member'])) {
         $_W['member'] = array();
     }
     if (!empty($_W['acid'])) {
         load()->model('account');
         if (empty($_W['uniaccount'])) {
             $_W['uniaccount'] = uni_fetch($_W['uniacid']);
         }
         if (empty($_W['account'])) {
             $_W['account'] = account_fetch($_W['acid']);
             $_W['account']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}";
             $_W['account']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}";
             $_W['account']['groupid'] = $_W['uniaccount']['groupid'];
         }
     }
 }
Example #6
0
function Mobile_GetMember($theThis, $uniacid, $id, $openid)
{
    global $_W, $_GPC;
    $rd = new ReturnData("");
    load()->model('account');
    $account = uni_fetch();
    load()->model('mc');
    $fans = mc_fansinfo($openid, $uniacid);
    $member = mc_fetch($fans['uid'], array('realname', 'mobile', 'qq', 'msn'));
    if (empty($member)) {
        $rd->setMsg("无法识别您的身份,请发送关键字到公众号 “" . $account['name'] . "” 参加活动");
        $rd->setCode(200);
    }
    $rd->addData('fans', $fans);
    $rd->addData('member', $member);
    return $rd;
}
Example #7
0
function Mobile_CheckFans($theThis, $uniacid, $openid, $follow)
{
    global $_W, $_GPC;
    $rd = new ReturnData('');
    load()->model('account');
    $account = uni_fetch();
    if (empty($openid) || $openid == '') {
        $rd->setCode(200);
        $rd->setNode('Mobile_CheckFans');
        $rd->setMsg('请通过发送关键字到公众号 “' . $account['name'] . '” 参与活动!' . '~');
        return $rd;
    } else {
        if (empty($follow) || $follow == 0) {
            $rd->setCode(201);
            $rd->setNode('Mobile_CheckFans');
            $rd->setMsg('请先关注公众号 “' . $account['name'] . '”  , 并通过发送关键字参与活动!' . '~~');
            return $rd;
        }
    }
    return $rd;
}
Example #8
0
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("套餐变更: &lt;p&gt;A、原套餐: %s , %s 到期&lt;/p&gt;&lt;p&gt;B、变更后: %s , %s 到期.&lt;/p&gt;", $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, "错误操作.");
}
Example #9
0
 protected function extend_W()
 {
     global $_W;
     if (!empty($_W['openid'])) {
         load()->model('mc');
         $_W['member'] = mc_fetch($_W['openid']);
     }
     if (empty($_W['member'])) {
         $_W['member'] = array();
     }
     if (!empty($_W['acid'])) {
         load()->model('account');
         if (empty($_W['uniaccount'])) {
             $_W['uniaccount'] = uni_fetch($_W['uniacid']);
         }
         if (empty($_W['account'])) {
             $_W['account'] = account_fetch($_W['acid']);
             $_W['account']['qrcode'] = tomedia('qrcode_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp'];
             $_W['account']['avatar'] = tomedia('headimg_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp'];
             $_W['account']['groupid'] = $_W['uniaccount']['groupid'];
         }
     }
 }
Example #10
0
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
defined('IN_IA') or exit('Access Denied');
$uniacid = intval($_GPC['uniacid']);
$acid = intval($_GPC['acid']);
if (!empty($acid)) {
    $account = account_fetch($acid);
    if (empty($account)) {
        message('子公众号不存在或是已经被删除');
    }
    $state = uni_permission($uid, $uniacid);
    if ($state != 'founder' && $state != 'manager') {
        message('没有该公众号操作权限!', url('accound/display'), 'error');
    }
    $uniaccount = uni_fetch($account['uniacid']);
    if ($uniaccount['default_acid'] == $acid) {
        message('默认子公众号不能删除');
    }
    $uniacid = $account['uniacid'];
    pdo_delete('account', array('acid' => $acid));
    pdo_delete('account_wechats', array('acid' => $acid, 'uniacid' => $uniacid));
    cache_delete("unicount:{$uniacid}");
    cache_delete('account:auth:refreshtoken:' . $acid);
    $oauth = uni_setting($uniacid, array('oauth'));
    if ($oauth['oauth']['account'] == $acid) {
        $acid = pdo_fetchcolumn('SELECT acid FROM ' . tablename('account_wechats') . " WHERE uniacid = :id AND level = 4 AND secret != '' AND `key` != ''", array(':id' => $uniacid));
        pdo_update('uni_settings', array('oauth' => iserializer(array('account' => $acid, 'host' => $oauth['oauth']['host']))), array('uniacid' => $uniacid));
    }
    @unlink(IA_ROOT . '/attachment/qrcode_' . $acid . '.jpg');
    @unlink(IA_ROOT . '/attachment/headimg_' . $acid . '.jpg');