Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for February, 2013

Find files with PHP

Wednesday, February 27th, 2013 by Servage
Sometimes you just stumble over very useful code snippets and want to share them... Like with this one: Very useful piece of PHP code to scan directories, and find files within them - including files that start with a dot. The regular functions in PHP to scan directories etc. ommit those kinds of files, so this function below creates a wrapper and performs and extra search for dot-files. /** * find files matching a pattern * using PHP "glob" function and recursion * * @return array containing all pattern-matched files * * @param string $dir - directory to start with * @param string $pattern - pattern ...

SEO friendly URLs with .htaccess

Saturday, February 23rd, 2013 by Servage
Are your Search Engine Optimizing your website? There are many things to consider when doing so. Have good and proper content, relevant to your products etc. Support it with relevant meta tags, like keywords, description etc. Implement SEO friendly URLs, which make it easier for search engines to index your content, but also makes your URLs look nicer to the human eye. Here is how you can get going: Example URLs // Bad URL: http://my-domain.com/products/descriptions.php?productId=463 // Good URL http://my-domain.com/products/my-super-product-title In the second example, you simply get the product title (or slug) from the URL, and search your database to provide the proper product page, instead of doing it by productId, like in the first example. Getting virtual URLs to map to ...

Delete folder recursively with PHP

Wednesday, February 20th, 2013 by Servage
Have you ever tried to manage files and folders from PHP? In some cases it makes good sense to manage some files with PHP. Say you generate images, PDF files or downloadable archives from your scripts. You may want to store dem in a file structure, instead of creating them again and again on every request. Sometimes you also need to delete files, sometimes even large groups of files or directories including all their subdirectories. The default functionality in PHP and Unix is very careful when it comes to deleting stuff recursively. Below is a function which enables you do do that, but with the security feature of adding a root ...

Browser specific CSS hacks

Sunday, February 17th, 2013 by Servage
Its a great hassle to optimize HTML page design (CSS) for every possible browser - and their individual shortcomings. Web designers have been fighting this stuff for ages, and even today in 2013 we still somewhat have to consider different browser render things differently. Hopefully this problem will minimize, maybe even cease to exist, in the future - but until then, we have to care about it. I found this list of available browser hacks, which is a great help to every web designer, to build things custom for browsers, to fix the browser compatibility issues: Selector Hacks /* IE6 and below */ * html #uno { color: red } /* IE7 */ *:first-child+html #dos ...

Use Servage mailing lists with AJAX

Friday, February 15th, 2013 by Servage
mailing_list_apiWe have received a few requests about the mailing list API. There has especially been interest in how to integrate the mailing list to an existing website without going through any Servage subscribe/unsubscribe pages. Therefore I have created a very simple sample AJAX integration example, and thought it would be interesting for some of your as well. You need to include the jQuery library, and please be aware that the email validation is very basic, and please also note that most browsers will not allow the API call because it goes outside the scope of your domain/URL (i.e. it tries to connect to Servage's domain, instead of yours). In such cases ...

Detect and cleanup a hacked WordPress site

Tuesday, February 12th, 2013 by Servage
In an earlier article we wrote about how to identify hacked code on Wordpress pages. Unfortunately page hacking is still an issue sometimes when users use insecure or very outdated scripts, e.g. forget to maintain their open-source installation of something in their hosting account. Servage would love to make sure this is always up-to-date for customers, but the self-hosted scripts of customers are simply too varying in type, to make it possible. Also many users need to maintain a specific version of a script, for something else to work properly. In that case security fixes and updates have to be done manually. This article has some great tips to ...

Why is the HTML head important?

Sunday, February 10th, 2013 by Servage
Sometimes novice web developers are not implementing the proper tags in the HTML head. I see this as a problem because the head part is very important. While it does not contain any information immediately important to the display of the page (except the title), the head still contains information which is very important to the page as such, in terms of SEO and other functionality. Example This is a basic HTML document structure: <html> <head> <!-- The Document Head --> </head> <body> <!-- The Document Body --> </body> </html> Title The title is important - it is displayed at the top of the browser window. <title>Document Title</title> Meta & SEO Meta tags like description and keywords are important for SEO. <meta name="description" content="Document Description"> Other Resources You ...

Building data models with MySQL Workbench

Friday, February 8th, 2013 by Servage
Building and maintaing a proper data model is crucial to any web application. I believe that one of the most powerful and often overlooked free tools available is the MySQL Workbench application. It has been introduced here earlier, but it still appears to come as a surprise to many, that such a great tool is available - and even free: Workbench is a desktop application which helps you design and administrate your MySQL servers, databases, tables, users etc. Extremely useful for large and smal projects. I particularly like the data model editor, where you can get a visual overview over your tables and relations between them. Check out the listed ...

Nette Framework

Tuesday, February 5th, 2013 by Servage
There are many available frameworks out there, and I love to see new ones mature. It's great that some many frameworks can be used, it gives lots of options - but also makes decision making increasingly difficult. The Nette Framework is another player in the sea of web application frameworks - but like most others, it has its right to be here. It comes with great and powerful features, and makes life easier for web developers. Perfect Security. Nette uses revolutionary technology that eliminates security holes and their misuse, such as XSS, CSRF, session hijacking, session fixation, etc. Want to know more? Debugging Tools. Possesses unmatched debug tools, which will help you discover ...

Join Servage on Facebook

Sunday, February 3rd, 2013 by Servage
Did you know that Servage is on Facebook? Join the Servage page on Facebook and take part in an active community of users, who share experiences, questions and help each other - while Servage regularly updates the page with great tips, interesting articles or other related news. https://www.facebook.com/servage Are you not on Facebook? That is no problem. In that case there are plenty of other resources for you to get involved in, to stay on top of your website and hosting experience. There are plenty of communities, discussion forums etc. online dedicated to web design and hosting related topics. Even Servage has a few more places than Facebook, which you can use. Tak a ...