File: 1.17.1a/server/bin/setvar.sh (View as HTML)

  1: #!/usr/bin/php -q
  2: <?php
  3: require("include.php");
  4: $NATS->Start();
  5: 
  6: 
  7: if ($argc!=3)
  8: 	{
  9: 	echo "Usage: setvar.sh var.name value\n";
 10: 	echo " set var.name to var.value (create if new)\n";
 11: 	echo "Usage: setvar.sh -d var.name\n";
 12: 	echo " delete var.name\n";
 13: 	$NATS->Stop();
 14: 	exit();
 15: 	}
 16: 
 17: if ($argv[1]=="-d") // delete
 18: 	{
 19: 	$q="DELETE FROM fnconfig WHERE fnc_var=\"".ss($argv[2])."\"";
 20: 	$r=$NATS->DB->Query($q);
 21: 	echo "Deleted ".$NATS->DB->Affected_Rows()." Variables\n";
 22: 	}
 23: else // update/create
 24: 	{
 25: 	$q="UPDATE fnconfig SET fnc_val=\"".ss($argv[2])."\" WHERE fnc_var=\"".ss($argv[1])."\"";
 26: 	$r=$NATS->DB->Query($q);
 27: 	$res=$NATS->DB->Affected_Rows();
 28: 	if ($res>0) echo "Updated ".$res." Variables\n";
 29: 	else
 30: 		{ // doesn't exist or the same value
 31: 		$q="INSERT INTO fnconfig(fnc_var,fnc_val) VALUES(\"".ss($argv[1])."\",\"".ss($argv[2])."\")";
 32: 		$r=$NATS->DB->Query($q);
 33: 		if ($NATS->DB->Affected_Rows()>0) echo "Inserted ".$NATS->DB->Affected_Rows()." Variables\n";
 34: 		else echo "Failed to update - value the same?\n";
 35: 		}
 36: 	}
 37: 
 38: $NATS->Stop();
 39: 
 40: ?>
 41: