Jump to content

christoph_999

Members
  • Content count

    15
  • Joined

  • Last visited

Everything posted by christoph_999

  1. christoph_999

    [Contribution] Secure Admin Login - Logout

    Hi Sara I know now, what the problem is: The problem was, that i was still logged in into the administration, i just closed the page. So, the bot came in whith my own session, which was still active. And because there was no robots.txt, the bot entered the administration. And then he followed all links and whith following the links, he activated and deactivated some configurations. Loading the robots.txt and disallowing /admin was a good thing. A timestamp which closes the session after x time of inactivity would be great. Bye Chris
  2. christoph_999

    [Contribution] Secure Admin Login - Logout

    Hi I think , i have found a security issue. I was wondering again and again about some configurations not beeing exactly as i left the shopadministration last day. i first thought about a hacker, but the domain was brandnew and so nobody knew about it. nobody but alexa. alexa has the ia_archiver which works for the waybackmachine. in my logs i found this: 209.234.171.38 - - [23/Jun/2008:04:49:05 +0200] "GET /robots.txt HTTP/1.0" 404 279 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:06 +0200] "GET /admin/affiliate_summary.php?selected_box=affiliate&osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 21046 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:07 +0200] "GET /admin/login.php?refer=%2Fadmin%2Faffiliate_summary.php%3Fselected_box%3Daffiliate%26osCAdminID%3Dcf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 200 1977 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:10 +0200] "GET /admin/articles.php?selected_box=articles&osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 39540 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:12 +0200] "GET /admin/login.php?refer=%2Fadmin%2Farticles.php%3Fselected_box%3Darticles%26osCAdminID%3Dcf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 200 1967 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:15 +0200] "GET /admin/categories.php?cPath=161&osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 31539 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:17 +0200] "GET /admin/login.php?refer=%2Fadmin%2Fcategories.php%3FcPath%3D161%26osCAdminID%3Dcf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 200 1957 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:21 +0200] "GET /admin/categories.php?osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 24912 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:21 +0200] "GET /admin/login.php?refer=%2Fadmin%2Fcategories.php%3FosCAdminID%3Dcf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 200 1947 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:26 +0200] "GET /admin/categories.php?selected_box=catalog&osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 25980 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:26 +0200] "GET /admin/login.php?refer=%2Fadmin%2Fcategories.php%3Fselected_box%3Dcatalog%26osCAdminID%3Dcf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 200 1968 "-" "ia_archiver" 209.234.171.38 - - [23/Jun/2008:04:49:31 +0200] "GET /admin/categories.php?selected_box=infobox&osCAdminID=cf7eb89001a7867f9e53b7d4124ca674 HTTP/1.0" 302 22925 "-" "ia_archiver" and i tried one of the links shown here. and it worked, i could open the page and work in it and then go further to another file and work in the other file the bot is using a sid. i am normally not, i have enabled cookies. now that i noticed, that the bot is reading robots.txt, i have uploaded a robots.txt and disallowed admin but thats not a solution has anybody else problems about some configurations changing from time to time? for example. attributes: i had downloads enabled, and the attributes didnt have the downloadfile anymore. attributes changed positions. specials enabled after some days when left disabled. some other features changing again and again whithout your interaction. i think, this is a severe problem. normally a bot should not have the possibility to login with a session id. but it really worked here. as i logged out, it was not possible anymore to login with this session-id. but as long as i didnt logout, i could make everything. sorry for my bad english, i hope everyone understood, what i meant. if not, please do not hesitate and post here.
  3. christoph_999

    "Dynamenu" for osCommerce

    Hi Bill Seems, i have the same problem as Eric (Dynatech) has got. I wanted to use STS too with dynamenu. (STS 4.3) I have done really EVERYTHING as you told and much more to get it running. I even did put the menu into a layer, because someone wrote, that tables would confuse the menu. Same problem: Menu doesnt fly out. (Horizontal menu) BUT: it is not the problem of stylesheet or somthing else. The VERTICAL menu functions correctly with fly out. Both, the vertical AND horizontal work perfect, when not using STS I have got some failure-messages from a developper-tool for firefox: The messages: moveLayerX1 is not definded (http://my.domain.at/index.php) line: 1 clearMTO is not defined (http://my.domain.at/index.php) line: 1 setLMTO is not defined (http://my.domain.at/index.php) line: 1 Can you deal with the failures? I dont understand them. Could you help me out? If you want to see the site, where it doesnt function, just tell me Thank you very much Christoph
  4. christoph_999

    PC Pro Creator

    THANK YOU, THANK YOU SOOOOOO MUCH. That was the part, i didnt understood. You have to give the assemble fee field in the configuration a value AND make a product in ROOT. Now it works --> PERFECT many thanks to you, you are my personal hero ;-) EDIT: what if you dont have ANY assembling fees? its not possible to set the field to 0.00 or leave it blank, because otherwise the pcconfigurator on client-side will not work anymore
  5. christoph_999

    PC Pro Creator

    Hi thanks for help, where is the assembly fee? In the new product, which i have to make or in CPC-configuration? Because in the new product, there is nothing where i could put assembly fee in Thank you for helping
  6. christoph_999

    PC Pro Creator

    Hi Meisterbartsch Mein Englisch ist wirklich nicht so besonders, als dass ich vielleicht auch klar ausdr?cken k?nnte, was mein Problem ist ;-) Deswegen (ich hoffe, das st?rt nicht) schreib ich hier nochmal auf deutsch: Ich habe bereits mehrere Versionen ausprobiert und sehe nirgends eine Option, um die Montagekosten a) in 2 oder mehrfacher Ausf?hrung irgedwo einzutragen b ) sie ganz wegzulassen bei a) ist klar, entweder bin ich blind oder bl?d, ich finds einfach nirgends, aber ich hab nat?rlich auch bemerkt, dass Du bei Deinem Screenshot, den Du schon hergezeigt hast, auch deutsche Sprache drin hast. Ich hab schon nach den Dateien f?r die Administration gesucht, finde aber nur ?berall entweder englisch, oder englisch und polnisch. Vielleicht hab ich ja ?berhaupt eine falsche Version oder so? Kann das sein? K?nntest Du mir vielleicht die derzeitig g?ltige Version nennen, in der das alles enthalten ist? ach ja, ich sollte noch zu b ) kommen Ok, wenn ich also versuche, das Montage-Feld ?berhaupt wegzulassen, indem ich einfach 0.00 ins Assembly Fee - Feld eintrage, dann wird das zwar in der Adminsitration angenommen, l?sst aber im Shop das compbuild.php nicht weiterladen, da steht dann einfach nur "l?dt........" und es tut sich aber nichts. Ich finde Deine Contribution wirklich total genial und es hat lange gedauert, bis ich darauf gestossen bin. Jetzt bin ich nat?rlich auch schon ganz quirlig und h?tte sie am allerliebsten schon gestern zum Laufen gebracht. Du siehst vielleicht an der Uhrzeit (es ist schon fr?h --> "schon") Schon deswegen, weil ich die ganze Nacht damit verbracht hab, es zum Laufen zu bringen. Bin aber schon verzweifelt und dachte mir noch als letzte "Verzweiflungs" tat schreibe ich Dir noch, bevor ich jetzt schlafen geh. Hilfst Du mir bitte? Ja? Danke danke danke danke :rolleyes:
  7. christoph_999

    PC Pro Creator

    Hi Meisterbartsch I have severe troubles making it work like on your or others pages. I have problems with the Assembly Fee I have already tried more versions, i.e. the one from 15.08. 18.07. But at both versions i have the same problem: when i add some assemblyfee (ie 100$), the compbuild.php doesnt show any assembly fee. There is the choice to choose an assembly fee, but there is no choice in it. Just "Montage" to click, but nothing happen, when clicking it. At individual-systems.de it is working properly. And i do not have any option to insert more than 1 assembly fee (you wrote: + enable compbulid to handle multiple assemblyfees -> done July 18th 2006 --> in contrib section) But i do have just the possibility to add 1 assembly fee. Further its not possible to leave the field blank or set assembly fee to 0.00 because compbuild.php will not stop to load something, so it will not appear (on client side) Please could you help me? What did i do wrong? Thanks for replies and sorry for my bad english
  8. christoph_999

    Contrib Installer

    Ok, next problem is: (I already wrote in your forum on http://cip.net.ua/forum/viewtopic.php?t=16 ) Everywhere in the files, where code has been replaced, there are little squares at the end of each line. I dont know where it comes from, i think from /n or /r which is making a break to the next line. I tried to find this in your contrib, but wasnt able. I think, this is not such a big problem as i wrote in your forum, i tested this, it is not the reason, why contributions cannot be uninstalled. Sometimes the uninstall doesnt work, contrib installer tells you, everything fine, but when you look in the log, there are errors, where text couldnt be found anymore. I will be testing further now to tell you more malfunctions. But i think, first of all you should make the problem with the ending slashes gone. When you want to write me a mail, then write to stefan683 at gmx.at
  9. christoph_999

    Contrib Installer

    Hi Vlad First of all: its a really GREAT contribution, i like it very much. I tried already a little bit more with your contribution. Here are the problems, when using it. (I installed on several systems, then uninstalled, then installed again and so on for testing purposes) The version i used, was version 1.0.16 Why? this was the only one version, where i was able (i am not a coder) to deactivate the sql-dump, in 2.0.5 i was looking for functions of sqldump, but wasnt able to "read" the code. Why this? The database on the shop was so big, that there was an execution error, so i couldnt install Contrib installer. As i removed the backup function, it worked. Here the problems: Any version (2.05 as well as 1.0.16) cannot deal with PHP-Version 4.4.4 This php-Version has a problem with the ending slash, when creating directories. I tried this in 1.0.16 in file admin/includes/functions/contrib_installer_base.php --------------------------------------------------------------- function recursive_chmod($path, $mod=0777) { if (is_dir($path) && $path!='/') { recursive_chmod(dirname($path)); //echo "chmod: ".$path." - ".$mod."<br>"; chmod($path, $mod); } } function recursive_mkdir($path) { if (!file_exists($path)) { if (is_dir($path)) { // HERE IS WHAT I INSERTED while (substr($path, -1, 1) == '/') $path = substr($path, 0, strlen($path)-1); // INSERT END recursive_permissions_check($path); //if (!is_writeable($path)) chmod($path, 0777); } else { // HERE IS WHAT I INSERTED while (substr(dirname($path), -1, 1) == '/') $path = substr(dirname($path), 0, strlen(dirname($path)-1)); // INSERT END recursive_mkdir(dirname($path)); //chmod(dirname($path), 0777); if (!is_writeable(dirname($path))) error('(recursive_mkdir) '.WRITE_PERMISSINS_NEEDED_TEXT.dirname($path).'/'); if(!@mkdir($path, 0777)) error ('(recursive_mkdir) '.CANT_CREATE_DIR_TEXT.$path); chmod($path, 0777); } } } ------------------------------------------- but with this i only got one step further. It created the directory /contributions/ Then the next error came I need write permission for: /home/.sites/69/site229/web/AAATEST5/admin/contributions/Contrib_Installer_1.0.16 The /Contrib_Installer_1.0.16 Directory was NOT created So i created it by myself and got the next errors when executing already install.xml (recursive_mkdir) Couldn't create directory: /home/.sites/69/site229/web/AAATEST5/admin/backups/Contrib_Installer_1.0.16/admin/ (So here again the errors with creating directories) I will write next problem in a new thread
  10. christoph_999

    Is there a support thread for SID Killer ?

    The same thing at my place, there is a new Version of seo.class . I tried to modify the new one to get the same result, but i am not a coder at all, so i couldnt make it. NFRobertson, could you help please? I am using the version 2.2.2 with the mysql-fix, because my provider upgraded to mysql 5. the others take this one now as "base-revision". In those versions there isnt if(isset($_sid) anymore sorry for my bad english, have a nice day
  11. christoph_999

    Easy Populate & Products Attributes

    Hi all Can someone give me a sample output-file with pricebreaks, so i could change it an upload all my products? I am not able to download the existing products with pricebreaks. Would be very helpful for me Thanks in advance
  12. christoph_999

    Easy Populate & Products Attributes

    Hi All Is there a solution for my problem? I wrote yesterday Thanks
  13. christoph_999

    Easy Populate & Products Attributes

    THIS IS MY EASYPOPULATE.PHP <?php // Current EP Version $curver = '2.76-MS2'; /* $Id: easypopulate.php,v 2.75 2005/04/05 AL Exp $ */ // //******************************* //******************************* // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* // **** Temp directory **** // if you changed your directory structure from stock and do not have /catalog/temp/, then you'll need to change this accordingly. // $tempdir = "/shop/temp/"; $tempdir2 = "/shop/temp/"; //**** File Splitting Configuration **** // we attempt to set the timeout limit longer for this script to avoid having to split the files // NOTE: If your server is running in safe mode, this setting cannot override the timeout set in php.ini // uncomment this if you are not on a safe mode server and you are getting timeouts // set_time_limit(330); // if you are splitting files, this will set the maximum number of records to put in each file. // if you set your php.ini to a long time, you can make this number bigger global $maxrecs; $maxrecs = 300; // default, seems to work for most people. Reduce if you hit timeouts //$maxrecs = 4; // for testing //**** Image Defaulting **** global $default_images, $default_image_manufacturer, $default_image_product, $default_image_category; // set them to your own default "We don't have any picture" gif //$default_image_manufacturer = 'no_image_manufacturer.gif'; //$default_image_product = 'no_image_product.gif'; //$default_image_category = 'no_image_category.gif'; // or let them get set to nothing $default_image_manufacturer = ''; $default_image_product = ''; $default_image_category = ''; //**** Status Field Setting **** // Set the v_status field to "Inactive" if you want the status=0 in the system // Set the v_status field to "Delete" if you want to remove the item from the system <- THIS IS NOT WORKING YET! // If zero_qty_inactive is true, then items with zero qty will automatically be inactive in the store. global $active, $inactive, $zero_qty_inactive, $deleteit; $active = 'Active'; $inactive = 'Inactive'; //$deleteit = 'Delete'; // not functional yet $zero_qty_inactive = true; //**** Size of products_model in products table **** // set this to the size of your model number field in the db. We check to make sure all models are no longer than this value. // this prevents the database from getting fubared. Just making this number bigger won't help your database! They must match! global $modelsize; $modelsize = 12; //**** Price includes tax? **** // Set the v_price_with_tax to // 0 if you want the price without the tax included // 1 if you want the price to be defined for import & export including tax. global $price_with_tax; $price_with_tax =true; // **** Quote -> Escape character conversion **** // If you have extensive html in your descriptions and it's getting mangled on upload, turn this off // set to 1 = replace quotes with escape characters // set to 0 = no quote replacement global $replace_quotes; $replace_quotes = true; // **** Field Separator **** // change this if you can't use the default of tabs // Tab is the default, comma and semicolon are commonly supported by various progs // Remember, if your descriptions contain this character, you will confuse EP! global $separator; $separator = "\t"; // tab is default //$separator = ","; // comma //$separator = ";"; // semi-colon //$separator = "~"; // tilde //$separator = "-"; // dash //$separator = "*"; // splat // **** Max Category Levels **** // change this if you need more or fewer categories global $max_categories; $max_categories = 3; // 7 is default // VJ product attributes begin // **** Product Attributes **** // change this to false, if do not want to download product attributes global $products_with_attributes; $products_with_attributes = true; // change this to true, if you use QTYpro and want to set attributes stock with EP. global $products_attributes_stock; $products_attributes_stock = false; // change this if you want to download selected product options // this might be handy, if you have a lot of product options, and your output file exceeds 256 columns (which is the max. limit MS Excel is able to handle) global $attribute_options_select; //$attribute_options_select = array('Size', 'Model'); // uncomment and fill with product options name you wish to download // comment this line, if you wish to download all product options // VJ product attributes end // **************************************** // Froogle configuration variables // -- YOU MUST CONFIGURE THIS! IT WON'T WORK OUT OF THE BOX! // **************************************** // **** Froogle product info page path **** // We can't use the tep functions to create the link, because the links will point to the admin, since that's where we're at. // So put the entire path to your product_info.php page here global $froogle_product_info_path; $froogle_product_info_path = "http://www.yourdomain.com/catalog/product_info.php"; // **** Froogle product image path **** // Set this to the path to your images directory global $froogle_image_path; $froogle_image_path = "http://www.yourdomain.com/catalog/images/"; // **** Froogle - search engine friendly setting // if your store has SEARCH ENGINE FRIENDLY URLS set, then turn this to true // I did it this way because I'm having trouble with the code seeing the constants // that are defined in other places. global $froogle_SEF_urls; $froogle_SEF_urls = false; // **************************************** // End Froogle configuration variables // **************************************** //******************************* //******************************* // E N D // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* //******************************* //******************************* // S T A R T // INITIALIZATION //******************************* //******************************* require('includes/application_top.php'); require('includes/database_tables.php'); //******************************* // If you are running a pre-Nov1-2002 snapshot of OSC, then we need this include line to avoid // errors like: // undefined function tep_get_uploaded_file if (!function_exists(tep_get_uploaded_file)){ include ('easypopulate_functions.php'); } //******************************* // VJ product attributes begin global $attribute_options_array; $attribute_options_array = array(); if ($products_with_attributes == true) { if (is_array($attribute_options_select) && (count($attribute_options_select) > 0)) { foreach ($attribute_options_select as $value) { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = '" . $value . "'"; $attribute_options_values = tep_db_query($attribute_options_query); if ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } else { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; $attribute_options_values = tep_db_query($attribute_options_query); while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } // VJ product attributes end global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders; // these are the fields that will be defaulted to the current values in the database if they are not found in the incoming file global $default_these; $default_these = array( 'v_products_image', #'v_products_mimage', #'v_products_bimage', #'v_products_subimage1', #'v_products_bsubimage1', #'v_products_subimage2', #'v_products_bsubimage2', #'v_products_subimage3', #'v_products_bsubimage3', 'v_categories_id', 'v_products_price', 'v_products_quantity', 'v_products_weight', 'v_date_avail', 'v_instock', 'v_tax_class_title', 'v_manufacturers_name', 'v_manufacturers_id', 'v_products_dim_type', 'v_products_length', 'v_products_width', 'v_products_height' ); //elari check default language_id from configuration table DEFAULT_LANGUAGE $epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'"); if (tep_db_num_rows($epdlanguage_query)) { $epdlanguage = tep_db_fetch_array($epdlanguage_query); $epdlanguage_id = $epdlanguage['languages_id']; $epdlanguage_name = $epdlanguage['name']; } else { Echo 'Strange but there is no default language to work... That may not happen, just in case... '; } $langcode = ep_get_languages(); if ( $dltype != '' ){ // if dltype is set, then create the filelayout. Otherwise it gets read from the uploaded file ep_create_filelayout($dltype); // get the right filelayout for this download } //******************************* //******************************* // E N D // INITIALIZATION //******************************* //******************************* if ( $download == 'stream' or $download == 'tempfile' ){ //******************************* //******************************* // DOWNLOAD FILE //******************************* //******************************* $filestring = ""; // this holds the csv file we want to download $result = tep_db_query($filelayout_sql); $row = tep_db_fetch_array($result); // Here we need to allow for the mapping of internal field names to external field names // default to all headers named like the internal ones // the field mapping array only needs to cover those fields that need to have their name changed if ( count($fileheaders) != 0 ){ $filelayout_header = $fileheaders; // if they gave us fileheaders for the dl, then use them } else { $filelayout_header = $filelayout; // if no mapping was spec'd use the internal field names for header names } //We prepare the table heading with layout values foreach( $filelayout_header as $key => $value ){ $filestring .= $key . $separator; } // now lop off the trailing tab $filestring = substr($filestring, 0, strlen($filestring)-1); // set the type if ( $dltype == 'froogle' ){ $endofrow = "\n"; } else { // default to normal end of row $endofrow = $separator . 'EOREOR' . "\n"; } $filestring .= $endofrow; $num_of_langs = count($langcode); while ($row){ // if the filelayout says we need a products_name, get it // build the long full froogle image path $row['v_products_fullpath_image'] = $froogle_image_path . $row['v_products_image']; // Other froogle defaults go here for now $row['v_froogle_instock'] = 'Y'; $row['v_froogle_shipping'] = ''; $row['v_froogle_upc'] = ''; $row['v_froogle_color'] = ''; $row['v_froogle_size'] = ''; $row['v_froogle_quantitylevel'] = ''; $row['v_froogle_manufacturer_id'] = ''; $row['v_froogle_exp_date'] = ''; $row['v_froogle_product_type'] = 'OTHER'; $row['v_froogle_delete'] = ''; $row['v_froogle_currency'] = 'USD'; $row['v_froogle_offer_id'] = $row['v_products_model']; $row['v_froogle_product_id'] = $row['v_products_model']; // names and descriptions require that we loop thru all languages that are turned on in the store foreach ($langcode as $key => $lang){ $lid = $lang['id']; // for each language, get the description and set the vals $sql2 = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id = " . $row['v_products_id'] . " AND language_id = '" . $lid . "' "; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); // I'm only doing this for the first language, since right now froogle is US only.. Fix later! // adding url for froogle, but it should be available no matter what if ($froogle_SEF_urls){ // if only one language if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id'] . '/language/' . $lid; } } else { if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id'] . '&language=' . $lid; } } $row['v_products_name_' . $lid] = $row2['products_name']; $row['v_products_description_' . $lid] = $row2['products_description']; $row['v_products_url_' . $lid] = $row2['products_url']; // froogle advanced format needs the quotes around the name and desc $row['v_froogle_products_name_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_name'])) . '"'; $row['v_froogle_products_description_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_description'])) . '"'; // support for Linda's Header Controller 2.0 here if(isset($filelayout['v_products_head_title_tag_' . $lid])){ $row['v_products_head_title_tag_' . $lid] = $row2['products_head_title_tag']; $row['v_products_head_desc_tag_' . $lid] = $row2['products_head_desc_tag']; $row['v_products_head_keywords_tag_' . $lid] = $row2['products_head_keywords_tag']; } // end support for Header Controller 2.0 } // for the categories, we need to keep looping until we find the root category // start with v_categories_id // Get the category description // set the appropriate variable name // if parent_id is not null, then follow it up. // we'll populate an aray first, then decide where it goes in the $thecategory_id = $row['v_categories_id']; $fullcategory = ''; // this will have the entire category stack for froogle for( $categorylevel=1; $categorylevel<$max_categories+1; $categorylevel++){ if ($thecategory_id){ $sql2 = "SELECT categories_name FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id = " . $thecategory_id . " AND language_id = " . $epdlanguage_id; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); // only set it if we found something $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name']; // now get the parent ID if there was one $sql3 = "SELECT parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id = " . $thecategory_id; $result3 = tep_db_query($sql3); $row3 = tep_db_fetch_array($result3); $theparent_id = $row3['parent_id']; if ($theparent_id != ''){ // there was a parent ID, lets set thecategoryid to get the next level $thecategory_id = $theparent_id; } else { // we have found the top level category for this item, $thecategory_id = false; } //$fullcategory .= " > " . $row2['categories_name']; $fullcategory = $row2['categories_name'] . " > " . $fullcategory; } else { $temprow['v_categories_name_' . $categorylevel] = ''; } } // now trim off the last ">" from the category stack $row['v_category_fullpath'] = substr($fullcategory,0,strlen($fullcategory)-3); // temprow has the old style low to high level categories. $newlevel = 1; // let's turn them into high to low level categories for( $categorylevel=6; $categorylevel>0; $categorylevel--){ if ($temprow['v_categories_name_' . $categorylevel] != ''){ $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel]; } } // if the filelayout says we need a manufacturers name, get it if (isset($filelayout['v_manufacturers_name'])){ if ($row['v_manufacturers_id'] != ''){ $sql2 = "SELECT manufacturers_name FROM ".TABLE_MANUFACTURERS." WHERE manufacturers_id = " . $row['v_manufacturers_id'] ; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); $row['v_manufacturers_name'] = $row2['manufacturers_name']; } } // If you have other modules that need to be available, put them here // VJ product attribs begin if (isset($filelayout['v_attribute_options_id_1'])){ $languages = tep_get_languages(); $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options) { $row['v_attribute_options_id_' . $attribute_options_count] = $attribute_options['products_options_id']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_options_languages_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_options_languages_values = tep_db_query($attribute_options_languages_query); $attribute_options_languages = tep_db_fetch_array($attribute_options_languages_values); $row['v_attribute_options_name_' . $attribute_options_count . '_' . $lid] = $attribute_options_languages['products_options_name']; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $row['v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values['products_options_values_id']; $attribute_values_price_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$row['v_products_id'] . "' and options_id = '" . (int)$attribute_options['products_options_id'] . "' and options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "'"; $attribute_values_price_values = tep_db_query($attribute_values_price_query); $attribute_values_price = tep_db_fetch_array($attribute_values_price_values); $row['v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values_price['price_prefix'] . $attribute_values_price['options_values_price']; //// attributes stock add start if ( $products_attributes_stock == true ) { $stock_attributes = $attribute_options['products_options_id'].'-'.$attribute_values['products_options_values_id']; $stock_quantity_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$row['v_products_id'] . "' and products_stock_attributes = '" . $stock_attributes . "'"); $stock_quantity = tep_db_fetch_array($stock_quantity_query); $row['v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count] = $stock_quantity['products_stock_quantity']; } //// attributes stock add end for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_values_languages_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_values_languages_values = tep_db_query($attribute_values_languages_query); $attribute_values_languages = tep_db_fetch_array($attribute_values_languages_values); $row['v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid] = $attribute_values_languages['products_options_values_name']; } $attribute_values_count++; } $attribute_options_count++; } } // VJ product attribs end // this is for the separate price per customer module if (isset($filelayout['v_customer_price_1'])){ $sql2 = "SELECT customers_group_price, customers_group_id FROM ".TABLE_PRODUCTS_GROUPS." WHERE products_id = " . $row['v_products_id'] . " ORDER BY customers_group_id" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); while( $row2 ){ $row['v_customer_group_id_' . $ll] = $row2['customers_group_id']; $row['v_customer_price_' . $ll] = $row2['customers_group_price']; $row2 = tep_db_fetch_array($result2); $ll++; } } if ($dltype == 'froogle'){ // For froogle, we check the specials prices for any applicable specials, and use that price // by grabbing the specials id descending, we always get the most recently added special price // I'm checking status because I think you can turn off specials $sql2 = "SELECT specials_new_products_price FROM ".TABLE_SPECIALS." WHERE products_id = " . $row['v_products_id'] . " and status = 1 and expires_date < CURRENT_TIMESTAMP ORDER BY specials_id DESC" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); if( $row2 ){ // reset the products price to our special price if there is one for this product $row['v_products_price'] = $row2['specials_new_products_price']; } } //elari - //We check the value of tax class and title instead of the id //Then we add the tax to price if $price_with_tax is set to 1 $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']); $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']); $row['v_products_price'] = round($row['v_products_price'] + ($price_with_tax * $row['v_products_price'] * $row_tax_multiplier / 100),2); // Now set the status to a word the user specd in the config vars if ( $row['v_status'] == '1' ){ $row['v_status'] = $active; } else { $row['v_status'] = $inactive; } // remove any bad things in the texts that could confuse EasyPopulate $therow = ''; foreach( $filelayout as $key => $value ){ //echo "The field was $key<br>"; $thetext = $row[$key]; // kill the carriage returns and tabs in the descriptions, they're killing me! $thetext = str_replace("\r",' ',$thetext); $thetext = str_replace("\n",' ',$thetext); $thetext = str_replace("\t",' ',$thetext); // and put the text into the output separated by tabs $therow .= $thetext . $separator; } // lop off the trailing tab, then append the end of row indicator $therow = substr($therow,0,strlen($therow)-1) . $endofrow; $filestring .= $therow; // grab the next row from the db $row = tep_db_fetch_array($result); } #$EXPORT_TIME=time(); $EXPORT_TIME = strftime('%Y%b%d-%H%I'); if ($dltype=="froogle"){ $EXPORT_TIME = "FroogleEP" . $EXPORT_TIME; } else { $EXPORT_TIME = "EP" . $EXPORT_TIME; } // now either stream it to them or put it in the temp directory if ($download == 'stream'){ //******************************* // STREAM FILE //******************************* header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=$EXPORT_TIME.txt"); // Changed if using SSL, helps prevent program delay/timeout (add to backup.php also) // header("Pragma: no-cache"); if ($request_type== 'NONSSL'){ header("Pragma: no-cache"); } else { header("Pragma: "); } header("Expires: 0"); echo $filestring; die(); } else { //******************************* // PUT FILE IN TEMP DIR //******************************* $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "$EXPORT_TIME.txt"; //unlink($tmpfname); $fp = fopen( $tmpfname, "w+"); fwrite($fp, $filestring); fclose($fp); echo "You can get your file in the Tools/Files under " . $tempdir . "EP" . $EXPORT_TIME . ".txt"; die(); } } // *** END *** download section ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top" height="27"> <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <?php require(DIR_WS_INCLUDES . 'column_left.php');?> </table></td> <td class="pageHeading" valign="top"><?php echo "Easy Populate $curver - Default Language : " . $epdlanguage_name . '(' . $epdlanguage_id .')'; ?> <p class="smallText"> <?php if ($localfile or (is_uploaded_file($usrfl) && $split==0)) { //******************************* //******************************* // UPLOAD AND INSERT FILE //******************************* //******************************* if ($usrfl){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } echo "<p class=smallText>"; echo "File uploaded. <br>"; echo "Temporary filename: " . $usrfl . "<br>"; echo "User filename: " . $usrfl_name . "<br>"; echo "Size: " . $usrfl_size . "<br>"; // get the entire file into an array $readed = file(DIR_FS_DOCUMENT_ROOT . $tempdir . $usrfl_name); } if ($localfile){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; $attribute_options_values = tep_db_query($attribute_options_query); $attribute_options_count = 1; //while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } echo "<p class=smallText>"; echo "Filename: " . $localfile . "<br>"; // get the entire file into an array $readed = file(DIR_FS_DOCUMENT_ROOT . $tempdir . $localfile); } // now we string the entire thing together in case there were carriage returns in the data $newreaded = ""; foreach ($readed as $read){ $newreaded .= $read; } // now newreaded has the entire file together without the carriage returns. // if for some reason excel put qoutes around our EOREOR, remove them then split into rows $newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded); $readed = explode( $separator . 'EOREOR',$newreaded); // Now we'll populate the filelayout based on the header row. $theheaders_array = explode( $separator, $readed[0] ); // explode the first row, it will be our filelayout $lll = 0; $filelayout = array(); foreach( $theheaders_array as $header ){ $cleanheader = str_replace( '"', '', $header); // echo "Fileheader was $header<br><br><br>"; $filelayout[ $cleanheader ] = $lll++; // } unset($readed[0]); // we don't want to process the headers with the data // now we've got the array broken into parts by the expicit end-of-row marker. array_walk($readed, 'walk'); } if (is_uploaded_file($usrfl) && $split==1) { //******************************* //******************************* // UPLOAD AND SPLIT FILE //******************************* //******************************* // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); //echo "Trying to move file..."; if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } $infp = fopen(DIR_FS_DOCUMENT_ROOT . $tempdir . $usrfl_name, "r"); //toprow has the field headers $toprow = fgets($infp,32768); $filecount = 1; echo "Creating file EP_Split" . $filecount . ".txt ... "; $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "EP_Split" . $filecount . ".txt"; $fp = fopen( $tmpfname, "w+"); fwrite($fp, $toprow); $linecount = 0; $line = fgets($infp,32768); while ($line){ // walking the entire file one row at a time // but a line is not necessarily a complete row, we need to split on rows that have "EOREOR" at the end $line = str_replace('"EOREOR"', 'EOREOR', $line); fwrite($fp, $line); if (strpos($line, 'EOREOR')){ // we found the end of a line of data, store it $linecount++; // increment our line counter if ($linecount >= $maxrecs){ echo "Added $linecount records and closing file... <Br>"; $linecount = 0; // reset our line counter // close the existing file and open another; fclose($fp); // increment filecount $filecount++; echo "Creating file EP_Split" . $filecount . ".txt ... "; $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "EP_Split" . $filecount . ".txt"; //Open next file name $fp = fopen( $tmpfname, "w+"); fwrite($fp, $toprow); } } $line=fgets($infp,32768); } echo "Added $linecount records and closing file...<br><br> "; fclose($fp); fclose($infp); echo "You can download your split files in the Tools/Files under /catalog/temp/"; } ?> </p> <table width="75%" border="2"> <tr> <td width="75%"> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php?split=0" METHOD=POST> <p> <div align = "left"> <p><b>Upload EP File</b></p> <p> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000000"> <p></p> <input name="usrfl" type="file" size="50"> <input type="submit" name="buttoninsert" value="Insert into db"> <br> </p> </div> </form> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php?split=1" METHOD=POST> <p> <div align = "left"> <p><b>Split EP File</b></p> <p> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000000"> <p></p> <input name="usrfl" type="file" size="50"> <input type="submit" name="buttonsplit" value="Split file"> <br> </p> </div> </form> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php" METHOD=POST> <p> <div align = "left"> <p><b>Import from Temp Dir (<? echo $tempdir; ?>)</b></p> <p class="smallText"> <INPUT TYPE="text" name="localfile" size="50"> <input type="submit" name="buttoninsert" value="Insert into db"> <br> </p> </div> </form> <p><b>Download EP and Froogle Files</b></p> <!-- Download file links - Add your custom fields here --> <a href="easypopulate.php?download=stream&dltype=full">Download <b>Complete</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=priceqty">Download <b>Model/Price/Qty</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=category">Download <b>Model/Category</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=froogle">Download <b>Froogle</b> tab-delimited .txt file</a><br> <!-- VJ product attributes begin //--> <?php if ($products_with_attributes == true) { ?> <a href="easypopulate.php?download=stream&dltype=attrib">Download <b>Model/Attributes</b> tab-delimited .txt file</a><br> <?php } ?> <!-- VJ product attributes end //--> <p><b>Create EP and Froogle Files in Temp Dir (<? echo $tempdir; ?>)</b></p> <a href="easypopulate.php?download=tempfile&dltype=full">Create Complete tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=priceqty"">Create Model/Price/Qty tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=category">Create Model/Category tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=froogle">Create Froogle tab-delimited .txt file in temp dir</a><br> <!-- VJ product attributes begin //--> <a href="easypopulate.php?download=tempfile&dltype=attrib">Create Model/Attributes tab-delimited .txt file in temp dir</a><br> <!-- VJ product attributes end //--> </td> </tr> </table> </td> </tr> </table> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <p>?</p> <p>?</p><p><br> </p></body> </html> <?php function ep_get_languages() { $languages_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " order by sort_order"); // start array at one, the rest of the code expects it that way $ll =1; while ($ep_languages = tep_db_fetch_array($languages_query)) { //will be used to return language_id en language code to report in product_name_code instead of product_name_id $ep_languages_array[$ll++] = array( 'id' => $ep_languages['languages_id'], 'code' => $ep_languages['code'] ); } return $ep_languages_array; }; function tep_get_tax_class_rate($tax_class_id) { $tax_multiplier = 0; $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " WHERE tax_class_id = '" . $tax_class_id . "' GROUP BY tax_priority"); if (tep_db_num_rows($tax_query)) { while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } } return $tax_multiplier; }; function tep_get_tax_title_class_id($tax_class_title) { $classes_query = tep_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'" ); $tax_class_array = tep_db_fetch_array($classes_query); $tax_class_id = $tax_class_array['tax_class_id']; return $tax_class_id; } function print_el( $item2 ) { echo " | " . substr(strip_tags($item2), 0, 10); }; function print_el1( $item2 ) { echo sprintf("| %'.4s ", substr(strip_tags($item2), 0, 80)); }; function ep_create_filelayout($dltype){ global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders, $max_categories; // depending on the type of the download the user wanted, create a file layout for it. $fieldmap = array(); // default to no mapping to change internal field names to external. switch( $dltype ){ case 'full': // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_products_model' => $iii++, 'v_products_image' => $iii++, ); foreach ($langcode as $key => $lang){ $l_id = $lang['id']; // uncomment the head_title, head_desc, and head_keywords to use // Linda's Header Tag Controller 2.0 //echo $langcode['id'] . $langcode['code']; $filelayout = array_merge($filelayout , array( 'v_products_name_' . $l_id => $iii++, 'v_products_description_' . $l_id => $iii++, 'v_products_url_' . $l_id => $iii++, // 'v_products_head_title_tag_'.$l_id => $iii++, // 'v_products_head_desc_tag_'.$l_id => $iii++, // 'v_products_head_keywords_tag_'.$l_id => $iii++, )); } // uncomment the customer_price and customer_group to support multi-price per product contrib // VJ product attribs begin $header_array = array( 'v_products_price' => $iii++, 'v_products_weight' => $iii++, 'v_date_avail' => $iii++, 'v_date_added' => $iii++, 'v_products_quantity' => $iii++, ); $languages = tep_get_languages(); global $attribute_options_array; $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options_values) { $key1 = 'v_attribute_options_id_' . $attribute_options_count; $header_array[$key1] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id; $header_array[$key2] = $iii++; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key3] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key4 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id; $header_array[$key4] = $iii++; } $key5 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key5] = $iii++; //// attributes stock add start if ( $products_attributes_stock == true ) { $key6 = 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key6] = $iii++; } //// attributes stock add end $attribute_values_count++; } $attribute_options_count++; } $header_array['v_manufacturers_name'] = $iii++; $filelayout = array_merge($filelayout, $header_array); // VJ product attribs end // build the categories name section of the array based on the number of categores the user wants to have for($i=1;$i<$max_categories+1;$i++){ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++)); } $filelayout = array_merge($filelayout, array( 'v_tax_class_title' => $iii++, 'v_status' => $iii++, )); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, p.products_image as v_products_image, p.products_price as v_products_price, p.products_weight as v_products_weight, p.products_date_available as v_date_avail, p.products_date_added as v_date_added, p.products_tax_class_id as v_tax_class_id, p.products_quantity as v_products_quantity, p.manufacturers_id as v_manufacturers_id, subc.categories_id as v_categories_id, p.products_status as v_status FROM ".TABLE_PRODUCTS." as p, ".TABLE_CATEGORIES." as subc, ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc WHERE p.products_id = ptoc.products_id AND ptoc.categories_id = subc.categories_id "; break; case 'priceqty': $iii = 0; // uncomment the customer_price and customer_group to support multi-price per product contrib $filelayout = array( 'v_products_model' => $iii++, 'v_products_price' => $iii++, 'v_products_quantity' => $iii++, #'v_customer_price_1' => $iii++, #'v_customer_group_id_1' => $iii++, #'v_customer_price_2' => $iii++, #'v_customer_group_id_2' => $iii++, #'v_customer_price_3' => $iii++, #'v_customer_group_id_3' => $iii++, #'v_customer_price_4' => $iii++, #'v_customer_group_id_4' => $iii++, ); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, p.products_price as v_products_price, p.products_tax_class_id as v_tax_class_id, p.products_quantity as v_products_quantity FROM ".TABLE_PRODUCTS." as p "; break; case 'category': // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_products_model' => $iii++, ); // build the categories name section of the array based on the number of categores the user wants to have for($i=1;$i<$max_categories+1;$i++){ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++)); } $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, subc.categories_id as v_categories_id FROM ".TABLE_PRODUCTS." as p, ".TABLE_CATEGORIES." as subc, ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc WHERE p.products_id = ptoc.products_id AND ptoc.categories_id = subc.categories_id "; break; case 'froogle': // this is going to be a little interesting because we need // a way to map from internal names to external names // // Before it didn't matter, but with froogle needing particular headers, // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_froogle_products_url_1' => $iii++, ); // // here we need to get the default language and put $l_id = 1; // dummy it in for now. // foreach ($langcode as $key => $lang){ // $l_id = $lang['id']; $filelayout = array_merge($filelayout , array( 'v_froogle_products_name_' . $l_id => $iii++, 'v_froogle_products_description_' . $l_id => $iii++, )); // } $filelayout = array_merge($filelayout , array( 'v_products_price' &
  14. christoph_999

    Easy Populate & Products Attributes

    Hi John First of all im sorry for bad english, im austrian. My question is about ep with price break. on a fresh 2.2 install i got the pricebreak contrib http://www.oscommerce.com/community/contri...rch,price+break to work fine. I tried the version from 6th may and 10th november everytime after a fresh install with EP 2.76 (v2.76) and used easypopulate_pricebreak.php When i download the complete txt file i dont get the multiple prices. i have also tried EP 2.74, same thing in my mysql, there are those fields present, but these fields are not in the downloaded txt-file i havent also found anything in the manual, just for separate pricing per customer to uncomment some lines. so i also looked to uncomment something, but there was nothing to uncomment what have i done wrong? im trying already 2 days. now i would appreciate your help. this is my easypopulate_pricebreak.php (i will also attach the easypopulate.php at the next message as i saw, that the easypopulate_pricebreak.php also needs the easypopulate.php to run) THIS IS MY EASYPOPULATE_PRICEBREAK.PHP <?php // Current EP Version $curver = '2.75-MS2'; // With Price Break, removed local paths from 7 Aug version, these are now correct. /* $Id: easypopulate.php,v 2.75 2005/04/05 AL Exp $ */ // //******************************* //******************************* // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* // **** Temp directory **** // if you changed your directory structure from stock and do not have /catalog/temp/, then you'll need to change this accordingly. // $tempdir = "/shop/temp/"; $tempdir2 = "/shop/temp/"; //**** File Splitting Configuration **** // we attempt to set the timeout limit longer for this script to avoid having to split the files // NOTE: If your server is running in safe mode, this setting cannot override the timeout set in php.ini // uncomment this if you are not on a safe mode server and you are getting timeouts // set_time_limit(330); // if you are splitting files, this will set the maximum number of records to put in each file. // if you set your php.ini to a long time, you can make this number bigger global $maxrecs; $maxrecs = 300; // default, seems to work for most people. Reduce if you hit timeouts //$maxrecs = 4; // for testing //**** Image Defaulting **** global $default_images, $default_image_manufacturer, $default_image_product, $default_image_category; // set them to your own default "We don't have any picture" gif //$default_image_manufacturer = 'no_image_manufacturer.gif'; //$default_image_product = 'no_image_product.gif'; //$default_image_category = 'no_image_category.gif'; // or let them get set to nothing $default_image_manufacturer = ''; $default_image_product = ''; $default_image_category = ''; //**** Status Field Setting **** // Set the v_status field to "Inactive" if you want the status=0 in the system // Set the v_status field to "Delete" if you want to remove the item from the system <- THIS IS NOT WORKING YET! // If zero_qty_inactive is true, then items with zero qty will automatically be inactive in the store. global $active, $inactive, $zero_qty_inactive, $deleteit; $active = 'Active'; $inactive = 'Inactive'; //$deleteit = 'Delete'; // not functional yet $zero_qty_inactive = false; //**** Size of products_model in products table **** // set this to the size of your model number field in the db. We check to make sure all models are no longer than this value. // this prevents the database from getting fubared. Just making this number bigger won't help your database! They must match! global $modelsize; $modelsize = 12; //**** Price includes tax? **** // Set the v_price_with_tax to // 0 if you want the price without the tax included // 1 if you want the price to be defined for import & export including tax. global $price_with_tax; $price_with_tax =true; // **** Quote -> Escape character conversion **** // If you have extensive html in your descriptions and it's getting mangled on upload, turn this off // set to 1 = replace quotes with escape characters // set to 0 = no quote replacement global $replace_quotes; $replace_quotes = true; // **** Field Separator **** // change this if you can't use the default of tabs // Tab is the default, comma and semicolon are commonly supported by various progs // Remember, if your descriptions contain this character, you will confuse EP! global $separator; $separator = "\t"; // tab is default //$separator = ","; // comma //$separator = ";"; // semi-colon //$separator = "~"; // tilde //$separator = "-"; // dash //$separator = "*"; // splat // **** Max Category Levels **** // change this if you need more or fewer categories global $max_categories; $max_categories = 3; // 7 is default // VJ product attributes begin // **** Product Attributes **** // change this to false, if do not want to download product attributes global $products_with_attributes; $products_with_attributes = true; // change this if you want to download selected product options // this might be handy, if you have a lot of product options, and your output file exceeds 256 columns (which is the max. limit MS Excel is able to handle) global $attribute_options_select; //$attribute_options_select = array('Size', 'Model'); // uncomment and fill with product options name you wish to download // comment this line, if you wish to download all product options // VJ product attributes end // **************************************** // Froogle configuration variables // -- YOU MUST CONFIGURE THIS! IT WON'T WORK OUT OF THE BOX! // **************************************** // **** Froogle product info page path **** // We can't use the tep functions to create the link, because the links will point to the admin, since that's where we're at. // So put the entire path to your product_info.php page here global $froogle_product_info_path; $froogle_product_info_path = "http://www.stylishbydesign.com/catalog/product_info.php"; // **** Froogle product image path **** // Set this to the path to your images directory global $froogle_image_path; $froogle_image_path = "http://www.stylishbydesign.com/catalog/images/"; // **** Froogle - search engine friendly setting // if your store has SEARCH ENGINE FRIENDLY URLS set, then turn this to true // I did it this way because I'm having trouble with the code seeing the constants // that are defined in other places. global $froogle_SEF_urls; $froogle_SEF_urls = false; // **************************************** // End Froogle configuration variables // **************************************** //******************************* //******************************* // E N D // C O N F I G U R A T I O N // V A R I A B L E S //******************************* //******************************* //******************************* //******************************* // S T A R T // INITIALIZATION //******************************* //******************************* require('includes/application_top.php'); require('includes/database_tables.php'); //******************************* // If you are running a pre-Nov1-2002 snapshot of OSC, then we need this include line to avoid // errors like: // undefined function tep_get_uploaded_file if (!function_exists(tep_get_uploaded_file)){ include ('easypopulate_functions.php'); } //******************************* // VJ product attributes begin global $attribute_options_array; $attribute_options_array = array(); if ($products_with_attributes == true) { if (is_array($attribute_options_select) && (count($attribute_options_select) > 0)) { foreach ($attribute_options_select as $value) { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " where products_options_name = '" . $value . "'"; $attribute_options_values = tep_db_query($attribute_options_query); if ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } else { $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; $attribute_options_values = tep_db_query($attribute_options_query); while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ $attribute_options_array[] = array('products_options_id' => $attribute_options['products_options_id']); } } } // VJ product attributes end global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders; // these are the fields that will be defaulted to the current values in the database if they are not found in the incoming file global $default_these; $default_these = array( 'v_products_image', // 'v_products_mimage', 'v_products_bimage', // 'v_products_subimage1', // 'v_products_bsubimage1', // 'v_products_subimage2', // 'v_products_bsubimage2', // 'v_products_subimage3', // 'v_products_bsubimage3', 'v_categories_id', 'v_products_price', 'v_products_price1', 'v_products_price2', 'v_products_price3', 'v_products_price4', 'v_products_price1_qty', 'v_products_price2_qty', 'v_products_price3_qty', 'v_products_price4_qty', 'v_products_qty_blocks', 'v_products_quantity', 'v_products_weight', 'v_date_avail', 'v_instock', 'v_tax_class_title', 'v_manufacturers_name', 'v_manufacturers_id', 'v_products_dim_type', 'v_products_length', 'v_products_width', 'v_products_height' ); //elari check default language_id from configuration table DEFAULT_LANGUAGE $epdlanguage_query = tep_db_query("select languages_id, name from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_LANGUAGE . "'"); if (tep_db_num_rows($epdlanguage_query)) { $epdlanguage = tep_db_fetch_array($epdlanguage_query); $epdlanguage_id = $epdlanguage['languages_id']; $epdlanguage_name = $epdlanguage['name']; } else { Echo 'Strange but there is no default language to work... That may not happen, just in case... '; } $langcode = ep_get_languages(); if ( $dltype != '' ){ // if dltype is set, then create the filelayout. Otherwise it gets read from the uploaded file ep_create_filelayout($dltype); // get the right filelayout for this download } //******************************* //******************************* // E N D // INITIALIZATION //******************************* //******************************* if ( $download == 'stream' or $download == 'tempfile' ){ //******************************* //******************************* // DOWNLOAD FILE //******************************* //******************************* $filestring = ""; // this holds the csv file we want to download $result = tep_db_query($filelayout_sql); $row = tep_db_fetch_array($result); // Here we need to allow for the mapping of internal field names to external field names // default to all headers named like the internal ones // the field mapping array only needs to cover those fields that need to have their name changed if ( count($fileheaders) != 0 ){ $filelayout_header = $fileheaders; // if they gave us fileheaders for the dl, then use them } else { $filelayout_header = $filelayout; // if no mapping was spec'd use the internal field names for header names } //We prepare the table heading with layout values foreach( $filelayout_header as $key => $value ){ $filestring .= $key . $separator; } // now lop off the trailing tab $filestring = substr($filestring, 0, strlen($filestring)-1); // set the type if ( $dltype == 'froogle' ){ $endofrow = "\n"; } else { // default to normal end of row $endofrow = $separator . 'EOREOR' . "\n"; } $filestring .= $endofrow; $num_of_langs = count($langcode); while ($row){ // if the filelayout says we need a products_name, get it // build the long full froogle image path $row['v_products_fullpath_image'] = $froogle_image_path . $row['v_products_image']; // Other froogle defaults go here for now $row['v_froogle_instock'] = 'Y'; $row['v_froogle_shipping'] = ''; $row['v_froogle_upc'] = ''; $row['v_froogle_color'] = ''; $row['v_froogle_size'] = ''; $row['v_froogle_quantitylevel'] = ''; $row['v_froogle_manufacturer_id'] = ''; $row['v_froogle_exp_date'] = ''; $row['v_froogle_product_type'] = 'OTHER'; $row['v_froogle_delete'] = ''; $row['v_froogle_currency'] = 'USD'; $row['v_froogle_offer_id'] = $row['v_products_model']; $row['v_froogle_product_id'] = $row['v_products_model']; // names and descriptions require that we loop thru all languages that are turned on in the store foreach ($langcode as $key => $lang){ $lid = $lang['id']; // for each language, get the description and set the vals $sql2 = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE products_id = " . $row['v_products_id'] . " AND language_id = '" . $lid . "' "; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); // I'm only doing this for the first language, since right now froogle is US only.. Fix later! // adding url for froogle, but it should be available no matter what if ($froogle_SEF_urls){ // if only one language if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '/products_id/' . $row['v_products_id'] . '/language/' . $lid; } } else { if ($num_of_langs == 1){ $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id']; } else { $row['v_froogle_products_url_' . $lid] = $froogle_product_info_path . '?products_id=' . $row['v_products_id'] . '&language=' . $lid; } } $row['v_products_name_' . $lid] = $row2['products_name']; $row['v_products_description_' . $lid] = $row2['products_description']; $row['v_products_url_' . $lid] = $row2['products_url']; // froogle advanced format needs the quotes around the name and desc $row['v_froogle_products_name_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_name'])) . '"'; $row['v_froogle_products_description_' . $lid] = '"' . strip_tags(str_replace('"','""',$row2['products_description'])) . '"'; // support for Linda's Header Controller 2.0 here if(isset($filelayout['v_products_head_title_tag_' . $lid])){ $row['v_products_head_title_tag_' . $lid] = $row2['products_head_title_tag']; $row['v_products_head_desc_tag_' . $lid] = $row2['products_head_desc_tag']; $row['v_products_head_keywords_tag_' . $lid] = $row2['products_head_keywords_tag']; } // end support for Header Controller 2.0 } // for the categories, we need to keep looping until we find the root category // start with v_categories_id // Get the category description // set the appropriate variable name // if parent_id is not null, then follow it up. // we'll populate an aray first, then decide where it goes in the $thecategory_id = $row['v_categories_id']; $fullcategory = ''; // this will have the entire category stack for froogle for( $categorylevel=1; $categorylevel<$max_categories+1; $categorylevel++){ if ($thecategory_id){ $sql2 = "SELECT categories_name FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id = " . $thecategory_id . " AND language_id = " . $epdlanguage_id ; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); // only set it if we found something $temprow['v_categories_name_' . $categorylevel] = $row2['categories_name']; // now get the parent ID if there was one $sql3 = "SELECT parent_id FROM ".TABLE_CATEGORIES." WHERE categories_id = " . $thecategory_id; $result3 = tep_db_query($sql3); $row3 = tep_db_fetch_array($result3); $theparent_id = $row3['parent_id']; if ($theparent_id != ''){ // there was a parent ID, lets set thecategoryid to get the next level $thecategory_id = $theparent_id; } else { // we have found the top level category for this item, $thecategory_id = false; } //$fullcategory .= " > " . $row2['categories_name']; $fullcategory = $row2['categories_name'] . " > " . $fullcategory; } else { $temprow['v_categories_name_' . $categorylevel] = ''; } } // now trim off the last ">" from the category stack $row['v_category_fullpath'] = substr($fullcategory,0,strlen($fullcategory)-3); // temprow has the old style low to high level categories. $newlevel = 1; // let's turn them into high to low level categories for( $categorylevel=6; $categorylevel>0; $categorylevel--){ if ($temprow['v_categories_name_' . $categorylevel] != ''){ $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel]; } } // if the filelayout says we need a manufacturers name, get it if (isset($filelayout['v_manufacturers_name'])){ if ($row['v_manufacturers_id'] != ''){ $sql2 = "SELECT manufacturers_name FROM ".TABLE_MANUFACTURERS." WHERE manufacturers_id = " . $row['v_manufacturers_id'] ; $result2 = tep_db_query($sql2); $row2 = tep_db_fetch_array($result2); $row['v_manufacturers_name'] = $row2['manufacturers_name']; } } // If you have other modules that need to be available, put them here // VJ product attribs begin if (isset($filelayout['v_attribute_options_id_1'])){ $languages = tep_get_languages(); $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options) { $row['v_attribute_options_id_' . $attribute_options_count] = $attribute_options['products_options_id']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_options_languages_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_options_languages_values = tep_db_query($attribute_options_languages_query); $attribute_options_languages = tep_db_fetch_array($attribute_options_languages_values); $row['v_attribute_options_name_' . $attribute_options_count . '_' . $lid] = $attribute_options_languages['products_options_name']; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $row['v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values['products_options_values_id']; $attribute_values_price_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$row['v_products_id'] . "' and options_id = '" . (int)$attribute_options['products_options_id'] . "' and options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "'"; $attribute_values_price_values = tep_db_query($attribute_values_price_query); $attribute_values_price = tep_db_fetch_array($attribute_values_price_values); $row['v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count] = $attribute_values_price['price_prefix'] . $attribute_values_price['options_values_price']; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $lid = $languages[$i]['id']; $attribute_values_languages_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$attribute_values['products_options_values_id'] . "' and language_id = '" . (int)$lid . "'"; $attribute_values_languages_values = tep_db_query($attribute_values_languages_query); $attribute_values_languages = tep_db_fetch_array($attribute_values_languages_values); $row['v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid] = $attribute_values_languages['products_options_values_name']; } $attribute_values_count++; } $attribute_options_count++; } } // VJ product attribs end // this is for the separate price per customer module if (isset($filelayout['v_customer_price_1'])){ $sql2 = "SELECT customers_group_price, customers_group_id FROM ".TABLE_PRODUCTS_GROUPS." WHERE products_id = " . $row['v_products_id'] . " ORDER BY customers_group_id" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); while( $row2 ){ $row['v_customer_group_id_' . $ll] = $row2['customers_group_id']; $row['v_customer_price_' . $ll] = $row2['customers_group_price']; $row2 = tep_db_fetch_array($result2); $ll++; } } if ($dltype == 'froogle'){ // For froogle, we check the specials prices for any applicable specials, and use that price // by grabbing the specials id descending, we always get the most recently added special price // I'm checking status because I think you can turn off specials $sql2 = "SELECT specials_new_products_price FROM ".TABLE_SPECIALS." WHERE products_id = " . $row['v_products_id'] . " and status = 1 and expires_date < CURRENT_TIMESTAMP ORDER BY specials_id DESC" ; $result2 = tep_db_query($sql2); $ll = 1; $row2 = tep_db_fetch_array($result2); if( $row2 ){ // reset the products price to our special price if there is one for this product $row['v_products_price'] = $row2['specials_new_products_price']; } } //elari - //We check the value of tax class and title instead of the id //Then we add the tax to price if $price_with_tax is set to 1 $row_tax_multiplier = tep_get_tax_class_rate($row['v_tax_class_id']); $row['v_tax_class_title'] = tep_get_tax_class_title($row['v_tax_class_id']); $row['v_products_price'] = round($row['v_products_price'] + ($price_with_tax * $row['v_products_price'] * $row_tax_multiplier / 100),2); $row['v_products_price1'] = round($row['v_products_price1'] + ($price_with_tax * $row['v_products_price1'] * $row_tax_multiplier / 100),2); $row['v_products_price2'] = round($row['v_products_price2'] + ($price_with_tax * $row['v_products_price2'] * $row_tax_multiplier / 100),2); $row['v_products_price3'] = round($row['v_products_price3'] + ($price_with_tax * $row['v_products_price3'] * $row_tax_multiplier / 100),2); $row['v_products_price4'] = round($row['v_products_price4'] + ($price_with_tax * $row['v_products_price4'] * $row_tax_multiplier / 100),2); // Now set the status to a word the user specd in the config vars if ( $row['v_status'] == '1' ){ $row['v_status'] = $active; } else { $row['v_status'] = $inactive; } // remove any bad things in the texts that could confuse EasyPopulate $therow = ''; foreach( $filelayout as $key => $value ){ //echo "The field was $key<br>"; $thetext = $row[$key]; // kill the carriage returns and tabs in the descriptions, they're killing me! $thetext = str_replace("\r",' ',$thetext); $thetext = str_replace("\n",' ',$thetext); $thetext = str_replace("\t",' ',$thetext); // and put the text into the output separated by tabs $therow .= $thetext . $separator; } // lop off the trailing tab, then append the end of row indicator $therow = substr($therow,0,strlen($therow)-1) . $endofrow; $filestring .= $therow; // grab the next row from the db $row = tep_db_fetch_array($result); } #$EXPORT_TIME=time(); $EXPORT_TIME = strftime('%Y%b%d-%H%I'); if ($dltype=="froogle"){ $EXPORT_TIME = "FroogleEP" . $EXPORT_TIME; } else { $EXPORT_TIME = "EP" . $EXPORT_TIME; } // now either stream it to them or put it in the temp directory if ($download == 'stream'){ //******************************* // STREAM FILE //******************************* header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=$EXPORT_TIME.txt"); header("Pragma: no-cache"); header("Expires: 0"); echo $filestring; die(); } else { //******************************* // PUT FILE IN TEMP DIR //******************************* $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "$EXPORT_TIME.txt"; //unlink($tmpfname); $fp = fopen( $tmpfname, "w+"); fwrite($fp, $filestring); fclose($fp); echo "You can get your file in the Tools/Files under " . $tempdir . "EP" . $EXPORT_TIME . ".txt"; die(); } } // *** END *** download section ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top" height="27"> <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <?php require(DIR_WS_INCLUDES . 'column_left.php');?> </table></td> <td class="pageHeading" valign="top"><?php echo "Easy Populate $curver - Default Language : " . $epdlanguage_name . '(' . $epdlanguage_id .')' ; ?> <p class="smallText"> <?php if ($localfile or (is_uploaded_file($usrfl) && $split==0)) { //******************************* //******************************* // UPLOAD AND INSERT FILE //******************************* //******************************* if ($usrfl){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } echo "<p class=smallText>"; echo "File uploaded. <br>"; echo "Temporary filename: " . $usrfl . "<br>"; echo "User filename: " . $usrfl_name . "<br>"; echo "Size: " . $usrfl_size . "<br>"; // get the entire file into an array $readed = file(DIR_FS_DOCUMENT_ROOT . $tempdir . $usrfl_name); } if ($localfile){ // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); $attribute_options_query = "select distinct products_options_id from " . TABLE_PRODUCTS_OPTIONS . " order by products_options_id"; $attribute_options_values = tep_db_query($attribute_options_query); $attribute_options_count = 1; //while ($attribute_options = tep_db_fetch_array($attribute_options_values)){ if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } echo "<p class=smallText>"; echo "Filename: " . $localfile . "<br>"; // get the entire file into an array $readed = file(DIR_FS_DOCUMENT_ROOT . $tempdir . $localfile); } // now we string the entire thing together in case there were carriage returns in the data $newreaded = ""; foreach ($readed as $read){ $newreaded .= $read; } // now newreaded has the entire file together without the carriage returns. // if for some reason excel put qoutes around our EOREOR, remove them then split into rows $newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded); $readed = explode( $separator . 'EOREOR',$newreaded); // Now we'll populate the filelayout based on the header row. $theheaders_array = explode( $separator, $readed[0] ); // explode the first row, it will be our filelayout $lll = 0; $filelayout = array(); foreach( $theheaders_array as $header ){ $cleanheader = str_replace( '"', '', $header); // echo "Fileheader was $header<br><br><br>"; $filelayout[ $cleanheader ] = $lll++; // } unset($readed[0]); // we don't want to process the headers with the data // now we've got the array broken into parts by the expicit end-of-row marker. array_walk($readed, 'walk'); } if (is_uploaded_file($usrfl) && $split==1) { //******************************* //******************************* // UPLOAD AND SPLIT FILE //******************************* //******************************* // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); //echo "Trying to move file..."; if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } $infp = fopen(DIR_FS_DOCUMENT_ROOT . $tempdir . $usrfl_name, "r"); //toprow has the field headers $toprow = fgets($infp,32768); $filecount = 1; echo "Creating file EP_Split" . $filecount . ".txt ... "; $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "EP_Split" . $filecount . ".txt"; $fp = fopen( $tmpfname, "w+"); fwrite($fp, $toprow); $linecount = 0; $line = fgets($infp,32768); while ($line){ // walking the entire file one row at a time // but a line is not necessarily a complete row, we need to split on rows that have "EOREOR" at the end $line = str_replace('"EOREOR"', 'EOREOR', $line); fwrite($fp, $line); if (strpos($line, 'EOREOR')){ // we found the end of a line of data, store it $linecount++; // increment our line counter if ($linecount >= $maxrecs){ echo "Added $linecount records and closing file... <Br>"; $linecount = 0; // reset our line counter // close the existing file and open another; fclose($fp); // increment filecount $filecount++; echo "Creating file EP_Split" . $filecount . ".txt ... "; $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "EP_Split" . $filecount . ".txt"; //Open next file name $fp = fopen( $tmpfname, "w+"); fwrite($fp, $toprow); } } $line=fgets($infp,32768); } echo "Added $linecount records and closing file...<br><br> "; fclose($fp); fclose($infp); echo "You can download your split files in the Tools/Files under /catalog/temp/"; } ?> </p> <table width="75%" border="2"> <tr> <td width="75%"> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php?split=0" METHOD=POST> <p> <div align = "left"> <p><b>Upload EP File</b></p> <p> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000000"> <p></p> <input name="usrfl" type="file" size="50"> <input type="submit" name="buttoninsert" value="Insert into db"><br> </p> </div> </form> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php?split=1" METHOD=POST> <p> <div align = "left"> <p><b>Split EP File</b></p> <p> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000000"> <p></p> <input name="usrfl" type="file" size="50"> <input type="submit" name="buttonsplit" value="Split file"><br> </p> </div> </form> <FORM ENCTYPE="multipart/form-data" ACTION="easypopulate.php" METHOD=POST> <p> <div align = "left"> <p><b>Import from Temp Dir (<? echo $tempdir; ?>)</b></p> <p class="smallText"> <INPUT TYPE="text" name="localfile" size="50"> <input type="submit" name="buttoninsert" value="Insert into db"><br> </p> </div> </form> <p><b>Download EP and Froogle Files</b></p> <!-- Download file links - Add your custom fields here --> <a href="easypopulate.php?download=stream&dltype=full">Download <b>Complete</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=priceqty">Download <b>Model/Price/Qty</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=category">Download <b>Model/Category</b> tab-delimited .txt file to edit</a><br> <a href="easypopulate.php?download=stream&dltype=froogle">Download <b>Froogle</b> tab-delimited .txt file</a><br> <!-- VJ product attributes begin //--> <?php if ($products_with_attributes == true) { ?> <a href="easypopulate.php?download=stream&dltype=attrib">Download <b>Model/Attributes</b> tab-delimited .txt file</a><br> <?php } ?> <!-- VJ product attributes end //--> <p><b>Create EP and Froogle Files in Temp Dir (<? echo $tempdir; ?>)</b></p> <a href="easypopulate.php?download=tempfile&dltype=full">Create Complete tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=priceqty"">Create Model/Price/Qty tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=category">Create Model/Category tab-delimited .txt file in temp dir</a><br> <a href="easypopulate.php?download=tempfile&dltype=froogle">Create Froogle tab-delimited .txt file in temp dir</a><br> <!-- VJ product attributes begin //--> <a href="easypopulate.php?download=tempfile&dltype=attrib">Create Model/Attributes tab-delimited .txt file in temp dir</a><br> <!-- VJ product attributes end //--> </td> </tr> </table> </td> </tr> </table> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <p>?</p> <p>?</p><p><br> </p></body> </html> <?php function ep_get_languages() { $languages_query = tep_db_query("select languages_id, code from " . TABLE_LANGUAGES . " order by sort_order"); // start array at one, the rest of the code expects it that way $ll =1; while ($ep_languages = tep_db_fetch_array($languages_query)) { //will be used to return language_id en language code to report in product_name_code instead of product_name_id $ep_languages_array[$ll++] = array( 'id' => $ep_languages['languages_id'], 'code' => $ep_languages['code'] ); } return $ep_languages_array; }; function tep_get_tax_class_rate($tax_class_id) { $tax_multiplier = 0; $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " WHERE tax_class_id = '" . $tax_class_id . "' GROUP BY tax_priority"); if (tep_db_num_rows($tax_query)) { while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += $tax['tax_rate']; } } return $tax_multiplier; }; function tep_get_tax_title_class_id($tax_class_title) { $classes_query = tep_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'" ); $tax_class_array = tep_db_fetch_array($classes_query); $tax_class_id = $tax_class_array['tax_class_id']; return $tax_class_id ; } function print_el( $item2 ) { echo " | " . substr(strip_tags($item2), 0, 10); }; function print_el1( $item2 ) { echo sprintf("| %'.4s ", substr(strip_tags($item2), 0, 80)); }; function ep_create_filelayout($dltype){ global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders, $max_categories; // depending on the type of the download the user wanted, create a file layout for it. $fieldmap = array(); // default to no mapping to change internal field names to external. switch( $dltype ){ case 'full': // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_products_model' => $iii++, 'v_products_image' => $iii++, 'v_products_bimage' => $iii++, ); foreach ($langcode as $key => $lang){ $l_id = $lang['id']; // uncomment the head_title, head_desc, and head_keywords to use // Linda's Header Tag Controller 2.0 //echo $langcode['id'] . $langcode['code']; $filelayout = array_merge($filelayout , array( 'v_products_name_' . $l_id => $iii++, 'v_products_description_' . $l_id => $iii++, 'v_products_url_' . $l_id => $iii++, 'v_products_head_title_tag_'.$l_id => $iii++, 'v_products_head_desc_tag_'.$l_id => $iii++, 'v_products_head_keywords_tag_'.$l_id => $iii++, )); } // uncomment the customer_price and customer_group to support multi-price per product contrib // VJ product attribs begin $header_array = array( 'v_products_price' => $iii++, 'v_products_price1' => $iii++, 'v_products_price2' => $iii++, 'v_products_price3' => $iii++, 'v_products_price4' => $iii++, 'v_products_price1_qty' => $iii++, 'v_products_price2_qty' => $iii++, 'v_products_price3_qty' => $iii++, 'v_products_price4_qty' => $iii++, 'v_products_qty_blocks' => $iii++, 'v_products_weight' => $iii++, 'v_date_avail' => $iii++, 'v_date_added' => $iii++, 'v_products_quantity' => $iii++, ); $languages = tep_get_languages(); global $attribute_options_array; $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options_values) { $key1 = 'v_attribute_options_id_' . $attribute_options_count; $header_array[$key1] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id; $header_array[$key2] = $iii++; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key3] = $iii++; $key4 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key4] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key5 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id; $header_array[$key5] = $iii++; } $attribute_values_count++; } $attribute_options_count++; } $header_array['v_manufacturers_name'] = $iii++; $filelayout = array_merge($filelayout, $header_array); // VJ product attribs end // build the categories name section of the array based on the number of categores the user wants to have for($i=1;$i<$max_categories+1;$i++){ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++)); } $filelayout = array_merge($filelayout, array( 'v_tax_class_title' => $iii++, 'v_status' => $iii++, )); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, p.products_image as v_products_image, p.products_bimage as v_products_bimage, p.products_price as v_products_price, p.products_price1 as v_products_price1, p.products_price2 as v_products_price2, p.products_price3 as v_products_price3, p.products_price4 as v_products_price4, p.products_price1_qty as v_products_price1_qty, p.products_price2_qty as v_products_price2_qty, p.products_price3_qty as v_products_price3_qty, p.products_price4_qty as v_products_price4_qty, p.products_qty_blocks as v_products_qty_blocks, p.products_weight as v_products_weight, p.products_date_available as v_date_avail, p.products_date_added as v_date_added, p.products_tax_class_id as v_tax_class_id, p.products_quantity as v_products_quantity, p.manufacturers_id as v_manufacturers_id, subc.categories_id as v_categories_id, p.products_status as v_status FROM ".TABLE_PRODUCTS." as p, ".TABLE_CATEGORIES." as subc, ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc WHERE p.products_id = ptoc.products_id AND ptoc.categories_id = subc.categories_id "; break; case 'priceqty': $iii = 0; // uncomment the customer_price and customer_group to support multi-price per product contrib $filelayout = array( 'v_products_model' => $iii++, 'v_products_price' => $iii++, 'v_products_price1' => $iii++, 'v_products_price2' => $iii++, 'v_products_price3' => $iii++, 'v_products_price4' => $iii++, 'v_products_price1_qty' => $iii++, 'v_products_price2_qty' => $iii++, 'v_products_price3_qty' => $iii++, 'v_products_price4_qty' => $iii++, 'v_products_qty_blocks' => $iii++, 'v_products_quantity' => $iii++, #'v_customer_price_1' => $iii++, #'v_customer_group_id_1' => $iii++, #'v_customer_price_2' => $iii++, #'v_customer_group_id_2' => $iii++, #'v_customer_price_3' => $iii++, #'v_customer_group_id_3' => $iii++, #'v_customer_price_4' => $iii++, #'v_customer_group_id_4' => $iii++, ); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, p.products_price as v_products_price, p.products_tax_class_id as v_tax_class_id, p.products_quantity as v_products_quantity FROM ".TABLE_PRODUCTS." as p "; break; case 'category': // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_products_model' => $iii++, ); // build the categories name section of the array based on the number of categores the user wants to have for($i=1;$i<$max_categories+1;$i++){ $filelayout = array_merge($filelayout, array('v_categories_name_' . $i => $iii++)); } $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, subc.categories_id as v_categories_id FROM ".TABLE_PRODUCTS." as p, ".TABLE_CATEGORIES." as subc, ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc WHERE p.products_id = ptoc.products_id AND ptoc.categories_id = subc.categories_id "; break; case 'froogle': // this is going to be a little interesting because we need // a way to map from internal names to external names // // Before it didn't matter, but with froogle needing particular headers, // The file layout is dynamically made depending on the number of languages $iii = 0; $filelayout = array( 'v_froogle_products_url_1' => $iii++, ); // // here we need to get the default language and put $l_id = 1; // dummy it in for now. // foreach ($langcode as $key => $lang){ // $l_id = $lang['id']; $filelayout = array_merge($filelayout , array( 'v_froogle_products_name_' . $l_id => $iii++, 'v_froogle_products_description_' . $l_id => $iii++, )); // } $filelayout = array_merge($filelayout , array( 'v_products_price' => $iii++, 'v_products_fullpath_image' => $iii++, 'v_category_fullpath' => $iii++, 'v_froogle_offer_id' => $iii++, 'v_froogle_instock' => $iii++, 'v_froogle_ shipping' => $iii++, 'v_manufacturers_name' => $iii++, 'v_froogle_ upc' => $iii++, 'v_froogle_color' => $iii++, 'v_froogle_size' => $iii++, 'v_froogle_quantitylevel' => $iii++, 'v_froogle_product_id' => $iii++, 'v_froogle_manufacturer_id' => $iii++, 'v_froogle_exp_date' => $iii++, 'v_froogle_product_type' => $iii++, 'v_froogle_delete' => $iii++, 'v_froogle_currency' => $iii++, )); $iii=0; $fileheaders = array( 'product_url' => $iii++, 'name' => $iii++, 'description' => $iii++, 'price' => $iii++, 'image_url' => $iii++, 'category' => $iii++, 'offer_id' => $iii++, 'instock' => $iii++, 'shipping' => $iii++, 'brand' => $iii++, 'upc' => $iii++, 'color' => $iii++, 'size' => $iii++, 'quantity' => $iii++, 'product_id' => $iii++, 'manufacturer_id' => $iii++, 'exp_date' => $iii++, 'product_type' => $iii++, 'delete' => $iii++, 'currency' => $iii++, ); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model, p.products_image as v_products_image, p.products_bimage as v_products_bimage, p.products_price as v_products_price, p.products_price1 as v_products_price1, p.products_price2 as v_products_price2, p.products_price3 as v_products_price3, p.products_price4 as v_products_price4, p.products_price1_qty as v_products_price1_qty, p.products_price2_qty as v_products_price2_qty, p.products_price3_qty as v_products_price3_qty, p.products_price4_qty as v_products_price4_qty, p.products_qty_blocks as v_products_qty_blocks, p.products_weight as v_products_weight, p.products_date_added as v_date_avail, p.products_tax_class_id as v_tax_class_id, p.products_quantity as v_products_quantity, p.manufacturers_id as v_manufacturers_id, subc.categories_id as v_categories_id FROM ".TABLE_PRODUCTS." as p, ".TABLE_CATEGORIES." as subc, ".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc WHERE p.products_id = ptoc.products_id AND ptoc.categories_id = subc.categories_id "; break; // VJ product attributes begin case 'attrib': $iii = 0; $filelayout = array( 'v_products_model' => $iii++ ); $header_array = array(); $languages = tep_get_languages(); global $attribute_options_array; $attribute_options_count = 1; foreach ($attribute_options_array as $attribute_options_values) { $key1 = 'v_attribute_options_id_' . $attribute_options_count; $header_array[$key1] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key2 = 'v_attribute_options_name_' . $attribute_options_count . '_' . $l_id; $header_array[$key2] = $iii++; } $attribute_values_query = "select products_options_values_id from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$attribute_options_values['products_options_id'] . "' order by products_options_values_id"; $attribute_values_values = tep_db_query($attribute_values_query); $attribute_values_count = 1; while ($attribute_values = tep_db_fetch_array($attribute_values_values)) { $key3 = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key3] = $iii++; $key4 = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; $header_array[$key4] = $iii++; for ($i=0, $n=sizeof($languages); $i<$n; $i++) { $l_id = $languages[$i]['id']; $key5 = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $l_id; $header_array[$key5] = $iii++; } $attribute_values_count++; } $attribute_options_count++; } $filelayout = array_merge($filelayout, $header_array); $filelayout_sql = "SELECT p.products_id as v_products_id, p.products_model as v_products_model FROM ".TABLE_PRODUCTS." as p "; break; // VJ product attributes end } $filelayout_count = count($filelayout); } function walk( $item1 ) { globa
  15. christoph_999

    Easy Populate & Products Attributes

    Hi Its already 5am and i cant make it work correctly :'( My problem seems to be with excel. when i download the complete txt (with all attributes), there is a "." as comma at the prices, but opening the txt with excel makes the "." change to a "," and as i upload the saved txt, all prices are rounded to a full number. example: shoes price: 53,99 with attribute red "+15,50" after upload: 53,00 attribute red "+15,00" sorry for my english i hope its not hopeless :-" please help, i already tried to make changes in excel. This transforming of the comma seems to be not changeable default. I also tried with import of the txt-file into excel, but with some 40 attributes i sit half an hour to change the import options for excel from "standard" to "text". And i have to make many changes many times would be glad, if somebody could help
×