Example #1
0
 public function respond()
 {
     global $_W;
     $message = $this->message;
     $from = $this->message['from'];
     $rid = $this->rule;
     $reply = pdo_fetch("SELECT * FROM " . tablename("kim_sign_reply") . " WHERE rid=:rid", array(":rid" => $rid));
     if (intval($reply['type']) == 1) {
         $news = array("title" => $reply['title'], "picurl" => $_W['attachurl'] . trim($reply['image_url'], '/'), "url" => $this->buildSiteUrl($this->createMobileUrl("sign")), "description" => $reply['description']);
         return $this->respNews($news);
     }
     $settings = getModulesSettings($this->modulename);
     $uid = getUserIdByOpenId($from);
     $login_url = $this->buildSiteUrl(url('mc'));
     if ($uid <= 0) {
         return $this->respText("请先登录后再签到! <a href='{$login_url}'>登录</a>");
     }
     list($bool, $code) = doSign($from, $settings);
     $board_url = $this->buildSiteUrl($this->createMobileUrl('LeaderBoard'));
     $my_url = $this->buildSiteUrl($this->createMobileUrl('MyPrize'));
     if (!$bool) {
         $hour = round(intval(24 / $settings['times']));
         $message = sprintf("每天可以签到%s次,每隔%s小时可签到一次", $settings['times'], $hour);
         if ($code == 'over_number') {
             return $this->respText($message . "\n\n/::d签到排行: <a href='{$board_url}'>查看</a>\n/:showlove我的奖品 <a href='{$my_url}'>查看</a>");
         }
         if ($code == 'over_time') {
             return $this->respText($reply['overtime']);
         }
     } else {
         $result = $code;
         //抽奖
         $prize_cls = new Prize();
         list($code, $message, $prize) = $prize_cls->lottery($uid, $settings['prize_group']);
         if ($code && !empty($prize)) {
             //中奖
             $result .= "\n\n /:gift有意外惊喜 %s";
             $prize_url = $this->buildSiteUrl($this->createMobileUrl('Prize', array('record_id' => $prize['record_id'])));
             $result = sprintf($result, "<a href='{$prize_url}'>查看</a>");
         } else {
             //未中奖
             $result .= "\n\n /:break很遗憾与奖品擦肩而过!";
         }
         return $this->respText("/:circle签到成功!\n" . $result . "\n\n/::d签到排行 <a href='{$board_url}'>查看</a>\n/:showlove我的奖品 <a href='{$my_url}'>查看</a>");
     }
 }
Example #2
0
 public function settingsDisplay($settings)
 {
     global $_GPC, $_W;
     $credits = uni_setting($_W['uniacid'], 'creditnames');
     $cls = new Prize();
     list($code, $groups) = $cls->groups();
     if (checksubmit()) {
         $cfg = array('times' => $_GPC['times'], 'start_time' => $_GPC['start_time'], 'end_time' => $_GPC['end_time'], 'prize_group' => $_GPC['prize_group'], 'credit_type' => $_GPC['credit_type'], 'credit' => intval($_GPC['credit']), 'rank' => intval($_GPC['rank']));
         $start_time = $cfg['start_time'];
         $start_time = strtotime($start_time);
         $end_time = $cfg['end_time'];
         $end_time = strtotime($end_time);
         if ($start_time >= $end_time) {
             message('开始时间不得晚于结束时间', 'refresh', 'error');
         } elseif ($this->saveSettings($cfg)) {
             message('保存成功', 'refresh');
         }
     }
     if (!isset($settings) || empty($settings)) {
         $UnIaCid = $_W['uniacid'];
         $par = array(':module' => $this->modulename, ':uniacid' => $UnIaCid);
         $sql = "SELECT COUNT(*) FROM " . tablename("uni_account_modules") . " WHERE module=:module AND uniacid=:uniacid";
         $row = pdo_fetchcolumn($sql, $par);
         if (empty($row) || intval($row) <= 0) {
             $cfg = array('module' => $this->modulename, 'uniacid' => $UnIaCid, 'enabled' => 1);
             pdo_insert("uni_account_modules", $cfg);
         }
     }
     if (!isset($settings['times'])) {
         $settings['times'] = '1';
     }
     if (!isset($settings['start_time'])) {
         $settings['start_time'] = '08:30';
     }
     if (!isset($settings['end_time'])) {
         $settings['end_time'] = '22:00';
     }
     if (!isset($settings['credit'])) {
         $settings['credit'] = '1';
     }
     if (!isset($settings['rank'])) {
         $settings['rank'] = '10';
     }
     include $this->template('setting');
 }
Example #3
0
    public static function makeList()
    {
        global $lng, $coach, $settings;
        HTMLOUT::frame_begin();
        # Make page frame, banner and menu.
        title($lng->getTrn('name', __CLASS__));
        echo $lng->getTrn('desc', __CLASS__) . "<br><br>\n";
        list($sel_node, $sel_node_id) = HTMLOUT::nodeSelector(array());
        $ALLOW_EDIT = is_object($coach) && $coach->isNodeCommish($sel_node, $sel_node_id);
        /* A new entry was sent. Add it to system */
        if ($ALLOW_EDIT && isset($_POST['tid']) && isset($_POST['trid'])) {
            if (get_magic_quotes_gpc()) {
                $_POST['title'] = stripslashes($_POST['title']);
                $_POST['txt'] = stripslashes($_POST['txt']);
            }
            switch ($_GET['action']) {
                case 'new':
                    status(self::create($_POST['ptype'], $_POST['tid'], $_POST['trid'], $_POST['title'], $_POST['txt']));
                    break;
            }
        }
        /* Was a request for a new entry made? */
        if (isset($_GET['action']) && $ALLOW_EDIT) {
            switch ($_GET['action']) {
                case 'delete':
                    if (isset($_GET['prid']) && is_numeric($_GET['prid'])) {
                        $pr = new Prize($_GET['prid']);
                        status($pr->delete());
                        unset($pr);
                    } else {
                        fatal('Sorry. You did not specify which prize ID you wish to delete.');
                    }
                    break;
                case 'new':
                    echo "<a href='handler.php?type=prize'><-- " . $lng->getTrn('common/back') . "</a><br><br>";
                    $_DISABLED = !isset($_POST['trid']) ? 'DISABLED' : '';
                    ?>
                <form name="STS" method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('common/tournament');
                    ?>
</b><br>
                <?php 
                    echo HTMLOUT::nodeList(T_NODE_TOURNAMENT, 'trid');
                    ?>
                <input type='submit' value='<?php 
                    echo $lng->getTrn('common/select');
                    ?>
'>
                </form>
                <br>
                <form method="POST" enctype="multipart/form-data">
                <b><?php 
                    echo $lng->getTrn('team', __CLASS__);
                    ?>
</b><br>
                <select name="tid" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    $teams = isset($_POST['trid']) ? Team::getTeams(false, array(get_parent_id(T_NODE_TOURNAMENT, (int) $_POST['trid'], T_NODE_LEAGUE)), true) : array();
                    foreach ($teams as $tid => $name) {
                        echo "<option value='{$tid}'>{$name}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <b><?php 
                    echo $lng->getTrn('kind', __CLASS__);
                    ?>
</b><br>
                <select name="ptype" <?php 
                    echo $_DISABLED;
                    ?>
>
                    <?php 
                    foreach (self::getTypes() as $ptype => $desc) {
                        echo "<option value='{$ptype}'>{$desc}</option>\n";
                    }
                    ?>
                </select>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_title', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('title', __CLASS__);
                    ?>
<br>
                <input type="text" name="title" size="60" maxlength="100" value="" <?php 
                    echo $_DISABLED;
                    ?>
>
                <br><br>
                <?php 
                    echo '<b>' . $lng->getTrn('g_about', __CLASS__) . '</b> &mdash; ' . $lng->getTrn('about', __CLASS__);
                    ?>
<br>
                <textarea name="txt" rows="15" cols="100" <?php 
                    echo $_DISABLED;
                    ?>
></textarea>
                <br><br><br>
                <input type='hidden' name='trid' value='<?php 
                    echo $_DISABLED ? 0 : $_POST['trid'];
                    ?>
'>
                <input type="submit" value="<?php 
                    echo $lng->getTrn('submit', __CLASS__);
                    ?>
" name="Submit" <?php 
                    echo $_DISABLED;
                    ?>
>
                </form>
                <br>
                <?php 
                    return;
                    break;
            }
        }
        if ($ALLOW_EDIT) {
            echo "<br><a href='handler.php?type=prize&amp;action=new'>" . $lng->getTrn('new', __CLASS__) . "</a><br>\n";
        }
        /* Print the prizes */
        self::printList($sel_node, $sel_node_id, $ALLOW_EDIT);
        HTMLOUT::frame_end();
    }
Example #4
0
 public function doWebPrizes()
 {
     global $_GPC, $_W, $ptr_title;
     checklogin();
     load()->func('tpl');
     $op = $_GPC['op'];
     $group_id = intval($_GPC['group_id']);
     $settings = getModulesSettings($this->modulename);
     if ($group_id <= 0) {
         $group_id = $settings['prize_group'];
     }
     $_GPC['group_id'] = $group_id;
     $ops = array('display', 'edit', 'delete', 'test', 'record');
     $op = in_array($op, $ops) ? $op : 'display';
     $cls = new Prize();
     $ptr_title = '奖品例表';
     //ajax 按钮
     if ($_W['ispost'] && $_W['isajax']) {
         if (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'status' && $cls->change()) {
             exit('success');
         } elseif (!empty($_GPC['fieldmap']) && $_GPC['fieldmap'] == 'release' && $cls->release()) {
             exit('success');
         }
         exit('操作失败');
     }
     if ($op == 'delete') {
         if ($cls->delete()) {
             message('删除成功!', $this->createWebUrl('Prizes'));
         }
     } elseif ($op == 'edit') {
         list($code, $groups) = $cls->groups();
         $id = $_GPC['id'];
         $_W['page']['title'] = intval($id) > 0 ? '奖品编辑 - 主要业务模块 - 签到' : '奖品添加 - 主要业务模块 - 签到';
         $ptr_title = intval($id) > 0 ? '奖品编辑' : '奖品添加';
         list($code, $message, $prize) = $cls->edit();
         if (!$code) {
             message($message);
         }
         if (intval($id) > 0 && empty($prize)) {
             message('奖品不存在.', $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
         if ($code && !empty($message)) {
             message($message, $this->createWebUrl('Prizes', array('group_id' => $group_id)));
         }
     } elseif ($op == 'test') {
         $cls->test_lottery(1, $settings['prize_group']);
     } elseif ($op == 'record') {
         $prize = $cls->findPrize();
     }
     if (checksubmit('import')) {
         $cls->import();
     }
     //导入奖品
     list($list, $total, $pager) = $cls->_list();
     //未领
     include $this->template('prizes');
 }
Example #5
0
 */
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$_W['page']['title'] = "签到领红包啦";
//检查是否登录
checkauth();
$settings = getModulesSettings($this->modulename);
$times = intval($settings['times']) <= 0 ? 1 : intval($settings['times']);
$today_sign = getUserTodaySign($_W['member']['uid'], $times);
//今天签到数据
if (checksubmit('sign')) {
    list($qd_code, $qd_message) = doWebSign($settings);
    if ($qd_code === 1) {
        //签到成功
        //抽奖
        $prize_cls = new Prize();
        list($code, $message, $prize) = $prize_cls->lottery($_W['member']['uid'], $settings['prize_group']);
        if ($code && !empty($prize) && !empty($prize['code']) && intval($prize['record_id']) > 0) {
            //中奖
            $prize_item = array("prize_url" => $this->createMobileUrl('Prize', array('record_id' => $prize['record_id'])), "prize_name" => $prize['prize_name'], "code" => $prize['code']);
            unset($prize);
        }
    }
    $result = array("code" => $qd_code, "title" => $qd_code === 1 ? "签到成功!" : "签到失败", "message" => $qd_message, "prize" => $prize_item);
    header('Content-Type:text/json; charset=utf-8');
    exit(json_encode($result));
}
if (!empty($today_sign)) {
    $hour = round(intval(24 / $times));
    $message = sprintf("每天可以签到 %s 次,每隔 %s 小时可签到一次", $times, $hour);
    message($message, $this->createMobileUrl('LeaderBoard'));