CakePHP是一个面向PHP的开源Web快速开发框架,它为开发,维护和部署应用程序提供了可扩展的体系结构。它使用公知的设计模式,如MVC和ORM,在约定范围内超过配置范例。
我想选择所有行不存在的所有行的数据。我认为这会起作用,但没有错误,以下ID仍然出现在检索的记录中。 我正在使用cakephp 2.5用于
我已经在这件事上已经砍了几个小时了。阅读大约7或8个在线教程,但我仍然无法与我的分页进行搜索结果。
$this->set('plans', $this->Plan->find('all', $options));
然后在usercontroller中登录函数: // Login User public function login() { // Check if the user is already logged in if ($this->Session->check('Auth.User.id')){ // Redirect to login page $this->redirect($this->Auth->loginRedirect); } else{ // If the user is not logged in session_set_cookie_params(0); // If the request is a POST request if ($this->request->is('post')) { //get credentials $this->username = $this->request->data['User']['username']; $this->password = $this->request->data['User']['password']; $this->domain = $this->request->data['User']['domain']; //debug($this->username); debug($this->domain) ; if ($this->Auth->login() ) { // Successful login //Check if specific user exists in LDAP: $this->loadModel('LdapUser'); $this->ds = $this->LdapUser->isConnected(); //print_r('Ldap status: '. $this->ds); //debug($this->ds) ; //echo $this->ds; $this->isLdapUser = $this->LdapUser->isLdapUser($this->username . //debug($this->isLdapUser); if ( $this->username =='tsc' || $this->ds ){ if ($this->isLdapUser || 'tsc' ) { // Get all the user information and store in Session $this->User->id = $this->Auth->user('id'); $this->User->contain(array('User', 'Role' => array('Ui', 'Action.name'))); $this->Session->write('User', $this->User->read()); $actions = array(); foreach ($this->Session->read('User.Role.Action') as $key => $value){ array_push($actions, $value['name']); } $this->Session->write('User.Role.Action', $actions); // Render different layout depending on user type if($this->Session->read('User.Role.Ui.name') == Configure::read('usertype.msp')){ $this->Session->write('SessionValues.ui', Configure::read('usertype.msp')); $this->Auth->loginRedirect = array('controller' => 'PortStats', 'action' => 'index'); } else if($this->Session->read('User.Role.Ui.name') == Configure::read('usertype.tsc')){ $this->Session->write('SessionValues.ui', Configure::read('usertype.tsc')); $this->Auth->loginRedirect = array('controller' => 'PortStats', 'action' => 'index'); } else if($this->Session->read('User.Role.Ui.name') == Configure::read('usertype.superAdminUserType')){ $this->Auth->loginRedirect = array('controller' => 'uis', 'action' => 'index'); } // Redirect to main login page $this->redirect($this->Auth->loginRedirect); } else { // Failed login session_destroy(); $this->Session->setFlash(__('Login failed: access not granted'), 'default', array(), 'fail'); } } else { // Failed login session_destroy(); $this->Session->setFlash(__('Login failed: LDAP out of reach'), 'default', array(), 'fail'); } } else { // Failed login $this->Session->setFlash(__('Invalid username or password, please try again'), 'default', array(), 'fail'); } } } } 我得到: Warning (2): ldap_bind() [http://php.net/function.ldap-bind]: Unable to bind to server: Invalid credentials [APP/Model/LdapUser.php, line 56] Warning (512): Model "User" is not associated with model "User" [CORE/Cake/Model /Behavior/ContainableBehavior.php, line 339] 我的猜测是,这可能是platofrms之间有案例敏感性的东西,但确实很困扰,在Ubuntu中不起作用。 [编辑]有我的用户模型: <?php App::uses('AuthComponent', 'Controller/Component'); class User extends AppModel { public $name = 'User'; var $actsAs = array('Containable'); // Define which database to use var $useDbConfig = 'myDb'; // Many-To-One relationship var $belongsTo = array('Role'); // validation of input data public $validate = array( 'username' => array( 'required' => array( 'rule' => 'notEmpty', 'message' => 'A username is required' ), 'isUnique' => array ( 'rule' => 'isUnique', 'message' => 'This username already exists' ) ), 'password' => array ( 'not_empty' => array ( 'rule' => 'notEmpty', 'message' => 'The field "Password" cannot be empty' ), 'between_chars' => array ( 'rule' => array ('between', 4, 10), 'message' => 'Password must be between 4 and 10 chars' ) ), 'passwordVerify' => array( 'not_empty' => array ( 'rule' => 'notEmpty', 'message' => 'The field "Confirm Password" cannot be empty' ), 'match_password' => array ( 'rule' => 'matchPasswords', 'message' => '"Confirm Password" must be the same as "Password"' ) ), 'name' => array( 'required' => array( 'rule' => array('notEmpty'), 'message' => 'A name is required' ) ), 'surname' => array( 'required' => array( 'rule' => array('notEmpty'), 'message' => 'A surname is required' ) ), 'role_id' => array( 'valid' => array( 'rule' => 'notEmpty', 'message' => 'Please enter a valid role', 'allowEmpty' => false ) ), 'oldPassword' => array ( 'match_password' => array ( 'rule' => 'matchOldPassword', 'message' => 'Invalid password' ), 'required' => array ( 'rule' => 'requiredOldPassword', 'message' => '"Current Password" is required if you wish to edit the password' ) ), 'newPassword' => array ( 'required' => array ( 'rule' => 'requiredNewPassword', 'message' => '"New Password" is required if you wish to edit the password' ), 'between_chars' => array ( 'rule' => 'lengthNewPassword', 'message' => 'Password must be between 4 and 10 chars' ) ), 'newPasswordVerify' => array ( 'required' => array ( 'rule' => 'requiredNewPasswordVerify', 'message' => '"Confirm Password" is required if you wish to edit the password' ), 'match_password' => array ( 'rule' => 'matchNewPasswordVerify', 'message' => '"Confirm Password" must be the same as "New Password"' ) ) ); // Verify that password and password verification match when creating a new user public function matchPasswords ($data) { if ($this->data['User']['password'] == $this->data['User']['passwordVerify']) { return true; } else { return false; } } public function matchOldPassword ($data) { if (!empty($this->data['User']['oldPassword'])){ // when an input is given for 'oldPassword'... if ($_SESSION['User']['User']['password'] == AuthComponent::password($this->data['User']['oldPassword'])) { // when password is correct (equal to 'password') return true; } else { // when password is invalid (not equal to 'password') return false; } } return false; // default value when 'oldPassword' is empty } // Verify that a value for 'oldPassword' (current password) is given when 'newPassword' or 'newPasswordVerify' are also given during the procedure of editing the password public function requiredOldPassword ($data) { if (!empty($this->data['User']['newPassword']) || !empty($this->data['User'] ['newPasswordVerify'])){ // when an input is given for 'newPassword' or 'newPasswordVerify'... if (!empty($this->data['User']['oldPassword'])){ // when an input is given for oldPassword... return true; } else { // when no input is given for oldPassword... return false; } } return false; // default value when 'newPassword' and 'newPasswordVerify' are left empty } // Verify that a value for 'newPassword' (current password) is given when public function requiredNewPassword ($data) { if (!empty($this->data['User']['oldPassword']) || !empty($this->data['User']['newPasswordVerify'])){ // when an input is given for 'oldPassword' or 'newPasswordVerify'... if (!empty($this->data['User']['newPassword'])){ return true; } else { // when no input is given for newPassword... return false; } } return false; } // Verify that 'newPassword' has an appropriate length public function lengthNewPassword ($data) { if (!empty($this->data['User']['newPassword'])) { )>=4 && . strlen($this->data['User']['newPassword'])<=10){ // when length is valid.. return true; } else { // when length is invalid... return false; } } return false; // default value when 'newPassword' is left empty } public function matchNewPasswordVerify ($data) { if ($this->data['User']['newPassword'] == $this->data['User'] ['newPasswordVerify']) { return true; } else { return false; } } public function requiredNewPasswordVerify ($data) { if (!empty($this->data['User']['oldPassword']) || !empty($this->data['User']['newPassword'])){ // when an input is given for 'oldPassword' or 'newPassword'... if (!empty($this->data['User']['newPasswordVerify'])){ // when an return true; } else { // when no input is given for newPasswordVerify... return false; } } return false; // default value when 'oldPassword' and 'newPassword' are left empty } // Password stored with SHA1 (cakePHP default) or MD5 hashing algorithm public function beforeSave($options = array()) { if (isset($this->data[$this->alias]['password'])) { $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']); //$this->data['User']['password'] = md5($this->data['User'] ['password']); // MD5 hashing algorithm } return true; } var $hasMany = array( 'MspDashboard' => array( 'className' => 'MspDashboard', 'foreignKey' => 'user_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ) ); } [编辑]: 我倾向于相信警告对我的问题不负责: 它发生在两个平台中,但不应该中断站点的汇集。 当Windows中的调试级别= 2时,我会看到: 但是,在Ubuntu中,我得到的只是这个屏幕: 512关联错误: $this->User->contain(array('User', 'Role' => array('Ui', 'Action.name'))); 改变: $this->User->contain(array('Role' => array('Ui', 'Action.name'))); 不包含模型本身。 LDAP错误似乎是这样的行: $this->exists = ldap_bind($this->ds, $user, $pass); 我将从这样的代码开始进行调试: var_dump($this->ds); var_dump($user); var_dump($pass); $this->exists = ldap_bind($this->ds, $user, $pass); 拷贝 - 将这些数据放入某些LDAP工具中,并首先验证它们是正确的。 尝试此功能以获取更多错误信息: http://php.net/manual/en/function.ldap-error.php ,神秘解决: 警告与此无关: 代码线是错误的: if ($this->isLdapUser || 'tsc' ) { ....... 用户TSC在本地DB中是管理员,并且在LDAP中不存在,因此肯定会从LDAP_BIND中获得时间,看起来Ubuntu平台会在浏览器超时上崩溃我的应用程序。相反,我的本地机器将在时间外等待并继续登录。 我刚刚修改了我的代码,所以管理用户'tsc' 将直接登录而无需从LDAP auth登录。
我如何更正jqgrid页脚信息? 我正在我的一个应用程序之一中使用JQGrid。 现在,我面临一个奇怪的问题,不知道如何纠正它? 实际上,在其中一个报告中(具有多个链接)JQGrid显示错误...
这是运行的代码:
中获取错误消息 element文件“ element/element/navbar.ctp”丢失。 我的cakephp默认布局中的我的代码(因为我想要所有“视图”中的纳维尔)
您在哪里存储 CakePHP 4 Mailer 的配置文件?
我正在 CakePHP 4.5 中编写一个发送电子邮件的应用程序。 我试图避免在我的代码中写满这个 $mailer = new Mailer('默认'); $mailer->setEmailFormat('两者') ->setFrom(['me@exampl...
未捕获的异常“CacheException”,消息为“缓存引擎“_cake_core_”未正确配置 cakephp AWS
我收到以下错误:使用 cakephp、aws。 警告:_cake_core_ 缓存无法将“cake_dev_en-gb”写入 文件缓存在 /var/www/html/myApp/lib/Cake/Cache/Cache.php 第 328 行
函数保存(对象){ var res = obj.id.split("-"); $.ajax({ var url="<?php echo $this->Html->url(array('controller'=>'ajax','action'=>'approveinfo')); ?>"; 类型:“</desc> <question vote="0"> <pre><code><script> function save(obj){ var res = obj.id.split("-"); $.ajax({ var url="<?php echo $this->Html->url(array('controller'=>'ajax','action'=>'approveinfo')); ?>"; type: "POST", data: {status: this.value}, success: function(data) { if(obj.id=='btnyes-'+res[1]){ var yesid='btnyes'+res[1]; document.getElementById('btnyes-'+res[1]).style.display = 'none'; document.getElementById('btnno-'+res[1]).style.display = 'none'; document.getElementById('yes-'+res[1]).style.display = 'block'; document.getElementById('no-'+res[1]).style.display = 'none'; } else if(obj.id=='btnno-'+res[1]) { document.getElementById('btnyes-'+res[1]).style.display = 'none'; document.getElementById('btnno-'+res[1]).style.display = 'none'; document.getElementById('yes-'+res[1]).style.display = 'none'; document.getElementById('no-'+res[1]).style.display = 'block'; } alert("Ajax save executed!"); } } }); } </code></pre> <p></p> <p>这个脚本应该调用ajax函数并将值更新为1或0 基于onclick函数。 但它没有更新..错误是什么? Ajax代码如下</p> <pre><code> public function approveinfo($approve="") { if(!empty($approve)) && ($approve=='yes') { $this->Purchaseorder->updateAll(array('Purchaseorder.approve' =>"1"), else{ $this->Purchaseorder->updateAll(array('Purchaseorder.approve' =>"0"), } $result=array(); array_push($result,$info); echo json_encode($result); exit; } } </code></pre> <p>我应该做什么,以便当我单击“是”时该值更新为 1,当我单击“否”时该值更新为 0</p> </question> <answer tick="false" vote="0"> <p>就像 arilia 所说,您通过 POST 将值传递到控制器操作。您需要做的就是检查帖子值:</p> <pre><code>if($this->request->is('post')){ if(!empty($this->request->data['status'])) && ($this->request->data['status']=='yes'){ } } </code></pre> </answer> </body></html>
CakePHP 在 MariaDB 中将 2024-12-30 存储为 2025-12-30,但 2024-12-29 可以正常工作
我正在开发一个 CakePHP 应用程序,我将日期保存到 MariaDB 数据库中。 absent_date 字段的类型为 DATE。然而,我遇到了一个奇怪的问题: 当我保存 2024-12-30 时,它会...
建筑 商业 电脑服务 文档 电子的 金融 信息通信技术、互联网 基础设施 生产 医疗的 其他(公共办公室等) 贸易公司 这是我的期权价值订单...