Re: Is this possible a big issue

2011-05-07 Thread datgs
strtotime('now') is from the CakePHP core, I have no comment :)

Someone told me about NPC to sync the time among multiple servers.
Anyway, it should be the job of administrator :)

On May 7, 4:36 pm, Elte Hupkes  wrote:
> Also make sure you use the same timezone on all servers.. I usually
> use date_default_timezone_set('UTC') and the UTC_ MySQL functions to
> that end.
>
> On a different note, why use strtotime('now') instead of time()?
>
> On May 6, 8:09 pm, datgs  wrote:
>
>
>
>
>
>
>
> > Thanks, I think NTP is a good choice.
>
> > On May 6, 4:05 pm, Ryan Schmidt  wrote:
>
> > > On May 6, 2011, at 03:59, datgs wrote:
>
> > > > I've worked with CakePHP magical created, modified and updated. And I
> > > > found that automation of getting current time based on php at
>
> > > > $time = strtotime('now');
>
> > > > I think it is not good for some case, for example if my MySQL server
> > > > time is different from HTTP server time and someone want to mine data
> > > > just at MySQL side, the result of query might be wrong.
>
> > > > I think CakePHP team should make a time synchronic between HTTP Server
> > > > & Database Server before saving the data.
>
> > > A what? I didn't understand this sentence.
>
> > > If you're concerned that the clocks on various servers would be 
> > > different, then fix that problem by using NTP on every server.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: newbie question - how to I find this particular value so I can pass it on via a redirect

2011-05-07 Thread dreamingmind
Barricades,

You don't really say WHERE the process seems to break down. The find
after the save seems suspicious to me. Is that returning the proper
slug to pass along to your view function? It looks like $slug will end
up holding the returned data array rather than the returned string
from the slug field (see below for more info)

You might take advantage of the fact that the id property of the model
is set to the id of the record that was created by save. So you should
be able to set your slug value properly after:

$this->Campaign->findById($this->Campaign-
>id,,array('fields'=>'slug'));

But you should also be aware that this will not return the slug field
directly. It's going to be in the usual data array:

Array
(
[Campaign] => Array
(
[slug] => My_crazy_slug
)
)

Regards,
Don

On May 7, 9:22 am, barricades  wrote:
> Hi, I'm new so please don't shout at me for the stupid question but...
>
> When I save a record I want to redirect straight to the record I just
> created. The record which I have just created uses sluggable behaviour
> to create a slug in a beforeSave, so I can't just use 
> $this->data['Campaign]['slug'] as it doesn't exist before I save my
>
> campaign.
>
> in my add function I've got:
>
> 
> if ($this->Campaign->save($this->data)) {
>         $slug = $this->Campaign->find('first', array('fields' =>
> 'Campaign.slug'));
>         $this->redirect(array('action' => 'view', $slug));
>         } else {
>         $this->Session->setFlash(__('The campaign could not be saved. Please,
> try again.', true));}
>
> 
>
> and then
>
> 
> function view($slug) {
>         $campaign = $this->Campaign->find('first',
> array('conditions'=>array('Campaign.slug'=>$slug), 'recursive'=>-1));
>         $this->set(compact('campaign'));
>         }
> 
>
> but that ain't working. I've tried a couple of other ways but I'm a
> bit stumped.
>
> How do I get the value that's in the slug column for the Campaign
> which has just been saved and pass it on to the view function so that
> I can display the right Campaign?
>
> thanks in advance :)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: I got problem in insert non english to form

2011-05-07 Thread Ryan Schmidt
Make sure your tables are in UTF-8 encoding instead of Latin-1.


On May 7, 2011, at 06:43, taq wrote:

> http://i.stack.imgur.com/H2mRB.jpg
> 
> how to hide or fix this problem thank to any suggest

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


User data invalid as I enter UsersController::beforeFilter()

2011-05-07 Thread Rob Wilkerson
I'm creating a registration page that allows for the possibility that
one user has created a partial record for another user. It looks like
this:

1. Some user creates a property and assigns a realtor.
2. The system creates a partial user record and sends an email to the
realtor to complete the user record if s/he cares to do so.
3. The realtor clicks a link in the email that brings them to the
registration page with an invite code that tells us who they are.

At this point, the realtor is at /users/register/ and the
user registration form is displayed with known data prepopulated.
What's confusing me is that several fields are already marked invalid
as soon as the page is loaded. No data was submitted, no data
validated, no save action has taken place. Moreover, dumping $this-
>User->invalidFields() at the moment the request enters
UsersController::beforeFilter() shows that invalid fields exist.

If, at the end of the invited user code, I don't set $this->data to
the found user, I don't see the errors.

How is that possible? What have I done that's initiated validation
this early in the request? I'm using the Auth component, so I suspect
that this is involved somehow, but I haven't been able to track down
what it might be.

Any insight would be much appreciated. I've been staring at this for
_way_ too long.

Thank you.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: TDD in CakePHP

2011-05-07 Thread Santiago Basulto
Wow, thanks for your answer Daniel.

It's great, i'll take a look and try it.

> Try defining your test cases, groups, etc. before you build the actual
> application, and not after the app is done. :)

Good advise by the way. Unfortunately i'm already on the run, so i'll
try to make tests for the new features and for the models.

Can you tell us about any good practice? Or some other practical
advise? Something you've expirienced?

I think i'd do TDD just for the Controllers and Models, not for views.
The deal would be to set the mock objects.

On May 6, 5:02 am, "Daniel S. Reichenbach" 
wrote:
> Greetings,
>
> > Does anyone do TDD in Cake? Do you have any recommendation or
> > something helpful to start with this practice?
>
> test-driven development with CakePHP is worth the effort. For starters,
> have a look e.g. in the test suite included with CakePHP, which can be
> found in the `cake/tests/` directory ([see here][1]).
>
> If you do want to write tests for CakePHP 1.3.x, you will need to grab
> [SimpleTest][2] and extract it into your vendor directory.
>
> For CakePHP 2.0.x, [PHPUnit][3] is used to write tests. I'd recommend
> to peek into the 2.0 branch on github, which comes with [tests][4] as
> well.
>
> An example for plugins and tests would probably be the debug kit, as
> it comes with [batteries included][5], too.
>
> Try defining your test cases, groups, etc. before you build the actual
> application, and not after the app is done. :)
>
> [1]:https://github.com/cakephp/cakephp/tree/master/cake/tests
> [2]:http://simpletest.org/
> [3]:http://phpunit.de/
> [4]:https://github.com/cakephp/cakephp/tree/2.0/lib/Cake/tests
> [5]:https://github.com/cakephp/debug_kit
> --
> [kogito](http://kogitoapp.com)  -  nerds available for awesome projects
>
> kogito Anwendungsentwicklung                       bra...@kogitoapp.com
> c/o Daniel S. Reichenbach                        phone: +49 6462 915060
> Auf dem Würtenberg 33                          mobile: +49 160 96311159
> 35075 Gladenbach, Germany

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


newbie question - how to I find this particular value so I can pass it on via a redirect

2011-05-07 Thread barricades
Hi, I'm new so please don't shout at me for the stupid question but...

When I save a record I want to redirect straight to the record I just
created. The record which I have just created uses sluggable behaviour
to create a slug in a beforeSave, so I can't just use $this-
>data['Campaign]['slug'] as it doesn't exist before I save my
campaign.

in my add function I've got:


if ($this->Campaign->save($this->data)) {
$slug = $this->Campaign->find('first', array('fields' =>
'Campaign.slug'));
$this->redirect(array('action' => 'view', $slug));
} else {
$this->Session->setFlash(__('The campaign could not be saved. Please,
try again.', true));
}


and then


function view($slug) {
$campaign = $this->Campaign->find('first',
array('conditions'=>array('Campaign.slug'=>$slug), 'recursive'=>-1));
$this->set(compact('campaign'));
}


but that ain't working. I've tried a couple of other ways but I'm a
bit stumped.

How do I get the value that's in the slug column for the Campaign
which has just been saved and pass it on to the view function so that
I can display the right Campaign?

thanks in advance :)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


I got problem in insert non english to form

2011-05-07 Thread taq
http://i.stack.imgur.com/H2mRB.jpg

how to hide or fix this problem thank to any suggest

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is this possible a big issue

2011-05-07 Thread Elte Hupkes
Also make sure you use the same timezone on all servers.. I usually
use date_default_timezone_set('UTC') and the UTC_ MySQL functions to
that end.

On a different note, why use strtotime('now') instead of time()?

On May 6, 8:09 pm, datgs  wrote:
> Thanks, I think NTP is a good choice.
>
> On May 6, 4:05 pm, Ryan Schmidt  wrote:
>
>
>
>
>
>
>
> > On May 6, 2011, at 03:59, datgs wrote:
>
> > > I've worked with CakePHP magical created, modified and updated. And I
> > > found that automation of getting current time based on php at
>
> > > $time = strtotime('now');
>
> > > I think it is not good for some case, for example if my MySQL server
> > > time is different from HTTP server time and someone want to mine data
> > > just at MySQL side, the result of query might be wrong.
>
> > > I think CakePHP team should make a time synchronic between HTTP Server
> > > & Database Server before saving the data.
>
> > A what? I didn't understand this sentence.
>
> > If you're concerned that the clocks on various servers would be different, 
> > then fix that problem by using NTP on every server.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Is this URL secure enough

2011-05-07 Thread Elte Hupkes
Ah, well in that case it's more like the token-activation kind of
thing you see on a lot of websites, that's usually pretty secure.

In these situations always ask yourself the questions "how could
somebody obtain this link?" and "if they obtain it, what can they do
with it?". In your case it seems that in order for someone to abuse
your system he must get the URL either through bruteforce (very,
_very_ unlikely), email hack (nothing you can do about that) or
browser history. In the unlikely scenario that someone obtains the URL
in the first place it must also still be valid, the odds of which are
severely decreased since the intended person has already clicked the
URL and thus most likely responded and invalidated it.
Long story short: I think you're good ;-).

On May 7, 6:36 am, datgs  wrote:
> Thanks for your comment. I would like to eplain more my situation.
>
> Assump that you have 2 users Officer and Approver. The Officer create
> a report and send it to Approver to be accepted or denied.
>
> The Approver receives an URL which meantioned within the email. He
> click the link:
>
> 1/ He can login the system without username & password
> 2/ Redirect to the report detail
>
> I know that the apperance of this link is high risk and have warned
> the Approver about ".. please keep the link in secure..". Moreover, I
> have added a lifetime to reduce the risk (because when the report is
> approved, the link is invalid, it looks like the URL used to activate
> the user after registration).
>
> Please tell me what is the best solution for this?
>
> On May 7, 4:14 am, Elte Hupkes  wrote:
>
>
>
>
>
>
>
> > Yes, URLs are encrypted over SSL (incidentally the reason you used to
> > be unable to host multiple domains under the same certificate - the
> > server couldn't make out which domain to serve). However, I would
> > consider sending private data in a URL a bad idea regardless of
> > whether it's encrypted or not; it shows up in browser history for
> > example, and you really want to avoid that.
>
> > On May 6, 8:15 pm, datgs  wrote:
>
> > > I have an URL under HTTPS.
>
> > >https://domain.com/privatekey/550e8400-e29b-41d4-a716-44665544
>
> > > Is the request path (privatekey/550e8400-e29b-41d4-a716-44665544)
> > > encrypted like POST or GET params?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php