Wednesday, June 25, 2008

Empty & old Cake

Hi, pals!

I have one old project with cake 1.1. And, suddenly, I start to get a lot of "empty" message.

So, it's look like this:

site.com/ads/add

Model have (all field) -> VALID_NOT_EMPTY

In controller, before $this->Ad->save() I made this:

trim(...)
strip_tags(...)
And, even, I wrote:

if ($this->data['Field'] == '') die;

But... But after one-two day I can found in DB records with empty fields. ;(

Of couse, I trying to add record with empty fields an cann't do it. Cake work fine, and return me to /ads/add with error "Field cannot be empty"

But fields empty. I don't know, how spammers do it, but he do it fine ;-(

After week of a lot attempts to fight with this I start use function afterSave ;-)

So

afterSave

$id = $this->Model->GetId();
$data = $this->Model->read(null,$id);
if ($data['Field'] == '') -> $this->Model->del($id)

After this I got only useful record in database.

But, of couse, this decision is not so beauty ;-(

If you know HOW this spammers do it - I'll be very happy if you tell me

(Yes, I look apache logs and don't found anything strange)

Labels: , ,