Showing posts with label tutorials. Show all posts
Showing posts with label tutorials. Show all posts

Saturday, March 20, 2010

Tutorial: Validating User's Arabic Input using Regular Expressions in PHP

In PHP, Regular Expressions can be used to match a string to a specific pattern, this can be used to validate user's input to avoid certain security problems such as spoofed form submissions and cross-site scripting (see http://phpsec.org/projects/guide/), this can be done using preg_match() function

Here I'll talk only about using preg_match() to validate arabic input, for an explanation of regular expressions in PHP, see http://www.phpro.org/tutorials/Introduction-to-PHP-Regex.html

First Method you can use to make regular expressions include arabic is using \p{Arabic}, this makes preg_match() accept arabic strings,

that's not completely true :D

The previous paragraph is maybe what you would get if you searched the Internet for arabic patterns, but it needs following modifications to work correctly:

  • use /u modifier so the pattern will be treated as UTF-8 (you can make it for all your patterns since it works only for alphanumeric characters) >> '/\p{Arabic}/u'

  • use the HTML META tag so that Request parameters (GET & POST) will be encoded as unicode (the charset attribute should be UTF-8)

those two steps are important to make your validation work

another method is using arabic characters unicode codes, you can use /\x{****}/u to represent any unicode character, also /[\x{****}-\x{----}]/u makes the pattern support any character/symbol which its unicode lies between **** and ----, but do not forget the /u modifier and setting charset to UTF-8

Monday, July 21, 2008

Building a New Computer

Although many people are already experts when it comes to building a new computer from scratch, many others are still a bit intimidated by the concept of looking for each component, and putting everything together. For those who actually want to know how to build a computer, the computer help website "The How-to Geek" has put up an excellent tutorial about building a computer from scratch.

The tutorial is mainly divided into five parts (the titles are self-explanatory):

The tutorial is very thorough, and full of pictures and screen-shots which makes it even easier to read and follow. If you are interested to learn about building computers, make sure to check it out.

Tuesday, March 18, 2008

Setup your Symbian C++ Development Environment on WindowsXp

this semester, we're studying Symbian OS Development for mobile phone software, the course started with C++ development using Carbide C++ and will move later to J2ME, we are currently interested in the S60 platform.

preparing for my next lab assignment, i invite you to join me in installing Carbide C++ on my WindowsXp PC, we'll proceed as follows:

1. install ActivePerl-5.6.1 (required to build your projects) (this setup adds some env variables).
2. install S60 SDK for Symbian, i don't recommend beta versions.
3. install JRE (required by the Carbide Eclipse-based IDE).
4. install Carbide C++.
5. for console apps to run, you'll need to add "textshell" in a separate line at the beginning of your "{SDK_PATH}\Epoc32\Data\epoc.ini" file.then open the Carbide C++ and create a new Symbian OS C++ project-> Generic Symbian OS-> Basic Console Application(EXE) build and run. Let's call this first project "Test"

Troubleshooting:

1. when i first tried to run, i got this error "BLDMAKE ERROR: Platform ARMV5 not supported by \Symbian\Carbide\workspace\Test\group\BLD.INF" i found that the BLD.INF file contained the project information specially the platform details, as a windows user you expect that to be: "PRJ_PLATFORMS WINSCW GCCE" i found it was "PRJ_PLATFORMS DEFAULT" u can change it manually but to avoid doing that everytime i found it can be customized in the Carbide under Windows-> Preferences-> Carbide.C++-> Platform Filtering Preferences where i unchecked everything except WINSCW and GCCE.

update: i found later that you can choose not to install the ARMV5 and GCCE in the SDK setup and everything will still work fine for you - as far as we are concerned.

2. Windows Vista users may face other problems but i can't cover everything here, however i can say that the Symbian online community is very active and you should be able to find the solution to ur problem after a simple search, just be patient it may seem difficult at the beginning.

next time we'll go through our first console application! have fun!!!

Saturday, February 2, 2008

Learn about RSS from Common Craft

i've been very amused about these kind of videos, they call it "XYZ in Plain English", which corresponds to our Arabic expression "بالعربى الفصيح", they aim to introduce complex ideas in a very intuitive and story like way guided with pointing fingers and simple sketches, that makes it easy for you to follow up and get the idea, without having to bear with much jargon.

These videos are created by Common Craft and uploaded to YouTube by leelefever, they made many wonderful videos and have some kind of a show too, very creative and inspiring...

one good example that's suitable for our new blog is RSS in Plain English, RSS makes it easy for you to keep track of your favorite blogs and news updates, the video introduces the idea non-technically which isn't enough for you, since it only introduced the illusion of the service,

i prefer you read a little bit more about it on Wikipedia, you can start from here, and to make this discussion more thorough, i have to mention pinging and its implications.

do want to know what an rss feed looks like? click this link to view our blog feed, maybe your browser will suggest registering the feed too, it's a kind of xml that contains some or all the data you need to get, you can view the page source to have a closer look.