8-3
function.php
if (! file_exists (XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php" )) { |
include_once XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php" ; |
include_once XOOPS_ROOT_PATH . "/modules/snews/function_block.php" ; |
include_once XOOPS_ROOT_PATH . "/modules/tadtools/TadUpFiles.php" ; |
$TadUpFiles = new TadUpFiles( "snews" ); |
global $xoopsTpl , $xoopsDB , $TadUpFiles ; |
$json = file_get_contents (XOOPS_URL . "/uploads/snews/focus.json" ); |
$all_focus = json_decode( $json , true); |
$xoopsTpl ->assign( 'all_focus' , $all_focus ); |
$myts = MyTextSanitizer::getInstance(); |
$tbl = $xoopsDB ->prefix( 'snews' ); |
$sql = "SELECT * FROM `$tbl` WHERE `sn` = '{$sn}'" ; |
$result = $xoopsDB ->query( $sql ) or web_error( $sql ); |
$snews = $xoopsDB ->fetchArray( $result ); |
$snews [ 'content' ] = $myts ->displayTarea( $snews [ 'content' ], 1, 0, 0, 0, 0); |
$snews [ 'title' ] = $myts ->htmlSpecialChars( $snews [ 'title' ]); |
$snews [ 'username' ] = $myts ->htmlSpecialChars( $snews [ 'username' ]); |
$content = "<h1>{$snews['title']}</h1>" ; |
$content .= "<p>{$snews['content']}</p>" ; |
file_put_contents (XOOPS_ROOT_PATH . "/uploads/snews/{$sn}.html" , $html ); |
global $xoopsDB , $TadUpFiles ; |
$myts = MyTextSanitizer::getInstance(); |
$tbl = $xoopsDB ->prefix( 'snews' ); |
$sql = "SELECT * FROM `$tbl` where `focus`=1 ORDER BY `sort`,`update_time` DESC" ; |
$result = $xoopsDB ->query( $sql ) or web_error( $sql ); |
while ( $snews = $xoopsDB ->fetchArray( $result )) { |
$content = str_replace ( array ( "\n" , "\r" ), '' , strip_tags ( $snews [ 'content' ])); |
$snews [ 'content' ] = word_cut( $content , 600); |
$snews [ 'summary' ] = word_cut( $content , 40); |
$snews [ 'title' ] = $myts ->htmlSpecialChars( $snews [ 'title' ]); |
$TadUpFiles ->set_col( 'sn' , $snews [ 'sn' ]); |
$snews [ 'cover' ] = $TadUpFiles ->get_pic_file(); |
$json = json_encode( $all_focus , JSON_UNESCAPED_UNICODE); |
file_put_contents (XOOPS_ROOT_PATH . "/uploads/snews/focus.json" , $json ); |