Cancel Php Script With Xhr?
Solution 1:
Any of the following may work:
ignore_user_abort(false);
for ($=0;$i++;$i<1000) {
if (connection_aborted()) break;
for ($=0;$i++;$i<1000) {
if (connection_status() != CONNECTION_NORMAL) break;
Solution 2:
If you have root access on the php server, if you are on linux, you can just execute some bash command, using `:
echo `ps -A`;
get you a list of all running processes on the machine, then if you know the user apache uses to execute scripts, you can then
echo ps -u user
;
After you identify the correct PID you can kill it with:
echo `kill PID`;
ex
echo `kill 1023`;
or
// I do not know if this works exactly this way
eval('echo kill '.$_GET['PID'].'
;');
All of this executed in a different php script, made exactly for the purpose to kill other scripts at command.
You can use AJAX to request this kind of jobs from the script mentioned about.
Also you can make php file write to the client it's own PID (google for the write function, it looks very much like the c one) and then the javascript can send that PID directly to that killer script to command an execution stop for some script.
EDIT 1:
you can get the running script PID with this function:
getmypid();
and you can save it in a file, or better in a session variable
$_SESSION[__FILE__] = getmypid();
and to stop a file from running, you can call a page like this (killer.php):
<?php// security verifications, etc/*
*/
session_start();
$f = $_SESSION[$_GET['file']];
echo `kill $f`;
?>
It is dangerous although.
I do not know the exact commands to execute, or if you have or not that kind of control, or even if you are on a linux system. If you want I can research it a bit.
Best regards,
Solution 3:
$("#click").click(function(){ //window.stop(); return false;
Post a Comment for "Cancel Php Script With Xhr?"