function xt_admin_ajax_share_update() { $result = array('code' => 0, 'msg' => '', 'result' => array()); if (!current_user_can('manage_options')) { $result['code'] = 500; $result['msg'] = '您无权操作此功能'; } if (!isset($_POST['id']) || empty($_POST['id'])) { $result['code'] = 500; $result['msg'] = '未指定分享'; } $id = intval(trim($_POST['id'])); $cids = isset($_POST['cids']) ? $_POST['cids'] : ''; if ($result['code'] == 0) { global $wpdb; $query = "SELECT t.*, tr.id AS share_id FROM " . XT_TABLE_CATALOG . " AS t INNER JOIN " . XT_TABLE_SHARE_CATALOG . " AS tr ON t.id = tr.cid WHERE t.type = 'share' AND tr.id =" . $id . " ORDER BY t.sort ASC,t.count DESC"; $term = $wpdb->get_results($query); $old = array(); if (!empty($term)) { foreach ($term as $_term) { $old[] = $_term->id; } } $cids = array_map('intval', explode(',', $cids)); if (empty($cids)) { $cids = array(); } $deleteIds = array_diff($old, $cids); //delete $addIds = array_diff($cids, $old); //add if (!empty($deleteIds)) { foreach ($deleteIds as $del) { xt_delete_share_catalog($del, $id); } } if (!empty($addIds)) { foreach ($addIds as $add) { xt_new_share_catalog(array('cid' => $add, 'id' => $id)); } } $share = get_share($id); $term = $wpdb->get_results($query); //reload xt_update_catalog_terms_cache($id, $term, 'share'); exit(xt_row_share($share, isset($_POST['alternate']) && $_POST['alternate'] ? 0 : 1)); } exit(json_encode($result)); }
function index_yaoqing() { global $_G; $content = $_G[setting][title]; $content .= ",独家精品优惠购,为你精心挑选最优惠的折扣商品,每天9点限时限量秒杀,汇聚淘宝网千款精品1折起,惊喜不断,疯抢不停,更有9.9秒杀、品牌团、热门活动给您带来惊喜!"; $arr = array('content' => $content, 'title' => '要是早点发现' . $_G[setting][title] . '就好了,就不用花那么多冤枉钱啦!' . $_G[siteurl] . '/?u=' . $_G[uid], 'picurl' => $_G[siteurl] . $_G[setting][logo], 'url' => $_G[siteurl] . '/?u=' . $_G[uid]); $share = get_share($arr); return array('share' => $share); }
/** * Retrieve share title. * * * @param int $id Optional. share ID. * @return string */ function get_the_share_title($id = 0) { $share =& get_share($id); $title = isset($share->title) ? $share->title : ''; $id = isset($share->id) ? $share->id : (int) $id; return apply_filters('the_share_title', $title, $id); }
/** * Inserts a album to the database. * * @param array $albumdata Contains information on the album. * @return int The new album's ID. */ function xt_insert_share_album($albumdata) { global $wpdb; extract(stripslashes_deep($albumdata), EXTR_SKIP); $_share = get_share($id); if (!empty($_share)) { $data = compact('user_id', 'user_name', 'id', 'album_id', 'create_date', 'create_date_gmt'); if ($wpdb->insert(XT_TABLE_SHARE_ALBUM, $data)) { $count = xt_update_album_count($album_id, $_share); return $id; } } return 0; }
function xt_update_comment_count_now($share_id) { global $wpdb; $share_id = (int) $share_id; if (!$share_id) { return false; } if (!($share = get_share($share_id))) { return false; } $old = (int) $share->comment_count; $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . XT_TABLE_SHARE_COMMENT . " WHERE share_id = %d AND status = 1", $share_id)); $wpdb->update(XT_TABLE_SHARE, array('comment_count' => $new), array('id' => $share_id)); do_action('xt_update_comment_count', $share_id, $new, $old); do_action('xt_edit_post', $share_id, $share); return true; }
function xt_insert_share_catalog($catalogdata) { global $wpdb; extract(stripslashes_deep($catalogdata), EXTR_SKIP); $_catalog = xt_get_catalog($cid); $_share = get_share($id); if (!empty($_catalog) && !empty($_share)) { $data = compact('id', 'cid', 'create_date_gmt'); if ($wpdb->insert(XT_TABLE_SHARE_CATALOG, $data)) { $count = xt_update_catalog_count($cid); return $id; } } return 0; }
function share() { global $_G; $type = $_GET[type]; if ($_GET[id] || $_GET[aid]) { $aid = $_GET[id] ? intval($_GET[id]) : intval($_GET[aid]); $goods = D(array('and' => 'and aid = ' . $aid)); if ($goods[aid] > 0) { $share = get_share($goods); } $desc = '分享商品-' . $goods[title] . '-' . $type . '-aid=' . $aid; $share_type = 'share_goods'; } else { $share = get_share($goods); $desc = '分享站点'; $share_type = 'share_web'; } if (isset($share[$type]) && $share[$type]) { $url = $share[$type]; if ($_G[uid]) { $count = getcount('sign', " uid = " . $_G[uid] . " AND `desc`='" . $desc . "' AND type = '" . $share_type . "'"); $is_add = false; if ($count == 0) { $is_add = true; } $today = dmktime(dgmdate(TIMESTAMP, 'd')); $count_day = getcount('sign', " uid = " . $_G[uid] . " AND type = '" . $share_type . "' AND dateline >=" . $today); if ($share_type == 'web' || $share_type == 'share_web') { if ($count_day > $_G[setting][share_web_num]) { $is_add = false; } } elseif ($share_type == 'share_goods') { if ($count_day > $_G[setting][share_goods_num]) { $is_add = false; } } if ($is_add) { $jf = $_G[setting][share_goods]; $add_jf = $_G['member']['jf'] + $jf; $sid = insert_sign(array('desc' => $desc, 'type' => 'share_goods', 'org_jf' => $add_jf, 'jf' => $jf)); if ($sid) { update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); } } } } else { $url = $share['weibo']; } _header("Location:" . $url); }