*jancis38* Posted December 19, 2007 Report Share Posted December 19, 2007 Kā var uztaisīt, ja lietotājs nav aktīvs *.php failā pieņemsim 20 sekundes tad pec 20 sekundēm tiek dzēsts info kas atrodas *.txt failā? Link to comment Share on other sites More sharing options...
Kavacky Posted December 19, 2007 Report Share Posted December 19, 2007 if ( time() > $lastVisitTime + 20 ) { deleteInfo(); } Link to comment Share on other sites More sharing options...
*jancis38* Posted December 19, 2007 Author Report Share Posted December 19, 2007 kkas pavienkāršās nav, īsti nesapratu. :/ Link to comment Share on other sites More sharing options...
andrisp Posted December 19, 2007 Report Share Posted December 19, 2007 Nē, nav gan. Ja nesaproti, tad jautā, ko tieši nesaproti. Link to comment Share on other sites More sharing options...
*jancis38* Posted December 20, 2007 Author Report Share Posted December 20, 2007 ja godīgi, es tur vsp neko nesaprotu. :( Link to comment Share on other sites More sharing options...
Delfins Posted December 20, 2007 Report Share Posted December 20, 2007 Tad sāc ar kaut ko vienkārsāku. Link to comment Share on other sites More sharing options...
Aleksejs Posted December 20, 2007 Report Share Posted December 20, 2007 *jancis38* Ko Tu esi domājis ar "lietotājs nav aktīvs *.php failā"? Link to comment Share on other sites More sharing options...
*jancis38* Posted December 20, 2007 Author Report Share Posted December 20, 2007 (edited) nu vot, ja es neko tajā *.php failā nedaru (caur browseri) tad lai pēc kkādām 60 sekundēm izdzēšas saturs no *.txt faila. Edited December 20, 2007 by *jancis38* Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 Tā īsti arī nevarēs. To kaut ko var izdarīt tikai tad, ja tas skripts tiek otreiz izsaukts. Un tad tajā otrajā reizē arī pārbaudi cik ilgs laiks pagāja no pirmās atvēršanas reizes. Ja vairāk par 20 sek, tad dzēs. Saglabāt iepriekšējo skripta atvēršanas laiku vari sesijā. Link to comment Share on other sites More sharing options...
Aleksejs Posted December 20, 2007 Report Share Posted December 20, 2007 hmm, nu tīri teorētiski... no php caur shellu palaiž: mainit.sh, kas satur kaut ko šādu: #!/bin/bash sleep 20 && mainit_failu.sh Bet pirms tam izveic killall mainit.sh :) Tātad kaut ko šādu: exec "killall mainit.sh"; exec "./mainit.sh"; Bet praktiski... Es tā toč nedarītu. Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 Aleksej, tā vienkārši arī tas nestrādās. Tev taču ir jāveic pārbaude arī vēl. Nu kaut kā jau samudrīt varētu. Link to comment Share on other sites More sharing options...
blackhalt Posted December 20, 2007 Report Share Posted December 20, 2007 No brouzera tak vajag. Var sūtīt ik pēc sekundes kaut kādu AJAX figņu. Link to comment Share on other sites More sharing options...
Aleksejs Posted December 20, 2007 Report Share Posted December 20, 2007 andrisp Kas tad vēl jāveic? Ja reiz lapu atver 20 sekunžu laikā no iepriekšējās atvēršanas, tad sleep 20 nodrošina, ka skripts mainit_datus.sh vēl nebūs izpildījies un tātad to varēs nokilot ;) Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 Jā, tiešām, es sākumā nesapratu. Link to comment Share on other sites More sharing options...
*jancis38* Posted December 20, 2007 Author Report Share Posted December 20, 2007 (edited) es mēģināju kko izvilkt no šitā skripta, bet nekas nesanāca. :/ <?php $rip = $_SERVER['REMOTE_ADDR']; $sd = time(); $count = 1; $file1 = "txt.txt"; $lines = file($file1); $line2 = ""; foreach ($lines as $line_num => $line) { $fp = strpos($line,'****'); $nam = substr($line,0,$fp); $sp = strpos($line,'++++'); $val = substr($line,$fp+4,$sp-($fp+4)); $diff = $sd-$val; if($diff < 300 && $nam != $rip) { $count = $count+1; $line2 = $line2.$line; } } $my = $rip."****".$sd."++++\n"; $open1 = fopen($file1, "w"); fwrite($open1,"$line2"); fwrite($open1,"$my"); fclose($open1); echo "$count"; ?> Edited December 20, 2007 by *jancis38* Link to comment Share on other sites More sharing options...
Recommended Posts