Troxy Posted July 6, 2007 Report Share Posted July 6, 2007 (edited) Veidoju onlain skriptu. doma sekojosha lietotajs janis skatas zinas lietotajs peteris skatas arhivu pirmamkartam vajag izvadit tada un tada ip adrese skatas to un to sadalu http://paste.php.lv/5761 Tabula timestamp ip FILE 1183737560 81.198.xx.xx /online.php ceru ka tik talu ir skaidra mana doma tatad ka izvadit ip adresi un linku kurua patreiz atrodas shis lietotajs Edited July 6, 2007 by Troxy Link to comment Share on other sites More sharing options...
NiTrino Posted July 6, 2007 Report Share Posted July 6, 2007 (edited) lai identificetu lietotaju tev vajadzes vinja ID... $PAGES = array ( 'news.php' => 'lasa ziņas', 'archive.php' => 'skatās arhīvu' ); //=========== $get = mysql_query ("SELECT timestamp,ip,FILEFROM online"); $rows = mysql_num_rows ($get); if ($rows > 0) { while ($i++<$rows) { $data = mysql_fetch_assoc ($get); echo '<p>lietotājs ar ip '.$data['ip'].$PAGES[$data['file']].'</p>'; } } te vel vajadzetu querijaa parbaudes uz laiku, cik skaitas online, bet nu ideju saprati.. Edited July 6, 2007 by NiTrino Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 6, 2007 Report Share Posted July 6, 2007 (edited) lai identificetu lietotaju tev vajadzes vinja ID... Peec IP nevar pateikt vai tas ir konkretais useris... Troxy --> datubaazee pieseivo lapas NR kad useris ieiet kaadaa sadaljaa tad 1. tiek nodzeesti visi vecie lietotaaji kas ir vecaaki par kautkaadu laiku nu teiksim 3Min ... 2. tiek pierakstiits lietotaaja ID un laiks kaa arii lapas NR.... (lapas ID) kad gribi izvadiit cik ko dara tad... nolasi visus lietotaajus kas skataas konkreto lapu... (taa lai useru ID nedubleetos.... pameklee tepat forumaa USER ONLINE) + arii cik ierakstu vispaar ir DB Pashu tabulu glabaa kaa MEM.... tas palielinaas skripta aatrumu.... tikai neaizmirsti noraadiit cik MAX rowu driikst buut tabulaa , ja negribi lai MYSQL apeed visu RAM.... to vari diezgan viegli izrekjinaat --> teiksim ja onlainaa plano ka buus 500 apmekleetaaju tad lapu videeji parskjirs katras 20 sek ... tas ir 3 lapas minuutee (VIDEJI !! nevis max un min...) taatad 500X3X3 =1500X3=4500 --> uzliec max row 10K un buus ar krietnu rezervi (nebaidies ka aiznjems atminjaa paaraak daudz vietas , jo glabaa jau tikai 3 Integer.... Aa un neizmanto autoincrament --> tobish unikaalo ID tev vispaar nevajag....... + noindieksee pee userID--> Laps ID.... edit : nu jaa ja tev vajag taas IP tad liec , bet neaizmirsti ka tavu lapu var skatiities kauchvai 100 cilveeki ar vienaadu IP... un to kodu jau daljeeji tachu biji Uzrakstijis ;) Edited July 6, 2007 by Grey_Wolf Link to comment Share on other sites More sharing options...
NiTrino Posted July 6, 2007 Report Share Posted July 6, 2007 nu kapec nevar. ja vinsh ir ielogojies, tad tu zini vinja ID. lidz ar to tabulaa laukaa userid to arii rakstam. Link to comment Share on other sites More sharing options...
hackerman Posted July 6, 2007 Report Share Posted July 6, 2007 Izskatās, ka Grey_Wolf ir vnk pārskatījies. :) Peec IP nevar pateikt vai tas ir konkretais useris... Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 6, 2007 Report Share Posted July 6, 2007 nea , es vienk pieversu uzmaniibu shiim fragmentam // timestamp,ip,FILEFROM online // un sho // lietotājs ar ip '.$data['ip']. // NiTrino -> nu jaa protams un pat ja vinsh nav ielagojies --> sesijaa var izveidoot Unikaalu ID .... Katram userim savu.... Link to comment Share on other sites More sharing options...
Paulinjsh Posted July 9, 2007 Report Share Posted July 9, 2007 ja nav ielogojies skaitam pēc sesijas_id Link to comment Share on other sites More sharing options...
Troxy Posted July 9, 2007 Author Report Share Posted July 9, 2007 Taatad turpinot pa teemu Ka ierobezhot pie izvadishanas jo izvada visus ierakstus ar vienadam ip, nu tipa ja tada ip jau existee tad neizvadam divreiz,jebshu nemaz nepiellaut ievadiit db divreiz vienu ip ceru ka funktieri saprataat. tagad man ir taa ka es nostaigaju p a shitajaam sadallam un rada visas kur pabiju. :| <? $uvisitor=$REQUEST_URI; $uvisitorip=$REMOTE_ADDR; $utime=time(); $exptime=$utime-600; // (in seconds) @mysql_query("delete from online where timevisit<$exptime"); $uexists=@mysql_num_rows(@mysql_query("select id from online where visitor='$uvisitor'")); if ($uexists>0){ @mysql_query("update online set timevisit='$utime' where visitor='$uvisitor'"); } else { @mysql_query("insert into online (ip,visitor,timevisit) values ('$uvisitorip','$uvisitor','$utime')"); } ?> <? $rs=@mysql_query("select * from online"); while ($ro=@mysql_fetch_array($rs)){ echo "<hr>".$ro[ip]." "; if ( $ro['visitor'] =='/index.php?categoryid=1') { echo 'Skatas Jaunumus<BR><hr>';} if ( $ro['visitor'] == '/index.php?categoryid=12' ) { echo 'skatas serverus<BR>';} if ( $ro['visitor'] == '/index.php?categoryid=20' ) { echo 'skatas statistiku<BR>';} } ?> Link to comment Share on other sites More sharing options...
Grey_Wolf Posted July 9, 2007 Report Share Posted July 9, 2007 Troxy -> tu izlasiji ko teicu par IP ? peec taa NEVAR identificeet Lietotaaju .... jo teiksi iestaadees ir Vienaada IP ... identificee pec usera ID (kaajau mineeja peec sesijas id ...) tad zinaasi cik reaali Kompji piesleegushies..... (nu var jau buut ka useris atver otru brauzeri, bet to var paredzeet un parakstiit cepuminjus....) Link to comment Share on other sites More sharing options...
Paulinjsh Posted July 9, 2007 Report Share Posted July 9, 2007 (edited) tabulas struktūra varētu būt šāda: CREATE TABLE `_online` ( `session` varchar(100) NOT NULL default '', `uid` int(11) unsigned NOT NULL default '0', `timestamp` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`session`), KEY `timestamp` (`timestamp`) ) ENGINE=MEMORY; Tālāk pats kods $timestamp = $_SERVER['REQUEST_TIME']-60*60*10; // timestamp laikam šobrīd - 10 minūtes mysql_query("DELETE FROM _online WHERE timestamp <= ".$timestamp); // izdzēšam visus vecos online mysql_query("UPDATE _online SET timestamp = ".$_SERVER['REQUEST_TIME']." WHERE session_id = '".session_id()."' LIMIT 1"); // apdeitojam šīs sesijas laiku if(mysql_affeched_rows() != 1) { // ja neviens lauks nav updeitots, tas nozīmē, ka nav vēl tabulā, tātad insertojam mysql_query("INSERT INTO _online VALUES ('".session_id()."', ".$_SESSION['user']['id'].", ".$_SERVER['REQUEST_TIME'].")"); } uz fikso rakstīju, gan jau kāds papildinās :) Edited July 9, 2007 by Paulinjsh Link to comment Share on other sites More sharing options...
Troxy Posted July 9, 2007 Author Report Share Posted July 9, 2007 nu ok paldies bet ka es noteikshu kuraa sadalaa atrodas users karoche nu man galva ir pilniiga putra :||| Link to comment Share on other sites More sharing options...
Paulinjsh Posted July 9, 2007 Report Share Posted July 9, 2007 nu tad tabulā pieliec vēl vienu lauku dir vai cat vai kā nu tu viņu nosauc, kurā glabā, kur konkrēts lietotājs atrodas. Link to comment Share on other sites More sharing options...
Troxy Posted July 9, 2007 Author Report Share Posted July 9, 2007 (edited) Nu kaukas man te tap askaidrs es tik tagad saku domat vai nebus vieglaak izvilkt no foruma to listu jo tur jau visas tabulas ir key_id user_id last_ip last_login 2cc6794722fad07c3b1900b295c42898 2 51c6ad20 1180782372 nu man ir shada tabula domaju varetu no shejienes tik japieliek viens lauks cat Edited July 9, 2007 by Troxy Link to comment Share on other sites More sharing options...
FireFox Posted August 9, 2007 Report Share Posted August 9, 2007 Davai kurs ir labinjsh, ievieto te visu sakombineetu scriptu kass strada! Link to comment Share on other sites More sharing options...
andrisp Posted August 9, 2007 Report Share Posted August 9, 2007 FireFox, sapnjo vien ;) Link to comment Share on other sites More sharing options...
Recommended Posts