Programovacie jazyky, rady, poradňa...
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 22 júl 2009, 22:30
Cawte mám kód v server.php kliknem naň dám tam všetko, prepíše to lenže keď pojdem napr. na index a potom zas na server.php tak sa mi to všetko vymaže tu je kód:
Kód: Vybrať všetko
<form action="" method="post">
<b><FONT COLOR='BLACK'>Rcon password:<br></FONT> </b>
<input name="cmd" type="password">
<br>
<form action="" method="post">
<b><FONT COLOR='BLACK'>Názov servera:<br></FONT> </b>
<input name="cmd1">
<br>
<form action="" method="post">
<b><FONT COLOR='BLACK'>gamemod:<br></FONT> </b>
<input name="cmd2">
<br>
<form action="" method="post">
<b><FONT COLOR='BLACK'>filterscipts:<br></FONT> </b>
<input name="cmd3">
<br>
<form action="" method="post">
<b><FONT COLOR='BLACK'>web stránka:<br></FONT> </b>
<input name="cmd4">
<br>
<form action="" method="post">
<b><FONT COLOR='BLACK'>heslo:<br></FONT> </b>
<input name="cmd5">
<br>
<?php
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[0] = "echo Executing Server Config...".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[1] = "lanmode 0".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[3] = "maxplayers 50".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[4] = "port 7777".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[5] = "hostname $_POST[cmd1]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[6] = "gamemode0 $_POST[cmd2]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[7] = "filterscripts $_POST[cmd3]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[8] = "announce 1".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[9] = "query 1".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[10] = "weburl $_POST[cmd4]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[11] = "anticheat 0".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[11] = "password $_POST[cmd5]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
?>
<input type="submit" name="ok" value="Uložiť">
</form>
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 23 júl 2009, 11:10
heh, pekný zlepenec kodu, veď ty nemáš ani základy html, pred každým inputom otvárať nový form a na konci ho iba raz uzavreť? A otvárať/zatvárať súbor pri každom riadku? No nevadí, skús takto
Kód: Vybrať všetko
<form action="" method="post">
<b><FONT COLOR='BLACK'>Rcon password:<br></FONT> </b>
<input name="cmd" type="password">
<br>
<b><FONT COLOR='BLACK'>Názov servera:<br></FONT> </b>
<input name="cmd1">
<br>
<b><FONT COLOR='BLACK'>gamemod:<br></FONT> </b>
<input name="cmd2">
<br>
<b><FONT COLOR='BLACK'>filterscipts:<br></FONT> </b>
<input name="cmd3">
<br>
<b><FONT COLOR='BLACK'>web stránka:<br></FONT> </b>
<input name="cmd4">
<br>
<b><FONT COLOR='BLACK'>heslo:<br></FONT> </b>
<input name="cmd5">
<br>
<?php
if(isset($_POST['ok'])){
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[0] = "echo Executing Server Config...".PHP_EOL;
$lines[1] = "lanmode 0".PHP_EOL;
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
$lines[3] = "maxplayers 50".PHP_EOL;
$lines[4] = "port 7777".PHP_EOL;
$lines[5] = "hostname $_POST[cmd1]".PHP_EOL;
$lines[6] = "gamemode0 $_POST[cmd2]".PHP_EOL;
$lines[7] = "filterscripts $_POST[cmd3]".PHP_EOL;
$lines[8] = "announce 1".PHP_EOL;
$lines[9] = "query 1".PHP_EOL;
$lines[10] = "weburl $_POST[cmd4]".PHP_EOL;
$lines[11] = "anticheat 0".PHP_EOL;
$lines[11] = "password $_POST[cmd5]".PHP_EOL;
file_put_contents('svr/server.cfg',$lines);
}
?>
<input type="submit" name="ok" value="Uložiť">
</form>
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 24 júl 2009, 16:38
no uz to ide len ked zmenim rcon password tak ostatne sa mi zmeni
a ja cem nech sa zmeni len rcon password ostatne nech ostane dik
//autoeditácia príspevku ( 24 Jul 2009, 16:38 )
pls poradte mi
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 24 júl 2009, 16:43
máš dve možnosti:
1) spraviť dva formuláre. Jeden bude iba na heslo, druhý na tie ostatné hodnoty
2) načítať tie hodnoty ešte pred formulárom, a hodnoty nahádzať do tých inputov. Potom sa nahradí hodnota tou istou hodnotou a teda v konečnom dôsledku sa nič nezmení
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 25 júl 2009, 10:00
a ako mam spravit toto?
2) načítať tie hodnoty ešte pred formulárom, a hodnoty nahádzať do tých inputov. Potom sa nahradí hodnota tou istou hodnotou a teda v konečnom dôsledku sa nič nezmení
//autoeditácia príspevku ( 24 Jul 2009, 23:26 )
pls pomozte mi
//autoeditácia príspevku ( 25 Jul 2009, 10:00 )
prosimmm pomoc
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 25 júl 2009, 10:19
jednoduchšie to bude tým prvým spôsobom, a to by si mohol zvládnuť aj sám. Bude to analogicky s tým čo som ti spravil, len to rozdelíš na dve časti. Odstrániš riadok kde sa prepisuje heslo, a v tom druhom bude zase iba heslo bez ostatného.
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 25 júl 2009, 11:03
vobec nechapem co mi tu rozpravas
co mi to pomoze ked dam prec heslo vlastne zvlast? ja som to uz tak mal a aj tak sa mi to vymazalo takze...
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 25 júl 2009, 11:12
Kód: Vybrať všetko
<form action="" method="post">
<b><FONT COLOR='BLACK'>Rcon password:<br></FONT> </b>
<input name="cmd" type="password"><input type="submit" name="ok">
<br>
</form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>Názov servera:<br></FONT> </b>
<input name="cmd1">
<br>
<b><FONT COLOR='BLACK'>gamemod:<br></FONT> </b>
<input name="cmd2">
<br>
<b><FONT COLOR='BLACK'>filterscipts:<br></FONT> </b>
<input name="cmd3">
<br>
<b><FONT COLOR='BLACK'>web stránka:<br></FONT> </b>
<input name="cmd4">
<br>
<b><FONT COLOR='BLACK'>heslo:<br></FONT> </b>
<input name="cmd5">
<br>
<?php
if(isset($_POST['ok'])){
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
if(!empty($_POST['cmd'])){
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
} else {
$lines[0] = "echo Executing Server Config...".PHP_EOL;
$lines[1] = "lanmode 0".PHP_EOL;
$lines[3] = "maxplayers 50".PHP_EOL;
$lines[4] = "port 7777".PHP_EOL;
$lines[5] = "hostname $_POST[cmd1]".PHP_EOL;
$lines[6] = "gamemode0 $_POST[cmd2]".PHP_EOL;
$lines[7] = "filterscripts $_POST[cmd3]".PHP_EOL;
$lines[8] = "announce 1".PHP_EOL;
$lines[9] = "query 1".PHP_EOL;
$lines[10] = "weburl $_POST[cmd4]".PHP_EOL;
$lines[11] = "anticheat 0".PHP_EOL;
$lines[11] = "password $_POST[cmd5]".PHP_EOL;
}
file_put_contents('svr/server.cfg',$lines);
}
?>
<input type="submit" name="ok" value="Uložiť">
</form>
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 25 júl 2009, 11:28
pocuj a ako mam spravyt vsetko tak zvlast bo okey to heslo ide ale ked tam dam gamemode a potom hostname tak sa to vymaze ale heslo ostane takto tako to mam ako to mam spravyt aby to bolo tak ako to heslo? dik
Kód: Vybrať všetko
<form action="" method="post">
<b><FONT COLOR='BLACK'>Rcon password:<br></FONT> </b>
<input name="cmd" type="password"><input type="submit" name="ok" value="Uložiť">
<br>
</form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>Názov servera:<br></FONT> </b>
<input name="cmd1"><input type="submit" name="ok" value="Uložiť">
<br></form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>gamemod:<br></FONT> </b>
<input name="cmd2"><input type="submit" name="ok" value="Uložiť">
<br></form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>filterscipts:<br></FONT> </b>
<input name="cmd3"><input type="submit" name="ok" value="Uložiť">
<br></form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>web stránka:<br></FONT> </b>
<input name="cmd4"><input type="submit" name="ok" value="Uložiť">
<br></form>
<form action="" method="post">
<b><FONT COLOR='BLACK'>heslo:<br></FONT> </b>
<input name="cmd5">
<br>
<?php
if(isset($_POST['ok'])){
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
if(!empty($_POST['cmd'])){
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
} else {
$lines[0] = "echo Executing Server Config...".PHP_EOL;
$lines[1] = "lanmode 0".PHP_EOL;
$lines[3] = "maxplayers 50".PHP_EOL;
$lines[4] = "port 7777".PHP_EOL;
$lines[5] = "hostname $_POST[cmd1]".PHP_EOL;
$lines[6] = "gamemode0 $_POST[cmd2]".PHP_EOL;
$lines[7] = "filterscripts $_POST[cmd3]".PHP_EOL;
$lines[8] = "announce 1".PHP_EOL;
$lines[9] = "query 1".PHP_EOL;
$lines[10] = "weburl $_POST[cmd4]".PHP_EOL;
$lines[11] = "anticheat 0".PHP_EOL;
$lines[11] = "password $_POST[cmd5]".PHP_EOL;
}
file_put_contents('svr/server.cfg',$lines);
}
?>
<input type="submit" name="ok" value="Uložiť">
</form>
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 25 júl 2009, 11:39
to php bude:
Kód: Vybrať všetko
<?php
if(isset($_POST['ok'])){
$lines = file("svr/server.cfg");
if(empty($lines)) $lines[0] = PHP_EOL;
$lines[0] = "echo Executing Server Config...".PHP_EOL;
$lines[1] = "lanmode 0".PHP_EOL;
$lines[3] = "maxplayers 50".PHP_EOL;
$lines[4] = "port 7777".PHP_EOL;
//sem dopíš aj ostatné ktoré neobsahujú premenné
if(!empty($_POST['cmd'])){
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
}
if(!empty($_POST['cmd1'])){
$lines[5] = "hostname $_POST[cmd1]".PHP_EOL;
}
if(!empty($_POST['cmd'])){
$lines[2] = "rcon_password $_POST[cmd]".PHP_EOL;
}
if(!empty($_POST['cmd2'])){
$lines[6] = "gamemode0 $_POST[cmd2]".PHP_EOL;
}
//takto pokračuješ až po poslednú položku
}
file_put_contents('svr/server.cfg',$lines);
}
?>nechce sa mi to celé písať, pozri si komentáre ktoré som ti tam vložil a dorob si to sám. Inak 11. riadok si prepisuješ najprv anticheatom a potom heslom, čiže je to kravina
eror
Medium Star
Príspevky: 457 Registrovaný: 16 nov 2008, 14:19
Bydlisko: GA
Príspevok
od používateľa eror » 25 júl 2009, 12:14
dik moc uz mi to ide...