/modules/gallery/index.php
PHP | 175 lines | 164 code | 11 blank | 0 comment | 20 complexity | e34ed06eef34f9bcc0913aade4e20ff7 MD5 | raw file
- <? include "../../inc/header_m.php";?>
- <?
- $searchinmodul=$_POST['searchinmodul'];
- if (!empty($searchinmodul)){
- $searchinmodul=explode(' ', $searchinmodul);
- foreach ($searchinmodul as $key => $value) {
- $searchinmodules.="or UPPER(title) LIKE '%".strtoupper($value)."%' ";
- $searchinmodules.="or UPPER(text) LIKE '%".strtoupper($value)."%' ";
- }
- $searchinmodules=' ('.substr($searchinmodules, 2).') and ';
- }
- $del = $_POST['list'];
- $sor = $_POST['sor'];
- $del2 = $_POST['list2'];
- $sor2 = $_POST['sor2'];
- if (isset($del))
- foreach ($del as &$delv)
- {
- $sql1="select * from {$pref}db_{$modul} where pid={$delv} ";
- $query1=mysql_query($sql1);
- if ($query1 && mysql_num_rows($query1)>0)
- while ($res1=mysql_fetch_array($query1)) {
- $pic=$res1['img'];
- unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/{$pic}");
- unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/mcith/mcith_{$pic}");
- }
- mysql_query("delete from {$pref}db_{$modul}_cat where id={$delv}");
- mysql_query("delete from {$pref}db_{$modul} where pid={$delv}");
- }
- if (isset($sor))
- foreach ($sor as $sork=>$sorv)
- {
- mysql_query("update {$pref}db_{$modul}_cat set sort={$sorv} where id={$sork}");
- }
- if (isset($del2))
- foreach ($del2 as &$delv2)
- {
- $pic=getdb('db_gallery',$delv2,'img');
- unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/{$pic}");
- unlink("{$_SERVER['DOCUMENT_ROOT']}/files/images/{$id_modules}/mcith/mcith_{$pic}");
- mysql_query("delete from {$pref}db_{$modul} where id={$delv2}");
- }
- if (isset($sor2))
- foreach ($sor2 as $sork2=>$sorv2)
- {
- mysql_query("update {$pref}db_{$modul} set sort={$sorv2} where id={$sork2}");
- }
- if (isset($_GET['sort'])) $_SESSION['sort'] = $_GET['sort'];
- if (isset($_SESSION['sort'])) $sort = $_SESSION['sort'];
- if (strpos($mod_ver,substr($sort,0,2))===false)
- $sort = 'sort,id';
- mysql_query("delete from {$pref}db_{$modul}_cat where status=-1");
- mysql_query("delete from {$pref}db_{$modul} where status=-1");
- $lim=30;
- if (isset($_GET['p'])) $p=$_GET['p']; else {$p=1;$_GET['p']=1;}
- $o=$p*$lim-$lim;
- if (isset($_GET['id_material'])||isset($_POST['id_material']))
- {
- if (isset($_GET['id_material'])) $id=$_GET['id_material'];
- if (isset($_POST['id_material'])) $id=$_POST['id_material'];
- $query=mysql_query("select * from {$pref}db_{$modul} where {$searchinmodules} pid='{$id}' order by {$sort} limit $o,$lim");
- $total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul} where {$searchinmodules} pid='{$id}'"));
- $m_title="Фото";
- $body="
- <table class='tablesorter' cellspacing='0'>
- <thead>
- <tr>
- <th>ID</th>
- <th>Заголовок</th>
- <th>Изображение</th>
- <th>Сортировка</th>
- <th>Статус</th>
- <td>Удалить<input type='checkbox' class='selectdelete'></td>
- </tr>
- </thead>
- <tbody>
- ";
- while ($res=mysql_fetch_array($query, MYSQL_ASSOC))
- {
- $body.="
- <tr>
- <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['id']}</td>
- <td><a href='edit.materials.php?id_material={$res['id']}'>{$res['title']}</td>
- <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>
- <td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor2[{$res['id']}]' value='{$res['sort']}' /></td>
- <td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}-{$res['id']}-{$res['status']}' >
- <img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
- <td><input type='checkbox' onclick='check();' name='list2[]' class='listdelete' value='{$res['id']}' /></td>
- </tr>";
- }
- $body.="
- </tbody>
- </table>
- ";
- }
- else
- {
- $query=mysql_query("select * from {$pref}db_{$modul}_cat where {$searchinmodules} 1=1 order by {$sort} limit $o,$lim");
- $total=mysql_num_rows(mysql_query("select * from {$pref}db_{$modul}_cat where {$searchinmodules} 1=1 "));
- $m_title="Галереи";
- $body="
- <table class='tablesorter' cellspacing='0'>
- <thead>
- <tr>
- <th>ID</th>
- <th>Заголовок</th>
- <th>Сортировка</th>
- <th>Статус</th>
- <th>Редактировать</th>
- <td>Удалить<input type='checkbox' class='selectdelete'></td>
- </tr>
- </thead>
- <tbody>
- ";
- while ($res=mysql_fetch_array($query, MYSQL_ASSOC))
- {
- $body.="
- <tr>
- <td><a href='index.php?id_material={$res['id']}'>{$res['id']}</td>
- <td><a href='index.php?id_material={$res['id']}'>{$res['title']}</td>
- <td><span class='hid'>{$res['sort']}</span><input type='text' size='3' name='sor[{$res['id']}]' value='{$res['sort']}' /></td>
- <td><span class='hid'>{$res['status']}</span><a class='statmat' id='_{$modul}_cat-{$res['id']}-{$res['status']}' >
- <img src='{$pt}/{$cmspatch}/templates/img/{$res['status']}.gif' /></td>
- <td><a href='edit.categorie.php?id_material={$res['id']}'><img src='{$pt}{$tpl_admin}/images/icn_edit.png' /></td>
- <td><input type='checkbox' onclick='check();' name='list[]' class='listdelete' value='{$res['id']}' /></td>
- </tr>";
- }
- $body.="
- </tbody>
- </table>
- ";
- }
- ?>
- <script>
- $(document).ready(function(){
- $('.modulForm').submit(function(){
- if (!confirm("Уверены, что хотите внести изменения?"))
- return false;
- })
- });
- </script>
- <form method='POST' acction='' class='modulForm' >
- <? if (isset($_POST['sf'])){?><h4 class="alert_success">Сохранено</h4><?}?>
- <article class="module width_full">
- <header><h3 class="tabs_involved"><?=$m_title?></h3>
- <!-- <ul class="tabs">
- <li><a href="#tab1">Список</a></li>
- </ul> -->
- </header>
- <div class="tab_container">
- <div id="tab1" class="tab_content">
- <?=$body?>
- </div></div>
- <footer>
- <div class="submit_link fl">
- <? paging_m($total,$lim,$p);?>
- </div>
- <div class="submit_link">
- <input type='submit' value='Сохранить' name='sf' />
- </div>
- </footer>
- </article>
- </form>
- <? include "../../inc/footer_m.php"; ?>