Snippee! is a personal code snippet manager that lets you Store, Share, and organize! ...

Getting Started Guide


What is Snippee!?


Snippee! is a web based, personal code snippet manager that allows you to create, organize, share and reuse your most valuable code snippets (pieces of code). The main idea is to make the process of finding and reusing code as easy and as effortless as possible to avoid wasting valuable time.

Snippee! comes with a powerful site administration back-end that allows administrators to manage all accounts and related information, a back-end for users to manage their own accounts and code snippets, and a front-end for published snippets that can be shared with anyone or registered users only.

Because Snippee! is built on top of a full featured Login and User Management system (PHP Security and User Management), it allows for multiple user accounts and is perfectly suited for a team environment...


  1. Deploy the database script located in the "connections" folder.
  2. Enter your database connection details in mysql.php located in the "connections" folder.
  3. Add your e-mail to the configuration file "web.config.php" under section five (5).
  4. Upload the MySnippets folder and its contents to your website root.
  5. That's it! For step by step instructions and explanation, please read below...

PHP Server Requirements


This application requires PHP 5.2.x on Linux and 5.3.x on Windows Server. PHP 5.2 will suffice on Windows but some functionality will not be available.

Unpacking the Downloaded Files


The file download is a RAR file. So, unpack the file to your desktop. You will get a single folder called "MySnippets", inside which you will find the application files. The file structure inside the unpacked folder should look something like the following image.

Creating the MySQL Database in phpMyAdmin


First things first... If you haven't created a MySQL database before, you can follow the instructions below. Create a new empty database in your hosting control panel and run the provided dbmysnippets.sql script on it to create all the database tables provided with this application.

  1. In your hosting control panel, navigate to the MySQL Databases section.
  2. Create a new empty database and name it anything you want or use the default (dbmysnippets) used in this application.
  3. When the database is created, make sure you assign a db user name and password to it. This is absolutely essential to keep your database secure and for the application to be able to connect to it and function properly.
  4. Once the database is created as described above, navigate to phpMyAdmin within your hosting control panel. You should be able to see the newly created empty database appear in the left hand column.
  5. Click on the name of the new empty database, then navigate to the "import" tab on top.
  6. Within the "File to Import" section on top, click the "Browse" button and navigate to the "connections" folder inside the downloaded files on your desktop. You will see a file named "dbmysnippets.sql". This is the provided sql script that will create all the tables for us.
  7. Double click on this file to select it.
  8. Now click the "Go" button on the bottom right of the phpMyAdmin window. This will deploy the database script and create all the required tables inside the new database that we have just created. The image below shows what you should see (approximately) when done.
  9. Before you leave this window, you should note the location address of your database. It should be displayed somewhere in your hosting control panel. It could be "Localhost" or something different.
  10. OK, the database is done. You can close this window if you want.
  11. At this point, you should remove the database script file from the "connections" folder and keep it in a safe place in case you need it later. You do not want to upload this file to your server for obvious security reasons.

Editing the Connection String

  1. The next thing we need to do is to edit the connection string so the application knows where the database is located and how to connect to it with the right security permissions (access rights). So, using your favorite editor, open the "mysql.php" file located inside the "connections" folder within the MySnippets folder.
  2. Make the appropriate changes for the database location, name, user name and password. Here is a screen-shot to help you along:
  3. Simply replace db_host, db_name, db_user_name, and db_password with the real values for the database we have created above.
  4. db_host could be something like "Localhost" or or something similar. This should be listed in your hosting control panel. If not, please contact your hosting provider for help.
  5. db_name is the name of the database you have created above.
  6. db_user_name is the user name you have assigned to the database when you've created it.
  7. db_password is the password you have assigned to the database when you've created it.
  8. Once this is in place, the connection string file will know exactly how to connect to the database in a safe and secure manner.

Editing the web.config.php


This file stores some global settings that are used throughout the application. Everything here is simple, self explanatory and straight forward. They are created to make programming easier, to avoid redundancy and to give you the convenience to turn features ON/OFF. If we need to change some values or turn features ON/OFF, we can do it all in one place rather than having to update a bunch of files. THE ONLY THING YOU HAVE TO CHANGE HERE IS YOUR EMAIL ADDRESS SO THE APPLICATION KNOWS WHERE TO SEND THE EMAILS WHEN REQUIRED.

At the time of this writing, there are nineteen (19) groups of settings that can be edited. The following sections below highlight a few important ones.

Moving the Application To Your Server


Securing Your Pages


Securing the pages you will create is very simple. You simply insert a PHP snippet at the top of each of your PHP pages that you wish to protect. Once the snippet is in place, you can define the role or roles that are allowed to access the page. User Roles can be created in the admin panel. Let's take a look at how the snippet works:

The Code Snippet

$auth_roles = array('owner','superadmin'); // << add roles here


  1. require_once('../web.config.php'); This code tells the application to include the web.config.php file which contains all the important application settings. Depending on where your protected page is located within the file structure, you have to adjust this URL so it is properly pointing to the web.config.php file. It doesn't matter how deeply your page is nested inside folders, just make sure the URL is correct.
  2. require_once(ROOT_PATH.'global.php'); This is another include file that tracks user sessions allowing the "visitors online" counter to work.
  3. $auth_roles = array('owner','superadmin','etc','etc'); // << add roles here This is where you define the allowed Roles (groups) that can access this page. As you can see above, the owner and superadmin are defined as allowed roles to view this fictional page. This means that any user who is in either of these two roles are permitted to view this page. You can add as many roles to the database as desired, name them as you wish and used them in your pages. So, in the above line of code, you would enter the role or roles in the manner you see it above, inside 'single quotes' separated by a coma, and you're good to go.
  4. require_once(ROOT_PATH.'controls/authorization/auth.php'); This is the PHP file that actually does all the work to authorize and authenticate the user trying to view the page.



It is highly recommended that you include the owner role in all protected pages because access is strictly restricted to the defined roles on each protected page. This ensures that the owner of the site has the highest privileges and can access any page. However, if the naming conventions of the default roles do not suffice, you can create your own roles and hierarchy in the admin panel and use them accordingly in your protected pages. Please note that while the use of the default roles are not mandatory, they are protected by the application and delete requests are simply ignored - just in case you need them later and wish you did not delete them.

There are no limits to the number of roles and no limits on how many roles a user is in. The application logic is very flexible and it is entirely up to you how you use them. The only thing you need to remember is that whatever role(s) is/are present in your code snippet, users in those roles are permitted to view the page. That's it!

The reCAPTCHA Control


If you want to take advantage of the recaptcha controls that are built in to the Login, Registration, Password Reset and Lost Activation controls, it is highly recommended that you register an account and create your own public and private keys. You can go here to do all of that. I have included a generic set of keys so you can test the application without having to mess with it but it is not secure since everyone who downloads the application will have the same pair of keys. So, please make sure you DON'T forget!

Turning The reCaptcha Control ON/OFF


Recaptcha adds an extra layer of security to your application and it is highly recommended. However, if you do not wish to use it on your Login and Registration pages, you can turn them off in the web.config.php file. Simply set the value to zero (0). To turn it back on, set the value back to one (1). Here is a visual to help you along:

File Structure and Architecture


This app was built with simple event driven programming so the code is easy to understand and edit even if you are a beginning / junior PHP developer.

There are lots of files - only because I tried to break out and isulate every distinct functionality to make finding and editing code as easy as possible. Once you've become familiar with the basic organization, it will be a breez to make edits and modifications.

The actual files that are viewed in the browser, only contain include files to keep things clean and organized. All code files are located and organized in the "controls" folders. One for each major section of the site. There is a "controls" folder in the site root, "admin" section, user "folder" and another one in the "feedback" folder. Each "controls" folder also contains an ".htacces" file that prevents direct access to these code files. They can only be used as include files within the application. Here is a visual to help you along.

As you can see, the control directories are pretty srtraight forward and just about explain themselves. Each directory is named after the functionality it contains. The PHP files inside them are also organized the same easy to follow way based on nothing more than common sense...or so is my hope. This allows you, hopefully, to quickly explore and find the code you're looking for.

End Note


Do you need more info? Let me know and I will add the explanations here... Cheers, Hunzonian