Benvenuto Posted July 20, 2005 Report Share Posted July 20, 2005 (edited) Meklēju veidu kā nogalbāt iekš php mainīga informāciju par adresi no kuras ienācis apmeklētājs manā lapā. Teiksim ne tieši pilnu URL, bet pašu pirmā līmeņa domēnu. Tātad, ja cilvēks ienācis pie manis no adreses http://www.govs.lv/aitas.html tad vajadzētu panākt to, lai iekš mainīgā tiek saglabats tikai govs.lv Piemēram šitā štelle: <? echo $_SERVER['HTTP_REFERER']; ?> man iedos visu url, bet es gribētu izlobīt tieši tīru pirmā līmeņa domēnu bez pārējās adreses daļās. Pliku govs.lv Edited July 20, 2005 by Benvenuto Link to comment Share on other sites More sharing options...
v3rb0 Posted July 20, 2005 Report Share Posted July 20, 2005 regex neder? ja http://asd.lv/qwe.html tad gried nost visu kopaa ar tresho slashu un atmet http:// dalju Link to comment Share on other sites More sharing options...
Benvenuto Posted July 20, 2005 Author Report Share Posted July 20, 2005 regex neder? ja http://asd.lv/qwe.html tad gried nost visu kopaa ar tresho slashu un atmet http:// dalju 19632[/snapback] Nu http:// dalju vareetu atmest ar preg_replace() bet kaa lai tiek valjaa no taa, kas ir aiz govs.lv/ Link to comment Share on other sites More sharing options...
bubu Posted July 20, 2005 Report Share Posted July 20, 2005 (edited) <?php $url = parse_url($_SERVER['HTTP_REFERER']); echo $url['host']; ?> Vai arī <?php $url = explode('/', $_SERVER['HTTP_REFERER'], 4); echo $url[2]; ?> Edited July 20, 2005 by bubu Link to comment Share on other sites More sharing options...
Benvenuto Posted July 20, 2005 Author Report Share Posted July 20, 2005 paaldies, bubu. Link to comment Share on other sites More sharing options...
Benvenuto Posted July 21, 2005 Author Report Share Posted July 21, 2005 <?php $url = parse_url($_SERVER['HTTP_REFERER']); echo $url['host']; ?> Vai arī <?php $url = explode('/', $_SERVER['HTTP_REFERER'], 4); echo $url[2]; ?> 19634[/snapback] Vispaar te rodas atkal jauna probleema. Pienjemsim, ka cilveeks ir ienaacis no http://top100.govs.lv/index.html Shis skripts atlasa top100.govs.lv Bet jautaajums ir kaa lai nogriezh veel arii to top100 (vai vienalga kas tur buutu priekshaa, kaut vai www) un atstaaj tikai govs.lv Link to comment Share on other sites More sharing options...
bubu Posted July 21, 2005 Report Share Posted July 21, 2005 Exploldē to "top100.govs.lv" pēc "." un paņem pēdējos divus masīva elementus. Link to comment Share on other sites More sharing options...
Benvenuto Posted July 21, 2005 Author Report Share Posted July 21, 2005 Exploldē to "top100.govs.lv" pēc "." un paņem pēdējos divus masīva elementus. 19678[/snapback] Yeah, tas straadaa! :) Link to comment Share on other sites More sharing options...
sviesc Posted July 21, 2005 Report Share Posted July 21, 2005 un kas notiks ja adrese būs janis.bezins.gov.lv ? ko tad :P - es teiktu jāņem masīva priekpējējais elemenc :blink: Link to comment Share on other sites More sharing options...
bubu Posted July 21, 2005 Report Share Posted July 21, 2005 un kas notiks ja adrese būs janis.bezins.gov.lv ? ko tad :P - es teiktu jāņem masīva priekpējējais elemenc :blink: 19682[/snapback] Es tak to jau arī teicu - masīva pēdējos divus elementus. Link to comment Share on other sites More sharing options...
smarty Posted July 21, 2005 Report Share Posted July 21, 2005 http://lv.php.net/manual/en/function.parse-url.php Link to comment Share on other sites More sharing options...
sviesc Posted July 21, 2005 Report Share Posted July 21, 2005 bubu sorry pārlasījos :P Link to comment Share on other sites More sharing options...
Recommended Posts