Skip to content

Commit

Permalink
Merge pull request #29 from mc12345678/v4.0.35.ZC
Browse files Browse the repository at this point in the history
V4.0.35.ZC
  • Loading branch information
mc12345678 committed May 19, 2016
2 parents c73036e + 120b605 commit e9fbf06
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 56 deletions.
17 changes: 12 additions & 5 deletions admin/easypopulate_4.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4.php, v4.0.34a 04-02-2016 mc12345678 $
// $Id: easypopulate_4.php, v4.0.35.ZC 04-29-2016 mc12345678 $

// CSV VARIABLES - need to make this configurable in the ADMIN
// $csv_delimiter = "\t"; // "\t" = tab AND "," = COMMA
Expand Down Expand Up @@ -78,7 +78,7 @@
//$sql_fail_test == true; // used to cause an sql error on new product upload - tests error handling & logs
/* Test area end */

$curver = '4.0.34.a';
$curver = '4.0.35.ZC';
$message = '';
if (IS_ADMIN_FLAG) {
$new_version_details = plugin_version_check_for_updates(2069, $curver);
Expand All @@ -88,7 +88,7 @@
}

// Current EP Version - Modded by mc12345678 after Chadd had done so much
$curver = $curver . ' - 04-02-2016' . $message;
$curver = $curver . ' - 04-29-2016' . $message;
$display_output = ''; // results of import displayed after script run
$ep_dltype = NULL;
$ep_stack_sql_error = false; // function returns true on any 1 error, and notifies user of an error
Expand All @@ -97,7 +97,12 @@
$zco_notifier->notify('EP4_START');

// Load language file(s) for main screen menu(s).
require(DIR_FS_ADMIN . DIR_WS_LANGUAGES . $_SESSION['language'] . '/easypopulate_4_menus.php');
if(file_exists(DIR_FS_ADMIN . DIR_WS_LANGUAGES . $_SESSION['language'] . '/easypopulate_4_menus.php'))
{
require(DIR_FS_ADMIN . DIR_WS_LANGUAGES . $_SESSION['language'] . '/easypopulate_4_menus.php');
} else {
require(DIR_FS_ADMIN . DIR_WS_LANGUAGES . 'english' . '/easypopulate_4_menus.php');
}

// all mods go in this array as 'name' => 'true' if exist. eg $ep_supported_mods['psd'] => true means it exists.
$ep_supported_mods = array();
Expand Down Expand Up @@ -344,7 +349,9 @@ function init()
</style>
</head>
<body onLoad="init()">
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<?php require(DIR_WS_INCLUDES . 'header.php');
$zco_notifier->notify('EP4_ZC155_AFTER_HEADER');
?>

<!-- body -->
<div style="padding:5px">
Expand Down
79 changes: 52 additions & 27 deletions admin/easypopulate_4_attrib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4_attrib.php, v4.0.32 12-30-2015 mc12345678 $
// $Id: easypopulate_4_attrib.php, v4.0.35 04-21-2016 mc12345678 $

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
Expand All @@ -21,7 +21,8 @@

// READ products_id and products_model from TABLE_PRODUCTS
// Since products_model must be unique (for EP4 at least), this query can be LIMIT 1
$query ="SELECT * FROM ".TABLE_PRODUCTS." WHERE (products_model = '" . addslashes($v_products_model) . "') LIMIT 1";
$query ="SELECT * FROM ".TABLE_PRODUCTS." WHERE (products_model = :v_products_model:) LIMIT 1";
$query = $db->bindVars($query, ':v_products_model', $v_products_model, 'string');
$result = ep_4_query($query);

if (($ep_uses_mysqli ? mysqli_num_rows($result) : mysql_num_rows($result)) == 0) { // products_model is not in TABLE_PRODUCTS
Expand Down Expand Up @@ -67,7 +68,9 @@
// HERE ==> language 1 is main key, and assumbed
$l_id = 1; // temporary check - should this be the default language id?
$query = "SELECT products_options_id, products_options_name FROM ".TABLE_PRODUCTS_OPTIONS."
WHERE products_options_name = '".$v_products_options_name[$l_id]."' AND language_id = '".$l_id."'";
WHERE products_options_name = :v_products_options_name: AND language_id = :language_id:";
$query = $db->bindVars($query, ':v_products_options_name:', $v_products_options_name[$l_id], 'string');
$query = $db->bindVars($query, ':language_id:', $l_id, 'integer');
$result = ep_4_query($query);

// insert new products_options_name
Expand All @@ -88,7 +91,11 @@
$sql = "INSERT INTO ".TABLE_PRODUCTS_OPTIONS."
(products_options_id, language_id, products_options_name, products_options_type)
VALUES
('$v_products_options_id', '".$l_id."', '".$v_products_options_name[$l_id]."', '".zen_db_input($v_products_options_type)."')";
(:v_products_options_id:, :language_id:, :v_products_options_name:, :v_products_options_type:)";
$sql = $db->bindVars($sql, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql = $db->bindVars($sql, ':language_id:', $l_id, 'integer');
$sql = $db->bindVars($sql, ':v_products_options_name', $v_products_options_name[$l_id], 'string');
$sql = $db->bindVars($sql, ':v_products_options_type', $v_products_options_type, 'integer');
$errorcheck = ep_4_query($sql);
}
$new_options_name++;
Expand Down Expand Up @@ -141,9 +148,11 @@
.TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS." as a, "
.TABLE_PRODUCTS_OPTIONS_VALUES." as b
WHERE
a.products_options_id = '".$v_products_options_id."' AND
a.products_options_id = :v_products_options_id: AND
a.products_options_values_id = b.products_options_values_id AND
b.products_options_values_name = '".$values_names_array[$l_id][$values_names_index]."'";
b.products_options_values_name = :values_name:";
$sql = $db->bindVars($sql, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql = $db->bindVars($sql, ':values_name:', $values_names_array[$l_id][$values_names_index], 'string');
$result4 = ep_4_query($sql);

// if $result4 == 0, products_options_values_name not found
Expand All @@ -158,10 +167,14 @@
products_options_values_name,
products_options_values_sort_order)
VALUES (
'$products_options_values_id',
'".$l_id."',
'".$values_names_array[$l_id][$values_names_index]."',
'$products_options_values_sort_order')";
:products_options_values_id:,
:language_id:,
:values_name:,
:products_options_values_sort_order:)";
$sql = $db->bindVars($sql, ':products_options_values_id:', $products_options_values_id, 'integer');
$sql = $db->bindVars($sql, ':language_id:', $l_id, 'integer');
$sql = $db->bindVars($sql, ':values_name:', $values_names_array[$l_id][$values_names_index], 'string');
$sql = $db->bindVars($sql, ':products_options_values_sort_order:', $products_options_values_sort_order, 'integer');
$errorcheck = ep_4_query($sql);
} // foreach
$new_options_values_name++;
Expand All @@ -179,15 +192,16 @@
FROM "
.TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS."
WHERE
products_options_id = '".$v_products_options_id."' AND
products_options_id = :v_products_options_id: AND
products_options_values_id = '0'";
$sql5 = $db->bindVars($sql5, ':v_products_options_id:', $v_products_options_id, 'integer');
$result5 = ep_4_query($sql5);
// if $result5 == 0, combination not found
if (($ep_uses_mysqli ? mysqli_num_rows($result5) : mysql_num_rows($result5)) == 0) { // combination is not in TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS
// insert new combination
$errorcheck = ep_4_query("INSERT INTO ".TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS."
(products_options_values_to_products_options_id, products_options_id, products_options_values_id)
VALUES('$products_options_values_to_products_options_id', '$v_products_options_id', '0')");
VALUES(" . (int)$products_options_values_to_products_options_id . ", " . (int)$v_products_options_id . ", 0)");
} else { // duplicate entry, skip
}
} else { // add $products_options_values_id
Expand All @@ -201,16 +215,18 @@
.TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS. " as a, "
.TABLE_PRODUCTS_OPTIONS_VALUES. " as b
WHERE
a.products_options_id = '".$v_products_options_id."' AND
a.products_options_id = :v_products_options_id: AND
a.products_options_values_id = b.products_options_values_id AND
b.products_options_values_name = '".$values_names_array[$l_id][$values_names_index]."'";
b.products_options_values_name = :values_name:";
$sql5 = $db->bindVars($sql5, ':v_products_options_id', $v_products_options_id, 'integer');
$sql5 = $db->bindVars($sql5, ':values_name:', $values_names_array[$l_id][$values_names_index], 'string');
$result5 = ep_4_query($sql5);

// if $result5 == 0, combination not found
if (($ep_uses_mysqli ? mysqli_fetch_array($result5) : mysql_num_rows($result5)) == 0) { // combination is not in TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS
$errorcheck = ep_4_query("INSERT INTO ".TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS."
(products_options_values_to_products_options_id, products_options_id, products_options_values_id)
VALUES('$products_options_values_to_products_options_id', '$v_products_options_id', '$products_options_values_id')");
VALUES(" . (int)$products_options_values_to_products_options_id . ", " . (int)$v_products_options_id . ", " . (int)$products_options_values_id . ")");
} else { // duplicate entry, skip
}
}
Expand All @@ -220,7 +236,7 @@
if (in_array($v_products_options_type, $exclude_array)) { //
$errorcheck = ep_4_query("INSERT INTO ".TABLE_PRODUCTS_ATTRIBUTES."
(products_id, options_id, options_values_id)
VALUES ('".$v_products_id."', '".$v_products_options_id."','0')");
VALUES (".(int)$v_products_id.", ".(int)$v_products_options_id.",0)");
} else {
$l_id = 1; // default first language is main key
$sql5 = "SELECT
Expand All @@ -232,9 +248,11 @@
.TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS. " as a, "
.TABLE_PRODUCTS_OPTIONS_VALUES. " as b
WHERE
a.products_options_id = '".$v_products_options_id."' AND
a.products_options_id = :v_products_options_id: AND
a.products_options_values_id = b.products_options_values_id AND
b.products_options_values_name = '". $values_names_array[$l_id][$values_names_index]."'";
b.products_options_values_name = :values_name:";
$sql5 = $db->bindVars($sql5, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql5 = $db->bindVars($sql5, ':values_name:', $values_names_array[$l_id][$values_names_index], 'string');
$result5 = ep_4_query($sql5);

$row5 = ($ep_uses_mysqli ? mysqli_fetch_array($result5) : mysql_fetch_array($result5));
Expand All @@ -247,23 +265,30 @@
$sql6 = "SELECT * FROM "
.TABLE_PRODUCTS_ATTRIBUTES. "
WHERE
products_id = '".$v_products_id."' AND
options_id = '".$v_products_options_id."' AND
options_values_id = '".$a_products_options_values_id."'";
products_id = :v_products_id: AND
options_id = :v_products_options_id: AND
options_values_id = :a_products_options_values_id:";
$sql6 = $db->bindVars($sql6, ':v_products_id:', $v_products_id, 'integer');
$sql6 = $db->bindVars($sql6, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql6 = $db->bindVars($sql6, ':a_products_options_values_id:', $a_products_options_values_id, 'integer');
$result6 = ep_4_query($sql6);
$row6 = ($ep_uses_mysqli ? mysqli_fetch_array($result6) : mysql_fetch_array($result6));
if (($ep_uses_mysqli ? mysqli_num_rows($result6) : mysql_num_rows($result6)) == 0) {
$errorcheck = ep_4_query("INSERT INTO ".TABLE_PRODUCTS_ATTRIBUTES."
(products_id, options_id, options_values_id)
VALUES ('".$v_products_id."', '".$v_products_options_id."','".$a_products_options_values_id."')");
VALUES (".(int)$v_products_id.", ".(int)$v_products_options_id.",".(int)$a_products_options_values_id.")");
$table_products_attributes_update = 0;
} else { // UPDATE
$sql7 ="UPDATE ".TABLE_PRODUCTS_ATTRIBUTES." SET
products_options_sort_order ='".$values_names_index."'
products_options_sort_order = :values_names_index:
WHERE
products_id = '".$v_products_id."' AND
options_id = '".$v_products_options_id."' AND
options_values_id = '".$a_products_options_values_id."'";
products_id = :v_products_id: AND
options_id = :v_products_options_id: AND
options_values_id = :a_products_options_values_id:";
$sql7 = $db->bindVars($sql7, ':values_names_index:', $values_names_index, 'integer');
$sql7 = $db->bindVars($sql7, ':v_products_id:', $v_products_id, 'integer');
$sql7 = $db->bindVars($sql7, ':v_products_options_id:', $v_products_options_id, 'integer');
$sql7 = $db->bindVars($sql7, ':a_products_options_values_id:', $a_productsion_options_values_id, 'integer');
$errorcheck = ep_4_query($sql7);
$table_products_attributes_update = 1;
}
Expand Down Expand Up @@ -300,4 +325,4 @@
} // END: if
} // END: while #2
} // END: while #1
?>
?>
Loading

0 comments on commit e9fbf06

Please sign in to comment.