Re: repeated URL

2010-12-09 Thread matsakaw


On Nov 4, 2:35 am, cricket  wrote:
> On Wed, Nov 3, 2010 at 12:23 AM,matsakaw wrote:
>
> > $this->Auth->loginRedirect = array('controller' => 'home');
>
> The plot thickens. What's this controller for? And why do you not
> specify an action? Do you have any routes set up for it?
>

i have routes set up to display the splash page home.ctp after
successful login.
so should it be $this->Auth->loginRedirect = array('controller' =>
'pages', 'action' => 'home');  ??
i don't have a controller named home, just the home.ctp from cake's
default. i just picked up
this loginRedirect thing from another tutorial.

> FYI, it'd be better to remove your comments from posted code, unless
> it's pertinent to the problem, as it makes things very difficult to
> read.

so sorry about those comments.  those were notes for me, as i grapple
on how to
make this Acl/Auth component work. i forgot to erase them before
posting.

> >> I'm wondering if there's something else configured that's
> >> hidden from you.
> > I was also suspecting that.  Maybe ISPConfig's has RewriteBase that is
> > wrong? I can ask web host.
>
> That might be it.
>

there was nothing wrong with web host configurations.

i also tried your foo and bar functions.   i did not see the same
problem, so i suspected that it was coming from Auth.

when i turned  it off (not use loginRedirect), the repeated URL after
login was gone.

so i thought there was really an issue with cake's loginRedirect.  i
googled some more and i found this thread.
http://groups.google.com/group/cake-php/browse_thread/thread/1e4b2be656586591/4c672237428cc978?lnk=gst&q=loginRedirect#4c672237428cc978
i was just so relieved to find out that others were experiencing the
same thing -- because it was beyond my skills to trace where that
weird URL was coming from.

anyway, thanks again for your help.  your clarification on
allow(..., ...) and allowedActions = array(..., ..., ... ) also
explained the erratic behavior of some of my unauthorized pages
because i used them interchangeably in app_controller,
users_controller and groups_controller, not understanding the
difference.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


Re: repeated URL

2010-11-03 Thread cricket
On Wed, Nov 3, 2010 at 12:23 AM, matsakaw  wrote:
>
> $this->Auth->loginRedirect = array('controller' => 'home');

The plot thickens. What's this controller for? And why do you not
specify an action? Do you have any routes set up for it?


> //TODO :        // $this->Auth->allow('display', 'index', 'view');
> //TODO :        find out its difference from $this->Auth->allowedActions =
> array('display', 'index', 'view');

The first is a class method to set the class variable (the second, above).

http://api.cakephp.org/class/auth-component


>        function beforeRender() {
> //TODO :        understand the difference of 'Auth' or 'auth'
> //??            i forgot which tutorial this line came from
> //??            does this mean i have both $Auth and $auth variables? (see
> beforeFilter)
>                $this->set('auth', $this->Auth->user());
>        }

$auth, in this case, is simply a variable set for the view and isn't
"built in". It looks like whoever wrote the tutorial wanted to have
access to the User info while in the view. But that can be done with:

$this->Session->read('Auth.User.x');

(where x is the User field you're after)

FYI, it'd be better to remove your comments from posted code, unless
it's pertinent to the problem, as it makes things very difficult to
read.


> 3. answers to your questions, and (sorry...) some more clarifications
>
>> If you can edit your httpd.conf or virtual host configs, the best
>> thing to do is to set DocumentRoot to:
>>
>> /var/www/web2/web/app/webroot
>
> If i do as you suggested, should i change config.php and the defines
> in the 3 index.phps?

Right. I'd forgotten to cover that. You can leave the top 2 index.php
files as they are. If things are working correctly, they'll never be
read. The one in app/webroot looks correct.

I don't know which config.php you're referring to, sorry.


>>  Is this a shared hosting
>> environment?
> Yes, they are using ISPConfig.
>
>> I'm wondering if there's something else configured that's
>> hidden from you.
> I was also suspecting that.  Maybe ISPConfig's has RewriteBase that is
> wrong? I can ask web host.

That might be it.


> 4. Maraming salamat (thank you in Filipino (from the Philippines) )
> for sharing your experience and time.

Hey, thanks for that. I'm always happy to learn a few words in another
language. "Thank you" is usually the first thing I'd like to know.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


Re: repeated URL

2010-11-02 Thread matsakaw
i have these :
1. users_controller.php

class UsersController extends AppController {

/* 01 http://book.cakephp.org/view/52/name
The $name attribute should be set to the name of the controller.
Usually this is just the plural form of the primary model the
controller uses.

It will be singularized, underscored and then be used to open the
table ??
*/
var $name = 'Users';
var $helpers = array('Html', 'Form', 'Javascript', 'Ajax');

var $components = array('RequestHandler');
// var $components = array('RequestHandler', 'Auth');
// Auth is not necessary here anymore, it was declared in
app_controller already

function login() {
// items commented as suggested
}


function logout() {
//00http://book.cakephp.org/view/643/Preparing-to-Add-Auth
//00Leave empty for now.  now = when initializing aros, acos, groups
and users the first time

//05http://book.cakephp.org/view/327/Simple-User-Authentication
//05Redirect users to this action if they click on a Logout button.
//05All we need to do here is trash the session information:
//05And we should probably forward them somewhere, too...
$this->Session->delete('User');

//00http://book.cakephp.org/view/650/Logout
//00next two lines were added after groups/build_acl, and users/
initDB were visited in browser's URL field
$this->Session->setFlash('Good-Bye');
$this->redirect($this->Auth->logout());
}


function beforeFilter() {
parent::beforeFilter();
//  should display nothing (even if http://localhost/groups/index or
http://localhost/groups/view/2 is typed by guest at browser's URL
field),
//  letting Acl take over authentication ...
$this->Auth->allowedActions = array('index', 'view');
}


2. app_controller.php

class AppController extends Controller {

/*  references :
//00 http://book.cakephp.org/view/643/Preparing-to-Add-Auth;
//00http://book.cakephp.org/view/646/Creating-ACOs;
//01 
http://lemoncake.wordpress.com/2007/07/19/using-authcomponent-and-acl-in-cakephp-12/
//02 
http://www.littlehart.net/atthekeyboard/2007/09/11/a-hopefully-useful-tutorial-for-using-cakephps-auth-component/
//03
http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/
//04
http://www.studiocanaria.com/articles/cakephp_auth_component_users_groups_permissions_revisited

//01It is very import that you include the AclComponent before the
AuthComponent otherwise you will get this funky error message. Fatal
error: Call to a member function check() on a non-object in /var/www/
geoff/cake/cake/libs/controller/components/acl.php on line 87
The reason for this is that Components are started in the order 
they
appear in the $components list, and the AuthComponent does all its
magic at startup, so when Auth tries to use Acl::check() there is no
Acl.

mark_story :
originally (circa buildAcl) :   $components = array('Auth', 'Acl')
changed to (circa build_acl):   $components = array('Acl', 'Auth')
but there was no mention of his reversing to Acl, Auth order in the
cake manual
//01
*/

var $helpers = array('Html', 'Csv');
var $components = array('Acl', 'Auth');

function beforeFilter() {
//00 Configure Authenticate Component
//TODO : understand the difference of authorizing 'actions' with
authorizing 'controllers'
$this->Auth->authorize = 'actions';

//02 Tell Auth what controller / action pair it needs to use to
present the login form.
$this->Auth->loginAction = array('controller' => 'users', 
'action'
=> 'login');

//02 Tell the Auth component where the user should be redirected when
user is logged-out.
$this->Auth->logoutRedirect = array('controller' => 'users',
'action' => 'login');

//02 Tell the Auth component where the user should be redirected after
a successful authentication.
$this->Auth->loginRedirect = array('controller' => 'home');

/*
//00 http://book.cakephp.org/view/646/Creating-ACOs
Create a 'root' or top level ACO called 'controllers'. The purpose of
this root node is to make it easy to allow/deny access on a global
application scope, and allow the use of the Acl for purposes not
related to controllers/actions such as checking model record
permissions.

As we will be using a global root ACO we need to make a small
modification to our AuthComponent configuration. AuthComponent needs
to know about the existence of this root node, so that when making ACL
checks it can use the correct node path when looking up controllers/
actions. In AppController add the following to the beforeFilter: $this-
>Auth->actionPath = 'controllers/';
//00
*/
$this->Auth->actionPath = 'controllers/';

//00 http://book.cakephp.org/view/647/An-Automated-tool-for-cr

Re: repeated URL

2010-11-02 Thread matsakaw
thanks a lot cricket!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


Re: repeated URL

2010-11-02 Thread cricket
On Tue, Nov 2, 2010 at 9:46 AM, matsakaw  wrote:
>
>> What does your Auth config look like?
> What do you mean? What info on Auth config should i post?

You need to configure Auth in AppController::beforeFilter()
http://book.cakephp.org/view/1250/Authentication

>> What does your login have in it?
> users_controller.php has this function.  nothing more than what the
> default cakePHP login has.  asks for username and password.
>
>        function login() {
> // http://book.cakephp.org/view/643/Preparing-to-Add-Auth
> // Authenticate Magic
>
> // http://book.cakephp.org/view/649/Logging-in
>                if ($this->Session->read('Auth.User')) {
>                        $this->Session->setFlash('You are logged in!');
>                        $this->redirect('/', null, false);
>                }
> //
>        }

Try commenting all of that out for now. Just leave login() as an empty method.

>> Are you using mod_rewrite?
> I have these 3 .htaccess and 3 index.php files
> 
> /var/www/web2/web/.htaccess
>
> 
>    RewriteEngine On
>    RewriteRule ^$      app/webroot/    [L]
>    RewriteRule (.*) app/webroot/$1     [L]
> 
>
> 
> /var/www/web2/web/index.php
> contains :
> define('APP_DIR', 'app');
> define('WEBROOT_DIR', 'webroot');
> define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
>
> define('ROOT', dirname(__FILE__));
> // should above be : define('ROOT','/var/www/web2/web');

__FILE__ means the current filename, and dirname() returns the
directory part of the path. So it amounts to the same thing. Better to
leave it as is.


> 
> /var/www/web2/web/app/.htaccess
>
> 
>    RewriteEngine On
>    RewriteRule ^$      webroot/        [L]
>    RewriteRule (.*) webroot/$1         [L]
> 
>
> /var/www/web2/web/app/index.php
> require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
>
>
> 
> /var/www/web2/web/app/webroot/.htaccess
>
> 
>    RewriteEngine On
>    RewriteCond %{REQUEST_FILENAME} !-d
>    RewriteCond %{REQUEST_FILENAME} !-f
>    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
> 
>
> 
> /var/www/web2/web/app/webroot/index.php
> contains :
> define('ROOT', '/var/www/web2/web');
> define('APP_DIR', 'app');
> define('CAKE_CORE_INCLUDE_PATH', '/var/www/web2/web');
>
>
>> Have you checked what headers the server is returning?
> How is this done?

The easiest way is probably with the Firebug or LiveHTTPHeaders
plugins for Firefox.

>> Also, why do you have app in the URL in the first place?
>> Why not set app to be the webserver's root?
> How do I do this?

Actually, I meant, app/webroot, but anyway ...

It depends on what your DocumentRoot is set to for Apache. It looks
like yours is:

/var/www/web2/web/

But, because you do have the .htaccess file in that dir, you shouldn't
need to supply 'app/' in the URL to get a proper Cake request from
Apache. When you request http://abc.domain.com/ Apache should look at
the .htaccess file in that dir and following the rewrite rule pointing
it instead to app/webroot/index.php. It should do the same if
requesting http://abc.domain.com/app (notice those two .htaccess files
both point the request to app/webroot/index.php)

If you can edit your httpd.conf or virtual host configs, the best
thing to do is to set DocumentRoot to:

/var/www/web2/web/app/webroot

If you can do that, for performance benefits, you should also remove
(or rename) all of the .htaccess files and add both "AllowOverride
None" (to tell Apache to ignore .htaccess) and the contents of
app/webroot/.htaccess to the  block in your Apache config.
Putting it all together:

DocumentRoot /var/www/web2/web/app/webroot


AllowOverride None
DirectoryIndex index.php
Order allow,deny
Allow from all


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]



(There's other stuff you'll need that has nothing to do with this
subject, though.)

Now, any request to http://abc.domain.com/ will go to index.php by
default. Anything else you place under webroot (javascript, css, html,
images, whatever) will be served normally, as long as Apache can see
it.

The only downside to doing this is if you've got other stuff in your
DocumentRoot (stats, logs, other shared hosting stuff). If that's the
case, you can deal with it through addition of some RewriteRules in
your config, but that's beyond the scope of this post (I have to get
back to work).

(hint: if possible, set up subdomains for your stats, PHPMySQLAdmin, etc.)

Now, whether that will fix your problem, I don't know. It's been years
since I really got my hands dirty with mod_rewrite and I couldn't say
what's going on with your situation. Is this a shared hosting
environment? I'm wondering if there's something else configured that's
hidden from you. You mentioned that you're only seeing this upon
login. But, what about if you call redirect() in some o

Re: repeated URL

2010-11-02 Thread matsakaw

> What does your Auth config look like?
What do you mean? What info on Auth config should i post?

> What does your login have in it?
users_controller.php has this function.  nothing more than what the
default cakePHP login has.  asks for username and password.

function login() {
// http://book.cakephp.org/view/643/Preparing-to-Add-Auth
// Authenticate Magic

// http://book.cakephp.org/view/649/Logging-in
if ($this->Session->read('Auth.User')) {
$this->Session->setFlash('You are logged in!');
$this->redirect('/', null, false);
}
//
}


> Are you using mod_rewrite?
I have these 3 .htaccess and 3 index.php files

/var/www/web2/web/.htaccess


RewriteEngine On
RewriteRule ^$  app/webroot/[L]
RewriteRule (.*) app/webroot/$1 [L]



/var/www/web2/web/index.php
contains :
define('APP_DIR', 'app');
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);

define('ROOT', dirname(__FILE__));
// should above be : define('ROOT','/var/www/web2/web');


/var/www/web2/web/app/.htaccess


RewriteEngine On
RewriteRule ^$  webroot/[L]
RewriteRule (.*) webroot/$1 [L]


/var/www/web2/web/app/index.php
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';



/var/www/web2/web/app/webroot/.htaccess


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]



/var/www/web2/web/app/webroot/index.php
contains :
define('ROOT', '/var/www/web2/web');
define('APP_DIR', 'app');
define('CAKE_CORE_INCLUDE_PATH', '/var/www/web2/web');


> Have you checked what headers the server is returning?
How is this done?


> Also, why do you have app in the URL in the first place?
> Why not set app to be the webserver's root?
How do I do this?

thanks, i hope these info help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


Re: repeated URL

2010-10-31 Thread cricket
On Sun, Oct 31, 2010 at 8:23 AM, matsakaw  wrote:
> example: say my site is http://abc.domain.com/app
> it has a user's login method in users controller. but when a user logs
> in to the site, the URL becomes http://abc.domain.com/app/http:/abc.domain.com
> producing a Not Found Error : The requested address 'http:/
> abc.domain.com' was not found on this server.
> Nevertheless, all the menus i have can be subsequently called, only
> the initial page after login produces that error.
>
> any ideas how to avoid this?  what term should i google to understand
> what is causing the repeated URL?
>
> i am using cake 1.2. it is web hosted using ISPConfig.

You'll need to provide more info. What does your Auth config look
like? What does your login have in it? Are you using mod_rewrite? Have
you checked what headers the server is returning?

Also, why do you have app in the URL in the first place? Why not set
app to be the webserver's root?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en


repeated URL

2010-10-31 Thread matsakaw
example: say my site is http://abc.domain.com/app
it has a user's login method in users controller. but when a user logs
in to the site, the URL becomes http://abc.domain.com/app/http:/abc.domain.com
producing a Not Found Error : The requested address 'http:/
abc.domain.com' was not found on this server.
Nevertheless, all the menus i have can be subsequently called, only
the initial page after login produces that error.

any ideas how to avoid this?  what term should i google to understand
what is causing the repeated URL?

i am using cake 1.2. it is web hosted using ISPConfig.

thanks for any leads

matsakaw

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en