if ($page>0){} else {$page=1;}
$np=$_GET["np"];
$perpageloop=18;
$pageloop=get_var("pl",1);
$result=$db->sql_query("select * from ".$table_prefix."data where (for_login_users=0 OR (for_login_users=1 AND '".$userrow[username]."'<>'')) AND offline=0 and id='$id' and lang_id=$lid AND (folder=2 or folder=-1)");
if ($row=$db->sql_fetchrow($result)) {
$show_subject=$row[show_subject];
$perpage=$row[per_page]*1;
$parent_id = $row[parent_id];
$id = $row[id];
$foldername = $row[foldername];
$submenuloop=getsubmenuloop($lid,$id);
if ($perpage>0) {} else {$perpage=1000000;}
$perpageloop=$perpage;
$sort_by=$row[sort_by];
$hide_children=$row[hide_children];
$mm=split($page_delimiter,$row[text]);
if (is_array($mm)) {
$sulnewspage=count($mm);
if ($np<=$sulnewspage && $np>=1) {} else {$np=1;}
$row[text]=$mm[$np-1];
}
$text=$row[text];
//$has_comment=$row[has_comment];
$st="select count(*) as sul from ".$table_prefix."data where (for_login_users=0 OR (for_login_users=1 AND '".$userrow[username]."'<>'')) AND show_in_submenulist=1 AND offline=0 and parent_id='$id' and lang_id=$lid and subject<>'' and foldername<>'' ";
$result=$db->sql_query($st);
if ($row=$db->sql_fetchrow($result)) { $sulloop=$row[sul];}
if ($sulloop<=$perpageloop+2) {$perpageloop=$sulloop;}
$sullooppage=ceil($sulloop/$perpageloop);
if ($pageloop<1) {$pageloop=1;}
if ($pageloop>$sullooppage) {$pageloop=$sullooppage;}
$n=($pageloop-1)*$perpageloop;
$offsetloop=($pageloop-1)*$perpageloop;
$n=$offsetloop;
$pagelooploop=Array();
for ($i=1; $i<=$sullooppage; $i++) {$pagelooploop[]=$i;}
$subloop=Array();
$shvili='';
if ($hide_children!=1) {
$ss="";
if ($sort_by) {$ss=$sort_by.", ";}
$result=$db->sql_query("select * from ".$table_prefix."data where (for_login_users=0 OR (for_login_users=1 AND '".$userrow[username]."'<>'')) AND show_in_submenulist=1 and offline=0 and parent_id='$id' and lang_id=$lid and subject<>'' and foldername<>'' order by $ss sort limit $n,$perpageloop");
while ($row=$db->sql_fetchrow($result)) {
if ($shvili=='') {$shvili=$row[foldername];}
$subloop[]=Array('url'=>gaige_url($row[id]), subject=>$row[subject], usefile=>$row[usefile], new_window=>$row[new_window], img=>$row[img], id=>$row[id], lnk=>$row["link"]);
}
}
// ------------------------------------------------------------ //
$page=get_var("p",1);
if ($page<=0) {$page=1;}
$offset1=($page-1)*$perpage;
$newsid=$i2;
$submenu_url=get_url($id);
$newsoopk=Array();
$news=Array();
$shida_id =array();
$sul=0;
if ($usefile=='lit') {
#tu sia und gamovides----
$st="select count(*) as sul from ".$table_prefix."data where offline=0 and parent_id='$id' and lang_id=$lid";
$result=$db->sql_query($st);
if ($row=$db->sql_fetchrow($result)) {$sul=$row[sul];}
$st="select * from ".$table_prefix."data where offline=0 and parent_id='$id' and lang_id=$lid order by sort limit $offset1,$perpage";
$result=$db->sql_query($st);
$ss=$offset1;
while ($row=$db->sql_fetchrow($result)) {
$ss++;
$newsloopk[]=array(id=>$id, lid=>$lid, foldername=>$foldername, n=>$ss,img=>$row['img'], id2=>$row['id'], subject=>$row['subject'], text=>$row['text_small'], file=>$row['file'], url_page=>get_url($row[id])."?p=$page", lnk=>$row["link"]);
$shida_id[] = $row['id'];
$sel=0; if ($newsid==$row[id]) {$sel=1;}
$submenuloop4firstpage[]=Array(url=>$submenu_url, n=>$ss, sel=>$sel, subject=>$row[subject], text=>$row[text_small], id2=>$row[id], lnk=>$row["link"]);
}
}
//$child_folder = getmenuloopbyparentid(79,2,2);
//var_dump($child_folder);
if ($newsid>0) {
$st="select * from ".$table_prefix."data where offline=0 and parent_id='$id' and lang_id=$lid and id='$newsid'";
$result=$db->sql_query($st);
if ($row=$db->sql_fetchrow($result)) {
$news[]=array(subject=>$row[subject], text=>$row[text], text_small=>$row[text_small], img=>$row[img],file=>$row[file], download=>$wordz[download], id2=>$row[id] );
}else {$newsid=0;}
}
if ($newsid) {} else {$submenuloop4firstpage=Array();}
$subject = array();
$result=$db->sql_query("select * from ".$table_prefix."data where offline=0 and id='$id' and lang_id=$lid");
if ($row=$db->sql_fetchrow($result)) {
$text_id=$row['id'];
$image=$row['img'];
//$text=$row['text'];
$text_small=$row['text_small'];
$folder_type=$row['folder'];
//$subject[] = array(subject=>$row['subject']);
}
//var_dump($folder_type);
//var_dump($usefile);
//var_dump($subject);
// ------------------------------------------------------------ //
$smarty=install_smarty();
$smarty->assign('newsloop',$newsloopk);
$smarty->assign('main_url',get_url($id));
$smarty->assign('text',$text);
$smarty->assign('lang',$lang);
$smarty->assign('subloop',$subloop);
$smarty->assign('subject',$subject);
$smarty->assign('show_subject',$show_subject);
$smarty->assign('total_views',$total_views);
$smarty->assign('error',$error);
$smarty->assign('action',$action);
$smarty->assign('sul',$sul);
$smarty->assign('pageloop',$pageloop);
$smarty->assign('page',$page);
$smarty->assign('sulpage',$sulpage);
$smarty->assign('userrow',$userrow);
// ------------------------------------------------------------ //
$smarty->assign('news',$news);
$smarty->assign('submenu_url',$submenu_url);
$smarty->assign('submenuloop',$submenuloop);
$smarty->assign('foldername',$foldername);
$smarty->assign('usefile',$usefile);
$smarty->assign('folder_type',$folder_type);
$smarty->assign('id',$id);
$smarty->assign('parent_id',$parent_id);
$smarty->assign('text_id',$text_id);
$smarty->assign('image',$image);
$smarty->assign('text',$text);
$smarty->assign('text_small',$text_small);
// ------------------------------------------------------------ //
$smarty->assign('sulloop',$sulloop);
$smarty->assign('child_folder',$child_folder);
$smarty->assign('sullooppage',$sullooppage);
$smarty->assign('pagelooploop',$pagelooploop);
$smarty->assign('np',$np);
$newspageloop=Array(); for ($i=1; $i<=$sulnewspage; $i++) {$newspageloop[]=$i;}
$smarty->assign('newspageloop',$newspageloop);
$smarty->assign('sulnewspage',$sulnewspage);
$out= $smarty->fetch('lit.tpl.php');
}
?>