cakephp-2.0

CakePHP cookies not persisting after browser close

蓝咒 提交于 2019-12-10 23:13:23
问题 I am in the process of moving away from Apache in favor of nginx due to the lower resource consumption. I have set up an Ubuntu Server box with the LEMP stack installed. After moving all my applications over (3 CakePHP 2.0.5 apps, 1 Wordpress install), everything seems to be working perfectly except for one thing - Cake's cookies suddenly disappear when the browser is closed. I have created a very simple test PHP page to test if cookies are working at all and they are in fact working, just

CakePHP 2.0 Object not Array

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 23:07:49
问题 I am currently a beginner in CakePHP, and have played around with CakePHP 1.3, but recently CakePHP 2.0 has been released. So far I like it but the only thing is being a pain is the fact that it doesn't return Objects, rather it just returns arrays. I mean, it hardly makes sense to have to do $post['Post']['id']. It is (in my opinion) much more practical to just do $post->id. Now after Google I stumbled upon this link, however, this kept generating errors about indexes not being defined when

CakePHP caching issue when redirecting back to same page

二次信任 提交于 2019-12-10 22:53:52
问题 I'm using CakePHP 2.6 I'm having a problem when I redirect back to the same view from where the request was made. The view seems to be cached, so whatever changes were made during the request are not shown until the page is refreshed again. This means: the user can't see the changes just made. Flash messages are shown on the following view (which is bad). Why is this happening? Things I've checked: My PHP environment has caching turned off My CakePHP configurations are the defaults (see below

Session timeout doesn't work + cakephp

一笑奈何 提交于 2019-12-10 19:06:19
问题 I want to increase my session timeout to around 24 hours and for this I searched net but nothing helped me out. presently my website make the session of around 40 mins after this is expires i want to make this to 24 hours. In my core.php I added these lines Configure::write('Session.timeout', '864'); // Session will last 24h Configure::write('Session.autoRegenerate',true); Configure::write('Security.level', 'medium'); any idea or sugesstion. 回答1: The naming of the CakeSession config

CakePHP 2 can not find plugin

柔情痞子 提交于 2019-12-10 18:50:04
问题 In CakePHP 2 I use @ichikaway's MongoDB plugin like this: public $default = array( 'datasource' => 'mongodb.mongodbSource', 'database' => 'mydbname', 'host' => 'host.mongohq.com', 'port' => 27018, 'login' => 'username', 'password' => 'secret' ); I have placed it in plugins/mongodb yet Cake can not find it and thus can not connect. What am I doing wrong? 回答1: You need to load the plugin in the bootstrap.php file either individually or all of your plugins with CakePlugin::loadAll() Also, keep

CakePHP - Absolute URLs for loginAction

你离开我真会死。 提交于 2019-12-10 18:03:39
问题 Due to the way we've setup our AWS hosting, I have to use absolute URLs for CakePHP's loginAction. Currently, my loginAction looks like this (doesn't work now) 'loginAction' => array('controller' => 'users', 'action' => 'login'), Combine that with a redirect from HTTP -> HTTPS I get a redirect loop. I can prove this by setting an absolute URL like this (works fine) 'loginAction' => array('https://foo.com'), I thought I could just set the final param to true like this 'loginAction' => array(

CakePHP 2.x warning SplFileInfo due to cakeshell

空扰寡人 提交于 2019-12-10 17:36:02
问题 I wrote a cakeshell script which I plan to use it using cronjob. while having run it manually (during testing), sometimes my site will throw SplFileInfo Warning e.g: Warning: SplFileInfo::openFile(/var/www/flat/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in /var/www/flat/lib/Cake/Cache/Engine/FileEngine.php on line 313 Warning (512): SplFileInfo::openFile(/var/www/flat/app/tmp/cache/models/myapp_cake_model_default_flat_list): failed to open

Apply same validation rule for multiple fields

早过忘川 提交于 2019-12-10 16:55:52
问题 How do i apply same validation rule for 50 fields in 2.0 i am not interested in repeating rule for different field public $validate = array( 'company' => array( 'notempty' => array( 'rule' => array('notempty'), 'message' => 'Cannot be Empty', ), ), // rule for other 50 fields.... ); 回答1: Possible solution: $validate_items = array('company', 'other', 'one_more'); $validate_rule = array( 'notempty' => array( 'rule' => array('notempty'), 'message' => 'Cannot be Empty') ); $validate = array();

How to generate secure private urls in CakePHP?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 15:09:36
问题 I like to create a secure URL for a user for his entries (delete and edit links). for ex, this is my actual URL http://localhost/project/blogs/delete/1/test-title what i want to do is, http://localhost/project/blogs/delete/4324143563443/test-title (some hash made of salt+user auth id) My main purpose is to create a secure hash along with the URL for delete and edit method. Is there any custom method's available? I searched in CakePHP Security functions http://book.cakephp.org/2.0/en/core

CakePHP: organise controllers in subfolders

喜你入骨 提交于 2019-12-10 14:22:31
问题 Is it possible in CakePHP to organise controllers (and models) in subfolders? Thanks. 回答1: Yes you can, but it is deprecated. See the discussion here. The last post on this page describes how to do it in the bootstrap. 回答2: It's not deprecated at all. You can accomplish this using the App:build and point to your subfolders. For example, if you want to put all of your Twitter models in Model/Twitter to keep your code organized, you can add the following to the bootstrap.php : App::build(array(