Page 1 of 1

[EN] User location is not case insensitive

Posted: Wed 28. Apr 2010, 14:07
by 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: Select all

                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: Select all

                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: Select all

                        $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: Select all

                        $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']))),
                        ));