Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Live Country List + Search + Flags - Mem
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2020-04-09 08:03:21
Here you can change the old country list for account-signup, and use a new better one with jQuery and select2 plugin.

Members can also search for a country in the dropdown field and easily locate a country without endless scrolling. Increases UX and encourages field population from members.

Open header.php and add (CDN):

<link href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js"></script>

<script>
function formatCountry (country) {
 if (!country.id) { return country.text; }
 var baseUrl = "<?php echo $site_config["SITEURL"]; ?>/images/countries";
 var $country = $(
   '<span><img src="' + baseUrl + '/' + country.text.toLowerCase() + '.png" class="img-flag" style="vertical-align:middle;width:25px;height:25px;margin-right:7px" />' + country.text + '</span>'
 );
 return $country;
};
$("#countries").select2({
 templateResult: formatCountry
});
</script>

Now open account-signup and find

          <tr>
               <td><?php echo T_("COUNTRY"); ?>:</td>
               <td>
                   <select name="country" size="1">
                       <?php
                       $countries = "<option value=\"0\">---- ".T_("NONE_SELECTED")." ----</option>\n";
                       $ct_r = SQL_Query_exec("SELECT id,name,domain from countries ORDER BY name");
                       while ($ct_a = mysql_fetch_assoc($ct_r)) {
                           $countries .= "<option value=\"$ct_a[id]\">$ct_a[name]</option>\n";
                       }
                       ?>
                       <?php echo $countries; ?>
                   </select>
               </td>
           </tr>
 
 
Replace with

           <tr>
               <td><?php echo T_("COUNTRY"); ?>:</td>
               <td>
               <?php
              // Include database
              $dsn = 'mysql:dbname=database;host=localhost;charset=utf8';
              $user = 'username;
              $password = 'password';
               try {
                   $db = new PDO($dsn, $user, $password);
                   $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Prevent advanced injection by disabling emulated prepared statements
                       $query      = $db->prepare("SELECT * FROM countries ORDER BY name");
                       $result        = $query->fetchAll(PDO::FETCH_ASSOC);
                       if ($query->execute()) {
                           while ($lang_a = $query->fetch()) {
                               $langimage               = $site_config["SITEURL"] . '/images/countries/' . $lang_a['flagpic'];
                               $lang_id             = $lang_a['id'];
                               $lang_name           = $lang_a['name'];
                               $lang_sa[$lang_name] = $lang_id;
                               $languages              .= "<option value='$lang_id'$lang>$lang_name</option>";  
                           }
                       }
               }
               catch (PDOException $e) {
                   echo "Error!: " . $e->getMessage() . "<br/>";
                   die();
               }
               ?>
                   </select>
               </td>
           </tr>
           <script>
           function formatState (state) {
             if (!state.id) {
               return state.text;
             }
             var baseUrl = "<?php echo $site_config["SITEURL"]; ?>/images/countries";
             var $state = $(
               '<span><img src="' + baseUrl + '/' + state.text.toLowerCase() + '.png" class="img-flag" style="vertical-align:middle;width:25px;height:25px;margin-right:7px" />' + state.text + '</span>'
             );
             return $state;
           };
           $("#countries").select2({
             templateResult: formatState
           });
           </script>

           <select name="country" id="countries">
                   <?php echo $languages; ?>
           </select>
 
 
Now run SQL query


UPDATE countries
SET flagpic = REPLACE(flagpic, 'gif', 'png')
WHERE flagpic LIKE '%gif%'



Now upload "countries" folder from ZIP file into /images/

Works like this

[ATTACH type="full" width="609px" alt="County-List-TTv3.png"]5436[/ATTACH]

Enjoy!
County-List-TTv3.png
County-List-TTv3.png
countries.zip
Download
2020-04-09 09:03:04
THANK YOU  (y)
2020-04-09 09:15:00
"spiritblue, post: 68329, member: 401":

THANK YOU  (y)


Anytime ;)
2020-04-09 10:55:33
Nice mod mate  (y)
2020-04-09 11:11:34
I'll need to update this.
- account-signup for checks for the field - fix.
- added flags and country name to accounts-details.php
-
added flags and country name to account.php
2020-04-09 19:20:31
ti-error ...in the account-signup part, an aportof is missing

seache: $user = 'username;

change...$user = 'username';
2020-04-09 19:32:42
error

             
[TABLE]
[TR]
[TD]Pays:[/TD]
[TD]                Erreur!: SQLSTATE[28000] [1045] Access denied for user 'username'@'localhost' (using password: YES)[/TD]
[/TR]
[/TABLE]



I added the server info and it still gives the same error

;)
2020-04-10 03:56:39
"spiritblue, post: 68342, member: 401":

error

           
[TABLE]
[TR]
[TD]Pays:[/TD]
[TD]                Erreur!: SQLSTATE[28000] [1045] Access denied for user 'username'@'localhost' (using password: YES)[/TD]
[/TR]
[/TABLE]



I added the server info and it still gives the same error

;)


Pay attention to the error. Confirm your database details. Do you have mysql_pdo installed? I should of added checks...
2020-04-10 11:32:16
"STorrents2020, post: 68344, member: 20382":

Pay attention to the error. Confirm your database details. Do you have mysql_pdo installed? I should of added checks...

ok,  pm;)

this mod should not be in this selection
2020-04-10 17:27:31
"spiritblue, post: 68348, member: 401":

ok,  pm;)

this mod should not be in this selection


I can provide non-PDO version, I just had better code in mind
2020-04-12 03:49:21
[ATTACH type="full" width="448px"]5441[/ATTACH]

Flags on profile/account coming soon, will update post
Flags-User-Profile.png
Flags-User-Profile.png
2020-04-12 03:53:49
Flags on profile/account coming soon, will update post.

[ATTACH type="full" width="570px"]5442[/ATTACH]
Flags-User-Profile.png
Flags-User-Profile.png
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728