function get_commenters($cid, $action = 'list') { $db = Typecho_Db::get(); $rs = $db->fetchAll($db->select('author,mail,url')->from('table.comments')->where('status=? AND cid=? AND authorID=?', 'approved', $cid, 0)->order('coid', Typecho_Db::SORT_DESC)); if ($rs == null) { $unique = null; $array = null; } else { $unique = unique_arr($rs); $array = array_slice($unique, 0, 12); } switch ($action) { case 'list': if ($array == null) { return; } foreach ($array as $key => $value) { echo '<a class="js-profile-popup-actionable js-user-tipsy js-tooltip" href="' . $array[$key]['url'] . '"> <img class="avatar size24 js-user-profile-link" src="' . get_avatar($array[$key]['mail'], 60) . '" alt="' . $array[$key]['author'] . '"> </a>'; } break; case 'comments_count': echo count($rs); break; case 'commenter_count': echo count($unique); break; } }
function updataKml($kmls, $starttime, $file = '', $source = 1, $topic) { //访问API $kmlUpdateApi = getConfig('kmlUpdateApi'); $unique = unique_arr($kmls); //去重 //print_r($unique);exit; $soadata = formatApiData($unique); //去重 $returnData = curlPost($kmlUpdateApi, array('data' => $soadata)); logs($returnData, 1, 'consumer', $topic); print_r($returnData); exit; //logs(' Access :'.$kmlUpdateApi, 1, 'consumer',$topic); //logs(' Params is:'.json_encode($data), 1, 'consumer',$topic); //logs(' Return is:'.$returnData, 1, 'consumer',$topic); $cachePath = getconfig('kmlCachePath'); $cacheBack = getconfig('kmlCacheBak'); //验证还回结果 $objs = json_decode($returnData); if (empty($returnData) || $objs->status != 0 || empty($objs->data)) { if ($source == 2) { $dir = $cacheBack . '/' . date('Y-m-d') . '/' . $topic; mkFolder($dir); $toPath = $dir . '/' . basename($file); moveFile($file, $toPath); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has move to ' . $toPath, 1, 'consumer', $topic); } else { if ($objs->status < 3) { $cacheTopicPath = $cachePath . '/' . $topic; mkFolder($cacheTopicPath); $filename = basename($file); $source = $cacheTopicPath . '/' . $filename; file_put_contents($source, $data); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has backup to ' . $source, 1, 'consumer', $topic); } else { $backFile = $cacheBack . '/' . basename($file); moveFile($file, $backFile); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file ' . basename($file) . 'has move to ' . $backFile, 1, 'consumer', $topic); } } } if ($source == 2) { if (file_exists($file)) { unlink($file); } } $arr = object2Array($objs); $returnKml = $arr['data']; $insertNum = 0; if ($source == 1) { $insertNum = addKml($returnKml, $kmls, $topic); } logs('kafka num:' . count($kmls) . ',send data num:' . count($unique) . ', API return:' . count($returnKml) . ',insertNum:' . $insertNum . ',Time: ' . getTime($starttime), 1, 'consumer', $topic); $kmls = ''; }
function get_lucky_list() { $sqlArr = array(); $sqlArr['param'] = "weixinName"; $sqlArr['where'] = "`isLucky` = '1' and `weixinName` != ''"; $sqlArr['order'] = "`luckyTime` DESC"; $data = select(LOG_TABLE, $sqlArr, 1); if (!empty($data)) { return unique_arr($data); } else { return false; } }
public function showRecommend() { $where['user_id'] = session('userId'); $book = array(); $browseInfo = array(); $data = M('browse')->field('book_id,COUNT(book_id) AS total')->where($where)->group('book_id')->order('total desc,book_id desc')->limit(3)->select(); if ($data) { for ($i = 0; $i < 3; $i++) { $book[$i] = $data[$i]['book_id']; $where1['book_id'] = $book[$i]; $data1 = M('book')->field('book_id,book_name,book_pic')->where($where1)->select(); if ($data1) { $browseInfo[$i] = array('book_id' => $data1[0]['book_id'], 'book_name' => $data1[0]['book_name'], 'book_pic' => $data1[0]['book_pic']); } } } $collectData = M('collection')->field('book_id')->where($where)->order('collection_id desc')->limit(2)->select(); if ($collectData) { for ($i = 3; $i < 5; $i++) { $book[$i] = $collectData[$i - 3]['book_id']; $where3['book_id'] = $book[$i]; $data2 = M('book')->field('book_id,book_name,book_pic')->where($where3)->select(); if ($data2) { $browseInfo[$i] = array('book_id' => $data2[0]['book_id'], 'book_name' => $data2[0]['book_name'], 'book_pic' => $data2[0]['book_pic']); } } } $result = M('browse')->field('type_id,COUNT(type_id) AS total')->where($where)->group('type_id')->order('total desc,book_id desc')->limit(2)->select(); if ($result) { for ($i = 5; $i < 7; $i++) { $book[$i] = $result[$i - 5]['type_id']; $where2['type_id'] = $book[$i]; $result1 = M('book')->field('book_id,book_name,book_pic')->where($where2)->order('book_view desc,book_id desc')->limit(1)->select(); if ($result1) { $browseInfo[$i] = array('book_id' => $result1[0]['book_id'], 'book_name' => $result1[0]['book_name'], 'book_pic' => $result1[0]['book_pic']); } } } $browseInfo = unique_arr($browseInfo); if (count($browseInfo, 1) > 0) { return $browseInfo; } else { return null; } }