a content management system built on top of codeigniter4 .Functionality: blog creation with image upload, deletion and edit of blog. Also image upload for gallery. Login consists of login for one admin , with captcha.
|andy brookes 1f7e3f2852 clean up||10 months ago|
|.sass-cache||10 months ago|
|PHPMailer||1 year ago|
|app||10 months ago|
|bootstrapCss||1 year ago|
|bootstrapS||1 year ago|
|fontawesome||1 year ago|
|public||10 months ago|
|scss||1 year ago|
|tecnickcom||1 year ago|
|tests||1 year ago|
|writable||10 months ago|
|.gitignore||10 months ago|
|.jshintrc||1 year ago|
|Gruntfile.js||1 year ago|
|README.md||10 months ago|
|composer.json||1 year ago|
|composer.lock||10 months ago|
|gulpfile.js||1 year ago|
|license.txt||1 year ago|
|package.json||1 year ago|
|spark||10 months ago|
current web im using this CMS myself is https://andrinaboutique.com/
The two main files you need to edit are home.php and layout.php both found in app/views
What is it. Quite frankly its a light, perhaps somewhat crude CMS written on top of CodeIgnier4. It suits my purpose because all I want is a simple blog engine where, from a url, I can access a basic admin area with links to do(CRUD operations) :
Add a art jpeg to Art gallery
Delete Art Image in Gallery
Upload and Image about a product
Edit product details eg where people can buy it
Also I may want to add some web fonts and change styling By using grunt from command line that can be done.
Because of upload size of image i've had to delete vendor (needed for Codeignier4 , and node_modules which are needed for grunt)
##what you need to do to see landing Page
1) Assuming your on Linux and have composer installed then all you have to do , from a terminal is :
unpack downloaded zip file to say your Desktop.
using terminal cd into it
run command :
run command :
In the web root, you should now see a vendor directory , this contains all of CI4 libs and stuff
(If you don't have composer see below : getting composer )
2) In the writable folder is an sqlite database called Art. Make sure permissions are read and write for user, group and everybody else .
Then while still in the context of being at web root from a terminal , run:
php spark serve
You should see a message saying go to address localhost:8080 So do that and you should see the landing page
##Now to set up admin user name and password
At address bar on browser go to : localhost8080/setUp
//notice lower case set , upper case U lower case p
You should see a form, just type in what you want for user name and password and hit submit. The user name will be then written to the sqlite database and also the password. The password will be encrypted for security
If you get a blank page its probably because I updated and forgot to uncomment these lines 38 and 39 :
If you uncomment and still get a blank page; its because of caching which is enabled. So Go to writable/cache and delete contents except for the index.html file .
##post setting up admin creds
after setting up admin credentials you need to make sure , nobody else can hack using creds, from url setUp . To do that simply go to app/config/Routes.php and comment out lines 38 and 39 like this:
##Now log in using your user name and password to see a crude admin task area
to log in go to url: localhost:8080/blackcat
type in your user name , password and numbers you see for captcha. You should then see a basic admin area. Click on any admin url to do things.
The two main issues are database not being writable; the other one I came across when I forgot to go to url /logout and instead shutdown my laptop. On trying to login , I got the login form Ok , but with correct password I got an incompletely rendered page. Its something to do with corruption of session. A quick fix i found was to simply go to url/logout which cleared session errors. I could then go to login at /blackcat sucessfully.
##Front end stuff
Now front end is Bootstrap and there is a custom.scss that overrides it.
.scss is in scss directory of main web root. When you run grunt , it will compile it to css and stick it where it needs to go for system sheet to work.
To play around with editing and converting scss ,you will need node_modules
To get that, simply from the context of being in the web root , from a terminal run :
you may need to have nodejs installed for that to work.
Now when you ran “composer install” that should have put twbs into vendor. The twbs directory will be Bootstrap in the form of Sass.
After editing either the bootstrap sass (not a good idea in my view) or the sass in the custom.scss (see image for location) run once :
That does the conversion of sass into css , concats 3 bootstrap css into one etc. Custom.css ,
by the way part overrides the bootstrap.css
One file which is referenced in the view layout.php brings it all together and is called “style.css” One you’ve run the 3 grunt as above run once :
This will wait and automatically convert any changes made to custom.scss ans convert it to custom.css
A note on cache. There are 2 banes to our lives , browser caching and codeigniter caching.
The idea of codeigniter having a cache for web pages is to make it load quicker. If you don't see changes happening go to /writable/cache and delete everything but maybe the html file
The CodeIgniter team make available Ci4 with a MIT licence.
I'm quite happy to have anything I've added to inherit that licence;
I’ve queried Richard Stallman on the matter who in an email reply suggested I just submit to fsf , so i've done that. I'm not holding my breath those GNU guys are slow, hey they haven't even finished the GNU Hurd kernel
I'm on Arch Linux where php is currently : PHP 8.1.5
Everything seems to work with CI4.1.9 and php 8 fine so far :^)
The good news is that the core is up to date and if it works with php8 then the framework isn't going to get outdated any time soon!
Sass has some advantages over css see: https://sass-lang.com/guide
For one you can define a colour once, and use that colour as a variable throughout the rest of the in my case custom.sass Grunt is a task runner and can do some tedious tasks for you such as automatically converting sass to css.
I installed grunt globally on my linux box using :
npm install -g grunt-cli
If you want to use Grunt you will have to do the same.
I then using a shell windows CD'd into my CodeIgniter4CMS and typed:
npm install grunt --save-dev
Again you will have to run that .
open up Sendmail.php in app/Controllers
Basically for me I use my own personal gmail to send emails to another of my email a address
Lines 94 to 96 are where I setp up my gmail for sending . You can also use gmail or edit . See PHPMailer docs
$mail->Username = "*@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "*****";
Line 90 (marked out here for privacy is my google email) now I had google email arranged as a “two step”
$mail->setFrom('admin@yourdomain', 'john Doe');
$mail->addAddress('emailAddressWhereMeesageShouldBeSent', 'John Doe');
The bane of our lives these days, are spammers, so before the input from a surfer gets sent to the email , defined in the controller Sendmail.php a bit of spam checking is done. On my live testing I didn't actually get much spam ( maybe that was due to not much traffic ?) any way , the spam checking is done via a Controller called SpamChecker.php located app/Andy/SpamChecker.php If you open up that file you will see a small array such as 'http','www','//', 'viagra','
Obviously spammers want to send you a link to their clients web site, so the first 3 values in the array reflect that. Then I've added key words from the spam i received. if any of that is input into the message text box of the contact form, the surfer gets re-directed to a "your a spammer page" and the message is not sent.
You can add your own key words as you see fit.
Now if you have done anything with html , you will know that some characters are best represented by their html entity for best rendering to how you want then to look; databases also don't like certain characters. So here's the problem, when you do an edit of a blog enter characters without thinking it ould cause glitch. I don't want that to happen, so when you click submit the system does some regular expression filtering. You also don't want the sytem to be a control freak either, or there might be no formating. So i've included tags that a permitted including <p > stuff here </p> (start and end of paragraph) You can also safely directly type apostrophies int othe text box, they will be converted to html code representations
Don't use underscore(_) in image name; dash ( -) is ok because of the regex if there are odd characters in the name they will get removed then there will be an issue of the name stored in the database and its orginal name , which is used for moving into blog Images directory
You might have come across Blade or twig on other systems. With CodeIgniter you can make use of "layouts" which is what i 've done.
So if you want to have another page called say something.php then the view contents would look like:
<?= $this->extend('layout') ?> <?= $this->section('content') ?>
Page content of the view goes here
One the home page that comes up if you click on I have also added a bit more information of the views, that come up on clicking them,
The reason why the system works and that you can see the arbitary blogs , is that it doesn't need MySQl to work. Instead i use sqlite3 database , which is "serverless" meaning it doesn't require a db server to work. The database name is just "Art" and is located in the writable directory. Make sure that the writable directory has read & write permissions and so does the Art database file. Sqlite db's sometimes are named with .db suffix. I found that with one datbase browser, nothing was visible until i clicked to open "all files". A light and simple database browser and editor is called sqlitebrowser: https://sqlitebrowser.org/ It should be in your repository if your on Linux.
the links take you to forms where administrative tasks can be done will be visible. if not logged in access the admin page http://localhost:8080/admin will come up as page not found. You don't want web surfers getting access to the url , so its prevented using filters.
This CMS is really aimed at aspiring coders maybe coming to a framework for the first time. Looking int othe code you can see the basics of CRUD operations. Maybe you will be able to improve on my code one day :^)
Anyway I have had the system testing live for some time , so maybe not sophisticaed it does the good
If you want to give it a go a few things need tweaking . At line 24 of app/Config/app.php I use the line :
public $baseURL = 'http://localhost:8080/';
Change that to your domain(keep trailing slash at end /) or if developing on Apache rather than using spark serve what ever url you have set to serve the app up. eg on my Apache I use 127.0.0.2 via /etc/hosts and my virtual hosts set up to serve up landing page of web
To get rid of debug toolbar at every bottom of page go to line 22 of index.php in public and change
$_SERVER['CI_ENVIRONMENT'] = 'development';
$_SERVER['CI_ENVIRONMENT'] = 'production';
CodeIgniter4 documentation is at : https://codeigniter4.github.io/userguide/
The CodeIniter forum is at : https://forum.codeigniter.com/portal.php
PS I apologise to anyone who previously downloaded when it was a chunky 90Mb , that was due to unseen junk in .files I've removed it so its now more a reasonable download size
Also i'm in the process of checking , adding things i've forgot , and tidying up , also checking things like inclusion of CSRF protection. Actually that should have been done in all the forms, but i will double check . so i will up date as I get the time. I've put authorship in the top of the controllers I wrote with my email if you have any burning questions
If your on Linux you can set up composer by just downloading the composer.phar file then, from a terminal do something like :
sudo chmod 777 composer.phar
sudo mv composer.phar /usr/local/bin/composer
that will put the executable file into your /usr/local/bin which then which then can be evoked just using
For composer use see : https://getcomposer.org/