Archive for July 2012

Domain Model Validation

Using some magic methods can integrate validation without having to implement get and set methods everywhere.


class ValidationException extends Exception {
}

abstract class DomainModel {
private $validationErrors = array();

final public function __get($field) {
$getMethodName = 'get' . ucfirst($field);
if (method_exists($this, $getMethodName)) {
return call_user_func(array($this, $getMethodName));
} elseif (isset($this->$field)) {
return $this->$field;
}
}

final public function __set($field, $value) {
$setMethodName = 'set' . ucfirst($field);
if (array_key_exists($field, $this->validationErrors)) {
unset($this->validationErrors[$field]);
}
if (method_exists($this, $setMethodName)) {
try {
call_user_func(array($this, $setMethodName), $value);
} catch (ValidationException $e) {
$this->validationErrors[$field] = $e->getMessage();
}
} elseif (array_key_exists($field, get_object_vars($this))) {
$this->$field = $value;
}
}

final public function isValid() {
return count($this->validationErrors) == 0;
}

final public function getValidationErrors() {
return array_values($this->validationErrors);
}

final public function setData($data) {
foreach ($data as $field => $value) {
$this->__set($field, $value);
}
}

final public function getData() {
return get_object_vars($this);
}
}

class Test extends DomainModel {
protected $message;

public function setMessage($msg) {
if ($msg == null || strlen(trim($msg)) == 0) {
throw new ValidationException("Message must not be empty");
}
$this->message = $msg;
}
}

$obj = new Test();
$obj->message = "Hello!";
echo $obj->message . "\n";
$obj->message = " ";
if (!$obj->isValid()) {
foreach ($obj->getValidationErrors() as $error) {
echo $error . "\n";
}
}

What is CakePHP? Why Use it?

http://book.cakephp.org/2.0/en/plugins.html

CakePHP is a free, open-source, rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. Our primary goal is to enable you to work in a structured and rapid manner–without loss of flexibility.

CakePHP takes the monotony out of web development. We provide you with all the tools you need to get started coding what you really need to get done: the logic specific to your application. Instead of reinventing the wheel every time you sit down to a new project, check out a copy of CakePHP and get started with the real guts of your application.

CakePHP has an active developer team and community, bringing great value to the project. In addition to keeping you from wheel-reinventing, using CakePHP means your application’s core is well tested and is being constantly improved.

Here’s a quick list of features you’ll enjoy when using CakePHP:

Active, friendly community
Flexible licensing
Compatible with versions PHP 5.2.6 and greater.
Integrated CRUD for database interaction.
Application scaffolding.
Code generation.
MVC architecture.
Request dispatcher with clean, custom URLs and routes.
Built-in validation.
Fast and flexible templating (PHP syntax, with helpers).
View Helpers for AJAX, JavaScript, HTML Forms and more.
Email, Cookie, Security, Session, and Request Handling Components.
Flexible ACL.
Data Sanitization.
Flexible Caching.
Localization.
Works from any web site directory, with

PHP assignment operators

PHP assignment operators are used to assign value in a variable such that we can assign value 10 in a variable $a like that $a=10. Now the value of $a is 10 because we assign 10 in variable a.

equal (=) sign is used to represent PHP assignment operator but in array we use => sign to assign value. Now take a look at an example of PHP assignment operators.
<?php
$a = 20;
echo $a;
?>
Save and run the above code.
We can use PHP arithmetic operator in PHP assignment operator. Here is an example:
<?php
$a=10;
$a+=10;
echo $a;
?>

How to hack facebook accounts

Now that you have an account that you know is one of your victems friends and you have about 20 mutual friends. Add your victim and tell him or her that this is your new Facebook Account. There will be no reason for him/her to not beleive you and he/she will add you.

Now, since you are friends with the victim you will have 100 percent complete full access to their profile on facebook. You have access to school information, employment information, videos, private photo albums and anything else she’s added to the fb account.

This is a great way to get around using the traditional hacks that require some technical knowledge to using some basic psychological principles and social engineering.

Most of the time, you are not going to face any sort of challenge like that, but it is always best to know the potential consequences of any type of hacking endeavor. The smart hacker knows that despite knowing how to get someone’s Facebook password, they can only run from hired guns for so long when those folks have a lot more manpower and technology to track down those that ‘wronged’ a company as massive as Facebook. Just to see private Facebook pictures it may be worth it to you, and if so then you want to focus on the methods. Keyloggers are a prime choice if you have access to a computer the person uses to log into the site. You can install these easily enough and they will log the keystrokes of the person so you can see the password they type. That means you can then take that password and perform a natural login. However, be aware that these programs are not your only method. Plenty of people pretend to be someone else, talk to a person and manage to weasel their password, or at least enough hints to guess it, out of them.

You will learn how to make facebook pages safer and tricks such as view others private profiles. No matter what facebook does there always seems to be a way to view users profile pictures, albums and at times their entire private facebook profile pages. Make sure you bookmark this page, as many new bugs will be released, and we will find out how to view all of these exploits. Post these links to all who think facebook profiles are truly secure or private, or to those who are wary of its security.

If you have any questions or concerns about how to see a private facebook pages and profiles or have a different view point, feel free to comment on any of the pages. If you like this site and you want to continue to get useful information on facebook tips, tricks and hacks read how you can keep this site running or Advertise with Us.

A recent patch meant that older versions would no longer work, but after some hard work, research and investigation How to Hack Facebook Password we have finally managed to fix the patch. Our Hack Facebook Password tool is once again functional!
Many of you are probably wandering how come it's possible to hack facebook password with just using this software? Well, to make you fully understand the system how this application works you would probably need around few months first to learn the basics of programming. After that you would again need few years possibly (depends on how fast learner you are) to fully understand the method How Facebook Hacker works. But briefly, Facebook Hacker is researching trough facebook database where accounts passwords are stored, and depends on your victim's email and profile ID number/ username, it decrypts the passwords using the decryptor plugin built inside. Some passwords can be hacked in few seconds only, some can take few minutes, or rarely hours. This depends on how your victim's facebook password is made. Passwords which are hard to hack are made of letters (uppercase + lowercase), numbers and special characters (. , - ! etc.). Obviously, easy facebook passwords are made just of letters, and can be hacked very fast. The crazy is, almost everyone use this easy password! And then whine about someone hacked them. Until they learn how important is to have strong password to be secure, you have the power to hack their facebook account!

PHP Switch Statement

Php Switch statement is very useful, it works like if/else statement & reduce the complication of numerous conditions in the script.

Syntax :

switch (expression)
{
case 1
code .. //execute code if expression = 1
break;
case 2
code ... //execute code if expression = 2
break;
default:
code...//execute code if expression not matched
}
Example :


<?php

$value = 6;

switch ($value)

{

case 1:

echo "Value 1";

break;

case 2:

echo "Value 2";

break;

case 3:

echo "Value 3";

break;

default:

echo "Value is " . $value . " not matched!";

}

?>



DateFormat

The DateFormat function is another really useful function. This is most helpful when using a timestamp from a database. Generally, I use the 'datetime' format from MySQL and the 'smalldatetime' format when using MSSQL. The date is returned as '2007-01-01 00:00:00'. In PHP, the best way to use dates is the Unix timestamp. The Unix timestamp is the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). So right now, the time is '2007-12-16 11:46:56', using Unix, the timestamp the time is '1197823616' or 1197823616 seconds since midnight January 1 1970. This function will still use the date formating as defined in the php function date(). You can check it out at php.net. One little problem with this function is that you are required to send a full date through.

The Function:
<?php
function DateFormat($date,$format)
{
$adbit = explode(" ",$date);
$bdbit = explode("-",$adbit[0]);

if(count($adbit) > 1)
{
$cdbit = explode(":",$adbit[1]);
}
else
{
$cdbit = array();
$cdbit[0] = 0;
$cdbit[1] = 0;
$cdbit[2] = 0;
}
if(strtolower($format) == "short")
{
$dformat = "m/d/Y";
$tformat = "H:i a";
}
elseif(strtolower($format) == "medium")
{
$dformat = "M d, Y";
$tformat = "H:i:s a";
}
elseif(strtolower($format) == "long")
{
$dformat = "F d, Y";
$tformat = "H:i:s a e";
}
elseif(strtolower($format) == "full")
{
$dformat = "l F d, Y";
$tformat = "H:i:s a e";
}
if(isset($dformat) && isset($tformat))
{
$date = date($dformat,mktime($cdbit[0],$cdbit[1],$cdbit[2],$bdbit[1],$bdbit[2],$bdbit[0])) . " " . date($tformat,mktime($cdbit[0],$cdbit[1],$cdbit[2],$bdbit[1],$bdbit[2],$bdbit[0]));
}
else
{
$date = date($format,mktime($cdbit[0],$cdbit[1],$cdbit[2],$bdbit[1],$bdbit[2],$bdbit[0]));
}
return $date;
}
?>


Usage:

<?php
$date = "2007-05-19 13:51:22";
// You can use either
echo DateFormat($date,"F d, Y, g:i a");
// Or you can use
echo DateFormat($date,"long");

?>

The resulting output is: May 19, 2007 1:51 pm



Real Estate Script, Real Estate Software, PHP Script for Real Estate


Real Estate Script, Real Estate Software, PHP Script for Real Estate

Real Estate Script is a complete software solution allows you to launch a real estate website in php script with rich functionalities for real estate agents to list properties.
Real Estate Portal Script Enterprise Edition is a complete power packed script with tons of powerful features that will save your money, time and effort.

For more details contact us on ready2goportals@gmail.comVisit us at www.ready2goportals.com

Assignment#2

Start to build base on Assignment#1:
File created:
1) headerINC.php, Time spent: 20 mins
2) hNavINC.php, Time spent: 10 mins
3) navINC.php, Time spent: 10 mins
4) footerINC.php, Time spent: 15 mins
5) template2.css, Time spent: 10 mins

6) index.php, Time spent: 0 mins
7) email.php, Time spent: 45 mins

Project unfinish........ continue on next days.

Outsourcing PHP Projects

PHP Website Designers Developers and Programmers have started Outsourcing PHP Projects and IT Services like Zen Online Shopping Cart Joomla .Net WordPress MySQL with Web Designing Company in Rajkot Ahmedabad Gujarat India.

Outsourcing PHP Projects is now key features of WeTheDevelopers.com

PHP Web Development Company WeTheDevelopers has just launched new website
PhpWebDevelopmentIndia.com to cater Outsourcing Web Design and outsourcing website development Work in India.

Indian Web Designers Developers and Programmers are Expert in Custom PHP Web Application Development and Offshore Outsource Web Development Works. Instead of complete Outsourcing PHP Project from India, few Global Clients prefer to Hire Dedicated Employee Staff for PHP MySQL Web Development Work from Indian Web Development Companies.

Thanks & Regards

WeTheDevelopers.com - Php Web Development Company in India

301-Golden Plaza, Tagore Road, Rajkot Gujarat India

Phone +91 281 662 6667 / +91 98257 65089

admin@wethedevelopers.com

www.WeTheDevelopers.com

www.PhpWebDevelopmentIndia.com

Web design blogs

Flyg till köpenhamn

PHP if statement

We use PHP if statement to control the PHP program flow based upon conditions. It is used to route program execution. Here is the general form of if statement.
if(condition)
Statement;
Under the if statement the condition part returns a boolean value. If the condition is true then the statement is executed.
It is a single statement but if the statement is complex we must enclosed the statement or block of code with curly braces otherwise the second statement is executed (if the condition is true or not). Here’s the form is
if(condition)
{
Statement1;
Statement2;
………………..
}
Now we try to solve a problem with PHP if statement. Here, if Rahim‘s age is greater than 20, then it print Rahim is old boy.
<?php
$age=50;
If($age>20)
echo ” Rahim is old boy”;
?>

Url Encode and Url Decode

<?
function SafUrlDecode($returnurl){
    
$returnurl str_replace("<safras.q>","?",$returnurl);
    
$returnurl str_replace("<safras.e>","=",$returnurl);
    
$returnurl str_replace("<safras.and>","&",$returnurl);
    return 
$returnurl;
}
function 
SafUrlEncode($returnurl){
    
$returnurl str_replace("?","<safras.q>",$returnurl);
    
$returnurl str_replace("=","<safras.e>",$returnurl);
    
$returnurl str_replace("&","<safras.and>",$returnurl);
    return 
$returnurl;
}
?>

HTTP Headers

You can add headers to the HTTP response in PHP using the Header() function. Since the response
headers are sent before any of the actual response data, you have to send these headers before
outputting any data.
Examples :

Example 1. Prompt user to save a generated PDF file.
<?php
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='downloaded.pdf'");
?>

Example 2. Redirect browser
<?php
header("Location: http://www.example.com/");
?>

Example 3. Hide away your environment information (if you cannot do this at server level)
<?php
header('Server: ');
header('X-Powered-By: ');
?>

Date() Functions

Php date function returns a formatted date string. Every call to a date/time function will generate a E_NOTICE, E_STRICT or E_WARNING if the time zone is not valid.

d - The day of the month (01 to 31)
m -Month (01 to 12)
Y - Year (in four digits)


Syntax :
date(format,timestamp)

Example :
echo date("Y M d", time());
echo date("Y-M-d", time());
echo date("Y / M / d", time());

Output today formated date : 2007 Dec 24, 2007-Dec-24 and 2007 / Dec /24


To get the future date, i.e tommrow :
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo "Tomorrow is ".date("Y/m/d", $tomorrow);
Output : Tomorrow is 2007/12/25

To get a date in the past or future dynamically is like this:

//get timestamp for past/future date I want
$pf_time = strtotime("-3 days");
//format the date using the timestamp generated
$pf_date = date("Y-m-d", $pf_time);

gmdate() - Format a GMT/UTC date/time
idate() - Format a local time/date as integer
getdate() - Get date/time information
getlastmod() - Gets time of last page modification
mktime() - Get Unix timestamp for a date
strftime() - Format a local time/date according to locale settings
time() - Return current Unix timestamp

Ways To Earn With AIM Global

There are 6 ways of earning with AIM Global. By the way, AIM Global stands for "Alliance in Motion Global" which is an international company that offers business opportunities for a very low capital cost.

Way Number 1: RETAILING
Registered distributors/ retailers enjoy 25% of discounts in all of the AIM Global's products! This means that if you are going to sell the products that you brought from AIM Global, 25% of the price will be your profit. Sounds good, isn't it?

For example, if a product cost Php 100.00, the Php 25.00 from it goes to your pocket as your earnings. So it is really good to sell their products. It's worth of your time and effort.

Join AIM Global NOW! Click Here!

Refer friends and colleagues to join AIM Global and earn Php 500.00. If a person joins AIM Global with you as their sponsor or referrer, AIM Global will give you Php 500.00 as a reward.

Sponsoring is also selling. Once you become an AIM Global distributor, you can also sell business packages. Every business package is worth Php 7,980.00. This is also the package I bought and using to sell AIM Global Products.

Just imagine if you can refer 20 persons or sell 20 packages. 20 multiply by Php 500.00 is Php 10,000.00. It means that you already get back your capital of Php 7,980.00.

I am offering you my personal assistance if you are going to join AIM Global under my sponsorship. Join AIM Global NOW! Click Here!

Way Number 3: Match Sales Bonus
By the way, AIM Global is not a pyramid scheme business. Besides, it uses binary system which every persons that you can refer goes to either your left group or right group. Since AIM Global's marketing plan is binary, you only have two work force, your LEFT work force and RIGHT work force.You are able to get Php 1500.00 if you have 1200 points in your left and 1200 points in your right.Remember that you can get the points through referral (Global Package worth Php 7980, which have 1200 pts) , and product reorder. Everytime you purchase a product, the company will give you a points allocated on that product.

Join AIM Global NOW! Let me be your sponsor! Click HERE!

Way Number 4: UNILEVEL
You will get 5% commission on your downlines repeat order from first level to tenth level. Then another 5% if you are the direct sponsor of your downline. So start your downline building as soon as you join AIM Global.

Join NOW!

Way Number 5: STAIRSTEP
In this plan you will get another commission in your dowline reorder which varies on your position.

Distributor – once you join in AIM Global, you are automaticaly become its distributor. In this position you have 0% commission from your first level to infinity level.

Silver Executive – in this position,you need to accumulate 10 Positional points. This is not individual points, it is a group points. If you get promoted as SE, you will have additional 10% commission on group product sales from first level to infinity level.

Gold Executive – in this position, you need to accumulate 100 Positional points. It is also a group points. If you get promoted as GE, you will have additional 20% commission on group product sales from first level to infinity level.

Global Ambassador – in this position, you need to accumulate 1000 Positional points. It is also a group points. If you get promoted as GA, you will have additional 30% commissionon group product sales from first level to infinity.

Join AIM Global NOW! Click Here!

Way Number 6: ROYALTY and PROFIT SHARING
When you get promoted as Global Ambassador or GA, you get 2% group product sales from all GA in your group up to 5th level. If you are promoted as GA with 2000 points, your 1st level is also a GA with 2000 points, 2nd level with 3 level 1 GA, and in 3rd level with 5 level 1 GA, you will have 2% profit sharing commission based on company's sales in a year.Start working now and get promoted.

Join AIM Global NOW! Click Here!