eldarian

Enth country disable fix

Apr 11th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.16 KB | None | 0 0
  1. 1) open mod_owned.php
  2. 2) go to line 786, find:
  3.  
  4.                mysql_close( $db_link_list );
  5.  
  6. 3) copy and REMOVE it from that line
  7.  
  8. 4) around line 798, find:
  9.  
  10.                $changes[] = 'Country field disabled.';
  11.  
  12. 5) paste what you removed from line 786, and paste it right before that line, so now it looks like:
  13.  
  14.                mysql_close( $db_link_list );
  15.                $changes[] = 'Country field disabled.';
  16.  
  17. 6) around line 831, find
  18.  
  19.                mysql_close( $db_link_list );
  20.  
  21. 7) copy and REMOVE it from that line
  22.  
  23. 8) around line 843, find:
  24.  
  25.                $changes[] = 'Country field enabled.';
  26.  
  27. 9) paste what you removed from line 831, and paste it right before that line, so now it looks like:
  28.  
  29.                mysql_close( $db_link_list );
  30.                $changes[] = 'Country field enabled.';
  31.  
  32. 10) make sure, you removed " mysql_close( $db_link_list ); " from where you originally found it, and moved it below, not just copy it, but remove it.
  33.  
  34. 11) open show_update.php, find line 159:
  35.  
  36.       // new country
  37.       if( isset( $_POST['country'] ) && $_POST['country'] == '' )
  38.          $data['country'] = $member['country'];
  39.       else
  40.          $data['country'] = clean( $_POST['country'] );
  41.  
  42.     replace it with:
  43.  
  44.       if( $info['country'] == 1 ) {
  45.          // new country
  46.          if( isset( $_POST['country'] ) && $_POST['country'] == '' )
  47.             $data['country'] = $member['country'];
  48.          else
  49.             $data['country'] = clean( $_POST['country'] );
  50.       }
  51.  
  52. 12) go to line 206, find:
  53.  
  54.                "Email: " . $data['email_new'] . "\r\n" .
  55.                "Country: " . $data['country'] . "\r\n" .
  56.                "URL: " . $data['url'] . "\r\n";
  57.  
  58.     replace it with:
  59.  
  60.                "Email: " . $data['email_new'] . "\r\n";              
  61.             if( $info['country'] == 1 )
  62.                $notify_message .= "Country: " . $data['country'] . "\r\n";
  63.             $notify_message .= "URL: " . $data['url'] . "\r\n";
  64.  
  65. 13) open show_join.php, go to line 232, find:
  66.  
  67.                "Email: $email\r\n" .
  68.                "Country: $country\r\n" .
  69.                "URL: $url\r\n";
  70.  
  71.     replace it with:
  72.  
  73.                "Email: $email\r\n";
  74.             if( $info['country'] == 1 )
  75.                $notify_message .= "Country: $country\r\n";
  76.             $notify_message .= "URL: $url\r\n";
  77.  
  78. 14) from your enth control panel, under the fanlisting you just disabled country field for, go to settings, and for the field "Sort members by," change it from "country" to "name" or whatever custom field you added depending on what table column you wanted to sort member list by
  79.  
  80. in the end, from line 767 to 846, your mod_owned.php should look like:
  81.          case 'country' :
  82.             // get info
  83.             if( $value == 'leave' )
  84.                continue;
  85.             $db_link_list = mysql_connect( $dbserver, $dbuser, $dbpassword )
  86.                or die( DATABASE_CONNECT_ERROR . mysql_error() );
  87.             mysql_select_db( $dbdatabase )
  88.                or die( DATABASE_CONNECT_ERROR . mysql_error() );
  89.  
  90.             if( $value == 'disable' ) {
  91.                // alter table
  92.                $query = "ALTER TABLE `$table` DROP `country`";
  93.                $result = mysql_query( $query, $db_link_list );
  94.                if( !$result ) {
  95.                   log_error( __FILE__ . ':' . __LINE__,
  96.                      'Error executing query: <i>' . mysql_error() .
  97.                      '</i>; Query is: <code>' . $query . '</code>' );
  98.                   die( STANDARD_ERROR );
  99.                }
  100.  
  101.                // update db_owned
  102.                $query = "UPDATE `$db_owned` SET `country` = 0 WHERE " .
  103.                   "`listingid` = '$id'";
  104.                $result = mysql_query( $query, $db_link );
  105.                if( !$result ) {
  106.                   log_error( __FILE__ . ':' . __LINE__,
  107.                      'Error executing query: <i>' . mysql_error() .
  108.                      '</i>; Query is: <code>' . $query . '</code>' );
  109.                   die( STANDARD_ERROR );
  110.                }
  111.                mysql_close( $db_link_list );
  112.                $changes[] = 'Country field disabled.';
  113.  
  114.             } else if( $value == 'enable' ) {
  115.                // alter table
  116.                $query = "ALTER TABLE `$table` ADD `country` VARCHAR(128) " .
  117.                   "NOT NULL default '' AFTER `name`";
  118.                $result = mysql_query( $query );
  119.                if( !$result ) {
  120.                   log_error( __FILE__ . ':' . __LINE__,
  121.                      'Error executing query: <i>' . mysql_error() .
  122.                      '</i>; Query is: <code>' . $query . '</code>' );
  123.                   die( STANDARD_ERROR );
  124.                }
  125.  
  126.                // drop fulltext index
  127.                $query = "ALTER TABLE `$table` DROP INDEX `email`";
  128.                $result = mysql_query( $query );
  129.                if( !$result ) {
  130.                   log_error( __FILE__ . ':' . __LINE__,
  131.                      'Error executing query: <i>' . mysql_error() .
  132.                      '</i>; Query is: <code>' . $query . '</code>' );
  133.                }
  134.  
  135.                // re-add fulltext index
  136.                $query = "ALTER TABLE `$table` ADD FULLTEXT ( `email`, " .
  137.                   "`name`, `country`, `url` )";
  138.                $result = mysql_query( $query );
  139.                if( !$result ) {
  140.                   log_error( __FILE__ . ':' . __LINE__,
  141.                      'Error executing query: <i>' . mysql_error() .
  142.                      '</i>; Query is: <code>' . $query . '</code>' );
  143.                   die( STANDARD_ERROR );
  144.                }
  145.  
  146.                // update db_owned
  147.                $query = "UPDATE `$db_owned` SET `country` = 1 WHERE " .
  148.                   "`listingid` = '$id'";
  149.                $result = mysql_query( $query, $db_link );
  150.                if( !$result ) {
  151.                   log_error( __FILE__ . ':' . __LINE__,
  152.                      'Error executing query: <i>' . mysql_error() .
  153.                      '</i>; Query is: <code>' . $query . '</code>' );
  154.                   die( STANDARD_ERROR );
  155.                }
  156.                mysql_close( $db_link_list );
  157.                $changes[] = 'Country field enabled.';
  158.  
  159.             }
  160.             break;
Add Comment
Please, Sign In to add comment