PHP文件的权限问题

Permission issue with PHP file

本文关键字:问题 权限 文件 PHP      更新时间:2023-09-26

我使用的是CMS。当我放入HTML代码时,它是有效的,当我放入像"helloWorld"这样的简单PHP代码时,或者当我尝试连接到数据库时,它都是有效的。但是,当我放入更复杂的PHP代码(如"phpinfo()")或任何SQL语句(如"$reponse = $bdd->query('SELECT * FROM insription_14juin');")时,它都不起作用。我用fiddler得到的信息是

 403 Forbidden
 You don't have permission to access /admin/modules/gestion_articles/updateContenu.php
on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

经过多次测试,我认为JavaScript文件试图将信息加载到PHP文件中,显然当PHP代码很复杂时,JavaScript文件没有访问PHP文件的权限。

这是JavaScript文件:

  $(function() {
$('#savemodif').click(function() {
    $('#formModif').append('<img src="images/ajax-loader.gif" alt="Enregistrement en cours..." id="loadingImg" />');
            var contenu ="";
    var type = $('#type').val();
    if(type == '0')
    {
                tinyMCE.triggerSave();
                contenu = $('#contenu').val();
                contenu = encodeURIComponent(contenu);
    }
    else
    {
                contenu = $('#contenu').val();
                contenu = encodeURIComponent(contenu);
    }
    /* Récupération d'infos nécessaires à la mise à jour */
    var id = $('#idcontenu').val();
    var oldtitre = $('#oldtitre').val();
    /* Récupération des mises à jours */
    var titre = $('#titre').val();
    var date = $('#date').val();
    var publie = 0; if($('#publie').is(':checked')) publie = 1;
            var diapo = '0'; if($('#diapo').is(':checked')) diapo = '1';
    var prive = 0; if($('#prive').is(':checked')) prive = 1;
    $.ajax({
        url: 'modules/gestion_articles/updateContenu_test.php',
        type: 'POST',
        data: 'id='+encodeURIComponent(id)
            + '&oldtitre='+encodeURIComponent(oldtitre)
            + '&titre='+encodeURIComponent(titre)
            + '&date='+encodeURIComponent(date)
            + '&contenu='+contenu
            + '&publie='+encodeURIComponent(publie)
            + '&diapo='+encodeURIComponent(diapo)
                            + '&prive='+encodeURIComponent(prive),
        success: function(result) {
            $('#result').html(result);
            $('#loadingImg').fadeOut(1000, function() {
                $(this).remove();
            });
        }
    });
    $('#oldtitre').attr('value',titre);
    return false;
});
  });

我已经尝试过在cpanel中更改权限,但不起作用。我重命名了每个htaccess文件,它不起作用。

如有任何帮助,我们将不胜感激。

问题终于解决了,它是关于modsecurity的。技术人员告诉我modsecurity有限制。如果您有同样的问题,请与您的提供商联系。

我在上面发布的代码现在运行得很好。

您的问题是对文件系统的权限。我假设你不是服务器管理员。

给你的服务器管理员发一封电子邮件,告诉他发生了什么,他会查看并更改权限。

这只是一个偶然的机会,但每当页面的服务器文件夹中缺少占位符文件时,我在cms上就会遇到类似的消息。比如index.php之类的。

另一件事可能是添加

async: false,

到您的ajax调用,以确保它使用适当的数据运行。