示例#1
0
function update_news_pos($pos)
{
    $db = get_db();
    $category = new category_class('news');
    if ($pos == 1) {
        $category_id = $category->find_by_name('富豪报道');
        $category_id = $category_id->id;
        $type = 'richindex_news_';
    } else {
        $category_id = $category->find_by_name('创富者说');
        $category_id = $category_id->id;
        $type = 'richindex_news1_';
    }
    $table = new table_class('fb_page_pos');
    $db->echo_sql = true;
    $items = $db->query("select id,title,created_at,description,author from fb_news where category_id={$category_id} order by created_at desc limit 6");
    $exist_items = $table->find('all', array('conditions' => "name like '{$type}%' and (end_time <= now() or end_time is null)", 'order' => "name"));
    $db->echo_sql = false;
    $len = empty($exist_items) ? 0 : count($exist_items);
    for ($i = 0; $i < $len; $i++) {
        $exist_items[$i]->display = $items[$i]->title;
        $exist_items[$i]->description = $items[$i]->description;
        $exist_items[$i]->href = dynamic_news_url($items[$i]);
        $exist_items[$i]->statci_href = static_news_url($items[$i]);
        $exist_items[$i]->title = $items[$i]->title;
        $exist_items[$i]->alias = $items[$i]->author;
        $exist_items[$i]->end_time = dt_increase(1, 'h', $exist_itmes->end_time);
        $exist_items[$i]->save();
    }
}
示例#2
0
function update_news_column($category_name, $limit, $type, $position_name)
{
    if ($type == 'author') {
        $author_type = 2;
    } else {
        if ($type == 'journalist') {
            $author_type = 1;
        }
    }
    $db = get_db();
    $category = new category_class();
    $category_id = $category->find_by_name($category_name)->id;
    if (!$category_id) {
        return false;
    }
    $ids = $category->children_map($category_id);
    $ids = implode(",", $ids);
    $sql = "select t1.id,t1.title,t1.short_title,t1.created_at,t1.description,t1.video_photo_src,t2.nick_name,t2.image_src,t2.column_name from fb_news t1 join fb_user t2 on t1.author_id=t2.id where 1=1 and t1.is_adopt=1 and t1.author_type={$author_type} and t1.category_id in ({$ids}) and t2.role_name='{$type}' order by t1.created_at desc";
    $news = $db->query($sql);
    $news_count = $db->record_count;
    for ($i = 0; $i < $news_count; $i++) {
        for ($j = 0; $j < $limit; $j++) {
            $pos_name = $position_name . $j;
            $record = $db->query("select id,end_time from fb_page_pos where name='{$pos_name}'");
            if ($db->record_count == 1) {
                if ($record[0]->end_time > now()) {
                } else {
                    $pos = new table_class('fb_page_pos');
                    $pos->find($record[0]->id);
                    $end_time = date('Y-m-d H:00:00', strtotime("+1hours", time()));
                    $pos->end_time = $end_time;
                    $pos->display = $news[$i]->short_title;
                    $pos->title = $news[$i]->title;
                    $pos->image1 = $news[$i]->video_photo_src;
                    $pos->image2 = $news[$i]->image_src;
                    if (!$news[$i]->column_name) {
                        $pos->alias = $news[$i]->nick_name . '专栏';
                    } else {
                        $pos->alias = $news[$i]->column_name . '专栏';
                    }
                    $pos->description = $news[$i]->description;
                    $pos->href = dynamic_news_url($news[$i]);
                    $pos->static_href = static_news_url($news[$i]);
                    $pos->save();
                    break;
                }
            } else {
                $pos = new table_class('fb_page_pos');
                $pos->name = $pos_name;
                $end_time = date('Y-m-d H:00:00', strtotime("+1hours", time()));
                $pos->end_time = $end_time;
                $pos->display = $news[$i]->short_title;
                $pos->title = $news[$i]->title;
                $pos->image1 = $news[$i]->video_photo_src;
                $pos->image2 = $news[$i]->image_src;
                if (!$news[$i]->column_name) {
                    $pos->alias = $news[$i]->nick_name . '专栏';
                } else {
                    $pos->alias = $news[$i]->column_name . '专栏';
                }
                $pos->description = $news[$i]->description;
                $pos->href = dynamic_news_url($news[$i]);
                $pos->static_href = static_news_url($news[$i]);
                $pos->comment = $category_name . $i;
                $pos->save();
                break;
            }
        }
    }
}
示例#3
0
 function get_news_url($news)
 {
     return dynamic_news_url($news);
 }
示例#4
0
文件: _index2.php 项目: sauger/forbes
    $table->name = $pos;
    $table->display = $news[0]->title;
    $table->description = $news[0]->description;
    $table->image1 = $items[$i]->image_src;
    $table->alias = $items[$i]->column_name ? $items[$i]->column_name : $items[$i]->nick_name;
    $table->reserve = "/column/{$items[$i]->name}";
    $table->href = dynamic_news_url($news[0]);
    $table->static_href = column_article_url($news[0]->name, $news[0], 'static');
    $table->save();
    $selected_news[] = $news[0]->id;
    for ($j = 1; $j < 3; $j++) {
        $pos = 'column_recommend_top_r_t2_' . $i . '_' . $j;
        $table->find('first', array("conditions" => "name = '{$pos}'"));
        #if(strtotime($table->end_time) && strtotime($table->end_time) >= time()){
        #	continue;
        #}
        $table->name = $pos;
        $table->display = $news[$j]->title;
        $table->href = dynamic_news_url($news[$j]);
        $table->static_href = column_article_url($news[$j]->name, $news[$j], 'static');
        $table->save();
        if ($news[$j]->id) {
            $selected_news[] = $news[$j]->id;
        }
    }
}
update_pos("城市", 3, "index_city", true, true);
#update_pos("早餐资讯",3,"index_zczx_",true,true);
#update_pos("基金经理看市",1,"index_jjjl",true,true);
#update_pos("股票之选",1,"index_gpzx",true,true);
update_pos("阳光财富观察", 2, "index_dyn_list", true, true);