LDAP – Create a list of Groupwise users inside an OU

This is just an example illustrating how to connect to the LDAP and get users and groups within a particular OU. The first part connects to the LDAP Second part gets all the groups within the specified OU and puts them in an array Last part gets loops through the groups and gets all the users within each group and puts them in a array Fill your LDAP connection parameters in this part [crayon-5996a8330c5e4634436532/] This part will get all groups within the OU. You may need to change OU=User Accounts part if your User Accounts are in a different OU e.g. Employee Accounts [crayon-5996a8330c5f1367892453/] This part will get all users within each of the groups [crayon-5996a8330c5f6117312415/] Echoes all the groups and users [crayon-5996a8330c5fb705985084/]   ...
Read More

Clean up Microsoft Word mark up in HTML

People are so used to using Microsoft word to type their content that it is not practical to even think of asking them to change and start thinking from a web perspective to produce a clean HTML and standards compliant markup using Adobe Dreamweaver or some other useful editor. But the basic purpose of a CMS is to decentralize the content uploading process and to be able to achieve this Microsoft Word is the biggest hurdle CMS users all over are facing. Till date there is no foolproof solution to this problem. Tools like HTML tidy, htmLawed etc do a descent job however it largely depends on how those tools are configured. HTML tidy can work at the Apache level which is the most cleanest way whereas htmLawed works at the application level. I liked htmLawed as it is very simple to use and quite flexible to change its configuration for different applications. Here are some steps to use htmLawed Download latest source code of htmLawed...
Read More

How to solve “FATAL ERROR: Cannot redeclare class/function”

This error occures when you have a function or class declared more than once Scenarios 1. I have a file with all the class declarations which I include after the header.php file. In my scenario it was not possible for me to include the class declaration file before calling the header. Later on there was a need to access the class functions within the header file. When I included the class within the header.php file, I got this error as the class declaration happened twice. 2. In rare occasions there can be a class name declared more than once. Solutions 1. Using  multiple includes: Class or functions file can be included multiple times. [crayon-5996a8330d10f455370759/] 2. Using IF statement: [crayon-5996a8330d117268171711/]  ...
Read More

Integrating Prestashop shopping cart with existing PHP -MySQL Authentication

Assumptions Here we are assuming that you are using PHP – MySQL and you have an existing list of clients/users already maintained in a seperate table. You have your own registration, login and logout mechanisms Step 1: Prestashop cookies First let us understand little bit about Prestashop cookies A customer login prestashop cookie is as below Cookie name: ps Cookie content:id_guest%7C1%C2%A4id_customer%7C1%C2%A4customer_lastname%7CLASTNAME%C2%A4customer_firstname%7CFIRSTNAME%C2%A4logged%7C1%C2%A4passwd%7CMD5_PASSWORD%C2%A4email%7CEMAIL%C2%A4 Note: there can be some other parameters as well in the cookie but I have included only the ones which we are interested. The cookie is ofcourse not readable. It is encrypted and decrypted using Rinjdael or Blowfish. Apart from that there is also a SALT phrase which is added through the settings.inc.php file Just for demonstration purposes I have removed the SALT phrase in settings.inc.php (in the config directory) as below [crayon-5996a8330d3f8412665794/] I disabled the cookie encryption and decryption process in Cookie.php file (in the classes directory) as shown below Comment below lines [crayon-5996a8330d400092097541/]   After doing the above changes, try to login again. If everything is done correctly, you should be able to login...
Read More

How to get the ID generated by the last INSERT

Many times there is a need to get the autogenerated ID from the last MySQL INSERT performed. This ID can then be used to perform some more INSERTs particularly in different tables. As a typical example lets assume you have members table and a seperate table to store their preference for receiving newsletter. When a new member registers, we perform the first INSERT to add the member details in the member table. Now our newsletter table needs the memberID generated from this insert so that we can store their preference (In case you are using their memberID as the primary key instead of the username) They way to perform this is as below [crayon-5996a8330db92455116856/]...
Read More

Create a List of files within a certain directory

This function will list files and directories within a specified directory E.g. if a directory named web contains some files like index.htm, contactus.htm and some folders like images, documents, products The script will return index.htm contactus.htm images documents products [crayon-5996a8330e26a514377697/] $sortflag can be any of below SORT_REGULAR – compare items normally (don’t change types) SORT_NUMERIC – compare items numerically SORT_STRING – compare items as strings SORT_LOCALE_STRING – compare items as strings, based on the current locale....
Read More

PHP – MySQL Search on multiple columns using concat

More often there is a need to search part of a text in multiple columns and the search is based on a single keyword text box For e.g. in a users table first name and last name can be stored in seperate columns Let’s assume a user named Joe Smith stored in a users table with first _name => Joe last_name => Smith If we have a single keyword text box search and if someone types “Joe Smith” and performs a search, a simple search query as below would give no results [crayon-5996a8330e4ee729505797/] For the query to give correct results it needs to be modifed as below [crayon-5996a8330e4f6873929157/]...
Read More
12