I Have a New Blog
I've started a new site, artooro.com. It is now the location of my new blog. This blog is as of now no longer active.
This blog will now automatically redirect to the new site.
It is certain, this is my blog!
I've started a new site, artooro.com. It is now the location of my new blog. This blog is as of now no longer active.
This blog will now automatically redirect to the new site.
Posted by
Arthur Wiebe
at
Thursday, January 25, 2007
0
comments
Mahmoud Abbas, "Aim your rifles at Israel."
For so long Abbas has been touted as a "moderate", someone who wants peace but is OK with the idea of Israel staying on the map.
Since Abbas replaced Arafat I've been highly critical of the man. It my opinion, it were better a moderate were an extremest in a way, either on one side or the other. If you're in between, you'll either get shot or not accomplish anything. Abbas has not accomplished anything since he started his current post. Yet some say "strengthening him" will help the peace process. I hope you see differently now.
Posted by
Arthur Wiebe
at
Sunday, January 14, 2007
0
comments
As what usually happens when you first right some code, and then put it into real world use, you make some changes to make it more efficient and easier to use. The same thing happened with my CheckFields function posted earlier.
So here's the code:
/*
'name',
'int' => 'year',
'email' => 'email',
'date' => 'date',
'length=2, int, date' => 'month',
'passwordsmatch' => 'password, confirmpass'
);
$input = array | example=($_POST || $_GET)
*/
class CheckFields {
public $lastError;
public function __construct($reqs, $input) {
foreach ($reqs as $type => $id) {
$fields = explode(', ', $id);
foreach ($fields as $field) {
if (!isset($input[$field]) || $input[$field] == '') {
$this->_ret(false, 00, $id, '"' . ucfirst($id) . '" Must be completed in order to continue.');
break(2);
//return array(false, $id . ' resulted in err00');
}
}
$types = explode(', ', $type);
foreach ($types as $t) {
switch (preg_replace('|(^.+)(\=.*)|', '$1', $t)) {
case 'passwordsmatch':
$fields = explode(', ', $id);
if ($input[$fields[0]] != $input[$fields[1]]) {
$this->_ret(false, 06, $id, '"' . ucfirst($fields[0]) . '" must be the same as "' . ucfirst($fields[1]) . '"');
break(3);
//return array(false, $id . ' resulted in err06');
}
break;
case 'date':
if (strtotime($input[$id]) === false) {
$this->_ret(false, 05, $id, '"' . ucfirst($id) . '" Is not a valid date.');
break(3);
//return array(false, $id . ' resulted in err05');
}
break;
case 'email':
if (!eregi("^(.+)(@)(.+)(\.)(.+)$", $input[$id])) {
$this->_ret(false, 04, $id, '"' . ucfirst($id) . '" Is not a valid email address.');
break(3);
//return array(false, $id . ' resulted in err04');
}
break;
case 'length':
// Make sure the field is the correct length
preg_match('|(^.+)(\=)(.*$)|', $t, $m);
if (strlen($input[$id]) != $m[3]) {
$this->_ret(false, 01, $id, '"' . ucfirst($id) . '" Is not the correct length.');
break(3);
//return array(false, $id . ' resulted in err01');
}
break;
case 'int':
if (!is_numeric($input[$id])) {
$this->_ret(false, 02, $id, '"' . ucfirst($id) . '" Must be a number and it is not.');
break(3);
//return array(false, $id . ' resulted in err02');
}
break;
case 'text':
if (!is_string($input[$id])) {
$this->_ret(false, 03, $id, '"' . ucfirst($id) . '" Must be text and it is not.');
break(3);
//return array(false, $id . ' resulted in err03');
}
break;
default:
trigger_error('Invalid type provided to checkFields()', E_USER_ERROR);
}
}
}
//return array(true, 'err7 - Success');
if (!isset($this->lastError)) {
$this->_ret(true, 07, NULL, 'It was a success!');
}
}
private function _ret($value, $code, $field_name, $description) {
$error = array(
'value' => $value,
'code' => $code,
'field' => $field_name,
'description' => $description
);
$this->lastError = $error;
}
public function __get($id) {
return $this->lastError[$id];
}
}
$requirements = array(
'date' => 'date',
'text' => 'name',
'email' => 'email',
'date, int, length=4' => 'yearofbirth'
);
$field_check = new CheckFields($requirements, $_POST);
print_r($field_check->lastError);
Posted by
Arthur Wiebe
at
Tuesday, January 02, 2007
0
comments