Skip to content

Commit

Permalink
Merge pull request #20 from mc12345678/master
Browse files Browse the repository at this point in the history
Update to master to V4.0.30
  • Loading branch information
mc12345678 committed Aug 5, 2015
2 parents df067fa + 06ea22c commit 22e95a9
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 51 deletions.
174 changes: 132 additions & 42 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.28 01-03-2015 mc12345678 $
// $Id: easypopulate_4.php, v4.0.30 06-27-2015 mc12345678 $

// CSV VARIABLES - need to make this configurable in the ADMIN
// $csv_delimiter = "\t"; // "\t" = tab AND "," = COMMA
Expand Down Expand Up @@ -30,7 +30,7 @@

@set_time_limit($ep_execution); // executin limit in seconds. 300 = 5 minutes before timeout, 0 means no timelimit

if (!$error) {
if ((isset($error) && !$error) || !isset($error)) {
$upload_max_filesize=ini_get("upload_max_filesize");
if (preg_match("/([0-9]+)K/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
if (preg_match("/([0-9]+)M/i",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
Expand All @@ -46,8 +46,8 @@
//$sql_fail_test == true; // used to cause an sql error on new product upload - tests error handling & logs
/* Test area end */

// Current EP Version - Modded by Chadd
$curver = '4.0.28 - Beta 01-03-2015';
// Current EP Version - Modded by mc12345678 after Chadd had done so much
$curver = '4.0.30 - Beta 06-27-2015';
$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 @@ -58,7 +58,7 @@
$ep_supported_mods = array();

// default smart-tags setting when enabled. This can be added to.
$smart_tags = array("\r\n|\r|\n" => '<br/>', ); // need to check into this more
$smart_tags = array("\r\n|\r|\n" => '<br />', ); // need to check into this more

if (substr($tempdir, -1) != '/') $tempdir .= '/';
if (substr($tempdir, 0, 1) == '/') $tempdir = substr($tempdir, 1);
Expand Down Expand Up @@ -99,8 +99,11 @@
$ep_supported_mods['upc'] = ep_4_check_table_column(TABLE_PRODUCTS,'products_upc'); // upc = UPC Code, added by Chadd
$ep_supported_mods['gpc'] = ep_4_check_table_column(TABLE_PRODUCTS,'products_gpc'); // gpc = google product category for Google Merchant Center, added by Chadd 10-1-2011
$ep_supported_mods['msrp'] = ep_4_check_table_column(TABLE_PRODUCTS,'products_msrp'); // msrp = manufacturer's suggested retail price, added by Chadd 1-9-2012
$ep_supported_mods['map'] = ep_4_check_table_column(TABLE_PRODUCTS,'map_enabled');
$ep_supported_mods['map'] = ($ep_supported_mods['map'] && ep_4_check_table_column(TABLE_PRODUCTS, 'map_price'));
$ep_supported_mods['gppi'] = ep_4_check_table_column(TABLE_PRODUCTS,'products_group_a_price'); // gppi = group pricing per item, added by Chadd 4-24-2012
$ep_supported_mods['excl'] = ep_4_check_table_column(TABLE_PRODUCTS,'products_exclusive'); // exclu = Custom Mod for Exclusive Products: 04-24-2012
$ep_supported_mods['dual'] = ep_4_check_table_column(TABLE_PRODUCTS_ATTRIBUTES, 'options_values_price_w');
// END: check for existance of various mods

// custom products fields check
Expand Down Expand Up @@ -225,7 +228,7 @@
}

// Handle file deletion (delete only in the current directory for security reasons)
if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"])) {
if (((isset($error) && !$error) || !isset($error)) && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"])) {
if (preg_match("/(\.(sql|gz|csv|txt|log))$/i",$_REQUEST["delete"]) && @unlink($upload_dir.basename($_REQUEST["delete"]))) {
// $messageStack->add(sprintf($_REQUEST["delete"]." was deleted successfully"), 'success');
zen_redirect(zen_href_link(FILENAME_EASYPOPULATE_4));
Expand Down Expand Up @@ -272,13 +275,13 @@ function init()
<?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?>
<div class="pageHeading"><?php echo "Easy Populate $curver"; ?></div>

<div style="text-align:right; float:right; width:25%"><a href="<?php echo zen_href_link(FILENAME_EASYPOPULATE_4, 'epinstaller=remove') ?>">Un-Install EP4</a>
<div style="text-align:right; float:right; width:25%"><a href="<?php echo zen_href_link(FILENAME_EASYPOPULATE_4, 'epinstaller=remove') ?>"><?php echo EASYPOPULATE_4_REMOVE_SETTINGS; ?></a>
<?php
echo '<br/><b><u>Configuration Settings</u></b><br/>';
echo 'Upload Directory: <b>'.$tempdir.'</b><br/>';
echo '<br/><b><u>' . EASYPOPULATE_4_CONFIG_SETTINGS . '</u></b><br/>';
echo EASYPOPULATE_4_CONFIG_UPLOAD . '<b>'.$tempdir.'</b><br/>';
echo 'Verbose Feedback: '.(($ep_feedback) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo 'Split Records: '.$ep_split_records.'<br/>';
echo 'Execution Time: '.$ep_execution.'<br/>';
echo EASYPOPULATE_4_DISPLAY_SPLIT_SHORT . $ep_split_records.'<br/>';
echo EASYPOPULATE_4_DISPLAY_EXEC_TIME . $ep_execution.'<br/>';
switch ($ep_curly_quotes) {
case 0:
$ep_curly_text = "No Change";
Expand All @@ -303,8 +306,8 @@ function init()
}
echo 'Convert Curly Quotes: '.$ep_curly_text.'<br/>';
echo 'Convert Char 0x92: '.$ep_char92_text.'<br/>';
echo 'Enable Products Metatags: '.$ep_metatags.'<br/>';
echo 'Enable Products Music: '.$ep_music.'<br/>';
echo EASYPOPULATE_4_DISPLAY_ENABLE_META.$ep_metatags.'<br/>';
echo EASYPOPULATE_4_DISPLAY_ENABLE_MUSIC.$ep_music.'<br/>';

echo '<br/><b><u>Custom Products Fields</u></b><br/>';
echo 'Product Short Descriptions: '.(($ep_supported_mods['psd']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
Expand All @@ -313,13 +316,14 @@ function init()
// Google Product Category for Google Merchant Center
echo 'Google Product Category: '.(($ep_supported_mods['gpc']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Manufacturer's Suggested Retail Price: ".(($ep_supported_mods['msrp']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Group Pricing Per Item: ".(($ep_supported_mods['gppi']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Manufacturer's Advertised Price: ".(($ep_supported_mods['map']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Group Pricing Per Item: ".(($ep_supported_mods['gppi']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Exclusive Products Mod: ".(($ep_supported_mods['excl']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "Stock By Attributes Mod: ".(($ep_4_SBAEnabled != false) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
echo "CEON URI Rewriter Mod: " . (($ep4CEONURIDoesExist == true) ? '<font color="green">TRUE</font>' : "FALSE") . '<br/>';
echo "Dual Pricing Mod: " . (($ep_supported_mods['dual']) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';


echo "<br/><b><u>User Defined Products Fields: </b></u><br/>";
echo "<br/><b><u>User Defined Products Fields: </u></b><br/>";
$i = 0;
foreach ($custom_field_names as $field) {
echo $field.': '.(($custom_field_check[$i]) ? '<font color="green">TRUE</font>':"FALSE").'<br/>';
Expand Down Expand Up @@ -403,7 +407,7 @@ function init()
echo zen_draw_input_field('export', 'Export', ' style="padding: 0px"', false, 'submit');
?>
<br/><br/>
</div>
</div></form>

<b>Product &amp; Pricing Export/Import Options:</b><br/>
<!-- Download file links -->
Expand Down Expand Up @@ -438,22 +442,89 @@ function init()
// List uploaded files in multifile mode
// Table header
echo '<br/><br/>';
echo "<table id=\"epfiles\" width=\"80%\" border=1 cellspacing=\"2\" cellpadding=\"2\">\n";
echo "<tr><th>File Name</th><th>Size</th><th>Date &amp; Time</th><th>Type</th><th>Split</th><th>Import</th><th>Delete</th><th>Download</th>\n";
// echo "<table id=\"epfiles\" width=\"80%\" border=1 cellspacing=\"2\" cellpadding=\"2\">\n";
// $upload_dir = DIR_FS_CATALOG.$tempdir; // defined above
if ($dirhandle = opendir($upload_dir)) {
$files = array();
while (false !== ($files[] = readdir($dirhandle))); // get directory contents
closedir($dirhandle);
$file_count = 0;
sort($files);
foreach ($files as $dirfile) {
if ( ($dirfile != ".") && ($dirfile != "..") && preg_match("/\.(sql|gz|csv|txt|log)$/i",$dirfile) ) {
$file_count++;
echo '<tr><td>'.$dirfile.'</td>
<td align="right">'.filesize($upload_dir.$dirfile).'</td>
<td align="center">'.date ("Y-m-d H:i:s", filemtime($upload_dir.$dirfile)).'</td>';
$ext = strtolower(end(explode('.', $dirfile)));
/*
* Have a list of files... Now need to work through them to identify what they can do.
* After identified what they can do, need to generate the screen view of their option(s). Ideally, every file will have the same capability, but will be grouped with a title and associated action.
* So need to identify the "#" of groups, and loop through the files for those groups. Probably a case statement
*/

$filenames =
array(
"attrib-basic-ep"=>ATTRIB_BASIC_EP,
"attrib-detailed-ep"=>ATTRIB_DETAILED_EP_DESC,
"category-ep"=>CATEGORY_EP_DESC,
"categorymeta-ep"=>CATEGORYMETA_EP_DESC,
"featured-ep"=>FEATURED_EP_DESC,
"pricebreaks-ep"=>PRICEBREAKS_EP_DESC,
"priceqty-ep"=>PRICEQTY_EP_DESC,
"sba-detailed-ep"=>SBA_DETAILED_EP_DESC,
"sba-stock-ep"=>SBA_STOCK_EP_DESC
);

$filetypes = array();

for ($i = 0; $i < sizeof($files); $i++) {
if ( ($files[$i] != ".") && ($files[$i] != "..") && preg_match("/\.(sql|gz|csv|txt|log)$/i",$files[$i]) ) {
$found = false;

foreach ($filenames as $key=>$val) {
if (strtolower(substr($files[$i],0,strlen($key))) == strtolower($key)) {
$filetypes[$key][] = $i;
$found = true;
break;
}
}

if ($found == false) {
// Treat as an everything else file.
$filetypes['zzzzzzzz'][] = $i;
}
} // End of if file is one to manage here.
} // End For $i of $files
ksort($filetypes);

$filenames =
array_merge($filenames, array("zzzzzzzz"=>CATCHALL_EP_DESC));

echo "\n";
echo "\n";
echo "<table id=\"epfiles\" width=\"80%\" border=1 cellspacing=\"2\" cellpadding=\"2\">\n";
if (EP4_SHOW_ALL_FILETYPES == 'Hidden') {
echo "<tr><th>File Name</th><th>Size</th><th>Date &amp; Time</th><th>Type</th><th>Split</th><th>Import</th><th>Delete</th><th>Download</th>\n";
}

foreach ((EP4_SHOW_ALL_FILETYPES != 'False' ? $filenames : $filetypes ) as $key=>$val) {
(EP4_SHOW_ALL_FILETYPES != 'False' ? $val = $filetypes[$key] : '');
if (EP4_SHOW_ALL_FILETYPES == 'Hidden') {
$val = array();
for ($i = 0; $i < sizeof($files); $i++){
$val[$i] = $i;
}
}

$file_count = 0;
//Display the information needed to start use of a filetype.
$plural_state = "<strong>" . (sizeof($val) > 1 ? EP_DESC_PLURAL : EP_DESC_SING) . "</strong>";
if (EP4_SHOW_ALL_FILETYPES != 'Hidden') {
echo "<tr><td colspan=\"8\">" . sprintf($filenames[$key], "<strong>" . $key . "</strong>", $plural_state) . "</td></tr>";
echo "<tr><th>File Name</th><th>Size</th><th>Date &amp; Time</th><th>Type</th><th>Split</th><th>Import</th><th>Delete</th><th>Download</th>\n";
}

for ($i=0; $i < sizeof($val); $i++) {
if (EP4_SHOW_ALL_FILETYPES != 'Hidden' || (EP4_SHOW_ALL_FILETYPES == 'Hidden' && ($files[$i] != ".") && ($files[$i] != "..") && preg_match("/\.(sql|gz|csv|txt|log)$/i",$files[$i]) )) {
$file_count++;
echo '<tr><td>'.$files[$val[$i]].'</td>
<td align="right">'.filesize($upload_dir.$files[$val[$i]]).'</td>
<td align="center">'.date ("Y-m-d H:i:s", filemtime($upload_dir.$files[$val[$i]])).'</td>';
$ext = strtolower(end(explode('.', $files[$val[$i]])));
// file type
switch ($ext) {
case 'sql':
Expand All @@ -476,30 +547,49 @@ function init()
// file management
if ($ext == 'csv') {
// $_SERVER["PHP_SELF"] vs $_SERVER['SCRIPT_NAME']
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?split=".$dirfile."\">Split</a></td>\n";
if (strtolower(substr($dirfile,0,12))== "sba-stock-ep") {
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$dirfile."\">Import</a><br/><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$dirfile."&sync=1\">Import w/Sync</a></td>\n";
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?split=".$files[$val[$i]]."\">Split</a></td>\n";
if (strtolower(substr($files[$val[$i]],0,12))== "sba-stock-ep") {
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$files[$val[$i]]."\">Import</a><br/><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$files[$val[$i]]."&amp;sync=1\">Import w/Sync</a></td>\n";
} else {
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$dirfile."\">Import</a></td>\n";
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?import=".$files[$val[$i]]."\">Import</a></td>\n";
}
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?delete=".urlencode($dirfile)."\">Delete file</a></td>";
echo "<td align=center><a href=".DIR_WS_CATALOG.$tempdir.$dirfile." target=_blank>Download</a></td></tr>\n";
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?delete=".urlencode($files[$val[$i]])."\">Delete file</a></td>";
echo "<td align=center><a href=\"".DIR_WS_CATALOG.$tempdir.$files[$val[$i]]."\" target=_blank>Download</a></td></tr>\n";
} else {
echo "<td>&nbsp;</td>\n";
echo "<td>&nbsp;</td>\n";
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?delete=".urlencode($dirfile)."\">Delete file</a></td>";
echo "<td align=center><a href=".DIR_WS_CATALOG.$tempdir.$dirfile." target=_blank>Download</a></td></tr>\n";
echo "<td align=center><a href=\"".$_SERVER['SCRIPT_NAME']."?delete=".urlencode($files[$val[$i]])."\">Delete file</a></td>";
echo "<td align=center><a href=\"".DIR_WS_CATALOG.$tempdir.$files[$val[$i]]."\" target=_blank>Download</a></td></tr>\n";
}
} // if (file types)
} // foreach
if ( $file_count == 0 ) {
echo "<tr><td COLSPAN=8><font color='red'><b>No Supported Data Files</b></font></td></tr>\n";
} // if (sizeof($files)>0)
}
} // End loop within a filetype
if ( $file_count == 0 && EP4_SHOW_ALL_FILETYPES != 'Hidden') {
echo "<tr><td COLSPAN=8><font color='red'><b>No Supported Data Files </b></font></td></tr>\n";
} // if (sizeof($files)>0)
if (EP4_SHOW_ALL_FILETYPES == 'Hidden') {
break;
}
} // End foreach filetype
if (EP4_SHOW_ALL_FILETYPES != 'Hidden') {
echo "</table>\n";
if (sizeof($filetypes) == 0) {
echo "<table id=\"epfiles\" width=\"80%\" border=1 cellspacing=\"2\" cellpadding=\"2\">\n";
echo "<tr><td COLSPAN=8><font color='red'><b>No Supported Data Files</b></font></td></tr>\n";
echo "</table>\n";
}
}
} else { // can't open directory
echo "<tr><td COLSPAN=8><font color='red'><b>Error Opening Upload Directory:</b></font> ".$tempdir."</td></tr>\n";
$error=true;
} // opendir()
echo "</table>\n";
if (EP4_SHOW_ALL_FILETYPES == 'Hidden') {
echo "</table>\n";
if (sizeof($filetypes) == 0) {
echo "<table id=\"epfiles\" width=\"80%\" border=1 cellspacing=\"2\" cellpadding=\"2\">\n";
echo "<tr><td COLSPAN=8><font color='red'><b>No Supported Data Files</b></font></td></tr>\n";
echo "</table>\n";
}
}



Expand All @@ -522,11 +612,11 @@ function init()
<?php
echo $display_output; // upload results
if (strlen($specials_print) > strlen(EASYPOPULATE_4_SPECIALS_HEADING)) {
echo '<br/>' . $specials_print . EASYPOPULATE_4_SPECIALS_FOOTER; // specials summary
echo '<br />' . $specials_print . EASYPOPULATE_4_SPECIALS_FOOTER; // specials summary
}
?>
</div>
<br/>
<br />
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
</body>
</html>
Expand Down
28 changes: 25 additions & 3 deletions admin/easypopulate_4_import.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: easypopulate_4_import.php, v4.0.28 01-03-2015 mc12345678 $
// $Id: easypopulate_4_import.php, v4.0.29 04-03-2015 mc12345678 $

// BEGIN: Data Import Module
if ( isset($_GET['import']) ) {
Expand Down Expand Up @@ -35,6 +35,10 @@
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$default_these[] = 'v_products_msrp';
}
if ($ep_supported_mods['map'] == true) { // Manufacturer's Advertised Price
$default_these[] = 'v_map_enabled';
$default_these[] = 'v_map_price';
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item - 4-24-2012
$default_these[] = 'v_products_group_a_price';
$default_these[] = 'v_products_group_b_price';
Expand Down Expand Up @@ -197,6 +201,12 @@
// UPDATE
$sql = "UPDATE ".TABLE_PRODUCTS_ATTRIBUTES." SET
options_values_price = ".$items[$filelayout['v_options_values_price']].",
";
if ($ep_supported_mods['dual']) {
$sql .= "options_values_price_w = ".$items[$filelayout['v_options_values_price_w']].",";
}

$sql .= "
price_prefix = '".$items[$filelayout['v_price_prefix']]."',
products_options_sort_order = ".$items[$filelayout['v_products_options_sort_order']].",
product_attribute_is_free = ".$items[$filelayout['v_product_attribute_is_free']].",
Expand Down Expand Up @@ -289,7 +299,7 @@
stock_attributes = '".$items[$filelayout['v_stock_attributes']]."',
quantity = ".$items[$filelayout['v_quantity']].",
sort = ".$items[$filelayout['v_sort']]. ( $ep_4_SBAEnabled == '2' ? ",
customid = ".$items[$filelayout['v_customid']] : " ") .
customid = '" . $items[$filelayout['v_customid']] . "' " : " ") .
"
WHERE (
stock_id = ".$items[$filelayout['v_stock_id']]." )";
Expand Down Expand Up @@ -518,6 +528,10 @@
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$sql .= 'p.products_msrp as v_products_msrp,';
}
if ($ep_supported_mods['map'] == true) { // Manufacturer's Advertised Price
$sql .= 'p.map_enabled as v_map_enabled,';
$sql .= 'p.map_price as v_map_price,';
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$sql .= 'p.products_group_a_price as v_products_group_a_price,';
$sql .= 'p.products_group_b_price as v_products_group_b_price,';
Expand Down Expand Up @@ -586,7 +600,7 @@
foreach ($langcode as $key => $lang) {
$sql2 = 'SELECT * FROM '.TABLE_PRODUCTS_DESCRIPTION.' WHERE products_id = '.$row['v_products_id'].' AND language_id = '.$lang['id'];
$result2 = ep_4_query($sql2);
$row2 = ($ep_uses_mysqli ? mysqli_fetch_array($result) : mysql_fetch_array($result2));
$row2 = ($ep_uses_mysqli ? mysqli_fetch_array($result2) : mysql_fetch_array($result2));
// create variables (v_products_name_1, v_products_name_2, etc. which corresponds to our column headers) and assign data
$row['v_products_name_'.$lang['id']] = ep_4_curly_quotes($row2['products_name']);

Expand Down Expand Up @@ -1173,6 +1187,10 @@
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$query .= "products_msrp = '".$v_products_msrp."',";
}
if ($ep_supported_mods['map'] == true) { // Manufacturer's Advertised Price
$query .= "map_enabled = '".$v_map_enabled."',";
$query .= "map_price = '".$v_map_price."',";
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$query .= "products_group_a_price = '".$v_products_group_a_price."',";
$query .= "products_group_b_price = '".$v_products_group_b_price."',";
Expand Down Expand Up @@ -1269,6 +1287,10 @@
if ($ep_supported_mods['msrp'] == true) { // Manufacturer's Suggested Retail Price
$query .= "products_msrp = '".$v_products_msrp."',";
}
if ($ep_supported_mods['map'] == true) { // Manufacturer's Advertised Price
$query .= "map_enabled = '".$v_map_enabled."',";
$query .= "map_price = '".$v_map_price."',";
}
if ($ep_supported_mods['gppi'] == true) { // Group Pricing Per Item
$query .= "products_group_a_price = '".$v_products_group_a_price."',";
$query .= "products_group_b_price = '".$v_products_group_b_price."',";
Expand Down
Loading

0 comments on commit 22e95a9

Please sign in to comment.