1<?php 2# --------------------------------------------------------------------- 3# rth is a requirement, test, and bugtracking system 4# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net 5# This program is distributed under the terms and conditions of the GPL 6# See the README and LICENSE files for details 7#---------------------------------------------------------------------- 8# ------------------------------------ 9# Bug Update Action Page 10# 11# $RCSfile: results_remote_execution_action.php,v $ 12# $Revision $ 13# ------------------------------------ 14 15include"./api/include_api.php"; 16auth_authenticate_user(); 17$err_message = ""; 18$port=6551; 19 20if ($_POST['command'] != "FILE") 21{ 22 23 $machineList = Array(); 24 25 foreach($_POST['machineList'] as $machineName) 26 { 27 $machineName = gethostbyname($machineName); 28 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 29 30 if (!$socket) 31 { 32 $err_message='socket%20create%20failed'; 33 } 34 else 35 { 36 $result = socket_connect($socket, $machineName, $port); 37 if (!$result) 38 { 39 $err_message='socket%20connect%20failed'; 40 } 41 else 42 { 43 if($_POST['command'] == "START") 44 { 45 sendData($socket,"PREPARE"); 46 $ret = receiveData($socket); 47 } 48 49 if($_POST['command'] == "CHANGE" || $_POST['command'] == "UPDATE") 50 { 51 if($_POST['project'] != "NOCHANGE") 52 { 53 $sendString="$_POST[command],$_POST[project]"; 54 sendData($socket,$sendString); 55 $ret = receiveData($socket); 56 sendData($socket, "END"); 57 $ret = receiveData($socket); 58 } 59 } 60 else 61 { 62 sendData($socket,$_POST['command']); 63 $ret = receiveData($socket); 64 sendData($socket, "END"); 65 $ret = receiveData($socket); 66 } 67 } 68 } 69 } 70 71} 72else 73{ 74 $lines = @file($_FILES['f'][tmp_name]); 75 76 foreach ($lines as $line_num => $line) 77 { 78 #print "$line<br>"; 79 if (preg_match('/^Yes/', $line)) 80 { 81 82 $properties = split(",",$line); 83 84 $name = $properties[2]; 85 $path = $properties[3]; 86 $params = $properties[4]; 87 $type = $properties[6]; 88 $machine = $properties[7]; 89 $priority = $properties[5]; 90 $tempestID = $properties[1]; 91 92 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 93 94 if (!$socket) 95 { 96 $err_message='socket%20create%20failed'; 97 } 98 else 99 { 100 $result = @socket_connect($socket, $machine, $port); 101 if (!$result) 102 { 103 $err_message='socket%20connect%20failed'; 104 } 105 else 106 { 107 $data="SEND,".$name.",".$path.",".$params.",".$tempestID.",".$priority.",".$type; 108 sendData($socket,$data); 109 $ret = receiveData($socket); 110 sendData($socket, "END"); 111 $ret = receiveData($socket); 112 } 113 } 114 } 115 } 116 117} 118 119if($err_message == "") 120{ 121 header('Location: index.php'); 122} 123else 124{ 125 header("Location: error.php?err=$err_message"); 126} 127 128function sendData($socket, $d) 129{ 130 socket_write($socket, $d . "\n", strlen($d)+1); 131} 132 133function receiveData($socket) 134{ 135 return socket_read($socket, 2048); 136} 137 138# ------------------------------------------------------------------ 139# $Log: results_remote_execution_action.php,v $ 140# Revision 1.1 2006/05/03 20:23:13 gth2 141# no message 142# 143# ------------------------------------------------------------------ 144?>