When I was working on the cakephp localization ( l10n ) and internationalization ( i18n ), I came across a problem so I decided to let the world know about it if anyone had got the same issue.
What we want here is that a user can go to the localized version of the website according to the URL identified, for instance we want the website to load the English locale when we pass a URL like this http://example.tld/eng/Controller/Action
The problem is that while implementing the routes for the language detection, the plugins made a conflict with the rules in the routes file. Language routing is easy but sometimes can be tricky.
Read more…
In this small article I’ll illustrate PHP’s variable variables and Variable constants. There is no variable constants in PHP but I’m introducing a methodology to implement the same approach and achieve the same functionality as variable variables.
Read more…
In this short tutorial I will illustrate how can you send and read custom HTTP headers using php.
First let’s start by sending a custom HTTP header to the server. I will be using cURL library to send HTTP requests.
Read more…
After going here and there and implementing alot of solutions, I found that every post request is getting redirected to get even if it was with HTTPS because of the implementation of the ForceSSL in the manual, so my word to you, save your time and implement this simple solution. I have tested it on cakephp 2.0 however I think it wouldn’t mind to work on cakephp 1.3
Read more…
I came across a problem while developing with cakephp 2.0.
Suppose that you have got a Post model and a Category model, and you have a grid, with all posts and the category title they belong to. In order to sort by the category title you will need to do as the following in your view.
echo $this->Paginator->sort('Category.title','labelForTheTableHeader');
Hope that helps anyone
Cheers
I’ve developed a snipped to correct the old numbers with the new numbers
The number change schema as follows:
(old -> new)
Mobinil
012 XXX XXXX -> 0122 XXX XXXX
017 XXX XXXX -> 0127 XXX XXXX
018 XXX XXXX -> 0128 XXX XXXX
0150 XXX XXXX -> 0120 XXX XXXX
Etisalat
011 XXX XXXX -> 0111 XXX XXXX
014 XXX XXXX -> 0114 XXX XXXX
0152 XXX XXXX -> 0112 XXX XXXX
Vodafone
010 XXX XXXX -> 0100 XXX XXXX
016 XXX XXXX -> 0106 XXX XXXX
019 XXX XXXX -> 0109 XXX XXXX
0151 XXX XXXX -> 0101 XXX XXXX
so here is my little php function that will use regular expressions
function changeMobileNumbers(&$contents){
// vodafone
$contents = preg_replace('/(0151)([0-9]{7})/', '0101$2', $contents);
$contents = preg_replace('/(010)([0-9]{7})/', '0100$2', $contents);
$contents = preg_replace('/(016)([0-9]{7})/', '0106$2', $contents);
$contents = preg_replace('/(019)([0-9]{7})/', '0109$2', $contents);
// etisalat
$contents = preg_replace('/(0152)([0-9]{7})/', '0112$2', $contents);
$contents = preg_replace('/(011)([0-9]{7})/', '0111$2', $contents);
$contents = preg_replace('/(014)([0-9]{7})/', '0114$2', $contents);
// mobinil
$contents = preg_replace('/(0150)([0-9]{7})/', '0120$2', $contents);
$contents = preg_replace('/(012)([0-9]{7})/', '0122$2', $contents);
$contents = preg_replace('/(017)([0-9]{7})/', '0127$2', $contents);
$contents = preg_replace('/(018)([0-9]{7})/', '0127$2', $contents);
return $contents;
}
Hope that was useful
In this article I’ll go through resetting MySQL root password the easiest way
We are going to stop the MySQL daemon to be able to run it in safe mode, then we are going to skip grant tables, which means we are skipping password authentication, then we will set our new password
Read more…
Tkinter is the most commonly used GUI programming toolkit for python
Here is how you can change the program icon in tkinter
Read more…
I wont cover what’s new in php 5.3 since it would be another article, however it contains alot of improvements including PHP Namespaces, Late Static Bindings, lambda functions, closures…etc. I would strongly recommend using it.
I’ll be explaining how to install LAMP stack with PHP 5.3.8 without compiling
It’s fairly easy using the dotdeb repository
Read more…
The fstab masks has puzzled me a little, because it’s not as the unix file permissions, so I thought to share the result of my research for anyone who felt the same.
The fstab exists in /etc/fstab, so let’s examine the fstab a little bit.
Read more…