<?php

/**
	/ricerca.php
	(C) Giovanni Capuano 2011
*/
require_once 'core/class.Ocarina.php';
$ocarina = new Ocarina();
$cercaNews = isset($_GET['news']) ? $ocarina->purge($_GET['news']) : '';
$cercaPagine = isset($_GET['pagine']) ? $ocarina->purge($_GET['pagine']) : '';
$cercaCommenti = isset($_GET['commenti']) ? $ocarina->purge($_GET['commenti']) : '';
$cerca = true;
$ocarina->skin = $ocarina->isLogged() ? $ocarina->username[0]->skin : $ocarina->config[0]->skin;
$ocarina->addValue('titolo', $ocarina->getLanguage('title', 9) . $ocarina->getLanguage('title', 2) . $ocarina->config[0]->nomesito);
$ocarina->addValue('description', $ocarina->getLanguage('description', 9));
if ($cercaNews !== '') {
    !($search = $ocarina->searchNews($cercaNews)) ? $ocarina->addValue('error_news', $ocarina->getLanguage('search', 0)) : $ocarina->addValue('news', $search);
    $cerca = false;
} elseif ($cercaPagine !== '') {
    !($search = $ocarina->searchPage($cercaPagine, 'wildcard')) ? $ocarina->addValue('error_page', $ocarina->getLanguage('search', 1)) : $ocarina->addValue('pagina', $search);
    $cerca = false;
} elseif ($cercaCommenti !== '') {
    !($search = $ocarina->searchComment($cercaCommenti)) ? $ocarina->addValue('error_comment', $ocarina->getLanguage('search', 2)) : $ocarina->addValue('commento', $search);
    $cerca = false;
}
$ocarina->addValue('cerca', $cerca);
$ocarina->isLogged() && $ocarina->username[0]->grado == 7 ? $ocarina->renderize('bannato.tpl') : $ocarina->renderize('ricerca.tpl');
$selected = isset($_POST['selected']) && $_POST['selected'] !== '' ? $ocarina->purgeSlashes($ocarina->purgeByXSS($_POST['selected'])) : '';
$submit = isset($_POST['submit']) ? true : false;
$ocarina->skin = 'admin';
$ocarina->addValue('titolo', $ocarina->getLanguage('title', 22) . $ocarina->getLanguage('title', 2) . $ocarina->getLanguage('title', 10) . $ocarina->getLanguage('title', 2) . $ocarina->config[0]->nomesito);
if ($ocarina->isLogged() && $ocarina->username[0]->grado < 4) {
    if (!$submit && $selected == '') {
        $result = '<form action="" method="post">' . $ocarina->getLanguage('editnews', 0) . '<select name="selected">';
        if ($ocarina->username[0]->grado == 3) {
            $ocarinaByUser = $ocarina->searchNewsByUser($ocarina->username[0]->nickname);
            if ($ocarinaByUser !== false) {
                foreach ($ocarina->searchNewsByUser($ocarina->username[0]->nickname) as $v) {
                    $result .= '<option value="' . $v->minititolo . '">' . $v->titolo . '</option>';
                }
            }
        } elseif ($ocarina->username[0]->grado < 3) {
            $allNews = $ocarina->searchNews('');
            // È come una wildcard
            if ($allNews !== false) {
                foreach ($allNews as $v) {
                    $result .= '<option value="' . $v->minititolo . '">' . $v->titolo . '</option>';
                }
            }
        }
        $result .= '</select><input type="submit" name="sel_submit" value="' . $ocarina->getLanguage('title', 22) . '" /></form>';
        $ocarina->addValue('result', $result);
    } elseif (!$submit && $selected !== '') {
        $ocarina->addValue('categorie', $ocarina->getCategory('news'));
        if ($this_news = $ocarina->getNews($selected)) {
            $ocarina->addValue('titolo_default', $this_news[0]->titolo);
            $ocarina->addValue('categoria', $this_news[0]->categoria);
            $ocarina->addValue('testo', $this_news[0]->contenuto);
<?php

/**
	/admin/cancellanews.php
	(C) Giovanni Capuano 2011
*/
require_once '../core/class.Ocarina.php';
$ocarina = new Ocarina();
$minititolo_news = isset($_POST['content']) && $_POST['content'] !== '' ? $ocarina->purge($_POST['content']) : '';
$submit = isset($_POST['submit']) ? true : false;
$ocarina->skin = 'admin';
$ocarina->addValue('titolo', $ocarina->getLanguage('title', 12) . $ocarina->getLanguage('title', 2) . $ocarina->getLanguage('title', 10) . $ocarina->getLanguage('title', 2) . $ocarina->config[0]->nomesito);
if ($ocarina->isLogged() && $ocarina->username[0]->grado < 3) {
    if (!$submit) {
        $ocarina->addValue('content', $ocarina->searchNews(''));
    } else {
        if ($minititolo_news !== '') {
            if ($ocarina->deleteNews($minititolo_news)) {
                $ocarina->addValue('result', $ocarina->getLanguage('deletenews', 0));
                if ($ocarina->config[0]->log == 1) {
                    $ocarina->log($ocarina->username[0]->nickname, 'News \'' . $minititolo_news . '\' deleted.');
                }
            } else {
                $ocarina->addValue('result', $ocarina->getLanguage('deletenews', 1));
                if ($ocarina->config[0]->log == 1) {
                    $ocarina->log($ocarina->username[0]->nickname, 'News \'' . $minititolo_news . '\' deletion failed.');
                }
            }
        } else {
            $ocarina->addValue('result', $ocarina->getLanguage('deletenews', 2));
            if ($ocarina->config[0]->log == 1) {
<?php

/**
	/archivio.php
	(C) Giovanni Capuano 2011
*/
require_once 'core/class.Ocarina.php';
$ocarina = new Ocarina();
$ocarina->skin = $ocarina->isLogged() ? $ocarina->username[0]->skin : $ocarina->config[0]->skin;
$ocarina->addValue('titolo', 'Archivio &raquo; ' . $ocarina->config[0]->nomesito);
$ocarina->addValue('description', $ocarina->getLanguage('description', 0));
!($getNews = $ocarina->searchNews('')) ? $ocarina->addValue('error_news', $ocarina->getLanguage('error', 0)) : $ocarina->addValue('news', $getNews);
!($getPage = $ocarina->searchPage('', 'wildcard')) ? $ocarina->addValue('error_page', $ocarina->getLanguage('error', 0)) : $ocarina->addValue('pagine', $getPage);
$ocarina->isLogged() && $ocarina->username[0]->grado == 7 ? $ocarina->renderize('bannato.tpl') : $ocarina->renderize('archivio.tpl');