Smarty new Smarty db_connect st do_style if isset _SESSION admin admin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
$Smarty = new Smarty();
db_connect();
$st = do_style();
if(isset($_SESSION['admin'])) $admin = $_SESSION['admin']; else $admin = null;
$q = "SELECT `value` FROM `site_options` WHERE `name` = 'news_on_page'";
$res = db_query($q) or die(mysql_error());
$row = mysql_fetch_assoc($res);
$num_res = mysql_num_rows($res);
if($num_res)
$zap_on_str = (int)$row['value'];
else $zap_on_str = 9;
//======= Output list======================================================
$query = "SELECT * FROM `news`";
$result = db_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
mysql_free_result($result);
$str_col = ($num_results/$zap_on_str)+1;
settype($str_col,"integer");
//Проверка количества записей и вывод нужных
if((!isset($_GET['str_id'])) || ($_GET['str_id'] == '0')) $str_id = 0;
else $str_id = (int)$_GET['str_id'];
$n_start = $str_id * $zap_on_str;
$n_end = $n_start + $zap_on_str;
$news = array();
$query = "SELECT * FROM `news` ORDER BY `id` DESC LIMIT $n_start,$n_end";
$result = db_query($query) or die(mysql_error());
While ($row = mysql_fetch_assoc($result))
{
$row['content'] = substr($row['content'],0,450);
$row['content'] .= '...';
$row['date'] = our_data($row['date']);
$news[] = $row;
}
if(isset($_REQUEST['id']))
$Smarty->assign("id",$_REQUEST['id']);
$Smarty->assign("st",$st);
$Smarty->assign("admin",$admin);
$Smarty->assign("zap_on_str",$zap_on_str);
$Smarty->assign("ident",$ident);
$Smarty->assign("table_title",$table_title);
$Smarty->assign("act",$act);
$Smarty->assign("title",$title);
$Smarty->assign("content",$content);
$Smarty->assign("but_cap",$but_cap);
$Smarty->assign("on_fns",$on_fns);
$Smarty->assign("str_col",$str_col);
$Smarty->assign("news",$news);
$Smarty->display("index.tpl");