鏂囨。涓嬭浇

2012 年 11 月 3 日4710

<?php

require_once(rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/'.'include/inc.php');

require_once(rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/'.'include/config.php');

//require_once($_SERVER['DOCUMENT_ROOT'].'/include/page.class.php');

//static $pg = 1;//瀹氫箟涓涓 鍏ㄥ眬闈欐佸彉閲

class class_myclass extends abs_plugin{

private $_db=NULL;

private $_tpl='plugins/classroom/class_myclass.html';//smarty妯℃澘璺寰

private $st;

private $ed = 9;

function __construct($params,$flag=0){ //鏋勯犲嚱鏁

parent::__construct($params,$flag);

$this->dbedf=MyDB('eduframework');

$this->dbedu=MyDB('educenter');

$this->dbsns=MyDB('sns_xin');

$this->dbres=MyDB('resources');

}

function index($params=array()){//鍙傛暟鏄涓涓鏁扮粍

if(isset($_REQUEST['page']))//妫鏌page鏄鍚﹁璧嬪

$pg = (int)($_REQUEST['page']);

else

$pg = 1;

//$url = "http://".$_SERVER['HTTP_HOST']."";

//$this->_smarty->assign('url',$url);

$sqledu="select * from video_main ,video_live where video_main.is_live_video=1 and video_live.v_id=video_main.v_id order by add_time desc ";

$resultedu= $this->dbedf->query($sqledu);

$hangshu = $resultedu->num_rows;//鏌ヨ㈢殑璁板綍鎬绘暟

$page_count = ceil($hangshu/$this->ed);//鏍规嵁璁板綍鎬绘暟闄や互姣忛〉鏄剧ず鐨勮板綍鏁版眰鍑烘墍鍒嗙殑鎬婚〉鏁

if($pg < 1) $pg = 1;

elseif($pg > 2 && $pg>$page_count) $pg=$page_count;

if($pg == 1)

{

$sqledu="

select

lower(hex(video_live.v_id)),

video_main.add_time,

video_main.video_id,

video_live.main_startime,

video_live.main_endtime,

video_main.title

from video_main ,video_live

where video_main.is_live_video=1

and video_live.v_id=video_main.v_id

order by add_time desc limit 0,9";

$resultedu= $this->dbedf->query($sqledu);

foreach($resultedu->result_array() as $name1)//杩斿洖璁板綍闆 杞涓 鏁扮粍鐨勫舰寮 瀛樻斁

{

$v_id=$name1['lower(hex(video_live.v_id))'];

$title=$name1['title'];

$add_time=$name1['add_time'];

$video_id=$name1['video_id'];

$startTM=$name1['main_startime'];

$endTM=$name1['main_endtime'];

$xiangchaTM2=date('y-m-d H:i:s'); //姹傚嚭褰撳墠鏃ユ湡锛岃浆涓虹浉搴旂殑鏍煎紡

if(strtotime($startTM)>strtotime($xiangchaTM2))

$xiangchaTM=0;//鏈寮濮

else

$xiangchaTM=1;//宸插紑濮

$tyuu = strtotime($xiangchaTM2);

$DT = date('Y/m/d H:i',strtotime($startTM));

$sz[] = array("title"=>$title, "add_time"=>$add_time,"video_id"=>$video_id,"startTM"=>$DT,"xiangchaTM"=>$xiangchaTM,"v_id"=>$v_id); //鍒涘缓浜岀淮鍏宠仈鏁扮粍锛屽苟涓旂粰鏁扮粍鍏冪礌璧嬪笺

}

$this->_smarty->assign("sz",$sz);

$this->_smarty->assign('viewurl',$viewurl);

}

else

{

//$pg=$_REQUEST['page'];

$st=($pg-1) * $this->ed; //璁$畻涓嬩竴椤典粠绗鍑犳潯鏁版嵁寮濮嬪惊鐜

$sqledu="select lower(hex(video_live.v_id)),video_main.add_time,video_main.video_id,video_live.main_startime,video_live.main_endtime,video_main.title from video_main ,video_live where video_main.is_live_video=1 and video_live.v_id=video_main.v_id order by add_time desc limit ".$st.",".$this->ed."";

$resultedu= $this->dbedf->query($sqledu);

foreach($resultedu->result_array() as $name1)

{

$v_id=$name1['lower(hex(video_live.v_id))'];

$title=$name1['title'];

$add_time=$name1['add_time'];

$video_id=$name1['video_id'];

$startTM=$name1['main_startime'];

$endTM=$name1['main_endtime'];

$xiangchaTM2=date('y-m-d H:i:s'); //姹傚嚭褰撳墠鏃ユ湡锛岃浆涓虹浉搴旂殑鏍煎紡

if(strtotime($startTM)>strtotime($xiangchaTM2))

$xiangchaTM=0;//鏈寮濮

else

$xiangchaTM=1;//宸插紑濮

$DT = date('Y/m/d H:i',strtotime($startTM));

$sz[] = array("title"=>$title, "add_time"=>$add_time,"video_id"=>$video_id,"startTM"=>$DT,"xiangchaTM"=>$xiangchaTM,"v_id"=>$v_id); //鍒涘缓浜岀淮鍏宠仈鏁扮粍锛屽苟涓旂粰鏁扮粍鍏冪礌璧嬪笺

}//鍒涘缓浜岀淮鏁扮粍銆

$a=1;

$this->_smarty->assign("a",$a);

$this->_smarty->assign("sz",$sz);//璧嬪兼搷浣

$this->_smarty->assign('viewurl',$viewurl);

}

$pd = 1;

$this->_smarty->assign('pd',$pd);//璧嬪

0 0