Re: Login from won't work from Home Page
I fixed the problem and I thought I would post the solution here in case someone came across the same problem. After WEEKS of trying to figure it out, I found the solution by accident. I accidentally commented the $components variable in my users_controller.php file and it suddenly started working. I started removing components to narrow down the problem and realized that, for some reason, the Security component was being the cause of these problems. Without it, after submitting I got access to the controller's actions, including login, without a single issue. I have no idea if this is a bug or an expected behavior, if someone knows I would greatly appreciate if you told me. Best, P. On Jan 5, 1:58 am, Ponch316 ponch...@gmail.com wrote: Hello, I've been trying to add a little Login module to my homepage and my Layout. I'm using the Auth component and have the following code: //app_controller.php: function beforeFilter() { $this-Auth-allow('display'); $this-Auth-autoRedirect = false; $this-Auth-fields = array('username' = 'email', 'password' = 'password'); $this-Auth-loginAction = array('admin' = false, 'controller' = 'users', 'action' = 'login'); $this-Auth-loginRedirect = array('controller'='dashboard', 'action'='index'); $this-Auth-logoutRedirect = array('admin' = false, 'controller' = 'pages', 'action' = 'home'); } //users_controller.php function login() { if ($this-Auth-user()) { if (!empty($this-data) $this-data['User']['remember_me']) { $cookie = array(); $cookie['email'] = $this-data['User']['email']; $cookie['password'] = $this-data['User']['password']; $this-Cookie-write('Auth.User', $cookie, true, '+2 weeks'); unset($this-data['User']['remember_me']); } $this-redirect($this-Auth-redirect()); } if(empty($this-data)) { $cookie = $this-Cookie-read('Auth.User'); if (!is_null($cookie)) { if ($this-Auth-login($cookie)) { $this-Session-del('Message.auth'); $this-redirect($this-Auth-redirect()); } else { $this-Cookie-del('Auth.User'); } } } } //(pages) home.ctp and (users) login.ctp ?php echo $form-create('User', array('action' = 'login', 'style'='margin: 5px 0 0 18px;')); echo 'div class = labelE-mail/div'; echo $form-input('email', array('label' = '')); echo 'div class = labelPassword/div'; echo $form-input('password', array('label' = '')); echo $form-input('remember_me', array('type' = 'checkbox','label'='Remember Me')); echo $form-end(array ('label'='Login','class'='b2','style'='margin-top: 13px;')); ? The problem is that the Login only works when I access it directly from /users/login, but if I try to login from the Homepage (or anywhere else for that matter) with the exact same code, it gives me a 404 NOT FOUND error. I've been browsing all over the Internet for a way to do this (a login element or a login form in the layout) but no luck yet. Any idea of what might be happening? Thanks in advance! Ponch 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
Login from won't work from Home Page
Hello, I've been trying to add a little Login module to my homepage and my Layout. I'm using the Auth component and have the following code: //app_controller.php: function beforeFilter() { $this-Auth-allow('display'); $this-Auth-autoRedirect = false; $this-Auth-fields = array('username' = 'email', 'password' = 'password'); $this-Auth-loginAction = array('admin' = false, 'controller' = 'users', 'action' = 'login'); $this-Auth-loginRedirect = array('controller'='dashboard', 'action'='index'); $this-Auth-logoutRedirect = array('admin' = false, 'controller' = 'pages', 'action' = 'home'); } //users_controller.php function login() { if ($this-Auth-user()) { if (!empty($this-data) $this-data['User']['remember_me']) { $cookie = array(); $cookie['email'] = $this-data['User']['email']; $cookie['password'] = $this-data['User']['password']; $this-Cookie-write('Auth.User', $cookie, true, '+2 weeks'); unset($this-data['User']['remember_me']); } $this-redirect($this-Auth-redirect()); } if(empty($this-data)) { $cookie = $this-Cookie-read('Auth.User'); if (!is_null($cookie)) { if ($this-Auth-login($cookie)) { $this-Session-del('Message.auth'); $this-redirect($this-Auth-redirect()); } else { $this-Cookie-del('Auth.User'); } } } } //(pages) home.ctp and (users) login.ctp ?php echo $form-create('User', array('action' = 'login', 'style'='margin: 5px 0 0 18px;')); echo 'div class = labelE-mail/div'; echo $form-input('email', array('label' = '')); echo 'div class = labelPassword/div'; echo $form-input('password', array('label' = '')); echo $form-input('remember_me', array('type' = 'checkbox','label'='Remember Me')); echo $form-end(array ('label'='Login','class'='b2','style'='margin-top: 13px;')); ? The problem is that the Login only works when I access it directly from /users/login, but if I try to login from the Homepage (or anywhere else for that matter) with the exact same code, it gives me a 404 NOT FOUND error. I've been browsing all over the Internet for a way to do this (a login element or a login form in the layout) but no luck yet. Any idea of what might be happening? Thanks in advance! Ponch 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
Containable, bindModel and HABTM problem
Hello, I have a problem with a couple of models that share a HABTM relationship. I've tried two different approaches, but none provide the desired result. Here are they both, I hope you can help me to fix either of them to get the array I need. I'm using the good old Post hasAndBelongsToMany Tag So, let's say I have three posts: Post #1 has Tags 'cool' and 'cakephp' Post #2 has Tag 'cakephp' Post #3 has Tag 'cool' 'dessert' This is the complicated part. What I want to achieve is to get a resultset (array) that has ONLY the posts which DO NOT JUST contain the Tag 'cakephp', and list their tags. i.e., something that looks like this Array ( [0] = Array ( [Post] = Array ( [id] = 1 [title] = Post1 ) [Tag] = Array ( [0] = Array ( [id] = 1 [name] = cool ) ) ) [1] = Array ( [Post] = Array ( [id] = 3 [title] = Post3 ) [Tag] = Array ( [0] = Array ( [id] = 1 [name] = cool ) [1] = Array ( [id] = 3 [name] = dessert ) ) ) My first approach was to use the Containable behavior. It helps me limit the Tags, but it doesnt let me filter the Posts. $this-Post-find('all', array('contain' = array( 'Tag' = array( 'conditions' = array('not'= array('Tag.name' = 'cakephp') ; This approach will return Posts 1, 2 and 3. but it will show a blank [Tag] array for Post #2 which is no good for me, since I don't want the Post to show up at all. The second approach was to use join tables (inner joins), using unbind and bindModel, as detailed by teknoid in his blog (http:// teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/) $this-Post-unbindModel(array('hasAndBelongsToMany'=array('Tag'))); $this-Post-bindModel(array('hasOne'=array( 'PostsTag'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('PostsTag.Post_id = Post.id') ), 'Tag'=array( 'className' = 'Tag', 'foreignKey'=false, 'type'='INNER', 'conditions'=array( 'Tag.id = PostsTag.Tag_id' ); $this-Post-find('all', array(' 'not' = array('Tag.name' = 'cakephp' ; This case almost provides me with the array I want (or at least one that I can use), except for the part that Post #3 will appear twice. One with the 'cool' tag as the result and one with the 'dessert' tag as the result. Also, in this case, the Tags do not nest inside of the [Tag] section of the array, which is desirable. So, my question is: is there a way to tweak any of these two methods to get the result I want?? I tried to provide as many details as I could. If i didn't make myself clear, please let me know. Thanks in advance, Ponch316 --~--~-~--~~~---~--~~ 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: De-sanitize for Text Boxes
I didn't set the encoding for UTF8. Should I? Are there any other encoding related specifications I should follow? Thanks. On Aug 2, 1:41 am, euromark (munich) dereurom...@googlemail.com wrote: just dont sanitize them in the first place the problem must be caused by something else usually cake escapes them automatically is everything UTF-8? especially the db? (careful: utf8 not uft-8 here!) On 2 Aug., 03:34, Ponch316 ponch...@gmail.com wrote: Hi, I'm new to CakePHP and I came across a little problem. I created a scaffold to upload a list of schools to my database and after uploading about 400, I noticed that some of the schools were disappearing both from the scaffold view and the database. Since no one else has access to my system, I realized that the only possible reason for that is that some characters I entered, like apostrophes ('), hyphens (-), and commas (,), caused trouble in the database somehow. I created a new scaffold using Bake and decided use Sanitize::clean() before saving. So far, schools are no longer disappearing, but when I try to edit one of these, the characters are NOT displayed correctly in the text boxes (e.g: O#039;Malley). I tried using the PHP method htmlspecialchars_decode() (http://us.php.net/htmlspecialchars_decode) before sending $this-data to the view but it didn't work, characters are still showing up like that. I was wondering if someone could help me to solve this problem. I don't know if I'm doing something wrong, cuz I'm very surprised that Cake has problems handling special characters, since a lot of last names use apostrophes. If you think I should use a different approach, please let me know as well. Thanks in advance. Ponch316 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
De-sanitize for Text Boxes
Hi, I'm new to CakePHP and I came across a little problem. I created a scaffold to upload a list of schools to my database and after uploading about 400, I noticed that some of the schools were disappearing both from the scaffold view and the database. Since no one else has access to my system, I realized that the only possible reason for that is that some characters I entered, like apostrophes ('), hyphens (-), and commas (,), caused trouble in the database somehow. I created a new scaffold using Bake and decided use Sanitize::clean() before saving. So far, schools are no longer disappearing, but when I try to edit one of these, the characters are NOT displayed correctly in the text boxes (e.g: O#039;Malley). I tried using the PHP method htmlspecialchars_decode() (http://us.php.net/htmlspecialchars_decode) before sending $this-data to the view but it didn't work, characters are still showing up like that. I was wondering if someone could help me to solve this problem. I don't know if I'm doing something wrong, cuz I'm very surprised that Cake has problems handling special characters, since a lot of last names use apostrophes. If you think I should use a different approach, please let me know as well. Thanks in advance. Ponch316 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---