php law php законодательство include_once config inc php htmlstart if

  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
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/******************************************************************************/
/* law.php */
/* законодательство */
/******************************************************************************/
include_once 'config.inc.php';
htmlstart();
if (isset($_GET['id']))
{
$id = mysql_escape_string(intval($_GET['id']));
query('LOCK TABLES content READ, items READ, list_items READ;');
$result = query(
"SELECT content.ru_text, content.img, content.ru_img_alt, bigimg, ru_bigimg_alt
FROM `content`
WHERE ( content.c_type_id=9 )
AND content.i_id=$id
;");
query('UNLOCK TABLES;');
if (mysql_num_rows($result)) while ($row = mysql_fetch_assoc($result)) $zagl = $row;
//dump($zagl);
$result = query(
"SELECT items.id,
content.ru_text
FROM `content`, `items`
WHERE content.c_type_id=4
AND content.i_id=items.id
AND items.active=1
AND (items.always=1 OR (now()+0 BETWEEN items.start AND items.end))
AND items.parent=$id
ORDER BY items.sort
;");
if (mysql_num_rows($result)) while ($row = mysql_fetch_row($result)) $objlist[] = $row;
if (isset($objlist))
{
foreach ($objlist as $k => $v)
{
query('LOCK TABLES content READ;');
$result = query("SELECT ru_text, img, imgalign, ru_img_alt, bigimg, ru_bigimg_alt, list_item_id
FROM `content`
WHERE i_id='".$v[0]."';");
query('UNLOCK TABLES;');
if (mysql_num_rows($result)) while( $row = mysql_fetch_assoc($result)) $podr[$k] = $row;
}
$podr['zagl']=$zagl;
//dump($podr);
$tpl = new Smarty;
$tpl -> assign('PODR', $podr);
$tpl -> assign('OUTPUT' , 'detail.thtml');
}
else{
$podr = false;
$tpl = new Smarty;
$tpl -> assign('OUTPUT' , 'nopage.thtml');
}
}
else
{
if(isset($news_count))
$num = $news_count; // количество на странице
else
$num = 5;
if(isset($_GET['page']))
$page = intval($_GET['page']);
else
$page = 1; // если страница не была установлена выводим первую страницу
$result = query(
"SELECT COUNT(*)
FROM `content`, `items`
WHERE content.c_type_id=9
AND content.i_id=items.id
AND items.active=1
AND (items.always=1 OR (now()+0 BETWEEN items.start AND items.end))
AND items.p_id=22;");
$allnews = mysql_fetch_row($result);
$total = intval(($allnews[0] - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$result = query(
"SELECT items.id, content.ru_text
FROM `content`, `items`
WHERE content.c_type_id=9
AND content.i_id=items.id
AND items.active=1
AND (items.always=1 OR (now()+0 BETWEEN items.start AND items.end))
AND items.p_id=22
ORDER BY items.sort
DESC LIMIT $start,$num;");
if ($total != 1){
$navi = get_navigation($page, $total, 'law.php');
} else $navi = false;
query('UNLOCK TABLES;');
if (mysql_num_rows($result)) while ($row = mysql_fetch_row($result)) $objlist[] = $row;
//dump($objlist);
// извлекаем всю необходимую инормацию
if ($objlist)
{
foreach ($objlist as $k => $v)
{
query('LOCK TABLES content READ;');
$result = query("SELECT ru_text, c_type_id, img, ru_img_alt, i_id FROM `content` WHERE i_id='".$v[0]."';");
query('UNLOCK TABLES;');
if (mysql_num_rows($result)) while( $row = mysql_fetch_assoc($result)) $news[$k][] = $row;
}
}
//dump($news);
$tpl = new Smarty;
$tpl -> assign('OBJ', $news);
$tpl -> assign('NAVI', $navi);
$tpl -> assign('OUTPUT' , 'law.thtml');
}
$tpl -> compile_check = $devel;
$tpl -> debugging = $tpl_debug;
$tpl -> assign('META' , get_meta(22));
$tpl -> assign('PAGE' , 'law');
$tpl -> assign('NEWS' , get_news_annonce());
$tpl -> display("main.thtml");
htmlend();
?>