Browse files

Changes to better handle first-run scenarios

  • Loading branch information...
1 parent 44c06dc commit 7d9dc9ef500632e8153579755ad741d4aea9b513 @jdpurdyvi jdpurdyvi committed May 10, 2010
Showing with 39 additions and 35 deletions.
  1. +9 −8 pos/is4c/configure.php
  2. +2 −2 pos/is4c/connect.php
  3. +0 −1 pos/is4c/lib/conf.php
  4. +2 −1 pos/is4c/lib/initialize.php
  5. +22 −18 pos/is4c/lib/query.php
  6. +3 −4 pos/is4c/login.php
  7. +1 −1 pos/is4c/variables.php
View
17 pos/is4c/configure.php
@@ -1,7 +1,7 @@
<?php
- include_once("connect.php");
- include_once("lib/query.php");
- include_once("lib/conf.php");
+ include_once("lib/conf.php");
+ include_once("connect.php");
+ include_once("lib/query.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -42,15 +42,16 @@
$_SESSION["config_saved"] = FALSE;
}
?>
- </p
+ </p>
<div class='config_forms'>
- <form action='/lib/apply_configurations.php' method='post'>
- <input type='submit' value='Save Changes' />
- <?php
+ <form action='/lib/apply_configurations.php' method='post'>
+ <input type='submit' value='Save Changes'/>
+ <?php
$groups = get_configuration_groups();
foreach ($groups as $group) {
?>
- <fieldset>
+ <fieldset>
+
<legend><?=$group["group_name"]?></legend>
<?php
$configs = get_configuration_settings($group["group_id"]);
View
4 pos/is4c/connect.php
@@ -22,7 +22,7 @@
*********************************************************************************/
if (!function_exists("get_config_auto")) {
include_once("lib/conf.php");
- apply_configurations();
+ # apply_configurations();
}
if (!function_exists("setglobalflags")) {
@@ -326,7 +326,7 @@ function sql_connect($server, $user, $pass) {
$connection = mssql_connect($server, $user, $pass);
}
else {
- $connection = mysql_connect($server, $user, $pass) or die(mysql_error());
+ $connection = mysql_connect($server, $user, $pass);
}
return $connection;
}
View
1 pos/is4c/lib/conf.php
@@ -1,5 +1,4 @@
<?php
-
include_once("/pos/is4c/lib/initialize.php");
if (!function_exists("get_users")) {
include_once("/pos/is4c/lib/query.php");
View
3 pos/is4c/lib/initialize.php
@@ -1,5 +1,5 @@
<?php
- if (!isset($_SESSION["DBMS"]))
+ if (!isset($_SESSION["DBMS"]) || empty($_SESSION['DBMS']))
{
$handle = fopen("/pos/db_connect", "r");
$contents = fread($handle, filesize("/pos/db_connect"));
@@ -24,5 +24,6 @@
preg_match('/[\r\n]?password:[^\r\n]*\n/', $contents, $match);
preg_match('/[^: ]*$/', $match[0], $match);
$_SESSION["localPass"] = trim($match[0]);
+ } else {
}
?>
View
40 pos/is4c/lib/query.php
@@ -1,6 +1,6 @@
<?php
if (!function_exists("pDataConnect")) {
- include("/pos/is4c/connect.php");
+ include_once("/pos/is4c/connect.php");
}
/*Returns an associative array of active employees.*/
@@ -121,7 +121,7 @@ function get_configuration_groups_query() {
$query =
'SELECT group_id,
group_name
- FROM configurationGroups
+ FROM `opdata`.`configurationGroups`
WHERE group_id > 0;';
$result = sql_query($query, pDataConnect());
for ($i = 0; $i < sql_num_rows($result); $i++) {
@@ -137,7 +137,7 @@ function get_configuration_group_settings_query($configuration_group) {
'SELECT `key`,
value,
type
- FROM configuration
+ FROM `opdata`.`configuration`
WHERE group_id = ' . $configuration_group;
$result = sql_query($query, pDataConnect());
for ($i = 0; $i < sql_num_rows($result); $i++) {
@@ -151,7 +151,7 @@ function get_configurations() {
$query =
'SELECT `key`,
value
- FROM configuration
+ FROM `opdata`.`configuration`
WHERE group_id > 0;';
$result = sql_query($query, pDataConnect());
for ($i = 0; $i < sql_num_rows($result); $i++) {
@@ -164,9 +164,9 @@ function get_configurations() {
// Checks for a list of configuration values that must be set for IS4C to operate.
// If any of these configurations are not set, then it returen false.
function configs_set() {
- $query =
+ $query =
'SELECT value
- FROM configuration
+ FROM `opdata`.`configuration`
WHERE `key` IN
(
"OS",
@@ -178,37 +178,41 @@ function configs_set() {
"localUser",
"laneno"
);';
- $result = sql_query($query, pDataConnect());
- for ($i = 0; $i < sql_num_rows($result); $i++) {
- $row = sql_fetch_assoc_array($result);
- if ($row["value"] == NULL)
- {
- return false;
- }
- }
- return true;
+ $result = sql_query($query, pDataConnect());
+ if ($result) {
+ for ($i = 0; $i < sql_num_rows($result); $i++) {
+ $row = sql_fetch_assoc_array($result);
+ if ($row["value"] == NULL)
+ {
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
}
function save_configurations($configurations) {
// Set all flag fields to 0.
// Those that have been checked will be reset back to 1.
$query =
'SELECT conf_id
- FROM configuration
+ FROM `opdata`.`configuration`
WHERE type = "flag";';
$result = sql_query($query, pDataConnect());
for ($i = 0; $i < sql_num_rows($result); $i++) {
$row = sql_fetch_assoc_array($result);
$query =
- 'UPDATE configuration
+ 'UPDATE `opdata`.`configuration`
SET value = 0
WHERE conf_id = "' . $row["conf_id"] . '";';
$execute = sql_query($query, pDataConnect());
}
// Save the configurations to the database.
foreach($configurations as $key => $value) {
$query =
- 'UPDATE configuration
+ 'UPDATE `opdata`.`configuration`
SET value = "' . $value . '"
WHERE `key` = "' . $key . '";';
$result = sql_query($query, pDataConnect());
View
7 pos/is4c/login.php
@@ -23,7 +23,6 @@
if (!function_exists("get_config_auto")) {
include_once("lib/conf.php");
- apply_configurations();
}
if (!function_exists("pDataConnect") || !function_exists("tDataConnect")) {
@@ -39,16 +38,16 @@
include("lib/conf.php");
}
- initiate_session();
-
if (!is_config_set()) {
?>
<script type='text/javascript'>
window.top.location = '/configure.php';
</script>
<?php
}
-
+
+ apply_configurations();
+ initiate_session();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
View
2 pos/is4c/variables.php
@@ -1,3 +1,3 @@
<?php
print_r($_SESSION);
-s
+?>

0 comments on commit 7d9dc9e

Please sign in to comment.