PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/news/index.php

https://bitbucket.org/ssimpledecision/simpledecision
PHP | 148 lines | 144 code | 4 blank | 0 comment | 15 complexity | 3193ac7a595c46b4b575a4a7dcbeadbd MD5 | raw file
  1. <? include "../../inc/header_m.php";?>
  2. <?
  3. $searchinmodul=$_POST['searchinmodul'];
  4. if (!empty($searchinmodul)){
  5. $searchinmodul=explode(' ', $searchinmodul);
  6. foreach ($searchinmodul as $key => $value) {
  7. $searchinmodules.="or UPPER(title) LIKE '%".strtoupper($value)."%' ";
  8. $searchinmodules.="or UPPER(text) LIKE '%".strtoupper($value)."%' ";
  9. }
  10. $searchinmodules=' ('.substr($searchinmodules, 2).') and ';
  11. }
  12. $del = $_POST['list'];
  13. $del2 = $_POST['list2'];
  14. $sor = $_POST['sor'];
  15. $sor2 = $_POST['sor2'];
  16. if (isset($del))
  17. foreach ($del as &$delv)
  18. {
  19. mysql_query("delete from {$pref}db_{$modul} where id={$delv}");
  20. }
  21. if (isset($del2))
  22. foreach ($del2 as &$delv)
  23. {
  24. mysql_query("delete from {$pref}db_{$modul}_cat where id={$delv}");
  25. }
  26. if (isset($sor))
  27. foreach ($sor as $sork=>$sorv)
  28. {
  29. mysql_query("update {$pref}db_{$modul}_cat set sort={$sorv} where id={$sork}");
  30. }
  31. if (isset($sor2))
  32. foreach ($sor2 as $sork=>$sorv)
  33. {
  34. mysql_query("update {$pref}db_{$modul} set sort={$sorv} where id={$sork}");
  35. }
  36. if (isset($_GET['sort'])) $_SESSION['sort'] = $_GET['sort'];
  37. if (isset($_SESSION['sort'])) $sort = $_SESSION['sort'];
  38. if (strpos($mod_ver,substr($sort,0,2))===false)
  39. $sort = 'sort,id';
  40. mysql_query("delete from {$pref}db_{$modul} where status=-1");
  41. mysql_query("delete from {$pref}db_{$modul}_cat where status=-1");
  42. $lim=30;
  43. if (isset($_GET['p'])) $p=$_GET['p']; else {$p=1;$_GET['p']=1;}
  44. $o=$p*$lim-$lim;
  45. if (!empty($_GET['cat'])){
  46. $query=mysql_query("select * from {$pref}db_{$modul} where {$searchinmodules} pid='{$_GET['cat']}' order by {$sort} limit $o,$lim");
  47. $total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where {$searchinmodules} pid='{$_GET['cat']}' "));
  48. $m_title="Новости";
  49. $body="
  50. <table class='tablesorter' cellspacing='0'>
  51. <thead>
  52. <tr>
  53. <th>ID</th>
  54. <th>Заголовок</th>
  55. <th>Дата</th>
  56. <th>Сортировка</th>
  57. <th>Статус</th>
  58. <td>Удалить<input type='checkbox' class='selectdelete'></td>
  59. </tr>
  60. </thead>
  61. <tbody>
  62. ";
  63. while ($res=mysql_fetch_array($query))
  64. {
  65. $body.="
  66. <tr>
  67. <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['id']}</td>
  68. <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['title']}</td>
  69. <td><a href='edit.materials.php?id_material={$res['id']}'>".sql2date1($res['date'])."</td>
  70. <td><span class='hid'>{$res['sort']}</span><input size='3' type='text' name='sor2[{$res['id']}]' value='{$res['sort']}' /></td>
  71. <td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}-{$res['id']}-{$res['status']}' >
  72. <img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
  73. <td><input type='checkbox' onclick='check();' name='list[]' class='listdelete' value='{$res['id']}' /></td>
  74. </tr>";
  75. }
  76. }
  77. else{
  78. $query=mysql_query("select * from {$pref}db_{$modul}_cat where {$searchinmodules} 1=1 order by {$sort} limit $o,$lim");
  79. $total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul}_cat where {$searchinmodules} 1=1"));
  80. $m_title="Ленты";
  81. $body="
  82. <table class='tablesorter' cellspacing='0'>
  83. <thead>
  84. <tr>
  85. <th>ID</th>
  86. <th>Название</th>
  87. <th>Сортировка</th>
  88. <th>Статус</th>
  89. <th>Редактировать</th>
  90. <td>Удалить<input type='checkbox' class='selectdelete'></td>
  91. </tr>
  92. </thead>
  93. <tbody>
  94. ";
  95. while ($res=mysql_fetch_array($query))
  96. {
  97. $body.="
  98. <tr>
  99. <td><a href='index.php?cat={$res['id']}'>{$res['id']}</td>
  100. <td><a href='index.php?cat={$res['id']}'>{$res['title']}</td>
  101. <td><span class='hid'>{$res['sort']}</span><input size='3' type='text' name='sor[{$res['id']}]' value='{$res['sort']}' /></td>
  102. <td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}_cat-{$res['id']}-{$res['status']}' >
  103. <img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
  104. <td><a href='edit.categorie.php?id_material={$res['id']}'><img src='{$pt}{$tpl_admin}/images/icn_edit.png' /></td>
  105. <td><input type='checkbox' onclick='check();' name='list2[]' class='listdelete' value='{$res['id']}' /></td>
  106. </tr>";
  107. }
  108. }
  109. $body.="
  110. </tbody>
  111. </table>
  112. ";
  113. ?>
  114. <script>
  115. $(document).ready(function(){
  116. $('.modulForm').submit(function(){
  117. if (!confirm("Уверены, что хотите внести изменения?"))
  118. return false;
  119. })
  120. });
  121. </script>
  122. <form method='POST' acction='' class='modulForm' >
  123. <? if (isset($_POST['sf'])){?><h4 class="alert_success">Сохранено</h4><?}?>
  124. <article class="module width_full">
  125. <header><h3 class="tabs_involved"><?=$m_title?></h3>
  126. <!-- <ul class="tabs">
  127. <li><a href="#tab1">Список</a></li>
  128. </ul> -->
  129. </header>
  130. <div class="tab_container">
  131. <div id="tab1" class="tab_content">
  132. <?=$body?>
  133. </div></div>
  134. <footer>
  135. <div class="submit_link fl">
  136. <? paging_m($total,$lim,$p);?>
  137. </div>
  138. <div class="submit_link">
  139. <input type='submit' value='Сохранить' name='sf' />
  140. </div>
  141. </footer>
  142. </article>
  143. </form>
  144. <? include "../../inc/footer_m.php"; ?>