'; echo ''; echo ''.mb_convert_encoding(gettext("Add entry to the calendar"), 'UTF-8', 'auto').''; echo ''; echo ''; echo ''; echo ''; echo '
'; } function html_footer() { if ($_SESSION['nikki_authenticated']) { echo '
'; echo '
'; echo ''; echo '
'; } echo '
'; copyright(); echo '
'; echo ''; echo ''; } function copyright() { echo mb_convert_encoding(gettext("Copyright (C) 2003 Javi Lavandeira (http://www.ag0ny.com)."), 'UTF-8', 'auto'); } function action_display_login_dialog() { if (isset($_SESSION['nikki_authenticated'])) { if ($_SESSION['nikki_authenticated']) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); } } else { $_SESSION['nikki_authenticated'] = 0; } html_header(mb_convert_encoding(gettext("Login screen"), 'UTF-8', 'auto')); echo '

'.mb_convert_encoding(gettext("program_name"), 'UTF-8', 'auto').'

'; echo '
'; echo ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; html_footer(); } function action_logout() { $_SESSION['nikki_authenticated'] = 0; header('Location: '.$GLOBALS['PHP_SELF']); } function action_authenticate() { $login = trim($_POST['login']); $password = trim($_POST['password']); if ($login == $GLOBALS['post_login'] && $password == $GLOBALS['post_password']) { $_SESSION['nikki_authenticated'] = 1; header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); } else { $_SESSION['nikki_authenticated'] = 0; header('Location: '.$GLOBALS['PHP_SELF'].'?action=login'); } } function action_check_post() { check_auth(); $day = isset($_POST['day'])?abs($_POST['day']):date('j'); $month = isset($_POST['month'])?abs($_POST['month']):date('n'); $year = isset($_POST['year'])?abs($_POST['year']):date('Y'); $message = isset($_POST['message'])?addslashes(mb_convert_encoding(trim($_POST['message']), 'UTF-8', 'auto')):''; if (!$message) { html_header(mb_convert_encoding(gettext("Error!"), 'UTF-8', 'auto')); echo mb_convert_encoding(gettext("Error: you didn't write anything!"), 'UTF-8', 'auto'); html_footer(); } else { $timestamp = substr('0000'.$year,-4,4).substr('00'.$month,-2,2).substr('00'.$day,-2,2); if ($result = mysql_query('INSERT INTO calendar SET timestamp=\''.$timestamp.'\', text=\''.$message.'\'')) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); } else { html_header(mb_convert_encoding(gettext("Error!"), 'UTF-8', 'auto')); echo mb_convert_encoding(gettext("Error: can't post to the database:"), 'UTF-8', 'auto'); echo '
'; echo mysql_error(); html_footer(); } } } function action_check_modify() { check_auth(); $id = isset($_POST['id'])?abs($_POST['id']):0; if (!$id) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); exit(); } $day = isset($_POST['day'])?abs($_POST['day']):date('j'); $month = isset($_POST['month'])?abs($_POST['month']):date('n'); $year = isset($_POST['year'])?abs($_POST['year']):date('Y'); $message = isset($_POST['message'])?addslashes(mb_convert_encoding(trim($_POST['message']), 'UTF-8', 'auto')):''; if (!$message) { html_header(mb_convert_encoding(gettext("Error!"), 'UTF-8', 'auto')); echo mb_convert_encoding(gettext("Error: you didn't write anything!"), 'UTF-8', 'auto'); html_footer(); } else { $timestamp = substr('0000'.$year,-4,4).substr('00'.$month,-2,2).substr('00'.$day,-2,2); if ($result = mysql_query("UPDATE calendar SET timestamp='$timestamp.', text='$message' WHERE id='$id'")) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); } else { html_header(mb_convert_encoding(gettext("Error!"), 'UTF-8', 'auto')); echo mb_convert_encoding(gettext("Error: can't post to the database:"), 'UTF-8', 'auto'); echo '
'; echo mysql_error(); html_footer(); } } } function action_delete() { check_auth(); $id = isset($_GET['id'])?abs($_GET['id']):0; if ($id) { mysql_query("DELETE FROM calendar WHERE id='$id'"); } header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); } function action_modify() { check_auth(); $id = isset($_GET['id'])?abs($_GET['id']):0; if (!$id) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); exit(); } html_header(mb_convert_encoding(gettext("Modify message"), 'UTF-8', 'auto')); echo '

'.mb_convert_encoding(gettext("Modify message"), 'UTF-8', 'auto').'

'; $result = mysql_query("SELECT * FROM calendar WHERE id='$id'"); if (!mysql_num_rows($result)) { header('Location: '.$GLOBALS['PHP_SELF'].'?action=list'); exit(); } $message = mysql_fetch_object($result); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'.mb_convert_encoding(gettext("Date"), 'UTF-8', 'auto').''.mb_convert_encoding(gettext("Message"), 'UTF-8', 'auto').'
'; echo '
'; echo ''; echo mb_convert_encoding(gettext("Year"), 'UTF-8', 'auto'); echo '
'; $cur_year = abs(substr($message->timestamp,0,4)); echo ''; echo '
'; echo '
'; echo mb_convert_encoding(gettext("Month"), 'UTF-8', 'auto'); $cur_month = abs(substr($message->timestamp,4,2)); echo '
'; echo ''; echo '
'; echo '
'; echo mb_convert_encoding(gettext("Day"), 'UTF-8', 'auto'); echo '
'; $cur_day = abs(substr($message->timestamp,6,2)); echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo ''; html_footer(); } function action_list() { check_auth(); html_header(mb_convert_encoding(gettext("Message list"), 'UTF-8', 'auto')); echo '

'.mb_convert_encoding(gettext("Message list"), 'UTF-8', 'auto').'

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'.mb_convert_encoding(gettext("Date"), 'UTF-8', 'auto').''.mb_convert_encoding(gettext("Message"), 'UTF-8', 'auto').'
'; echo '
'; echo mb_convert_encoding(gettext("Year"), 'UTF-8', 'auto'); echo '
'; $cur_year = date('Y'); echo ''; echo '
'; echo '
'; echo mb_convert_encoding(gettext("Month"), 'UTF-8', 'auto'); $cur_month = date('n'); echo '
'; echo ''; echo '
'; echo '
'; echo mb_convert_encoding(gettext("Day"), 'UTF-8', 'auto'); echo '
'; $cur_day = date('j'); echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; $result = mysql_query('SELECT * FROM calendar ORDER BY timestamp DESC,id'); if (mysql_num_rows($result)) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; while ($entry = mysql_fetch_object($result)) { echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
'.mb_convert_encoding(gettext("Date"), 'UTF-8', 'auto').''.mb_convert_encoding(gettext("Message"), 'UTF-8', 'auto').''.mb_convert_encoding(gettext("Options"), 'UTF-8', 'auto').'
'.$entry->timestamp.''; echo mb_convert_encoding(stripslashes($entry->text), 'UTF-8', 'auto'); echo ''; echo ''.mb_convert_encoding(gettext("Delete"), 'UTF-8', 'auto').'
'; echo ''.mb_convert_encoding(gettext("Modify"), 'UTF-8', 'auto').''; echo '
'; } html_footer(); } $action = isset($_GET['action'])?$_GET['action']:''; switch ($action) { case 'list': action_list(); break; case 'checkpost': action_check_post(); break; case 'checkmodify': action_check_modify(); break; case 'delete': action_delete(); break; case 'modify': action_modify(); break; case 'authenticate': action_authenticate(); break; case 'logout': action_logout(); break; case 'setlang': $_SESSION['lang'] = isset($_POST['lang'])?$_POST['lang']:$GLOBALS['default_language']; header('Location: '.$GLOBALS['PHP_SELF'].'?action=login'); break; case 'login': default: action_display_login_dialog(); break; } ?>