-
Notifications
You must be signed in to change notification settings - Fork 6
/
walkserver.php
632 lines (499 loc) · 22.9 KB
/
walkserver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?php
include("config.php");
include("lib/functions.php");
require_once 'lib/steam-condenser/lib/steam-condenser.php';
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($table) or die(mysql_error());
error_reporting(E_ALL);
ini_set("display_errors", 1);
//SteamSocket::setTimeout(2000);
function getnumbers($data)
{
preg_match("/[0-9]+/i", $data, $value);
return $value[0];
}
function resetplugins( $serverid, $type )
{
mysql_query("UPDATE srv_mods SET status = 'inactive' where serverid = '$serverid' and $type <> 0");
}
function trimv(&$val){return $val = trim($val);}
function go($data,$type,$number,$serverid) {
global $table, $fp, $global, $errors;
$pluginInfo = array( 'Timestamp' => '', 'URL' => '', 'Author' => '' );
// get the mod information
$is_error = strpos($data,'Load error:') !== FALSE;
// split up the lines
$mparray = explode("\n",$data);
// trim white spaces in beginning
array_walk($mparray, create_function( '&$v', '$v = trim( $v );' ) );
// remove last wrong empty line
//array_pop($mparray);
// check for errors , wrong loading mods, take them out
foreach($mparray as $string) {
$string = mysql_real_escape_string($string);
// get the first name, and the data after that
$pos = strpos($string,':');
if($pos) {
// the data itself
$tempname = substr($string,0, $pos);
$pluginInfo[ $tempname ] = substr($string,$pos+2,strlen($string)-$pos-2);
}
}
if (!array_key_exists('Loaded', $pluginInfo))
$pluginInfo['Loaded'] = 'Yes';
if(!$is_error && strpos($pluginInfo['Loaded'], 'Yes') !== FALSE){
// no error, no skip
if ( $type == "sm" && isset( $pluginInfo[ 'Version' ] ) && $pluginInfo[ 'Version' ] && isset( $pluginInfo[ 'Filename' ] ) && $pluginInfo[ 'Filename' ] ) {
$Version = $pluginInfo[ 'Version' ]; $Author = $pluginInfo[ 'Author' ]; $Title = $pluginInfo[ 'Title' ]; $URL = $pluginInfo[ 'URL' ]; $Status = $pluginInfo[ 'Status' ]; $Reloads = $pluginInfo[ 'Reloads' ]; $Timestamp = $pluginInfo[ 'Timestamp' ];
$Filename = preg_replace( '/^.+[\\\\\\/]/', '', $pluginInfo[ 'Filename' ] );
$result = mysql_query("SELECT modid FROM mods WHERE filename = '$Filename' and version = '$Version'");
$row = mysql_fetch_array($result);
$latestid = $row['modid'];
if (mysql_num_rows($result)) {
// it exists in the mod db.
$result2 = mysql_query("SELECT id from srv_mods where modid = (SELECT modid from mods WHERE filename = '$Filename' AND version = '$Version') and serverid = '$serverid'");
if (mysql_num_rows($result2)) {
// it already has a entry in srv_mods, update plugin nr.
mysql_query("UPDATE srv_mods SET pluginnr = '$number', status = 'active' WHERE serverid = '$serverid' AND modid = (SELECT modid from mods WHERE filename = '$Filename' AND version = '$Version')");
// if it does not, it means it has the same version and need to be added.
} else {
mysql_query("INSERT INTO srv_mods (modid,metaid,serverid,status,pluginnr) VALUES($latestid,0,$serverid,'active',$number)");
fwrite( $fp, "Unlinked plugin $Filename ($Version) found, link added to database.\n" );
}
} else {
$result = mysql_query("SELECT threadid from plugindb where filename = '$Filename'");
if ( mysql_num_rows( $result ) ) {
$row = mysql_fetch_array($result);
mysql_query("INSERT INTO mods (filename, title, author, version, url, status, reloads, timestamp, threadid) VALUES('$Filename', '$Title','$Author','$Version','$URL','$Status','$Reloads','$Timestamp','" . $row['threadid'] . "')");
} else
mysql_query("INSERT INTO mods (filename, title, author, version, url, status, reloads, timestamp) VALUES('$Filename', '$Title','$Author','$Version','$URL','$Status','$Reloads','$Timestamp')");
$lastid = mysql_insert_id();
// add the refence table
mysql_query("INSERT INTO srv_mods (modid,extid,metaid,serverid,status,pluginnr) VALUES($lastid,0,0,$serverid,'active',$number)");
fwrite( $fp, "New plugin $Filename ($Version) found, plugin and link added to database.\n" );
}
} elseif ( $type == "mm" && isset( $pluginInfo[ 'Version' ] ) && $pluginInfo[ 'Version' ] && isset( $pluginInfo[ 'File' ] ) && $pluginInfo[ 'File' ] ) {
$Name = $pluginInfo[ 'Name' ]; $Version = $pluginInfo[ 'Version' ]; $Description = $pluginInfo[ 'Description' ]; $URL = $pluginInfo[ 'URL' ]; $Details = $pluginInfo[ 'Details' ];
// remove the dirty path in front of the files
$basefile = preg_replace( '/^.+[\\\\\\/]/', '', $pluginInfo[ 'File' ] );
$result = mysql_query("SELECT metaid FROM metamods WHERE file = '$basefile' and version = '$Version'");
$row = mysql_fetch_array($result);
$latestid = $row['metaid'];
if (mysql_num_rows($result)) {
// it exists in the meta db.
$result2 = mysql_query("SELECT id from srv_mods where metaid = (SELECT metaid from metamods WHERE file = '$basefile' AND version = '$Version') and serverid = '$serverid'");
if (mysql_num_rows($result2)) {
// it already has a entry in srv_mods, update plugin nr.
mysql_query("UPDATE srv_mods SET pluginnr = '$number', status = 'active' WHERE serverid = '$serverid' AND metaid = (SELECT metaid from metamods WHERE file = '$basefile' AND version = '$Version')");
// if it does not, add it.
} else {
mysql_query("INSERT INTO srv_mods (id,modid,metaid,serverid,status,pluginnr) VALUES(NULL,0,$latestid,$serverid,'active',$number)");
fwrite( $fp, "Unlinked plugin $basefile ($Version) found, link added to database.\n" );
}
}
else {
$query = mysql_query("INSERT INTO metamods (metaid, name, version, description, url, details, file) VALUES('NULL', '$Name', '$Version','$Description','$URL','$Details','$basefile')");
// add the refence table
$lastid = mysql_insert_id();
mysql_query("INSERT INTO srv_mods (modid,extid,metaid,serverid,status,pluginnr) VALUES(0,0,$lastid,$serverid,'active',$number)");
fwrite( $fp, "New plugin $basefile ($Version) found, plugin and link added to database.\n" );
}
} elseif ( $type == "ext" && isset( $pluginInfo[ 'Loaded' ] ) && $pluginInfo[ 'Loaded' ] && isset( $pluginInfo[ 'File' ] ) && $pluginInfo[ 'File' ] ) {
$Info = $pluginInfo[ 'Binary info' ]; $Name = $pluginInfo[ 'Name' ];
// remove the dirty path in front of the files
$basefile = preg_replace( '/^.+[\\\\\\/]/', '', $pluginInfo[ 'File' ] );
preg_match( '/.*\(version (.*?)\)/', $pluginInfo[ 'Loaded' ], $version ); $Version = $version[ 1 ];
preg_match( '/(.*)\((.*?)\)/', $pluginInfo[ 'Author' ], $matches ); $Author = $matches[ 1 ]; $Link = $matches[ 2 ];
$result = mysql_query("SELECT extid FROM extensions WHERE file = '$basefile' and version = '$Version'");
$row = mysql_fetch_array($result);
$latestid = $row['extid'];
if (mysql_num_rows($result)) {
// it exists in the meta db.
$result2 = mysql_query("SELECT id from srv_mods where extid = (SELECT extid from extensions WHERE file = '$basefile' AND version = '$Version') and serverid = '$serverid'");
if (mysql_num_rows($result2)) {
// it already has a entry in srv_mods, update plugin nr.
mysql_query("UPDATE srv_mods SET pluginnr = '$number', status = 'active' WHERE serverid = '$serverid' AND extid = (SELECT extid from extensions WHERE file = '$basefile' AND version = '$Version')");
// if it does not, add it.
} else {
mysql_query("INSERT INTO srv_mods (id,modid,metaid,extid,serverid,status,pluginnr) VALUES(NULL,0,0,$latestid,$serverid,'active',$number)");
fwrite( $fp, "Unlinked SourceMod extension $basefile ($Version) found, link added to database.\n" );
}
}
else {
$query = mysql_query("INSERT INTO extensions (extid, name, author, file, version, url, details) VALUES('NULL', '$Name', '$Author','$basefile','$Version','$Link','$Info')");
// add the refence table
$lastid = mysql_insert_id();
mysql_query("INSERT INTO srv_mods (modid,metaid,extid,serverid,status,pluginnr) VALUES(0,0,$lastid,$serverid,'active',$number)");
fwrite( $fp, "New SourceMod extension $basefile ($Version) found, extension and link added to database.\n" );
}
}
} else {
$errors[$type][] = $pluginInfo['File'];
}
// return true;
}
function walker_errorhandler( $errno, $errstr, $errfile, $errline ) {
global $fp;
fwrite( $fp, "Error: ". $errline ." " . $errstr . " on line " . $errline . " in file " . $errfile . "\n" );
//fwrite( $fp, "Error: ". $errline ." " . $errstr . "\n" ); // . " on line $errline in file $errfile";
}
if( isset( $_GET[ 'clean' ] ) ) {
session_start();
unlink( $_SESSION[ 'walkfile' ] );
unset( $_SESSION[ 'servers' ] );
} else if( isset( $_GET[ 'walk' ] ) ) {
set_error_handler("walker_errorhandler");
session_start();
$output = array();
$errors = array();
if( isset( $_GET[ 'init' ] ) ) {
$_SESSION[ 'servers' ] = array();
$_SESSION[ 'walkfile' ] = "cache/walk_" . rand() . ".txt";
$output[ 'file' ] = $_SESSION[ 'walkfile' ];
$result = mysql_query( "SELECT serverid, servername, ip, port, rconpass from servers" . ( isset( $_GET[ 'id' ] ) ? " WHERE serverid='" . mysql_real_escape_string( $_GET[ 'id' ] ) . "'" : "" ) ) or die( "Error retrieving servers: " . mysql_error() ); // retrieve all servers
while( $row = mysql_fetch_array( $result ) )
$_SESSION[ 'servers' ][] = array( $row[ 'serverid' ], $row[ 'servername' ], $row[ 'ip' ], $row[ 'port' ], $row[ 'rconpass' ] );
$output[ 'servers' ] = mysql_num_rows( $result );
$output[ 'next' ] = $_SESSION[ 'servers' ][ 0 ][ 1 ];
} else if( isset( $_GET[ 'next' ] ) ) {
$fp = fopen( $_SESSION[ 'walkfile' ], 'w');
$server = array_shift( $_SESSION[ 'servers' ] );
$serverid = $server[ 0 ];
$name = $server[ 1 ];
$ip = $server[ 2 ];
$port = $server[ 3 ];
$rcon = $server[ 4 ];
$update = 0;
$serverIP = $ip;
$server = new SourceServer( $serverIP, $port );
//$server->initialize();
//fwrite($fp, $server->getPlayers() );
//$info = $server->getServerInfo();
//fwrite ($fp, "$info" );
//echo "$poep";
$error = false;
try {
$server->rconAuth($rcon);
} catch(Exception $e) {
fwrite( $fp, "Unable to Authenticate to server, perhaps down? $serverIP $port $server $rcon" );
$error = $e;
}
if( $error ) {
fwrite( $fp, "Unable to continue" );
// Use below line to check error
//fwrite( $fp, "$error" );
}
else {
fwrite( $fp, "Connection to server established.\n" );
// get all the metamod data
//$res = $srcds_rcon->command("meta list");
try { $res = $server->rconExec('meta list'); } catch(Exception $e) {}
if( $res ) {
resetplugins( $serverid, 'metaid' );
if( strpos( $res, 'Unknown command' ) === false ) {
$m = getnumbers( $res );
fwrite( $fp, $m . " Metamod plugin(s) found, scanning...\n" );
$m++;
for( $i = 1; $i < $m; $i++ ) {
//$mp = $srcds_rcon->command("meta info " . $i );
try { $mp = $server->rconExec('meta info ' . $i ); } catch(Exception $e) {}
if( $mp )
go( $mp, 'mm', $i, $serverid );
}
// get all the sourcemod data - depends on metamod
//$res = $srcds_rcon->command("sm plugins list");
try { $res = $server->rconExec('sm plugins list'); } catch(Exception $e) {}
if( $res ) {
resetplugins( $serverid, 'modid' );
if( strpos( $res, 'Unknown command' ) === false ) {
$m = getnumbers( $res );
fwrite( $fp, $m . " SourceMod plugin(s) found, scanning...\n" );
$m++;
for( $i = 1; $i < $m; $i++ ) {
//$mp = $srcds_rcon->command("sm plugins info " . $i );
try { $mp = $server->rconExec('sm plugins info ' . $i ); } catch(Exception $e) {}
if( $mp )
go( $mp, 'sm', $i, $serverid );
}
// get all the extensions data - depends on sourcemod
//$res = $srcds_rcon->command("sm exts list");
try { $res = $server->rconExec('sm exts list'); } catch(Exception $e) {}
if( $res ) {
resetplugins( $serverid, 'extid' );
$m = getnumbers( $res );
fwrite( $fp, $m . " SourceMod extension(s) found, scanning...\n" );
$m++;
for( $i = 1; $i < $m; $i++ ) {
//$mp = $srcds_rcon->command("sm exts info " . $i );
try { $mp = $server->rconExec('sm exts info ' . $i ); } catch(Exception $e) {}
if( $mp )
go( $mp, 'ext', $i, $serverid );
}
$update = 2;
} else {
fwrite( $fp, "Failed to retrieve list of SourceMod extensions.\n" );
$update = 1;
}
} else {
fwrite( $fp, "SourceMod is not installed on this server.\n" );
$update = 2;
}
} else {
fwrite( $fp, "Failed to retrieve list of SourceMod plugins.\n" );
$update = 1;
}
} else {
fwrite( $fp, "Metamod is not installed on this server.\n" );
$update = 2;
}
} else
fwrite( $fp, "Failed to retrieve list of Metamod plugins.\n" );
//$srcds_rcon->disconnect( );
}
$result = mysql_query( "SELECT * FROM srv_mods WHERE status = 'inactive' and serverid = '" . $serverid . "'" );
while( $row = mysql_fetch_array( $result ) ) {
if( $row[ 'metaid' ] != 0 ) {
$re = mysql_query( "SELECT * FROM metamods WHERE metaid = " . $row[ 'metaid' ] );
$ro = mysql_fetch_array( $re );
$name = $ro[ 'file' ];
$version = $ro[ 'version' ];
$what = 'Metamod plugin';
} else if( $row[ 'modid' ] != 0 ) {
$re = mysql_query( "SELECT * FROM mods WHERE modid = " . $row[ 'modid' ] );
$ro = mysql_fetch_array( $re );
$name = $ro[ 'filename' ];
$version = $ro[ 'version' ];
$what = 'SourceMod plugin';
} else if( $row[ 'extid' ] != 0 ) {
$re = mysql_query( "SELECT * FROM extensions WHERE extid = " . $row[ 'extid' ] );
$ro = mysql_fetch_array( $re );
$name = $ro[ 'file' ];
$version = $ro[ 'version' ];
$what = 'SourceMod extension';
}
fwrite( $fp, "Linked " . $what . " $name ($version) not found, link removed from database.\n" );
}
mysql_query( "DELETE FROM srv_mods WHERE status = 'inactive'" );
fwrite( $fp, "Server update " . ( $update == 0 ? "failed" : ( $update == 1 ? "partially " : "" ) . "completed") . ".\n\n" );
if( count( $_SESSION[ 'servers' ] ) == 0 ) {
//$result = mysql_query( "SELECT file, version FROM `metamods` WHERE ( select count( * ) from srv_mods where srv_mods.metaid = metamods.metaid limit 1 ) = 0" );
//while( $row = mysql_fetch_array( $result ) )
// echo "Metamod plugin " . $row[ 'file' ] . " (" . $row[ 'version' ] . ") not found anywhere, plugin removed from database.\n";
mysql_query( "DELETE FROM `metamods` WHERE ( select count( * ) from srv_mods where srv_mods.metaid = metamods.metaid limit 1 ) = 0" );
//$result = mysql_query( "SELECT filename, version FROM `mods` WHERE ( select count( * ) from srv_mods where srv_mods.modid = mods.modid limit 1 ) = 0" );
//while( $row = mysql_fetch_array( $result ) )
// echo "SourceMod plugin " . $row[ 'filename' ] . " (" . $row[ 'version' ] . ") not found anywhere, plugin removed from database.\n";
mysql_query( "DELETE FROM `mods` WHERE ( select count( * ) from srv_mods where srv_mods.modid = mods.modid limit 1 ) = 0" );
mysql_query( "DELETE FROM `extensions` WHERE ( select count( * ) from srv_mods where srv_mods.extid = extensions.extid limit 1 ) = 0" );
} else
$output[ 'next' ] = $_SESSION[ 'servers' ][0][1];
}
if (count($errors) > 0) {
fwrite($fp, "Following errors encountered:\n");
foreach ($errors as $type => $errors2) {
foreach ($errors2 as $filename) {
fwrite($fp, "\t$type: $filename\n");
}
}
}
// restore_error_handler();
// fclose($fp);
mysql_close();
die( json_encode( $output ) );
}
$start = head();
?>
<script type="text/javascript">
function toggle( id ) {
if( lastid !== false ) {
document.getElementById( "log" + lastid ).style.display = "none";
document.getElementById( "sname" + lastid ).style.fontWeight = "normal";
}
document.getElementById( "log" + id ).style.display = "block";
document.getElementById( "sname" + id ).style.fontWeight = "bold";
lastid = id;
}
var xmlhttp1, xmlhttp2, lastid = false;
function getXMLHTTP() {
var xmlhttp;
if ( window.XMLHttpRequest ) { // Mozilla, Safari,...
xmlhttp = new XMLHttpRequest();
if ( xmlhttp.overrideMimeType )
xmlhttp.overrideMimeType( 'text/xml' );
} else if (window.ActiveXObject) { // IE
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (! xmlhttp ) {
alert('Cannot create XMLHTTP instance.');
return false;
}
return xmlhttp;
}
var walker = {
init: function() {
this.done = true;
this.server = false;
this.servers = false;
this.progress = 0;
this.currid = 0;
this.t = false;
this.fileExists = false;
this.window = document.getElementById( "progress" );
this.window.innerHTML = '';
$( "#progress" ).dialog({
title: 'Update in progress...',
height: 480,
width: 600,
modal: true,
autoOpen: false,
beforeClose: function( event, ui ) {
if( walker.progress == walker.servers ) {
setTimeout( 'walker.init();', 0 );
walker.button( false );
return true;
}
if( confirm( "Are you sure you want to interrupt the update?" ) ) {
setTimeout( 'walker.init();', 0 );
clearTimeout( walker.t );
walker.button( false );
return true;
} else
return false;
}
});
},
button: function( bool ) {
document.getElementById( "completebutton" ).disabled = bool;
document.getElementById( "singlebutton" ).disabled = bool;
document.getElementById( "serverid" ).disabled = bool;
},
start: function( server ) {
this.button ( true );
if( server )
this.request( "init&id=" + server );
else {
this.request( "init" );
var bar = document.createElement( "div" );
bar.id = "progressbar";
this.window.appendChild( bar );
$( "#progressbar" ).progressbar( { value: 0 } );
}
$( '#progress' ).dialog( 'open' );
this.snames = document.createElement( "div" );
this.snames.id = "snames";
this.window.appendChild( this.snames );
},
update: function( ) {
if( !( this.progress == this.servers && this.done == true ) && this.fileExists )
// setTimeout( 'walker.status();', 0 );
document.getElementById( "log" + this.currid ).src = this.file;
else if (!this.fileExists)
this.status();
if( this.done && this.progress < this.servers ) {
this.request( "next" );
this.currid = walker.progress;
this.done = false;
}
if( this.progress < this.servers )
this.t = setTimeout( 'walker.update();', 1000 );
else {
var a = document.createElement( "iframe" );
a.src = "?clean";
a.style.visibility = "hidden";
document.body.appendChild( a );
}
},
request: function( parameter ) {
if(! parameter )
parameter = '';
xmlhttp1 = getXMLHTTP();
xmlhttp1.onreadystatechange = walker.handle;
xmlhttp1.open( 'GET', '?walk&' + parameter, true );
xmlhttp1.send( null );
return false;
},
status: function( ) {
xmlhttp2 = getXMLHTTP();
xmlhttp2.onreadystatechange = walker.statusHandle;
xmlhttp2.open( 'GET', this.file, true );
xmlhttp2.send( null );
return false;
},
statusHandle: function( ) {
if ( xmlhttp2.readyState == 4 ) {
if ( xmlhttp2.status == 200 ) {
walker.fileExists = true;
} else {
}
}
return false;
},
handle: function( ) {
if ( xmlhttp1.readyState == 4 ) {
if ( xmlhttp1.status == 200 ) {
var response = eval( '(' + xmlhttp1.responseText + ')' );
if( walker.servers == false ) {
walker.servers = response.servers;
walker.file = response.file;
} else {
walker.progress += 1;
$( "#progressbar" ).progressbar( { value: ( walker.progress / walker.servers ) * 100 } );
}
if( walker.progress < walker.servers ) {
walker.server = response.next;
$( '#progress' ).dialog( { title: "Updating server: " + walker.server } );
var sname = document.createElement( "a" );
sname.id = "sname" + walker.progress;
sname.innerHTML = walker.server;
sname.href = "javascript:toggle( " + walker.progress + " )";
walker.snames.appendChild( sname );
walker.snames.appendChild( document.createElement( "br" ) );
walker.snames.scrollTop = walker.snames.scrollHeight;
var log = document.createElement( "iframe" );
log.id = "log" + walker.progress;
log.className = "logframe";
walker.window.appendChild( log );
toggle( walker.progress );
if( walker.done ) {
walker.request( "next" );
walker.done = false;
walker.update();
} else
walker.done = true;
} else {
$( '#progress' ).dialog( { title: "Update completed." } );
}
} else {
alert( "Request failed. HTTP status code: " + xmlhttp1.status );
}
}
return false;
}
}
window.onload = function () {
walker.init();
}
</script>
<style>
.ui-progressbar-value { background-image: url(images/pbar-ani.gif); }
</style>
<div class="progress" id="progress"></div>
<input type="button" id="completebutton" onclick="walker.start();" value="Run Complete Walk"/> or
<select id="serverid">
<?php
$result = mysql_query( "SELECT * from servers ORDER BY servername" ) or die( mysql_error() ); // retrieve all servers
while( $row = mysql_fetch_array( $result ) ) // for each result
echo " <option value=\"" . $row['serverid'] . "\">" . $row['servername'] . "</option>\n";
?>
</select>
<input type="button" id="singlebutton" onclick="walker.start( document.getElementById('serverid').value );" value="Walk Server" />
<?php
mysql_close();
bottom($start);
?>