snake Posted June 23, 2010 Report Share Posted June 23, 2010 (edited) Vēlējos uzināt kā es varu uzlikt, lai ja jau tāds servers ir text failā scripts to nepievieno. Lūk kods <?php //TE noradi kura faila bus visi dati $datufails = "lgsl_servers.html"; //Shite uz aatro naviagcija echo "<a href=\"?id=1\">Pievienot serveri</a> <br><br><br>"; //Ja Gribi lai citi redz tavu pieteikumu <a href=\"?id=2\">Pieteikumi</a>"." //Shite uz aatro kkada navigacija ar switchu switch(htmlspecialchars(stripslashes(trim($_GET['id'])))) { case "1": // Sheit bus pieteikuma forma //Ja forma nav apstiprinata taa tiks paradiita if(!isset($_POST['submitted'])) { ?> <form name="forma" method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> Ip/dns: <input type="text" name="vards" size="25"><br> Ports: <input type="text" name="parole" size="25"><br> <input type="submit" value="Pievienot" name="poga"> <input type="hidden" name="submitted" value="TRUE"> </form> <?php //Ja ir apstiprinata tad daram visu ko vajag attiecigi ierakstam failaa.... } elseif(isset($_POST['submitted'])) { // Shis te noraada ja ir noradits kkads teksts un vards if(isset($_POST['parole']) && isset($_POST['vards']) && !empty($_POST['vards']) && !empty($_POST['parole'])) { //rekur tad te buus tavs laiks setlocale(LC_TIME, 'Latvian_Latvia.1257'); // win $datums = strftime("%Y.gada %d.%B"); $laiks = date("H:i:s"); $time = $datums." ".$laiks; //Nedaudz filtrejam lai neiebaro neko $vards = htmlspecialchars(stripslashes(trim($_POST['vards']))); $parole = htmlspecialchars(stripslashes(trim($_POST['parole']))); //rekur mes noradam tekstu un failu, attiecigi atveram ierakstam un aizveram failu $teksts=" ".$vards.":".$parole.":halflife" ; $fails = fopen("$datufails", "a"); fwrite($fails,$teksts); fclose($fails); //paradam ka viss ir veiksmigi ierakstis echo "Serveris pievienots sarakstam"; //Te ja nenorada tekstu parada zinu .... } else { echo "Tu neaizpildiji kadu laucinu"; } //sheit aizveram else } //shiet beidzas pieteikuma forma #4 break; //rekur paradisim pieteikumus (ja tas vajadzigs nonjemiet "//" //default: case "2": $linijas = file("$datufails"); foreach ($linijas as $linija) { //echo htmlspecialchars(stripslashes(trim($linija))) . '<br />'; } break; } ?> Edited June 23, 2010 by snake Quote Link to comment Share on other sites More sharing options...
aldis Posted June 23, 2010 Report Share Posted June 23, 2010 Nesapratu kur tu serveri gribi bāzt, tā ir stacionāra kārba un tā. Bet notestēt, vai tāds fails jau nav uz vietas vari: if (file_exists($TAVSFAILANOSAKUMS)) { echo 'fails jau pastaav'; } else { echo 'Fails nepastaav'; } Kautkā tā, pats pielāgosi noteikti skriptam! :) Quote Link to comment Share on other sites More sharing options...
cunamiX Posted June 23, 2010 Report Share Posted June 23, 2010 Nesapratu kur tu serveri gribi bāzt, tā ir stacionāra kārba un tā. Bet notestēt, vai tāds fails jau nav uz vietas vari: if (file_exists($TAVSFAILANOSAKUMS)) { echo 'fails jau pastaav'; } else { echo 'Fails nepastaav'; } Kautkā tā, pats pielāgosi noteikti skriptam! :) Viņam vajag, lai pārbauda vai tāds serveris jau nav pievienots. Quote Link to comment Share on other sites More sharing options...
codez Posted June 23, 2010 Report Share Posted June 23, 2010 $file='test37.txt'; $v=(string)@$_GET['v']; $p=(string)@$_GET['p']; $txt=$v.":".$p.":halflife\n"; if (!in_array($txt,file($file)) and $v!='' and $p!='') fwrite(fopen($file,'a'),$txt); Quote Link to comment Share on other sites More sharing options...
codez Posted June 23, 2010 Report Share Posted June 23, 2010 Tevi interesē šīs 2 rindiņas: $txt=$vards.":".$parole.":halflife\n"; if (!in_array($txt,file($datufails))) fwrite(fopen($datufails,'a'),$txt); 1. sagatavo tekstu 2. pārbauda vai failā ir tāda rindiņa ar tekstu, ja nav, tad ieraksta pārtaisīju piemēru ar taviem mainīgo nosaukumiem: Kas Jāņu naktī kodē, tam visu gadu labi kodēsies. Quote Link to comment Share on other sites More sharing options...
snake Posted June 24, 2010 Author Report Share Posted June 24, 2010 (edited) Var TC Edited June 24, 2010 by snake Quote Link to comment Share on other sites More sharing options...
Pentiums Posted June 28, 2010 Report Share Posted June 28, 2010 šitie CS tārpi jau līdz kaklam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.