コード例 #1
0
ファイル: user.php プロジェクト: playgamelxh/lxh
function articles($userArr)
{
    global $db, $curl;
    $page = 1;
    while (true) {
        $url = "http://www.jianshu.com/users/{$userArr['name']}/latest_articles?page={$page}";
        $curl->setUrl($url);
        $html = $curl->run();
        $p = '/<h4 class="title"><a target="_blank" href="\\/p\\/(.*?)">(.*?)<\\/a><\\/h4>/';
        preg_match_all($p, $html, $match);
        print_r($match);
        if (is_array($match[1]) && !empty($match[1])) {
            foreach ($match[1] as $key => $value) {
                $temp = $db->get('article', '*', array('name' => $value));
                if (!is_array($temp) || empty($temp)) {
                    $data = getArticleInfo($value);
                    //                    echo $value;print_r($data);
                    $data['uid'] = $userArr['id'];
                    $data['name'] = $value;
                    $data['title'] = trim($match[2][$key]);
                    $commentUserArr = $data['comment_user'];
                    unset($data['comment_user']);
                    $id = $db->insert('article', $data);
                    if (is_array($commentUserArr) && !empty($commentUserArr)) {
                        foreach ($commentUserArr as $name) {
                            $temp = $db->get('user', '*', array('name' => $name));
                            if (!is_array($temp) || empty($temp)) {
                                $db->insert('user', array('name' => $name));
                            }
                            $db->clear();
                        }
                    }
                }
                $db->clear();
            }
        } else {
            break;
        }
        $page++;
        echo "article:" . $page, "\r\n";
    }
}
コード例 #2
0
ファイル: show.php プロジェクト: lz1988/stourwebcms
<?php

require_once dirname(__FILE__) . "/../include/common.inc.php";
require_once dirname(__FILE__) . "/article.func.php";
$typeid = 4;
//文章栏目
require_once SLINEINC . "/view.class.php";
$pv = new View($typeid);
if (!isset($aid)) {
    exit('Wrong Id');
}
$aid = RemoveXSS($aid);
//防止跨站攻击
updateVisit($aid, $typeid);
//更新访问次数
$row = getArticleInfo($aid);
if (empty($row['id'])) {
    head404();
}
if (!empty($row['redirecturl'])) {
    head301($row['redirecturl']);
}
$prenext = GetPreNext($aid);
//获取上一条,下一条
foreach ($prenext as $k => $v) {
    $pv->Fields[$k] = $v;
}
if (is_array($row)) {
    $row['litpic'] = !empty($row['litpic']) ? $row['litpic'] : getDefaultImage();
    $row['taglook'] = GetTagsLink($row['tagword']);
    $row['description'] = !empty($row['description']) ? "<meta name=\"description\" content=\"" . $row['description'] . "\"/>" : "";
コード例 #3
0
function sportal_admin_article_edit()
{
    global $txt, $smcFunc, $context;
    global $func;
    // Seems that we aren't ready.
    if (empty($_POST['add_article'])) {
        // Check it as we just accept integer.
        $_REQUEST['article_id'] = (int) $_REQUEST['article_id'];
        // Do we know the one to be edited?
        if (empty($_REQUEST['article_id'])) {
            fatal_lang_error('error_sp_id_empty', false);
        }
        // Get the article info.
        $context['article_info'] = getArticleInfo($_REQUEST['article_id']);
        $context['article_info'] = $context['article_info'][0];
        // List all the categories.
        $context['list_categories'] = getCategoryInfo();
        // Call the right template.
        $context['page_title'] = $txt['sp-articlesEdit'];
        $context['sub_template'] = 'article_edit';
    } else {
        // A small array.
        $articleInfo = array('category' => $_POST['category'], 'approved' => empty($_POST['approved']) ? '0' : '1');
        // Do it please.
        $smcFunc['db_query']('', '
			UPDATE {db_prefix}sp_articles
			SET id_category = {int:category}, approved = {int:approved}
			WHERE id_article = {int:id}', array('id' => $_POST['article_id'], 'category' => $articleInfo['category'], 'approved' => $articleInfo['approved']));
        // Fix the article counts.
        fixCategoryArticles();
        // I wanna go back to the list. :)
        redirectexit('action=admin;area=portalarticles;sa=articles');
    }
}