"The URI you submitted has disallowed characters" in CodeIgniter - codeigniter

I am receiving this error "The URI you submitted has disallowed characters." I got this error when I search for email rest of things working perfectly.
I also changed these two things but no luck
$config['enable_query_strings'] = True;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-#\=';

just change to:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-#\=+()';

Change this
$config['enable_query_strings'] = True;
to
$config['enable_query_strings'] = FALSE;
hope this will help you.
still getting error ..please post your url and how it generated.

Related

Make user-friendly URL in Codeigniter with multi-language support

I have created a multi-language website.
Facing issue while creating SEO user-friendly URL.
current URL:
http://localhost/example/en/user/myaccount OR
http://localhost/example/fr/user/myaccount
want to change it with
http://localhost/example/en/myaccount OR
http://localhost/example/fr/user/myaccount
routes.php
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
// URI like '/en/about' -> use controller 'about'
$route['^(en|de|fr|nl|id|es)/(.+)$'] = "$2";
// '/en', '/de', '/fr','/es' and '/nl' URIs -> use default controller
$route['^(en|de|fr|nl|id|es)$'] = $route['default_controller'];
also tried with
$route["myaccount"] = "user/myaccount";
$route["^(en|de|fr|nl|id|es)$/myaccount"] = "user/myaccount";
Nothing will work in this case. Already used following in routes.php file other demo projects with out multi-language. There it's work perfectly.
$route["myaccount"] = "user/myaccount";
Thanks in advance
you can consult the documentation for routes here
https://www.codeigniter.com/user_guide/general/routing.html
and for your problem
$route["(:any)/myaccount"] = "user/myaccount/$1";

preg_match to only allow https:// in an URL

I'd like to allow only https:// links to be used as remote avatar images in phpbb to avoid mixed content. This seems to be the code that is used to check whether the entered url is correct (to be found in /phpbb/avatar/driver/remote.php):
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.('. implode('|', $this->allowed_extensions) . ')$#i', $url))
{
$error[] = 'AVATAR_URL_INVALID';
return false;
}
I'd like to add a if{}-condition before this code block to give an informative error message if the user selected an image from a non-secure server. Can anyone help me defining the correct preg_match() string please?
Based on the suggestion by #casimir, I used the following code and it works:
$urlchk = parse_url($url);
$urlscheme = isset($urlchk['scheme']) ? $urlchk['scheme'].'://' : 'http://';
if ($urlscheme=='http://'){
// error message
}

how to remove added '?' into url in CI before controller name

I have a login function where after successful login, new directory mentioned like :
redirect('admin');
But when new directory loaded at that time url become like this :
"//localhost/xyz/?admin"
Here an character "?" added into URL. How can i solve this problem.
In your config (applications/config/config.php), query strings will be enabled:
$config['enable_query_strings'] = TRUE;
To remove the ?, disable query strings:
$config['enable_query_strings'] = FALSE;

SMTP Codeigniter email error '354 End data with .'

I'm having trouble getting the Codeigniter email library working on a new server.
This code has previously worked before but has recently stopped working and I cannot for the life of me figure out why. Essentially, here is the code:
$this->email->from('example#example.com', 'Intranet');
$this->email->to($c['email']);//This is def a valid email
//$name is being obtained from elsewhere
$this->email->subject('Time manager reminder');
$this->email->message("
{$name[0]},
<br/><br/>You haven’t completed your time for today. Please don’t forget to do so<br/><br/>
Intranet
");
$this->email->send();
And the email.php config password
$config['mailtype'] = "html";
$config['priority'] = 1;
$config['protocol'] = "smtp";
$config['smtp_host'] = "my server..";
$config['smtp_user'] = "u/n";
$config['smtp_pass'] = "p/w";
$config['smtp_timeout'] = 1;
$config['validate'] = true;
The error I receive from $this->email->print_debugger(); is as follows:
data: 354 End data with .
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
You can view the full error on pastebin here http://pastebin.com/y9UeaEGY
I've crossed out the emails in all places, but I can assure you they are valid and used email addresses.
I'd appreciate any help you can offer. Thanks
I figured out the reason. Apparently, in the config, you need to set
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
manually in the email.php file. Codeigniter doesn't seem to do it by default. Odd :)

GET params with URI rounting/ Codeigniter

$route['ajax/get/mail'] = "mail/get_mail_by_params";
I am trying to request *ajax/get/mail?user_id=123&foo=bar&bar=foo*
And params it in controller:
$foo = $this->input->get('foo')
But $_GET in ajax/get/mail variable is empty!
I suggest, that routing doesn’t supports GET paramets. What to do?
Have you tried using the MY_Input library? http://codeigniter.com/wiki/MY_Input/
Also, I think you may need to update your URI Protocol in config.php to PATH_INFO.
$config['uri_protocol'] = "PATH_INFO";

Resources