Re: [fw-general] [ZF 1.10.4] Chain route + language code

2010-07-08 Thread Ben Scholzen
Am 08.07.2010 19:25, schrieb Laurent Melmoux:
> Hi,
> 
> I'm trying to add "language route" support. I'm using the code down below :
> 
> $router = new Zend_Controller_Router_Rewrite();
> $languageRoute  = new Zend_Controller_Router_Route(':language',
> array('language' => 'fr'), array('language' => 'fr|en'));
> $defaultRoute = new
> Zend_Controller_Router_Route(':module/:controller/:action/*',
>array( 'module' => 'default',
>   'controller' => 'index',
>   'action' => 'index')
> );
>   $router->addRoute('default', $languageRoute->chain($defaultRoute));

That's fine so far, nothing wrong with that.

> But if there is no params or only the language code in the url, routing
> doesn't work !
> 
> on routeShutdown I have
> 
> / => All Request object  param's are set to null
> /fr => All Request object  param's are set to null
> 
> But with a module name every thing works ok.
> /fr/a-module-name => fr/a-module-name/index/index
> 
> Does any body have some advice to give me to sort this out ?

This is actually a bug, or more, a shortcoming, in the current system,
which is hardly solvable. It will be solved with the new routing system
in ZF2 tho. For the moment I'd suggest you the following to work around it:

Have one empty static route, which sets default language, module,
controller and action. Have an additional single language route which
sets default module, controller and action. After those, have you
chained route.

Hope that helps.

-- 
Ben Scholzen 'DASPRiD'
Community Review-Team  | m...@dasprids.de
Zend Framework | http://www.dasprids.de
PGP key: http://stuff.dasprids.de/pgp/ben-scholzen-pgp-key.asc


Re: [fw-general] remember me and session cookies

2010-07-08 Thread scs
Ralph,
Thanks for your reply.
Answers are inline:

On Thu, Jul 8, 2010 at 7:31 PM, Ralph Schindler wrote:

> Response inline..
>
>
> scs wrote:
>
>> Hello,
>>
>> I have 3 questions:
>> 1. How can I find about a logged-in user's session data?
>> I would like to see when was the session started, how long has the user
>> been idle? and how much time left for session expire?
>>
>
> That is a tough one if you are using files.  PHP's garbage collector will
> run on a specific interval looking for files that have old timestamps
> (outside of a specificed range), and once it finds them, it will delete
> them.
>
> If you wanted to iterate the session's file directory, you can get the last
> modification or last access time of the files (whichever is available) and
> you might get some information for when the last time the session was
> active.  You'd also have to actually open the files and unserialize the data
> in order to determine who that session file belongs to.
>
> Your other option is to put sessions in the database, that might give you a
> bit more flexibility to do this kind of introspection at the application
> level.
>

I thought that some variables might be in the session such as idle time,
session generated time, expiry time etc. That was why I asked that.
I dumped the $_SESSION but there was not anything other than my user data
and the standard hash elements of the login form.
Why I wanted to see the expiry time was for testing if the session is valid
till the time I set for expiry.
I may switch session handler to database as you suggest. How about
performance? Any decrease?



>
>
>  2. I have a session setting in my application.ini file related to
>> session's save_path as below:
>> resources.session.save_path = path_to_project"/data/sessions"
>>
>
>
> is path_to_project a constant? only PHP constants are replaced in ini
> files, we typically use APPLICATION_PATH whcih is typically defined in the
> public/index.php
>

My directory structure is something like this:

myproject
..application
..models
..modules
..etc
..data
..sessions
..etc
..public
...

And the path_to_project_dir is a PHP constant I defined in public/index.php
which corresponds to
When I check the session.save_path via ini_get, I find the path is valid and
shows the location I wanted. something like this: /var/www/data/sessions (of
course apache is configured to as /public is the document root!)


> If its the same as APPLICATION_PATH, then the files will be stored at
> APPLICATION_PATH . '/data/sessions'.  That directory will need to be
> read/write by the web server.
>

And yes, the directory is writable by www-data user. Could that be related
to other session variables such as use_cookies etc?


> Otherwise, the data is going somewhere else, typically into /tmp/
>
> I checked /tmp but nothing found accept for the zend cache files for
zend_date scripts.



>
>  However, the session cookie files are not saved on this location. How can
>> I force this location?
>>
>> 3. I tried to implement remember me functionality for logins as below:
>> //if login successfull
>> Zend_Session::rememberMe($rememberMeSeconds);//remember me for 1 month.
>>
>> But this code sends the user to login form and does not give any error.
>> However, when debugging via webdeveloper plugin, i see a cookie that is
>> valid through the rememberMeSeconds.
>> But still i have one more default cookie for the domain which is firstly
>> created.
>>
>> What is the correct way to implement rememberme functionality?
>>
>
> Can you determine why the cookie is not staying set? Are you calling this
> only after authentication or on every request?  It should only be during
> authentication that you call this method.
>

I set the cookie (via Zend_Session:rememberMe...) only and once the auth is
successfull.
I see two cookies via webdeveloper plugin and I see that one of them(2nd
one) is valid till the time I set. And indeed the session is valid even
after hours (whereas it was only valid for half an hour before this
setting). When i delete the 1st cookie, system sends me to login page. But
when deleting the second
nothing happends.

The interesting thing, If uncomment the line below in the login/auth action:
//Zend_Session::rememberMe($rememberMeSeconds);//remember me for 1 month.
then instead of redirecting me to member area, site sends me to login form
as if the login operation was unsuccessfull. and without any error...

I think I might be doing something wrong or some settings in the application
ini file are interfering..

zend fw version is 1.10.2
linux, debian, php 5.2.6

thanks




> -ralph
>


Re: [fw-general] Zend_Scheduler

2010-07-08 Thread noHumans
Hi!

Zend_Queue simple example for offline processing

http://www.zfsnippets.com/snippets/view/id/60

Bye!


[fw-general] [ZF 1.10.4] Chain route + language code

2010-07-08 Thread Laurent Melmoux

Hi,

I'm trying to add "language route" support. I'm using the code down below :

$router = new Zend_Controller_Router_Rewrite();
$languageRoute  = new Zend_Controller_Router_Route(':language', 
array('language' => 'fr'), array('language' => 'fr|en'));
$defaultRoute = new 
Zend_Controller_Router_Route(':module/:controller/:action/*',

   array( 'module' => 'default',
  'controller' => 'index',
  'action' => 'index')
);
  
$router->addRoute('default', $languageRoute->chain($defaultRoute));


But if there is no params or only the language code in the url, routing 
doesn't work !


on routeShutdown I have

/ => All Request object  param's are set to null
/fr => All Request object  param's are set to null

But with a module name every thing works ok.
/fr/a-module-name => fr/a-module-name/index/index

Does any body have some advice to give me to sort this out ?

Thanks,

Laurent


Re: [fw-general] Zend_Scheduler

2010-07-08 Thread Ralph Schindler
I dont think Zend_Scheduler has been created as of yet. This is merely a 
proposal.


What you might be interested in is taking existing components to do this 
job.  For example, you could use Zend_Queue to schedule or create a 
queue of jobs, then write a script that is triggered to create and send 
mails with Zend_Mail.


URLS:
http://framework.zend.com/manual/en/zend.queue.html
http://framework.zend.com/manual/en/zend.mail.html

hope that helps,
ralph

Abi wrote:
I would like to use Zend_Scheduler, Please tell me how to use, I have 
got a URL on working of zend_scheduler to send emails, But i dont know 
how to use that material,Please tell me how to use it. 
http://framework.zend.com/wiki/display/ZFPROP/Zend_Schedule+-+Mark+Corti


View this message in context: Zend_Scheduler 

Sent from the Zend Framework mailing list archive 
 
at Nabble.com.


Re: [fw-general] remember me and session cookies

2010-07-08 Thread Ralph Schindler

Response inline..

scs wrote:

Hello,

I have 3 questions:
1. How can I find about a logged-in user's session data?
I would like to see when was the session started, how long has the user 
been idle? and how much time left for session expire?


That is a tough one if you are using files.  PHP's garbage collector 
will run on a specific interval looking for files that have old 
timestamps (outside of a specificed range), and once it finds them, it 
will delete them.


If you wanted to iterate the session's file directory, you can get the 
last modification or last access time of the files (whichever is 
available) and you might get some information for when the last time the 
session was active.  You'd also have to actually open the files and 
unserialize the data in order to determine who that session file belongs to.


Your other option is to put sessions in the database, that might give 
you a bit more flexibility to do this kind of introspection at the 
application level.



2. I have a session setting in my application.ini file related to 
session's save_path as below:

resources.session.save_path = path_to_project"/data/sessions"



is path_to_project a constant? only PHP constants are replaced in ini 
files, we typically use APPLICATION_PATH whcih is typically defined in 
the public/index.php


If its the same as APPLICATION_PATH, then the files will be stored at 
APPLICATION_PATH . '/data/sessions'.  That directory will need to be 
read/write by the web server.


Otherwise, the data is going somewhere else, typically into /tmp/

However, the session cookie files are not saved on this location. How 
can I force this location?


3. I tried to implement remember me functionality for logins as below:
//if login successfull
Zend_Session::rememberMe($rememberMeSeconds);//remember me for 1 month.

But this code sends the user to login form and does not give any error.
However, when debugging via webdeveloper plugin, i see a cookie that is 
valid through the rememberMeSeconds.
But still i have one more default cookie for the domain which is firstly 
created.


What is the correct way to implement rememberme functionality?


Can you determine why the cookie is not staying set? Are you calling 
this only after authentication or on every request?  It should only be 
during authentication that you call this method.


-ralph


[fw-general] remember me and session cookies

2010-07-08 Thread scs
Hello,

I have 3 questions:
1. How can I find about a logged-in user's session data?
I would like to see when was the session started, how long has the user been
idle? and how much time left for session expire?

2. I have a session setting in my application.ini file related to session's
save_path as below:
resources.session.save_path = path_to_project"/data/sessions"
However, the session cookie files are not saved on this location. How can I
force this location?

3. I tried to implement remember me functionality for logins as below:
//if login successfull
Zend_Session::rememberMe($rememberMeSeconds);//remember me for 1 month.

But this code sends the user to login form and does not give any error.
However, when debugging via webdeveloper plugin, i see a cookie that is
valid through the rememberMeSeconds.
But still i have one more default cookie for the domain which is firstly
created.

What is the correct way to implement rememberme functionality?


Thanks in advance


[fw-general] Re: Zend Framework 1.10.x and namespaces

2010-07-08 Thread Thomas D.


weierophinney wrote:
> 
>> require_once 'Zend/Loader/Autoloader.php';
>> $autoloader = Zend_Loader_Autoloader::getInstance();
>> $autoloader->registerNamespace('My_');
> 
> Here's your problem. Your classes are using a true PHP namespace of "My"
> -- drop the trailing underscore in the above line, and the autoloader
> should work:
> 
> $autoloader->registerNamespace('My');
> 
Oh right, I forgot to change the bootstrap file.

It is now working as expected.

Thank you!

-
Regards,
Thomas

-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Framework-1-10-x-and-namespaces-tp2281724p2282408.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Re: Zend Framework 1.10.x and namespaces

2010-07-08 Thread Alex Howansky

Remove this (you shouldn't need it and it is a waste of cycles):
$autoloader->setFallbackAutoloader(true);


If you're using namespaces and your code instantiates objects from 
strings, like this:


$class = '\\My\\Thing';
$obj = new $class();

Then you'll need to call setFallbackAutoloader() in order to work around 
PHP bug 50731. Alternatively, you can also do this:


$autoloader->registerNamespace('My');
$autoloader->registerNamespace('\\My');

I think this bug has been fixed for the next release, so hopefully this 
technique will become unnecessary.


--
Alex


Re: [fw-general] Zend Framework 1.10.x and namespaces

2010-07-08 Thread Matthew Weier O'Phinney
-- Thomas D.  wrote
(on Thursday, 08 July 2010, 03:16 AM +0200):
> Hi,
> 
> I am trying to add namespace support to our library. But I am unsuccessful,
> because some of our classes are using Zend Framework classes, which will
> fail to load:
> 
> /libs/Zend - location of Zend Framework
> /libs/My   - location of our library
> 
> In our bootstrap file, we make sure, that "/libs" will be added to the
> include_path and initialize Zend_Autoloader:
> 
> <==
> // ...
> 
> set_include_path(get_include_path() . PATH_SEPARATOR . $include_path);
> 
> require_once 'Zend/Loader/Autoloader.php';
> $autoloader = Zend_Loader_Autoloader::getInstance();
> $autoloader->registerNamespace('My_');

Here's your problem. Your classes are using a true PHP namespace of "My"
-- drop the trailing underscore in the above line, and the autoloader
should work:

$autoloader->registerNamespace('My');

> $autoloader->setFallbackAutoloader(true);
> 
> // ...
> ==>
> 
> /libs/My/Model/Test.php looks like:
> 
> <==
> namespace My\Model;
> 
> class Test extends TestAbstract
> {
>   // ...
>   
>   protected function _init() // Will be called from the parent constructor
>   {
>  if (self::$_cache === null)
>  {
> self::$_cache = Zend_Registry::get('Zend_Cache');
>  }
>   }
>   
>   // ...
> }
> ==>
> 
> When we are instanciating this class like
> 
> /test.php:
> <==
>  require_once('bootstrap.php');
> $model = new \My\Model\Test();
> ==>
> 
> we will get the following error message
> 
> "Failed opening 'My\Model\Zend\Registry.php' for inclusion..."
> 
> 
> Am I doing something wrong or is the current Zend Framework just
> incompatible with namespaces?
> 
> 
> -- 
> Regards,
> Thomas
> 
> 

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc


[fw-general] Re: Zend Framework 1.10.x and namespaces

2010-07-08 Thread Wil Moore III


Thomas D. wrote:
> 
> $autoloader->registerNamespace('My_');
> $autoloader->setFallbackAutoloader(true);
> 

Change 'registerNamespace()' to:
$autoloader->registerNamespace('My\\');

Remove this (you shouldn't need it and it is a waste of cycles):
$autoloader->setFallbackAutoloader(true);
-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Zend-Framework-1-10-x-and-namespaces-tp2281724p2281991.html
Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Problems with Zend_Form_Element_Hash

2010-07-08 Thread Marcus Stöhr
Hi Chris.

Nope, didn't work. I still get 'The two given tokens do not match' for the 
Hash-element.

- Marcus

Am 08.07.2010 um 09:28 schrieb Chris Riesen:

> On Register_Controller.php here
> https://gist.github.com/c66b22f11bbe138df6ad delete or comment out
> lines 22 and 23 then retry. I think that might be the problem there.
> 
> On Thu, Jul 8, 2010 at 9:18 AM, Marcus Stöhr  
> wrote:
>> Hi Chris.
>> 
>> The only redirect action I have fires only when the form is valid and the 
>> user saved in the database. Here is some sample code (I stripped out some 
>> things not relevant):
>> 
>> https://gist.github.com/c66b22f11bbe138df6ad
>> 
>> I use the actual trunk of Zend Framework and tried also the latest release 
>> 1.10.6 but the problems stays the same.
>> 
>> - Marcus
>> 
>> Am 07.07.2010 um 21:36 schrieb Chris Riesen:
>> 
>>> It get's set and reset at every load. Are you by chance using any
>>> forwarders or redirects? It gave me the error when I sent a form,
>>> validated it and the went back with the browser button to the form
>>> again and tried sending it again (of course). Maybe you have some
>>> code?
>>> 
>>> On Wed, Jul 7, 2010 at 8:22 PM, Marcus Stöhr  
>>> wrote:
 Hello.
 
 I have a strange problem: I have a form where I add an CSFR-Protection 
 using Zend_Form_Element_Hash.
 When I call the form, a new session is correctly created in the database. 
 But when I submit the form, I get a validation error stating that the 
 provided hash doesn't match the saved one. The funny part is that this 
 exactly form already worked and I haven't changed anything that could 
 cause this (well, I did not activly changed anything).
 
 Any suggestions how to track down this error?
 
 - Marcus
>>> 
>>> 
>>> 
>>> --
>>> Greetings,
>>> Christian Riesen
>>> http://christianriesen.com/ - My personal page
>>> http://toreas.com/ - Toreas a free fantasy novel
>>> http://gamewiki.net/ - Open Videogames Wiki
>> 
>> 
> 
> 
> 
> -- 
> Greetings,
> Christian Riesen
> http://christianriesen.com/ - My personal page
> http://toreas.com/ - Toreas a free fantasy novel
> http://gamewiki.net/ - Open Videogames Wiki



Re: [fw-general] Problems with Zend_Form_Element_Hash

2010-07-08 Thread Chris Riesen
On Register_Controller.php here
https://gist.github.com/c66b22f11bbe138df6ad delete or comment out
lines 22 and 23 then retry. I think that might be the problem there.

On Thu, Jul 8, 2010 at 9:18 AM, Marcus Stöhr  wrote:
> Hi Chris.
>
> The only redirect action I have fires only when the form is valid and the 
> user saved in the database. Here is some sample code (I stripped out some 
> things not relevant):
>
> https://gist.github.com/c66b22f11bbe138df6ad
>
> I use the actual trunk of Zend Framework and tried also the latest release 
> 1.10.6 but the problems stays the same.
>
> - Marcus
>
> Am 07.07.2010 um 21:36 schrieb Chris Riesen:
>
>> It get's set and reset at every load. Are you by chance using any
>> forwarders or redirects? It gave me the error when I sent a form,
>> validated it and the went back with the browser button to the form
>> again and tried sending it again (of course). Maybe you have some
>> code?
>>
>> On Wed, Jul 7, 2010 at 8:22 PM, Marcus Stöhr  
>> wrote:
>>> Hello.
>>>
>>> I have a strange problem: I have a form where I add an CSFR-Protection 
>>> using Zend_Form_Element_Hash.
>>> When I call the form, a new session is correctly created in the database. 
>>> But when I submit the form, I get a validation error stating that the 
>>> provided hash doesn't match the saved one. The funny part is that this 
>>> exactly form already worked and I haven't changed anything that could cause 
>>> this (well, I did not activly changed anything).
>>>
>>> Any suggestions how to track down this error?
>>>
>>> - Marcus
>>
>>
>>
>> --
>> Greetings,
>> Christian Riesen
>> http://christianriesen.com/ - My personal page
>> http://toreas.com/ - Toreas a free fantasy novel
>> http://gamewiki.net/ - Open Videogames Wiki
>
>



-- 
Greetings,
Christian Riesen
http://christianriesen.com/ - My personal page
http://toreas.com/ - Toreas a free fantasy novel
http://gamewiki.net/ - Open Videogames Wiki


Re: [fw-general] Problems with Zend_Form_Element_Hash

2010-07-08 Thread Marcus Stöhr
Hi Chris.

The only redirect action I have fires only when the form is valid and the user 
saved in the database. Here is some sample code (I stripped out some things not 
relevant):

https://gist.github.com/c66b22f11bbe138df6ad

I use the actual trunk of Zend Framework and tried also the latest release 
1.10.6 but the problems stays the same.

- Marcus

Am 07.07.2010 um 21:36 schrieb Chris Riesen:

> It get's set and reset at every load. Are you by chance using any
> forwarders or redirects? It gave me the error when I sent a form,
> validated it and the went back with the browser button to the form
> again and tried sending it again (of course). Maybe you have some
> code?
> 
> On Wed, Jul 7, 2010 at 8:22 PM, Marcus Stöhr  
> wrote:
>> Hello.
>> 
>> I have a strange problem: I have a form where I add an CSFR-Protection using 
>> Zend_Form_Element_Hash.
>> When I call the form, a new session is correctly created in the database. 
>> But when I submit the form, I get a validation error stating that the 
>> provided hash doesn't match the saved one. The funny part is that this 
>> exactly form already worked and I haven't changed anything that could cause 
>> this (well, I did not activly changed anything).
>> 
>> Any suggestions how to track down this error?
>> 
>> - Marcus
> 
> 
> 
> -- 
> Greetings,
> Christian Riesen
> http://christianriesen.com/ - My personal page
> http://toreas.com/ - Toreas a free fantasy novel
> http://gamewiki.net/ - Open Videogames Wiki