更改文件权限和编辑Htaccess文件

时间:2018-12-17 07:48:47

标签: php jquery .htaccess

下面是一些有关为什么我要问这个question的背景,然后是我提出该问题之前到目前为止所做的一些研究。我希望我问的是正确的问题。通常我们会问错问题,因为我们不完全理解该问题,因此浪费了我们和其他人的时间。

发现问题:

我单击我网站上的一个按钮,该按钮应该将编辑内容保存到文章中。当我单击按钮时,得到以下信息:它变成白色,没有任何变化。

下面是相关按钮的代码。该按钮存在于文件 community / profile.php中。

<button onclick="saveEditedArticle();" class="btn btn-dark btn-lg btn-block" id="edit_postbutton">Save Article</button>

调查问题的初步步骤

我打开了chrome开发工具,以查看可能发生的情况。

1)在Chrome Dev Tools中出现403错误

10jquery.js:8630 POST https://bullbuster.net/community/controllers/article.php 403
send @ jquery.js:8630
ajax @ jquery.js:8166
saveEditedArticle @ (index):591
onclick @ (index):6451

2)I Do Some Research To See What A 403 Error Is

3)我在此问题上使用Google和查找堆栈溢出问题:

403 forbidden error -executing and ajax page

403 Forbidden error when making an ajax Post request

4)我被告知403错误,表明我的文件权限错误

然后我更改以下权限: https://bullbuster.net/community/controllers/article.php

0644 what this means)从

0755 what this means

5)我被告知我的 htaccess 文件可能存在问题:

Header set Access-Control-Allow-Origin "*"

以下是 community / controllers / article.php 中文件的一部分,即使 0755权限

case 'save-edit':

		//echo 'made it';

		$validation = $validate->check($_POST, array(
							'edit_article_category' => array(
								'required' => true,
								),
							'edit_new_post_title' => array(
								'required' => true,
								),
							'edit_new_post_content' => array(
								'required' => true,
								),
							'edit_line_type' => array(
								'required' => true,
								),	/*
							'edit_lbtest-select' => array(
								'required' => true,
								),*/
						));

	    if($validation->passed()){

		$update = $Ambassador->saveEditedArticle();

在两个文件中找到功能 saveEditedArticle

1)community / profile.php

function saveEditedArticle()
      {
        event.preventDefault();

        $("#edit_formatted-tags").val($("#edit_tags").tagsinput('items'));
        //alert(tags);
        //var form = $("#article").serialize();

        //alert(tags);
        $('.selectpicker').selectpicker('setStyle', 'error-input', 'remove');

        $('#new_post_title').removeClass('error-input');
        $('#redactor-uuid-0').removeClass("error-input");

        $.ajax({
          url: './controllers/article.php',
          type: 'post',
          dataType: 'json',
          crossDomain: 'true',
          data:
                $("#edit_article").serialize()
          ,
          success: function(data){


            if(data == 'validation passed'){

                    $('#edit_validation-error').hide();
                    $('#edit_postbutton').attr('disabled', 'true');
                    $('#edit_submission-success').show();

                      setTimeout(function() {

                          //location.reload();
                          var location = window.location.href;
                          window.location = location;
                      }, 1500);

            } else {
                 for (i = 0; i < data.length; i++) {
                    var field = data[i][0];
                    //$('#'+field).addClass("error-input");
                    if(field=='edit_new_post_title'){
                      $('#edit_new_post_title').addClass("error-input");
                    }
                    if(field=='edit_new_post_content'){
                      $('.redactor-editor').addClass("error-input");
                    }
                    $('#'+field).selectpicker('setStyle', 'error-input');
                    $('#edit_validation-error').show();
              }
            }

          }
        });
    }

2)这在文件classes / ambassador.php

	public function saveEditedArticle(){


		$content = Input::get('edit_new_post_content');
		$start = "<img src=\"";
		$end = "\"";

		$image = self::getBetween($content, $start, $end);

		if($image==''){
			$start = "src=\"//www.youtube.com/embed/";
			$end = "\"";
			$image = self::getBetween($content, $start, $end);
			if($image!=''){
				$image = "https://img.youtube.com/vi/" . $image . "/0.jpg";
			}
			if($image==''){
				$start = "//player.vimeo.com/video/";
				$end = "\"";
				$image = self::getBetween($content, $start, $end);
				if($image!=''){
					$link = 'https://vimeo.com/api/v2/video/' . $image . '.php';
					$html_returned = unserialize(file_get_contents($link));
					$image = $html_returned[0]['thumbnail_large'];
				}
			}	
		}

		if($image==''){
			$image = 'img/articles/475-33d0f7b0970af583c001559f19c26911.jpg';
		}

		//$content = str_replace('http://', 'https://', Input::get('new_post_content'));

		$slug1 = strtolower(Input::get('edit_article_category'));
		$slug2 = strtolower(Input::get('edit_new_post_title'));

		$slug2 = preg_replace('/[^a-zA-Z0-9 ]/s', '', $slug2);

		
		$slug = $slug1 . '/' . $slug2;
		$slug = str_replace(' ', '-', $slug);

		$slug = preg_replace ('/-+/', '-', $slug);

		$article_category = Input::get('edit_article_category');
		$article_title = ucwords(Input::get('edit_new_post_title'));
		$article_content = Input::get('edit_new_post_content');
		$line_category_id = Input::get('edit_line_type');
		//$lb_test_id = Input::get('edit_lbtest-select');
		$tags = Input::get('edit_formatted-tags');
		$article_id = Input::get('article_id');

		$update = $this->_db->update('Article', $article_id,
							  array(
							  		'category'=>$article_category,
							  		'title'=>$article_title,
							  		'content'=>$article_content,
							  		'line_category_id'=>$line_category_id,
							  		//'lb_test_id'=>$lb_test_id,
							  		'tags'=>$tags,
							  		'image_preview'=>$image,
							  		'slug'=>$slug
									),
							  'id');

	}

0 个答案:

没有答案