Skip to content

Instantly share code, notes, and snippets.

@aurenen
Last active April 13, 2016 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aurenen/0f98a366e66c58251a627c36b70788aa to your computer and use it in GitHub Desktop.
Save aurenen/0f98a366e66c58251a627c36b70788aa to your computer and use it in GitHub Desktop.
Fixed disabling and enabling country field for fanlistings
1) open mod_owned.php
2) go to line 786, find:
mysql_close( $db_link_list );
3) copy and REMOVE it from that line
4) around line 798, find:
$changes[] = 'Country field disabled.';
5) paste what you removed from line 786, and paste it right before that line, so now it looks like:
mysql_close( $db_link_list );
$changes[] = 'Country field disabled.';
6) around line 831, find
mysql_close( $db_link_list );
7) copy and REMOVE it from that line
8) around line 843, find:
$changes[] = 'Country field enabled.';
9) paste what you removed from line 831, and paste it right before that line, so now it looks like:
mysql_close( $db_link_list );
$changes[] = 'Country field enabled.';
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.
11) open show_update.php, find line 159:
// new country
if( isset( $_POST['country'] ) && $_POST['country'] == '' )
$data['country'] = $member['country'];
else
$data['country'] = clean( $_POST['country'] );
replace it with:
if( $info['country'] == 1 ) {
// new country
if( isset( $_POST['country'] ) && $_POST['country'] == '' )
$data['country'] = $member['country'];
else
$data['country'] = clean( $_POST['country'] );
}
12) go to line 206, find:
"Email: " . $data['email_new'] . "\r\n" .
"Country: " . $data['country'] . "\r\n" .
"URL: " . $data['url'] . "\r\n";
replace it with:
"Email: " . $data['email_new'] . "\r\n";
if( $info['country'] == 1 )
$notify_message .= "Country: " . $data['country'] . "\r\n";
$notify_message .= "URL: " . $data['url'] . "\r\n";
13) open show_join.php, go to line 232, find:
"Email: $email\r\n" .
"Country: $country\r\n" .
"URL: $url\r\n";
replace it with:
"Email: $email\r\n";
if( $info['country'] == 1 )
$notify_message .= "Country: $country\r\n";
$notify_message .= "URL: $url\r\n";
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
in the end, from line 767 to 846, your mod_owned.php should look like:
case 'country' :
// get info
if( $value == 'leave' )
continue;
$db_link_list = mysql_connect( $dbserver, $dbuser, $dbpassword )
or die( DATABASE_CONNECT_ERROR . mysql_error() );
mysql_select_db( $dbdatabase )
or die( DATABASE_CONNECT_ERROR . mysql_error() );
if( $value == 'disable' ) {
// alter table
$query = "ALTER TABLE `$table` DROP `country`";
$result = mysql_query( $query, $db_link_list );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
die( STANDARD_ERROR );
}
// update db_owned
$query = "UPDATE `$db_owned` SET `country` = 0 WHERE " .
"`listingid` = '$id'";
$result = mysql_query( $query, $db_link );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
die( STANDARD_ERROR );
}
mysql_close( $db_link_list );
$changes[] = 'Country field disabled.';
} else if( $value == 'enable' ) {
// alter table
$query = "ALTER TABLE `$table` ADD `country` VARCHAR(128) " .
"NOT NULL default '' AFTER `name`";
$result = mysql_query( $query );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
die( STANDARD_ERROR );
}
// drop fulltext index
$query = "ALTER TABLE `$table` DROP INDEX `email`";
$result = mysql_query( $query );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
}
// re-add fulltext index
$query = "ALTER TABLE `$table` ADD FULLTEXT ( `email`, " .
"`name`, `country`, `url` )";
$result = mysql_query( $query );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
die( STANDARD_ERROR );
}
// update db_owned
$query = "UPDATE `$db_owned` SET `country` = 1 WHERE " .
"`listingid` = '$id'";
$result = mysql_query( $query, $db_link );
if( !$result ) {
log_error( __FILE__ . ':' . __LINE__,
'Error executing query: <i>' . mysql_error() .
'</i>; Query is: <code>' . $query . '</code>' );
die( STANDARD_ERROR );
}
mysql_close( $db_link_list );
$changes[] = 'Country field enabled.';
}
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment