@ -108,7 +108,7 @@ post('/login', function() {
}
}
});
});
get ( " /:static/:sub/edit " , function ( $static , $sub ) {
get ( " /:static/:sub/edit " , function ( $static , $sub ) {
if ( login ()) {
if ( login ()) {
@ -120,8 +120,8 @@ get("/:static/:sub/edit", function($static, $sub) {
}
}
$post = $post [ 0 ];
$post = $post [ 0 ];
$page = get_static_sub_post ( $static , $sub );
$page = get_static_sub_post ( $static , $sub );
if ( ! $page ) {
if ( ! $page ) {
not_found ();
not_found ();
@ -141,28 +141,31 @@ get("/:static/:sub/edit", function($static, $sub) {
header ( " location: $login " );
header ( " location: $login " );
}
}
});
});
post ( " /:static/:sub/edit " , function ( $static , $sub ) {
post ( " /:static/:sub/edit " , function ( $static , $sub ) {
$proper = is_csrf_proper ( from ( $_REQUEST , 'csrf_token' ));
$proper = is_csrf_proper ( from ( $_REQUEST , 'csrf_token' ));
if ( ! login ()) {
if ( ! login ())
{
$login = site_url () . 'login' ;
$login = site_url () . 'login' ;
header ( " location: $login " );
header ( " location: $login " );
}
}
$title = from ( $_REQUEST , 'title' );
$title = from ( $_REQUEST , 'title' );
$url = from ( $_REQUEST , 'url' );
$url = from ( $_REQUEST , 'url' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$destination = from ( $_GET , 'destination' );
$destination = from ( $_GET , 'destination' );
if ( $destination === null ) {
$description = from ( $_REQUEST , 'description' );
if ( $destination === null )
{
$destination = $static . " / " . $sub ;
$destination = $static . " / " . $sub ;
}
}
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
edit_page ( $title , $url , $content , $oldfile , $destination );
edit_page ( $title , $url , $content , $oldfile , $destination , $description );
} else {
} else {
$url = $title ;
$url = $title ;
edit_page ( $title , $url , $content , $oldfile , $destination );
edit_page ( $title , $url , $content , $oldfile , $destination , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -190,7 +193,7 @@ post("/:static/:sub/edit", function($static, $sub) {
}
}
});
});
get ( " /:static/:sub/delete " , function ( $static , $sub ) {
get ( " /:static/:sub/delete " , function ( $static , $sub ) {
if ( login ()) {
if ( login ()) {
@ -203,7 +206,7 @@ get("/:static/:sub/delete", function($static, $sub) {
$post = $post [ 0 ];
$post = $post [ 0 ];
$page = get_static_sub_post ( $static , $sub );
$page = get_static_sub_post ( $static , $sub );
if ( ! $page ) {
if ( ! $page ) {
not_found ();
not_found ();
@ -236,7 +239,8 @@ post("/:static/:sub/delete", function() {
// The blog post page
// The blog post page
get ( '/:year/:month/:name' , function ( $year , $month , $name ) {
get ( '/:year/:month/:name' , function ( $year , $month , $name ) {
if ( config ( " views.counter " ) != " true " ) {
if ( config ( " views.counter " ) != " true " )
{
if ( ! login ()) {
if ( ! login ()) {
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
}
}
@ -249,8 +253,9 @@ get('/:year/:month/:name', function($year, $month, $name) {
if ( ! $current ) {
if ( ! $current ) {
not_found ();
not_found ();
}
}
if ( config ( " views.counter " ) == " true " ) {
if ( config ( " views.counter " ) == " true " )
{
add_view ( $current -> file );
add_view ( $current -> file );
if ( ! login ()) {
if ( ! login ()) {
@ -279,7 +284,7 @@ get('/:year/:month/:name', function($year, $month, $name) {
}
}
render ( 'post' , array (
render ( 'post' , array (
'head_contents' => head_contents ( $current -> title . ' - ' . blog_title (), $current -> description , $current -> url ),
'head_contents' => head_contents ( $current -> title . ' - ' . blog_title (), $description = get_description ( $ current -> body ) , $current -> url ),
'p' => $current ,
'p' => $current ,
'authorinfo' => authorinfo ( $bio -> title , $bio -> body ),
'authorinfo' => authorinfo ( $bio -> title , $bio -> body ),
'bodyclass' => 'inpost' ,
'bodyclass' => 'inpost' ,
@ -339,12 +344,13 @@ post('/:year/:month/:name/edit', function() {
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$destination = from ( $_GET , 'destination' );
$destination = from ( $_GET , 'destination' );
$description = from ( $_REQUEST , 'description' );
if ( $proper && ! empty ( $title ) && ! empty ( $tag ) && ! empty ( $content )) {
if ( $proper && ! empty ( $title ) && ! empty ( $tag ) && ! empty ( $content )) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
edit_post ( $title , $tag , $url , $content , $oldfile , $destination );
edit_post ( $title , $tag , $url , $content , $oldfile , $destination , $description );
} else {
} else {
$url = $title ;
$url = $title ;
edit_post ( $title , $tag , $url , $content , $oldfile , $destination );
edit_post ( $title , $tag , $url , $content , $oldfile , $destination , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -448,11 +454,9 @@ get('/author/:profile', function($profile) {
$bio = default_profile ( $profile );
$bio = default_profile ( $profile );
}
}
$description = 'Profile page and all posts by ' . $bio -> title . ' on ' . blog_title () . '.' ;
if ( empty ( $posts ) || $page < 1 ) {
if ( empty ( $posts ) || $page < 1 ) {
render ( 'profile' , array (
render ( 'profile' , array (
'head_contents' => head_contents ( 'Profile for: ' . $bio -> title . ' - ' . blog_title (), $description , site_url () . 'author/' . $profile ),
'head_contents' => head_contents ( 'Profile for: ' . $bio -> title . ' - ' . blog_title (), 'Profile page and all posts by ' . $bio -> title . ' on ' . blog_title () . '.' , site_url () . 'author/' . $profile ),
'page' => $page ,
'page' => $page ,
'posts' => null ,
'posts' => null ,
'bio' => $bio -> body ,
'bio' => $bio -> body ,
@ -465,7 +469,7 @@ get('/author/:profile', function($profile) {
}
}
render ( 'profile' , array (
render ( 'profile' , array (
'head_contents' => head_contents ( 'Profile for: ' . $bio -> title . ' - ' . blog_title (), $description , site_url () . 'author/' . $profile ),
'head_contents' => head_contents ( 'Profile for: ' . $bio -> title . ' - ' . blog_title (), 'Profile page and all posts by ' . $bio -> title . ' on ' . blog_title () . '.' , site_url () . 'author/' . $profile ),
'page' => $page ,
'page' => $page ,
'posts' => $posts ,
'posts' => $posts ,
'bio' => $bio -> body ,
'bio' => $bio -> body ,
@ -501,8 +505,9 @@ post('/edit/profile', function() {
$user = $_SESSION [ config ( " site.url " )][ 'user' ];
$user = $_SESSION [ config ( " site.url " )][ 'user' ];
$title = from ( $_REQUEST , 'title' );
$title = from ( $_REQUEST , 'title' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$description = from ( $_REQUEST , 'description' );
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
edit_profile ( $title , $content , $user );
edit_profile ( $title , $content , $user , $description );
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
if ( empty ( $title )) {
if ( empty ( $title )) {
@ -702,13 +707,14 @@ get('/:static', function($static) {
}
}
die ;
die ;
} else {
} else {
if ( config ( " views.counter " ) != " true " ) {
if ( config ( " views.counter " ) != " true " )
{
if ( ! login ()) {
if ( ! login ()) {
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
}
}
}
}
$post = get_static_post ( $static );
$post = get_static_post ( $static );
if ( ! $post ) {
if ( ! $post ) {
@ -717,7 +723,8 @@ get('/:static', function($static) {
$post = $post [ 0 ];
$post = $post [ 0 ];
if ( config ( " views.counter " ) == " true " ) {
if ( config ( " views.counter " ) == " true " )
{
add_view ( $post -> file );
add_view ( $post -> file );
if ( ! login ()) {
if ( ! login ()) {
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
@ -725,7 +732,7 @@ get('/:static', function($static) {
}
}
render ( 'static' , array (
render ( 'static' , array (
'head_contents' => head_contents ( $post -> title . ' - ' . blog_title (), $post -> description , $post -> url ),
'head_contents' => head_contents ( $post -> title . ' - ' . blog_title (), $description = get_description ( $post -> body ) , $post -> url ),
'bodyclass' => 'inpage' ,
'bodyclass' => 'inpage' ,
'breadcrumb' => '<a href="' . site_url () . '">' . config ( 'breadcrumb.home' ) . '</a> » ' . $post -> title ,
'breadcrumb' => '<a href="' . site_url () . '">' . config ( 'breadcrumb.home' ) . '</a> » ' . $post -> title ,
'p' => $post ,
'p' => $post ,
@ -765,22 +772,24 @@ get('/:static/edit', function($static) {
post ( '/:static/edit' , function () {
post ( '/:static/edit' , function () {
$proper = is_csrf_proper ( from ( $_REQUEST , 'csrf_token' ));
$proper = is_csrf_proper ( from ( $_REQUEST , 'csrf_token' ));
if ( ! login ()) {
if ( ! login ())
{
$login = site_url () . 'login' ;
$login = site_url () . 'login' ;
header ( " location: $login " );
header ( " location: $login " );
}
}
$title = from ( $_REQUEST , 'title' );
$title = from ( $_REQUEST , 'title' );
$url = from ( $_REQUEST , 'url' );
$url = from ( $_REQUEST , 'url' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$oldfile = from ( $_REQUEST , 'oldfile' );
$destination = from ( $_GET , 'destination' );
$destination = from ( $_GET , 'destination' );
$description = from ( $_REQUEST , 'description' );
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
if ( $proper && ! empty ( $title ) && ! empty ( $content )) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
edit_page ( $title , $url , $content , $oldfile , $destination );
edit_page ( $title , $url , $content , $oldfile , $destination , $description );
} else {
} else {
$url = $title ;
$url = $title ;
edit_page ( $title , $url , $content , $oldfile , $destination );
edit_page ( $title , $url , $content , $oldfile , $destination , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -873,13 +882,14 @@ post('/add/post', function() {
$tag = from ( $_REQUEST , 'tag' );
$tag = from ( $_REQUEST , 'tag' );
$url = from ( $_REQUEST , 'url' );
$url = from ( $_REQUEST , 'url' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$description = from ( $_REQUEST , 'description' );
$user = $_SESSION [ config ( " site.url " )][ 'user' ];
$user = $_SESSION [ config ( " site.url " )][ 'user' ];
if ( $proper && ! empty ( $title ) && ! empty ( $tag ) && ! empty ( $content )) {
if ( $proper && ! empty ( $title ) && ! empty ( $tag ) && ! empty ( $content )) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
add_post ( $title , $tag , $url , $content , $user );
add_post ( $title , $tag , $url , $content , $user , $description );
} else {
} else {
$url = $title ;
$url = $title ;
add_post ( $title , $tag , $url , $content , $user );
add_post ( $title , $tag , $url , $content , $user , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -935,12 +945,13 @@ post('/add/page', function() {
$title = from ( $_REQUEST , 'title' );
$title = from ( $_REQUEST , 'title' );
$url = from ( $_REQUEST , 'url' );
$url = from ( $_REQUEST , 'url' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$description = from ( $_REQUEST , 'description' );
if ( $proper && ! empty ( $title ) && ! empty ( $content ) && login ()) {
if ( $proper && ! empty ( $title ) && ! empty ( $content ) && login ()) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
add_page ( $title , $url , $content );
add_page ( $title , $url , $content , $description );
} else {
} else {
$url = $title ;
$url = $title ;
add_page ( $title , $url , $content );
add_page ( $title , $url , $content , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -1233,13 +1244,14 @@ get('/:static/add', function($static) {
config ( 'views.root' , 'system/admin/views' );
config ( 'views.root' , 'system/admin/views' );
$post = get_static_post ( $static );
$post = get_static_post ( $static );
if ( ! $post ) {
if ( ! $post )
{
not_found ();
not_found ();
}
}
$post = $post [ 0 ];
$post = $post [ 0 ];
render ( 'add-page' , array (
render ( 'add-page' , array (
'head_contents' => head_contents ( 'Add page - ' . blog_title (), blog_description (), site_url ()),
'head_contents' => head_contents ( 'Add page - ' . blog_title (), blog_description (), site_url ()),
'bodyclass' => 'addpage' ,
'bodyclass' => 'addpage' ,
@ -1257,12 +1269,13 @@ post('/:static/add', function($static) {
$title = from ( $_REQUEST , 'title' );
$title = from ( $_REQUEST , 'title' );
$url = from ( $_REQUEST , 'url' );
$url = from ( $_REQUEST , 'url' );
$content = from ( $_REQUEST , 'content' );
$content = from ( $_REQUEST , 'content' );
$description = from ( $_REQUEST , 'description' );
if ( $proper && ! empty ( $title ) && ! empty ( $content ) && login ()) {
if ( $proper && ! empty ( $title ) && ! empty ( $content ) && login ()) {
if ( ! empty ( $url )) {
if ( ! empty ( $url )) {
add_sub_page ( $title , $url , $content , $static );
add_sub_page ( $title , $url , $content , $static , $description );
} else {
} else {
$url = $title ;
$url = $title ;
add_sub_page ( $title , $url , $content , $static );
add_sub_page ( $title , $url , $content , $static , $description );
}
}
} else {
} else {
$message [ 'error' ] = '' ;
$message [ 'error' ] = '' ;
@ -1288,28 +1301,29 @@ post('/:static/add', function($static) {
}
}
});
});
get ( '/:static/:sub' , function ( $static , $sub ) {
get ( '/:static/:sub' , function ( $static , $sub ) {
$father_post = get_static_post ( $static );
$father_post = get_static_post ( $static );
if ( ! $father_post ) {
if ( ! $father_post ) {
not_found ();
not_found ();
}
}
$post = get_static_sub_post ( $static , $sub );
$post = get_static_sub_post ( $static , $sub );
if ( ! $post ) {
if ( ! $post ) {
not_found ();
not_found ();
}
}
$post = $post [ 0 ];
$post = $post [ 0 ];
if ( config ( " views.counter " ) == " true " ) {
add_view ( $post -> file );
}
if ( config ( " views.counter " ) == " true " )
{
add_view ( $post -> file );
}
if ( ! login ()) {
if ( ! login ()) {
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
file_cache ( $_SERVER [ 'REQUEST_URI' ]);
}
}
render ( 'static' , array (
render ( 'static' , array (
'head_contents' => head_contents ( $post -> title . ' - ' . blog_title (), $post -> description , $post -> url ),
'head_contents' => head_contents ( $post -> title . ' - ' . blog_title (), $description = get_description ( $post -> body ) , $post -> url ),
'bodyclass' => 'inpage' ,
'bodyclass' => 'inpage' ,
'breadcrumb' => '<a href="' . site_url () . '">' . config ( 'breadcrumb.home' ) . '</a> » <a href="' . $father_post [ 0 ] -> url . '">' . $father_post [ 0 ] -> title . '</a> » ' . $post -> title ,
'breadcrumb' => '<a href="' . site_url () . '">' . config ( 'breadcrumb.home' ) . '</a> » <a href="' . $father_post [ 0 ] -> url . '">' . $father_post [ 0 ] -> title . '</a> » ' . $post -> title ,
'p' => $post ,
'p' => $post ,