<?php require_once "admin-mode.php"; require_once "mysqlconnect.php"; require_once "document.php"; if (!is_admin_mode()) { header("Location: /"); exit; } $document = new Document(); $document->SetTitle("Admin: Lisamise tulemus"); $document->AddMainMenu(); $document->AddSubMenu(); $hash = sha1($_POST['pass']); $query = "INSERT INTO `archive` \n( `id` , \n`name` , \n`address` , \n`date` , \n`next` , \n`previous` , \n`groupid` , \n`order` , \n`type` , \n`category` , \n`comments` ) \nVALUES (\n'', \n'{$_POST['name']}', \n'{$_POST['address']}', \nCURDATE( ) , \n'0', \n'0', \n'0', \n'0', \n'{$_POST['type']}', \n'{$_POST['category']}', \n'{$_POST['comments']}'\n);"; mysql_query($query); $chapter = <<<EOHTML <h1>Admin: Lisamine õnnestus</h1> <dl> <dt>Nimi</dt><dd>{$_POST['nimi']}</dd> <dt>Aadress</dt><dd>{$_POST['address']}</dd> <dt>Tüüp</dt><dd>{$_POST['type']}</dd> <dt>Kategooria</dt>{$_POST['category']}<dd></dd> <dt>Kommentaarid</dt><dd>{$_POST['comments']}</dd> </dl> EOHTML; $document->AddBasicChapter($chapter, "Admin:_Lisamise_tulemus"); $document->Out();
$name = $comment['name']; } return <<<EOHTML <div id="kommentaar_{$comment['id']}"> {$comment['text']} <p class="autor"> Teema: {$comment['article']}<br /> {$date} {$name} ({$comment['email']}).<br /> <b><a href="?delete={$comment['id']}">Kustuta</a></b> </p> </div> EOHTML; } if (isset($_GET["delete"])) { $delete_id = intval($_GET["delete"]); mysql_query("DELETE FROM comments WHERE id={$delete_id}"); } // Otsime andmebaasist viimased kommentaarid $result = mysql_query("\n SELECT\n comments.id as id,\n comments.name as name,\n datetime,\n homepage,\n email,\n text,\n archive.name as article\n FROM comments LEFT JOIN archive ON (comments.articleid=archive.id)\n ORDER BY datetime DESC"); $comments = ""; while ($row = mysql_fetch_array($result)) { $comments .= commentToHtml($row); } $chapter = <<<EOHTML <h1>Admin: Viimased kommentaarid</h1> {$comments} EOHTML; $document->AddBasicChapter($chapter, "kommentaarid"); $document->Out();
$document = new Document(); $document->SetTitle("Arhiiv"); $document->AddMainMenu("Arhiiv"); $document->AddSubMenu(); $chapter = "<h1>Arhiiv</h1>\n"; $query = "SELECT * FROM archive WHERE category<>'Luuletused' AND category<>'Laulud' AND `order`=0 ORDER BY category, date DESC, name"; $result = mysql_query($query); while ($doc = mysql_fetch_array($result)) { if ($doc['category'] != $old_category) { if (strlen($old_category) != 0) { $chapter .= "</ul>\n"; } $chapter .= "<h2>{$doc['category']}</h2>\n"; $chapter .= "<ul>\n"; $old_category = $doc['category']; } $address = '/' . str_replace('-', '/', $doc['date']) . '/' . UrlVars::real2url($doc['name']); if ($doc['type'] == 'normal') { $class = ''; } elseif ($doc['type'] == 'standalone') { $class = ' class="standalone"'; } elseif ($doc['type'] == 'text/css') { $class = ' class="css"'; } else { $class = ' class="file"'; } $chapter .= "<li{$class}><a href=\"{$address}\">{$doc['name']}</a></li>\n"; } $chapter .= "</ul>\n"; $document->AddBasicChapter($chapter, "Arhiiv"); $document->Out();
$document = new Document(); $document->SetTitle("Looming"); $document->AddMainMenu("Looming"); $document->AddSubMenu(); $chapter = "<h1>Looming</h1>\n"; $query = "SELECT * FROM archive WHERE category='Luuletused' OR category='Laulud' AND `order`=0 ORDER BY category, date DESC, name"; $result = mysql_query($query); while ($doc = mysql_fetch_array($result)) { if ($doc['category'] != $old_category) { if (strlen($old_category) != 0) { $chapter .= "</ul>\n"; } $chapter .= "<h2>{$doc['category']}</h2>\n"; $chapter .= "<ul>\n"; $old_category = $doc['category']; } $address = '/' . str_replace('-', '/', $doc['date']) . '/' . UrlVars::real2url($doc['name']); if ($doc['type'] == 'normal') { $class = ''; } elseif ($doc['type'] == 'standalone') { $class = ' class="standalone"'; } elseif ($doc['type'] == 'text/css') { $class = ' class="css"'; } else { $class = ' class="file"'; } $chapter .= "<li{$class}><a href=\"{$address}\">{$doc['name']}</a></li>\n"; } $chapter .= "</ul>\n"; $document->AddBasicChapter($chapter, "Looming"); $document->Out();
</fieldset> <fieldset> <legend>Kategooria</legend> <select name="category"> <option value="Üldine">Üldine</option> <option value="HTML ja CSS">HTML ja CSS</option> <option value="Kool">Kool</option> <option value="Trinoloogia">Trinoloogia</option> <option value="Laulud">Laulud</option> <option value="Luuletused">Luuletused</option> </select> </fieldset> <fieldset> <legend>Kommentaaride lubamine</legend> <ul> <li><label><input type="radio" name="comments" value="Y" checked="checked" />Jah</label></li> <li><label><input type="radio" name="comments" value="N" />Ei</label></li> </ul> </fieldset> <input type="submit" value="Salvesta" /> </form> EOHTML; $document->AddBasicChapter($chapter, "Admin:_Uue_artikli_lisamine"); $document->Out();
<div class="pilt"> <img src="/archive/mina.jpg" alt="Minu pilt" /> <p>Mina, oma eduka sportlaskarjääri tipphetkel?</p> </div> <p>No põhimõtteliselt, kui keegi väga soovib, siis võib ta ju mulle kirjutada ja joonistada. Aadress on igatahes nüüd välja jagatud ja saab näha, kas sünnib sellest halba/head. Ega must mingit head kirjasõpra vast ei tule, nii et parem ärge selles suunas kohe proovima hakakegi.</p> <p>Aga kui on midagi seoses sellesama Trinoloogialehega või triinudega, siis see on kõik päris kindlasti alati teretulnud.</p> <p>Seda pilti siin tuleb ühtlasi võtta kui hoiatust, et te ei kipuks kuidagi pimesi minuga kohtuma, ja et te päris selgesti näeksite, et mina ei kuulu triinude hulka.</p> <p>Olge tublid!</p> <ul> <li>Haapsalu</li> <li>Männi 9-3</li> <li>Rene Saarsoo</li> </ul> EOHTML; $document->AddBasicChapter($chapter, "Kontakt"); $document->Out();
$document->AddSubMenu(); $login_page = <<<EOHTML <h1>Admin: Login</h1> <form action="login.php" method="post"> <fieldset> <legend>Autentimine</legend> <p><label for="af_pass">Kasutaja</label> <input type="text" name="user" id="af_user" /></p> <p><label for="af_pass">Parool</label> <input type="password" name="pass" id="af_pass" /></p> </fieldset> <input type="submit" value="Sisene" /> </form> EOHTML; $logout_link = <<<EOHTML <h1>Admin: Login</h1> <p>Oled sisse logitud. <a href="logout.php">Logi välja.</a></p> <ul> <li><a href="add-article-form.php">Lisa artikkel.</a></li> <li><a href="latest-comments.php">Vaata viimaseid kommentaare.</a></li> </ul> EOHTML; $document->AddBasicChapter(is_admin_mode() ? $logout_link : $login_page, "Admin:_Login"); $document->Out();