/!\ IMPORTANT Laisser en http (nécessaire) curl_setopt($ch, CURLOPT_URL, "http://art-dambrine.ovh:".$port); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); //echo $output; if($output == null){ //echo $port.' is unused port
'; return $port; } else { echo 'Robot is busy.
'; if($port == $max_port) return false; } } } //function isWorkingSite($url) function isSiteAvailible($url){ // Check, if a valid url is provided if(!filter_var($url, FILTER_VALIDATE_URL)){ return false; } // Initialize cURL $curlInit = curl_init($url); // Set options curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10); curl_setopt($curlInit,CURLOPT_HEADER,true); curl_setopt($curlInit,CURLOPT_NOBODY,true); curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true); // Get response $response = curl_exec($curlInit); // Close a cURL session curl_close($curlInit); return $response?true:false; } /* Projet learning 2019 */ include("head.php"); include("entete.php"); $regex_url = "%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu" ; $url = $_POST['URL']; $urlIsVerified = false; $clean_url = $url; if (preg_match($regex_url, $url)) { $scheme = parse_url($url, PHP_URL_SCHEME); $domain = parse_url($url, PHP_URL_HOST); $clean_url = $scheme."://".$domain; $urlIsVerified = true; } ?>

Robot Index


= 50){ $iterations = 50; } echo'

'; if ($launchJava = isSiteAvailible($_POST['URL'])){ echo $clean_url; } else { echo '

Désolé ' . $url .' n\'est pas une url valide pour notre robot
'; echo 'Pouvez vous utiliser une url copiée directement
depuis la barre d\'adresse du navigateur ? :)

'; } echo'

'; echo '

'; echo '
'; echo 'Pages à visiter : '. $iterations; echo '
'; // Tester si $_POST['URL'] est une URL valide // Checkin what port to use for the JAVA Robot WebServer $available_port = availablePort(8085, 8088); echo 'Notification port : ' . $available_port .'
'; $java_shell_exec = "cd /var/www/java && nohup java -cp mysql-connector-java.jar:RobotIndex.jar robotindex.RobotIndex " .$clean_url. " " . $iterations . " " .$available_port." &"; // code JAVA exec if($launchJava && $urlIsVerified && $available_port!=false){ //echo 'Launch JAVA cmd :' . $java_shell_exec; echo '
'; // to execute a command in background <3 pclose(popen($java_shell_exec, 'r')); } else { echo 'Essayer une url differente.'; } echo '

'; ?>

Dialog-box: