-3

i used open source in kitploit

i was execute on webserver this code but occur post 500 error

echo '<script type="text/javascript">';
echo "beginCrawl('$urlToCrawl','$testId');";
echo '</script>';

call beginCrawl on php

<script type='text/javascript'>
function beginCrawl(value, valueTwo){
jQuery.post('crawler/begin_crawl.php', {specifiedUrl:value,testId:valueTwo});
}
</script>

this is define beginCrawl

in the "begin_crawl.php"

isset($_POST['specifiedUrl']) ? $urlToScan = $_POST['specifiedUrl'] : $urlToScan = '';
isset($_POST['testId']) ? $testId = $_POST['testId'] : $testId = 0;

using specifiedUrl and testId

in log, exist "Calling AJAX function beginCrawl()"

but not call "begin_crawl.php" and occur post 500 error

how to fix this error?

DarkMukke
  • 2,469
  • 1
  • 23
  • 31
k. min
  • 13
  • 1
  • 1
  • 5
  • 2
    500 is an internal Server error. look into your logfiles and find out what is happening – Jens Aug 01 '17 at 08:47
  • What Jens said, also, you may want to [enable error reporting](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) while building your app so you will get useful error messages when things go wrong without having to dig through the logs – Wesley Smith Aug 01 '17 at 08:50
  • Also, you say "*in log, exist "Calling AJAX function beginCrawl()"*" but you dont show us where you're logging that in your code so the fact that it is logging it, doesnt really tell us anything – Wesley Smith Aug 01 '17 at 08:52

1 Answers1

-1

I think, you cannot assign a variable inside a ternary operator, in order to use that, you rather use a variable and assign the result of the ternary operator to it. You should change below 2 lines:

isset($_POST['specifiedUrl']) ? $urlToScan = $_POST['specifiedUrl'] : $urlToScan = '';
isset($_POST['testId']) ? $testId = $_POST['testId'] : $testId = 0;

to this lines:

$urlToScan = isset($_POST['specifiedUrl']) ? $_POST['specifiedUrl'] : '';
$testId = isset($_POST['testId']) ? $_POST['testId'] : 0;
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35