MainController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <?php
  2. /**
  3. * MainController
  4. * Feel free to delete the methods and replace them with your own code.
  5. *
  6. * @author darkredz
  7. */
  8. class MainController extends DooController{
  9. private $column;
  10. private $comart;
  11. function __construct() {
  12. include './protected/config/index.conf.php';
  13. $this->column=$column;
  14. Doo::loadModel('Article');
  15. $article=new Article();
  16. $cid=$this->column['COMPANY'];
  17. $this->comart=$article->getArticleByCid($cid,4);
  18. }
  19. function index() {
  20. Doo::loadModel('Column');
  21. Doo::loadModel('Product');
  22. $article=new Article();
  23. $product=new Product();
  24. $column=new Column();
  25. $cid=$this->column['SOFTAPP'].",".$this->column['WEBAPP'];
  26. $data['WEBAPP']=$this->column['WEBAPP'];
  27. $col=$column->getColumnByIdList($cid);
  28. //foreach ($col as $key=>$value){
  29. $pro=$product->getProductByCid($col[0]['cid']);
  30. $col[0]['product']=$pro;
  31. //}
  32. $cid=$this->column['TRAINC'];
  33. $train=$article->getArticleByTrain(2);
  34. $end=$doing=$apply=array();
  35. foreach ($train as $key=>$value){
  36. $type=getTrainTimeByStatus($value['enroll_time']);
  37. $date=explode(":", $value['enroll_time']);
  38. if($type=="end"){
  39. $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  40. array_push($end, $train[$key]);
  41. }elseif ($type=="doing"){
  42. $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  43. array_push($doing, $train[$key]);
  44. }elseif ($type=="apply"){
  45. $time = strtotime($date[0]) - 60*60*24;
  46. $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  47. array_push($apply, $train[$key]);
  48. }
  49. }
  50. $ta=$apply+$doing+$end;
  51. //print_r($ta);die;
  52. //$type=="apply";
  53. //$article->find ( array ('desc' => 'time', 'limit'=>4 , 'where' => 'cid=4 and ', 'asArray' => TRUE ) );
  54. //$art=$article->getArticleByCid($cid,4);
  55. $art=array_slice($ta,0,4);
  56. foreach ($art as $key=>$value){
  57. $art[$key]['timeStuts']=getTrainTime2($value['enroll_time']);
  58. $art[$key]['timeStuts3']=getTrainTime3($value['enroll_time']);
  59. $art[$key]['Stuts']=strlen($art[$key]['timeStuts']);
  60. }
  61. $list1=$article->getArticleByCid2($this->column['COMPANY'],5);
  62. foreach ($list1 as $key=>$value){
  63. $list1[$key]['title']=$this->cut_str($value['title'], 45);
  64. }
  65. $list2=$article->getArticleByCid($this->column['INDUSTRY'],5);
  66. foreach ($list2 as $key=>$value){
  67. $list2[$key]['title']=$this->cut_str($value['title'], 45);
  68. }
  69. Doo::loadModel('Product');
  70. $product=new Product();
  71. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  72. $data['article']=$art;
  73. $data['comart']=$this->comart;
  74. $data['column']=$col;
  75. $data['map']='index';
  76. $data['companyNews']=$list1;
  77. $data['industryNews']=$list2;
  78. $this->render ( "/index3", $data );
  79. }
  80. function softDown2(){
  81. Doo::loadModel('Product');
  82. Doo::loadModel('Down');
  83. $down=new Down();
  84. $product=new Product();
  85. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  86. $html="";
  87. foreach ($data['product'] as $key=>$value){
  88. $data['product'][$key]['down']=array();
  89. if(!empty($value['did']))
  90. $data['product'][$key]['down']=$down->getDownByIdList($value['did']);
  91. foreach ($data['product'][$key]['down'] as $keys=>$values){
  92. $t=explode("{b}", $values['down_url']);
  93. $i=2;
  94. foreach ($t as $k=>$v){
  95. if($i==2)
  96. $html.='<a href="'.$v.'">点击下载</a>';
  97. // elseif($i==1)
  98. // $html.='<a href="'.$v.'">联通线路</a>';
  99. $i--;
  100. }
  101. $data['product'][$key]['down'][$keys]['html']=$html;
  102. $i=2;$html="";
  103. }
  104. }
  105. $data['comart']=$this->comart;
  106. $data['map']='softDown';
  107. $this->render ( "/softDown2", $data );
  108. }
  109. function softDown(){
  110. Doo::loadModel('Product');
  111. $product=new Product();
  112. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  113. $data['comart']=$this->comart;
  114. $data['map']='softDown';
  115. $this->render ( "/softDown", $data );
  116. }
  117. function ajaxSoftDown(){
  118. Doo::loadModel('Down');
  119. Doo::loadModel('Product');
  120. Doo::loadModel('Animation');
  121. $animation=new Animation();
  122. $product=new Product();
  123. $down=new Down();
  124. $did=$this->get_args('did');
  125. $pid=$this->get_args('pid');
  126. if(!empty($did))
  127. $do['dot']=$down->getDownByIdList($did);
  128. $info=$product->getProductById($pid);
  129. $MyAnimation=array();
  130. if(!empty($info[0]['anid']))
  131. $MyAnimation=$animation->getAnimationByIdList($info[0]['anid']);
  132. $belongAnimation=$animation->getAnimationByBelong();
  133. $uc='<div class="softVideo">
  134. <div class="videoItem">';
  135. if (empty($MyAnimation) ){
  136. $uc.='<span class="tips">该软件无专属教程,您可观看通用教程</span>';
  137. }else{
  138. $uc.='<h1>专属教程</h1>
  139. <ul class="clearfix">';
  140. foreach ($MyAnimation as $key=>$value){
  141. $uc.='<li>
  142. <img src="'.$value['img_url'].'">
  143. <h3>'.$value['title'].'</h3>
  144. <div class="videoCon">
  145. <span class="playBtn" data-toggle="modal" href="#myModal'.$value['aid'].'" data-keyboard="false" data-backdrop="ture"><b></b>播放</span>
  146. <a target="blank" href="'.$value['down_url'].'" ><span class="downBtn"><b></b>下载</span></a>
  147. </div>
  148. </li>';
  149. }
  150. $uc.='</ul>';
  151. }
  152. $uc.='</div>
  153. <div class="videoItem">
  154. <h1>通用教程</h1>
  155. <ul class="clearfix">';
  156. foreach ($belongAnimation as $key=>$value){
  157. $uc.='<li>
  158. <img src="'.$value['img_url'].'">
  159. <h3>'.$value['title'].'</h3>
  160. <div class="videoCon">
  161. <span class="playBtn" data-toggle="modal" href="#myModal'.$value['aid'].'" data-keyboard="false" data-backdrop="ture"><b></b>播放</span>
  162. <a target="blank" href="'.$value['down_url'].'"> <span class="downBtn"><b></b>下载</span> </a>
  163. </div>
  164. </li>';
  165. }
  166. $uc.='</ul>
  167. </div>
  168. <div class="bottomSpace"></div>
  169. </div>';
  170. $html='<div class="dSoftInof">
  171. <div class="productTab clearfix">
  172. <div class="title fL"><img width="32" src="'.$info[0]['logo'].'"><b>'.$info[0]['title'].'</b></div>
  173. <ul>
  174. <li class="now" id="a" onclick="changeProduct(\'info\')" title="查看版本功能更新">版本更新</li>
  175. <li id="c" onclick="changeProduct(\'edition\')" title="浏览软件简介" class="">软件介绍</li>
  176. <li id="d" onclick="changeProduct(\'animation\')" title="观看软件动画教程" class="">动画教程 </li>
  177. </ul>
  178. </div>
  179. <div class="contentItem" id="info" style="display: block;">
  180. '.$info[0]['edition'].'
  181. </div>
  182. <div class="contentItem" id="edition" style="display: none;">
  183. '.$info[0]['content'].'
  184. </div>
  185. <div class="contentItem" id="animation" style="display: none;">
  186. '.$uc.'
  187. </div>
  188. </div>';
  189. if($info[0]['p_type']!=2)
  190. $do['info']=$html;
  191. else
  192. $do['info']="";
  193. $show=json_encode($do);
  194. echo $show;
  195. }
  196. function product(){
  197. $pid=$this->params['pid'];
  198. $pid=is_numeric($pid)?$pid:0;
  199. Doo::loadModel('Product');
  200. Doo::loadModel('Down');
  201. Doo::loadModel('Animation');
  202. $animation=new Animation();
  203. $down=new Down();
  204. $product=new Product();
  205. $data['product']=$product->getProductByCid($this->column['SOFTAPP']);
  206. if (empty($pid))
  207. $pid=$data['product'][0]['pid'];
  208. //获取下载内容
  209. $data['productInfo']=$product->getProductById($pid);
  210. if(empty($data['productInfo'][0]['did']))
  211. $data['productInfo'][0]['did']=0;
  212. $do=$down->getDownByIdList($data['productInfo'][0]['did']);
  213. foreach ($do as $key=>$value){
  214. $url=explode("{b}", $value['down_url']);
  215. $do[$key]['down_url']=$url;
  216. }
  217. $data['productInfo'][0]['down']=$do;
  218. $data['MyAnimation']=array();
  219. if(!empty($data['productInfo'][0]['anid']))
  220. $data['MyAnimation']=$animation->getAnimationByIdList($data['productInfo'][0]['anid']);
  221. $data['belongAnimation']=$animation->getAnimationByBelong();
  222. $data['comart']=$this->comart;
  223. $data['map']='product';
  224. $data['title']=$data['productInfo'][0]['title'];
  225. $this->render ( "/product", $data );
  226. }
  227. function aboutUs(){
  228. $k=isset($this->params ['k'])?$this->params['k']:'';
  229. $data['comart']=$this->comart;
  230. $data['map']='aboutUs';
  231. if (empty($k)){
  232. $this->render ( "/aboutUsAbout", $data );
  233. }else{
  234. Doo::loadModel('Article');
  235. $article=new Article();
  236. //$s=strtotime(date('Y')."-01-01");
  237. $s=strtotime("2015-01-01");
  238. $list=$article->find(array ( 'where' => 'cid= 7 and time>='.$s,'desc'=>'time','asArray' => TRUE ));
  239. foreach ($list as $key=>$value){
  240. $list[$key]['month']=date('m',$value['time']);
  241. if(empty($value['thum']))
  242. $list[$key]['thum']='/global/img/2.png';
  243. }
  244. $data['list']=$list;
  245. $data['year']=date('Y');
  246. $this->render ( "/".$k, $data );
  247. }
  248. }
  249. function contact(){
  250. $data['comart']=$this->comart;
  251. $data['map']='contact';
  252. $data['iscontact'] = 1;
  253. $this->render ( "/contact", $data );
  254. }
  255. function contact2(){
  256. $data['iscontact'] = 1;
  257. $this->render ( "/contact2", $data );
  258. }
  259. function train(){
  260. $article=new Article();
  261. $train=$article->getArticleByTrain(2);
  262. $end=$doing=$apply=array();
  263. foreach ($train as $key=>$value){
  264. $type=getTrainTimeByStatus($value['enroll_time']);
  265. $date=explode(":", $value['enroll_time']);
  266. if($type=="end"){
  267. $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  268. array_push($end, $train[$key]);
  269. }elseif ($type=="doing"){
  270. $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  271. array_push($doing, $train[$key]);
  272. }elseif ($type=="apply"){
  273. $time = strtotime($date[0]) - 60*60*24;
  274. $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  275. array_push($apply, $train[$key]);
  276. }
  277. }
  278. $train=$article->getArticleByTrain(1);
  279. $end1=$doing1=$apply1=array();
  280. foreach ($train as $key=>$value){
  281. $type=getTrainTimeByStatus($value['enroll_time']);
  282. $date=explode(":", $value['enroll_time']);
  283. if($type=="end"){
  284. $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  285. array_push($end1, $train[$key]);
  286. }elseif ($type=="doing"){
  287. $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  288. array_push($doing1, $train[$key]);
  289. }elseif ($type=="apply"){
  290. $time = strtotime($date[0]) - 60*60*24;
  291. $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  292. array_push($apply1, $train[$key]);
  293. }
  294. }
  295. $data['end1']=$end1;
  296. $data['doing1']=$doing1;
  297. $data['apply1']=$apply1;
  298. $data['end']=$end;
  299. $data['doing']=$doing;
  300. $data['apply']=$apply;
  301. $data['comart']=$this->comart;
  302. $data['map']='trainI';
  303. $this->render ( "/train2", $data );
  304. }
  305. function trainPage(){
  306. $aid=$this->params['aid'];
  307. $aid=is_numeric($aid)?$aid:0;
  308. if(empty($aid)){
  309. return "/train";
  310. }
  311. $article=new Article();
  312. $trainPage=$article->getArticleByTrainAid($aid);
  313. $trainPage[0]['timeStuts']=getTrainTime($trainPage[0]['enroll_time']);
  314. $trainPage[0]['class']=getTrainTimeByStatus($trainPage[0]['enroll_time']);
  315. $data['trainPage']=$trainPage[0];
  316. $data['comart']=$this->comart;
  317. $data['map']='train';
  318. $this->render ( "/trainPage", $data );
  319. }
  320. function searchNews(){
  321. $kind = $this->get_args('kind') ? $this->get_args('kind') : 1;
  322. $k = $this->get_args('k') ? $this->get_args('k') : "";
  323. $onPage =$this->get_args('onPage')&&is_numeric ( $this->get_args('onPage') ) ? $this->get_args('onPage') : 1;
  324. $list=array();$next=0;$previous=0;
  325. if (!empty($k)){
  326. Doo::loadModel('Down');
  327. $down=new Down();
  328. $article=new Article();
  329. if ($onPage <= 0)
  330. $onPage = 1;
  331. $pageSize = 20;
  332. $o=$onPage;
  333. $lower = (-- $o) * $pageSize;
  334. $previous = $onPage != 0 ? $onPage - 1 : $onPage;
  335. if ($kind==2){
  336. $list=$down->find(array('where'=>'title like "%'.$k.'%" or key_number like "%'.$k.'%"','limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  337. $totalCount = $down->count(array('where'=>'title like "%'.$k.'%" or key_number like "%'.$k.'%"','limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  338. $total = intval ( $totalCount / $pageSize );
  339. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  340. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  341. foreach ($list as $key=>$value){
  342. $url=explode("{b}", $value['down_url']);
  343. $list[$key]['down_url']=$url;
  344. }
  345. }elseif($kind==3){
  346. Doo::loadModel('ArticleDao');
  347. $ArticleDao=new ArticleDao();
  348. $list=$ArticleDao->find(array('select'=>'title,aid,cid,time','where'=>'title like "%'.$k.'%" ',
  349. 'limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  350. $totalCount = $ArticleDao->count(array('where'=>'title like "%'.$k.'%" ','asArray' => TRUE));
  351. $total = intval ( $totalCount / $pageSize );
  352. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  353. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  354. }else{//or content like "%'.$k.'%"
  355. $list=$article->find(array('select'=>'title,aid,cid,time','where'=>'title like "%'.$k.'%" and ( cid=4 or cid=5 or cid=3 or cid=7)',
  356. 'limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  357. $totalCount = $article->count(array('where'=>'title like "%'.$k.'%" and ( cid=4 or cid=5 or cid=3 or cid=7)','asArray' => TRUE));
  358. $total = intval ( $totalCount / $pageSize );
  359. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  360. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  361. foreach ($list as $key=>$value){
  362. if($value['cid']==4)
  363. $list[$key]['c']='公司新闻';
  364. elseif ($value['cid']==5)
  365. $list[$key]['c']='行业新闻';
  366. elseif ($value['cid']==3)
  367. $list[$key]['c']='培训教育';
  368. elseif ($value['cid']==7)
  369. $list[$key]['c']='软件更新';
  370. }
  371. }
  372. }
  373. $data['next']=$next;
  374. $data['previous']=$previous;
  375. $data['k']=$k;
  376. $data['onPage']=$onPage;
  377. $data['list']=$list;
  378. $data['kind']=$kind;
  379. $data['map']='sNews';
  380. $this->render ( "/search", $data );
  381. }
  382. function news(){
  383. $n = "";
  384. $cid=isset($this->params ['cid'])&&is_numeric($this->params['cid'])?$this->params['cid']:$this->column['COMPANY'];
  385. $aid=isset($this->params ['aid'])&&is_numeric($this->params['aid'])?$this->params['aid']:0;
  386. $on_page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  387. //
  388. if ($on_page <= 0)
  389. $on_page = 1;
  390. $page_size = 10;
  391. // //检索条件
  392. if($cid==$this->column['TRAINC'])
  393. $n = " and a_type=2 and cid =" . $cid .' and title!=""';
  394. else
  395. $n = " and a_type=1 and cid =" . $cid .' and title!=""';
  396. $condition=$n;
  397. $action = "/news/";
  398. Load::logic ( 'Admin' );
  399. $this->adminlogic = new AdminLogic ();
  400. //获取分页相关数据
  401. $page = $this->adminlogic->get_page ( "sc_article", $condition, $on_page, $page_size, $action );
  402. $limit = " order by update_time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  403. Doo::loadModel('Article');
  404. $article=new Article();
  405. // $k=$article->getOne(array ('where' => 'aid=721' , 'asArray' => TRUE ));
  406. //
  407. // print_r();
  408. //echo $condition;
  409. $page ['article_list'] = $article->getArticleList ( array (), $condition, $limit );
  410. $data['articleInfo']=array();
  411. if(empty($aid)){
  412. if(!empty($page ['article_list']))
  413. $data['articleInfo']=$page ['article_list'][0];
  414. }else{
  415. $a=$article->getArticleById($aid);
  416. $data['articleInfo']=$a[0];
  417. }
  418. foreach ($page ['article_list'] as $key=>$value){
  419. if(empty($value['thum']))
  420. $page ['article_list'][$key]['thum']='/global/img/2.png';
  421. }
  422. $data ['article'] = $page;
  423. $k="";
  424. for ($i=1;$i<=$page['total_page'];$i++){
  425. if($on_page==$i)
  426. $k.="<option value='".$cid.":".$i."' selected>第".$i."页</option>";
  427. else
  428. $k.="<option value='".$cid.":".$i."'>第".$i."页</option>";
  429. }
  430. $data['page']=$page;
  431. $data['comart']=$this->comart;
  432. $data['onpage']=$on_page;
  433. $data['cid']=$cid;
  434. $data['aid']=$aid;
  435. $data['column']=$this->column;
  436. $data['map']='news';
  437. $this->render ( "/news2", $data );
  438. }
  439. function newsPage(){
  440. $aid=isset($this->params ['aid'])&&is_numeric($this->params['aid'])?$this->params['aid']:0;
  441. Doo::loadModel('Article');
  442. $article=new Article();
  443. $a=$article->getArticleById($aid);
  444. $list=$article->find(array ( 'where' => 'aid !=' . $a[0]['aid'].' and cid='.$a[0]['cid'], 'limit'=>'5','desc'=>'aid' ,'asArray' => TRUE ));
  445. $data['list']=$list;
  446. $data['cid']=$a[0]['cid'];
  447. $data['articleInfo']=$a[0];
  448. $data['comart']=$this->comart;
  449. $data['aid']=$aid;
  450. $data['column']=$this->column;
  451. $data['map']='news';
  452. $this->render ( "/newsContent", $data );
  453. }
  454. function video(){
  455. Doo::loadModel('Animation');
  456. $animation=new Animation();
  457. $data['comart']=$this->comart;
  458. $data['map']='video';
  459. if(isset($this->params['aid'])){
  460. $data['nimationInfo']=$animation->getAnimationById($this->params['aid']);
  461. $this->render ( "/videoPage", $data );
  462. }else{
  463. $data['nimation']=$animation->getAnimationList(array(), "", "order by aid asc");
  464. $this->render ( "/video", $data );
  465. }
  466. }
  467. function sdown(){
  468. $url=isset($this->params ['url'])?$this->params['url']:0;
  469. if(!empty($url)){
  470. $url=base64_decode($url);
  471. if(!empty($url))
  472. return $url;
  473. }else{
  474. return "/";
  475. }
  476. }
  477. function getInfo(){
  478. $article=new Article();
  479. $info=$article->getArticleByCid($this->column['COMPANY'],2);
  480. $k=array();
  481. foreach ($info as $key=>$value){
  482. array_push($k, array('aid'=>$value['aid'],'title'=>$value['title']));
  483. }
  484. $pa['company']=$k;
  485. $cid=$this->column['TRAINC'];
  486. $art=$article->getArticleByCid($cid,3);
  487. $k=array();//,'timeStuts'=>getTrainTimeTk($value['enroll_time'])
  488. foreach ($art as $key=>$value){
  489. array_push($k, array('aid'=>$value['aid'],'title'=>$value['enroll_title']));
  490. }
  491. $pa['trainc']=$k;
  492. echo json_encode($pa);
  493. }
  494. function getInfo2(){
  495. $article=new Article();
  496. $info=$article->getArticleByCid($this->column['COMPANY'],6);
  497. $k=array();
  498. foreach ($info as $key=>$value){
  499. array_push($k, array('aid'=>$value['aid'],'title'=>$value['title']));
  500. }
  501. $pa['company']=$k;
  502. $cid=$this->column['TRAINC'];
  503. $art=$article->getArticleByCid($cid,3);
  504. $k=array();//,'timeStuts'=>getTrainTimeTk($value['enroll_time'])
  505. foreach ($art as $key=>$value){
  506. array_push($k, array('aid'=>$value['aid'],'title'=>$value['enroll_title']));
  507. }
  508. $pa['trainc']=$k;
  509. echo json_encode($pa);
  510. }
  511. function newsHttp(){
  512. $updateTime = $this->get_args('updateTime')&&is_numeric($this->get_args('updateTime')) ? $this->get_args('updateTime') : 0;
  513. $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
  514. $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
  515. Doo::loadModel('Article');
  516. $article=new Article();
  517. if ($page!=1)
  518. $page=$page*$size-1;
  519. else
  520. $page--;
  521. $count=$article->count(array('where'=>'title!="" and (update_time>'.$updateTime.')','limit'=>$page.','.$size,'asArray'=>true));
  522. $list=$article->find(array('where'=>'title!="" and (update_time>'.$updateTime.')','limit'=>$page.','.$size,'desc'=>'update_time','asArray'=>true));
  523. echo json_encode(array('status'=>1,'articleList'=>$list,'count'=>$count));
  524. }
  525. function authentication(){
  526. $data=array();
  527. $this->render ( "/productSecurity", $data );
  528. }
  529. function doAuthentication(){
  530. $key = $this->get_args('key')? $this->get_args('key') :"";
  531. $data['comart']=$this->comart;
  532. if (!empty($key)){
  533. require_once (SITE_PATH . '/protected/class/client.php');
  534. $client = new client ( 'http://cld.smartcost.com.cn/' );
  535. $list = $client->zhsso_getSerialNumber ( $key );
  536. $list=json_decode($list,true);
  537. if (empty($list['list'])){
  538. $this->render ( "/productSecurityPiracy", $data );die;
  539. }
  540. $data['list']=$list['list'];
  541. $this->render ( "/productSecurityGenuine", $data );
  542. }else
  543. $this->render ( "/productSecurityPiracy", $data );die;
  544. }
  545. function authenticationHttp(){
  546. $SerialNumber = $this->get_args('SerialNumber')? $this->get_args('SerialNumber') :"";
  547. $data['comart']=$this->comart;
  548. if (!empty($SerialNumber)){
  549. require_once (SITE_PATH . '/protected/class/client.php');
  550. $client = new client ( 'http://cld.smartcost.com.cn/' );
  551. $list = $client->zhsso_getSerialNumber2 ( $SerialNumber );
  552. $list=json_decode($list,true);
  553. if (empty($list['list'])){
  554. $this->render ( "/productSecurityPiracy", $data );die;
  555. }
  556. $data['list']=$list['list'];
  557. $this->render ( "/productSecurityGenuine2", $data );
  558. }else{
  559. $this->render ( "/productSecurityPiracy", $data );die;
  560. }
  561. }
  562. function cut_str($string, $length, $dot = ' ...'){
  563. if(strlen($string) <= $length)
  564. {
  565. return $string;
  566. }
  567. $strcut = '';
  568. $sys_config = 'utf-8';
  569. if($sys_config == 'utf-8'){
  570. $n = $tn = $noc = 0;
  571. while($n < strlen($string))
  572. {
  573. $t = ord($string[$n]);
  574. if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
  575. $tn = 1; $n++; $noc++;
  576. } elseif(194 <= $t && $t <= 223) {
  577. $tn = 2; $n += 2; $noc += 2;
  578. } elseif(224 <= $t && $t < 239) {
  579. $tn = 3; $n += 3; $noc += 2;
  580. } elseif(240 <= $t && $t <= 247) {
  581. $tn = 4; $n += 4; $noc += 2;
  582. } elseif(248 <= $t && $t <= 251) {
  583. $tn = 5; $n += 5; $noc += 2;
  584. } elseif($t == 252 || $t == 253) {
  585. $tn = 6; $n += 6; $noc += 2;
  586. } else {
  587. $n++;
  588. }
  589. if($noc >= $length)
  590. {
  591. break;
  592. }
  593. }
  594. if($noc > $length)
  595. {
  596. $n -= $tn;
  597. }
  598. $strcut = mb_substr($string, 0, $n);
  599. }
  600. else
  601. {
  602. for($i = 0; $i < $length; $i++)
  603. {
  604. $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
  605. }
  606. }
  607. return $strcut.$dot;
  608. }
  609. /**
  610. * 获取get或者POST值
  611. * @param string $name 属性名称
  612. * @return fixed 值
  613. */
  614. function get_args($name) {
  615. if (isset ( $_GET [$name] )) {
  616. if (is_array ( $_GET [$name] ))
  617. return $_GET [$name];
  618. else
  619. return addslashes ( $_GET [$name] );
  620. } elseif (isset ( $_POST [$name] )) {
  621. if (is_array ( $_POST [$name] ))
  622. return $_POST [$name];
  623. else
  624. return addslashes ( $_POST [$name] );
  625. } else {
  626. return false;
  627. }
  628. }
  629. }
  630. ?>