[EN] User location is not case insensitive

Benutzeravatar
Marc
Administrator
Administrator
Beiträge: 620
Registriert: Di 2. Sep 2008, 23:48
phpbb.com: Marc
Wohnort: Munich

[EN] User location is not case insensitive

Beitrag von Marc »

In the phpBB Statistics 1.0.2 package, the location is being sorted case sensitive. If you don't want that, you can change it easily.

Open includes/stats/stats_settings.php
Find:

Code: Alles auswählen

                if($db->sql_layer != 'mssql' && $db->sql_layer != 'mssql_odbc')
                {
                $sql = 'SELECT TRIM(user_from) AS location, COUNT(user_id) AS count FROM ' . USERS_TABLE . "
                            WHERE user_from <> ''
                                GROUP BY TRIM(user_from)
                            ORDER BY count DESC, location ASC";
                }
                else
                {
                    $sql = 'SELECT LTRIM(RTRIM(user_from)) AS location, COUNT(user_id) AS count FROM ' . USERS_TABLE . "
                                WHERE user_from <> ''
                                GROUP BY LTRIM(RTRIM(user_from))
                                ORDER BY count DESC, location ASC";
                } 


Replace with:

Code: Alles auswählen

                if($db->sql_layer != 'mssql' && $db->sql_layer != 'mssql_odbc')
                {
                $sql = 'SELECT TRIM(LOWER(user_from)) AS location, COUNT(user_id) AS count FROM ' . USERS_TABLE . "
                            WHERE user_from <> ''
                                GROUP BY TRIM(LOWER(user_from))
                            ORDER BY count DESC, location ASC";
                }
                else
                {
                    $sql = 'SELECT LTRIM(RTRIM(LOWER(user_from))) AS location, COUNT(user_id) AS count FROM ' . USERS_TABLE . "
                                WHERE user_from <> ''
                                GROUP BY LTRIM(RTRIM(LOWER(user_from)))
                                ORDER BY count DESC, location ASC";
                } 
Find:

Code: Alles auswählen

                        $template->assign_block_vars('location_row', array(
                            'LOCATION'            => $row['location'],
                            'COUNT'                => $row['count'],
                            'PCT'                        => number_format($row['count'] / $total_users_set_location * 100, 3),
                            'BARWIDTH'                    => number_format($row['count'] / $max_count * 100, 1),
                            'IS_MAX'                => ($row['count'] == $max_count),
                            'IS_MINE'                => ($row['location'] == trim(strtolower($user->data['user_from']))),
                        )); 
Replace with:

Code: Alles auswählen

                        $left_character = substr($row['location'], 0, 1);
                        $left_character = mb_strtoupper($left_character, 'UTF-8');
                        $template->assign_block_vars('location_row', array(
                            'LOCATION'            => $left_character . substr($row['location'], 1),
                            'COUNT'                => $row['count'],
                            'PCT'                        => number_format($row['count'] / $total_users_set_location * 100, 3),
                            'BARWIDTH'                    => number_format($row['count'] / $max_count * 100, 1),
                            'IS_MAX'                => ($row['count'] == $max_count),
                            'IS_MINE'                => ($row['location'] == trim(strtolower($user->data['user_from']))),
                        )); 
Bild