%PDF- %PDF-
Direktori : /home/nailstv/public_html/es.nails.tv/admin/ |
Current File : /home/nailstv/public_html/es.nails.tv/admin/galeria_kepek.php |
<?php require_once '../config/config.php'; if(isset($_GET['id'])) { $_SESSION['galeria_id'] = $_GET['id']; $_SESSION['tipus'] = $_GET['tipus']; } $page = new Page('admin', true); if(isset($_GET['id'])) { $_SESSION['vissza_href'] = Registry::get('referer'); } $page->assign('content', kepek()); $page->display('admin/page.tpl.html'); //////////////////////////////////////////////////////////////////////////////// function kepek() { $db = Registry::get('db'); $c = new Content(); if(isset($_GET['delete'])) deleteKep($_GET['delete']); if($_POST && $_POST['func'] == 'sorrend') $db->updateSorrend($_POST["sorrend"], 'kep'); if($_POST && $_POST['func'] == 'torol') deleteMultiple($_POST["torol"]); if(isset($_GET['edit'])) $c->assign('edit', $db->select($_GET['edit'], 'kep')); kepList($_SESSION['galeria_id'], $c); $c->assign('tipus', $_SESSION['tipus']); return $c->fetch('admin/galeria_kepek.tpl.html'); } function deleteKep($id) { $db = Registry::get('db'); $sql = "SELECT file FROM kep WHERE id = " . $id; $row = $db->GetRow($sql); @unlink(Registry::get('dirroot') . '/images/galeria/' . $row['file']); $sql = "DELETE FROM kep WHERE id = " . $id; $db->query($sql); $sql = "SELECT id FROM kep WHERE def = 't' AND galeria_id = " . $_SESSION['galeria_id'] . " AND tipus = '" . $_SESSION['tipus'] . "'"; $row = $db->GetRow($sql); if(empty($row)) { if($_SESSION['tipus'] == 'stepbystep'){ $sql = "SELECT max(id) AS id FROM kep WHERE galeria_id = " . $_SESSION['galeria_id'] . " AND tipus = '" . $_SESSION['tipus'] . "'"; $row = $db->GetRow($sql); if(!empty($row['id'])) { $sql = "UPDATE kep SET def = 't' WHERE id = " . $row['id']; $db->query($sql); } } else { $sql = "SELECT id FROM kep WHERE galeria_id = " . $_SESSION['galeria_id'] . " AND tipus = '" . $_SESSION['tipus'] . "' ORDER BY sorrend LIMIT 0,1"; $row = $db->GetRow($sql); if(!empty($row)) { $sql = "UPDATE kep SET def = 't' WHERE id = " . $row['id']; $db->query($sql); } } } } function deleteMultiple($arr) { foreach($arr as $key => $val) { deleteKep($key); } } function kepList($id, $c) { $db = Registry::get('db'); $sql = "SELECT k.id, k.file, k.def, k.sorrend FROM kep k WHERE k.galeria_id = " . $id . " AND k.tipus = '" . $_SESSION['tipus'] . "' ORDER BY k.sorrend"; $r = $db->Execute($sql); $kepek = $r->GetArray(); $c->assign('kepek', $kepek); } ?>