Exemplo n.º 1
0
function insert($t_key, $t_keys, $t_adkey, $t_layer)
{
    global $db;
    global $bn;
    global $index;
    global $cfg_dbqz;
    $epath = get_epath($t_key);
    //生成标题
    $arr_keys = explode(',', $t_keys);
    shuffle($arr_keys);
    $arr_keys = array_slice($arr_keys, 0, 2);
    $title = $t_key . '_' . implode('_', $arr_keys);
    $sql = "INSERT ignore  INTO `" . $cfg_dbqz . "cat`(`key`,`title`,`keys`,`epath`, `ad_key`, `layer`) VALUES ('{$t_key}','{$title}','{$t_keys}','{$epath}', '{$t_adkey}', {$t_layer});";
    $db->query($sql);
    $x = $db->affected_rows();
    $bn++;
    if ($bn == 5) {
        echo "<br>-------------error:{$t_key}-------------<br>";
        $x = 1;
    }
    //连续5词获取不到唯一id则跳过
    if ($x != 1) {
        insert($t_key, $t_keys, $t_adkey, $t_layer);
    }
}
Exemplo n.º 2
0
function out_view($arr, $arr_view, $domain, $base_url)
{
    global $cfg_tk_pid;
    $con = file_get_contents("./templets/view.html");
    /* =================
     * 生成链接
     * =================
     *
     * 生成相关链接
     * $key_link:由关键词列表生成关键词连接集
     */
    $arr_keys = explode(",", $arr['keys']);
    //生成相关关键词链接
    $key_link = '';
    //由关键词动态生成,不记录在cache,但要输出
    foreach ($arr_keys as $kk) {
        $key_epath = get_epath($kk);
        $arr_temp = explode("/", $key_epath);
        $key_link .= '<li><a href="http://' . $arr_temp[0] . $domain . '/' . $arr_temp[1] . '">' . $kk . '</a></li>';
    }
    /*
     * $tag_link:生成tag链接,包含随机部分及互连部分
     */
    $tag_link = $arr['flink'];
    //生成tag链接,包含随机部分及互连部分(数据库给出)
    $arr_randkey = explode(',', $arr['tag_key']);
    foreach ($arr_randkey as $kk) {
        $key_epath = get_epath($kk);
        $arr_temp = explode("/", $key_epath);
        $tag_link .= '<li><a href="http://' . $arr_temp[0] . $domain . '/' . $arr_temp[1] . '">' . $kk . '</a></li>';
    }
    $base = str_replace('/x', '', $base_url . 'x');
    /*
     * 替换数组
     */
    $arr_rep = array();
    $arr_rep['key'] = $arr['key'];
    $arr_rep['title'] = $arr_view['title'];
    $arr_rep['maintitle'] = $arr['title'];
    $description = preg_replace("%<[^>]+>%", ',', $arr_view['description']);
    $description = substr_utf8($description, 0, 50);
    $arr_rep['miaoshu'] = $description;
    $arr_rep['base_url'] = $base;
    $arr_rep['body'] = $arr_view['body'] . "<br>" . "您可能感兴趣:<br>" . $arr_view['x_link'];
    if ($arr_rep['body'] == '') {
        //如果尚未生成文章内容
        $arr_rep['body'] = '暂无数据,请等待。错误编码:' . md5($base_url);
    }
    $arr_rep['adkey'] = $arr['adkey'];
    $arr_rep['adkey_code'] = urlencode($arr['adkey']);
    $arr_rep['adkey_iconv'] = urlencode(iconv("UTF-8", "GBK//IGNORE", $arr['adkey']));
    $arr_rep['pid'] = $cfg_tk_pid;
    $arr_rep['keys_link'] = $key_link;
    $arr_rep['tag_link'] = $tag_link;
    /*
     * 替换
     */
    foreach ($arr_rep as $k => $v) {
        $con = str_replace('{' . $k . '}', $v, $con);
    }
    echo $con;
    include './fun/robot.php';
}
Exemplo n.º 3
0
function out_index($arr, $domain, $base_url)
{
    global $cfg_tk_pid;
    $con = file_get_contents("./templets/index.html");
    /* =================
     * 生成链接
     * =================
     *
     * 生成相关链接
     * $key_link:由关键词列表生成关键词连接集
     */
    $arr_keys = explode(",", $arr['keys']);
    //生成相关关键词链接
    $key_link = '';
    //由关键词动态生成,不记录在cache,但要输出
    foreach ($arr_keys as $kk) {
        $key_epath = get_epath($kk);
        $arr_temp = explode("/", $key_epath);
        $key_link .= '<li><a href="http://' . $arr_temp[0] . $domain . '/' . $arr_temp[1] . '">' . $kk . '</a></li>';
    }
    /*
     * $tag_link:生成tag链接,包含随机部分及互连部分
     */
    $tag_link = $arr['flink'];
    //生成tag链接,包含随机部分及互连部分(数据库给出)
    $arr_randkey = explode(',', $arr['tag_key']);
    foreach ($arr_randkey as $kk) {
        $key_epath = get_epath($kk);
        $arr_temp = explode("/", $key_epath);
        $tag_link .= '<li><a href="http://' . $arr_temp[0] . $domain . '/' . $arr_temp[1] . '">' . $kk . '</a></li>';
    }
    /*
     * 替换数组
     */
    $arr_rep = array();
    $arr_rep['key'] = $arr['key'];
    $arr_rep['keys'] = $arr['keys'];
    $arr_rep['title'] = $arr['title'];
    $arr_rep['adkey'] = $arr['adkey'];
    $arr_rep['adkey_code'] = urlencode($arr['adkey']);
    $arr_rep['adkey_iconv'] = urlencode(iconv("UTF-8", "GBK//IGNORE", $arr['adkey']));
    $arr_rep['pid'] = $cfg_tk_pid;
    $arr_rep['keys_link'] = $key_link;
    $arr_rep['tag_link'] = $tag_link;
    $arr_rep['ov_url'] = 'http://' . $base_url . 'view-' . $arr['rid'] . '.html';
    $arr_rep['ov_title'] = $arr['ov_title'];
    $arr_rep['ov_des'] = $arr['ov_des'];
    $arr_rep['rn_url'] = 'http://' . $base_url . 'read-' . $arr['rnid'] . '.html';
    $arr_rep['rn_title'] = $arr['rn_title'];
    $arr_rep['rn_des'] = $arr['rn_des'];
    $arr_rep['ri_url'] = 'http://' . $base_url . 'reads-' . $arr['riid'] . '.html';
    $arr_rep['ri_title'] = $arr['ri_title'];
    $arr_rep['ri_des'] = $arr['ri_des'];
    /*
     * 替换
     */
    foreach ($arr_rep as $k => $v) {
        $con = str_replace('{' . $k . '}', $v, $con);
    }
    echo $con;
    include './fun/robot.php';
}