ray Posted December 20, 2007 Report Share Posted December 20, 2007 Kā no adreses www.mana_lapa.lv/1/2/3/index.php?id=1&a=1&b=3&c=4 utt. atlasīt domēna vārdu www.mana_lapa.lv? Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 http://lv2.php.net/manual/en/function.parse-url.php Bet varētu arī ar regulārajām ekspresijām. Link to comment Share on other sites More sharing options...
Paulinjsh Posted December 20, 2007 Report Share Posted December 20, 2007 (edited) preg_match("/(?:((?:https?|s?ftp):\/\/((?:[a-zA-Z_0-9]{2,}\.)+[a-zA-Z]{2,4})))\/(?:[a-zA-Z_+]?\/?)*/", $urlis, $tmp); © mefisto andrisp šitādu funkciju nebiju pamanījis :) Edited December 20, 2007 by Paulinjsh Link to comment Share on other sites More sharing options...
marcis Posted December 20, 2007 Report Share Posted December 20, 2007 $_SERVER['HTTP_HOST']; moš nepareizi, bet mainīgajā $_SERVER ir. print_r($_SERVER); Link to comment Share on other sites More sharing options...
ray Posted December 20, 2007 Author Report Share Posted December 20, 2007 (edited) ok, tad man ir tabula (id | url | user) ar adresēm [tādām nesmukām kā iepriekš minēju]. Kā man viņas ar sql sagrupēt, lai rādītos tabula, piem.: www.mana_lapa.lv - 3 [kolonu skaits, kurās adrese satur šo domēnu] www.cita_lapa.lv - 2 www.kkāda_lapa.lv - 1 utt. Edited December 20, 2007 by ray Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 (edited) Var jau ti kā mēģināt regexoties sql (skaties manuāli) pusē. Bet labāk iesaku pie ierakstīšanas tabulā izgriezt to domēnu un pieglabāt atsevišķā laukā. Ja tie dati jau eksistē, tad uztaisi skriptu, kas nolasa visus datus, izgriež un apdeito. Edited December 20, 2007 by andrisp Link to comment Share on other sites More sharing options...
Kavacky Posted December 20, 2007 Report Share Posted December 20, 2007 preg_match("/(?:((?:https?|s?ftp):\/\/((?:[a-zA-Z_0-9]{2,}\.)+[a-zA-Z]{2,4})))\/(?:[a-zA-Z_+]?\/?)*/", $urlis, $tmp); © mefisto LOL, šite nav nedaudz overkills? Manuprāt, priekš vienkāršas domēna noteikšanas ( ne tur 1337 pārbaudes, vai tas tiešām ir reāli atļauts ) pietiktu, ja atdala sākumā http:// un www., bet pēc tam meklē līdz pirmajam / un viss. Link to comment Share on other sites More sharing options...
Roze Posted December 20, 2007 Report Share Posted December 20, 2007 Arī tas ir overkills.. marcis tak jau uzrakstija atbildi $_SERVER['HTTP_HOST'] .. un viss.. Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 Roze, marcis, kur ir teikts, ka viņam vajag zināt domēnu caur kuru atvērta lapa ? Man gan izskatās, ka viņam kaut kādus refererus statistikā or something vajag apstrādāt. Link to comment Share on other sites More sharing options...
Aleksejs Posted December 20, 2007 Report Share Posted December 20, 2007 Kaut kāds šāds tas vaicājums varētu būt... SELECT COUNT(id) AS skaits, SUBSTRING_INDEX(url,'/',1) AS urlis FROM adres_tabula GROUP BY urlis Link to comment Share on other sites More sharing options...
blackhalt Posted December 20, 2007 Report Share Posted December 20, 2007 Tak ar parse_url() var apstrādāt un atlikt atpakaļ. <?php $url = 'http://www.mana_lapa.lv/1/2/3/index.php?id=1&a=1&b=3&c=4'; $host = parse_url($url,PHP_URL_HOST); ?> Link to comment Share on other sites More sharing options...
ray Posted December 20, 2007 Author Report Share Posted December 20, 2007 >> blackhalt Mēģināju, bet tavu domu man realizēt nesanāca, kāds var palīdzēt? Link to comment Share on other sites More sharing options...
andrisp Posted December 20, 2007 Report Share Posted December 20, 2007 Kā nesanāca realizēt ? Just copy`n`paste. Link to comment Share on other sites More sharing options...
ray Posted December 20, 2007 Author Report Share Posted December 20, 2007 es mēģināju grupēt ar to iegūto rezultātu, bet nu nesanāca izdomāt, kā to varētu izdarīt :/ Link to comment Share on other sites More sharing options...
Aleksejs Posted December 20, 2007 Report Share Posted December 20, 2007 Ar "nesanāca" ir par maz! Kādu kļūdu Tev izdod mysql??? Link to comment Share on other sites More sharing options...
Recommended Posts