function xt_cron_autoshare() { global $wpdb; if (!IS_CLOUD) { set_time_limit(0); } $date = gmdate('Y-m-d H', current_time('timestamp')); $shares = $wpdb->get_results('SELECT * FROM ' . XT_TABLE_SHARE_CRON . ' WHERE create_date<=\'' . $date . '\' LIMIT 200'); $deleteKeys = array(); if (!empty($shares)) { foreach ($shares as $share) { $share_key = $share->share_key; $user_id = $share->user_id; $user_name = $share->user_name; $album_id = $share->album_id; $data = array(); if (!empty($share->cache_data)) { $data = maybe_unserialize($share->cache_data); if (!empty($data)) { if (xt_check_share($data['share_key'], $user_id)) { $deleteKeys[] = $share_key; continue; } } } if (empty($data)) { $fetch = array(); if (startsWith($share_key, 'tb')) { //taobao $fetch = xt_share_fetch('http://item.taobao.com/item.htm?id=' . str_replace('tb_', '', $share_key)); } elseif (startWith($share_key, 'pp')) { //paipai $fetch = xt_share_fetch('http://auction1.paipai.com/' . str_replace('pp_', '', $share_key)); } if (!empty($fetch)) { $data = array('share_key' => $fetch['share_key'], 'title' => $fetch['title'], 'pic_url' => $fetch['pic_url'], 'price' => $fetch['price'], 'cid' => $fetch['cid'], 'cache_data' => $fetch['cache_data'], 'content' => '', 'from_type' => $fetch['from_type']); } } if (!empty($data)) { xt_share_share(array('share_key' => $data['share_key'], 'title' => $data['title'], 'pic_url' => $data['pic_url'], 'price' => $data['price'], 'cid' => (int) $data['cid'], 'user_id' => (int) $user_id, 'user_name' => $user_name, 'cache_data' => $data['cache_data'], 'from_type' => $data['from_type'], 'data_type' => 1, 'content' => isset($data['content']) ? trim(strip_tags($data['content'])) : null, 'album_id' => (int) $album_id)); } $deleteKeys[] = $share_key; } if (!empty($deleteKeys)) { $_keys = array(); foreach ($deleteKeys as $deleteKey) { $_keys[] = "'{$deleteKey}'"; } $wpdb->query('DELETE FROM ' . XT_TABLE_SHARE_CRON . ' WHERE share_key in (' . implode(',', $_keys) . ')'); } xt_catalogs_share(true); //reload catalogs and tags do_action('xt_page_updated', 'home'); //clear home cache } }
function xt_ajax_share_fetch() { $url = $_POST['url']; exit(json_encode(xt_share_fetch($url))); }
<?php $_url = isset($_POST['url']) ? $_POST['url'] : ''; $item = array(); $msg = ''; if (!empty($_url)) { $result = xt_share_fetch($_url, -1); if ($result['code'] == 0) { $item = $result['result']; } else { $msg = $result['msg']; } } if (!empty($item)) { $clickUrl = xt_jump_url(array('id' => get_the_share_key($item['share_key']), 'type' => $item['from_type'])); if ($item['from_type'] == 'taobao') { ?> <div class="row-fluid"> <div class="span9"> <div class="pull-left" style="width:300px;overflow:hidden"> <a href="<?php echo $clickUrl; ?> " target="_blank"> <img src="<?php echo xt_pic_url($item['pic_url'], 300, $item['from_type']); ?> "/> </a> </div> <div class="pull-left" style="margin-left: 20px;width:380px;overflow: hidden;">