zoukankan      html  css  js  c++  java
  • 社区之星代码

      securecrt 软件

      使用此软件,打开以后输入   crontab -e

    eg:0 1 * * 1 php /var/share/www/medai360.com/index.php forum star   (每周一的 01:00执行后面的cli下的forum下的star方法)(社区之星)

    社区之星代码(发帖,回帖)

    function star(){

    $start = date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y")));
    $end = date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y")));
    $week_date[0] = array(
    'start' => $start,
    'end' => $end,
    );
    $forum_star = $this->Article->get(array(" pub_time >='{$week_date[0]['start']}' AND pub_time <='{$week_date[0]['end']}' AND type = 4 and status=2"), array('$field'=>'author_id'));
    $comment_star = $this->Comment->get(array(" time >='{$week_date[0]['start']}' AND time <='{$week_date[0]['end']}' and status=1"), array('$field'=>'author_id'));

    if($comment_star){
    //帖子数量
    foreach($forum_star as $k=>$v){
    $star_list_for[$k]= $v['author_id'];
    }
    foreach($star_list_for as $val)
    {
    $author_for[$val][] =$val;
    }
    foreach($author_for as $key=>$value)
    {
    $author_num_for[$key] = count($value);
    }
    //回复数量
    foreach($comment_star as $k=>$v){
    $star_list_com[$k]= $v['author_id'];
    }
    foreach($star_list_com as $value)
    {
    $author_com[$value][] =$value;
    }
    foreach($author_com as $key=>$value)
    {
    $author_num_com[$key] = count($value);
    }

    $all_num = array();
    foreach ($author_num_for as $k=>$v) {
    if (isset($author_num_com[$k])) {
    $all_num[$k] = $v + $author_num_com[$k];
    } else {
    $all_num[$k] = $v;
    }
    }
    $diff = array_diff_key($author_num_com, $all_num);

    foreach ($diff as $k=>$v) {
    $all_num[$k] = $v;
    }
    }
    $author_star = array_search(max($all_num), $all_num);//社区之星id
    $author_list = $this->User->get_line(array('id'=>$author_star), array('$field'=>'name, avatar'));
    $author_list['u_id'] = $author_star;
    !empty($author_num_com[$author_star]) ? $author_list['comment_num'] =$author_num_com[$author_star] : $author_list['comment_num'] =0 ;
    !empty($author_num_for[$author_star]) ? $author_list['forum_num'] = $author_num_for[$author_star] : $author_list['forum_num'] =0;
    $author_list['time'] = date('Y-m-d 00:00:00');

    $this->Forum_star->add($author_list);
    //送100大米
    $this->User->rice_issue($author_star, 22);
    return $author_list;
    }

  • 相关阅读:
    bzoj4810 [Ynoi2017]由乃的玉米田 bitset优化+暴力+莫队
    Ionic Js六:切换开关操作
    Ionic Js五:单选框操作
    Ionic Js四:复选框
    Ionic Js三:下拉刷新
    Ionic Js二:背景层
    Ionic Js一:上拉菜单(ActionSheet)
    Ionic入门十:icon(图标)
    Ionic入门九:颜色
    Ionic入门八:头部与底部
  • 原文地址:https://www.cnblogs.com/yangjing1314/p/3950991.html
Copyright © 2011-2022 走看看