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.sitepath FROM `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; } |
<?php function sp_input( $text ) { $text = trim( $text ); $text = htmlspecialchars( $text ); if ( !get_magic_quotes_gpc() ) return addslashes( $text ); else return $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 ); } ?> |
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明: DEDECMS织梦模板下载随机调用文章数据方法汇总教程