<?php if (iCMS != 1) { exit; } require './lib/categories.php'; require LANG_DIR . 'content.php'; #Template $view->title = $lang['batch']; $view->dir = './plugins/upload/'; $view->cache = './cache/upload/'; $view->add('upload', array('cat' => Slaves(1, 0))); #Supported archives $zip = extension_loaded('zip'); $rar = extension_loaded('rar'); #Supported miniatures $gd = extension_loaded('gd'); #Supported EXIF $exif = extension_loaded('exif'); #Archives #Stage 1: select archive if (isset($_POST['next'])) { $cat = is_numeric($_POST['cat']) ? $_POST['cat'] : 0; $title = empty($_POST['title']) ? $lang['noname'] : clean($_POST['title']); //todo:translate $autor = clean($_POST['author']); $dsc = $_POST['dsc']; #Choice: Folder on server if (empty($_POST['up'])) { $dir = new DirectoryIterator($_POST['folder']); foreach ($dir as $x) {
} #Params -> string $param = $join . ($param ? ' WHERE ' . join(' AND ', $param) : ''); #Count items $total = dbCount($table . $param); #Zero if ($total == 0 && !$find) { header('Location: ' . URL . url('edit/' . $act, $id ? 'catid=' . $id : null)); $view->info($lang['noc']); return 1; } #Prepare URL $url = url('list/' . $act . '/' . $id); #Get items $res = $db->query('SELECT ID,name,access FROM ' . PRE . $table . $param . ' ORDER BY ID DESC LIMIT ' . $st . ',30'); $res->setFetchMode(3); $items = array(); #Prepare item foreach ($res as $i) { switch ($i[2]) { case '1': $a = $lang['yes']; break; default: $a = $lang['no']; } $items[] = array('num' => ++$st, 'title' => $i[1], 'id' => $i[0], 'on' => $a, 'url' => $href . $i[0], 'editURL' => url('edit/' . $act . '/' . $i[0])); } #Template $view->add('list', array('item' => $items, 'act' => $act, 'url' => $url, 'intro' => $lang['i' . $act], 'type' => $type, 'cats' => Slaves($act), 'pages' => pages($page, $total, 30, $url . '&find=' . $find, 1), 'addURL' => url('edit/' . $act, $id ? 'catid=' . $id : null), 'catsURL' => admit('C') ? url('cats/' . $act, null, 'admin') : false));
} #Get text $res = $db->query('SELECT page,text,opt FROM ' . PRE . 'artstxt WHERE ID=' . $id . ' ORDER BY page'); $full = $res->fetchAll(3); $res = null; if (!$full) { $full = array(array(1, '', 1)); } } else { $art = array('pages' => 1, 'name' => '', 'access' => 1, 'priority' => 2, 'dsc' => '', 'author' => $user['login'], 'cat' => $lastCat); $full = array(array(1, '', 1)); } } #Checkbox foreach ($full as $key => &$val) { $full[$key] = array('page' => $val[0], 'txt' => $val[1], 'br' => $val[2] & 1, 'emo' => $val[2] & 2, 'code' => $val[2] & 4); if ($full[$key]['code']) { $full[$key]['txt'] = preg_replace_callback(array('#<(pre)([^>]*)>(.*?)</pre>#si', '#<(code)([^>]*)>(.*?)</code>#si'), create_function('$x', 'return "<$x[1]$x[2]>".htmlspecialchars_decode($x[3],0)."</$x[1]>";'), $full[$key]['txt']); } } #Editor JS if (isset($cfg['wysiwyg']) && is_dir('plugins/editor')) { $view->script('plugins/editor/loader.js'); } else { $view->script(LANG_DIR . 'edit.js'); $view->script('cache/emots.js'); $view->script('lib/editor.js'); } #Template $view->add('edit_art', array('art' => &$art, 'id' => $id, 'full' => &$full, 'cats' => Slaves(1, $art['cat']), 'author' => authors()));
$id = $db->lastInsertId(); } #Apply changes $e->apply(); #Redirect to link if (isset($_GET['ref']) && isset($cfg['linkFull'])) { header('Location: ' . URL . url('link/' . $id)); } #Link URL $url = isset($cfg['linkFull']) ? url('link/' . $id) : $link['adr']; #Info + links $view->info($lang['saved'], array($url => sprintf($lang['see'], $link['name']), url($link['cat']) => $lang['goCat'], url('edit/4') => $lang['add4'], url('list/4') => $lang['links'], url('list/4/' . $link['cat']) => $lang['doCat'])); unset($e, $link); return 1; } catch (Exception $e) { $view->info($e->getMessage()); } } else { if ($id) { $link = $db->query('SELECT * FROM ' . PRE . 'links WHERE ID=' . $id)->fetch(2); //ASSOC if (!$link || !admit($link['cat'], 'CAT')) { return; } } else { $link = array('cat' => $lastCat, 'name' => '', 'dsc' => '', 'access' => 1, 'nw' => 0, 'priority' => 2, 'adr' => 'http://'); } } #Template $view->add('edit_link', array('link' => &$link, 'id' => $id, 'cats' => Slaves(4, $link['cat'])));
} catch (Exception $e) { $view->info($e->getMessage()); } } else { if ($id) { $news = $db->query('SELECT n.*,f.text FROM ' . PRE . 'news n LEFT JOIN ' . PRE . 'newstxt f ON n.ID=f.ID WHERE n.ID=' . $id)->fetch(2); $full =& $news['text']; #Verify privileges if (!$news || !admit($news['cat'], 'CAT', $news['author'])) { return; } } else { $news = array('cat' => $lastCat, 'name' => '', 'txt' => '', 'access' => 1, 'img' => '', 'opt' => 3); $full = ''; } } #Checkbox fields $news['br'] = $news['opt'] & 1; $news['emo'] = $news['opt'] & 2; $news['fn'] = $news['opt'] & 4; #JavaScript editor if (isset($cfg['wysiwyg']) && is_dir('plugins/editor')) { $view->script('plugins/editor/loader.js'); } else { $view->script(LANG_DIR . 'edit.js'); $view->script('cache/emots.js'); $view->script('lib/editor.js'); } #Template $view->add('edit_news', array('news' => &$news, 'full' => &$full, 'id' => $id, 'cats' => Slaves(5, $news['cat']), 'fileman' => admit('FM')));
#Redirect to file if (isset($_GET['ref'])) { header('Location: ' . URL . url('file/' . $id)); } #Info + links $view->info($lang['saved'], array(url('file/' . $id) => sprintf($lang['see'], $file['name']), url($file['cat']) => $lang['goCat'], url('edit/2') => $lang['add2'], url('list/2') => $lang['files'], url('list/2/' . $file['cat']) => $lang['doCat'])); unset($e, $file); return 1; } catch (Exception $e) { $view->info($e->getMessage()); } } else { if ($id) { $file = $db->query('SELECT * FROM ' . PRE . 'files WHERE ID=' . $id)->fetch(2); if (!$file || !admit($file['cat'], 'CAT', $file['author'])) { return; } } else { $file = array('cat' => $lastCat, 'name' => '', 'dsc' => '', 'priority' => 2, 'file' => 'files/', 'size' => '', 'author' => $user['login'], 'fulld' => '', 'access' => 1); } } #Editor JS if (isset($cfg['wysiwyg']) && is_dir('plugins/editor')) { $view->script('plugins/editor/loader.js'); } else { $view->script(LANG_DIR . 'edit.js'); $view->script('lib/editor.js'); } #Template $view->add('edit_file', array('file' => &$file, 'id' => $id, 'cats' => Slaves(2, $file['cat']), 'fileman' => admit('FM') ? true : false));
$db->commit(); UpdateCatPath($id); #Redirect if (isset($_GET['ref'])) { header('Location: ' . URL . url($id)); } #Info + links $view->info($lang['saved'] . ' ID: ' . $id, array(url($id) => $lang['goCat'], url('editCat', '', 'admin') => $lang['addCat'], url('editCat/' . $id, '', 'admin') => $lang['editCat'], url('list/' . $id) => $lang['mantxt'], url('edit/' . $cat['type'], 'catid=' . $id) => $lang['addItem'])); return 1; } catch (Exception $e) { $view->info($e->getMessage()); //Errors } } elseif ($id) { if (!($cat = $db->query('SELECT * FROM ' . PRE . 'cats WHERE ID=' . $id)->fetch(2))) { //ASSOC return; } } else { $cat = array('name' => '', 'dsc' => '', 'type' => isset($_GET['type']) ? (int) $_GET['type'] : 5, 'sc' => 0, 'text' => '', 'sort' => 2, 'opt' => 15, 'access' => 1); } #Editor JS if (isset($cfg['wysiwyg']) && is_dir('plugins/editor')) { $view->script('plugins/editor/loader.js'); } else { $view->script(LANG_DIR . 'edit.js'); $view->script('lib/editor.js'); } #Prepare template $view->add('editCat', array('cat' => &$cat, 'o1' => $cat['opt'] & 1, 'o2' => $cat['opt'] & 2, 'o3' => $cat['opt'] & 4, 'o4' => $cat['opt'] & 8, 'o5' => $cat['opt'] & 16, 'cats' => Slaves(0, $cat['sc'], $id), 'langs' => listBox('lang', 1, $cat['access'])));
#Redirect to link if (isset($_GET['ref'])) { header('Location: ' . URL . url('img/' . $id)); } #Info + links $view->info($lang['saved'], array(url('img/' . $id) => sprintf($lang['see'], $img['name']), url($img['cat']) => $lang['goCat'], url('edit/3') => $lang['add3'], url('list/3') => $lang['imgs'], url('list/3/' . $img['cat']) => $lang['doCat'])); unset($e, $img); return 1; } catch (Exception $e) { $view->info($e->getMessage()); } } else { if ($id) { $img = $db->query('SELECT * FROM ' . PRE . 'imgs WHERE ID=' . $id)->fetch(2); if (!$img || !admit($img['cat'], 'CAT', $img['author'])) { return; } } else { $img = array('cat' => $lastCat, 'name' => '', 'dsc' => '', 'priority' => 2, 'file' => 'img/', 'th' => 'img/', 'size' => '', 'author' => $user['login'], 'access' => 1, 'type' => 1); } } #Edytor JS if (isset($cfg['wysiwyg']) && is_dir('plugins/editor')) { $view->script('plugins/editor/loader.js'); } else { $view->script(LANG_DIR . 'edit.js'); $view->script('lib/editor.js'); } #Template $view->add('edit_img', array('img' => &$img, 'id' => $id, 'cats' => Slaves(3, $img['cat']), 'size' => $img['size'] ? explode('|', $img['size']) : array('', ''), 'fileman' => admit('FM') ? true : false));
if ($_POST) { $rss = array('name' => clean($_POST['name']), 'dsc' => clean($_POST['dsc']), 'url' => clean($_POST['url']), 'lang' => ctype_alnum($_POST['lang']) ? $_POST['lang'] : LANG, 'auto' => isset($_POST['auto']), 'cat' => (int) $_POST['cat'], 'num' => (int) $_POST['num']); try { if ($id) { $q = $db->prepare('UPDATE ' . PRE . 'rss SET auto=:auto, name=:name, dsc=:dsc, url=:url, lang=:lang, cat=:cat, num=:num WHERE ID=' . $id); } else { $q = $db->prepare('INSERT INTO ' . PRE . 'rss (auto,name,dsc,url,lang,cat,num) VALUES (:auto,:name,:dsc,:url,:lang,:cat,:num)'); } $q->execute($rss); if (!$id) { $id = $db->lastInsertId(); } #Rebuild RSS RSS($id); header('Location: ' . URL . url('rss/update', '', 'admin')); return 1; } catch (Exception $e) { $view->info($e); } } elseif ($id) { if (!($rss = $db->query('SELECT * FROM ' . PRE . 'rss WHERE ID=' . $id)->fetch(2))) { return; } } else { $rss = array('name' => '', 'dsc' => '', 'auto' => 1, 'num' => 20, 'cat' => 0, 'lang' => LANG, 'url' => URL); } #Prepare template $view->add('editRss', array('rss' => $rss, 'cats' => Slaves(5, $rss['cat']), 'langs' => listBox('lang', 1, $rss['lang'])));
if ($db->exec('DELETE FROM ' . PRE . 'mitems WHERE type=5 AND url IN(' . $x . ')')) { include './lib/mcache.php'; RenderMenu(); } //Finish and redirect $db->commit(); header('Location: ' . URL . url('cats', '', 'admin')); } else { $cat = array(); foreach ($res as $x) { if (in_array($x['ID'], $cfg['start'])) { $warn = sprintf($lang['warnCat'], strtoupper($x['access'])); } else { $warn = false; } $cat[] = array('id' => $x['ID'], 'title' => $x['name'], 'url' => url($x['ID']), 'cats' => Slaves($x['type'], 0, $x['ID']), 'warn' => $warn, 'edit' => $warn ? url('editCat/' . $x['ID'], '', 'admin') : false); } $view->add('editCats', array('cat' => $cat)); } $view->title = $lang['delCat']; } elseif (isset($_POST['count'])) { $db->beginTransaction(); CountItems(); $db->commit(); header('Location: ' . URL . url('cats', '', 'admin')); exit; } else { header('Location: ' . URL . url('cats', '', 'admin')); $view->info($lang['nocats']); } } catch (PDOException $e) {