Tag Archives: mysql

To many, developers are seen as a commodity that only differs in cost. Projects are often given to the lowest bid. The thinking is, so what if the tech team working on my project is in India, China, or some other remote part of the world? In Bootsoft, we have seen first-hand how this can have dire consequences on projects and which is why all our projects are not only managed by a project manager in-house in New York but also led by a resident technical expert who is not only fluent in technology but is able to understand complex businesses processes and the interdependent relationship between business and technology.

David Bebawy is one of our brightest tech leads for several reasons. David has the technical skills to handle any task thrown at him no matter how complex or daunting it seems. Need a LAMP (Linux, Apache, Mysql, PHP), telephony, or e-mail expert? David is your man. David not only excels technically but has a keen talent for understanding business processes. While some expect a developer to simply complete the task at hand, David goes the extra mile to make sure that the task at hand does not negatively affect the entire project and often proposes better solutions. This is key in high profile and high traffic sites where one small mistake can have a snowball effect and take down an entire site or application. David is able to see the big picture even while focusing on leading the development team in ironing out the details.

For the last three years, David has focused on working on LeadRouter, an enterprise-grade real-estate lead management system used by hundreds of thousands of agents and processing millions of leads each year. David’s mission is to support this large-scale application and ensure both its short term stability, performance and long term success.

Gone are the days where clients can sit in a vacuum, come up with pages and pages of requirements, hand them over to developers, and expect a polished finished product. Developing and maintaining enterprise online applications is quite a complex endeavor that needs to be handled by an all-star technical team led by someone such as David.

Congratulations to David for this well-earned recognition and I am confident that David will continue nailing it in future and projects to come.

It’s hard to imagine the current state of business, entertainment or media without the remarkable impact and contribution of websites in the modern world.

It has to be noted the influence of a website is derived from a combination of its well organized content and the presentation. Content needs to be managed and updated. One of the key technologies in managing content is a Content Management System; a stand-alone application framework responsible to create, manage and deploy web page content. Much to the relief of non-technical website owners and clients, web CMS systems provides users with the ability to edit, publish, administer and even go back-and-forth between versions of their website contents that is instantly reflected to the other side of the world.

I’d like to quickly dive into a particular web CMS framework called Concrete5 and give some of my insights regarding its unique features and functionalities.

Concrete5 is an open source web CMS written in PHP and MySQL. C5 comes with a set of powerful tools and features that are written using object-oriented concepts and the model-view-controller (MVC) architecture. C5 has become being best known for its sleek interface, ease of use, and fast response as well as a resourceful community. Let’s examine some of the interesting aspects that make C5 special.

In-Context Editing

One of the unique features in C5 is its easy and intuitive ability to edit pages on-the-fly: In-Context editing. With a single click of the edit button from the C5 editing toolbar, page is put under edit mode – highlighting the editable page areas on mouse rollover. Users can make all sorts of changes on the editable areas, preview their changes privately, discard them or, if its ready to go live, they can type a description for their current edit version and then publish it. Changes would instantly go live.

One feature many would find useful during an in-context editing is the Scrapbook. Scrapbook is the “clipboard” version of Concrete5, where editors can simply copy one or many already configured and content managed page areas and paste them into other pages without going through the processes they went through the copied areas.

Themes & Templates


Themes define the look and feel of our entire C5 site. A theme is basically a directory of HTML, PHP, image, CSS and javascript files collaborating to render pages. Ideally, developers are responsible to “concretize” their site designs into a C5 friendly theme directory. By concretizing we mean organising the directory structure as per the C5 convention, define common site elements (headers and footers), define templates (page types in C5), define single pages (pages like login and contact-us) and then insert snippets of PHP codes in order to make page areas editable.

C5 allows one active theme at a time but we may have a number of them ready on our themes dashboard section. This list of themes could be a collection of themes from the fresh C5 install, custom made or downloaded/installed from the concrete5.org Marketplace.

Blocks & Block Areas


Blocks are the smallest display units in Concrete5. As the name implies, they are the building blocks of a page and its these entities users manipulate when a page is put under edit mode. Display units like carousel sliders, page navigators and image galleries make a good candidate for a block. When editing a carousel slider a block, for instance, users can specify the number of slides, its speed and the images and once the page gets published, the block’s controller is smart enough to process these inputs (or configurations) and send the processed data to its view.

One thing that always goes together with a block is a block area. A block area is simply the hole a block lives in. These areas has to be predefined on a page so users can manipulate them to add blocks, layouts or even alter their design on-the-fly (i.e. play with fonts, background colors, spacing, borders and even add an inline CSS code).

The fresh C5 install comes with several basic blocks like video player, Google maps, HTML editor, forms and so on.

Page Types


One of the signatures of a well crafted website is its consistent design and layout between pages grouped within the same type of category. C5 has a great way of predefining these types of pages as templates where their common components, layouts and design comes incorporated with their blank page instance. From C5 editing toolbar, users are given an easy task of adding a page, select its type and then fill out their desired content within the block areas defined.

This is very helpful for websites heavy-laden with articles, news and the likes that persistently get created every now and then. Moreover, the desire to improve designs and layouts can easily be achieved on the templates which automatically gets propagated to all other instances of the page type as well as to the newly created ones.

Single Pages


On the contrary to page types, single pages in Concrete5 represent pages that are one-off with unique design and layouts. Pages like Login, Contact and About often are presented with their unique design and layout and C5 does not require these to fall under any of the page types defined; for the simple fact that no more than one of these pages would exist throughout the site. Similar to page type templates, however, single pages could still be set up with block areas as desired so that the actual content can be managed by the end user.

The Dashboard


The C5 dashboard is a hub hosting several admin based tools and global settings like the File Manager – a centralized area to manage site assets like images and docs that could be used by page contents, Users and Groups – permissions and access rights, Reports – system logs, and page errors. The dashboard hosts tools where our custom made blocks, themes, page types and so on are activated before they’re ready for use on the main site section.

Besides these visible features, C5 also comes incorporated with different Zend libraries for its internationalization and powerful caching features geared towards optimizing pages for speed and lightness.

Conclusion

All in all, Concrete5 is an inexpensive, well thought and crafted extensible framework that makes content management a friendly task for regular end users. The number of addons and themes available through the C5 marketplace is an important part of its flexibility and success.

Feel like reading more about Concrete5?
http://www.concrete5.org/documentation/using-concrete5/
http://www.webdesignerdepot.com/2012/08/an-introduction-to-concrete5/
http://www.noupe.com/tools/is-concrete5-the-right-cms-for-your-website-73213.html

URL shortening is widely used and there are a number of sites, such as tinyurl, that offer the service for free. So, why roll your own?

  • Because it’s easy. Using PHP, MySQL, and Apache , it can be done in 3 steps that can take only 15 minutes.
  • You reduce your dependency on external services. If a site like tinyurl was to go out of business, any links published through them would be dead.
  • You can use any short names you want .

Step 1: Create the schema in MySQL

Login to MySQL and run these queries:

CREATE DATABASE my_tinyurl ;
USE my_tinyurl;
 -- Create a table to hold the mapping from short URL to real URL
 CREATE TABLE links (
 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 link VARCHAR(255),
 short_link VARCHAR(100)
 );
 -- Add a user and grant privileges for the database: :
 CREATE USER ‘tinyurl_user'@'localhost' IDENTIFIED BY 'password';
 GRANT SELECT,INSERT,UPDATE,DELETE ON my_tinyurl.* TO ‘tinyurl_user'@'localhost';
-- Add one record for testing
 INSERT INTO links (link,slink) VALUES ('http://bootstrapsoftware.com','b');

Step 2: Script the translation service

Create a file called index.php and place this code inside

<?php
# connect to the database
$db = mysql_connect('127.0.0.1','tinyurl_user','password') or die("Database error");
mysql_select_db('my_tinyurl', $db);

# get the real link
$domain_name = mysql_escape_string($_GET[domain]);
$result = mysql_query("SELECT link FROM links where short_link = ‘$domain_name’");
$array = mysql_fetch_assoc($result);
$redirect = (is_null($array['link'])) ? "http://google.com" : = $array['link'];
header(“Location: $redirect”);
?>

Step 3: Rewrite the short link as a GET parameter

In the same directory as index.php, create a .htaccess file and place the following rewrite rules inside:

 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule (.*) /link/index.php?domain=$1 [L]

New links can be added by manually inserting them into the database. Or, an html GUI and PHP script can be created to add them.

How might you use a service such as this as part of your application or business?

You’d think upgrading from MySQL 4.0 to 4.1 would be a trivial task. Unfortunately it’s not due to the fact that MySQL 4.1 has knowledge of character sets where 4.0 did not. If you have plans for internationalization or are working with other non-English language, now is the time to take the plunge and make sure your data is in utf-8 (unicode) in the database.

The following describes the process of upgrading MySQL from 4.0.16 to 4.1.22.

Step 1 – Put System in Maintenance Mode
Make sure there is no data changing in the MySQL database.

Step 2 – Data Backup
• Make a copy of mysql data directory.

Step 3 – MySQL Upgrade + Data Verification
• STOP SLAVE on slaves if running replication
• Shutdown mysql on all servers
• Modify my.cnf on all servers as follows
• [mysqld]
character-set-server = latin1
default-character-set = latin1

• Upgrade MySQL to 4.1.22 on all servers
• Start MySQL on master database
• Upgrade password handling (mysql_fix_privilege_tables script).
# mysql_fix_privilege_tables rootpassword
• Run following statement for every table to convert from latin-1 to utf-8 character set.
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 ;
• Modify my.cnf
[mysqld]
# Remove the following two lines
character-set-server = latin1
default-character-set = latin1
# Add
[mysqld]
character-set-server = utf8
default-character-set = utf8
[client]
default-character-set=utf8
• Restart MySQL
• Restart replication

Step 4 – Apache Modifications
• Modify Apache to set.
AddDefaultCharset utf-8
• Turn off maintenance mode

Step 5 – Testing
Test entire application
Issues to expect:
• TIMESTAMP fomat output has changed significantly so scripts that parse a date are very likely broken.
• Check all instances of Load Data Infile
• Syntax for multiple-table DELETE statements has changed

References:
http://dev.mysql.com/doc/refman/4.1/en/upgrading-from-4-0.html
http://dev.mysql.com/doc/refman/4.1/en/charset-conversion.html
http://peter-zaitsev.livejournal.com/12083.html
http://www.w3.org/International/O-HTTP-charset
http://dev.mysql.com/doc/refman/4.1/en/charset-connection.html

Michael Sleman
Tech Lead