我有一个共同的脚本,我包括在我的PHPcron文件和通过浏览器访问的文件.代码的某些部分,我只需要非cron文件.如何检测执行是来自CLI还是通过浏览器(我知道可以通过传递一些带有cron文件的参数来完成,但我无法访问crontab).还有其他方法吗?
我在我的项目中使用安全组件,有没有办法在开发时获得有关错误的详细描述?例如: - 如果在视图中添加任何字段而不使用cakephp的form方法,则在blackHoleCallback函数中返回错误为'auth'.相反,我需要因为它返回错误的原因.因为它需要花费很多时间来纠正这个问题.有没有办法得到详细的错误描述?
我已经在模型中进行了验证.此外,我已在控制器中进行了一些验证以检查验证码.之后,应用程序不显示模型验证错误.如果我评论控制器代码,模型验证工作正常并显示错误.两个都不工作..
型号代码(样品)
class User extends AppModel {
var $name = 'User';
var $validate = array(
'username' => 'notempty',
'firstname' => 'notempty'
);
Run Code Online (Sandbox Code Playgroud)
}
控制器代码
if (!empty($this->data)) {
$this->User->set($this->data);
$this->User->create();
$captcha = $this->Session->read('CAPTCHA_CODE');
if (strtolower($captcha) != strtolower($this->data['User']['captcha']))
{
$this->User->invalidate('captcha', __('Sorry, your entry did not match', true));
}
if ($this->User->save($this->data, array('validate' => 'only')))
{
if ($this->User->save($this->data, array('validate' => 'false'))) {
$this->Session->setFlash(__('Registered successfully', true));
$this->redirect('success');
}
}else {
$this->Session->setFlash(__('Please, try again.', true));
}
Run Code Online (Sandbox Code Playgroud)
}
我已经更换了if ($this->User->save($this->data, array('validate' => 'only')))
线路if ($this->User->validates()) …
我有使用cakephp 1.3开发的项目和测试我使用SQL Inject me addon(firefox)
从cakephp手册,我理解的是,save()和find()方法将自动保护数据免受SQL注入.但是在运行"SQL注入我"测试时,我总是因此而失败.
例如:结果:服务器状态代码:302 Found测试值:1'AND 1 =(SELECT COUNT(*)FROM tablenames); - 服务器状态码:302找到测试值:'; DESC用户; - 服务器状态码:302找到测试值:1'1
我尝试过cakephp santize方法,然后我也得到了"sql注入我"中的错误.
有帮助吗?
示例代码
$this->data['User'] = Sanitize::clean($this->data['User'], array('encode' => false));
$this->User->save($this->data);
Run Code Online (Sandbox Code Playgroud) 我正在使用amazon-php-sdk.在我的应用程序中,我接受表单中的密钥和秘密值,并通过连接到Aws.这是我的代码.
<?php
require 'aws-autoloader.php';
use Aws\S3\S3Client;
try {
$s3Client = S3Client::factory(array(
'key' => 'my key',
'secret' => 'my secret key'
));
}
catch(S3Exception $e) {
echo 'Msg' . $e->getMessage();
}
?>
Run Code Online (Sandbox Code Playgroud)
我有一个搜索表单,我正在使用GET方法提交它.提交表单后,我需要使用提交的值预先填写表单.如果它是POST,蛋糕将自动处理这个,但它不适用于GET.我使用cakephp的表单助手创建了表单和表单控件.有没有简单的方法来预填字段而不是手动设置每个字段?我正在使用cakephp2.x
我有一个cakephp应用程序,我还有另一个聊天应用程序(非蛋糕),所以为了访问聊天应用程序,我把它放在app/webroot下.从蛋糕,登录后,我使用this-> Session-> write方法设置会话.如何从放置在聊天应用程序中的php脚本中获取此会话值?
我有一个使用flash和php开发的游戏网站.php代码包含4000行,它将作为cron运行.在代码内部,有一个while循环,它将无限运行,用于检查在套接字中写入的任何数据,并相应地调用不同的函数,并将结果发送回套接字.从闪存中,它将获得结果并将显示.
我面临的问题是,从PHP代码的某个地方,它是泄漏内存.由于它非常大,我无法从它发生的地方找到它.而且它只能作为一个cron运行.是否有任何工具可以找出内存泄漏?我听说过xdebug但我没用过.任何其他 ?
check.php(作为cron)
$sock = fsockopen(IP_ADDRESS, PORT, $sock_error_code, $sock_error_string, 10); if (!$sock){
$message = "Server was down, restarting...\n\n";
$last_line = system("php -q gameserver/server.php", $retval);} else {
$message = "Server is up...";
$message .= $sock_error_string." (".$sock_error_code.")\n\n";}
Run Code Online (Sandbox Code Playgroud)
server.php(只是部分)
class gameserver {
var $server_running = true;
function gameserver() {
global $cfg, $db;
$this->max_connections = $cfg["server"]["max-connections"];
$this->start_socket();
echo "Gameserver initialized\n";
while ($this->server_running) {
$read = $this->get_socket_list();
$temp = socket_select($read, $null, $null, 0, 15);
if (!empty($read)) {
$this->read_sockets($read);
}
$db->reconnection();
$this->update_DB_records();
$this->check_games_progress(); …
Run Code Online (Sandbox Code Playgroud) 我正在学习cakephp的ACL功能.我已经走了cakephp docs.为了解更多信息,我检查了一些ACL插件的代码/ db,如croogo和alaxos ACL插件.我可以看到在aros_acos表中,有像_create,_read,_update和_delete这样的列.从这些例子(croogo/alaxos),对于一个动作,例如: - add(在用户控制器下),我可以在_create,_read,_update和_delete列中看到值为1 1 1 1.正如名称所示,add应该只映射到_create(1 0 0 0),对吧?此外,在这种情况下,我们需要4列吗?
我与CRUD模式的动作模式混淆.在我的应用程序中,除了CRUD之外,还有一些功能,如批准,拒绝等.我是否需要为这些操作添加列?或者mapactions适合这种情况(在这种情况下,我是否需要映射控制器中的所有操作)?此外,在我的应用程序中,我需要授予所有者编辑和所有者删除权限.如何以更好的方式使用Cakephp ACL完成所有这些操作?
希望这张图片说明一切...... !!! 需要在html + css中执行此操作.注意:我想要图像中的边框.