ass Api extends CI_Controller { public function __construct() { parent::__construct(); ini_set('date.timezone','Asia/Shanghai'); $this->load->model('Announce'); $this->load->model('Text'); $this->load->model('Log'); $this->load->model('Solr'); $this->load->model('Solr_html'); $this->load->model('News'); $this->load->driver('cache'); $this->cache->redis->is_supported(); $this->data['filebase'] = $this->config->item('filebase'); $this->data['type_cache_time'] = $this->config->item('type_cache_time'); $this->data['wait_cache_time'] = $this->config->item('wait_cache_time'); $this->data['info_cache_time'] = $this->config->item('info_cache_time'); $this->data['sum_cache_time'] = $this->config->item('sum_cache_time'); $this->data['search_cache_time'] = $this->config->item('search_cache_time'); $this->data['database'] = $this->config->item('database'); $this->data['database_test'] = 'juchao'; $this->timestamp = 0; $this->data['file_suffix'] = $this->config->item('file_suffix'); $this->load->helper('api'); $this->load->helper('auth'); $this->load->helper('data'); } /** 测试 OK X港通法律法规、投资者教育 输入参数: type=1 法律法规 http://www.szse.cn/main/szhk/ggtywgz/ type=2 投资者教育 http://www.szse.cn/main/szhk/tzzjy/ggttzzjy/zlwz/ pagesize 每页大小 pagenum 页码,从1开始 输出参数: pagesize 每页大小 pagenum 页码,从1开始 totalcount 总结果数 totalpage 总页数 item 结果项 **/ public function xgtdoc() { $type = $this->input->get('type'); if(!in_array($type, array(1,2))) $type = 1; $key = 'xgtdoc_'.$type; $json = get_CI()->cache->redis->get($key); if(empty($json)) { $dbconn_news = get_CI()->load->database("news",TRUE); $sql = "select * from xgtdoc where type=".$type." order by rectime desc limit 7"; $rs = $dbconn_news->query($sql); $data = array(); foreach ($rs->result() as $val) { $data[] = array( 'title' => $val->title, 'ggdate' => $val->ggdate, 'url' => $val->url ); } $json = json_encode($data); get_CI()->cache->redis->save($key, $json, 60*60*24); } print $json; exit; } /** 行情模块检索个股时用 **/ public function codeList() { $json = get_CI()->cache->redis->get('juchao_hq_api_codeList_2'); if(empty($json)) { $dbconn_juchao = get_CI()->load->database("juchao",TRUE); $sql = "select ob_seccode_0007,ob_secname_0007,f005v_0007 from tb_public_0007 where f005v_0007 in('012001','012002','012015','012003') and f002v_0007 in ('001001','001002','003001','003004','002010','004002') and (f017v_0007 is null or f017v_0007='013001')"; $rs = $dbconn_juchao->query($sql); $data = array(); foreach ($rs->result() as $row) { if($row->F005V_0007=='012001') $prefix = 'sh'; else $prefix = 'sz'; $data[] = array( 'value' => $prefix.$row->OB_SECCODE_0007, 'label' =>urlencode($row->OB_SECNAME_0007.'('.$prefix.$row->OB_SECCODE_0007.')') ); } $json = urldecode(json_encode($data)); get_CI()->cache->redis->save('juchao_hq_api_codeList_2', $json, 60*60*24); } header('Content-Type:application/json;charset=utf-8'); print 'var codelist='.$json.';'; exit; } /** 从 juchao 库获取AB股公司列表 **/ public function codeListAB() { $json = get_CI()->cache->redis->get('test_juchao_api_abg_6'); if(empty($json)) { $dbconn_news = get_CI()->load->database("juchao",TRUE); $sql = "select ob_seccode_0007,ob_secname_0007 from cninfo.tb_public_0007 where f005v_0007 in('012001','012002','012015','012003') and f002v_0007 in ('001001','001002') and ob_isvalid_0007=1 and f017v_0007<>'013002' and f005v_0007<>'012088' order by ob_seccode_0007"; $rs = $dbconn_news->query($sql); $data = array(); foreach ($rs->result() as $row) { $data['o'.$row->OB_SECCODE_0007] = $row->OB_SECNAME_0007; } $json = json_encode($data); get_CI()->cache->redis->save('test_juchao_api_abg_6', $json, 60*60*24); } header('Content-Type:application/json;charset=utf-8'); print $json; exit; } /** 从news库中获取A股公司列表 **/ public function codeListA() { $json = get_CI()->cache->redis->get('juchao_hq_api_ag_2'); if(empty($json)) { $dbconn_juchao = get_CI()->load->database("news_slave",TRUE); $sql = "select ob_seccode_0007,f005v_0007,ob_secname_0007 from tb_public_0007 where f002v_0007='001001' and ob_isvalid_0007=1 and f017v_0007<>'013002' and f005v_0007<>'012088' order by ob_seccode_0007"; $rs = $dbconn_juchao->query($sql); $data = array(); foreach ($rs->result() as $row) { if($row->f005v_0007=='012001') $prefix = 'sh'; else $prefix = 'sz'; $data[] = array('code'=>$prefix.$row->ob_seccode_0007,'name'=>$row->ob_secname_0007); } $json = json_encode($data); get_CI()->cache->redis->save('juchao_hq_api_ag_2', $json, 60*60*24); } header('Content-Type:application/json;charset=utf-8'); print $json; exit; } public function ag_zs() { $this->cache->redis->is_supported(); $json = get_CI()->cache->redis->get('juchao_hq_api_ag_6'); if(empty($json)) { $dbconn_juchao = get_CI()->load->database("juchao",TRUE); $sql = "select ob_seccode_0007,f005v_0007,ob_secname_0007 from tb_public_0007 where f002v_0007='001001' and ob_isvalid_0007=1 and f017v_0007<>'013002' and f005v_0007<>'012088' order by ob_seccode_0007"; $rs = $dbconn_juchao->query($sql); $data = array(); foreach ($rs->result() as $row) { if($row->F005V_0007=='012001') $prefix = 'sh'; else $prefix = 'sz'; $data[] = array('code'=>$prefix.$row->OB_SECCODE_0007,'name'=>$row->OB_SECNAME_0007); } $json = json_encode($data); get_CI()->cache->redis->save('juchao_hq_api_ag_6', $json, 60*60); } $data = json_decode($json, true); foreach ($data as &$val) { $str = $this->cache->redis->get('hq:intime:'.substr($val['code'],0,2).':'.substr($val['code'],2)); $item = json_decode($str); $val['date'] = substr($item[0],0,8); $val['prevclose'] = $item[1]; } $json = json_encode($data); header('Content-Type:application/json;charset=utf-8'); print $json; exit; } /** 公告分类对照表 0047 **/ public function getSortcodeList() { $cache = $this->cache->redis->get('gg_sortcode_list'); if(empty($cache)) { $cache = ''; $sql = "select ob_sortcode_0047,ob_sortname_0047 from tb_text_0047 where ob_isvalid_0047=1"; $dbconn = $this->load->database("news_slave",TRUE); $rs = $dbconn->query($sql); foreach ($rs->result() as $val) { $cache .= ''; } $cache .= '
'.$val->ob_sortcode_0047.''.$val->ob_sortname_0047.'
'; $this->cache->redis->save('gg_sortcode_list', $cache, 60*60*24*30); } print($cache); exit; } /** 市场类型对照表 0007 f005v f006v **/ public function getMtypeList() { $cache = $this->cache->redis->get('gg_mtype_list7'); if(empty($cache)) { $arr = array( '012007'=>'港交所创业板', '012006'=>'港交所主板', '012005'=>'代办转让', '012001'=>'上交所', '012002'=>'深交所主板', '012015'=>'深交所创业板', '012003'=>'深交所中小板', '012999'=>'其他', '012088'=>'拟上市' ); $cache = ''; foreach ($arr as $key=>$val) { $cache .= ''; } $cache .= '
'.$key.''.$val.'
'; $this->cache->redis->save('gg_mtype_list7', $cache, 60*60*24*30); } print($cache); exit; } /** http://app.cnstock.com/api/notice/getNoticeByStockcode/?items=10&stockcode=601238 网上路演页面使用。(根据股票代码获取公告列表) 使用中 **/ public function getNoticeByStockcode() { $stockcode = $this->input->get("stockcode"); $items = $this->input->get("items")?$this->input->get("items"):10; $url = "http://php.cnstock.com/news_new/index.php/api/getAnnounceList?code=".$stockcode; $str = file_get_contents($url); $jsonarr = json_decode($str, true); $res = ""; $i = 0; foreach ($jsonarr['item'] as $val) { $i++; $res .= "document.write('
  • ".$val["title"]." [".$val["ggdate"]."]
  • ');"; if($i>=$items) break; } echo $res; } //根据code。巨潮数据源。 //不在使用中 function getSumList() { $params = correctParams();//时间的检验和修正,有默认值的参数的初始化 $kpramas = $params; $kpramas['cache'] = null; $kpramas['callback'] = null; if(!empty($params['code'])) { $k = md5('ggsumlist_code_'.$params['code']); $result = $this->cache->redis->get($k); if(empty($result) || $params['cache']=="off") { $result = $this->Text->get_sumlist_by_code($params['code']); $this->cache->redis->save($k, $result, 1800); } $length = $params['pagesize']; $min = ($params['pagenum']*$params['pagesize']); $result['item'] = array_slice($result['item'], $min, $length); $result['pagenum'] = $params['pagenum']; $result['pagesize'] = $params['pagesize']; $jsonstr = json_encode($result); //echo $jsonstr; print $jsonstr; exit; } } public function zq136514() { $str = '{"error":0,"msg":"success","numFound":11,"item":[{"textid":"zqannouncement_0","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382015\u5e74\u5e74\u5ea6\u62a5\u544a\uff08\u4ee5\u6b64\u4e3a\u51c6\uff09","rectime":"2016-09-01 15:30:04","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526496065724.pdf","size":6943,"secucode":"136514","ggdate":"2016-09-01","format":"pdf"},{"textid":"zqannouncement_1","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382016\u5e74\u534a\u5e74\u5ea6\u62a5\u544a","rectime":"2016-09-01 08:00:35","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526886066684.pdf","size":7829,"secucode":"136514","ggdate":"2016-08-31","format":"pdf"},{"textid":"zqannouncement_2","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382016\u5e74\u534a\u5e74\u5ea6\u62a5\u544a\u6458\u8981","rectime":"2016-09-01 08:00:35","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526937206716.pdf","size":827,"secucode":"136514","ggdate":"2016-08-31","format":"pdf"},{"textid":"zqannouncement_3","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u4e0a\u5e02\u516c\u544a\u4e66","rectime":"2016-07-25 17:20:17","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2666068011390174.pdf","size":1074,"secucode":"136514","ggdate":"2016-07-26","format":"pdf"},{"textid":"zqannouncement_4","title":"\u5173\u4e8e\u62df\u59d4\u6258\u4e2d\u56fd\u8bc1\u5238\u767b\u8bb0\u7ed3\u7b97\u6709\u9650\u8d23\u4efb\u516c\u53f8\u4e0a\u6d77\u5206\u516c\u53f8\u4ee3\u7406\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u5151\u4ed8\u5151\u606f\u76f8\u5173\u4e8b\u5b9c\u7684\u516c\u544a","rectime":"2016-07-25 17:20:17","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2665950504795689.pdf","size":197,"secucode":"136514","ggdate":"2016-07-26","format":"pdf"},{"textid":"zqannouncement_5","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u53d1\u884c\u7ed3\u679c\u516c\u544a","rectime":"2016-07-08 09:20:06","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2653117286775566.pdf","size":469,"secucode":"136514","ggdate":"2016-07-08","format":"pdf"},{"textid":"zqannouncement_6","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u5f00\u53d1\u884c2016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u7968\u9762\u5229\u7387\u516c\u544a","rectime":"2016-07-06 12:50:02","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2651436769528575.pdf","size":407,"secucode":"136514","ggdate":"2016-07-06","format":"pdf"},{"textid":"zqannouncement_7","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u52df\u96c6\u8bf4\u660e\u4e66","rectime":"2016-07-03 14:40:09","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860699047356.pdf","size":4311,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_8","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u503a\u5238\u53d1\u884c\u516c\u544a","rectime":"2016-07-03 14:40:09","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860889197512.pdf","size":973,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_9","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u52df\u96c6\u8bf4\u660e\u4e66\u6458\u8981","rectime":"2016-07-03 14:50:07","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860972627526.pdf","size":1303,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_10","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u4fe1\u7528\u8bc4\u7ea7\u62a5\u544a","rectime":"2016-07-03 14:50:07","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647861119687705.pdf","size":2376,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"}],"pagesize":20}'; return $str; } /** 查询接口 - 主 Solr - getAnnounceList的替代测试 **/ public function getAnnounceList() { $database = 'solr'; $this->data['database'] = $database; //香港交易所公告,只有 news_new 数据库 hkex 表中有 if($this->input->get('sortcode')=='0101030105') { $params = correctParams(); $result = get_hkex_news($params); $json = json_encode($result); print $json; exit; } //格式为 HTML 的公告 if($this->input->get('format') == 'html') { $this->getAnnounceList_html(); } //检查用户是否有刷接口嫌疑 $this->isUnfriendly(); //检查和修正查询参数 $params = correctParams();//时间的检验和修正,有默认值的参数的初始化 $params['keyword'] = null;//不支持全文检索 $kpramas = $params; $kpramas['cache'] = null; $kpramas['callback'] = null; //远东国际租赁有限公司债券 if($params['code'] == '136514') { $jsonstr = $this->zq136514(); print $jsonstr; exit; } //从缓存中查找数据 $k = md5('list_'.$database.json_encode($kpramas)); $jsonstr = $this->cache->redis->get($k); //只有巨潮中才能查到的公告类型 if(!empty($params['sortcode']) && ( ( substr($params['sortcode'],0,4)=="0199") || ( substr($params['sortcode'],0,8)=="01010101") || strstr($params['sortcode'],",0141") || in_array($params['sortcode'],array("014125","014124","0135","010120","010119","010118","010117","013507","013505","013503","013501","0110","0139","0109","010101","01010101","01010303","01010307","01010509")))){ $this->getAnnounceList_juchao(); } //Solr 中的公告 else if(empty($jsonstr) || $params['cache']=='off') { //交易所公告,仅有 HTML 格式 if(substr($params["sortcode"],0,8)=='01010301') { $jsonarr = $this->Solr_html->gglist($params); } //TXT 格式公告,仅巨潮中有 elseif($params['format']=='txt' && !empty($params['code'])) { $database = 'juchao'; //$jsonarr = $this->Announce->get_gglist_bycodes_juchao($params); $this->getAnnounceList_juchao(); } else { $jsonarr = $this->Solr->get_gglist($params); } $jsonstr = json_encode($jsonarr); $this->cache->redis->save($k, $jsonstr, 600); } //输出json字串 header('Content-Type:text/json;charset=utf-8'); $jsoncallback = get_CI()->input->get('callback', true); if(!empty($jsoncallback)) { $jsonstr = $jsoncallback.'('.$jsonstr.')'; } print $jsonstr; exit; } //巨潮 列表接口,不含实践参数 public function getAnnounceList_juchao() { $params = correctParams(); $k = md5('gglist_sortcode_'.$params['sortcode'].$params['code']); $result = $this->cache->redis->get($k); if(empty($result) || $params['cache']=="off") { $time = 60*30; if(empty($params['code'])) { $time = 60*60*10; $result = $this->Text->get_gglist_by_sortcode_juchao($params['sortcode']); } else if($params['sortcode']=='01010509' || $params['sortcode']=='0139') $result = $this->Text->get_gglist_by_sortcode_code_juchao($params['sortcode'], $params['code']); else $result = $this->Text->get_gglist_by_sortcode_juchao($params['sortcode']); $r = $this->cache->redis->save($k, $result, $time); } else { $result = unserialize($result); } $length = $params['pagesize']; $min = ($params['pagenum']*$params['pagesize']); $result['item'] = array_slice($result['item'], $min, $length); $result['pagenum'] = $params['pagenum']; $result['pagesize'] = $params['pagesize']; $jsonstr = json_encode($result); //输出json字串 header('Content-Type:text/json;charset=utf-8'); $jsoncallback = get_CI()->input->get('callback', true); if(!empty($jsoncallback)) { $jsonstr = $jsoncallback.'('.$jsonstr.')'; } print $jsonstr; exit; } //巨潮 文件接口 public function fileview_juchao($id='') { if(empty($id)) { $id = $this->input->get('ID'); } if(empty($id)) { exit; } $k = 'juchao:text:'.$id; $str = $this->cache->redis->get($k); if(!empty($str)) { print $str; exit; } $ip = get_client_ip(); $key1 = "ggjd_cache_download_".$ip."_". date('Y-m-d H'); $key2 = "ggjd_cache_download_".$ip."_". date('Y-m-d H:i'); $dac = $this->cache->redis->get($key1); $dc = $this->cache->redis->get($key2); $allow_ips = array( "202.109.75.174" //"112.64.158.121", //"202.109.75.208", ); if(!$dc || ($dc<100 && $dac<4000) || in_array($ip,$allow_ips)){ $this->cache->redis->save($key1, ($dac+1), 240*3600); $this->cache->redis->save($key2, ($dc+1), 240*3600); }else{ $this->cache->redis->save($key1, ($dac+1), 240*3600); $this->cache->redis->save($key2, ($dc+1), 240*3600); echo ""; exit; } /*$sql = "select f006b_0042,f008V_0042,ob_textid_0042,f004v_0042 from cninfo.tb_text_0042 where ob_textid_0042=?"; $dbconn_juchao = $this->load->database("juchao",TRUE); $rs = $dbconn_juchao->query($sql,array($id)); if(empty($rs) || empty($rs->row()) ||$rs->num_rows() == 0) { exit; } if($rs->row()->F008V_0042=='PDF') { $name = $rs->row()->OB_TEXTID_0042.'.PDF'; if(empty($rs->row()->F006B_0042)) exit; header('Content-Type: application/pdf'); header('Content-Disposition: inline;filename="'.$name.'"'); while(!$rs->row()->F006B_0042->eof()){ echo $rs->row()->F006B_0042->read(1024); } exit; } else if($rs->row()->F008V_0042=='TXT') { $sql = "select f006l_0046 from cninfo.tb_text_0046 where ob_textid_0046='".$id."'"; $rs = $dbconn_juchao->query($sql); if(empty($rs->row()->F006L_0046)) exit; echo $rs->row()->F006L_0046->load(); exit; } else { exit; }*/ $sql = "select f006l_0046 from cninfo.tb_text_0046 where ob_textid_0046='".$id."'"; $dbconn_juchao = $this->load->database("juchao",TRUE); $rs = $dbconn_juchao->query($sql); if(empty($rs->row()->F006L_0046)) exit; $str = $rs->row()->F006L_0046->load(); echo $str; $this->cache->redis->save($k, $str, 3600*24); exit; } //抓到的文件类型公告:沪深港三板等 public function fileview_news() { $id = $this->input->get('ID', true); if(strlen($id) <= 32) { header('HTTP/1.1 404 Not Found'); exit; } /* $ip = get_client_ip(); $key1 = "ggjd_cache_download_".$ip."_". date('Y-m-d H'); $key2 = "ggjd_cache_download_".$ip."_". date('Y-m-d H:i'); $dac = $this->cache->redis->get($key1); $dc = $this->cache->redis->get($key2); $allow_ips = array( "202.109.75.174" //"112.64.158.121", //"202.109.75.208", ); if(!$dc || ($dc<30 && $dac<100) || in_array($ip,$allow_ips)){ $this->cache->redis->save($key1, ($dac+1), 240*3600); $this->cache->redis->save($key2, ($dc+1), 240*3600); }else{ $this->cache->redis->save($key1, ($dac+1), 240*3600); $this->cache->redis->save($key2, ($dc+1), 240*3600); echo ""; exit; }*/ $date = substr($id, 0, 8); $id = substr($id,8,32); $date_format = substr($date,0,4)."-".substr($date, 4, 2)."-".substr($date,6); if(strtotime($date_format)data['file_suffix']."/web/".$id.".pdf"; else $fileurl = $this->data['file_suffix']."/".substr($date,0,4)."/".$date."/".$id.".pdf"; $headers = get_headers($fileurl, true); // 文件存在,直接跳到文件地址 if(strstr($headers[0], "200")) { header('Location: '.$fileurl); exit; } exit; //文件不存在,得到 URL $dbconn = $this->load->database("news",TRUE); $dbconn->select('ob_rectime_0042,f008v_0042,ob_url_0042,f003d_0042,f002d_0042,f007n_0042,sectype'); $dbconn->where('ob_textid_0042', $id); $db = $this->input->get('db'); if($db=='xsb') { $rs = $dbconn->get('xsb_tb_text_0042'); } else { $rs = $dbconn->get('tb_text_0042'); } //不存在 if($rs->num_rows()==0) { echo "不存在"; exit; } //是从巨潮中转存的 else if(empty($rs->row()->ob_url_0042)) { $fileurl = $this->data['file_suffix'].'/juchao/'.$id.'.'.$rs->row()->f008v_0042; } else { //html 格式 if(str_replace('htm', '', $rs->row()->ob_url_0042)<>$rs->row()->ob_url_0042) { $this->cache->redis->save(md5($k), $rs->row()->ob_url_0042, 1800); header('Location: '.$rs->row()->ob_url_0042); exit; } //直接输出到原地址并加入下载队列 /*$dbconn = get_CI()->load->database('news', true); $sql = "insert into queue(textid,url,releasetime,status,no,size,TtoS) values(?,?,?,?,?,?,?);"; if(strstr($rs->row()->ob_url_0042, 'hkexnews')) { $TtoS = 1; } else { $TtoS = 0; } $params = array($id, $rs->row()->ob_url_0042, $rs->row()->ob_rectime_0042, 0, $rs->row()->sectype, $rs->row()->f007n_0042, $TtoS); $dbconn->query($sql, $params); */ $fileurl = $rs->row()->ob_url_0042; } $headers = get_headers($fileurl, true); // 文件存在,直接跳到文件地址 if(strstr($headers[0], "200")) { header('Location: '.$fileurl); exit; } else { if(empty($rs->row()->ob_url_0042)) { //去巨潮找 $dbconn->select('juchao_textid'); $dbconn->where('news_textid', $id); $rs = $dbconn->get('juchao_news'); if($rs->num_rows() > 0) { $juchao_textid = $rs->row()->juchao_textid; $news_textid = $id; } else { return; } $this->fileview_juchao($juchao_textid); } } } /** 各种新抓HTML格式公告 **/ public function getAnnounceList_html() { $params = correctParams(); $key = md5("getAnnounceList".serialize($params)); $jsonstr = $this->cache->redis->get($key); if(empty($jsonstr) || $params['cache'] == 'off') { $jsonarr = $this->Solr_html->gglist($params); $jsonstr = json_encode($jsonarr); $this->cache->redis->save($key, $jsonstr, 600); } //输出json字串 header('Content-Type:text/json;charset=utf-8'); $jsoncallback = get_CI()->input->get('callback', true); if(!empty($jsoncallback)) { $jsonstr = $jsoncallback.'('.$jsonstr.')'; } print $jsonstr; exit; } public function fileview_html() { $id = $this->input->get('ID'); $id = str_replace(array("'",'"','-','\\','+'), '', $id); $key = md5("fileview".serialize($id)); $content = $this->cache->redis->get($key); if(empty($content)) { $file = $this->News->fileview($id); if(!empty($file)) { $content = ''.$file['title'].''.$file['content'].''; $this->cache->redis->save($key, $content, 3600*24); } } print $content; exit; } /** 公告解读系统同步AB股公告用 **/ public function getAnnounces($maxoid='') { if($this->data['database']=='juchao') $jsonarr = $this->Announce->get_texts_by_maxoid_juchao($maxoid); else $jsonarr = $this->Announce->get_texts_by_maxoid($maxoid); $json = json_encode($jsonarr); $jsonstr = $this->cache->redis->get(md5('maxoid_'.$jsonarr['maxoid'])); header('Content-Type:application/json;charset=utf-8'); print($json); exit; } /** 公告解读系统同步AB股公告用 **/ public function getMinOid($date='') { if(empty($date)) $date = date('Y-m-d',time()); if($this->data['database']=='juchao') $jsonarr = $this->Announce->get_minobjectid_by_date_juchao($date); else $jsonarr = $this->Announce->get_minobjectid_by_date($date); $json = json_encode($jsonarr); header('Content-Type:application/json;charset=utf-8'); print($json); exit; } /** 读公告摘要。目前仅巨潮库提供。 中国证券网APP,harry juchao **/ public function getAnnounceSummary() { $params = correctParams(); $k = 'summary_'.json_encode($params); $jsonstr = $this->cache->redis->get(md5($k)); if(empty($jsonstr)) { $jsonstr = $this->Announce->get_ggsummary_bytextid_juchao($params); if(!empty($jsonstr)) { $survivalTime = 60*60*3; $this->cache->redis->save(md5($k),$jsonstr,$survivalTime); } } if(!empty($jsonstr)) { print $jsonstr; } exit; } /** william 使用中 **/ public function uuu() { $k = 'hwhqjson_allcode_william_0811'; $rst = get_CI()->cache->redis->get($k); if(empty($rst)) { $dbconn=$this->load->database("news_slave",TRUE); $sql = "select ob_secname_0007 AS name,ob_seccode_0007 AS code FROM tb_public_0007 WHERE (f002v_0007='001001' OR f002v_0007 ='001002') AND ob_isvalid_0007=1 AND f017v_0007<>'013002' AND f005v_0007<>'012088' ORDER BY ob_seccode_0007 asc "; $query=$dbconn->query($sql); $list=$query->result(); $zycp = array(); foreach($list as $itm){ $zycp[] = array( 'code' => $itm->code, 'name' => $itm->name, ); } $list = $zycp; $rst = json_encode($list); get_CI()->cache->redis->save($k, $rst, 60*60*12); } print $rst; exit; } /** 判断客户端IP是否友好 **/ public function isUnfriendly() { return true; $ip = get_client_ip(); $key1 = "ggtext_cache_".$ip."_". date('Y-m-d H', time()); $key2 = "ggtext_cache_".$ip."_". date('Y-m-d H:i', time()); $dac = $this->cache->redis->get($key1); $dc = $this->cache->redis->get($key2); if(empty($dac)) $dac = 0; else if(empty($dc)) $dc = 0; else if($dc>15 || $dac>300){ header('Content-Type:text/plain;charset=utf-8'); $data['error'] = 1; $data['msg'] = urlencode('请稍后再试'); print urldecode(json_encode($data)); exit; } $this->cache->redis->save($key1, ($dac+1), 24*3600); $this->cache->redis->save($key2, ($dc+1), 24*3600); } /** 读公告TXT。目前仅巨潮库提供。 中国证券网APP,harry juchao **/ public function getAnnounceText() { $this->timestamp = time(); $id = $this->input->get('id'); $database = checkTextID($id); if($database==false) { $jsonarr['error'] = 1; $jsonarr['msg'] = 'WRONG ID'; output($jsonarr); } $db = $database; $isUser = true; if(!$isUser) { $jsonarr['error'] = 1; $jsonarr['msg'] = 'auth failed'; output($jsonarr); } $params['textid'] = $id; $k = '____list_text4_'.$database.json_encode($params); $jsonarr = $this->cache->redis->get(md5($k)); if(empty($jsonstr)) { $this->isUnfriendly(); if($database=='juchao') $jsonarr = $this->Announce->get_ggtext_bytextid_juchao($params); else exit;//$jsonarr = $this->Announce->get_ggtext_bytextid_news($params); if(!empty($jsonarr)) { $survivalTime = 60*60*24*10; $this->cache->redis->save(md5($k),$jsonarr,$survivalTime); } } else { $db = 'cache_'.$database; } output($jsonarr); } public function fileview_zq136514() { $json = '{"error":0,"msg":"success","numFound":11,"item":[{"textid":"zqannouncement_0","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382015\u5e74\u5e74\u5ea6\u62a5\u544a\uff08\u4ee5\u6b64\u4e3a\u51c6\uff09","rectime":"2016-09-01 15:30:04","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526496065724.pdf","size":6943,"secucode":"136514","ggdate":"2016-09-01","format":"pdf"},{"textid":"zqannouncement_1","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382016\u5e74\u534a\u5e74\u5ea6\u62a5\u544a","rectime":"2016-09-01 08:00:35","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526886066684.pdf","size":7829,"secucode":"136514","ggdate":"2016-08-31","format":"pdf"},{"textid":"zqannouncement_2","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u53f8\u503a\u52382016\u5e74\u534a\u5e74\u5ea6\u62a5\u544a\u6458\u8981","rectime":"2016-09-01 08:00:35","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2700526937206716.pdf","size":827,"secucode":"136514","ggdate":"2016-08-31","format":"pdf"},{"textid":"zqannouncement_3","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u4e0a\u5e02\u516c\u544a\u4e66","rectime":"2016-07-25 17:20:17","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2666068011390174.pdf","size":1074,"secucode":"136514","ggdate":"2016-07-26","format":"pdf"},{"textid":"zqannouncement_4","title":"\u5173\u4e8e\u62df\u59d4\u6258\u4e2d\u56fd\u8bc1\u5238\u767b\u8bb0\u7ed3\u7b97\u6709\u9650\u8d23\u4efb\u516c\u53f8\u4e0a\u6d77\u5206\u516c\u53f8\u4ee3\u7406\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u5151\u4ed8\u5151\u606f\u76f8\u5173\u4e8b\u5b9c\u7684\u516c\u544a","rectime":"2016-07-25 17:20:17","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2665950504795689.pdf","size":197,"secucode":"136514","ggdate":"2016-07-26","format":"pdf"},{"textid":"zqannouncement_5","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u53d1\u884c\u7ed3\u679c\u516c\u544a","rectime":"2016-07-08 09:20:06","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2653117286775566.pdf","size":469,"secucode":"136514","ggdate":"2016-07-08","format":"pdf"},{"textid":"zqannouncement_6","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f8\u516c\u5f00\u53d1\u884c2016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u7968\u9762\u5229\u7387\u516c\u544a","rectime":"2016-07-06 12:50:02","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2651436769528575.pdf","size":407,"secucode":"136514","ggdate":"2016-07-06","format":"pdf"},{"textid":"zqannouncement_7","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u52df\u96c6\u8bf4\u660e\u4e66","rectime":"2016-07-03 14:40:09","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860699047356.pdf","size":4311,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_8","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u503a\u5238\u53d1\u884c\u516c\u544a","rectime":"2016-07-03 14:40:09","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860889197512.pdf","size":973,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_9","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u52df\u96c6\u8bf4\u660e\u4e66\u6458\u8981","rectime":"2016-07-03 14:50:07","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647860972627526.pdf","size":1303,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"},{"textid":"zqannouncement_10","title":"\u8fdc\u4e1c\u56fd\u9645\u79df\u8d41\u6709\u9650\u516c\u53f82016\u5e74\u516c\u53f8\u503a\u5238\uff08\u7b2c\u4e09\u671f\uff09\u4fe1\u7528\u8bc4\u7ea7\u62a5\u544a","rectime":"2016-07-03 14:50:07","url":"http:\/\/www.sse.com.cn\/disclosure\/bond\/announcement\/company\/c\/2647861119687705.pdf","size":2376,"secucode":"136514","ggdate":"2016-07-04","format":"pdf"}],"pagesize":20}'; $array = json_decode($json, true); foreach ($array['item'] as $val) { if($id == $val['textid']) { header('Location: '.$val['url']); exit; } } exit; } /** 读公告文件,巨潮&news_new **/ public function fileview() { $id = $this->input->get('ID'); //债券136514,未知某处使用。 if(strstr($id, 'zqannouncement_')) { $this->fileview_zq136514($id); } if($id=='jj_50203800000000000000000000000') { header('location:http://php.cnstock.com/texts/2018/20180615/jj_50203800000000000000000000000.docx'); exit; } // HTML 格式 if($this->input->get('format') == 'html' || $this->input->get('db') == 'html') { $this->fileview_html(); } //去除特殊字符 $id = str_replace(array("'",'"','-','\\','+'), '', $id); if(checkTextID($id)=='juchao') { $this->fileview_juchao($id); } else if(checkTextID($id)=='news') { $this->fileview_news(); } } } function get_CI(){ $CI= &get_instance(); return $CI; } function get_clinet_ip() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ips = explode(',', $_SERVER['HTTP_CLIENT_IP']); foreach ($ips as $ip) { $ip = trim($ip); return $ip; } } if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); foreach ($ips as $ip) { $ip = trim($ip); return $ip; } } return $_SERVER['REMOTE_ADDR']; } ?>

    A PHP Error was encountered

    Severity: Warning

    Message: Cannot modify header information - headers already sent by (output started at /data/php/news_new/application/controllers/api.php:974)

    Filename: core/Common.php

    Line Number: 443

    404 Page Not Found

    404 Page Not Found

    The page you requested was not found.