Example #1
0
function insertart($key, $keys, $a_no, $base_url)
{
    global $cfg_xs_url;
    $url = 'http://' . $base_url . 'reads-' . $a_no . 'html';
    $md5_url = md5($url);
    /*
     * 生成指纹序列
     * $art_sp:文章指纹序列
     * $choas_sp:乱序指纹序列
     */
    for ($i = 0; $i < 5; $i++) {
        //文章指纹序列
        $art_sp[$i] = toTen(substr($md5_url, $i * 4, 4)) + 1;
    }
    $choas_sp = str_split(toTen(substr($md5_url, 0, 8)) . toTen(substr($md5_url, 8, 8)) . toTen(substr($md5_url, 16, 8)) . toTen(substr($md5_url, 24, 8)), 1);
    /*
     * 副关键词
     */
    $arr_keys = explode(",", $keys);
    $arr_keys = arr_choas($arr_keys, $choas_sp);
    $key2 = $arr_keys[0];
    /*
     * 确定标题
     * 选取第一个文章。
     * 按指纹插入关键词。
     */
    $title = file_get_contents($cfg_xs_url . $art_sp[0] . ".txt");
    $arr_title = explode("|", $title);
    $arr_key = array($key, $key2);
    $title = arr_insertkey($arr_title, $choas_sp, $arr_key, 1);
    $title = preg_replace("%<[^>]+>%", ',', $title);
    //防止网址中字母被匹配
    $title = str_replace(array(',', '。', ':', '”', '“', '!', '……', '?', ';', ' ', ','), '', $title);
    $title = replace_db($title, '');
    $title = substr_utf8($title, 0, 20);
    /*
     * 确定描述
     * 选取5个文章。
     * 按指纹插入关键词。
     */
    $des = '';
    for ($i = 0; $i < 5; $i++) {
        $temp = file_get_contents($cfg_xs_url . $art_sp[$i] . ".txt");
        $des .= $temp;
    }
    $arr_des = explode('|', $des);
    $des = arr_insertkey($arr_des, $choas_sp, $arr_key, 3);
    $des = preg_replace("%<[^>]+>%", ',', $des);
    //防止网址中字母被匹配
    $des = replace_dbs($des, '.');
    $des = str_replace(' ', '', $des);
    $des = substr_utf8($des, 0, 500);
    /*
     * 返回
     * $arr_res[]
     */
    $arr_res = array();
    $arr_res['title'] = $title;
    $arr_res['des'] = $des;
    return $arr_res;
}
Example #2
0
function insertart($key, $keys, $a_no, $base_url)
{
    global $cfg_xs_url;
    $url = 'http://' . $base_url . 'reads-' . $a_no . 'html';
    $md5_url = md5($url);
    /*
     * 生成指纹序列
     * $body_sp:正文指纹序列
     * $choas_sp:乱序指纹序列
     */
    for ($i = 0; $i < 7; $i++) {
        //标题取第1个,文章28个指纹序列
        $body_sp[$i] = toTen(substr($md5_url, $i * 4, 4)) + 1;
        $body_sp[$i + 7] = toTen(substr($md5_url, $i * 4 + 1, 4)) + 1;
        $body_sp[$i + 14] = toTen(substr($md5_url, $i * 4 + 2, 4)) + 1;
        $body_sp[$i + 21] = toTen(substr($md5_url, $i * 4 + 3, 4)) + 1;
    }
    $choas_sp = str_split(toTen(substr($md5_url, 0, 8)) . toTen(substr($md5_url, 8, 8)) . toTen(substr($md5_url, 16, 8)) . toTen(substr($md5_url, 24, 8)), 1);
    /*
     * 副关键词
     */
    $arr_keys = explode(",", $keys);
    $arr_keys = arr_choas($arr_keys, $choas_sp);
    $key2 = $arr_keys[0];
    /*
     * 确定标题
     * 选取第一个文章。
     * 按指纹插入关键词。
     */
    $title = file_get_contents($cfg_xs_url . $body_sp[0] . ".txt");
    $body = $title;
    $arr_title = explode("|", $title);
    $arr_key = array($key, $key2);
    $title = arr_insertkey($arr_title, $choas_sp, $arr_key, 1);
    $title = preg_replace("%<[^>]+>%", ',', $title);
    //防止网址中字母被匹配
    $title = str_replace(array(',', '。', ':', '”', '“', '!', '……', '?', ';', ' ', ','), '', $title);
    $title = replace_db($title, '');
    $title = substr_utf8($title, 0, 20);
    /*
     * 确定描述
     * 选取28个文章。
     * 按指纹插入关键词。
     */
    for ($i = 0; $i < 28; $i++) {
        $temp = file_get_contents($cfg_xs_url . $body_sp[$i] . ".txt");
        $body .= '|' . $temp;
        if ($i % 5 > 3) {
            $body .= '<br>';
        }
    }
    $arr_body = explode('|', $body);
    $arr_key = explode(",", $key . ',' . $keys . ',' . $key . ',' . $key . ',' . $key);
    $body = arr_insertkey($arr_body, $choas_sp, $arr_key, 10);
    $body = replace_dbs($body, '.');
    $body = str_replace(' ', '', $body);
    //$body=substr_utf8($body,0,500);
    /*
     * 返回
     * $arr_res[]
     */
    $arr_res = array();
    $arr_res['title'] = $title;
    $arr_res['body'] = $body;
    return $arr_res;
}