Пример #1
0
 function insert($arr, $id)
 {
     global $_G;
     if (!$arr) {
         return false;
     }
     $arr['nick'] = $arr['nick'] ? trim($arr['nick']) : '';
     $arr['sid'] = $arr['sid'] ? trim($arr['sid']) : '';
     $arr['title'] = $arr['title'] ? trim($arr['title']) : '';
     $arr['desc'] = $arr['desc'] ? trim($arr['desc']) : '';
     $arr['pic_path'] = $arr['pic_path'] ? trim($arr['pic_path']) : '';
     $arr['picurl'] = $arr['picurl'] ? trim($arr['picurl']) : '';
     $arr['banner'] = $arr['banner'] ? trim($arr['banner']) : '';
     $arr['url'] = $arr['url'] ? trim($arr['url']) : '';
     $arr['start_time'] = dmktime($arr['start_time']);
     $arr['end_time'] = dmktime($arr['end_time']);
     $arr['zk'] = floatval($arr['zk']);
     $arr['cate'] = intval($arr['cate']);
     $arr['shop_type'] = intval($arr['shop_type']);
     $arr['hide'] = intval($arr['hide']);
     $arr['sort'] = intval($arr['sort']);
     if ($id > 0) {
         $id = DB::update('shop', $arr, 'id=' . $id);
         api_post(array('a' => 'update', 'table' => 'shop', 'data' => $arr, 'pre_key' => 'sid', 'id' => $arr['sid'], 'cache' => 'channels,all_channel'));
     } else {
         $arr['dateline'] = TIMESTAMP;
         $id = DB::insert('shop', $arr, 1);
         if ($id > 0) {
             api_post(array('a' => 'insert', 'table' => 'shop', 'data' => $arr, 'cache' => 'shop,shop_type', 'id' => $id));
         }
     }
     return $id;
 }
Пример #2
0
 function cache()
 {
     global $_G;
     if ($_GET['onsubmit'] && check()) {
         if ($_GET[postdb][system_cache] == 1) {
             memory('clear');
             loadcache($_G[_config][cache_list], 'update');
         }
         api_post(array('m' => 'cache', 'a' => 'update', 'cache_list' => implode(',', $_G[_config][cache_list])));
         remove_dir('web/templates_c/');
         cpmsg('更新成功', 'success', 'm=tools&a=cache');
         return false;
     }
     $this->show('tools/cache');
 }
Пример #3
0
 function insert($arr, $update = false)
 {
     global $_G;
     if (!$arr || !$arr['num_iid']) {
         return false;
     }
     $num_iid = trim($arr['num_iid']);
     $res = DB::fetch_first("SELECT aid FROM " . DB::table('goods') . " WHERE num_iid='{$num_iid}'");
     if ($res[aid] > 0) {
         if ($update) {
             return $this->update($arr, $res['aid']);
         } else {
             return false;
         }
     }
     if ($arr['images'] && is_array($arr['images'])) {
         $arr['images'] = array_filter($arr['images']);
         $arr['images'] = implode(',', $arr['images']);
     } elseif (!$arr['images']) {
         $arr['images'] = '';
     }
     $arr['sid'] = intval($arr['sid']);
     $arr['fid'] = intval($arr['fid']);
     $arr['flag'] = intval($arr['flag']);
     $arr['sort'] = intval($arr['sort']);
     $arr['num'] = intval($arr['num']);
     $arr['baoyou'] = intval($arr['baoyou']);
     $arr['views'] = intval($arr['views']);
     $arr['hide'] = intval($arr['hide']);
     $arr['post'] = intval($arr['post']);
     $arr['cate'] = intval($arr['cate']);
     $arr['check'] = intval($arr['check']);
     $arr['shop_type'] = intval($arr['shop_type']);
     $arr['sum'] = intval($arr['sum']);
     $arr['bili'] = $arr['bili'] ? $arr['bili'] : '';
     $arr['apply_user'] = $arr['apply_user'] ? trim($arr['apply_user']) : '';
     $arr['apply_phone'] = $arr['apply_phone'] ? trim($arr['apply_phone']) : '';
     $arr['apply_wangwang'] = $arr['apply_wangwang'] ? trim($arr['apply_wangwang']) : '';
     $arr['keywords'] = $arr['keywords'] ? trim($arr['keywords']) : '';
     $arr['description'] = $arr['description'] ? trim($arr['description']) : '';
     $arr['apply_qq'] = $arr['apply_qq'] ? trim($arr['apply_qq']) : '';
     if ($arr['ly']) {
         $arr['ly'] = trim($arr['ly']);
         $arr['ly'] = strip_tags($arr['ly']);
     }
     $arr['return_msg'] = $arr['return_msg'] ? trim($arr['return_msg']) : '';
     $arr['num_iid'] = $arr['num_iid'] ? trim($arr['num_iid']) : '';
     $arr['title'] = $arr['title'] ? trim($arr['title']) : '';
     $arr['nick'] = $arr['nick'] ? trim($arr['nick']) : '';
     $arr['picurl'] = $arr['picurl'] ? trim($arr['picurl']) : $arr['images'][0];
     $arr['url'] = 'http://item.taobao.com/item.htm?id=' . $arr['num_iid'];
     $arr['price'] = $arr['price'] ? sprintf("%.1f", $arr['price']) : 0;
     $arr['city'] = $arr['city'] ? trim($arr['city']) : '';
     $arr['state'] = $arr['state'] ? trim($arr['state']) : '';
     $arr['message'] = $arr['message'] ? trim($arr['message']) : '';
     $arr['username'] = $_G['username'] ? trim($_G['username']) : '外星人';
     $arr['uid'] = $_G['uid'] ? intval($_G['uid']) : 0;
     $arr['yh_price'] = $arr['yh_price'] ? sprintf("%.1f", $arr['yh_price']) : $arr['price'];
     $arr['start_time'] = dmktime($arr['start_time']);
     $arr['end_time'] = dmktime($arr['end_time']);
     $arr['dateline'] = $arr['dateline'] > 0 ? $arr['dateline'] : TIMESTAMP;
     $arr['posttime'] = $arr['posttime'] > 0 ? $arr['posttime'] : TIMESTAMP;
     $arr['like'] = intval($arr[like]);
     $arr['open_iid'] = $arr['open_iid'] ? trim($arr['open_iid']) : '';
     $arr['title'] = trim_html($arr['title'], 1);
     $arr['title'] = cutstr($arr['title'], 250, '');
     $arr['ly'] = cutstr($arr['ly'], 250, '');
     $arr['return_msg'] = cutstr($arr['return_msg'], 250, '');
     unset($arr['zk']);
     if (!$arr['keywords'] && $_G[setting][auto_keywords] == 1) {
         $arr['keywords'] = get_keywords($arr['title']);
     }
     try {
         $id = DB::insert('goods', $arr, 1);
     } catch (PDOException $e) {
         L('商品ID重复', 'error');
         return false;
     }
     if ($id > 0) {
         $arr['aid'] = $id;
         api_post(array('a' => 'insert', 'table' => 'goods', 'data' => $arr));
     }
     return $id;
 }
Пример #4
0
 function cate_add()
 {
     global $_G;
     if ($_GET['onsubmit'] && check()) {
         $cate = get_filed('cate', $_GET['postdb'], $_GET['id']);
         $cate['page'] = $cate['page'] ? intval($cate['page']) : 20;
         $url = '';
         if ($_FILES[file]) {
             $pic = upload();
             if ($pic) {
                 $cate[picurl] = $pic;
             }
         }
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             $r = DB::update('cate', $cate, "id=" . $id);
             if ($r > 0) {
                 api_post(array('a' => 'update', 'table' => 'cate', 'data' => $cate, 'pre_key' => 'id', 'id' => $id, 'cache' => 'cate'));
             }
             $url = '&id=' . $id;
             $msg = '修改';
         } else {
             $msg = '添加';
             $cate['dateline'] = TIMESTAMP;
             $r = DB::insert('cate', $cate, true);
             if ($r > 0) {
                 api_post(array('a' => 'insert', 'table' => 'cate', 'data' => $cate, 'cache' => 'cate', 'id' => $r));
             }
         }
         loadcache("cate", 'update');
         cpmsg($msg . '分类成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url);
         return false;
     } elseif ($_GET['id']) {
         $id = intval($_GET['id']);
         $cate = $_G['cate'][$id];
     } else {
         $cate = get_filed('cate');
     }
     $this->add(array('cate' => $cate));
     $this->show();
 }
Пример #5
0
 function del()
 {
     global $_G;
     if (!$_GET['id']) {
         cpmsg('抱歉,要删除的店铺ID不存在', 'error', "m=shop&a=main");
         return false;
     }
     $id = intval($_GET['id']);
     if (!$_GET['ok']) {
         cpmsg('您确定要删除当前店铺吗?删除后不可恢复?', 'error', "m=shop&a=del&ok=1&id=" . $id, '确定删除', "<p><a href='" . URL . "m=shop&a=main'>取消</a></p>");
         return false;
     } else {
         $sid = DB::result_first("SELECT sid FROM " . DB::table('shop') . " WHERE id = " . $id);
         api_post(array('a' => 'delete', 'table' => 'shop', 'id' => $sid, 'pre_key' => 'sid', 'cache' => 'shop,shop_type'));
         DB::delete("shop", "id=" . $id);
         cpmsg('删除成功', 'success', "m=shop&a=main");
         return false;
     }
 }
Пример #6
0
 function del()
 {
     global $_G;
     if (!$_GET['id']) {
         cpmsg('抱歉,要删除的文章ID不存在', 'error', "m=article&a=main");
         return false;
     }
     $id = intval($_GET['id']);
     if (!$_GET['ok']) {
         cpmsg('您确定要删除当前文章吗?删除后不可恢复?', 'error', "m=article&a=del&ok=1&id=" . $id, '确定删除', "<p><a href='" . URL . "m=article&a=main'>取消</a></p>");
         return false;
     } else {
         DB::delete("article", "id=" . $id);
         api_post(array('a' => 'delete', 'table' => 'article', 'id' => $id, 'pre_key' => 'id'));
         cpmsg('删除成功', 'success', "m=article&a=main");
         return false;
     }
 }
Пример #7
0
 function type_post()
 {
     global $_G;
     if ($_GET['onsubmit'] && check()) {
         $type = get_filed('pics_type', $_GET['postdb'], $_GET['id']);
         $url = '';
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             DB::update('pics_type', $type, "id=" . $id);
             api_post(array('a' => 'update', 'table' => 'pics_type', 'data' => $type, 'pre_key' => 'id', 'id' => $id, 'cache' => 'pics_type'));
             $url = '&id=' . $id;
             $msg = '修改';
         } else {
             $msg = '添加';
             $r = DB::insert('pics_type', $type, true);
             if ($r > 0) {
                 api_post(array('a' => 'insert', 'table' => 'pics_type', 'data' => $type, 'cache' => 'pics_type', 'id' => $r));
             }
         }
         loadcache('pics', 'update');
         loadcache('pics_type', 'update');
         cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url);
         return false;
     } elseif ($_GET['id']) {
         $type = DB::fetch_first("SELECT * FROM " . DB::table('pics_type') . " WHERE id = " . intval($_GET['id']));
     } else {
         $type = get_filed('pics_type');
     }
     $this->add(array('type' => $type));
     $this->show();
 }
Пример #8
0
 function del()
 {
     global $_G;
     if (!$_GET['id']) {
         cpmsg('抱歉,要删除的广告ID不存在', 'error', "m=ad&a=main");
         return false;
     }
     $id = intval($_GET['id']);
     if (!$_GET['ok']) {
         cpmsg('您确定要删除当前广告吗?删除后不可恢复?', 'error', "m=ad&a=del&ok=1&id=" . $id, '确定删除', "<p><a href='" . URL . "m=ad&a=main'>取消</a></p>");
         return false;
     } else {
         DB::delete(__CLASS__, "id=" . $id);
         loadcache(__CLASS__, 'update');
         api_post(array('a' => 'delete', 'table' => 'ad', 'id' => $id, 'pre_key' => 'id', 'cache' => 'ad'));
         cpmsg('删除成功', 'success', "m=ad&a=main");
         return false;
     }
 }
Пример #9
0
    Private Mail
 *******************/
$app->get('/api/inbox', function () use($app) {
    return api_pmail_list($app);
});
$app->get('/api/inbox/{id:[0-9]+}', function ($msg_id) use($app) {
    return api_pmail($app, $msg_id);
});
$app->get('/api/sent', function () use($app) {
    return api_pmail_list($app, false);
});
$app->get('/api/sent/{id:[0-9]+}', function ($msg_id) use($app) {
    return api_pmail($app, $msg_id);
});
$app->post('/api/sent', function () use($app) {
    return api_post($app, 0, 0, true);
});
function api_pmail_list($app, $inbox = true)
{
    global $prop_tz, $server_tz, $user_id, $pm_deleted_by_receiver, $pm_deleted_by_sender;
    $response = new Response();
    $count = $app->request->getQuery('count');
    if (!is_null($count)) {
        $count = intval($count);
    } else {
        $count = 20;
    }
    $max_id = $app->request->getQuery('id');
    if (is_null($max_id)) {
        $max_id = -1;
    } else {
Пример #10
0
 function friend_link_add()
 {
     global $_G;
     //节省一个模板,就得先把这些字段给定义,不然在模板中显示都是NULL,正常的PHP是显示'',TAE的PHP与普通的PHP不一样
     if ($_GET['onsubmit'] && check()) {
         $friend_link = get_filed('friend_link', $_GET['postdb'], $_GET['id']);
         if ($_FILES[file]) {
             $src = upload();
             if ($src) {
                 $friend_link[picurl] = $src;
             }
         }
         if ($_GET['id']) {
             $id = intval($_GET['id']);
             DB::update('friend_link', $friend_link, "id=" . $id);
             loadcache('friend_link', 'update');
             api_post(array('a' => 'update', 'table' => 'friend_link', 'data' => $friend_link, 'pre_key' => 'id', 'id' => $id, 'cache' => 'friend_link'));
             cpmsg('修改成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . '&id=' . $id);
             return false;
         } else {
             $friend_link['dateline'] = TIMESTAMP;
             $r = DB::insert('friend_link', $friend_link, true);
             if ($r > 0) {
                 api_post(array('a' => 'insert', 'table' => 'friend_link', 'data' => $friend_link, 'cache' => 'friend_link', 'id' => $r));
             }
             loadcache('friend_link', 'update');
             cpmsg('添加成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__);
             return false;
         }
     } elseif ($_GET['id']) {
         //编辑
         $id = intval($_GET['id']);
         if (!$_G['friend_link'][$id]) {
             cpmsg('抱歉,该友情链接不存在', 'error', 'm=' . __CLASS__ . '&a=friend_link');
             return false;
         } else {
             $friend_link = $_G['friend_link'][$id];
         }
     } else {
         $friend_link = get_filed('friend_link');
     }
     $this->add(array('friend_link' => $friend_link));
     $this->show();
 }
Пример #11
0
 function main()
 {
     global $_G;
     if ($_GET['onsubmit'] && check() && !$_GET[search]) {
         $page = $_G[page] > 1 ? '&page=' . $_G[page] : '';
         foreach ($_GET[ids] as $k => $v) {
             if ($_GET[del][$k] == 0) {
                 continue;
             }
             $aid = intval($v);
             $arr = array();
             $arr['start_time'] = dmktime($_GET['start_time'][$k]);
             $arr['end_time'] = dmktime($_GET['end_time'][$k]);
             $arr['sort'] = intval($_GET['sort'][$k]);
             if ($_GET['cate'][$k] > 0) {
                 $arr['cate'] = intval($_GET['cate'][$k]);
             }
             $arr['hide'] = intval($_GET['hide'][$k]);
             if ($_GET['cate_in'] != '-1') {
                 $arr['cate'] = intval($_GET['cate_in']);
             }
             if ($_GET['flag_in'] > 0) {
                 $arr['flag'] = intval($_GET['flag_in']);
             }
             if ($_GET['hide_in'] == 1) {
                 $arr['hide'] = 1;
             }
             if ($_GET['check'] == 1) {
                 $arr['check'] = 1;
             }
             if ($_GET['in_fid']) {
                 $arr['fid'] = intval($_GET['in_fid']);
             }
             if ($_GET['start_time_in'] && dmktime($_GET['start_time_in']) > 0) {
                 $arr['start_time'] = dmktime($_GET['start_time_in']);
             }
             if ($_GET['end_time_in'] && dmktime($_GET['end_time_in']) > 0) {
                 $arr['end_time'] = dmktime($_GET['end_time_in']);
             }
             $num_iid = $_GET['num_iid'][$k];
             if ($_GET['_del_all'] == 1 && $_GET['del'][$k]) {
                 api_post(array('a' => 'delete', 'table' => 'goods', 'id' => $num_iid, 'pre_key' => 'num_iid'));
                 DB::delete("goods", "aid=" . intval($aid));
             } else {
                 api_post(array('a' => 'update', 'table' => 'goods', 'data' => $arr, 'pre_key' => 'num_iid', 'id' => $num_iid));
                 DB::update("goods", $arr, "aid=" . $aid);
             }
         }
         $this->add(array('goods' => $goods, 'field' => $field, 'bm_status_text' => $bm_status_text));
         $url = '';
         cpmsg('操作成功', 'success');
         return false;
     }
     $and = ' AND `post` > 0';
     $url = '';
     if (isset($_GET['checks'])) {
         $check = intval($_GET['checks']);
         $and .= " AND `check` =" . $check;
         $url .= "&checks=" . $check;
     }
     $rs = D(array('and' => $and, 'all' => true, 'order' => 'aid ASC'), array('url' => URL . "m=apply&a=main" . $url, 'size' => 40));
     if ($_G[setting][bm_status_text]) {
         if (!is_array($_G[setting][bm_status_text])) {
             $bm_status_text = array();
             $tmp = explode("\r\n", $_G[setting][bm_status_text]);
             foreach ($tmp as $k => $v) {
                 $v = explode("|", $v);
                 $bm_status_text[$v[0]] = array('status' => $v[0], 'name' => $v[1], 'content' => $v[2]);
             }
         } else {
             $bm_status_text = $_G[setting][bm_status_text];
         }
     }
     $rs[bm_status_text] = $bm_status_text;
     $this->add($rs);
     $this->show('apply/main');
 }