示例#1
0
function findArticlePosById($articles, $id)
{
    foreach ($articles as $pos => $article) {
        $thisId = get_article_id($article);
        if ($thisId == $id) {
            return $pos;
        }
    }
}
示例#2
0
        $nf_text[] = "<strong>Category:</strong> <a href=\"" . WW_WEB_ROOT . '/' . $_GET['category_url'] . "/\">" . $_GET['category_url'] . "</a> was found!";
    }
}
if (isset($_GET['author_url'])) {
    if (!isset($_GET['author_id'])) {
        $nf_text[] = "<strong>Author:</strong> " . $_GET['author_url'] . " - not found";
    } else {
        $nf_text[] = "<strong>Author:</strong> <a href=\"" . WW_WEB_ROOT . '/author/' . $_GET['author_url'] . "/\">" . $_GET['author_url'] . "</a> was found!";
    }
}
if (isset($_GET['tag_url'])) {
    if (!isset($_GET['tag_id'])) {
        $nf_text[] = "<strong>Tag:</strong> " . $_GET['tag_url'] . " - not found";
    } else {
        $nf_text[] = "<strong>Tag:</strong> <a href=\"" . WW_WEB_ROOT . '/tag/' . $_GET['tag_url'] . "/\">" . $_GET['tag_url'] . "</a> was found!";
    }
}
if (isset($_GET['article_url'])) {
    $article_id = get_article_id();
    if (empty($article_id)) {
        $nf_text[] = "<strong>Article:</strong> " . $_GET['article_url'] . " - not found";
    } else {
        $nf_text[] = "<strong>Article:</strong> <a href=\"" . WW_WEB_ROOT . '/id/' . $article_id . "/\">" . $_GET['article_url'] . "</a> was found!";
    }
}
// build content
echo "\n\t<h1>404 error</h1>\n\t<h4>Based on the url you entered we tried to find the following:</h4>\n\t<ul>";
foreach ($nf_text as $nf) {
    echo "\n\t\t<li>" . $nf . "</li>";
}
echo "\n\t</ul>";
示例#3
0
/**
 *  采集互联网上的文章,用于学习和交流
 * @author suhanyu<*****@*****.**>
 */
define('PHP_QUERY', '/www/8hao/html/tool/QueryList/');
include PHP_QUERY . 'QueryList.class.php';
require PHP_QUERY . '../include/connector.php';
//获取左岸的文章列表标题
$url = 'http://www.zreading.cn/';
$hj = QueryList::Query($url, array("title" => array('#content .entry-name a', 'text'), "url" => array('#content .entry-name', 'text', 'a', 'getUrl'), 'tag' => array('#content .entry-meta', 'html', 'a'), 'category' => array('#content .entry-meta', 'html', 'a', 'getCategory')));
$nowDate = time();
if ($hj->jsonArr) {
    foreach ($hj->jsonArr as $key => $value) {
        $data = array();
        $data['sourceId'] = get_article_id($value['url']);
        # 如果存在,则不执行添加操作
        $res1 = $arti->select('select "X" from uctoo_article_article where sourceId=' . $data['sourceId']);
        if ($res1) {
            continue;
        }
        $data['title'] = $value['title'];
        $data['source'] = $value['url'];
        $data['sourceType'] = 2;
        // 2表示来源是互联网
        $data['classId'] = 3;
        // 3表示左岸频道
        $data['category'] = 1;
        // 1表示创造之路
        $data['isPublish'] = 1;
        $data['publishTime'] = $nowDate;
示例#4
0
     alert('出错的URL是:' . $list_url . $i);
 } else {
     curl_close($list_handle);
     alert("第 {$i} 列表页html内容获取成功!");
 }
 $html = str_get_html($pageContent);
 $thread_lists = $html->find('#container');
 $urlPrev = 'http://yu.pk1024.com/bbs/';
 foreach ($thread_lists as $threadTable) {
     $dataArr = array();
     // 标题和链接地址   find('tr .f_title a[href^="thread"]')
     foreach ($threadTable->find('#content header h2 a') as $url) {
         $title = trim($url->innertext);
         #$data_url = "http://yu.pk1024.com/bbs/" . $url->href;
         $detailUrl = trim($url->href);
         $sourceId = get_article_id($detailUrl);
         $addTime = date('Y-m-d H:i:s');
         if (check_exists_data($sourceId)) {
             echo "{$sourceId} 存在 \r\n";
             continue;
         }
         $dataArr[] = '("' . $detailUrl . '","' . $sourceId . '","' . $addTime . '")';
     }
     $partSql = implode(',', $dataArr);
     # 没有数据 则跳过
     if (!$dataArr) {
         continue;
     }
     try {
         //    		$stmt = $pdo->prepare("INSERT INTO list(
         //    				detail_url,source_id,add_time)
示例#5
0
    <title>Blog</title>
    <link href="/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>My Blog</h1><?php 
if (count($articles) > 0) {
    ?>
<h2>List of Articles</h2>

<div>
    <ul>
        <?php 
    foreach ($articles as $article) {
        ?>
        <li><a href="#<?php 
        echo get_article_id($article);
        ?>
"><?php 
        echo $article['title'];
        ?>
</a></li>
    <?php 
    }
    ?>
    </ul>
</div>
<div><?php 
}
foreach ($articles as $article1) {
    echoArticle($article1);
}
/**
 * process request
 * 
 * this function is called at the top of the main index page
 * it processes the GET parameters created by process_url()
 * and determines which data should be retrieved, creating additional
 * parameters if necessary for specific datasets
 */
function process_request()
{
    // search request - redirect to keep tidy url
    if (isset($_POST['search'])) {
        $search_redirect = WW_WEB_ROOT . '/search/' . $_POST['search'] . '/';
        header('HTTP/1.1 302 Moved Temporarily');
        header('Location: ' . $search_redirect);
    }
    // redirect jump links from select boxes
    if (isset($_POST['select_link'])) {
        $select_redirect = $_POST['select_link'];
        header('HTTP/1.1 302 Moved Temporarily');
        header('Location: ' . $select_redirect);
    }
    // now get urldata
    $urldata = process_url();
    // author url
    if (isset($_GET['author_url']) && !empty($_GET['author_url'])) {
        $author_id = get_author_id($_GET['author_url']);
        if (!empty($author_id)) {
            $_GET['author_id'] = $author_id;
        } else {
            $_GET['page_name'] = '404';
        }
    }
    // category url
    if (isset($_GET['category_url']) && !empty($_GET['category_url'])) {
        $category_id = get_category_id($_GET['category_url']);
        if (!empty($category_id)) {
            $_GET['category_id'] = $category_id;
        } else {
            $_GET['page_name'] = '404';
        }
    }
    // tag url
    if (isset($_GET['tag_url']) && !empty($_GET['tag_url'])) {
        $tag_id = get_tag_id($_GET['tag_url']);
        if (!empty($tag_id)) {
            $_GET['tag_id'] = $tag_id;
        } else {
            $_GET['page_name'] = '404';
        }
    }
    // have we already 404ed?
    if (isset($_GET['page_name']) && $_GET['page_name'] == '404') {
        show_404($urldata);
        return false;
    }
    // start getting data
    // was a single article requested?
    if (isset($_GET['article_id']) && !empty($_GET['article_id']) || isset($_GET['article_url']) && !empty($_GET['article_url'])) {
        $article_id = get_article_id();
        if (!empty($article_id)) {
            // n.b. page_name could be 'feed' if looking for article comments rss
            $_GET['page_name'] = isset($_GET['page_name']) ? $_GET['page_name'] : 'article';
            $_GET['article_id'] = $article_id;
            return true;
        } else {
            show_404($urldata);
            return false;
        }
        // or a search term or feed request
    } elseif (isset($_GET['feed']) || isset($_GET['feed_listing'])) {
        return true;
        // or did we get a valid author, category, or tag id - or a search, or date request?
    } elseif (!empty($author_id) || !empty($category_id) || !empty($tag_id) || isset($_GET['year']) || isset($_GET['search'])) {
        $_GET['page_name'] = 'listing';
        return true;
        // if anything else has been requested we sure can't find it
    } elseif (!empty($urldata)) {
        show_404($urldata);
        return false;
    }
    // default
    $_GET['page_name'] = 'front';
    return false;
}