diff --git a/std-script/compile b/std-script/compile --- a/std-script/compile +++ b/std-script/compile @@ -30,12 +30,14 @@ RUBY_INTERPRETER = "/usr/bin/ruby" PYTHON_INTERPRETER = "/usr/bin/python" PYTHON_CHECKER = "/usr/bin/pyflakes" +PHP_INTERPRETER = "/usr/bin/php" C_OPTIONS = "-O2 -s -static -std=c99 -DCONTEST -lm -Wall" CPLUSPLUS_OPTIONS = "-O2 -s -std=c++11 -static -DCONTEST -lm -Wall" PASCAL_OPTIONS = "-O1 -XS -dCONTEST" JAVA_OPTIONS = "" PYTHON_OPTIONS = "" +PHP_OPTIONS = "-l" # Check for the correct number of arguments. Otherwise, print usage. if ARGV.length == 0 or ARGV.length > 4 @@ -149,7 +151,19 @@ File.chmod(0755, params[:output_file]) FileUtils.cp("#{params[:source_file]}c",params[:output_file]) end - + +when "php" + command = "#{PHP_INTERPRETER} #{PHP_OPTIONS} #{params[:source_file]} 2> #{params[:message_file]}" + if system(command) + File.open(params[:output_file],"w") do |out_file| + out_file.puts "#!#{PHP_INTERPRETER}" + File.open(params[:source_file],"r").each do |line| + out_file.print line + end + end + File.chmod(0755, params[:output_file]) + end + else talk("ERROR: Invalid language specified!") open(params[:message_file],"w") do |f| diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -32,7 +32,7 @@ end def extract_time(t) - puts "TIME: #{t}" + #puts "TIME: #{t}" if (result=/^(.*)r(.*)u(.*)s(.*)kbytes/.match(t)) {:real => result[1], :user => result[2], :sys => result[3], :mem => result[4]} else diff --git a/std-script/judge b/std-script/judge --- a/std-script/judge +++ b/std-script/judge @@ -53,7 +53,7 @@ end language = ARGV[0] -if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" +if language != "c" && language != "c++" && language != "pas" && language != "java" && language != "ruby" && language != "python" && language != "php" log "You specified a language that is not supported: #{language}." exit(127) end diff --git a/std-script/run b/std-script/run --- a/std-script/run +++ b/std-script/run @@ -93,6 +93,7 @@ JAVA_OPTION = "-s set_robust_list -s futex -s clone -s getppid -s clone -s wait4 -p /usr/bin/ -p ./" RUBY_OPTION = "-p /usr/lib64/ -p /lib64/ -p /dev/urandom -p #{sandbox_dir}/#{program_name} -s set_robust_list -s sched_getaffinity -s clock_gettime -s sigaltstack -s pipe2 -s clone -s futex -s openat" PYTHON_OPTION = "-p /usr/lib64/ -p /lib64/ -p /usr/bin/ -p /usr/local/lib64/ -p /usr/local/lib/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p #{sandbox_dir}/#{source_name} -s set_robust_list -s openat -s recvmsg -s connect -s socket -s sendto -E PYTHONNOUSERSITE=yes" +PHP_OPTION = "-p /usr/lib64/ -p/lib64/ -p /usr/bin/ -p #{sandbox_dir}/#{program_name} -p ./#{program_name} -p /usr/share/ -s setfsuid -s setfsgid -s openat -s set_robust_list -s futex " case language when "java" @@ -108,6 +109,8 @@ run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} #{RUBY_OPTION} -i #{input_file_name} -o output.txt /usr/bin/ruby #{program_name} 2>run_result" when "python" run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} #{PYTHON_OPTION} -i #{input_file_name} -o output.txt /usr/bin/python #{program_name} 2>run_result" + when "php" + run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} #{PHP_OPTION} -i #{input_file_name} -o output.txt /usr/bin/php #{program_name} 2>run_result" else # for c++, pascal, we do the normal checking run_command = "#{problem_home}/script/box -a 2 -f -T -t #{time_limit} -m #{mem_limit} -i #{input_file_name} -o output.txt #{program_name} 2>run_result" end