PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/gallery/index.php

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