<?php
/**
 * 用户搜索结果csv文件下载
 * $Id: user_csv_download.php 81403 2015-03-30 10:16:52Z zhouz $
 * @author zhouz
 * @access public
 * @package partner.public_html
 */

// クラス・設定読み込み
require_once("manager_include.inc");

// ログインチェック
require_once("check_login.inc");

//执行日期
$last_registration_date = "2018-12-29 00:00:00";

//接受URL
$api = 'http://data.zz.baidu.com/urls?site=www.beautyplus088.com&token=Fqmo37V2P076dKwX';
$api_mobile = 'http://data.zz.baidu.com/urls?site=mobile.beautyplus088.com&token=Fqmo37V2P076dKwX';
$urls = array();
$urls_mobile = array();
//首页
$urls[] = "http://" . HOST_NAME;
//按分类列表页
$param = array();
$param["delete_flg"] = false;
$param["registration_date_MIN"] = $last_registration_date;
$category_list = ArticleCategoryMst::getList($param, "display_order", "desc");
foreach($category_list as $category) {
	$urls[] = "http://" . HOST_NAME . "/index.php/" . $category->category_id . "_1.html";
	$urls_mobile[] = "http://" . MOBILE_HOST_NAME . "/index.php/" . $category->category_id . "_1.html";
}

//按标签列表页
$param = array();
$param["delete_flg"] = false;
$param["registration_date_MIN"] = $last_registration_date;
$article_tag_list = ArticleTagsDat::getList($param,"id","desc");
foreach($article_tag_list as $tag) {
	$urls[] = "http://" . HOST_NAME . "/tag.php/" . urlencode($tag->tag) . "_1.html";
	$urls_mobile[] = "http://" . MOBILE_HOST_NAME . "/tag.php/" . urlencode($tag->tag) . "_1.html";
}
//内容详情页
$param = array();
$param["delete_flg"] = false;
$param["registration_date_MIN"] = $last_registration_date;
$article_dat_list = ArticleDat::getList($param,"id","desc");
foreach($article_dat_list as $article) {
	$urls[] = "http://" . HOST_NAME . "/preview.php/" . $article->id . ".html";
	$urls_mobile[] = "http://" . MOBILE_HOST_NAME . "/preview.php/" . $article->id . ".html";
}

//批量提交[pc]
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;

//批量提交[mobile]
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api_mobile,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls_mobile),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;

?>