Skip to content

Commit

Permalink
1.3.1.0 - Hosted Version Changes
Browse files Browse the repository at this point in the history
Only affects hosted versions.
  • Loading branch information
geoffhumphrey committed Aug 24, 2015
1 parent 2000530 commit 06b2f68
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 deletions.
6 changes: 4 additions & 2 deletions lib/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// ---------------------------------------------------

Expand Down
76 changes: 43 additions & 33 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,49 @@

if (HOSTED) {

$gh_user_name = "[email protected]";

$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 = "[email protected]";
$gh_user_name = "[email protected]";
$gh_password = "d9efb18ba2bc4a434ddf85013dbe58f8";
$random1 = random_generator(7,2);
$random2 = random_generator(7,2);
require(CLASSES.'phpass/PasswordHash.php');
$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);

}

}
Expand All @@ -85,21 +90,26 @@
<div id="header-inner"><h1>BCOE&amp;M <?php echo $current_version; ?> Database Update Script</h1></div>
</div>
<?php

$sub_folder = str_replace("http://".$_SERVER['SERVER_NAME'],"",$base_url);
$filename = $_SERVER['DOCUMENT_ROOT'].$sub_folder."/includes/version.inc.php";

/* ---- DEBUG ----
//echo $updateSQL."<br>";
//echo $updateSQL1."<br>";
//echo $updateSQL2."<br>";
//echo $filename;
*/



if (file_exists($filename)) {

//require(DB.'archive.db.php');

function check_setup($tablename, $database) {
require(CONFIG.'config.php');
/*
if(!$database) {
$res = mysql_query("SELECT DATABASE()");
$database = mysql_result($res, 0);
}
*/

$query_log = "
SELECT COUNT(*) AS count
FROM information_schema.tables
Expand Down

0 comments on commit 06b2f68

Please sign in to comment.