function lib_randarc(&$ctag , &$refObj){global $dsql;FillAttsDefault($ctag->CAttribute->Items ,"limit|1");extract($ctag->CAttribute->Items);$s = '';$tcp = new DedeTagParse();$tcp->SetNameSpace("field",'[',']');$tcp->LoadSource($ctag->GetInnerText());$sql = $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepathFROM `dede_archives` se LEFT JOIN `dede_arctype` tp ON se.typeid=tp.id WHERE 1 order by rand() limit $limit";$dsql->Execute("f",$sql);while($row1 = $dsql->GetArray("f")){$row1['arcurl'] = GetFileUrl($row1['id'],$row1['typeid'],$row1['senddate'],$row1['title'],$row1['ismake'],$row1['arcrank'],$row1['namerule'],$row1['typedir'],$row1['money'],$row1['filename'],$row1['moresite'],$row1['siteurl'],$row1['sitepath']);foreach($tcp->CTags as $k => $v ){$tcp->Assign($k , $row1[$v->GetName()]);}$s.=$tcp->GetResult();}return $s;} |
<?phpfunction sp_input( $text ){$text = trim( $text );$text = htmlspecialchars( $text );if ( !get_magic_quotes_gpc() )return addslashes( $text );elsereturn $text;}$autotime = 300;//自动更新时间,单位为秒,这里我设为5分钟,大家可以自行更改。$fpath = "../data/last_time.inc";//记录更新时间文件,如果不能达到目的,请检查是否有读取权限。include( $fpath );if( emptyempty($last_time) )$last_time = 0;if( sp_input($_GET['renew'])=="now" )$last_time = 0;if( (time()-$last_time)>=$autotime ){define('DEDEADMIN', ereg_replace("[/]{1,}",'/',dirname(__FILE__) ) );require_once(DEDEADMIN."/../include/common.inc.php");require_once(DEDEINC."/arc.partview.class.php");/*$row = $dsql->GetOne("Select * From dede_homepageset");$dsql->Close();$templet=$row['templet'];$position=$row['position'];*/$templet = "default/index.htm";//这里是首页模板位置,当前是dede默认首面位置。$position = "../index.html";$homeFile = dirname(__FILE__)."/".$position;$homeFile = str_replace( "", "/", $homeFile );$homeFile = str_replace( "//", "/", $homeFile );$pv = new PartView();$pv -> SetTemplet( $cfg_basedir.$cfg_templets_dir."/".$templet );$pv -> SaveToHtml( $homeFile );$pv -> Close();$file = fopen( $fpath, "w" );fwrite( $file, "<?phpn" );fwrite( $file, "$last_time=".time().";n" );fwrite( $file, '?>' );fclose( $file );}?> |
新闻热点
疑难解答