Asdres balk uitlezen inc. #
ik heb een klein scriptje die de adress balk van een browser kan uitlezen.
alleen op het moment dat er een # in de url staat leest hij tot daar en geeft hij dus de link tot het # weer.
ik wil eigenlijk dat hij de hele link incusief het # weer geeft iemand een idee hoe dit komt.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
$uri = selfURL();
?>
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
$uri = selfURL();
?>
alvast bedankt!
En dan zul je zien dat je niet opnieuw het wiel hoeft uit te vinden :D
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Array
(
[UNIQUE_ID] => uvpYIsCoAXoAAAgMYcMAAAD4
[HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
[HTTP_ACCEPT_LANGUAGE] => nl
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2)
[HTTP_HOST] => localhost
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => PHPSESSID=3gom6rc4ubod2766e31vuivia3
[PATH] => C:\Program Files\Autodesk\Maya 8.5 Personal Learning Edition\bin;C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Norman\Npm\Bin;D:\www\openssl\bin;D:\www\Apache22\bin;D:\www\php5;D:\www\mysql5\bin;D:\www\perl\bin;D:\Program Files\QuickTime\QTSystem\
[SystemRoot] => C:\WINDOWS
[COMSPEC] => C:\WINDOWS\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
[WINDIR] => C:\WINDOWS
[SERVER_SIGNATURE] => <address>Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8e mod_fastcgi/mod_fastcgi-SNAP-0404142202 PHP/5.2.1 mod_perl/2.0.3 Perl/v5.8.8 Server at localhost Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8e mod_fastcgi/mod_fastcgi-SNAP-0404142202 PHP/5.2.1 mod_perl/2.0.3 Perl/v5.8.8
[SERVER_NAME] => localhost
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[REMOTE_ADDR] => 127.0.0.1
[DOCUMENT_ROOT] => D:/www/webroot
[SERVER_ADMIN] => admin@localhost
[SCRIPT_FILENAME] => D:/www/webroot/middelman/index.php
[REMOTE_PORT] => 1102
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /middelman/
[SCRIPT_NAME] => /middelman/index.php
[PHP_SELF] => /middelman/index.php
[REQUEST_TIME] => 1213962758
)
(
[UNIQUE_ID] => uvpYIsCoAXoAAAgMYcMAAAD4
[HTTP_ACCEPT] => image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
[HTTP_ACCEPT_LANGUAGE] => nl
[HTTP_UA_CPU] => x86
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2)
[HTTP_HOST] => localhost
[HTTP_CONNECTION] => Keep-Alive
[HTTP_COOKIE] => PHPSESSID=3gom6rc4ubod2766e31vuivia3
[PATH] => C:\Program Files\Autodesk\Maya 8.5 Personal Learning Edition\bin;C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Norman\Npm\Bin;D:\www\openssl\bin;D:\www\Apache22\bin;D:\www\php5;D:\www\mysql5\bin;D:\www\perl\bin;D:\Program Files\QuickTime\QTSystem\
[SystemRoot] => C:\WINDOWS
[COMSPEC] => C:\WINDOWS\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
[WINDIR] => C:\WINDOWS
[SERVER_SIGNATURE] => <address>Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8e mod_fastcgi/mod_fastcgi-SNAP-0404142202 PHP/5.2.1 mod_perl/2.0.3 Perl/v5.8.8 Server at localhost Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8e mod_fastcgi/mod_fastcgi-SNAP-0404142202 PHP/5.2.1 mod_perl/2.0.3 Perl/v5.8.8
[SERVER_NAME] => localhost
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 80
[REMOTE_ADDR] => 127.0.0.1
[DOCUMENT_ROOT] => D:/www/webroot
[SERVER_ADMIN] => admin@localhost
[SCRIPT_FILENAME] => D:/www/webroot/middelman/index.php
[REMOTE_PORT] => 1102
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /middelman/
[SCRIPT_NAME] => /middelman/index.php
[PHP_SELF] => /middelman/index.php
[REQUEST_TIME] => 1213962758
)
aleen dit is de url in de adres balk
en die kan ik dus nog steeds niet ophalen.
http://localhost/middelman/#/startpagina
Het is onmogelijk om alles achter het #'je uit te lezen met PHP, aangezien de browser het niet meestuurt. Dat is zo omdat het puur aan de browser gericht is, namelijk om ergens naar een anchor op de pagina te gaan.
Bedankt voor de info:D
met javascript ophalen, vervolgens met ajax naar php sturen
zou je mij een klein opzetje kunnen geven
alvast bedankt.