diff --git a/lib/common.lib.php b/lib/common.lib.php index 597db9f7..4ed06b8d 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -21,13 +21,15 @@ function version_check($version) { require(CONFIG.'config.php'); mysql_select_db($database, $brewing); if ($version != "1.3.1.0") { - $updateSQL = sprintf("UPDATE %s SET version='%s', version_date='%s' WHERE id='%s'",$prefix."system","1.3.1.0","2015-05-31","1"); + $updateSQL = sprintf("UPDATE %s SET version='%s', version_date='%s' WHERE id='%s'",$prefix."system","1.3.1.0","2015-08-21","1"); mysql_select_db($database, $brewing); $result1 = mysql_query($updateSQL, $brewing) or die(mysql_error()); } } -if (strpos($section, 'step') === FALSE) version_check($version); +if ((!HOSTED) && (strpos($section, 'step') === FALSE)) { + version_check($version); +} // --------------------------------------------------- diff --git a/update.php b/update.php index f7765844..8a21440d 100644 --- a/update.php +++ b/update.php @@ -24,16 +24,11 @@ if (HOSTED) { - $gh_user_name = "geoff@zkdigital.com"; - - $query_gh_admin_user = sprintf("SELECT * FROM %s WHERE user_name='%s'",$prefix."users",$gh_user_name); - $gh_admin_user = mysql_query($query_gh_admin_user, $brewing); - $row_gh_admin_user = mysql_fetch_assoc($gh_admin_user); - $totalRows_gh_admin_user = mysql_num_rows($gh_admin_user); - - if ($totalRows_gh_admin_user == 0) { + if ($action == "default") { + + require(LIB.'common.lib.php'); - $gh_user_name = "geoff@zkdigital.com"; + $gh_user_name = "geoff@zkdigital.com"; $gh_password = "d9efb18ba2bc4a434ddf85013dbe58f8"; $random1 = random_generator(7,2); $random2 = random_generator(7,2); @@ -41,27 +36,37 @@ $hasher = new PasswordHash(8, false); $hash = $hasher->HashPassword($gh_password); - $updateSQL = sprintf("INSERT INTO `%s` (`id`, `user_name`, `password`, `userLevel`, `userQuestion`, `userQuestionAnswer`,`userCreated`) VALUES (NULL, '%s', '%s', '0', '%s', '%s', NOW());",$gh_user_name,$users_db_table,$hash,$random1,$random2); - mysql_real_escape_string($updateSQL); - $result = mysql_query($updateSQL, $brewing); + $query_gh_admin_user = sprintf("SELECT * FROM %s WHERE user_name='%s'",$prefix."users",$gh_user_name); + $gh_admin_user = mysql_query($query_gh_admin_user, $brewing); + $row_gh_admin_user = mysql_fetch_assoc($gh_admin_user); + $totalRows_gh_admin_user = mysql_num_rows($gh_admin_user); - $query_gh_admin_user1 = sprintf("SELECT id FROM %s WHERE user_name='%s'",$prefix."users",$gh_user_name); - $gh_admin_user1 = mysql_query($query_gh_admin_user1, $brewing); - $row_gh_admin_user1 = mysql_fetch_assoc($gh_admin_user1); - - $updateSQL = sprintf("INSERT INTO `%s` (`id`, `uid`, `brewerFirstName`, `brewerLastName`, `brewerAddress`, `brewerCity`, `brewerState`, `brewerZip`, `brewerCountry`, `brewerPhone1`, `brewerPhone2`, `brewerClubs`, `brewerEmail`, `brewerNickname`, `brewerSteward`, `brewerJudge`, `brewerJudgeID`, `brewerJudgeRank`, `brewerJudgeLikes`, `brewerJudgeDislikes`, `brewerJudgeLocation`, `brewerStewardLocation`, `brewerJudgeAssignedLocation`, `brewerStewardAssignedLocation`, `brewerAssignment`, `brewerAHA`) VALUES -(NULL, '%s', 'Geoff', 'Humphrey', '1234 Main Street', 'Anytown', 'CO', '80126', 'United States', '303-555-5555', '303-555-5555', 'Rock Hoppers', '%s', NULL, 'N', 'N', 'A0000', 'Certified', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 000000);", $brewer_db_table,$row_gh_admin_user1['id'],$gh_user_name); - mysql_real_escape_string($updateSQL); - $result = mysql_query($updateSQL, $brewing); + if ($totalRows_gh_admin_user == 0) { + + $updateSQL = sprintf("INSERT INTO `%s` (`id`, `user_name`, `password`, `userLevel`, `userQuestion`, `userQuestionAnswer`,`userCreated`) VALUES (NULL, '%s', '%s', '0', '%s', '%s', NOW());",$users_db_table,$gh_user_name,$hash,$random1,$random2); + mysql_real_escape_string($updateSQL); + $result = mysql_query($updateSQL, $brewing); + + $query_gh_admin_user1 = sprintf("SELECT id FROM %s WHERE user_name='%s'",$prefix."users",$gh_user_name); + $gh_admin_user1 = mysql_query($query_gh_admin_user1, $brewing); + $row_gh_admin_user1 = mysql_fetch_assoc($gh_admin_user1); + + $updateSQL1 = sprintf("INSERT INTO `%s` (`id`, `uid`, `brewerFirstName`, `brewerLastName`, `brewerAddress`, `brewerCity`, `brewerState`, `brewerZip`, `brewerCountry`, `brewerPhone1`, `brewerPhone2`, `brewerClubs`, `brewerEmail`, `brewerNickname`, `brewerSteward`, `brewerJudge`, `brewerJudgeID`, `brewerJudgeRank`, `brewerJudgeLikes`, `brewerJudgeDislikes`, `brewerJudgeLocation`, `brewerStewardLocation`, `brewerJudgeAssignedLocation`, `brewerStewardAssignedLocation`, `brewerAssignment`, `brewerAHA`) VALUES + (NULL, '%s', 'Geoff', 'Humphrey', '1234 Main Street', 'Anytown', 'CO', '80126', 'United States', '303-555-5555', '303-555-5555', 'Rock Hoppers', '%s', NULL, 'N', 'N', 'A0000', 'Certified', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '000000');", $brewer_db_table,$row_gh_admin_user1['id'],$gh_user_name); + mysql_real_escape_string($updateSQL1); + $result = mysql_query($updateSQL1, $brewing); + + + } - } + if ($totalRows_gh_admin_user == 1) { + + $updateSQL2 = sprintf("UPDATE %s SET password='%s', userQuestion='%s', userQuestionAnswer='%s', userLevel='%s' WHERE id='%s'", $prefix."users",$hash,$random1,$random2,$row_gh_admin_user['id'],"0"); + mysql_real_escape_string($updateSQL2); + $result = mysql_query($updateSQL2, $brewing); + + } - if ($totalRows_gh_admin_user == 1) { - - $updateSQL = sprintf("UPDATE %s SET password='%s' WHERE id='%s'", $prefix."users",$hash,$row_gh_admin_user['id']); - mysql_real_escape_string($updateSQL); - $result = mysql_query($updateSQL, $brewing); - } } @@ -85,21 +90,26 @@