forked from science-ation/science-ation
Dennis: Changes required for Windows OS IIS or Apache web servers. Windows with Apache needs more work.
This commit is contained in:
parent
17f6feee93
commit
648d3f3e56
@ -29,6 +29,12 @@
|
||||
require_once('judges.inc.php');
|
||||
require_once('anneal.inc.php');
|
||||
|
||||
// INFO ONLY: Re Windows OS. I have not found a test that works for both methods of starting this
|
||||
// SERVER_ADDR is Always null in Windows OS IIS server
|
||||
// when I launch using judges_sa_launcher_apache.php I could test using SERVER_NAME
|
||||
// However when I Launch using $WshShell->run($bat_filename,0,false ); for Windows IIS it seems:
|
||||
// All the $_SERVER variables are set as if were a website page so any variable I have tried will cause a bailout
|
||||
// THUS.. There is no test I have found to verify this was run from the command line (or in background) for Windows
|
||||
if($_SERVER['SERVER_ADDR']) {
|
||||
echo "This script must be run from the command line";
|
||||
exit;
|
||||
|
@ -6,10 +6,54 @@ if(!file_exists("../data/logs"))
|
||||
|
||||
if(!file_exists("../data/logs/.htaccess"))
|
||||
@file_put_contents("../data/logs/.htaccess","Order Deny,Allow\r\nDeny From All\r\n");
|
||||
|
||||
// Check which OS we are running
|
||||
$pos = strpos(getcwd(),'/');
|
||||
if($pos === false)
|
||||
{
|
||||
// Windows os server.
|
||||
// if IIS Web Server use WScript.Shell 'run' command and.. we need a batch file to start a process and return immediately
|
||||
$bat_filename = "../data/judges_sa.bat";
|
||||
if(file_exists($bat_filename)){
|
||||
// delete the batch file then re-create it with the current date
|
||||
unlink($bat_filename);
|
||||
}
|
||||
$bat_file = fopen($bat_filename, "w");
|
||||
if($bat_file) {
|
||||
fwrite($bat_file, "ECHO OFF"."\n");
|
||||
fwrite($bat_file, "START /BELOWNORMAL /B php judges_sa.php >../data/logs/judge_scheduler_".date("YmdHis").".log 2>&1 &"."\n");
|
||||
fwrite($bat_file, "EXIT"."\n");
|
||||
fclose($bat_file);
|
||||
}
|
||||
$WshShell = new COM("WScript.Shell");
|
||||
// next line designed for Windows os with IIS web server. It will probably fail if Windows using apache web server
|
||||
try {
|
||||
$oExec = $WshShell->run($bat_filename,0,false ); // THIS SHOULD WORK for windows using IIS as webserver.
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// if the wshshell-> run fails then we are perhaps running an apache server and the next might work.
|
||||
// But, the call in judges_sa_launcher_apache.php does not return until completed so I use this logic
|
||||
// to inform the user how to get to the status page.
|
||||
// CAUTION: This path REQUIRES that php be compiled with CLI option and other things Dennis does not understand!
|
||||
// This may work for some servers. NEVER use this on a shared server - you will hog it and get your account suspended.
|
||||
echo " This server requires manual intervention to start the scheduler and to navigate to the Status page.<br/>";
|
||||
echo " The scheduler will run at normal priority - which in some servers may present a sluggish response.<br />";
|
||||
echo " Please follow these instruction exactly:<br />";
|
||||
echo " 1. Click 'Start the Scheduler' link ONCE. (You will not see any change in this screen) <br />";
|
||||
echo " *** DO NOT Click 'Start the Scheduler' more than once!<br />";
|
||||
echo " 2. Click 'Check the Status' link and wait. (You will be taken to the Status Page. There, you should see that the scheduler is running.) <br />";
|
||||
echo "<br /><a href=\"judges_sa_launcher_apache.php\">Start the Scheduler</a><br /><br />";
|
||||
echo "<a href=\"judges_scheduler_status.php\">Check the Status</a><br />";
|
||||
exit;
|
||||
// This is the call that works - but it does not return until judges_sa is finished so... I launch it from another window
|
||||
// exec("php judges_sa.php >../data/logs/judge_scheduler_".date("YmdHis").".log 2>&1 &");
|
||||
}
|
||||
}
|
||||
else{
|
||||
// *nix server
|
||||
//add PHP_SELF just so when we do a process listing on the server we know which fair its running for
|
||||
//the argument does not get used by the script at all
|
||||
exec("nice php judges_sa.php {$_SERVER['PHP_SELF']} >../data/logs/judge_scheduler_".date("YmdHis").".log 2>&1 &");
|
||||
}
|
||||
usleep(1500000); // 1.5 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon
|
||||
header("Location: judges_scheduler_status.php");
|
||||
exit;
|
||||
|
6
admin/judges_sa_launcher_apache.php
Normal file
6
admin/judges_sa_launcher_apache.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
// In Windows OS with Apache server this exec call will start judges_sa.php as a separate process but the call to exec() does not return until the scheduler completes. Note the process runs at normal priority. Status can be checked with judges_scheduler_status.php. This is a temporary solution for Windows / Apache
|
||||
exec("php judges_sa.php >../data/logs/judge_scheduler_".date("YmdHis").".log 2>&1 &");
|
||||
exit;
|
||||
?>
|
||||
|
@ -151,6 +151,7 @@ echo "<br />";
|
||||
echo "<a href=\"reports.php\">".i18n("Print/Export Reports")."</a>";
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo "Note: If you are using Windows Internet Explorer and do not see status updates do this:<br /> Click menu bar 'Tools' then 'Internet Options'.<br /> In the 'General' Tab under 'Browsing history' click 'Settings'.<br /> Under 'Check for newer versions of stored pages:'<br /> Select the option 'Every time I visit the webpage'.<br /> Click OK then OK";
|
||||
}
|
||||
send_footer();
|
||||
|
||||
|
@ -435,7 +435,7 @@ $(document).ready(function(){
|
||||
</script>
|
||||
<?
|
||||
//if we're under /admin or /config we also want the translation editor
|
||||
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
|
||||
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config" || substr(getcwd(),-6)=="\\admin" || substr(getcwd(),-7)=="\\config")
|
||||
require_once("../translationseditor.inc.php");
|
||||
?>
|
||||
|
||||
@ -636,7 +636,7 @@ else if($title)
|
||||
echo "<h2>".$title."</h2>";
|
||||
|
||||
//if we're under /admin or /config then we want to show the ? help icon
|
||||
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config")
|
||||
if(substr(getcwd(),-6)=="/admin" || substr(getcwd(),-7)=="/config" || substr(getcwd(),-6)=="\\admin" || substr(getcwd(),-7)=="\\config" )
|
||||
{
|
||||
if($_SERVER['REDIRECT_SCRIPT_URL'])
|
||||
$fname=substr($_SERVER['REDIRECT_SCRIPT_URL'],strlen($config['SFIABDIRECTORY'])+1);
|
||||
@ -662,7 +662,13 @@ global $config;
|
||||
//we only show the debug session variables if we have an ODD numbered version.
|
||||
if(substr($config['version'], -1) % 2 != 0)
|
||||
{
|
||||
$revision=exec("svn info |grep Revision");
|
||||
$pos = strpos(getcwd(),'/');
|
||||
if($pos === false){ // Windows OS
|
||||
$revision = "na";
|
||||
}
|
||||
else{
|
||||
$revision=exec("svn info |grep Revision");
|
||||
}
|
||||
$extra=" (Development $revision)";
|
||||
if($_SESSION['debug']=="true")
|
||||
$extra.=" DEBUG: ".print_r($_SESSION,true);
|
||||
@ -697,7 +703,7 @@ function send_popup_header($title="")
|
||||
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/theme/<?=$config['theme']?>/sfiab.css" type="text/css" media="all" />
|
||||
<link media=all href="<?=$config['SFIABDIRECTORY']?>/tableeditor.css" type=text/css rel=stylesheet>
|
||||
</head>
|
||||
<body onload="window.focus()">
|
||||
<body onLoad="window.focus()">
|
||||
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jquery/1.3.2/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/jqueryui/1.7.2/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="<?=$config['SFIABDIRECTORY']?>/js/sfiab.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user