ClassiPHPied PHP Classified Ads System (Free Download)

ClassiPHPied is a simple PHP Classified Ads System. This is not a “we have a load of features, but you won’t even use half of them” kind of system. Just a basic one, with the essentials to help you get started quickly – Be it for a small business, or expanding on top of it.

 

TABLE OF CONTENTS

 

 

DOWNLOAD & INSTALLATION

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

LICENSE & DOWNLOAD

ClassiPHPied is released under the MIT License. You are free to use it for personal and commercial projects, and modify it as you see fit. On the condition that the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

Download ClassiPHPied | GitHub | SourceForge

 

REQUIREMENTS

  • LAMP/WAMP/MAMP/XAMPP
  • Apache Mod Rewrite
  • PHP MYSQL PDO Extension
  • At least PHP 8.0

 

INSTALLATION

Just access http://your-site.com in your browser and walk through the installer. Login at http://your-site.com/admin.

 

 

HOW TO USE

So far so good? Let us now go through a quick crash course on how to use ClassiPHPied.

 

STEP 0) ACCESS THE ADMIN PANEL

The admin panel is accessible at http://your-site.com/admin.

 

STEP 1) REGISTER CATEGORIES

Categories > Hit the + button to add a new category > Register your categories.

 

STEP 2) UPLOAD IMAGES

Images > Upload your images.

 

STEP 3) CREATE CLASSIFIED ADS

Ads > Hit the + button to add a new classified > Fill in the form.

 

 

DONE!

That’s all! Head back to http://your-site.com/ and verify the listings.

 

CLASSIPHPIED FAQ

ClassiPHPied is “not working”? Here are a few of the common problems and how to “fix” them.

 

I DELETED ALL ADMIN ACCOUNTS

recover.php
require "lib/CORE-Go.php";
$_CORE->load("Users");
$_CORE->Users->save("NAME", "EMAIL", "PASSWORD");

Just create an “account recovery” script to create a new account (or update an existing one). Run and delete this afterward.

 

CHANGED DOMAIN OR PATH

  • Update HOST_BASE in lib/CORE-Config.php. Make sure to include the path (with a trailing slash) if not deployed at the base URL. E.G. http://site.com/classiphpied/
  • Delete the existing .htaccess file.
  • Create init.php.
    • require "lib/CORE-Go.php";
    • $_CORE->Route->init();
  • Access http://site.com/init.php, this will automatically regenerate the .htaccess file.
  • Delete init.php.
  • Clear the service worker and browser cache if you want to be “totally safe”.

 

PAGES ARE NOT RESOLVING OR SHOWING PROPERLY

  • Make sure that MOD_REWRITE is enabled in Apache.
  • Make sure that AllowOverride is set properly in Apache.
  • If using https://, make sure that your SSL cert and virtual host are properly set.
  • In Mac/Linux, make sure that Apache/PHP has permission to read the files and folders.

Here is a quick “working example” of a test site on my WAMP server:

httpd.conf OR httpd-vhosts.conf
<VirtualHost site.com:443>
  DocumentRoot "D:\http"
  ServerName site.com:443
  SSLEngine On
  SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
  SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"
  <Directory "D:\http">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

 

 

MANUAL INSTALLATION

  • Create a database and import all lib/SQL-*.sql in ascending order.
  • Open lib/CORE-Config.php, update the settings to your own.
    • The host settings.
    • Database settings.
    • If you want to develop mobile apps, consider enabling CORS.
    • Set your own JWT secret key, and the issuer to your domain or company name.
  • Run $_CORE->Route->init() to create .htaccess.
  • Create your own admin user. See “deleted all admin accounts” above.
  • Update index.php.
    • require __DIR__ . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "CORE-Go.php";
    • $_CORE->load("Route");
    • $_CORE->Route->run();

 

I WANT TO CHANGE THE DATE FORMAT

Login > under system settings section > there are 4 “MYSQL date/time format” settings, change them accordingly. These are simply formats for the MYSQL DATE_FORMAT() function.

 

NOT WORKING. DON’T KNOW WHY.

Open the developer’s console, reload the page and see the error message.

 

QUICK REFERENCE

This section is for the developers, a quick walkthrough of the general system structures.

 

FOLDER STRUCTURE

  • assets/ Public images, Javascript, CSS, etc…
  • lib/ Core engine and library files.
    • API-AAA.php The API endpoints. Will be deployed at http://site.com/api/AAA/.
    • CORE-CCC.php Core engine files. Try not to mess with these.
    • LIB-LLL.php Library files.
    • SQL-SSS.php SQL database files. Can actually delete these after installation.
  • pages/ HTML pages and template.
    • PAGE-PPP.php “Normal” pages. Will be deployed at http://site.com/PPP/.
    • ADM-AAA.php Protected admin pages. Will be deployed at http://site.com/admin/AAA/.
    • TEMPLATE-TTT.php HTML page template.
    • MAIL-MMM.php Email templates.

 

THE FRAMEWORKS

ClassiPHPied is built with:

 

 

DATABASE TABLES

USERS

users
Field Description
user_id The user ID, primary key.
user_name
The user name.
user_email
The user’s email address.
user_password
The password. Encrypted.
password_reset – Forgotten password recovery.
Field Description
user_id User ID, primary and foreign key.
reset_hash Password reset security hash.
reset_time Timestamp when the reset request is made. Spam prevention.

 

SYSTEM

settings
Field Description
setting_name Primary key.
setting_description Description of the setting.
setting_value The value of the setting.
setting_group Setting group.

  • 0 – “Hidden” system settings and definitions.
  • 1 – User changeable settings.

 

CLASSIFIEDS

categories – Classified Categories
Field Description
cat_id Category ID, primary key.
cat_name Category name.
cat_desc Category description, if any.
classifieds – Classified Ads
Field Description
cla_id Classified ID, primary key.
cla_title Title (255 characters max).
cla_summary A short summary (255 characters max).
cla_text The body text.
cla_date Date when the ad is posted.
cla_person Contact person (or company).
cla_email Contact email.
cla_tel Contact telephone number.
cla_images – Classified Ad Images
Field Description
cla_id Partial primary key and foreign key.
slot_id
Partial primary key.
img_file
Image file attached to the ad.
cla_to_cat – Classified To Category
Field Description
cla_id Partial primary key and foreign key.
cat_id
Partial primary key and foreign key.

 

DEVELOPING CLASSIPHPIED

As simple as it may be, going through the entire system is still going to take some time. So instead of “explaining line-by-line”, here is a condensed version of “how to quickly customize and upgrade”.

 

CORE BOXX LIBRARY REFERENCE

For most of the core modules, you can refer to the Core Boxx reference library.

 

STEP 1) CREATE/MODIFY DATABASE TABLES

Add your new tables or views, modify the existing ones.

 

STEP 2) ADD/UPDATE SYSTEM MODULE

lib/LIB-Report.php
class Report extends Core {
  function getNewClassifieds () {
    return $this->DB->fetchAll("SELECT * FROM `classifieds` ORDER BY `cla_date` DESC LIMIT 0, 20");
  }
}

To add a new module, create lib/LIB-Module.php. Define class Module extends Core, and add functions inside. In this example, we add a new report module – lib/LIB-Report.php and class Report extends Core.

That’s all. This new module can now be loaded via $_CORE->load("Report") and the function can be accessed via $_CORE->Report->getNewClassifieds().

 

 

STEP 3) ADD/UPDATE API ENDPOINT (OPTIONAL)

lib/API-report.php
// (A) MUST BE SIGNED IN
if (!isset($_SESS["user"])) {
  $_CORE->respond(0, "Please sign in first", null, null, 403);
}
 
switch ($_REQ) {
  // (B) INVALID REQUEST
  default:
    $_CORE->respond(0, "Invalid request", null, null, 400);
    break;
 
  // (C) GET NEW CLASSIFIEDS REPORT
  case "getNewClassifieds":
    $_CORE->autoGETAPI("Report", "getNewClassifieds");
    break;
}

To add an API endpoint:

  • Core Boxx has an API structure of http://site.com/api/MODULE/REQUEST.
  • lib/API-report.php will create an API endpoint at http://site.com/api/report.
  • $_REQ is the requested service REQUEST segment of the URL.

So for this example, we access http://site.com/report/getNewClassifieds/ to get the movement report. The API will reply with a JSON encoded string.

 

STEP 4) ADD/UPDATE HTML CSS JAVASCRIPT

  • Add your new pages in pages/.
    • For example, pages/PAGE-about.php can be accessed from http://site.com/about.
    • For admin pages, it is pages/ADM-report.php and http://site.com/admin/report instead.
    • Take note – ADM-AAA.php can only be accessed by users who are signed in.

That’s about it. Just reverse engineer and copy from the existing libraries, API, and pages… You will see the development pattern here.

9 thoughts on “ClassiPHPied PHP Classified Ads System (Free Download)”

  1. First of all, this is great! Thank you. Got it working with the install script very easily on my local xampp server. Trying to install it on a live server, I am able to follow the steps until I reach:
    run ‘$_CORE->Route->init() to create .htaccess. ‘
    I have no idea where to ‘run’ this ~ is this through SSH? Sorry if it seems like a waste-of-time question, but I cannot find solutions online. I dont have a lot of XP working with .htaccess
    Regards

    1. FAQ updated, see above… You don’t actually need to regenerate .htaccess if the path remains the same, just change HOST_BASE and database settings in the config file. E.G. Migrating from localhost/ads to site.com/ads

      1. Whoops. I missed it. Thank you for pointing it out to me, and thanks for sharing this with us! I love your work.

  2. It happened… Again…

    Unable to connect to database – SQLSTATE[HY000] [1045] Access denied for user ‘root’@’localhost’ (using password: NO)

Leave a Comment

Your email address will not be published. Required fields are marked *