我被要求用蛋糕php维护一个项目。客户在他的主机上完美运行了项目,并意外删除了所有内容,然后我被要求将部署重新部署到新主机上。
我做了标准过程,我将所有文件复制到FTP目录,并修复了与数据库.php文件和wordpress组件中的数据库的新连接链接.php(因为该项目与wordpress上的页面集成)以及wp-config.php自己的文件夹中运行WordPress中的其他应用程序。
起初,我在网站上遇到了相当开放的问题,损坏的图像和表单不起作用。我意识到我缺少临时文件夹的权限(在新的FTP新提供程序中上传文件后),然后在内部文件夹核心的临时文件夹中授予了权限755,\ app \ webroot \文件中的"files"文件夹也意识到我的Filezilla损坏了要上传的文件和图像,然后不得不重做整个上传新文件。该网站已恢复工作。
但是我在管理面板的设计上遇到了问题。有一个选项卡用于注册"产品"和"报纸"类型的对象,这些对象是带有图像的文本(表示站点页面上的产品)。
每当我编辑该页面的信息时,我都会收到本主题中提到的错误。"400 错误请求
您的浏览器发送了此服务器无法理解的请求。
更新:我注意到该错误与产品对象信息中加载的表有关。如果我编辑产品,并排除此表,或创建新产品,则错误显示不同,这似乎仅与加载图像的功能有关:
致命错误:在/home/serramar.coop.br/public_html/app/Plugin/upload/Model/Behavior/UploadBehavior.php 第 829 行中找不到类 'imagick'
来自日志的营养致敬
#托管服务器错误日志:
[Tue Mar 22 03:35:19 2016] [error] [client 189.110.14.241] ModSecurity: Access denied with code 400 (phase 2). Pattern match "\\%(?!$|\\W|[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})" at ARGS:data[Product][nutrition]. [id "950107"] [msg "URL Encoding Abuse Attack Attempt"] [severity "WARNING"] [hostname "serramar.coop.br"] [uri "/admin/products/edit/7"] [unique_id "aqC917rtAAIAAENAEKkAAAA2"]
[Tue Mar 22 03:35:19 2016] [error] [client 189.110.14.241] ModSecurity: Audit log: Failed to lock global mutex: Bad file descriptor [hostname "serramar.coop.br"] [uri "/admin/products/edit/7"] [unique_id "aqC917rtAAIAAENAEKkAAAA2"]
[Tue Mar 22 03:35:19 2016] [error] [client 189.110.14.241] ModSecurity: Audit log: Failed to unlock global mutex: Bad file descriptor [hostname "serramar.coop.br"] [uri "/admin/products/edit/7"] [unique_id "aqC917rtAAIAAENAEKkAAAA2"]
#/public_html htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
#/public_html/app htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteBase /webroot/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
#/public_html/app/webroot htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteBase /app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
#产品控制器.php在public_html/应用程序/控制器/产品控制器中.php
<?php
App::uses('AppController', 'Controller');
/**
* Products Controller
*
* @property Product $Product
*/
class ProductsController extends AppController {
public function beforeFilter() {
$directory = $this->webroot . 'files' . DS . 'product' . DS . 'picture' . DS;
$this->set('directory', $directory);
$this->set('tabelanutricional', $this->Product->getTabelaNutricional());
return parent::beforeFilter();
}
/**
* Layout
*
* @var string
*/
public $layout = 'bootstrap';
/**
*
*
* @var array
*/
public $helpers = array('TwitterBootstrap.BootstrapHtml', 'TwitterBootstrap.BootstrapForm', 'TwitterBootstrap.BootstrapPaginator');
/**
* Components
*
* @var array
*/
public $components = array('Session');
public function index($line = null){
$this->layout = 'default';
$this->Product->recursive = 0;
$this->redirect('/#produtos');
}
public function serramar(){
$this->layout = 'default';
$this->Product->recursive = 0;
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'serramar')));
$this->set('products', $products);
$this->set('page', 'produtos');
$this->set('subtitle', 'Conheça a linha de produtos feitos com o mais delicioso leite das fazendas, um privilégio que você pode ter todos os dias em sua casa');
}
public function maringa(){
$this->layout = 'default';
$this->Product->recursive = 0;
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'maringa')));
$this->set('products', $products);
$this->set('page', 'produtos');
$this->set('subtitle', 'A tradição que põe um sabor especial na sua mesa.');
}
public function milkmix(){
$this->layout = 'default';
$this->Product->recursive = 0;
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'milkmix')));
$this->set('products', $products);
$this->set('page', 'produtos');
$this->set('subtitle', 'A saborosa bebida láctea da Serramar em novos e deliciosos sabores: ameixa e laranja. Saiba mais!');
}
public function serramar_all($id = null){
$this->layout = 'ajax';
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'serramar')));
$this->set('products', $products);
$this->set('id', $id);
}
public function milkmix_all($id = null){
$this->layout = 'ajax';
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'milkmix')));
$this->set('products', $products);
$this->set('id', $id);
}
public function maringa_all($id = null){
$this->layout = 'ajax';
$products = $this->Product->find('all', array('conditions'=>array('Product.line'=>'maringa')));
$this->set('products', $products);
$this->set('id', $id);
}
/**
* index method
*
* @return void
*/
public function admin_index() {
$this->Product->recursive = 0;
$this->set('products', $this->paginate());
}
/**
* view method
*
* @param string $id
* @return void
*/
public function admin_view($id = null) {
$this->Product->id = $id;
if (!$this->Product->exists()) {
throw new NotFoundException(__('Invalid %s', __('product')));
}
$this->set('product', $this->Product->read(null, $id));
}
/**
* add method
*
* @return void
*/
public function admin_add() {
if ($this->request->is('post')) {
$this->Product->create();
if ($this->Product->save($this->request->data)) {
$this->Session->setFlash(
__('The %s has been saved', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-success'
)
);
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(
__('The %s could not be saved. Please, try again.', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-error'
)
);
}
}
}
/**
* edit method
*
* @param string $id
* @return void
*/
public function admin_edit($id = null) {
$this->Product->id = $id;
if (!$this->Product->exists()) {
throw new NotFoundException(__('Invalid %s', __('product')));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Product->save($this->request->data)) {
$this->Session->setFlash(
__('The %s has been saved', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-success'
)
);
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(
__('The %s could not be saved. Please, try again.', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-error'
)
);
}
} else {
$this->request->data = $this->Product->read(null, $id);
}
}
/**
* delete method
*
* @param string $id
* @return void
*/
public function admin_delete($id = null) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
}
$this->Product->id = $id;
if (!$this->Product->exists()) {
throw new NotFoundException(__('Invalid %s', __('product')));
}
if ($this->Product->delete()) {
$this->Session->setFlash(
__('The %s deleted', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-success'
)
);
$this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(
__('The %s was not deleted', __('product')),
'alert',
array(
'plugin' => 'TwitterBootstrap',
'class' => 'alert-error'
)
);
$this->redirect(array('action' => 'index'));
}
}
问题解决了!!
再次修复日志后:
[Tue Mar 22 22:30:26 2016] [error] [client 200.100.30.37] ModSecurity: Access denied with code 400 (phase 2). Pattern match "\\% ($ | \\ W | [0-9a-fA-F] {2} | u [0-9a-fA-F] {4}!)" At ARGS: date [Product] [nutrition]. [Id "950107"] [msg "URL Encoding Abuse Attack Attempt"] [severity "WARNING"] [hostname "serramar.coop.br"] [uri "/ admin / products / edit / 7"] [unique_id "RjzfCLrtAAIAAMynquEAAABM" ]
[Tue Mar 22 22:30:46 2016] [error] [client 200.100.30.37] ModSecurity: Access denied with code 400 (phase 2). Pattern match "\\% ($ | \\ W | [0-9a-fA-F] {2} | u [0-9a-fA-F] {4}!)" At ARGS: date [Product] [nutrition]. [Id "950107"] [msg "URL Encoding Abuse Attack Attempt"] [severity "WARNING"] [hostname "serramar.coop.br"] [uri "/ admin / products / edit / 7"] [unique_id "R3HZ1rrtAAIAAKH1tKEAAABr" ]
我看到他拒绝访问产品营养表的内容,代码:
[产品] [营养] https://i.stack.imgur.com/yg7q3.png
我删除了该表,并尝试再次注册产品并给出此错误:
[Tue Mar 22 22:31:46 2016] [error] [client 200.100.30.37] PHP Fatal error: Class 'imagick' not found in /home/serramar.coop.br/public_html/app/Plugin/upload/Model/ Behavior / UploadBehavior.php on line 829, referer: http://serramar.coop.br/admin/products/edit/7
然后我意识到"imagick"类是每个支持PHP的主机的标准类,我怀疑我的客户端的托管不支持php。
我再次将整个项目上传到我拥有的 php 主机(hostgator)中,一切正常。
原因:托管不支持 php。解决方案:托管替代一个具有PHP支持。