Fix PHP communication with socket

This commit is contained in:
nemunaire 2014-12-28 11:13:50 +01:00
parent e8e0b4478b
commit 7865fbdf1f
2 changed files with 10 additions and 2 deletions

View File

@ -15,9 +15,10 @@ if (count($p) > 2)
case "init":
unlink($VAR["misc_dir"]."/challenge_started");
pipe_backend_scheduler("resetreset:HOME:all:SY");
break;
}
}
header("Location: /".SALT_ADMIN."/");
exit();
exit();

View File

@ -24,15 +24,22 @@ if (is_file($VAR["misc_dir"]."/challenge_started"))
function pipe_backend_scheduler($instruct)
{
global $VAR;
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (is_writable($VAR["scheduler_socket"]) && socket_connect($socket, $VAR["scheduler_socket"]))
{
socket_write($socket, $instruct);
socket_close($socket);
}
else if(defined("DEBUG") && DEBUG)
{
print("Socket '".$VAR["scheduler_socket"]."' is not writable by ".$_SERVER["USER"]." user!");
exit(1);
}
}
if (!empty($VAR['misc_dir']))
$template->assign("MISC_DIR", $VAR['misc_dir']);
if (!empty($LANG))
$template->assign("LANG", $LANG);
$template->assign("LANG", $LANG);