Problem with filter with Cyrillic

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
kerelov
Veteran Member
Posts: 45
Joined: 2020-04-17 21:20
Location: Bulgaria

Problem with filter with Cyrillic

Post by kerelov » 2024-08-19 15:35

Hi guys,
I have the following issue> I need to redirect a specific group of users to a page with predefined filtered content. So I saved the filter I need using the advanced page filter in table view of the page. So I got something like this:

Code: Select all

tasks_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=5&FilterOperator%5B1%5D=equal-to&FilterValue%5B1%5D=19.08.2024&FilterAnd%5B2%5D=and&FilterField%5B2%5D=6&FilterOperator%5B2%5D=equal-to&FilterValue%5B2%5D=%D0%A5%D1%80%D0%B8%D1%81%D1%82%D0%BE+%D0%98%D0%B2%D0%B0%D0%BD%D0%BE%D0%B2
So this basically filters the tasks for each day for each user from the group. The problem is that the names are in Cyrillic. So this part:

Code: Select all

%D0%A5%D1%80%D0%B8%D1%81%D1%82%D0%BE+%D0%98%D0%B2%D0%B0%D0%BD%D0%BE%D0%B2
is actually: Христо Иванов
So normally when they login I get their names by the username that they login. Then I encode the names using urlencode or rawurlencode and all looks fine when I error_log it. The problem comes when I use header or redirect to send the user to this actual page and filter by his/her name. The url seems to decode itself and the name in it is not encoded. That way the filter doesn't work. i also tried using js with window.location but without any luck. I checked if Apache uses UTF without BOM it is also ok. I don't know what I'm missing here guys please help. Here is the very simple code that drives me crazy:

Code: Select all

$mi = getMemberInfo();
	$username = $mi["username"];
	//get worker name by username
	$workerName = sqlValue("SELECT name FROM workers WHERE username = '$username'");	
	//encode name for use in url
	$workerName = rawurlencode($workerName);
	//get current date
	$currentDate = date('d.m.Y');
	//redirect to filtered tasks page with current technician and current date
	$locationURL = "tasks_view.php?SortField=&SortDirection=&FilterAnd%5B1%5D=and&FilterField%5B1%5D=5&FilterOperator%5B1%5D=equal-to&FilterValue%5B1%5D=$currentDate&FilterAnd%5B2%5D=and&FilterField%5B2%5D=8&FilterOperator%5B2%5D=equal-to&FilterValue%5B2%5D=$workerName";
	//redirect to tasks
	redirect($locationURL);

mcvaidas
Posts: 29
Joined: 2019-04-14 17:45

Re: Problem with filter with Cyrillic

Post by mcvaidas » 2025-04-24 12:39

And I also had issues with Cyrillic in my project; both searching and sorting didn't work. I solved it by changing the table encoding in the database to utf8_general.

Post Reply