codeigniter allow "http://" in get variable - php

My app is based on Codeigniter Framework
If I type the following url, I get 404 error :
http://example.com/mycontroller/func/?url=http://www.hello.com
but if type anything other that http it work normally, for example
http://example.com/mycontroller/func/?url=ptth://www.hello.com
EDIT:
I want to achieve this because I have a form that doesn't submit when I use the word http inside it, this form need to be stored into the database. I don't know why this happen at all but all I know is that if I can get the app to work the url form above it would probably work fix my problem with the form too as long as the problem looks similar Here's my other question
Why codeigniter doesn't allow the word http:// to be passed as a get variable and How can enable the word 'http://' to be able to pass through the URL ?

Make sure your config file has the following:
$config['enable_query_strings'] = true;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-=&?';
Note the ? added to permitted_uri_chars

Related

How to access TYPO3 action via browser

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.

Page not reading query string without index.php in the URL

this problem started happening when my server got upgraded to use PHP7, so I suspect it has something to do with that.
My website's URLs build the page content based on the query string. For example:
example.com/?prop=one
example.com/?prop=two
example.com/?prop=three
etc...
But for some reason, when I do the following:
$prop = $_REQUEST["prop"];
or:
$prop = $_GET["prop"];
It does not recognize the specified query string value.
On the other hand, using the following URL format works fine (note the addition of "index.php"):
example.com/index.php?prop=one
example.com/index.php?prop=two
example.com/index.php?prop=three
In other words, I'm able to grab the prop query string value without a problem with the presence of the "index.php" in the URL. I don't want to use index.php in the URL, I'd like the URLs to remain clean. This is basically a single page info-app that changes the content via that query string value, so there should be no need for index.php at the root of the domain.
Any thoughts as to how I would fix this? Does this have something to do with updating to PHP7 on the server?
Well, this is embarrassing.
Basically I realized that the problem was that I had an index.html file at the root, and the server was picking that up by default when the index file wasn't specified. So naturally there was no PHP present, so it gave the impression that the query string value wasn't being read correctly. After renaming the index.html file, everything works as expected.
I'm wondering if the settings on my previous server were set to pick up the index.php file by default instead of index.html.
I'd delete this entire post but I suppose someone else might have the same problem so I'll leave it.

Error with a "returnUrl" in URL params

I am working with the Yii Framework.
In a controller, after a model save, I'm trying to redirect the user to /module/controller/action and set a parameter (redirectUrl) to another URL. Here is my code:
$this->redirect(array('/module/controller/action/', 'redirectUrl'=>'/index.php/some/url/id/'.$id));
This seems to work well as I am redirected to:
http://localhost/index.php/module/controller/action/redirectUrl/%2Findex.php%2Fsome%2Furl%2Fid%2F11
But when I get there I get the following error:
Not Found
The requested URL
/index.php/module/controller/action/redirectUrl//index.php/some/url/id/11 was not found on this server.
The URL like /index.php/module/controller/action/redirectUrl/1234 works fine.
I don't understand what I am doing wrong here, URL seems to be correctly encoded. Any idea would be of great help!
Thanks
Your example URL is only passing 1234 as the parameter, not a full relative URL, e.g. /index.php/some/url/id/1234. I think what you want is:
$this->redirect(array('/module/controller/action/', 'redirectUrl'=>$id));
You could skip the URL rules on your server and minimally reduce load with:
$this->redirect('/module/controller/action/redirectUrl/' . $id);
$this->redirect($this->createUrl('/module/controller/action/',
array('redirectUrl'=>'/index.php/some/url/id/'.$id));
If this does not work do
$this->redirect($this->createUrl('/module/controller/action/',
array('redirectUrl'=>$id));
and then just add '/index.php/some/url/id/' in the action.
http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail

Codeigniter Url Problem on Server

I have some problem in codeigniter url segment problem in server..
In local server my web url is http:localhost/test/index.php/user/userGetData/3..if we want to get the 3 from url in controller function .
then we use $this->uri->?segment(3); it works.
But when uploaded on server we use url rewriting
$routes['getData'] = 'user/userGetData/$1'; and refresh the page after this change, server url look like http://www.test.com/getData/3
in controller function userGetData() $this->uri->segment(3); doesn't work.
How to fix this problem and same case in all function?
Are you sure $this->uri->?segment(3) it's work?
First, you need to change $config['base_url']
Use $this->uri->segment(2) to get data.

GET method in php clean URL

I have successfully created clean url for my project.. now what i need to do is add variables to URL..
localhost/user1/file?action=add
localhost/user2/file2?action=delete
where user and file are already rewritten i dont want it to be like localhost/user/file/add because localhost/user/folder/file will be mistaken to to the action parameter.. please help
Try using the ampersand instead of question mark:
localhost/user2/file2&action=delete
In your htaccess, the rewrite rule might look something like this:
RewriteRule ^user([0-9]+)/file([0-9]+)$ /page\.php?user=$1&file=$2
As you can see, the question mark is already there even though it is masked in the address bar. Appending another variable to the query string would require the ampersand for successful concatenation.
You need to get the url and start parsing the url from the question mark. I would save the contents then to an array, so that you've got a key and a value.
$uri = $_SERVER["REQUEST_URI"];
$questionMark = explode('?',$uri);
$questionMark[1] is the action=delete then. There are probably better ways then using explode() method here, but I just wanted to show how you get the string.
You can read GET variables in PHP by accessing the global $_GET array:
http://php.net/manual/en/reserved.variables.get.php
In your example, the php file that is used for handling files would be able to read in:
echo $_GET['action']; // 'add' or 'delete'

Categories