Location: PHPKode > scripts > Lightning Notes > ln_distro/ln_distro/admin/enter.php
<?php
//phpinfo();
//error_reporting(E_ALL);
$ttstring = gmdate("l, Y-m-d H:i");
$tstring = gmdate("YmdHi");
/*
$idx = $HTTP_SERVER_VARS['QUERY_STRING'];
if (isset($idx) && (!empty($idx))) {
    $idy = strip_tags($idx);
    $idz = escapeshellcmd($idy);
    $cat = $idz;
}
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
    include ("config.php");
    echo '<title>entries.app ['.$CFGglobal['title'].']</title>'."\n";
?>
    <link rel="stylesheet" media="screen" href="adm.css" type="text/css" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <!-- iso-8859-1 -->
    <style type="text/css">
body { 
    margin: 0 auto;
    padding: 0;
    width: 90%;
    max-width: 1000px;
}
h1 { margin-bottom: 0.5em; }
#forms, #samples { font-size: 100%; padding: 0 0.5%; top; 0; }
#forms {
    position: relative;
    float: left;
    /*color: #000;
    background: url("../i/stripes_gray.gif");*/
    padding: 0.35em 0; margin: 0;
    width: 70%;
    voice-family: "\"}\""; voice-family: inherit;
    width: 69%;
    }
html>body #forms { width: 69%; }
#samples {
    position: relative;
    float: left;
    padding: 0.5em 0.5%;
    color: #000;
    background: url("../i/stripes_gray.gif");
    width: 30%;
    voice-family: "\"}\""; voice-family: inherit;
    width: 29%;
    }
html>body #samples { width: 29%; }
#samples .entry { color: #000; background: url("../i/stripes_gray.gif"); padding: 0.25em 0; margin: 0.5em 0; }
#forms h1, #samples h2 { font-size: 130%; }
#samples .entry h2 { font-size: 115%; }
form input, form textarea, form select, form option { color: #000; background: url("../i/stripes_gray.gif"); }
input.bn:hover, input.bn:focus { background: url("../i/stripes_gray.gif"); }
.date { color: #c00; background-color: transparent; font-family: Georgia, serif; }
p.date { margin: 0 0 0.35em 0; }
span.date { margin: 0 0 0.66em 0; }
p.date a { text-decoration: none; }
p.date a span { font-weight: bold; text-decoration: none; font-size: 140%; }
p.date a:link, p.date a:visited { background-color: transparent; }
p.date a:link, p.date a:visited { color: #666; }
p.date a:hover, p.date a:active { background-color: transparent; }
p.date a:hover { color: #f00; }
p.date a:active { color: #c00; }

/* calendar
-------------------------------------------- */
#cal { width: 99%; font-size: 90%; margin: 0; padding: 0; }
#cal td a { display: block; }
#cal a:link, #cal a:visited { color: #300; background-color: transparent; }
#cal a:hover, #cal a:active { text-decoration: none; }
#cal a:hover { color: #fff; background-color: #600; }
#cal a:active { color: #fff; background-color: #f00; }
#cal th { color: #333; background-color: transparent; font-weight: normal; text-align: center; font-size: 90%; border-bottom: 1px solid #aaa; }
#cal span { display: block; font-weight: bold; color: #fff; background-color: #900; }
#cal caption a { text-decoration: none; }
#cal span a:link,#cal span a:visited { color: #fff; text-decoration: none; }
#cal tr { margin: 0; padding: 0; }
#cal td { width: 1.95em; text-align: center; margin: 0; padding: 0; border-left: 1px solid #aaa; }
#cal caption { font-weight: bold; margin: 0; padding: 1px; }
#cal caption div { position: relative; text-align: center; }
#cal caption span { font-size: 120%; display: inline; color: #300; background-color: transparent; }
#cal caption span.this { font-size: 100%; }
#cal caption span a { padding: 0 10px; text-decoration: none; }
#cal caption span a:link, #cal caption span a:visited { color: #300; background-color: transparent; }
#cal caption span a:hover { color: #fff; background-color: #600; }
table#cal caption div span.skip { display: none; }
#cal th { font-weight: normal; text-align: center; font-size: 90%; border-bottom: 1px solid; }

/* search
-------------------------------------------- */
#nav form { margin: 0; padding: 0; }
#nav form p { text-align: right; margin: 0; }
span.query { font-weight: bold; color: #000; background-color: #ff6; }
input, textarea, form { margin: 0; }
#nav input.bn { font-size: 90%; }
input.bn {
    font-size: 100%;
    text-transform: uppercase;
    padding: 2px 3px 2px 3px;
    color: #000;
    background: url("../i/stripes_gray.gif");
    margin: 0.1em 0 0 0;
    border-color: #999 black black #999;
    border-width: 2px;
    border-style: solid;
    }
input, input.bt, textarea { color: #000; background: url("../i/stripes_gray.gif");
    font-size: 100%;
    line-height: 100%;
    padding: 2px 1px 1px 1px;
    margin: 0.1em 0 0 0;
    border-color: black #999 #999 black;
    border-width: 2px;
    border-style: solid;
    }
fieldset { display: inline; padding: 2px; margin: 0.25em 0.25em 0 0; }
label { margin: 0 5px; display: block; cursor: pointer; /*color: #000; background-color: #ff6;*/ }
label.i { margin: 0 5px; display: inline; }
input.rad { padding: 2px; margin: 0; }
select { margin: 0; }
form p { padding: 0; margin: 0; }
    </style>
</head>
<body>

<div id="forms">
<?php
require_once ("admfnc.php");
require_once ("notesfnc.php");
require_once ("textfnc_lite.php");
$tree = GetXMLTree("entries.xml");
echo '<h1><a href="/'.$CFGglobal['root'].'/">'.$CFGglobal['title'].'</a></h1>'."\n";

/* 
Form-Input
------------------------------------------------------------ */

$author = $CFGauthor['name'];
$date = $ttstring;
$status = 'publish'."\n";
echo '<form method="get" action="'.$PHP_SELF.'">'."\n";

echo '<fieldset><legend>Input-Lang</legend>'."\n";
echo '<input type="radio" class="rad" name="lang" value="en" checked="checked" /><label for="en" class="i">en</label>'."\n";
echo '<input type="radio" class="rad" name="lang" value="de" /><label for="de" class="i">de</label>'."\n";
echo '</fieldset>'."\n";

echo '<fieldset><legend>Status</legend>'."\n";
echo '<input type="radio" class="rad" name="status" value="publish" checked="checked" /><label for="publish" class="i">publish</label>'."\n";
echo '<input type="radio" class="rad" name="status" value="draft" /><label for="draft" class="i">draft</label>'."\n";
echo '</fieldset>'."\n";

echo '<fieldset><legend>Entry-Type</legend>'."\n";
echo '<input type="radio" class="rad" name="entrytype" value="post" checked="checked" /><label for="post" class="i">Post</label>'."\n";
echo '<input type="radio" class="rad" name="entrytype" value="feature" /><label for="feature" class="i">Feature</label>'."\n";
echo '</fieldset>'."\n";

echo '<fieldset><legend>Titling</legend>'."\n";
echo '<select name="words">'."\n";
echo '<option value="">2</option>'."\n";
echo '<option value="3">3</option>'."\n";
echo '<option value="4">4</option>'."\n";
echo '<option value="5">5</option>'."\n";
echo '<option value="6">6</option>'."\n";
echo '</select><label for="words" class="i"># of Words for Title-URL</label>'."\n";

$title = isset($_REQUEST['title']) ?
    rawurldecode(stripslashes($_REQUEST['title'])) : ''."\n";
echo '<label for="title">TITLE</label>'."\n";
echo '<textarea name="title" id="title" rows="1" cols="77" tabindex="1" accesskey="1">'.$title.'</textarea>'."\n";
echo '</fieldset>'."\n";

$body = isset($_REQUEST['body']) ?
    rawurldecode(stripslashes($_REQUEST['body'])) : ''."\n";
echo '<fieldset><legend>Content</legend>'."\n";
echo '<p><label for="body">BODY</label>'."\n";
echo '<textarea name="body" id="body" rows="5" cols="77" accesskey="2">'.$body.'</textarea></p>'."\n";

$extbody = isset($_REQUEST['extbody']) ?
    rawurldecode(stripslashes($_REQUEST['extbody'])) : ''."\n";
echo '<p><label for="extbody">EXTBODY</label>'."\n";
echo '<textarea name="extbody" id="extbody" rows="3" cols="77" accesskey="3">'.$extbody.'</textarea></p>'."\n";

$excerpt = isset($_REQUEST['excerpt']) ?
    rawurldecode(stripslashes($_REQUEST['excerpt'])) : ''."\n";
echo '<p><label for="excerpt">EXCERPT</label>'."\n";
echo '<textarea name="excerpt" rows="1" cols="77" accesskey="4">'.$excerpt.'</textarea></p>'."\n";
echo '</fieldset>'."\n";

echo '<fieldset style="width:55%;"><legend>Archiving</legend>'."\n";
echo '<p><input type="text" name="category" value="'.$category.'" size="30" />'."\n";
echo '<label for="category" class="i" accesskey="5">CATEGORY<br /></label></p>'."\n";

echo '<p><input type="text" name="subcategories" value="'.$subcategories.'" size="30"  accesskey="6" />'."\n";
echo '<label for="subcategories" class="i">SUBCATEGORIES<br /></label></p>'."\n";

echo '<p><input type="text" name="keywords" value="'.$keywords.'" size="30" accesskey="7" />'."\n";
echo '<label for="keywords" class="i">KEYWORDS</label></p>'."\n";
echo '</fieldset>'."\n";

echo '<p><input class="bn" type="submit" name="submit" value="Preview Entry" />'."\n";
echo '<input class="bn" type="reset" name="reset" value="Reset" /></p>'."\n";
echo '</form>'."\n";

/* 
Encode, Decode, Beautify
------------------------------------------------------------ */

$title = textile($text = $title,$lite='');
$title = str_replace('&quot;','"',$title);
$title = str_replace('<p>','',$title);
$title = str_replace('</p>','',$title);

$body = textile($text = $body,$lite='');
$body = str_replace('&quot;','"',$body);

if (!empty($extbody)) {
    $extbody = textile($text = $extbody,$lite='');
    $extbody = str_replace('&quot;','"',$extbody);
}

$excerpt = textile($text = $excerpt,$lite='');
$excerpt = str_replace('&quot;','"',$excerpt);

/* 
Produce the missing values for the XML-entry
------------------------------------------------------------ */

    $patterns[0] = "/&ouml;/";
    $patterns[1] = "/&auml;/";
    $patterns[2] = "/&uuml;/";
    $patterns[3] = "/&szlig;/";
    $patterns[4] = "/ /";
    $patterns[5] = "/-/";
    
    $replacements[0] = "oe";
    $replacements[1] = "ae";
    $replacements[2] = "ue";
    $replacements[3] = "ss";
    $replacements[4] = "_";
    $replacements[5] = "_";

$categoryref = preg_replace($patterns, $replacements, strtolower(htmlentities(($category))));

if (empty ($words)) {
    $words = '3'."\n";
}
$filename = title2url($title, $words);

if ($entrytype == 'post') {
    $urlfrag = 'archive.php'."\n";
} elseif ($entrytype == 'feature') {
    $urlfrag = 'feature.php'."\n";
}

$titleurl = '/'.$CFGglobal['root'].'/'.$urlfrag.'?entry='.date("Ymd",(strtotime($date))).$filename;

$subcat = split(",", trim($subcategories));

$id = date("Ymd",(strtotime($date))).$filename;

/* 
Output to screen + update XML
------------------------------------------------------------ */
echo '<form action="file_update.php" method="post">'."\n";

echo '<fieldset><legend>Preview XML</legend>'."\n";
echo '<p><label for="data">Data</label>'."\n";
echo '<textarea name="data" rows="5" cols="77">'."\n";
$out = '<entry>'."\r";
$out .= '<id>'.$id.'</id>'."\r";
$out .= '<lang>'.$lang.'</lang>'."\r";
$out .= '<author>'.htmlentities($author).'</author>'."\r";
$out .= '<date>'.$date.'</date>'."\r";
$out .= '<title><![CDATA['.$title.']]></title>'."\r";
$out .= '<url>'.$titleurl.'</url>'."\r";
$out .= '<category ref="'.$categoryref.'"><![CDATA['.trim(htmlentities($category)).']]></category>'."\r";
if (!empty($subcategories)) {
    $list = '<subcategories>'."\r";
    foreach ($subcat as $value) {
        $list .= '<subcat ref="'.preg_replace($patterns, $replacements, strtolower(htmlentities(($value)))).'"><![CDATA['.htmlentities($value).']]></subcat>'."\r";
    }
    $list .= '</subcategories>'."\r";
}
$out .= $list;
$out .= '<status>'.$status.'</status>'."\r";
$out .= '<body><![CDATA['.$body.']]></body>'."\r";
if (!empty($extbody)) {
    $out .= '<extbody><![CDATA['.$extbody.']]></extbody>'."\r";
}
$out .= '<excerpt><![CDATA['.$excerpt.']]></excerpt>'."\r";
$out .= '<keywords><![CDATA['.$keywords.']]></keywords>'."\r";
$out .= '<timestamp>'.$tstring.'</timestamp>'."\r";
$out .= '</entry>'."\n\n\n";
$out = str_replace('\\', '', $out);
echo htmlentities($out);
echo '</textarea></p>'."\n";
echo '</fieldset>'."\n";
echo '<p><input type="submit" name="submit" class="bn" value="Add Entry" /></p>'."\n";
echo '</form>'."\n";

/* 
Generate RDF
------------------------------------------------------------ */

echo '<form action="rdf/generate_rdf.php" method="post">'."\n";
echo '<p><input type="submit" class="bn" name="submit" value="Generate RSS" /></p>'."\n";
echo '</form>'."\n";
?>
</div>

<div id="samples">
<?php
echo '<h2>Sample Output</h2>'."\n";

$test = '<collection>'."\n";
$test .= $out;
$test .= '</collection>'."\n";
$tree = GetXMLTreeData($test);
echo entrybyid ($tree, $id, $dir = '1', $showdate = '1', $showcat = '1', &$category, $query);

echo '<h2>Navigation</h2>'."\n";
echo '<ul>'."\n";
echo '<li class="home"><a href="/'.$CFGglobal['root'].'/">'.$CFGglobal['title'].'</a>'."\n";
echo '<ul>'."\n";
echo '<li><a href="/'.$CFGglobal['root'].'/admin/enter.php">New Entry &#187;</a></li>'."\n";
echo '<li class="cat"><a href="/'.$CFGglobal['root'].'/category.php">Categories</a>'."\n";
echo '<ul>'."\n";

$tree = GetXMLTree("entries.xml");
echo categories ($tree, $showsubcat = '1');

echo '</ul></li>'."\n";
echo '<li class="arc"><a href="/'.$CFGglobal['root'].'/archive.php">Archive ['.entrycount ($tree).' Entries]</a></li>'."\n";
echo '</ul></li>'."\n";
echo '</ul>'."\n";

if (!isset($nosearch)) {
    echo '<h3>Search</h3>'."\n";
    echo '<form method="get" action="/'.$CFGglobal['root'].'/search.php">'."\n";
    echo '<p><input type="text" class="bt" name="query" value="'.$query.'"'."\n";
    echo '" size="20" maxlength="128" /></p><p><input type="submit" class="bn" name="submit" value="Search" /></p>'."\n";
    echo '</form>'."\n";
}

if (isset($month)) {
    $calyear = substr(($month), 0, 4);
    $calmonth = substr(($month), 4, 2);
} else {
    $calyear = date('Y');
    $calmonth = date('m');
}
echo '<h3>Calendar</h3>'."\n";
echo calendar ($tree, $calyear, $calmonth);
?>

</div>

</body>
</html>
Return current item: Lightning Notes