Sessions, phpThumb, SwfUpload, Cake 1.2
Hi Everyone, So here is my issue. I have gotten the phpThumb and SWFupload components working. They upload, create thumbnails and using an ajax call will even post the thumbnails back on the page. There is an issue though. When I went back to only allow people logged in to upload pictures cake would drop my sessions. I tried many different things. I even deleted everything in the view, but my session still did not appear. Finally I decided to restore everything and simply delete: var $components = array('Thumb','SwfUpload'); Once this line was removed my sessions were working. However, at this point nothing else was. The other interesting thing is that the session would end with pages that didn't use either of these components (but use the same controller). Here are the important parts of my controller: (I tried using that before filter thing, but its pointless because my session ends in the component...,) ?php class GalleryPhotosController extends AppController { var $name = 'GalleryPhotos'; var $components = array('Thumb','SwfUpload'); var $helpers = array('Form','Javascript'); function beforeFilter() { if ($this-action == 'add'||$this-action == 'modify') { $this-Session-id($this-params['pass'][0]); $this-Session-start(); } parent::beforeFilter(); } function add($galleryCatId=0){ if ($this-requestAction('/members/isLoggedIn/')){ $memberId =$this-requestAction('/gallery_categories/findMemberId/'. $galleryCatId); if ($memberId==$this-Session-read('Member.id')){ $this-set('galleryCatId',$galleryCatId); $eventId =$this-requestAction('/gallery_categories/findEventId/'. $galleryCatId); $this-set('eventId',$eventId); $this-set('error',false); } else { $this-set('error',true); } } else { $this-set('error',true); } } function upload($galleryCatId,$sessionId,$overwrite=false){ if (isset($this-params['form']['Filedata'])) { // upload the file // use these to configure the upload path, web path, and overwrite settings if necessary $this-SwfUpload-uploadpath = 'fileupload'.DS. $galleryCatId.DS; $this-SwfUpload-webpath = '/fileupload/'. $galleryCatId.'/'; $this-SwfUpload-overwrite = $overwrite; //by default, SwfUploadComponent does NOT overwrite files // if ($this-SwfUpload-upload()) { $this-data['GalleryPhoto']['gallery_category_id'] = $galleryCatId; if (!($file = $this-GalleryPhoto-save($this-data))){ $this-Session-setFlash('Database save failed'); } else { $this-data['GalleryPhoto']['id'] = $this- GalleryPhoto-getLastInsertId(); $this-data['GalleryPhoto']['photo_caption'] = ; $this-data['GalleryPhoto']['photo_filename'] = $galleryCatId.DS.$this-SwfUpload-filename; $this-GalleryPhoto-save($this-data); if(!$this-Thumb-generateThumbnail($this-SwfUpload- uploadpath.$this-SwfUpload-filename,$this-SwfUpload- uploadpath.'tb_'.$this-SwfUpload-filename)){ pr($this-Thumb-errors); } } } else { $this-Session-setFlash($this-SwfUpload- errorMessage); } } } } ? I could also add the components they actually may be useful. I am sure most of you have them though. I didn't include the view because completely deleting everything from it had no effect. My security settings are medium, I have turned off checkUserAgent. Thanks --~--~-~--~~~---~--~~ 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: Sessions, phpThumb, SwfUpload, Cake 1.2
Hey, If you are overwriting your $components variable for that controller, try adding in the Session component. I've got the feeling you'll want to do: var $components = array('Thumb', 'SwfUpload', 'Session'); Cheers, Graham On Mon, 12 Jan 2009 12:43:45 -0800 (PST), Parris presid...@parrisstudios.com wrote: Hi Everyone, So here is my issue. I have gotten the phpThumb and SWFupload components working. They upload, create thumbnails and using an ajax call will even post the thumbnails back on the page. There is an issue though. When I went back to only allow people logged in to upload pictures cake would drop my sessions. I tried many different things. I even deleted everything in the view, but my session still did not appear. Finally I decided to restore everything and simply delete: var $components = array('Thumb','SwfUpload'); Once this line was removed my sessions were working. However, at this point nothing else was. The other interesting thing is that the session would end with pages that didn't use either of these components (but use the same controller). Here are the important parts of my controller: (I tried using that before filter thing, but its pointless because my session ends in the component...,) ?php class GalleryPhotosController extends AppController { var $name = 'GalleryPhotos'; var $components = array('Thumb','SwfUpload'); var $helpers = array('Form','Javascript'); function beforeFilter() { if ($this-action == 'add'||$this-action == 'modify') { $this-Session-id($this-params['pass'][0]); $this-Session-start(); } parent::beforeFilter(); } function add($galleryCatId=0){ if ($this-requestAction('/members/isLoggedIn/')){ $memberId =$this-requestAction('/gallery_categories/findMemberId/'. $galleryCatId); if ($memberId==$this-Session-read('Member.id')){ $this-set('galleryCatId',$galleryCatId); $eventId =$this-requestAction('/gallery_categories/findEventId/'. $galleryCatId); $this-set('eventId',$eventId); $this-set('error',false); } else { $this-set('error',true); } } else { $this-set('error',true); } } function upload($galleryCatId,$sessionId,$overwrite=false){ if (isset($this-params['form']['Filedata'])) { // upload the file // use these to configure the upload path, web path, and overwrite settings if necessary $this-SwfUpload-uploadpath = 'fileupload'.DS. $galleryCatId.DS; $this-SwfUpload-webpath = '/fileupload/'. $galleryCatId.'/'; $this-SwfUpload-overwrite = $overwrite; //by default, SwfUploadComponent does NOT overwrite files // if ($this-SwfUpload-upload()) { $this-data['GalleryPhoto']['gallery_category_id'] = $galleryCatId; if (!($file = $this-GalleryPhoto-save($this-data))){ $this-Session-setFlash('Database save failed'); } else { $this-data['GalleryPhoto']['id'] = $this- GalleryPhoto-getLastInsertId(); $this-data['GalleryPhoto']['photo_caption'] = ; $this-data['GalleryPhoto']['photo_filename'] = $galleryCatId.DS.$this-SwfUpload-filename; $this-GalleryPhoto-save($this-data); if(!$this-Thumb-generateThumbnail($this-SwfUpload- uploadpath.$this-SwfUpload-filename,$this-SwfUpload- uploadpath.'tb_'.$this-SwfUpload-filename)){ pr($this-Thumb-errors); } } } else { $this-Session-setFlash($this-SwfUpload- errorMessage); } } } } ? I could also add the components they actually may be useful. I am sure most of you have them though. I didn't include the view because completely deleting everything from it had no effect. My security settings are medium, I have turned off checkUserAgent. Thanks --~--~-~--~~~---~--~~ 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: Sessions, phpThumb, SwfUpload, Cake 1.2
Graham, Thanks for the response; however, that did not fix the situation. I know the session is dead because when I look at the login area it tells me to log in. The strange thing is that when i go to a different page the session is alive again. It seems that the session just temporarily goes away whenever I include the phpThumb and swfupload components. I don't know why it would even happen with phpThumb. (yea I remove all components, and the session is alive. Leaving only swfupload or thumb will kill it, and yes normal components and other components do work. my captcha component works fine). I may try to use an iframe and just pass all the information into it, but that is causing more problems for sure. Plus it is rather hackish. --~--~-~--~~~---~--~~ 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: Sessions, phpThumb, SwfUpload, Cake 1.2
I am happy to report that the iframe work around did work; however, it did cause a significant amount of grief! There is a security hole now. I could solve it with some round about magic I suppose. Possibly manually creating some sort of checking mechanism. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---