Exemple #1
0
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
    }
}
Exemple #2
0
<?php

$_catalogs = xt_catalogs_share(true);
$cid = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
$s = isset($_GET['s']) ? urldecode($_GET['s']) : '';
$_shares = query_shares(array('share_per_page' => 50, 'page' => isset($_GET['paged']) ? intval($_GET['paged']) : 1, 'cid' => $cid, 's' => $s));
?>
<div class="clear" style="margin-top:10px;">
    <p class="search-box">
        <label class="screen-reader-text" for="filter-search-input">搜索分享:</label>
        <input type="search" id="filter-search-input" name="s" value="<?php 
echo $s;
?>
">
        <input type="button" name="" id="filter-search-submit" class="button" value="搜索分享">
    </p>    
</div>
<div class="tablenav top">
    <div class="alignleft actions">
        <select name="cat" id="filter-cat" class="postform">
            <option value="0" <?php 
echo $cid == 0 ? 'selected' : '';
?>
>全部</option>
            <option value="-1" <?php 
echo $cid == -1 ? 'selected' : '';
?>
>未分类</option>
            <?php 
if (!empty($_catalogs)) {
    foreach ($_catalogs as $_cat) {
Exemple #3
0
function xt_admin_ajax_catalog_delete()
{
    $result = array('code' => 0, 'msg' => '', 'result' => array());
    if (!current_user_can('manage_options')) {
        $result['code'] = 500;
        $result['msg'] = '您无权操作此功能';
    }
    if (!isset($_POST['ids']) || empty($_POST['ids'])) {
        $result['code'] = 500;
        $result['msg'] = '未指定分类';
    }
    $ids = trim($_POST['ids']);
    $type = trim($_POST['type']);
    if ($result['code'] == 0) {
        xt_catalog_delete($ids);
        if ($type == 'share') {
            xt_catalogs_share(true);
            //FORCE
        } elseif ($type == 'album') {
            xt_catalogs_album(true);
            //FORCE
        }
    }
    exit(json_encode($result));
}
Exemple #4
0
 public function refresh($params = array())
 {
     xt_catalogs_share(true);
     //catalogs and tags
     return true;
 }
<?php

global $wpdb;
if (!current_user_can('publish_pages')) {
    exit('您无权操作此功能');
}
$_share_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($_share_id == 0) {
    exit('未指定要分类的分享');
}
$cids = $wpdb->get_col('SELECT cid FROM ' . XT_TABLE_SHARE_CATALOG . ' WHERE id=' . $wpdb->escape($_share_id));
$cats = xt_catalogs_share();
if (!empty($cats)) {
    echo '<div id="X_Share_Tool_Catalog" data-id="' . $_share_id . '">';
    foreach ($cats as $cat) {
        $childs = $cat->child;
        if (in_array($cat->id, $cids)) {
            echo '<span data-value="' . $cat->id . '" class="label label-default">' . esc_html($cat->title) . '</span>';
        } else {
            echo '<span data-value="' . $cat->id . '" class="label">' . esc_html($cat->title) . '</span>';
        }
        if (!empty($childs)) {
            $childCats = $childs['catalogs'];
            foreach ($childCats as $sub) {
                if (in_array($sub->id, $cids)) {
                    echo '<span data-value="' . $sub->id . '" class="label label-default">' . esc_html($sub->title) . '</span>';
                } else {
                    echo '<span data-value="' . $sub->id . '" class="label">' . esc_html($sub->title) . '</span>';
                }
            }
        }
function xt_catalogs_share_sub($cid)
{
    $_catalogs = xt_catalogs_share();
    if ($cid == 0) {
        $result = array();
        foreach ($_catalogs as $_cat) {
            $result[] = $_cat;
        }
        return $result;
    } else {
        foreach ($_catalogs as $_cat) {
            if ($_cat->id == $cid) {
                if (isset($_cat->child)) {
                    $_child = $_cat->child;
                    return isset($_child['catalogs']) ? $_child['catalogs'] : array();
                }
            }
        }
    }
    return array();
}
function xt_select_catalogs($id, $name, $class, $selected = '', $isBlank = true, $isChild = false)
{
    $roots = xt_catalogs_share();
    echo '<select id = "' . $id . '" name = "' . $name . '" class = "' . $class . '">';
    if ($isBlank) {
        echo '<option value = "0">无</option>';
    }
    foreach ($roots as $cat) {
        echo '<option value = "' . $cat->id . '" data-issub = "0" data-isfront = "' . $cat->is_front . '" ' . selected($cat->id, $selected, false) . '>' . $cat->title . '</option>';
        if ($isChild) {
            if (isset($cat->child) && !empty($cat->child) && isset($cat->child['catalogs'])) {
                $childs = $cat->child['catalogs'];
                foreach ($childs as $sub) {
                    echo '<option value = "' . $sub->id . '" data-issub = "1" ' . selected($sub->id, $selected, false) . '>&nbsp;
                        &nbsp;
                        &nbsp;
                        ' . $sub->title . '</option>';
                }
            }
        }
    }
    echo '</select>';
}