Do It Yourself CMS » Blog »


New DiY-CMs features 1: reducing queries by 50-85%

  By: admin   tags Date Added: Wednesday 09-02-2011

After I finished programming my first app for facebook - Friends Stat, I started thinking about new ways to improve DiY-CMS. I have many ideas to develop but there are three features of them which I believe are important. They are: cache system to minimise mysql queries, adding php code into main templates and improving the update system in DiY-CMS control panel.

I will explain the first feature in this blog and then talk about the rest in later blogs.
Cache system is developed to ease the process of retrieving data from database. In other words cache system saves the results of repetitive queries that do not change often into files and then retrieve the data from these files rather that querying database again and again. As you might have guessed by now, this process will reduce the load on database and increase the cms performance.

In DiY-CMS there are number of queries that do not change often such as general settings, module settings, plugins details, themes, templates and other queries. Cache system will save the results of each one of these queries to a single file and place it in cache folder. Once a query is requested in the front-end DiY-CMS will check if there is a cache file relevant to that query and retrieve results saved in it, otherwise the query will run normally.

Cache files do not have expiry data, so files would remain for unlimited period of time. What if I make changes to settings, theme or templates? In this case the relevant cache file would be updated automatically once changes occur in the control panel. Also, you can remove cache files manually from Cache folder any time you whish and DiY-CMS will create new cache files.

This feature reduces mysql queries and therefore increases overall performance. In some pages of DiY-CMS queries reached as little as 1 query per page. Certainly the number of queries cached would be different from module to another and one page to other pages but on average mysql queries have been minimised by 50-85%. See chart below.



Furthermore, you can use this system to cache queries that you might use in modules, plugins or blocks you develop for DiY-CMS. Implementing cache is easy and requires three functions one to create the cache file, second one to check file existence.

Say we have this query that we want to cache:

$result = $diy_db->query("SELECT variable,value FROM diy_settings");


You would be place this code in the place where the data of diy_settings is updated:

// Query database table
while ($row = $diy_db->dbarray($query_result)) {
$key = $row['variable'];
$array[$key] = $row['value'];
}

// create a cache file and save data into it
$diy_db->create_query_cache_file('global_settings', $array);


Notice that create_query_cache_file() function takes two parameters, the first one is the file name and the second one is query data that needs to be cached.

Then you would use this code to check for the file and retrieve its data:

// check if file exists
$cahce = $diy_db->check_query_cache_file('global_settings');
if ($cahce) {
// if file exists retrieve its data and place them in a varaible
$array = $diy_db->get_query_cache_file('global_settings');
} else {
// if file does not exist proceed with query as normal
$result = $diy_db->query("SELECT variable,value FROM diy_settings");

while ($row = $diy_db->dbarray($result, $i++)) {
$key = $row['variable'];
$array[$key] = $row['value'];
}
}
// here $array data can be used as whished


In the last code snippet there are two important functions, the first one is check_query_cache_file() which checked if file exists and the second retrieve data from the cache file. Both functions take one parameter and it is the file name that we creates using create_query_cache_file() fcuntion.

I hope that this blog provides some insights into the feature of DiY-CMS and how to use them.

In next blog I will explain the rest of features.


Tags: updates-diy-cms-mysql More details

Learning the structure of DiY-CMS folders and file - Part 3

  By: admin   tags Date Added: Tuesday 09-11-2010

This is the third post that is directed to the developers more than the end user. In this post I will talk about the files in the “includes” folder in the root DiY-CMS directory. Knowing the task of each file will assist the developer to understand the architecture of DiY-CMS and data flow as well.




Includes folder contains the files responsible for the main tasks to run DiY-CMS and control the different aspect of the CMS.

Here is the list of folders and files:
PHPMailer folder: This folder contains the folders and file of popular mail program PHPMailer. It is the standard program in DiY-CMS to send emails for notifications or other uses.

bbcode.class.php: This file contains the class that handles bbcode format.

blocks.class.php: This file handles the arrangement of blocks (menus) in DiY-CMS view.

date_conversion.class.php: handles date conversion in DiY-CMS. It converts Gregorian date to Hijri (Islamic lunar) date and vice-versa.

email.class.php: This class utilises the functions of PHPMailer and group in one class to ease its use.

files.class.php: This class handles files read and write functions.

form.class.php: This file contains the functions needed to produce a form with different fields, such as creating an input field or textarea.

general.functions.php: This file contains general functions like functions handling page header, page footer, errors or message display.

hooks.functions.php: This file handles hooks management in DiY-CMS. You can use it to place a hook in a certain place in the module or plug-in you develop. Alternatively, you can use it to hook your functions to the built-in hooks in DiY-CMS. (I will explain how hooks work in detail in a future post).

keyword_generator.class.php: This class is used to generate keyword on the fly for posts in DiY-CMS. It increases posts’ friendliness to search-engine.

login.class.php: This file controls users’ authentication in DiY-CMS.

module.class.php: This file is responsible for module management. It checks for module’s status, loads its templates, load its settings and run the module.

mysql.class.php: This file contains the necessary functions that manage database connection, querying, database error handling.

plugins.class.php: This file handles plug-in management. It loads all the active plug-ins, load settings, load permissions and then run plug-ins.

post.functions.php: This file contains post-related functions. They include post sanitisation, preventing sql injections, check required fields and other functions.

protection.php: This file mainly prevents XSS attacks on DiY-CMS.

session.class.php: This class handles sessions.

spam.class.php: This class prevent post spamming in DiY-CMS, by checking IP address and time intervals between two consecutive posts of the same user.

templae.class.php: This class handles theme-related task. It check for the theme selected, load its templates, process their content and then output the page.

upload.class.php: This class handles file uplads in DiY-CMS. It can handle adding or editing multiple files at the same time.

I hope you liked this post, and looking forward to hear your comments and suggestions.


Tags: DiY-CMS-structure More details

Learning the structure of DiY-CMS folders and file - Part 2

  By: admin   tags Date Added: Sunday 31-10-2010

In last post I explained the task that each file in the root directory handles. In this post, I will keep on explaining the rest of folders in the root directory.



Admin folder: This folder contains the folders and files that are responsible for the administration part of DiY-CMS. It contains four folders and a number of files.

admin_classes folder: contains files essential PHP classes to run the administration area.

admin_lang folder: contains the language file for the UI of the administration panel.

admin_sections folder: contains the folders responsible for the different administration sections (the menus to the left of the administration panel) , such as managing modules, themes .. etc.

admin_skin folder: contains the skin or themes for the administration panel.

conf.php: contains the values required for database connection, folders location, site administration contact details and some other values.

index.php: runs the main view of the DiY-CMS admin panel.

global.php: Global file for DiY-CMS panel area, it must be included in all files in the admin area.
sections.php: Manages sections view and management in the admin panel.


Blocks folder: This folder includes all the blocks (or menus) designed for DiY-CMS.

Html folder: Contains files required the included WYSIWYG editor in DiY-CMS.

Images folder: Includes images that used are used globally across DiY-CMS.

Includes folder: contains the necessary PHP classes to run DiY-CMS such as database connection, themes management, module control and other functionality. (I will explain the tasks that each files handle in a future tutorial).

Install folder: This folder is responsible for running the installation wizard when using DiY-CMS for the first time at your server. If installation is complete the folder name will be changed for security reasons.

Lang folder: Contains the languages files for DiY-CMS interface.

Modules folder: Contains modules folders.

Plugins folder: Contains DiY-CMS plug-ins folders and files.

Themes folder: Contains DiY-CMS themes.

Upload folder: This folder is used for file upload. It should be the only place for file upload. This will make data transfer or upgrade easier for the end-user.

Please let me know if there are any part of this tutorial needs to be further explained.


Tags: DiY-CMS-structure More details

Learning the structure of DiY-CMS folders and file - Part 1

  By: admin   tags Date Added: Wednesday 20-10-2010

When I created DiY-CMS I made number of tutorials explaining how to manage and use DiY-CMS. Those tutorials were tailored the general user of CMS, a user who has no or little programming knowledge. Since that series of tutorials is complete, I will be starting another series; a one that is made specifically for developers who whish to develop DiY-CMS to create modules or plug-ins for DiY-CMS, or modify in any way they wish. In basic, this tutorials series is mainly for developers with sound programming language knowledge.

I will start explaining the general structure of folders and files of DiY-CMS. Then I will write number of tutorials detailing the best way to program a plug-in. I will then explain how to program a module and the best practices that one should use for programming.

In this tutorial I will start with the first part of explain the folders and files structure of DiY-CMS. I will explore the folders one by one and explain the files they contain and their main functions.

Once you download DiY-CMS and extract the zipped file, your will find a structure similar to this:



In the first part I will explain what each file in the root folder does then I will explain the function of the rest of the folders and files in the second part.

.htaccess: contains information about url re-write.

control.php: provides a user interface to manage modules from one place.

filemanager.php: renders image files, particularly avatar, thumb images and can be used to render any kind of image.

global.php: This file is a global file, meaning that it must be included in all files of DiY-CMS. It manages the inclusion of the necessary files to run DiY-CMS, such as files responsible for database connection, theme selection or user authorisation. By default all modules have this file included, so you do not have to include it in any module file you would like to program.

index.php: this the index file of DiY-CMS. It displays the first page of DiY-CMS to the user.
licence.txt : the licence of DiY-CMS. Since DiY-CMS is an open-source program, (GNU GENERAL PUBLIC LICENSE) GPL licence is used.

mod.php: this file manage DiY-CMS modules display. It is responsible for reading the general layout of any opened module.

online.php: retrieve the number of people online and their location in the DiY-CMS.

robots.txt: communicates with search engine crawlers and tells them which part of DiY-CMS to access and not to access.

In the second part of this tutorial I will explore the contents of admin folder.


Tags: file-structure, diy-cms More details

Finally, a DiY-CMS / vBulletin bridge

  By: admin   tags Date Added: Friday 24-09-2010



Finally, I was able to create a bridge between DiY-CMS and vBulletin forum. I designed the bridge in the form of a plug-in so it is easir for adminisitrators to control it. The plugin would unify registration and login in DiY-CMS and vBulletin forums.

The plguin will:
1- Unify registration. User would have to register once using the same registration form.
2- Unify login, through DiY-CMS only.
3- Unify logout, through DiY-CMS only.
4- Import users who registered through vBulletin forms.

Installation:
1- Download plug-in from this link: http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=30

2- Extract the contents of the zip file and then upload the folder to the plugins folder in your website.

3- Open config.php inside the plug-in folder and edit this line:
define('FORUMPATH', 'D:/xampp/htdocs/vb/'); // path to your forum 


Change D:/xampp/htdocs/vb/ to the path of vBulltein forums on your website.

4- Install the plug-in through the admin panel. In the plug-in setup tick users module only. You can select other modules, however this will increase the database enquires number and the plug-in is programmed to be working only on the users module (since that is all it needs to function correctly)

5- In the plug-in settings you will see the following:



Select the new users group. Link DiY-CMS groups to the corresponding vBulltein forum groups.

Import users to DiY-CMS by clicking on the green button. You have to repeat the last step (the importing part) from time to time in order to import users who users who register through vBulltein.

Alternatively you can disable registration at the vbulletin and enable it only through DiY-CMS


Tags: vbulltein-bridge, diy-cms More details

Blog module for DiY-CMS

  By: admin   tags Date Added: Tuesday 31-08-2010


Hi
As promised, I made the blog module available for download. This website is a live example of the blog module.

Module features:
- Unlimited categories and subcategories.
- Groups-based permissions for adding and editing posts.
- ability to add tags to blogs.
- and many more.

to download the module:
http://www.diy-cms.com/download/view_file/downid_27


Tags: blog, module, diy-cms More details

Video module 1.0

  By: admin   tags Date Added: Wednesday 28-07-2010


Hi
Today I present you with the video module. It enables users to add videos to your website. Users can add videos either by uploading files from their computers or adding the embed link using any of the video sharing websites.

Module features:
- Unlimited categories and subcategories.
- Multiple video upload at the same time.
- Set video types allowed for upload
- Using group settings you can set the size of video uploaded
- and many more.

to download the module:
http://www.diy-cms.com/download/view_file/downid_29


Tags: video, cms More details

Friendly Links plugin

  By: admin   tags Date Added: Thursday 15-07-2010



Hi
I have programmed a new plguin for DiY-CMS. It basically converts most of the links in DiY-CMS from dynamic to static.

So links like this:
http://www.diy-cms.com/mod.php?mod=download&modfile=view_file&downid=26

would be converted to his:
http://www.diy-cms.com/download/view_file/downid_26


to download the plugin follow any of the links above :)

hopefully in the next blogs i will be talking about how to write a plugin for diy-cms using the hooks system


Tags: plugins, firendly-links, diy-cms More details

Gallery module for diy-cms

  By: admin   tags Date Added: Thursday 01-07-2010

Hi
Couple of weeks I started planning to program three modules for DiY-CMS which I thought are necessary for the completion of the CMS. They are gallery, audio and video modules.

Here is the first one, the gallery module. To download it Click Here.

Features:
- Unlimited categories and subcategories.
- Multiple images upload at the same time.
- Three types of listing: Title & photo, Photo Only or Title only.
- Add Copyright text
- Customise copyright colour and position.
- and many more.

Here is the image of the image listing in a category with photo and title type:


and this is the screenshot for viewing a single photo:


Tags: gallery, diycms, module More details

Admin area tutorials: user groups and smile

  By: admin   tags Date Added: Monday 03-05-2010

Hi
Today I have few updates that I would like to talk about which I have been working on them in the last month or so.

First, website design is completely changed. Thanks to subswiss owner the design is tableless (something that I wanted to do number of times but was not able to due to my little design experience).

Second, I have add two video tutorials to my youtube channel. The first one is about user groups management in the Admin Area of DiY-CMS, and the second explains the usage and the administration of smiles in DiY-CMS admin area.

Here are the tutorials:










Second part:









Tags: diycms, tutorials, video, user-groups, smiles More details

Pages
 1 
2 3 > »