New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Simple and tiny blog - WIP
Hello. @Daniel gave me an idea of a simple blog. So, I was thinking about it, what about any webserver+PHP? No MySQL, No SQLite. So I started... this is what I got so far:
<?php include('header.php'); exec("ls posts/*.txt", $output); if (!$output) echo "No posts, yet!"; //o incluir un php con una informacion de nuevo blog else { echo "<div style='width:600px;'>"; for ($x=0; $x<4; $x++){ if (count($output)<=$x) break; //if there's less posts than the post per pages, it will stop include($output[$x]); echo "<br>"; } //fin del FOR } //fin del ELSE //include("footer.php"); ?>
What's missing?
-The "older posts" link. I will update it later on.
-Print the date. don't know if get it via filemtime() or manually print it on the post.
-Basic admin. Get posts, previews, delete, edit, new post (using the NicEdit).
what do you think? Any ideas?
Comments
Nice one. Go ahead and make a nice more robust system!!
Copy @sleddog - Blite is lovely (y)
While looking for this...
http://stevehanov.ca/blog/index.php?id=49 ("A complete blogging system in 1900 lines of php")
...I found this:
https://github.com/sadasant/b ("A blog with 100 lines of not so obfuscated code using PHP, JSON, Markdown, Facebook Meta Tags and Disquss.")
O-M-F-G
Exactly, that's pretty impressive. It's just dark as hell.
There's also this.
Pretty good. Use PHP's glob function instead of exec to list the files (Theres another way, but off my head I can not remember).
Lol, it is like mine! thanks 4 the idea of glob, I will research... it will help to make it portable
I jumped the gun on glob way too early. Your better off using DirectoryIterator. Here's an example code (thanks stackoverflow! http://stackoverflow.com/questions/7642191/php-directoryiterator-sort-files-by-date )
Just change the arg passed to the DirectoryIterator to the directory. Then it will be sorted w/ ksort, based on the modified time.
Why? glob seems fine. I have updated the code, and made the new post page too
I will fix the "older posts" tomorrow, and some template thing and publish it 
I like it, sooo f*cking simple, using just php+text files
You could just use this for the admin part; to edit, post new etc.
https://github.com/rocktronica/OneFileCMS
You should ideally load the content before you load the header, so you can load the blog post into the page name?
You can remove that if statement being run each loop by something like
$ppp=4;
for ($x=0; $x<min($ppp,count($output)); $x++){
Which only counts the number of text files once. and takes $ppp out (posts per page)
When you add pages you can multiply the needed parts for the loop to work
maybe similar to
where $pageno is >1 ?
not sure why the times astrix sign is not showing between both $pageno and $ppp there should be one
Thank you, I'll check it, although I want to finish what I started
I had made the new post one.
I was thinking about that, making the first line of the post as the page name. Maybe when I finish the basic things. I have made the post show (changed a little bit the code), and make new post, allso basic, but working
. Then, I'm gonna implement CSS.
for ($x=0; $x<min($ppp,count($output)); $x++){
for ($x=($pageno-1)$ppp; $x<min($pageno$ppp,count($output)); $x++){
where $pageno is >1 ?
It's too early for me to process your information, but it seems that the add pages is what I am trying to achieve. The $ppp is the next thing I'm gonna make, maybe even taking out some things into a config.php file. Look at this code now:
btw, this is my new posts php, is there any problem with it? (code injection)
Depends on how you name your files. If you name then by ids (like 1, 2, 3), then its fine. However, if it's by name, you'll want to use the code I posted to sort by the file modified time.
Yeap, they are just numbers, so it is fine
Your if statement gets run and checked when it doesnt need to, Have as as the for argument and it wont run extra times when it doesnt need to. Ive just tested it and it works well could do a minimum function containing the amount of pages, so if a number too high is entered it just shows the last page (so page 999999 would show page 2 assuming 4 per page and 6 entries)
Now I get it! with the min() function, sorry, it was too late (10am) and on the work, but my mind was closed hahaha. I will implement it later on
btw I think that I had covered the basic things:
index.php
@netomx open a github account or host the code somewhere dude.
i will, when the time comes
btw, this is what I achieved: http://backup2.neto.mx/blog/
btw, the borders are just to know if it is well-formatted. I will finish admin today and start the design process, cleaning the style things and use CSS.