include_once(dirname(__FILE__).'/config.php');
include_once(dirname(__FILE__).'/../codebase/core.class.php');
$c = new Core();
$news_file_dir = dirname(__FILE__).'/cache/';
$p = $c->getVal("p"); // povzetek
$bdc = $c->getVal("bdc"); // bordercolor
$bgc = $c->getVal("bgc"); // bgcolor
$sd = $c->getVal("sd",1); // datum
$w = $c->getVal("w",330); // width
$nc = $c->getVal("nc",5); // stevilo novic
$l = $c->getVal("l",0); // logo
$ct = $c->getVal("ct",2); // kodni nabor
$fc = $c->getVal("fc",'000000'); // font color
$encodingsArr=array(
3=>"windows-1250",
0=>"windows-1250",
1=>"ISO-8859-2",
2=>"utf-8"
);
$cacheKey = md5(json_encode($_GET));
$file = $news_file_dir.$cacheKey;
if (!file_exists($file) || (time() - filemtime($file)) > (3600*2)){
$c->loadWP();
$posts = get_posts([
'numberposts' => intval($nc),
'post_type' => 'post',
'meta_query' => [[
'key' => 'it-company',
'value' => '',
'compare' => '='
]],
'orderby' => 'publish_date',
'order' => 'DESC'
]);
$html = '
';
if ($l) {
$html.='
.'/assets/images/racunalniske-novice-logo.png) |
';
}
$html.='
';
foreach ($posts as $p) {
global $post;
setup_postdata($p);
$html.='';
if ($sd){
$style=!empty($bdc)?'style="border-bottom:solid 1px #'.$bdc.';border-right:solid 1px #'.$bdc.'" ':"";
$html.=''.get_the_date("d.m.", $p).' | ';
}
$style=!empty($bdc)?'style="border-bottom:solid 1px #'.$bdc.'" ':"";
$html .=''.$p->post_title.'';
if ($p) {
$html.=' '.strip_tags(get_summary($p->ID)).'';
}
$html .= '';
$html.=' | ';
}
if (!$l) {
$html.='
Novice posreduje revija Računalniške novice |
';
}
$html.='
|
';
$s = 'document.write('.json_encode($html).')';
switch($ct)
{
default:
$s = iconv("UTF-8", "Windows-1250", $s);
$chrs="windows-1250";
break;
case 1:
$s = iconv("UTF-8", "ISO-8859-2", $s);
$chrs="ISO-8859-2";
break;
case 2:
$chrs="utf-8";
break;
}
if($fh=fopen($file,'w'))
{
flock($fh, LOCK_EX);
fwrite($fh,$s);
flock($fh, LOCK_UN);
fclose($fh);
}
}
switch($ct)
{
default:
$chrs="windows-1250";
break;
case 1:
$chrs="ISO-8859-2";
break;
case 2:
$chrs="utf-8";
break;
}
//prikazemo vsebino
header("Content-Type: text/plain; charset=".$chrs);
if($fh = fopen($file, 'r')) {
flock($fh, LOCK_SH);
fpassthru($fh);
flock($fh, LOCK_UN);
fclose($fh);
}
?>