Laravel route query get email address from query value instead of key - laravel

I have encountered an issue regarding Laravel 8 routes.
And I am unable to find a solution to this problem.
For example, I have this route format in Laravel:
$domain/password_reset?$email
Where it will look like this:
http://test-website.com/password_reset?test#gmail.com
I am aware that query parameters have ?key=value format. However in my case, the provided route format is what is expected (by client). Not the conventional key=value way. Also, the url link is clicked from an email. Wherein the link in the email uses the exact route format given (not url-encoded).
The sample request query that is fetched in the controller is as follows:
If you would notice, the email became a key (which is expected). And since it is a key, . has been changed to _. Instead of gmail.com it became gmail_com.
Would there be a better solution to get the exact email address from the url (not url-encoded) in this route format? Hopefully someone can help me with this. Thank you very much in advanced!

You should get the request query and parse it yourself:
[$path, $query] = explode('?',$request->fullUrl())
In the exemple above $query should hold everything after ? on the URL.
Alternativelly you can just get the key of the array you already have:
$email = array_keys($request->all())[0]

Related

CodeIgniter URL Encryption

All Viewers I am New in Codeigniter, I need your guide to done my work, I want to Encrypted full URL like below example.
For example this is my url www.example.com & my controller is home, so full url is www.example.com/home
now I want to encrypted all controller, function like below
www.example.com/5115784bef2514430e7f74d9a71d4142a942efb0f7cc428626bda7633326f9d015fbacc60d93cd6b858f9b6e05c1e56263acb24297cecc720467eb4f222d81e5hdn5B
I can encrypted & decrypted the text well, but I just don't get how can I decrypted from url & make understand which controller or function its called, I want to decrypted everything after base_url.
please don't suggest me about using common controller, because I already know that & anyhow common controller its hide everything so its not required the encryption as I believe.
Waiting for your positive response, hopefully my problem will be solve soon. T.I.A
Well i never encrypt any URL before but you can use a php function url_encode
And "str_replace" function.
the reason for using "str_replace" beacause url_encode only encode special character in URL.
Hope I help some.
Try the code below.
urlencode(str_replace("your_domain.com/YourCOntrollerName/YourMethodName" , "SM5ah52" , yor_domain.com . "YourCOntrollerName/YourMethodName/YOuData"));
If not this. There is an library in CI Framework called Encryption.
You can get help from there Encryption.
Go with URI Routing and define one controller to decode whatever you are passing, and call proper controller / method from it.
You can use URI Routing with regular expressions.
$route["other_controllers/method"] = "other_controllers/method"; //you can add this kind of lines to not to affect other controllers
$route["([a-zA-Z0-9]+)"] = "home/decrypt/$1";
In the home controller, You can
Redirect to the page
Or
Load a view
public function decrypt($token){
//geting the page according to the token from database.
$desired_page = $this->some_model->get_page($token);
//if you want to redirect
redirect($desired_page);
//if you want to load a view
$this->load->view($desired_page);
}

Magento getPost empty array

I have the following code (please excuse the bad coding, it's like that to debug):
$postData = Mage::app()->getRequest()->getPost();
if(!$postData)
{
$postData = $this->getRequest()->getPost();
}
if(!$postData)
{
$postData = $_POST;
}
As you can see, I am simply trying to get the HTTP POST values.
Here's the scenario:
From a HTTP POST Simulator, the data comes through
From the Shopify webhook, nothing comes through (just "Array()")
Shopify posting to PostCatcher shows a lot of data
Shopify is posting in JSON format.
Any ideas as to ahy I can't catch the POST array?
You cant get JSON post values by using simply $_POST or Mage::app()->getRequest()->getPost();. Just try this,
$value = json_decode(file_get_contents('php://input'));
print_r($value);
In one of my project I got the same error
Mage::app()->getRequest()->getPost(); was giving the blank values.
I was using one extension when I was submitting the form there was one description field for the manufacturer.
If it was having text content like from , select or some content similar to SQL commands.
It was not posting the form data.
The reason was the hosting provider had some settings for sanitizing the data to prevent the SQL injection.
I raised the ticket to the hosting provider and the problem was solved.
Before this I tried lot of coding stuff which was not required.
Basically
Mage::app()->getRequest()->getPost(); and $this->getRequest()->getPost(); are the same if you are in a controller.
They are also the same thing with $_POST with some additional filtering on the values.
So if you receive an empty array in any case you should receive an empty array for all cases.
Make sure the data is sent through POST.
Also try to see how $this->getRequest()->getParams() look like. Maybe Magento considers that the parameters are sent through _GET

Pass encrypted email in url in nop commerece

I want to pass encrypted email in url,but its not working on server,
while it is working on localhost.
I check the encrypted email- It contains some specific character like + , =
all those url which contains + sign are not working on server. but it working on localhost.
for example-
url format - {controllername}/{methodname}/{encrypted email}/{bool}
working url-
www.test.com/home/index/IZoc1QJlukTro7XN4kTaRDoy7mPNS-14YjKeZsXeyt3XsL4tXbLUPQ==/false
not working url-
www.test.com/home/index/KV6UWqy5fN7FY+lZuMAQ5nvA0+X4f8sQyB0la+-bSawUPEY1TIHK-C2bUdZUBRA6/false
not working url gives error like
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Thoughts ?
You should pass it as an url encoded query string parameter and not as part of the route:
http://www.test.com/home/index?email=IZoc1QJlukTro7XN4kTaRDoy7mPNS-14YjKeZsXeyt3XsL4tXbLUPQ%3D%3D%2Ffalse
If you want to pass some string as part of the route you should ensure that it doesn't contain dangerous characters which is your case. Scott Hanselman wrote a nice and detailed blog post on the difficulties that you might encounter if you attempt to pass such strings as part of the route here: http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx
I will quote his conclusion if you don't want to go through the entire post:
After ALL this effort to get crazy stuff in the Request Path, it's
worth mentioning that simply keeping the values as a part of the Query
String (remember WAY back at the beginning of this post?) is easier,
cleaner, more flexible, and more secure.

way to pass variable through url in codeigniter

I got a big search module in my Codeigniter project. Well simply I am passing variable to a view like
<a href=<?php echo site_url('controller/view/1'); ?>>View List</a>
And fetching its data in controller like
$id=$this->uri->segment(3);
For pagination
http://wwww.site.com/controller/view/<filter id>/<page from>
This is working perfectly in the case of simple query.
Now I got some more filter quires like
Country
State
City
Customer type
etc etc
then the url should be
http://wwww.site.com/controller/view/1/id2/id3/i4/id5
Is this the correct way to do the process ? If not please give a little advice...
I am new to codeigniter
The problem you are facing i have recently found a solution for this.
When you are first sending parameters through url use POST instead.
When you get the parameters you can pass them to session in a variable
type. Next time when you paginate get the type value from session and
put it in your query to get the desired result.
If you have more than 1 parameters you can put them in sessions and
unset them on certain conditions so that they are not called in every query.
I think the best approach here is to create another method in the controller something like filtered_view that accepts a filter_id and a page number, and that methode will fetch the data from the database with the provided filter and you'll use your pagination class as usual.
Hope this help.

Passing Params to a page in key-value pair in CodeIgniter

I am using CodeIgniter, and I am new to it.
I came to know that I can pass parameters to another page like http://example.com/users/list/param1/param2/param3/.... and so on.
Now on the destination php script, I can get it as $this->uri->segment(2) , but I must know that which location it is in the uri. Say I am getting param2 , I must know that it is uri segment 4. This is a great pain for me. I previously worked with ZEND , where we send parameters like
http://examples.com/controller/action/key/value/key/value , Now in this case I can always dynamic number of parameters and I don't need to know their location in the uri, but I just need to know the key.
Qestion : Is there a way where I can pass parameters using GET in key-value pairs in codeigniter, like the one ZEND do?
Take a look at the function $this->uri->uri_to_assoc(n) in the URI class. It will take in your url segments as an associative array. You could then check whether the keys are present in it or not.
Example and full explanation in the user guide.

Resources