commit 39aa8f75bc0f62a33a7d998b50ee1040bb7dbeae Author: david Date: Tue Jun 26 08:20:58 2007 +0000 git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_WebOSC/tags/1.0.2@4 15ff7747-3a15-8b43-b76a-1f22d5625af6 diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..cb3e2df --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,335 @@ +$Id: $ + +osCommerce Changelog +Copyright (c) 2006 osCommerce + +------------------------------------------------------------------------------ +08/17/2006 osCommerce 2.2 Milestone 2 Update 060817 +------------------------------------------------------------------------------ + +Please review the update-20060817.txt file for the important changes made. + +------------------------------------------------------------------------------ +11/13/2005 osCommerce 2.2 Milestone 2 Update 051113 +------------------------------------------------------------------------------ + + * Fixed bug 1662; update of customers address through the My Account page + resulted in the country value not being stored properly and affected tax + rate values. + +------------------------------------------------------------------------------ +11/12/2005 osCommerce 2.2 Milestone 2 Update 051112 +------------------------------------------------------------------------------ + +Please review the update-20060817.txt file for the important changes made. + + * Index language definition: updated the Wiki link to point to the Knowledge + Base site + + * Reviews Box: Renamed the following variables due to naming conflicts: + + $review_query -> $rand_review_query + $review -> $rand_review + $review -> $rand_review_text + + * Wrapped all input parameters with tep_output_string() in the tep_image() + function on the administration tool + (admin/includes/functions/html_output.php) + + * UPS shipping module removed due to it violating the UPS terms of service. + An alternative module can be found here: + http://www.oscommerce.com/community/contributions,1323 + + * Updated codebase for PHP 5.0 compatibility + + * Updated database structure for MySQL 5.0 compatibility + +------------------------------------------------------------------------------ +12/07/2003 osCommerce 2.2 Milestone 2 +------------------------------------------------------------------------------ + + * Shared SSL servers are now properly supported with cookie parameters + existing for both normal and secure servers. + + * The installation/upgrade procedure was simplified with a new layout. + + * Internally set PHPs error reporting to E_ALL to remove all notice messages + on the Catalog module. + + * Renamed default.php to index.php. + + * Sanitize all user input on the Catalog module before inserting it into the + database. + + * Updated the layout of the shopping cart page. + + * Fixed linefeed issues with emails. + + * Modules are now installed at the Administration Tool via Install/Remove + buttons located in the infobox; no longer through clicking on the status + icons. This is to be consistent with other areas of the Administration + Tool. + + * Updated the layout of the product listing page. + + * Updated the splitPageResults class to use the benefits a class provides. + + * Realized the My Account Proposal as discussed on the developers forum + channel. + + * Introduced the message stack class used on the Administration Tool to the + Catalog module. It has been extended to store messages in groups allowing + to display the messages in groups at separate sections of the page. + + * Removed old European currencies (Deutsche Mark and Spanish Peseta) + + * Update the default configuration parameters to meet the needs of USA (it + was previously meeting a mix of USA and European regulations) + + * IP Address and Client Browser User Agent validations implemented for the + Security And Privacy Proposal. + + * Session ID Regeneration feature implemented as part of the Security And + Privacy Proposal. + + * New file upload class implemented. + + * Search Engine Spider Session Prevention feature implemented as part of the + Security And Privacy Proposal. + + * Manually round numbers in the tep_round() function, bypassing PHPs round() + and number_format() functions. + + The PHP round() and number_format() functions return different results when + strings or floats are being processed. + + * Added data validation to the Customers section on the Administration Tool. + + * Tax Compounding logic corrected. + + * Cross site scripting vulnerabilities fixed. + + * Moved filename and database table definitions from application_top.php to + their own files. + + * The Tax Priority can now be inserted when creating new tax rates in the + Administration Tool. + + * Implement the force cookie usage and ssl_session_id validations features + from the Security and Privacy Proposal. + + * Virtual products tax update (virtual products were not being updated as no + shipping address is in use. Instead, the billing address is used to base + the taxes on. + +------------------------------------------------------------------------------ +02/17/2003 osCommerce 2.2 Milestone 1 +------------------------------------------------------------------------------ + +*** The changelog entry for the 2.2 Milestone releases will be updated *** +*** throughout the Milestone release path. The information here is *** +*** currently old. *** + + * Manufacturer now saved when adding products. (bug fix) + + * Added .htaccess file in the 'includes' directory for some security (blocks + direct http requests to .php files). + ie, http://server/catalog/includes/application_top.php + + * New cache class added for the categoies box (only for PHP4) + - Note, this is disabled by default due to our run out-of-the-box approach. + Can also be used in other areas of the catalog. + + * New Who's Online section in the administration tool. + + * Updated payment and shipping modules structure - no longer has multiple + include statements - and are now classes. + + * Administration Tool sections now with opened/closed box approach (the list + of functions was getting too long!). + + * New login and create account option page (ala Amazon style) + + * Click on the products image (in products details) and a new browser window + will open and resize itself to the image shown - used to display larger + pictures of the product. + + * All font styles are now in stylesheets. + + * Full locaization support (ie, categories title, products descriptions, + image buttons, etc) + + * Table names now as constants (variables) + + * Banner support functionality + + * Products expected now as normal products (with descriptions) + + * Stock control functionality + + * Products with different attributes can now be added to the shopping cart. + (feature fix) + + * Authorize.net support added + + * Sessions can now be stored in the database + + * Tell-A-Friend function for products + + * Information box, with all informations about shipping & returns, privacy + notice and conditions of use + + * Newsletter function in the administration tool. + + * New zones for germany, swiss and austria. + + * Prices can now be handled with/without tax. The tax would be correct + calculated. + + * Prices in all countries which joined the euro currency, displays the prices + in euro and national currency. This is a european guideline which is now + support by TEP. + + * All address information is now stored in the address_book table only. This + change was made to reduce redundancy and allow more feautures in the + checkout part (e.g. selection of different BillTo and SendTo addresses) + +------------------------------------------------------------------------------ +03/06/2001 The Exchange Project Preview Release 2.1 +------------------------------------------------------------------------------ + + * Payment methods are now modules, makes it easier to implement other payment + methods. Supported methods COD, Credit Card, Paypal. CC also supports + storing only part of the CC# in the DB with the other digits being emailled + to a specific email address. + + * Shipping Modules - Modular shipping methods with support for UPS, USPS, + FEDEX(Ground), Per Item and Flat rate shipping. + + * Db query clean up a few AS clauses were added for earlier MySQL versions. + Error checking added for when no records exist. + + * Added languages box - customers can now choose their language anywhere + except during the checkout procedure (due to POST variables in forms) + + * Added currencies box - customers can now choose their currency independent + from the language chosen + + * Currencies can be added/deleted/modified through the administration tool - + no longer through individual language files in the include directory + + * Added a 'Contact Us' Page. + + * Added COMMENTS field to Orders table - an order history + Need to ALTER TABLE orders ADD comments TEXT not null; + + * Selectable columns in 'Product Listings'. + + * Added a delete button to the orders in the admin tool. + + * Solved a problem with the session id not being passed to the secure server. + + * Countries added to the admin tool. + + * The 'Add a Quickie' box now uses the model number instead of the product + id. + + * The 'Search' box and the 'Advanced Search' now use the same engine. + + * Backup in the admin tool. + + * Numerous bugs fixed. + + * Categories box has been updated to display path taken in bold, and display + the parent categories (tree navigation) + + * Font styles implemented + + * tep_image now optionally calculates image size if omitted + + * products_to_manufacturers table removed. Manufacturers are now directly + link to products, via manufacturers_id record in the products table + + * tep_href_link now removes extra & and ? characters in the URL + + * Products with no manufacturers are now listed in the catalog module + + * New DIR_* definitions for easier understanding -> + FS = Filesystem (physical) + WS = Webserver (virtual) + +------------------------------------------------------------------------------ +12/13/2000 The Exchange Project Preview Release 2.0a +------------------------------------------------------------------------------ + + * Added FedEx shipping module + * Bugfixes + +------------------------------------------------------------------------------ +12/02/2000 The Exchange Project Preview Release 2.0 +------------------------------------------------------------------------------ + + * Manufacturers pull-down select box + * Number of products in each category displayed + * Bestsellers box + * See what other customers have brought (linked to current product displayed) + * Administration Tool now user-friendlier via new layout + * Categories-to-Categories structure + * Spanish added to the official languages supported + * Dynamic product attributes + * Tax zones, classes, and rates + * Now PHP3/PHP4 compatible + * Some configuration parameters now in database + * Manufacturers now directly linked to products + * Status of orders can now be modified + * New advanced search page + * Order confirmation emails can now be sent to multiple addresses + * Address formating function implemented + * PayPal payments implemented + * Currencies are now formated to the selected locale + +------------------------------------------------------------------------------ +05/14/2000 The Exchange Project Preview Release 1.1 +------------------------------------------------------------------------------ + + * Customization variables and constants + * English and German localization + * New products and upcoming products modularized + * Added custom tep_db_* database functions + * Added custom tep_session_* session functions + * Added tep_href_link function + * Added tep_image function + * Added tep_image_submit function + * Added tep_black_line function + * Added tep_break_string function + * Added tep_products_in_cart function + * Added tep_exit function + * Added tep_number_format function + * Reviews-Box now displays a random review + * account_edit_process.php updated + * Review-Box: text now broken to avoid exceeding box width + * address_book_add.php updated, also combined with + address_book_add_process.php + * login.php updated, also combined with login_process.php + * login_forgotten.php and login_forgotten_process.php now combined to + password_forgotten.php + * Added products image to reviews info + * products_reviews_write.php and products_reviews_write_process.php combined + * shopping_cart.php updates + * shopping_cart.php now displays proper price on special for nonsess cart + * Fixed misalignment of checkout information + * New directory structure for includes + * application_top.php and application_bottom.php implemented for application + wide parameters + * column_left.php and column_right.php structure implemented + * Display parse time of pages + * SQL queries optimized + * tep_number_format function implemented, but not in use + * Fixed add a quickie bug - when product did not exist in catalog, it + inserted a null entry in the cart + +------------------------------------------------------------------------------ +03/12/2000 The Exchange Project Preview Release 1.0 +------------------------------------------------------------------------------ + + * Initial Release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8915310 --- /dev/null +++ b/LICENSE @@ -0,0 +1,91 @@ +GNU GENERAL PUBLIC LICENSE + + +Version 2, June 1991 +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + + +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + + +GNU GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + + +NO WARRANTY +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +END OF TERMS AND CONDITIONS diff --git a/STANDARD b/STANDARD new file mode 100644 index 0000000..cce4562 --- /dev/null +++ b/STANDARD @@ -0,0 +1,501 @@ +$Id: STANDARD,v 1.13 2003/06/09 21:13:13 hpdl Exp $ + +osCommerce Coding Standards + +Coding standards are defined to keep the codebase in a maintainable state. + +The more developers working within the codebase means the more ways php +logic can be written. + +If every developer follows the standards then everyone is able to review +the codebase and not waste time thinking about why a certain style was +used in a particular area compared to another area. + +File Format +----------- + +The source code should be saved in Unix format - meaning with Unix +linefeeds. + +Most editors are able to set the preferred format method of Windows, +Unix, or Macintosh. + +Some editors add a line to the bottom of the file. This is safe to have +as long as a further character (including the space character) does not +exist. Characters that exist at the end of the file may interfer when +redirections occur as text has been sent to the client already. + +The filename of the files must be all lowercass characters and contain +no more than 31 characters to be Apple/Mac compatible. + +Indentation +----------- + +Indentation of logic should be 2 whitespace characters. + +TABs should not be used. + +Starting and Ending PHP Logic +----------------------------- + +When starting PHP logic, the tag should be written as "". + +A valid example: + + + +Defining Constants +------------------ + +Constants must be defined before they are being used - which also includes +constants called from include()'d/require()'d files. + +Variable Scope* +-------------- + +All variables must be accessed and set within their scope as: + +$HTTP_GET_VARS['variable'] +$HTTP_POST_VARS['variable'] +$HTTP_COOKIE_VARS['variable'] +$variable (either local, or session) + +* This needs to be updated when the codebase has been made compatible with +the register_global parameter. Session variables are then accessed and set +within its scope as: + +$HTTP_SESSION_VARS['variable'] + +When PHP3 support is dropped, the following scope will be used: + +$_GET['variable'] +$_POST['variable'] +$_COOKIE['variable'] +$_SESSION['variable'] + +PHP 4.0.x does not support the above scope which was introduced in PHP 4.1.x. +The following can be used which is not compatible with PHP 3.x: + +$_GET =& $HTTP_GET_VARS; +$_POST =& $HTTP_POST_VARS; +$_COOKIE =& $HTTP_COOKIE_VARS; +$_SESSION =& $HTTP_SESSION_VARS; + +include() vs require() +---------------------- + +The use of include() will include the specified file when needed, whereas +the use of require() will always include the specified file regardless if it +is needed or not. + +Example: + + + +Instantiating Classes +--------------------- + +When instantiating classes into objects, the following style must be used: + + + +* PHP3 does not support the following style which includes an empty bracket +set: + + + +Displaying Strings +------------------ + +Strings or values should be displayed as: + + + +The following styles should be avoided: + + + + + +Singe-Quotes vs Double-Quotes +----------------------------- + +When displaying strings single quote characters should be used. + +Double quote characters should be used only when control characters are +needed. + +For example: + + + + +Custom Functions +---------------- + +All custom functions should start with tep_ so that the developer knows +a native PHP function is not being called.* + +An example custom function style: + + + +* When 2.2 is finalized the custom functions should be renamed to osc_* +as "tep" refers to the previous name of the project. + +Class Names +----------- + +There are two types of styles to use when classes are used. + +The first type of class set are the static classes that can be found in +the includes/classes directory. + +If the class name contains more than one word, the words in the filename +are separated with an underscore character. The actual class name is one +whole word where words from the second onwards being capitalized. + +For example, a class name of myOwnClass has a filename of +my_own_class.php. + +The second type of class set are the dynamic modules that can be found +in the includes/modules/* directories. + +The class names must match the filename as most of them are include()'d +dynamicly. + +For example, a class filename of my_own_module.php has a class name of +my_own_module. + +Class Structure +--------------- + +The class should be written in the following structure: + +variable = 'set'; + + return true; + } + } + + $class = new myclass; + $class->do_something(); +?> + +Database Queries +---------------- + +Database queries are wrapped around custom functions and should be +structured as: + + + +Unlike displaying strings, double quote characters are wrapped around the sql query. + +The following is currently for the Administration Tool but will also be implemented +in the Catalog module. + +Before data can be entered in the database, it must be protected against possible +attacks residing in the user input. The data is first prepared and then protected +when inserting it into the table. The following structure is used: + + + +Variable type casting should be performed directly for integer based values, such +as column IDs: (int)$variable + +Multiple values can be parsed, protected and inserted into the table in an easier +fashion: + + $value1, + 'column2' => $value2, + 'column3' => $value3); + + tep_db_perform('table', $sql_data_array); +?> + +A similar structure can be used for updating values in a table: + + $value1, + 'column2' => $value2, + 'column3' => $value3); + + tep_db_perform('table', $sql_data_array, 'update', "id = '" . (int)$id . "'"); +?> + +Table names should not directly be entered in the query, but the constant +parameter assigned to that table. A list of defined constant table names +can currently be found in includes/database_tables.php. + +Function Output +--------------- + +All custom functions should return strings; not directly via echo(). + +For example: + + + +and not: + + + +Condition Statements +-------------------- + +If statements should be written as: + + + +If the condition is to check for a boolean value, this should be added +to the condition (as above) for clarity. + +The following should not be used: + + + +instead use the following: + + + +Multiple conditions should reside in their own parenthesis, as: + + + +Simple boolean expressions can be written as: + + + +Simple statements can be written as: + + + +Functions do not need to be checked with a true/false +statement. For the following valid example: + + + +Switch-Case statements should be written as: + + + +Condition Checking +------------------ + +To see if a variable exists, use the following structure: + + + +and not: + + + +Repetitive Statements +--------------------- + +while loops should be written as: + + + +Walking through an array should be written as: + + $value) { + .... + } +?> + +for loops should be written as: + + + +Mixing HTML and PHP +------------------- + +Common HTML tags started in HTML must end in HTML, and +tags started in PHP must end in PHP. + +Wrong: + +"; ?> + +Correct: + + + +Correct: + +Hello'; +?> + +Exceptions to this standard include the tep_draw_form() +function: + + +[form input fields are placed here] + +?> diff --git a/_PSD/Thumbs.db b/_PSD/Thumbs.db new file mode 100644 index 0000000..ba5e86a Binary files /dev/null and b/_PSD/Thumbs.db differ diff --git a/_PSD/button_long.psd b/_PSD/button_long.psd new file mode 100644 index 0000000..09214ba Binary files /dev/null and b/_PSD/button_long.psd differ diff --git a/_PSD/button_short.psd b/_PSD/button_short.psd new file mode 100644 index 0000000..c034113 Binary files /dev/null and b/_PSD/button_short.psd differ diff --git a/_PSD/button_small.psd b/_PSD/button_small.psd new file mode 100644 index 0000000..a7e3b63 Binary files /dev/null and b/_PSD/button_small.psd differ diff --git a/catalog/.htaccess b/catalog/.htaccess new file mode 100644 index 0000000..13d0b2f --- /dev/null +++ b/catalog/.htaccess @@ -0,0 +1,40 @@ +# $Id: .htaccess,v 1.3 2003/06/12 10:53:20 hpdl Exp $ +# +# This is used with Apache WebServers +# +# For this to work, you must include the parameter 'Options' to +# the AllowOverride configuration +# +# Example: +# +# +# AllowOverride Options +# +# +# 'All' with also work. (This configuration is in the +# apache/conf/httpd.conf file) + +# The following makes adjustments to the SSL protocol for Internet +# Explorer browsers + + + + SetEnvIf User-Agent ".*MSIE.*" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + + + +# If Search Engine Friendly URLs do not work, try enabling the +# following Apache configuration parameter +# +# AcceptPathInfo On + +# Fix certain PHP values +# (commented out by default to prevent errors occuring on certain +# servers) +# +# +# php_value session.use_trans_sid 0 +# php_value register_globals 1 +# diff --git a/catalog/_version_ b/catalog/_version_ new file mode 100644 index 0000000..e6d5cb8 --- /dev/null +++ b/catalog/_version_ @@ -0,0 +1 @@ +1.0.2 \ No newline at end of file diff --git a/catalog/account.php b/catalog/account.php new file mode 100644 index 0000000..aa79b3a --- /dev/null +++ b/catalog/account.php @@ -0,0 +1,271 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT); + + $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + +size('account') > 0) { +?> + + + + + + + + + + 0) { +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + // Rodax Software +?> + +
+ + + + +
+
+ +

+ +
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + +
' . 'Hacer un pedido nuevo o continuar el pendiente' . ''; ?>
' . MY_ORDERS_VIEW . ''; ?>
output('account'); ?>
+ + + + +
' . OVERVIEW_SHOW_ALL_ORDERS . ''; ?>
+ + + +
+ + + + + +
' . OVERVIEW_PREVIOUS_ORDERS . '
' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?>
+ + + + + + + + + + +
' . Ver /*tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW)*/ . ''; ?>
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + + + + +
' . MY_ACCOUNT_INFORMATION . ''; ?>
' . MY_ACCOUNT_ADDRESS_BOOK . ''; ?>
' . MY_ACCOUNT_PASSWORD . ''; ?>
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + +
' . EMAIL_NOTIFICATIONS_NEWSLETTERS . ''; ?>
' . EMAIL_NOTIFICATIONS_PRODUCTS . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account.php.ORIGINAL b/catalog/account.php.ORIGINAL new file mode 100644 index 0000000..d1c16be --- /dev/null +++ b/catalog/account.php.ORIGINAL @@ -0,0 +1,271 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT); + + $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + +size('account') > 0) { +?> + + + + + + + + + + 0) { +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ + // Rodax Software +?> + +
+ + + + +
+
+ +

+ +
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + +
' . 'Hacer un pedido nuevo o continuar el pendiente' . ''; ?>
' . MY_ORDERS_VIEW . ''; ?>
output('account'); ?>
+ + + + +
' . OVERVIEW_SHOW_ALL_ORDERS . ''; ?>
+ + + +
+ + + + + +
' . OVERVIEW_PREVIOUS_ORDERS . '
' . tep_image(DIR_WS_IMAGES . 'arrow_south_east.gif'); ?>
+ + + + + + + + + + +
' . tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW) . ''; ?>
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + + + + +
' . MY_ACCOUNT_INFORMATION . ''; ?>
' . MY_ACCOUNT_ADDRESS_BOOK . ''; ?>
' . MY_ACCOUNT_PASSWORD . ''; ?>
+ + + +
+ + + +
+ + + + + + + +
+ + + + + + +
' . EMAIL_NOTIFICATIONS_NEWSLETTERS . ''; ?>
' . EMAIL_NOTIFICATIONS_PRODUCTS . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_edit.php b/catalog/account_edit.php new file mode 100644 index 0000000..5b65ae1 --- /dev/null +++ b/catalog/account_edit.php @@ -0,0 +1,281 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + +// needs to be included earlier to set the success message in the messageStack + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_EDIT); + + if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { + if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']); + $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']); + $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']); + if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']); + $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']); + $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']); + $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']); + + $error = false; + + if (ACCOUNT_GENDER == 'true') { + if ( ($gender != 'm') && ($gender != 'f') ) { + $error = true; + + $messageStack->add('account_edit', ENTRY_GENDER_ERROR); + } + } + + if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_edit', ENTRY_FIRST_NAME_ERROR); + } + + if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_edit', ENTRY_LAST_NAME_ERROR); + } + + if (ACCOUNT_DOB == 'true') { + if (!checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4))) { + $error = true; + + $messageStack->add('account_edit', ENTRY_DATE_OF_BIRTH_ERROR); + } + } + + if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR); + } + + if (!tep_validate_email($email_address)) { + $error = true; + + $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); + } + + $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and customers_id != '" . (int)$customer_id . "'"); + $check_email = tep_db_fetch_array($check_email_query); + if ($check_email['total'] > 0) { + $error = true; + + $messageStack->add('account_edit', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS); + } + + if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_edit', ENTRY_TELEPHONE_NUMBER_ERROR); + } + + if ($error == false) { + $sql_data_array = array('customers_firstname' => $firstname, + 'customers_lastname' => $lastname, + 'customers_email_address' => $email_address, + 'customers_telephone' => $telephone, + 'customers_fax' => $fax); + + if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender; + if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob); + + tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'"); + + tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'"); + + $sql_data_array = array('entry_firstname' => $firstname, + 'entry_lastname' => $lastname); + + tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$customer_default_address_id . "'"); + +// reset the session variables + $customer_first_name = $firstname; + + $messageStack->add_session('account', SUCCESS_ACCOUNT_UPDATED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + } + } + + $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); + $account = tep_db_fetch_array($account_query); + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +size('account_edit') > 0) { +?> + + + + + + + + + + + + + + + + +
+ + + + +
output('account_edit'); ?>
+ + + + + + +
+ + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + + < ? php echo $ account ['customers_lastname']; ? > */ + ?> + + + + + + + + + + + + + + + + + + + + + + +
' . ENTRY_GENDER_TEXT . '': ''); ?>
' . ENTRY_DATE_OF_BIRTH_TEXT . '': ''); ?>


Si algún dato de su cuento no es correcto, por favor, contacte con .
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_history.php b/catalog/account_history.php new file mode 100644 index 0000000..70a03f5 --- /dev/null +++ b/catalog/account_history.php @@ -0,0 +1,169 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY); + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + 0) { +?> + + + + + + + + + + +
+ + + + +
+ 0) { + $history_query_raw = "select o.orders_id, o.date_purchased, o.delivery_name, o.billing_name, ot.text as order_total, s.orders_status_name from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_TOTAL . " ot, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customer_id . "' and o.orders_id = ot.orders_id and ot.class = 'ot_total' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' order by orders_id DESC"; + $history_split = new splitPageResults($history_query_raw, MAX_DISPLAY_ORDER_HISTORY); + $history_query = tep_db_query($history_split->sql_query); + $i = 0; + while ($history = tep_db_fetch_array($history_query)) { + $i++; + $products_query = tep_db_query("select count(*) as count from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$history['orders_id'] . "'"); + $products = tep_db_fetch_array($products_query); + + if (tep_not_null($history['delivery_name'])) { + $order_type = TEXT_ORDER_SHIPPED_TO; + $order_name = $history['delivery_name']; + } else { + $order_type = TEXT_ORDER_BILLED_TO; + $order_name = $history['billing_name']; + } +?> + '; + } else { + echo ''; + }?> + + + + + + + + +
' . TEXT_ORDER_NUMBER . ' ' . $history['orders_id']; ?>' . TEXT_ORDER_DATE . ' ' . tep_date_long($history['date_purchased']) ?> ' . TEXT_ORDER_PRODUCTS . ' ' . $products['count'] ?> ' . TEXT_ORDER_STATUS . ' ' . $history['orders_status_name']; ?>' . Ver /*tep_image_button('small_view.gif', SMALL_IMAGE_BUTTON_VIEW)*/ . ''; ?>
+ + + + + + + + +
+ + + +
+ +
+ + + + +
display_count(TEXT_DISPLAY_NUMBER_OF_ORDERS); ?>display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?>
+ + + +
+ + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_history_info.php b/catalog/account_history_info.php new file mode 100644 index 0000000..e6ac20a --- /dev/null +++ b/catalog/account_history_info.php @@ -0,0 +1,277 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) { + tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + } + + $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'"); + $customer_info = tep_db_fetch_array($customer_info_query); + if ($customer_info['customers_id'] != $customer_id) { + tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO); + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + $breadcrumb->add(sprintf(NAVBAR_TITLE_3, $HTTP_GET_VARS['order_id']), tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $HTTP_GET_VARS['order_id'], 'SSL')); + + require(DIR_WS_CLASSES . 'order.php'); + $order = new order($HTTP_GET_VARS['order_id']); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + +
(' . $order->info['orders_status'] . ')'; ?>
info['date_purchased']); ?>info['total']; ?>
+ +delivery != false) { +?> + + + + +
+ + + + + + +info['shipping_method'])) { +?> + + + + + + +delivery['shipdate'])){ +?> + + + + + + + +
delivery['format_id'], $order->delivery, 1, ' ', '
'); ?>
info['shipping_method']; ?>
delivery['shipdate']); ?>
+ + + +
+info['tax_groups']) > 1) { +?> + + + + + + + + + +products); $i<$n; $i++) { + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + + /*if (sizeof($order->info['tax_groups']) > 1) { + echo ' ' . "\n"; + } + + echo ' ' . "\n" . + ' ' . "\n"; + */ + } +?> +
' . $order->products[$i]['qty'] . ' x' . $order->products[$i]['name']; + + if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) { + for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { + echo '
  - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . ''; + } + } + + echo '
' . tep_display_tax_value($order->products[$i]['tax']) . '%' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '
+ + + + +
+ + + + + + + + + + + + +
billing['format_id'], $order->billing, 1, ' ', '
'); ?>
info['payment_method']; ?>
+totals); $i<$n; $i++) { + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + }*/ +?> +
' . $order->totals[$i]['title'] . '' . $order->totals[$i]['text'] . '
Historial de estados del pedido
+ + + +
+' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . tep_date_short($statuses['date_added']) . '' . tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . '' . $statuses['orders_status_name'] . '' . (empty($statuses['comments']) ? ' ' : nl2br(tep_output_string_protected($statuses['comments']))) . '
+ + + +
+ + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_history_info.php.ORIGINAL b/catalog/account_history_info.php.ORIGINAL new file mode 100644 index 0000000..ee12ec3 --- /dev/null +++ b/catalog/account_history_info.php.ORIGINAL @@ -0,0 +1,262 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) { + tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + } + + $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '". (int)$HTTP_GET_VARS['order_id'] . "'"); + $customer_info = tep_db_fetch_array($customer_info_query); + if ($customer_info['customers_id'] != $customer_id) { + tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_HISTORY_INFO); + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL')); + $breadcrumb->add(sprintf(NAVBAR_TITLE_3, $HTTP_GET_VARS['order_id']), tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $HTTP_GET_VARS['order_id'], 'SSL')); + + require(DIR_WS_CLASSES . 'order.php'); + $order = new order($HTTP_GET_VARS['order_id']); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + +
(' . $order->info['orders_status'] . ')'; ?>
info['date_purchased']); ?>info['total']; ?>
+ +delivery != false) { +?> + + + + +
+ + + + + + +info['shipping_method'])) { +?> + + + + + + + +
delivery['format_id'], $order->delivery, 1, ' ', '
'); ?>
info['shipping_method']; ?>
+ + + +
+info['tax_groups']) > 1) { +?> + + + + + + + + + +products); $i<$n; $i++) { + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + + if (sizeof($order->info['tax_groups']) > 1) { + echo ' ' . "\n"; + } + + echo ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . $order->products[$i]['qty'] . ' x' . $order->products[$i]['name']; + + if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) { + for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { + echo '
  - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . ''; + } + } + + echo '
' . tep_display_tax_value($order->products[$i]['tax']) . '%' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '
+ + + + +
+ + + + + + + + + + + + +
billing['format_id'], $order->billing, 1, ' ', '
'); ?>
info['payment_method']; ?>
+totals); $i<$n; $i++) { + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . $order->totals[$i]['title'] . '' . $order->totals[$i]['text'] . '
+ + + +
+' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . tep_date_short($statuses['date_added']) . '' . $statuses['orders_status_name'] . '' . (empty($statuses['comments']) ? ' ' : nl2br(tep_output_string_protected($statuses['comments']))) . '
+ + + +
+ + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_newsletters.php b/catalog/account_newsletters.php new file mode 100644 index 0000000..2a36103 --- /dev/null +++ b/catalog/account_newsletters.php @@ -0,0 +1,159 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + +// needs to be included earlier to set the success message in the messageStack + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_NEWSLETTERS); + + $newsletter_query = tep_db_query("select customers_newsletter from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); + $newsletter = tep_db_fetch_array($newsletter_query); + + if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { + if (isset($HTTP_POST_VARS['newsletter_general']) && is_numeric($HTTP_POST_VARS['newsletter_general'])) { + $newsletter_general = tep_db_prepare_input($HTTP_POST_VARS['newsletter_general']); + } else { + $newsletter_general = '0'; + } + + if ($newsletter_general != $newsletter['customers_newsletter']) { + $newsletter_general = (($newsletter['customers_newsletter'] == '1') ? '0' : '1'); + + tep_db_query("update " . TABLE_CUSTOMERS . " set customers_newsletter = '" . (int)$newsletter_general . "' where customers_id = '" . (int)$customer_id . "'"); + } + + $messageStack->add_session('account', SUCCESS_NEWSLETTER_UPDATED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + } + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + +
+ + + + + +
+ + + + + + + + +
  + + + + + +
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_notifications.php b/catalog/account_notifications.php new file mode 100644 index 0000000..75cea67 --- /dev/null +++ b/catalog/account_notifications.php @@ -0,0 +1,251 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + +// needs to be included earlier to set the success message in the messageStack + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_NOTIFICATIONS); + + $global_query = tep_db_query("select global_product_notifications from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customer_id . "'"); + $global = tep_db_fetch_array($global_query); + + if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { + if (isset($HTTP_POST_VARS['product_global']) && is_numeric($HTTP_POST_VARS['product_global'])) { + $product_global = tep_db_prepare_input($HTTP_POST_VARS['product_global']); + } else { + $product_global = '0'; + } + + (array)$products = $HTTP_POST_VARS['products']; + + if ($product_global != $global['global_product_notifications']) { + $product_global = (($global['global_product_notifications'] == '1') ? '0' : '1'); + + tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set global_product_notifications = '" . (int)$product_global . "' where customers_info_id = '" . (int)$customer_id . "'"); + } elseif (sizeof($products) > 0) { + $products_parsed = array(); + for ($i=0, $n=sizeof($products); $i<$n; $i++) { + if (is_numeric($products[$i])) { + $products_parsed[] = $products[$i]; + } + } + + if (sizeof($products_parsed) > 0) { + $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")"); + $check = tep_db_fetch_array($check_query); + + if ($check['total'] > 0) { + tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "' and products_id not in (" . implode(',', $products_parsed) . ")"); + } + } + } else { + $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "'"); + $check = tep_db_fetch_array($check_query); + + if ($check['total'] > 0) { + tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where customers_id = '" . (int)$customer_id . "'"); + } + } + + $messageStack->add_session('account', SUCCESS_NOTIFICATIONS_UPDATED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + } + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + +
+ + + + + +
+ + + +
+ + + + + +
+ + + + + + + + +
 
+ + + +
+ + + + + +
+ 0) { +?> + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/account_password.php b/catalog/account_password.php new file mode 100644 index 0000000..620dac4 --- /dev/null +++ b/catalog/account_password.php @@ -0,0 +1,183 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + +// needs to be included earlier to set the success message in the messageStack + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT_PASSWORD); + + if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { + $password_current = tep_db_prepare_input($HTTP_POST_VARS['password_current']); + $password_new = tep_db_prepare_input($HTTP_POST_VARS['password_new']); + $password_confirmation = tep_db_prepare_input($HTTP_POST_VARS['password_confirmation']); + + $error = false; + + if (strlen($password_current) < ENTRY_PASSWORD_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_password', ENTRY_PASSWORD_CURRENT_ERROR); + } elseif (strlen($password_new) < ENTRY_PASSWORD_MIN_LENGTH) { + $error = true; + + $messageStack->add('account_password', ENTRY_PASSWORD_NEW_ERROR); + } elseif ($password_new != $password_confirmation) { + $error = true; + + $messageStack->add('account_password', ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING); + } + + if ($error == false) { + $check_customer_query = tep_db_query("select customers_password from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); + $check_customer = tep_db_fetch_array($check_customer_query); + + if (tep_validate_password($password_current, $check_customer['customers_password'])) { + tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($password_new) . "' where customers_id = '" . (int)$customer_id . "'"); + + tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customer_id . "'"); + + $messageStack->add_session('account', SUCCESS_PASSWORD_UPDATED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + } else { + $error = true; + + $messageStack->add('account_password', ERROR_CURRENT_PASSWORD_NOT_MATCHING); + } + } + } + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ACCOUNT_PASSWORD, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +size('account_password') > 0) { +?> + + + + + + + + + + + + + + + + +
+ + + + +
output('account_password'); ?>
+ + + + + + +
+ + + + +
+ + + +
+ + + + + + + + + + + + + + + +
' . ENTRY_PASSWORD_CURRENT_TEXT . '': ''); ?>
' . ENTRY_PASSWORD_NEW_TEXT . '': ''); ?>
' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '': ''); ?>
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/address_book.php b/catalog/address_book.php new file mode 100644 index 0000000..c6c58a7 --- /dev/null +++ b/catalog/address_book.php @@ -0,0 +1,190 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADDRESS_BOOK); + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +size('addressbook') > 0) { +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
output('addressbook'); ?>
+ + + +
+ + + + + +
+ + + + + + +

'); ?>
+ + + +
+ + + + + + + +
+ + + + + + + +
' . PRIMARY_ADDRESS . ''; ?>' . tep_image_button('small_edit.gif', SMALL_IMAGE_BUTTON_EDIT) . ' ' . tep_image_button('small_delete.gif', SMALL_IMAGE_BUTTON_DELETE) . ''; ?>
+ + + + + +
'); ?>
+ + + +
+ + + + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>' . tep_image_button('button_add_address.gif', IMAGE_BUTTON_ADD_ADDRESS) . ''; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/address_book_process.php b/catalog/address_book_process.php new file mode 100644 index 0000000..68d0e48 --- /dev/null +++ b/catalog/address_book_process.php @@ -0,0 +1,405 @@ +set_snapshot(); + tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); + } + +// needs to be included earlier to set the success message in the messageStack + require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADDRESS_BOOK_PROCESS); + + if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'deleteconfirm') && isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) { + tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['delete'] . "' and customers_id = '" . (int)$customer_id . "'"); + + $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } + +// error checking when updating or adding an entry + $process = false; + if (isset($HTTP_POST_VARS['action']) && (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'update'))) { + $process = true; + $error = false; + + if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']); + if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']); + $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']); + $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']); + $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']); + if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']); + $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']); + $city = tep_db_prepare_input($HTTP_POST_VARS['city']); + $country = tep_db_prepare_input($HTTP_POST_VARS['country']); + if (ACCOUNT_STATE == 'true') { + if (isset($HTTP_POST_VARS['zone_id'])) { + $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']); + } else { + $zone_id = false; + } + $state = tep_db_prepare_input($HTTP_POST_VARS['state']); + } +//Rodax Software begin + $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']); +//Rodax Software end + if (ACCOUNT_GENDER == 'true') { + if ( ($gender != 'm') && ($gender != 'f') ) { + $error = true; + + $messageStack->add('addressbook', ENTRY_GENDER_ERROR); + } + } + + if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_FIRST_NAME_ERROR); + } + + if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_LAST_NAME_ERROR); + } + + if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_STREET_ADDRESS_ERROR); + } + + if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_POST_CODE_ERROR); + } + + if (strlen($city) < ENTRY_CITY_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_CITY_ERROR); + } + + if (!is_numeric($country)) { + $error = true; + + $messageStack->add('addressbook', ENTRY_COUNTRY_ERROR); + } + + if (ACCOUNT_STATE == 'true') { + $zone_id = 0; + $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'"); + $check = tep_db_fetch_array($check_query); + $entry_state_has_zones = ($check['total'] > 0); + if ($entry_state_has_zones == true) { + $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')"); + if (tep_db_num_rows($zone_query) == 1) { + $zone = tep_db_fetch_array($zone_query); + $zone_id = $zone['zone_id']; + } else { + $error = true; + + $messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT); + } + } else { + if (strlen($state) < ENTRY_STATE_MIN_LENGTH) { + $error = true; + + $messageStack->add('addressbook', ENTRY_STATE_ERROR); + } + } + } + + if ($error == false) { + $sql_data_array = array('entry_firstname' => $firstname, + 'entry_lastname' => $lastname, + 'entry_street_address' => $street_address, + 'entry_telephone' => $telephone, //Rodax Software + 'entry_postcode' => $postcode, + 'entry_city' => $city, + 'entry_country_id' => (int)$country); + + if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender; + if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company; + if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb; + if (ACCOUNT_STATE == 'true') { + if ($zone_id > 0) { + $sql_data_array['entry_zone_id'] = (int)$zone_id; + $sql_data_array['entry_state'] = ''; + } else { + $sql_data_array['entry_zone_id'] = '0'; + $sql_data_array['entry_state'] = $state; + } + } + + if ($HTTP_POST_VARS['action'] == 'update') { + tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id ='" . (int)$customer_id . "'"); + +// reregister session variables + if ( (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) || ($HTTP_GET_VARS['edit'] == $customer_default_address_id) ) { + $customer_first_name = $firstname; + $customer_country_id = $country; + $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0'); + $customer_default_address_id = (int)$HTTP_GET_VARS['edit']; + + $sql_data_array = array('customers_firstname' => $firstname, + 'customers_lastname' => $lastname, + 'customers_default_address_id' => (int)$HTTP_GET_VARS['edit']); + + if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender; + + tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'"); + } + } else { + $sql_data_array['customers_id'] = (int)$customer_id; + tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); + + $new_address_book_id = tep_db_insert_id(); + +// reregister session variables + if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) { + $customer_first_name = $firstname; + $customer_country_id = $country; + $customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0'); + if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $customer_default_address_id = $new_address_book_id; + + $sql_data_array = array('customers_firstname' => $firstname, + 'customers_lastname' => $lastname); + + if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender; + if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $sql_data_array['customers_default_address_id'] = $new_address_book_id; + + tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'"); + } + } + + $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success'); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } + } + + if (isset($HTTP_GET_VARS['edit']) && is_numeric($HTTP_GET_VARS['edit'])) { + $entry_query = tep_db_query("select entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_zone_id, entry_country_id, entry_telephone from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "'"); + + if (!tep_db_num_rows($entry_query)) { + $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } + + $entry = tep_db_fetch_array($entry_query); + } elseif (isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) { + if ($HTTP_GET_VARS['delete'] == $customer_default_address_id) { + $messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning'); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } else { + $check_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['delete'] . "' and customers_id = '" . (int)$customer_id . "'"); + $check = tep_db_fetch_array($check_query); + + if ($check['total'] < 1) { + $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } + } + } else { + $entry = array(); + } + + if (!isset($HTTP_GET_VARS['delete']) && !isset($HTTP_GET_VARS['edit'])) { + if (tep_count_customer_address_book_entries() >= MAX_ADDRESS_BOOK_ENTRIES) { + $messageStack->add_session('addressbook', ERROR_ADDRESS_BOOK_FULL); + + tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + } + } + + $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL')); + $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL')); + + if (isset($HTTP_GET_VARS['edit']) && is_numeric($HTTP_GET_VARS['edit'])) { + $breadcrumb->add(NAVBAR_TITLE_MODIFY_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'edit=' . $HTTP_GET_VARS['edit'], 'SSL')); + } elseif (isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) { + $breadcrumb->add(NAVBAR_TITLE_DELETE_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'delete=' . $HTTP_GET_VARS['delete'], 'SSL')); + } else { + $breadcrumb->add(NAVBAR_TITLE_ADD_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, '', 'SSL')); + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +size('addressbook') > 0) { +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +snapshot) > 0) { + $back_link = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); + } else { + $back_link = tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'); + } +?> + + + + + +
+ + + + +
output('addressbook'); ?>
+ + + +
+ + + + + +
+ + + + + + +

'); ?>
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>' . tep_image_button('button_delete.gif', IMAGE_BUTTON_DELETE) . ''; ?>
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
+ + + +
+ + + + + + +
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>
'; ?>
+ + + +
+ + + + + +
+ + + diff --git a/catalog/admin/.htaccess b/catalog/admin/.htaccess new file mode 100644 index 0000000..d0feb4a --- /dev/null +++ b/catalog/admin/.htaccess @@ -0,0 +1,40 @@ +# $Id: .htaccess,v 1.1 2003/06/20 00:18:30 hpdl Exp $ +# +# This is used with Apache WebServers +# +# For this to work, you must include the parameter 'Options' to +# the AllowOverride configuration +# +# Example: +# +# +# AllowOverride Options +# +# +# 'All' with also work. (This configuration is in the +# apache/conf/httpd.conf file) + +# The following makes adjustments to the SSL protocol for Internet +# Explorer browsers + + + + SetEnvIf User-Agent ".*MSIE.*" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + + + +# If Search Engine Friendly URLs do not work, try enabling the +# following Apache configuration parameter +# +# AcceptPathInfo On + +# Fix certain PHP values +# (commented out by default to prevent errors occuring on certain +# servers) +# +# +# php_value session.use_trans_sid 0 +# php_value register_globals 1 +# diff --git a/catalog/admin/SearchSuggest.php b/catalog/admin/SearchSuggest.php new file mode 100644 index 0000000..7543719 --- /dev/null +++ b/catalog/admin/SearchSuggest.php @@ -0,0 +1,37 @@ + + + + + + +
 ' . $product_array['products_quantity'] . ''; + echo ' ' . $product_array['products_name'] . '' . "\n"; + ?>
\ No newline at end of file diff --git a/catalog/admin/backup.php b/catalog/admin/backup.php new file mode 100644 index 0000000..4d91af1 --- /dev/null +++ b/catalog/admin/backup.php @@ -0,0 +1,494 @@ +add_session(SUCCESS_LAST_RESTORE_CLEARED, 'success'); + + tep_redirect(tep_href_link(FILENAME_BACKUP)); + break; + case 'backupnow': + tep_set_time_limit(0); + $backup_file = 'db_' . DB_DATABASE . '-' . date('YmdHis') . '.sql'; + $fp = fopen(DIR_FS_BACKUP . $backup_file, 'w'); + + $schema = '# osCommerce, Open Source E-Commerce Solutions' . "\n" . + '# http://www.oscommerce.com' . "\n" . + '#' . "\n" . + '# Database Backup For ' . STORE_NAME . "\n" . + '# Copyright (c) ' . date('Y') . ' ' . STORE_OWNER . "\n" . + '#' . "\n" . + '# Database: ' . DB_DATABASE . "\n" . + '# Database Server: ' . DB_SERVER . "\n" . + '#' . "\n" . + '# Backup Date: ' . date(PHP_DATE_TIME_FORMAT) . "\n\n"; + fputs($fp, $schema); + + $tables_query = tep_db_query('show tables'); + while ($tables = tep_db_fetch_array($tables_query)) { + list(,$table) = each($tables); + + $schema = 'drop table if exists ' . $table . ';' . "\n" . + 'create table ' . $table . ' (' . "\n"; + + $table_list = array(); + $fields_query = tep_db_query("show fields from " . $table); + while ($fields = tep_db_fetch_array($fields_query)) { + $table_list[] = $fields['Field']; + + $schema .= ' ' . $fields['Field'] . ' ' . $fields['Type']; + + if (strlen($fields['Default']) > 0) $schema .= ' default \'' . $fields['Default'] . '\''; + + if ($fields['Null'] != 'YES') $schema .= ' not null'; + + if (isset($fields['Extra'])) $schema .= ' ' . $fields['Extra']; + + $schema .= ',' . "\n"; + } + + $schema = ereg_replace(",\n$", '', $schema); + +// add the keys + $index = array(); + $keys_query = tep_db_query("show keys from " . $table); + while ($keys = tep_db_fetch_array($keys_query)) { + $kname = $keys['Key_name']; + + if (!isset($index[$kname])) { + $index[$kname] = array('unique' => !$keys['Non_unique'], + 'columns' => array()); + } + + $index[$kname]['columns'][] = $keys['Column_name']; + } + + while (list($kname, $info) = each($index)) { + $schema .= ',' . "\n"; + + $columns = implode($info['columns'], ', '); + + if ($kname == 'PRIMARY') { + $schema .= ' PRIMARY KEY (' . $columns . ')'; + } elseif ($info['unique']) { + $schema .= ' UNIQUE ' . $kname . ' (' . $columns . ')'; + } else { + $schema .= ' KEY ' . $kname . ' (' . $columns . ')'; + } + } + + $schema .= "\n" . ');' . "\n\n"; + fputs($fp, $schema); + +// dump the data + $rows_query = tep_db_query("select " . implode(',', $table_list) . " from " . $table); + while ($rows = tep_db_fetch_array($rows_query)) { + $schema = 'insert into ' . $table . ' (' . implode(', ', $table_list) . ') values ('; + + reset($table_list); + while (list(,$i) = each($table_list)) { + if (!isset($rows[$i])) { + $schema .= 'NULL, '; + } elseif (tep_not_null($rows[$i])) { + $row = addslashes($rows[$i]); + $row = ereg_replace("\n#", "\n".'\#', $row); + + $schema .= '\'' . $row . '\', '; + } else { + $schema .= '\'\', '; + } + } + + $schema = ereg_replace(', $', '', $schema) . ');' . "\n"; + fputs($fp, $schema); + + } + } + + fclose($fp); + + if (isset($HTTP_POST_VARS['download']) && ($HTTP_POST_VARS['download'] == 'yes')) { + switch ($HTTP_POST_VARS['compress']) { + case 'gzip': + exec(LOCAL_EXE_GZIP . ' ' . DIR_FS_BACKUP . $backup_file); + $backup_file .= '.gz'; + break; + case 'zip': + exec(LOCAL_EXE_ZIP . ' -j ' . DIR_FS_BACKUP . $backup_file . '.zip ' . DIR_FS_BACKUP . $backup_file); + unlink(DIR_FS_BACKUP . $backup_file); + $backup_file .= '.zip'; + } + header('Content-type: application/x-octet-stream'); + header('Content-disposition: attachment; filename=' . $backup_file); + + readfile(DIR_FS_BACKUP . $backup_file); + unlink(DIR_FS_BACKUP . $backup_file); + + exit; + } else { + switch ($HTTP_POST_VARS['compress']) { + case 'gzip': + exec(LOCAL_EXE_GZIP . ' ' . DIR_FS_BACKUP . $backup_file); + break; + case 'zip': + exec(LOCAL_EXE_ZIP . ' -j ' . DIR_FS_BACKUP . $backup_file . '.zip ' . DIR_FS_BACKUP . $backup_file); + unlink(DIR_FS_BACKUP . $backup_file); + } + + $messageStack->add_session(SUCCESS_DATABASE_SAVED, 'success'); + } + + tep_redirect(tep_href_link(FILENAME_BACKUP)); + break; + case 'restorenow': + case 'restorelocalnow': + tep_set_time_limit(0); + + if ($action == 'restorenow') { + $read_from = $HTTP_GET_VARS['file']; + + if (file_exists(DIR_FS_BACKUP . $HTTP_GET_VARS['file'])) { + $restore_file = DIR_FS_BACKUP . $HTTP_GET_VARS['file']; + $extension = substr($HTTP_GET_VARS['file'], -3); + + if ( ($extension == 'sql') || ($extension == '.gz') || ($extension == 'zip') ) { + switch ($extension) { + case 'sql': + $restore_from = $restore_file; + $remove_raw = false; + break; + case '.gz': + $restore_from = substr($restore_file, 0, -3); + exec(LOCAL_EXE_GUNZIP . ' ' . $restore_file . ' -c > ' . $restore_from); + $remove_raw = true; + break; + case 'zip': + $restore_from = substr($restore_file, 0, -4); + exec(LOCAL_EXE_UNZIP . ' ' . $restore_file . ' -d ' . DIR_FS_BACKUP); + $remove_raw = true; + } + + if (isset($restore_from) && file_exists($restore_from) && (filesize($restore_from) > 15000)) { + $fd = fopen($restore_from, 'rb'); + $restore_query = fread($fd, filesize($restore_from)); + fclose($fd); + } + } + } + } elseif ($action == 'restorelocalnow') { + $sql_file = new upload('sql_file'); + + if ($sql_file->parse() == true) { + $restore_query = fread(fopen($sql_file->tmp_filename, 'r'), filesize($sql_file->tmp_filename)); + $read_from = $sql_file->filename; + } + } + + if (isset($restore_query)) { + $sql_array = array(); + $sql_length = strlen($restore_query); + $pos = strpos($restore_query, ';'); + for ($i=$pos; $i<$sql_length; $i++) { + if ($restore_query[0] == '#') { + $restore_query = ltrim(substr($restore_query, strpos($restore_query, "\n"))); + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + continue; + } + if ($restore_query[($i+1)] == "\n") { + for ($j=($i+2); $j<$sql_length; $j++) { + if (trim($restore_query[$j]) != '') { + $next = substr($restore_query, $j, 6); + if ($next[0] == '#') { +// find out where the break position is so we can remove this line (#comment line) + for ($k=$j; $k<$sql_length; $k++) { + if ($restore_query[$k] == "\n") break; + } + $query = substr($restore_query, 0, $i+1); + $restore_query = substr($restore_query, $k); +// join the query before the comment appeared, with the rest of the dump + $restore_query = $query . $restore_query; + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + continue 2; + } + break; + } + } + if ($next == '') { // get the last insert query + $next = 'insert'; + } + if ( (eregi('create', $next)) || (eregi('insert', $next)) || (eregi('drop t', $next)) ) { + $next = ''; + $sql_array[] = substr($restore_query, 0, $i); + $restore_query = ltrim(substr($restore_query, $i+1)); + $sql_length = strlen($restore_query); + $i = strpos($restore_query, ';')-1; + } + } + } + + tep_db_query("drop table if exists address_book, address_format, banners, banners_history, categories, categories_description, configuration, configuration_group, counter, counter_history, countries, currencies, customers, customers_basket, customers_basket_attributes, customers_info, languages, manufacturers, manufacturers_info, orders, orders_products, orders_status, orders_status_history, orders_products_attributes, orders_products_download, products, products_attributes, products_attributes_download, prodcts_description, products_options, products_options_values, products_options_values_to_products_options, products_to_categories, reviews, reviews_description, sessions, specials, tax_class, tax_rates, geo_zones, whos_online, zones, zones_to_geo_zones"); + + for ($i=0, $n=sizeof($sql_array); $i<$n; $i++) { + tep_db_query($sql_array[$i]); + } + + tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'DB_LAST_RESTORE'"); + tep_db_query("insert into " . TABLE_CONFIGURATION . " values ('', 'Last Database Restore', 'DB_LAST_RESTORE', '" . $read_from . "', 'Last database restore file', '6', '', '', now(), '', '')"); + + if (isset($remove_raw) && ($remove_raw == true)) { + unlink($restore_from); + } + + $messageStack->add_session(SUCCESS_DATABASE_RESTORED, 'success'); + } + + tep_redirect(tep_href_link(FILENAME_BACKUP)); + break; + case 'download': + $extension = substr($HTTP_GET_VARS['file'], -3); + + if ( ($extension == 'zip') || ($extension == '.gz') || ($extension == 'sql') ) { + if ($fp = fopen(DIR_FS_BACKUP . $HTTP_GET_VARS['file'], 'rb')) { + $buffer = fread($fp, filesize(DIR_FS_BACKUP . $HTTP_GET_VARS['file'])); + fclose($fp); + + header('Content-type: application/x-octet-stream'); + header('Content-disposition: attachment; filename=' . $HTTP_GET_VARS['file']); + + echo $buffer; + + exit; + } + } else { + $messageStack->add(ERROR_DOWNLOAD_LINK_NOT_ACCEPTABLE, 'error'); + } + break; + case 'deleteconfirm': + if (strstr($HTTP_GET_VARS['file'], '..')) tep_redirect(tep_href_link(FILENAME_BACKUP)); + + tep_remove(DIR_FS_BACKUP . '/' . $HTTP_GET_VARS['file']); + + if (!$tep_remove_error) { + $messageStack->add_session(SUCCESS_BACKUP_DELETED, 'success'); + + tep_redirect(tep_href_link(FILENAME_BACKUP)); + } + break; + } + } + +// check if the backup directory exists + $dir_ok = false; + if (is_dir(DIR_FS_BACKUP)) { + if (is_writeable(DIR_FS_BACKUP)) { + $dir_ok = true; + } else { + $messageStack->add(ERROR_BACKUP_DIRECTORY_NOT_WRITEABLE, 'error'); + } + } else { + $messageStack->add(ERROR_BACKUP_DIRECTORY_DOES_NOT_EXIST, 'error'); + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
+ + + '' . TEXT_INFO_HEADING_NEW_BACKUP . ''); + + $contents = array('form' => tep_draw_form('backup', FILENAME_BACKUP, 'action=backupnow')); + $contents[] = array('text' => TEXT_INFO_NEW_BACKUP); + + $contents[] = array('text' => '
' . tep_draw_radio_field('compress', 'no', true) . ' ' . TEXT_INFO_USE_NO_COMPRESSION); + if (file_exists(LOCAL_EXE_GZIP)) $contents[] = array('text' => '
' . tep_draw_radio_field('compress', 'gzip') . ' ' . TEXT_INFO_USE_GZIP); + if (file_exists(LOCAL_EXE_ZIP)) $contents[] = array('text' => tep_draw_radio_field('compress', 'zip') . ' ' . TEXT_INFO_USE_ZIP); + + if ($dir_ok == true) { + $contents[] = array('text' => '
' . tep_draw_checkbox_field('download', 'yes') . ' ' . TEXT_INFO_DOWNLOAD_ONLY . '*

*' . TEXT_INFO_BEST_THROUGH_HTTPS); + } else { + $contents[] = array('text' => '
' . tep_draw_radio_field('download', 'yes', true) . ' ' . TEXT_INFO_DOWNLOAD_ONLY . '*

*' . TEXT_INFO_BEST_THROUGH_HTTPS); + } + + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_backup.gif', IMAGE_BACKUP) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'restore': + $heading[] = array('text' => '' . $buInfo->date . ''); + + $contents[] = array('text' => tep_break_string(sprintf(TEXT_INFO_RESTORE, DIR_FS_BACKUP . (($buInfo->compression != TEXT_NO_EXTENSION) ? substr($buInfo->file, 0, strrpos($buInfo->file, '.')) : $buInfo->file), ($buInfo->compression != TEXT_NO_EXTENSION) ? TEXT_INFO_UNPACK : ''), 35, ' ')); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'restorelocal': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_RESTORE_LOCAL . ''); + + $contents = array('form' => tep_draw_form('restore', FILENAME_BACKUP, 'action=restorelocalnow', 'post', 'enctype="multipart/form-data"')); + $contents[] = array('text' => TEXT_INFO_RESTORE_LOCAL . '

' . TEXT_INFO_BEST_THROUGH_HTTPS); + $contents[] = array('text' => '
' . tep_draw_file_field('sql_file')); + $contents[] = array('text' => TEXT_INFO_RESTORE_LOCAL_RAW_FILE); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_restore.gif', IMAGE_RESTORE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete': + $heading[] = array('text' => '' . $buInfo->date . ''); + + $contents = array('form' => tep_draw_form('delete', FILENAME_BACKUP, 'file=' . $buInfo->file . '&action=deleteconfirm')); + $contents[] = array('text' => TEXT_DELETE_INTRO); + $contents[] = array('text' => '
' . $buInfo->file . ''); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($buInfo) && is_object($buInfo)) { + $heading[] = array('text' => '' . $buInfo->date . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); + $contents[] = array('text' => '
' . TEXT_INFO_DATE . ' ' . $buInfo->date); + $contents[] = array('text' => TEXT_INFO_SIZE . ' ' . $buInfo->size); + $contents[] = array('text' => '
' . TEXT_INFO_COMPRESSION . ' ' . $buInfo->compression); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + +read()) { + if (!is_dir(DIR_FS_BACKUP . $file)) { + $contents[] = $file; + } + } + sort($contents); + + for ($i=0, $n=sizeof($contents); $i<$n; $i++) { + $entry = $contents[$i]; + + $check = 0; + + if ((!isset($HTTP_GET_VARS['file']) || (isset($HTTP_GET_VARS['file']) && ($HTTP_GET_VARS['file'] == $entry))) && !isset($buInfo) && ($action != 'backup') && ($action != 'restorelocal')) { + $file_array['file'] = $entry; + $file_array['date'] = date(PHP_DATE_TIME_FORMAT, filemtime(DIR_FS_BACKUP . $entry)); + $file_array['size'] = number_format(filesize(DIR_FS_BACKUP . $entry)) . ' bytes'; + switch (substr($entry, -3)) { + case 'zip': $file_array['compression'] = 'ZIP'; break; + case '.gz': $file_array['compression'] = 'GZIP'; break; + default: $file_array['compression'] = TEXT_NO_EXTENSION; break; + } + + $buInfo = new objectInfo($file_array); + } + + if (isset($buInfo) && is_object($buInfo) && ($entry == $buInfo->file)) { + echo ' ' . "\n"; + $onclick_link = 'file=' . $buInfo->file . '&action=restore'; + } else { + echo ' ' . "\n"; + $onclick_link = 'file=' . $entry; + } +?> + + + + + +close(); + } +?> + + + + + + + + + +
 
' . tep_image(DIR_WS_ICONS . 'file_download.gif', ICON_FILE_DOWNLOAD) . ' ' . $entry; ?> bytesfile)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
' . tep_image_button('button_backup.gif', IMAGE_BACKUP) . ''; if ( ($action != 'restorelocal') && isset($dir) ) echo '  ' . tep_image_button('button_restore.gif', IMAGE_RESTORE) . ''; ?>
' . TEXT_FORGET . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/banner_manager.php b/catalog/admin/banner_manager.php new file mode 100644 index 0000000..345618b --- /dev/null +++ b/catalog/admin/banner_manager.php @@ -0,0 +1,466 @@ +add_session(SUCCESS_BANNER_STATUS_UPDATED, 'success'); + } else { + $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error'); + } + + tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['page'] . '&bID=' . $HTTP_GET_VARS['bID'])); + break; + case 'insert': + case 'update': + if (isset($HTTP_POST_VARS['banners_id'])) $banners_id = tep_db_prepare_input($HTTP_POST_VARS['banners_id']); + $banners_title = tep_db_prepare_input($HTTP_POST_VARS['banners_title']); + $banners_url = tep_db_prepare_input($HTTP_POST_VARS['banners_url']); + $new_banners_group = tep_db_prepare_input($HTTP_POST_VARS['new_banners_group']); + $banners_group = (empty($new_banners_group)) ? tep_db_prepare_input($HTTP_POST_VARS['banners_group']) : $new_banners_group; + $banners_html_text = tep_db_prepare_input($HTTP_POST_VARS['banners_html_text']); + $banners_image_local = tep_db_prepare_input($HTTP_POST_VARS['banners_image_local']); + $banners_image_target = tep_db_prepare_input($HTTP_POST_VARS['banners_image_target']); + $db_image_location = ''; + $expires_date = tep_db_prepare_input($HTTP_POST_VARS['expires_date']); + $expires_impressions = tep_db_prepare_input($HTTP_POST_VARS['expires_impressions']); + $date_scheduled = tep_db_prepare_input($HTTP_POST_VARS['date_scheduled']); + + $banner_error = false; + if (empty($banners_title)) { + $messageStack->add(ERROR_BANNER_TITLE_REQUIRED, 'error'); + $banner_error = true; + } + + if (empty($banners_group)) { + $messageStack->add(ERROR_BANNER_GROUP_REQUIRED, 'error'); + $banner_error = true; + } + + if (empty($banners_html_text)) { + if (empty($banners_image_local)) { + $banners_image = new upload('banners_image'); + $banners_image->set_destination(DIR_FS_CATALOG_IMAGES . $banners_image_target); + if ( ($banners_image->parse() == false) || ($banners_image->save() == false) ) { + $banner_error = true; + } + } + } + + if ($banner_error == false) { + $db_image_location = (tep_not_null($banners_image_local)) ? $banners_image_local : $banners_image_target . $banners_image->filename; + $sql_data_array = array('banners_title' => $banners_title, + 'banners_url' => $banners_url, + 'banners_image' => $db_image_location, + 'banners_group' => $banners_group, + 'banners_html_text' => $banners_html_text); + + if ($action == 'insert') { + $insert_sql_data = array('date_added' => 'now()', + 'status' => '1'); + + $sql_data_array = array_merge($sql_data_array, $insert_sql_data); + + tep_db_perform(TABLE_BANNERS, $sql_data_array); + + $banners_id = tep_db_insert_id(); + + $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success'); + } elseif ($action == 'update') { + tep_db_perform(TABLE_BANNERS, $sql_data_array, 'update', "banners_id = '" . (int)$banners_id . "'"); + + $messageStack->add_session(SUCCESS_BANNER_UPDATED, 'success'); + } + + if (tep_not_null($expires_date)) { + list($day, $month, $year) = explode('/', $expires_date); + + $expires_date = $year . + ((strlen($month) == 1) ? '0' . $month : $month) . + ((strlen($day) == 1) ? '0' . $day : $day); + + tep_db_query("update " . TABLE_BANNERS . " set expires_date = '" . tep_db_input($expires_date) . "', expires_impressions = null where banners_id = '" . (int)$banners_id . "'"); + } elseif (tep_not_null($expires_impressions)) { + tep_db_query("update " . TABLE_BANNERS . " set expires_impressions = '" . tep_db_input($expires_impressions) . "', expires_date = null where banners_id = '" . (int)$banners_id . "'"); + } + + if (tep_not_null($date_scheduled)) { + list($day, $month, $year) = explode('/', $date_scheduled); + + $date_scheduled = $year . + ((strlen($month) == 1) ? '0' . $month : $month) . + ((strlen($day) == 1) ? '0' . $day : $day); + + tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_scheduled = '" . tep_db_input($date_scheduled) . "' where banners_id = '" . (int)$banners_id . "'"); + } + + tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'bID=' . $banners_id)); + } else { + $action = 'new'; + } + break; + case 'deleteconfirm': + $banners_id = tep_db_prepare_input($HTTP_GET_VARS['bID']); + + if (isset($HTTP_POST_VARS['delete_image']) && ($HTTP_POST_VARS['delete_image'] == 'on')) { + $banner_query = tep_db_query("select banners_image from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); + $banner = tep_db_fetch_array($banner_query); + + if (is_file(DIR_FS_CATALOG_IMAGES . $banner['banners_image'])) { + if (is_writeable(DIR_FS_CATALOG_IMAGES . $banner['banners_image'])) { + unlink(DIR_FS_CATALOG_IMAGES . $banner['banners_image']); + } else { + $messageStack->add_session(ERROR_IMAGE_IS_NOT_WRITEABLE, 'error'); + } + } else { + $messageStack->add_session(ERROR_IMAGE_DOES_NOT_EXIST, 'error'); + } + } + + tep_db_query("delete from " . TABLE_BANNERS . " where banners_id = '" . (int)$banners_id . "'"); + tep_db_query("delete from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$banners_id . "'"); + + if (function_exists('imagecreate') && tep_not_null($banner_extensio)) { + if (is_file(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { + if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension)) { + unlink(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banners_id . '.' . $banner_extension); + } + } + + if (is_file(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension)) { + if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension)) { + unlink(DIR_WS_IMAGES . 'graphs/banner_yearly-' . $banners_id . '.' . $banner_extension); + } + } + + if (is_file(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension)) { + if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension)) { + unlink(DIR_WS_IMAGES . 'graphs/banner_monthly-' . $banners_id . '.' . $banner_extension); + } + } + + if (is_file(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension)) { + if (is_writeable(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension)) { + unlink(DIR_WS_IMAGES . 'graphs/banner_daily-' . $banners_id . '.' . $banner_extension); + } + } + } + + $messageStack->add_session(SUCCESS_BANNER_REMOVED, 'success'); + + tep_redirect(tep_href_link(FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['page'])); + break; + } + } + +// check if the graphs directory exists + $dir_ok = false; + if (function_exists('imagecreate') && tep_not_null($banner_extension)) { + if (is_dir(DIR_WS_IMAGES . 'graphs')) { + if (is_writeable(DIR_WS_IMAGES . 'graphs')) { + $dir_ok = true; + } else { + $messageStack->add(ERROR_GRAPHS_DIRECTORY_NOT_WRITEABLE, 'error'); + } + } else { + $messageStack->add(ERROR_GRAPHS_DIRECTORY_DOES_NOT_EXIST, 'error'); + } + } +?> + +> + + +<?php echo TITLE; ?> + + + + + +
+ + + + + + + + + + + + +
+ + + +
+ + + + '', + 'date_scheduled' => '', + 'banners_title' => '', + 'banners_url' => '', + 'banners_group' => '', + 'banners_image' => '', + 'banners_html_text' => '', + 'expires_impressions' => ''); + + $bInfo = new objectInfo($parameters); + + if (isset($HTTP_GET_VARS['bID'])) { + $form_action = 'update'; + + $bID = tep_db_prepare_input($HTTP_GET_VARS['bID']); + + $banner_query = tep_db_query("select banners_title, banners_url, banners_image, banners_group, banners_html_text, status, date_format(date_scheduled, '%d/%m/%Y') as date_scheduled, date_format(expires_date, '%d/%m/%Y') as expires_date, expires_impressions, date_status_change from " . TABLE_BANNERS . " where banners_id = '" . (int)$bID . "'"); + $banner = tep_db_fetch_array($banner_query); + + $bInfo->objectInfo($banner); + } elseif (tep_not_null($HTTP_POST_VARS)) { + $bInfo->objectInfo($HTTP_POST_VARS); + } + + $groups_array = array(); + $groups_query = tep_db_query("select distinct banners_group from " . TABLE_BANNERS . " order by banners_group"); + while ($groups = tep_db_fetch_array($groups_query)) { + $groups_array[] = array('id' => $groups['banners_group'], 'text' => $groups['banners_group']); + } +?> + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
banners_title, '', true); ?>
banners_url); ?>
banners_group) . TEXT_BANNERS_NEW_GROUP . '
' . tep_draw_input_field('new_banners_group', '', '', ((sizeof($groups_array) > 0) ? false : true)); ?>
' . DIR_FS_CATALOG_IMAGES . tep_draw_input_field('banners_image_local', (isset($bInfo->banners_image) ? $bInfo->banners_image : '')); ?>
banners_html_text); ?>

(dd/mm/yyyy)

(dd/mm/yyyy)
' . tep_draw_input_field('expires_impressions', $bInfo->expires_impressions, 'maxlength="7" size="7"') . ' ' . TEXT_BANNERS_IMPRESSIONS; ?>
+ + + + +
' . TEXT_BANNERS_INSERT_NOTE . '
' . TEXT_BANNERS_EXPIRCY_NOTE . '
' . TEXT_BANNERS_SCHEDULE_NOTE; ?>
' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+ + + '' . $bInfo->banners_title . ''); + + $contents = array('form' => tep_draw_form('banners', FILENAME_BANNER_MANAGER, 'page=' . $HTTP_GET_VARS['page'] . '&bID=' . $bInfo->banners_id . '&action=deleteconfirm')); + $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); + $contents[] = array('text' => '
' . $bInfo->banners_title . ''); + if ($bInfo->banners_image) $contents[] = array('text' => '
' . tep_draw_checkbox_field('delete_image', 'on', true) . ' ' . TEXT_INFO_DELETE_IMAGE); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (is_object($bInfo)) { + $heading[] = array('text' => '' . $bInfo->banners_title . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); + $contents[] = array('text' => '
' . TEXT_BANNERS_DATE_ADDED . ' ' . tep_date_short($bInfo->date_added)); + + if ( (function_exists('imagecreate')) && ($dir_ok) && ($banner_extension) ) { + $banner_id = $bInfo->banners_id; + $days = '3'; + include(DIR_WS_INCLUDES . 'graphs/banner_infobox.php'); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image(DIR_WS_IMAGES . 'graphs/banner_infobox-' . $banner_id . '.' . $banner_extension)); + } else { + include(DIR_WS_FUNCTIONS . 'html_graphs.php'); + $contents[] = array('align' => 'center', 'text' => '
' . tep_banner_graph_infoBox($bInfo->banners_id, '3')); + } + + $contents[] = array('text' => tep_image(DIR_WS_IMAGES . 'graph_hbar_blue.gif', 'Blue', '5', '5') . ' ' . TEXT_BANNERS_BANNER_VIEWS . '
' . tep_image(DIR_WS_IMAGES . 'graph_hbar_red.gif', 'Red', '5', '5') . ' ' . TEXT_BANNERS_BANNER_CLICKS); + + if ($bInfo->date_scheduled) $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_SCHEDULED_AT_DATE, tep_date_short($bInfo->date_scheduled))); + + if ($bInfo->expires_date) { + $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_EXPIRES_AT_DATE, tep_date_short($bInfo->expires_date))); + } elseif ($bInfo->expires_impressions) { + $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_EXPIRES_AT_IMPRESSIONS, $bInfo->expires_impressions)); + } + + if ($bInfo->date_status_change) $contents[] = array('text' => '
' . sprintf(TEXT_BANNERS_STATUS_CHANGE, tep_date_short($bInfo->date_status_change))); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + + +banners_id)) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + + + +
 
' . tep_image(DIR_WS_IMAGES . 'icon_popup.gif', 'View Banner') . ' ' . $banners['banners_title']; ?> +' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', 'Set Inactive', 10, 10) . ''; + } else { + echo '' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', 'Set Active', 10, 10) . '  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', 'Inactive', 10, 10); + } +?>' . tep_image(DIR_WS_ICONS . 'statistics.gif', ICON_STATISTICS) . ' '; if (isset($bInfo) && is_object($bInfo) && ($banners['banners_id'] == $bInfo->banners_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + + + + +
display_count($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_BANNERS); ?>display_links($banners_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
' . tep_image_button('button_new_banner.gif', IMAGE_NEW_BANNER) . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/banner_statistics.php b/catalog/admin/banner_statistics.php new file mode 100644 index 0000000..cb82a9e --- /dev/null +++ b/catalog/admin/banner_statistics.php @@ -0,0 +1,179 @@ +add(ERROR_GRAPHS_DIRECTORY_NOT_WRITEABLE, 'error'); + } + } else { + $messageStack->add(ERROR_GRAPHS_DIRECTORY_DOES_NOT_EXIST, 'error'); + } + } + + $banner_query = tep_db_query("select banners_title from " . TABLE_BANNERS . " where banners_id = '" . (int)$HTTP_GET_VARS['bID'] . "'"); + $banner = tep_db_fetch_array($banner_query); + + $years_array = array(); + $years_query = tep_db_query("select distinct year(banners_history_date) as banner_year from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . (int)$HTTP_GET_VARS['bID'] . "'"); + while ($years = tep_db_fetch_array($years_query)) { + $years_array[] = array('id' => $years['banner_year'], + 'text' => $years['banner_year']); + } + + $months_array = array(); + for ($i=1; $i<13; $i++) { + $months_array[] = array('id' => $i, + 'text' => strftime('%B', mktime(0,0,0,$i))); + } + + $type_array = array(array('id' => 'daily', + 'text' => STATISTICS_TYPE_DAILY), + array('id' => 'monthly', + 'text' => STATISTICS_TYPE_MONTHLY), + array('id' => 'yearly', + 'text' => STATISTICS_TYPE_YEARLY)); +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + +
+ + + + + +

+'; + break; + default: + case 'daily': + echo TITLE_MONTH . ' ' . tep_draw_pull_down_menu('month', $months_array, (isset($HTTP_GET_VARS['month']) ? $HTTP_GET_VARS['month'] : date('n')), 'onChange="this.form.submit();"') . '
' . TITLE_YEAR . ' ' . tep_draw_pull_down_menu('year', $years_array, (isset($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y')), 'onChange="this.form.submit();"') . ''; + break; + } +?> +
+ + + + + + + +' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . $stats[$i][0] . '' . number_format($stats[$i][1]) . '' . number_format($stats[$i][2]) . '
+ +
' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+ + + + + +
+ + + diff --git a/catalog/admin/cache.php b/catalog/admin/cache.php new file mode 100644 index 0000000..cbfe64c --- /dev/null +++ b/catalog/admin/cache.php @@ -0,0 +1,131 @@ +add(ERROR_CACHE_DIRECTORY_NOT_WRITEABLE, 'error'); + } else { + $messageStack->add(ERROR_CACHE_DIRECTORY_DOES_NOT_EXIST, 'error'); + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
+ + + +
+ + + + + +size < 1) { + $languages = tep_get_languages(); + + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + if ($languages[$i]['code'] == DEFAULT_LANGUAGE) { + $language = $languages[$i]['directory']; + } + } + + for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) { + $cached_file = ereg_replace('-language', '-' . $language, $cache_blocks[$i]['file']); + + if (file_exists(DIR_FS_CACHE . $cached_file)) { + $cache_mtime = strftime(DATE_TIME_FORMAT, filemtime(DIR_FS_CACHE . $cached_file)); + } else { + $cache_mtime = TEXT_FILE_DOES_NOT_EXIST; + $dir = dir(DIR_FS_CACHE); + + while ($cache_file = $dir->read()) { + $cached_file = ereg_replace('-language', '-' . $language, $cache_blocks[$i]['file']); + + if (ereg('^' . $cached_file, $cache_file)) { + $cache_mtime = strftime(DATE_TIME_FORMAT, filemtime(DIR_FS_CACHE . $cache_file)); + break; + } + } + + $dir->close(); + } +?> + + + + + + + + + +
 
' . tep_image(DIR_WS_IMAGES . 'icon_reset.gif', 'Reset', 13, 13) . ''; ?> 
+ + + + + +
+ + + diff --git a/catalog/admin/categories.php b/catalog/admin/categories.php new file mode 100644 index 0000000..95a394e --- /dev/null +++ b/catalog/admin/categories.php @@ -0,0 +1,1025 @@ + $sort_order); + + if ($action == 'insert_category') { + $insert_sql_data = array('parent_id' => $current_category_id, + 'date_added' => 'now()'); + + $sql_data_array = array_merge($sql_data_array, $insert_sql_data); + + tep_db_perform(TABLE_CATEGORIES, $sql_data_array); + + $categories_id = tep_db_insert_id(); + } elseif ($action == 'update_category') { + $update_sql_data = array('last_modified' => 'now()'); + + $sql_data_array = array_merge($sql_data_array, $update_sql_data); + + tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'"); + } + + $languages = tep_get_languages(); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $categories_name_array = $HTTP_POST_VARS['categories_name']; + + $language_id = $languages[$i]['id']; + + $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id])); + + if ($action == 'insert_category') { + $insert_sql_data = array('categories_id' => $categories_id, + 'language_id' => $languages[$i]['id']); + + $sql_data_array = array_merge($sql_data_array, $insert_sql_data); + + tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array); + } elseif ($action == 'update_category') { + tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); + } + } + + if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) { + tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'"); + } + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); + break; + case 'delete_category_confirm': + if (isset($HTTP_POST_VARS['categories_id'])) { + $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); + + $categories = tep_get_category_tree($categories_id, '', '0', '', true); + $products = array(); + $products_delete = array(); + + for ($i=0, $n=sizeof($categories); $i<$n; $i++) { + $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'"); + + while ($product_ids = tep_db_fetch_array($product_ids_query)) { + $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id']; + } + } + + reset($products); + while (list($key, $value) = each($products)) { + $category_ids = ''; + + for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) { + $category_ids .= "'" . (int)$value['categories'][$i] . "', "; + } + $category_ids = substr($category_ids, 0, -2); + + $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")"); + $check = tep_db_fetch_array($check_query); + if ($check['total'] < '1') { + $products_delete[$key] = $key; + } + } + +// removing categories can be a lengthy process + tep_set_time_limit(0); + for ($i=0, $n=sizeof($categories); $i<$n; $i++) { + tep_remove_category($categories[$i]['id']); + } + + reset($products_delete); + while (list($key) = each($products_delete)) { + tep_remove_product($key); + } + } + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); + break; + case 'delete_product_confirm': + if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) { + $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); + $product_categories = $HTTP_POST_VARS['product_categories']; + + for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) { + tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'"); + } + + $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); + $product_categories = tep_db_fetch_array($product_categories_query); + + if ($product_categories['total'] == '0') { + tep_remove_product($product_id); + } + } + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath)); + break; + case 'move_category_confirm': + if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) { + $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); + $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); + + $path = explode('_', tep_get_generated_category_path_ids($new_parent_id)); + + if (in_array($categories_id, $path)) { + $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error'); + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id)); + } else { + tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'"); + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id)); + } + } + + break; + case 'move_product_confirm': + $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); + $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']); + + $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'"); + $duplicate_check = tep_db_fetch_array($duplicate_check_query); + if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'"); + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id)); + break; + case 'insert_product': + case 'update_product': + if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) { + $action = 'new_product'; + } else { + if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']); + $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']); + + $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null'; + + $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']), + 'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']), + 'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']), + 'products_date_available' => $products_date_available, + 'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']), + 'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']), + 'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']), + 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id'])); + + if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) { + $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']); + } + + if ($action == 'insert_product') { + $insert_sql_data = array('products_date_added' => 'now()'); + + $sql_data_array = array_merge($sql_data_array, $insert_sql_data); + + tep_db_perform(TABLE_PRODUCTS, $sql_data_array); + $products_id = tep_db_insert_id(); + + tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')"); + } elseif ($action == 'update_product') { + $update_sql_data = array('products_last_modified' => 'now()'); + + $sql_data_array = array_merge($sql_data_array, $update_sql_data); + + tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'"); + } + + $languages = tep_get_languages(); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $language_id = $languages[$i]['id']; + + $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]), + 'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]), + 'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id])); + + if ($action == 'insert_product') { + $insert_sql_data = array('products_id' => $products_id, + 'language_id' => $language_id); + + $sql_data_array = array_merge($sql_data_array, $insert_sql_data); + + tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array); + } elseif ($action == 'update_product') { + tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'"); + } + } + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id)); + } + break; + case 'copy_to_confirm': + if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) { + $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); + $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']); + + if ($HTTP_POST_VARS['copy_as'] == 'link') { + if ($categories_id != $current_category_id) { + $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'"); + $check = tep_db_fetch_array($check_query); + if ($check['total'] < '1') { + tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')"); + } + } else { + $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error'); + } + } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { + $product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); + $product = tep_db_fetch_array($product_query); + + tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')"); + $dup_products_id = tep_db_insert_id(); + + $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); + while ($description = tep_db_fetch_array($description_query)) { + tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); + } + + tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); + $products_id = $dup_products_id; + } + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + } + + tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id)); + break; + case 'new_product_preview': +// copy image only if modified + $products_image = new upload('products_image'); + $products_image->set_destination(DIR_FS_CATALOG_IMAGES); + if ($products_image->parse() && $products_image->save()) { + $products_image_name = $products_image->filename; + } else { + $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); + } + break; + } + } + +// check if the catalog image directory exists + if (is_dir(DIR_FS_CATALOG_IMAGES)) { + if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); + } else { + $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); + } +?> + +> + + +<?php echo TITLE; ?> + + + + +
+ + + + + + + + + + + + +
+ + + +
+ '', + 'products_description' => '', + 'products_url' => '', + 'products_id' => '', + 'products_quantity' => '', + 'products_model' => '', + 'products_image' => '', + 'products_price' => '', + 'products_weight' => '', + 'products_date_added' => '', + 'products_last_modified' => '', + 'products_date_available' => '', + 'products_status' => '', + 'products_tax_class_id' => '', + 'manufacturers_id' => ''); + + $pInfo = new objectInfo($parameters); + + if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) { + $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); + $product = tep_db_fetch_array($product_query); + + $pInfo->objectInfo($product); + } elseif (tep_not_null($HTTP_POST_VARS)) { + $pInfo->objectInfo($HTTP_POST_VARS); + $products_name = $HTTP_POST_VARS['products_name']; + $products_description = $HTTP_POST_VARS['products_description']; + $products_url = $HTTP_POST_VARS['products_url']; + } + + $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE)); + $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); + while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { + $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], + 'text' => $manufacturers['manufacturers_name']); + } + + $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); + $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); + while ($tax_class = tep_db_fetch_array($tax_class_query)) { + $tax_class_array[] = array('id' => $tax_class['tax_class_id'], + 'text' => $tax_class['tax_class_title']); + } + + $languages = tep_get_languages(); + + if (!isset($pInfo->products_status)) $pInfo->products_status = '1'; + switch ($pInfo->products_status) { + case '0': $in_status = false; $out_status = true; break; + case '1': + default: $in_status = true; $out_status = false; + } +?> + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

(YYYY-MM-DD)
manufacturers_id); ?>
products_id, $languages[$i]['id']))); ?>
products_tax_class_id, 'onchange="updateGross()"'); ?>
products_price, 'onKeyUp="updateGross()"'); ?>
products_price, 'OnKeyUp="updateNet()"'); ?>
+ + + + +
 products_id, $languages[$i]['id']))); ?>
products_quantity); ?>
products_model); ?>
' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?>
' . TEXT_PRODUCTS_URL_WITHOUT_HTTP . ''; ?>products_id, $languages[$i]['id']))); ?>
products_weight); ?>
products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '  ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+products_image; + } + + $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; + + echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"'); + + $languages = tep_get_languages(); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { + $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); + $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); + $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); + } else { + $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); + $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); + $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); + } +?> + + + + + + + + + + +products_url) { +?> + + + + + + + + + + +products_date_available > date('Y-m-d')) { +?> + + + + + + + + + + + +products_id; + } +?> + + + + + + + +
+ + + + +
products_name; ?>format($pInfo->products_price); ?>
products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?>
products_url); ?>
products_date_available)); ?>
products_date_added)); ?>
' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; +?>
+ + + + + + + + +
+ + + + + +
+ + + + + + +
+'; +?> +
+'; +?> +
+ + + '' . TEXT_INFO_HEADING_NEW_CATEGORY . ''); + + $contents = array('form' => tep_draw_form('newcategory', FILENAME_CATEGORIES, 'action=insert_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"')); + $contents[] = array('text' => TEXT_NEW_CATEGORY_INTRO); + + $category_inputs_string = ''; + $languages = tep_get_languages(); + for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { + $category_inputs_string .= '
' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']'); + } + + $contents[] = array('text' => '
' . TEXT_CATEGORIES_NAME . $category_inputs_string); + $contents[] = array('text' => '
' . TEXT_CATEGORIES_IMAGE . '
' . tep_draw_file_field('categories_image')); + $contents[] = array('text' => '
' . TEXT_SORT_ORDER . '
' . tep_draw_input_field('sort_order', '', 'size="2"')); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'edit_category': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_CATEGORY . ''); + + $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=update_category&cPath=' . $cPath, 'post', 'enctype="multipart/form-data"') . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); + $contents[] = array('text' => TEXT_EDIT_INTRO); + + $category_inputs_string = ''; + $languages = tep_get_languages(); + for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { + $category_inputs_string .= '
' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('categories_name[' . $languages[$i]['id'] . ']', tep_get_category_name($cInfo->categories_id, $languages[$i]['id'])); + } + + $contents[] = array('text' => '
' . TEXT_EDIT_CATEGORIES_NAME . $category_inputs_string); + $contents[] = array('text' => '
' . tep_image(DIR_WS_CATALOG_IMAGES . $cInfo->categories_image, $cInfo->categories_name) . '
' . DIR_WS_CATALOG_IMAGES . '
' . $cInfo->categories_image . ''); + $contents[] = array('text' => '
' . TEXT_EDIT_CATEGORIES_IMAGE . '
' . tep_draw_file_field('categories_image')); + $contents[] = array('text' => '
' . TEXT_EDIT_SORT_ORDER . '
' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="2"')); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete_category': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_CATEGORY . ''); + + $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=delete_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); + $contents[] = array('text' => TEXT_DELETE_CATEGORY_INTRO); + $contents[] = array('text' => '
' . $cInfo->categories_name . ''); + if ($cInfo->childs_count > 0) $contents[] = array('text' => '
' . sprintf(TEXT_DELETE_WARNING_CHILDS, $cInfo->childs_count)); + if ($cInfo->products_count > 0) $contents[] = array('text' => '
' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $cInfo->products_count)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'move_category': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_MOVE_CATEGORY . ''); + + $contents = array('form' => tep_draw_form('categories', FILENAME_CATEGORIES, 'action=move_category_confirm&cPath=' . $cPath) . tep_draw_hidden_field('categories_id', $cInfo->categories_id)); + $contents[] = array('text' => sprintf(TEXT_MOVE_CATEGORIES_INTRO, $cInfo->categories_name)); + $contents[] = array('text' => '
' . sprintf(TEXT_MOVE, $cInfo->categories_name) . '
' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete_product': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_PRODUCT . ''); + + $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=delete_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); + $contents[] = array('text' => TEXT_DELETE_PRODUCT_INTRO); + $contents[] = array('text' => '
' . $pInfo->products_name . ''); + + $product_categories_string = ''; + $product_categories = tep_generate_category_path($pInfo->products_id, 'product'); + for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++) { + $category_path = ''; + for ($j = 0, $k = sizeof($product_categories[$i]); $j < $k; $j++) { + $category_path .= $product_categories[$i][$j]['text'] . ' > '; + } + $category_path = substr($category_path, 0, -16); + $product_categories_string .= tep_draw_checkbox_field('product_categories[]', $product_categories[$i][sizeof($product_categories[$i])-1]['id'], true) . ' ' . $category_path . '
'; + } + $product_categories_string = substr($product_categories_string, 0, -4); + + $contents[] = array('text' => '
' . $product_categories_string); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'move_product': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_MOVE_PRODUCT . ''); + + $contents = array('form' => tep_draw_form('products', FILENAME_CATEGORIES, 'action=move_product_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); + $contents[] = array('text' => sprintf(TEXT_MOVE_PRODUCTS_INTRO, $pInfo->products_name)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENT_CATEGORIES . '
' . tep_output_generated_category_path($pInfo->products_id, 'product') . ''); + $contents[] = array('text' => '
' . sprintf(TEXT_MOVE, $pInfo->products_name) . '
' . tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $current_category_id)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'copy_to': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_COPY_TO . ''); + + $contents = array('form' => tep_draw_form('copy_to', FILENAME_CATEGORIES, 'action=copy_to_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id)); + $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENT_CATEGORIES . '
' . tep_output_generated_category_path($pInfo->products_id, 'product') . ''); + $contents[] = array('text' => '
' . TEXT_CATEGORIES . '
' . tep_draw_pull_down_menu('categories_id', tep_get_category_tree(), $current_category_id)); + $contents[] = array('text' => '
' . TEXT_HOW_TO_COPY . '
' . tep_draw_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '
' . tep_draw_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_copy.gif', IMAGE_COPY) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if ($rows > 0) { + if (isset($cInfo) && is_object($cInfo)) { // category info box contents + $heading[] = array('text' => '' . $cInfo->categories_name . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '' . tep_image_button('button_move.gif', IMAGE_MOVE) . ''); + $contents[] = array('text' => '
' . TEXT_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added)); + if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified)); + $contents[] = array('text' => '
' . tep_info_image($cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '
' . $cInfo->categories_image); + $contents[] = array('text' => '
' . TEXT_SUBCATEGORIES . ' ' . $cInfo->childs_count . '
' . TEXT_PRODUCTS . ' ' . $cInfo->products_count); + } elseif (isset($pInfo) && is_object($pInfo)) { // product info box contents + $heading[] = array('text' => '' . tep_get_products_name($pInfo->products_id, $languages_id) . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '' . tep_image_button('button_move.gif', IMAGE_MOVE) . '' . tep_image_button('button_copy_to.gif', IMAGE_COPY_TO) . ''); + $contents[] = array('text' => '
' . TEXT_DATE_ADDED . ' ' . tep_date_short($pInfo->products_date_added)); + if (tep_not_null($pInfo->products_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($pInfo->products_last_modified)); + if (date('Y-m-d') < $pInfo->products_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE . ' ' . tep_date_short($pInfo->products_date_available)); + $contents[] = array('text' => '
' . tep_info_image($pInfo->products_image, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
' . $pInfo->products_image); + $contents[] = array('text' => '
' . TEXT_PRODUCTS_PRICE_INFO . ' ' . $currencies->format($pInfo->products_price) . '
' . TEXT_PRODUCTS_QUANTITY_INFO . ' ' . $pInfo->products_quantity); + $contents[] = array('text' => '
' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%'); + } + } else { // create category/product info + $heading[] = array('text' => '' . EMPTY_CATEGORY . ''); + + $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + tep_childs_in_category_count($categories['categories_id'])); + $category_products = array('products_count' => tep_products_in_category_count($categories['categories_id'])); + + $cInfo_array = array_merge($categories, $category_childs, $category_products); + $cInfo = new objectInfo($cInfo_array); + } + + if (isset($cInfo) && is_object($cInfo) && ($categories['categories_id'] == $cInfo->categories_id) ) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + +products_id) ) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + 0) { + for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) { + if (empty($cPath_back)) { + $cPath_back .= $cPath_array[$i]; + } else { + $cPath_back .= '_' . $cPath_array[$i]; + } + } + } + + $cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : ''; +?> + + + +
 
' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' ' . $categories['categories_name'] . ''; ?> categories_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . ' ' . $products['products_name']; ?> +' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . ''; + } else { + echo '' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10); + } +?>products_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + +
' . TEXT_PRODUCTS . ' ' . $products_count; ?> 0) echo '' . tep_image_button('button_back.gif', IMAGE_BACK) . ' '; if (!isset($HTTP_GET_VARS['search'])) echo '' . tep_image_button('button_new_category.gif', IMAGE_NEW_CATEGORY) . ' ' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . ''; ?> 
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ +
+ + + + + +
+ + + diff --git a/catalog/admin/configuration.php b/catalog/admin/configuration.php new file mode 100644 index 0000000..f588750 --- /dev/null +++ b/catalog/admin/configuration.php @@ -0,0 +1,171 @@ + + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
+ + + '' . $cInfo->configuration_title . ''); + + if ($cInfo->set_function) { + eval('$value_field = ' . $cInfo->set_function . '"' . htmlspecialchars($cInfo->configuration_value) . '");'); + } else { + $value_field = tep_draw_input_field('configuration_value', $cInfo->configuration_value); + } + + $contents = array('form' => tep_draw_form('configuration', FILENAME_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=save')); + $contents[] = array('text' => TEXT_INFO_EDIT_INTRO); + $contents[] = array('text' => '
' . $cInfo->configuration_title . '
' . $cInfo->configuration_description . '
' . $value_field); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($cInfo) && is_object($cInfo)) { + $heading[] = array('text' => '' . $cInfo->configuration_title . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ''); + $contents[] = array('text' => '
' . $cInfo->configuration_description); + $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added)); + if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified)); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + +', $use_function)) { + $class_method = explode('->', $use_function); + if (!is_object(${$class_method[0]})) { + include(DIR_WS_CLASSES . $class_method[0] . '.php'); + ${$class_method[0]} = new $class_method[0](); + } + $cfgValue = tep_call_function($class_method[1], $configuration['configuration_value'], ${$class_method[0]}); + } else { + $cfgValue = tep_call_function($use_function, $configuration['configuration_value']); + } + } else { + $cfgValue = $configuration['configuration_value']; + } + + if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $configuration['configuration_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) { + $cfg_extra_query = tep_db_query("select configuration_key, configuration_description, date_added, last_modified, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_id = '" . (int)$configuration['configuration_id'] . "'"); + $cfg_extra = tep_db_fetch_array($cfg_extra_query); + + $cInfo_array = array_merge($configuration, $cfg_extra); + $cInfo = new objectInfo($cInfo_array); + } + + if ( (isset($cInfo) && is_object($cInfo)) && ($configuration['configuration_id'] == $cInfo->configuration_id) ) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + +
 
configuration_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/countries.php b/catalog/admin/countries.php new file mode 100644 index 0000000..2d06f7b --- /dev/null +++ b/catalog/admin/countries.php @@ -0,0 +1,203 @@ + + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
+ + + '' . TEXT_INFO_HEADING_NEW_COUNTRY . ''); + + $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&action=insert')); + $contents[] = array('text' => TEXT_INFO_INSERT_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_NAME . '
' . tep_draw_input_field('countries_name')); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_2 . '
' . tep_draw_input_field('countries_iso_code_2')); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_3 . '
' . tep_draw_input_field('countries_iso_code_3')); + $contents[] = array('text' => '
' . TEXT_INFO_ADDRESS_FORMAT . '
' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats())); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'edit': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_COUNTRY . ''); + + $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id . '&action=save')); + $contents[] = array('text' => TEXT_INFO_EDIT_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_NAME . '
' . tep_draw_input_field('countries_name', $cInfo->countries_name)); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_2 . '
' . tep_draw_input_field('countries_iso_code_2', $cInfo->countries_iso_code_2)); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_3 . '
' . tep_draw_input_field('countries_iso_code_3', $cInfo->countries_iso_code_3)); + $contents[] = array('text' => '
' . TEXT_INFO_ADDRESS_FORMAT . '
' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats(), $cInfo->address_format_id)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_COUNTRY . ''); + + $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id . '&action=deleteconfirm')); + $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); + $contents[] = array('text' => '
' . $cInfo->countries_name . ''); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (is_object($cInfo)) { + $heading[] = array('text' => '' . $cInfo->countries_name . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_NAME . '
' . $cInfo->countries_name); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_2 . ' ' . $cInfo->countries_iso_code_2); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_CODE_3 . ' ' . $cInfo->countries_iso_code_3); + $contents[] = array('text' => '
' . TEXT_INFO_ADDRESS_FORMAT . ' ' . $cInfo->address_format_id); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + +countries_id)) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + + +
 
countries_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + + + + + + +
display_count($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?>display_links($countries_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
' . tep_image_button('button_new_country.gif', IMAGE_NEW_COUNTRY) . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/create_order.php b/catalog/admin/create_order.php new file mode 100644 index 0000000..652b593 --- /dev/null +++ b/catalog/admin/create_order.php @@ -0,0 +1 @@ + 0) { // Query Successful $SelectCustomerBox = "\n"; } $query = tep_db_query("select code, value from " . TABLE_CURRENCIES . " ORDER BY code"); $result = $query; if (tep_db_num_rows($result) > 0) { // Query Successful $SelectCurrencyBox = "\n"; } if(IsSet($HTTP_GET_VARS['Customer'])) { $account_query = tep_db_query("select * from " . TABLE_CUSTOMERS . " where customers_id = '" . $HTTP_GET_VARS['Customer'] . "'"); $account = tep_db_fetch_array($account_query); $customer = $account['customers_id']; $address_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $HTTP_GET_VARS['Customer'] . "'"); $address = tep_db_fetch_array($address_query); //$customer = $account['customers_id']; } elseif (IsSet($HTTP_GET_VARS['Customer_nr'])) { $account_query = tep_db_query("select * from " . TABLE_CUSTOMERS . " where customers_id = '" . $HTTP_GET_VARS['Customer_nr'] . "'"); $account = tep_db_fetch_array($account_query); $customer = $account['customers_id']; $address_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $HTTP_GET_VARS['Customer_nr'] . "'"); $address = tep_db_fetch_array($address_query); //$customer = $account['customers_id']; } require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ORDER_PROCESS); // #### Generate Page ?> > <?php echo HEADING_TITLE ?> + + + diff --git a/catalog/admin/includes/boxes/configuration.php b/catalog/admin/includes/boxes/configuration.php new file mode 100644 index 0000000..9467ed9 --- /dev/null +++ b/catalog/admin/includes/boxes/configuration.php @@ -0,0 +1,38 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/customers.php b/catalog/admin/includes/boxes/customers.php new file mode 100644 index 0000000..65c0f47 --- /dev/null +++ b/catalog/admin/includes/boxes/customers.php @@ -0,0 +1,33 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/localization.php b/catalog/admin/includes/boxes/localization.php new file mode 100644 index 0000000..68346f1 --- /dev/null +++ b/catalog/admin/includes/boxes/localization.php @@ -0,0 +1,34 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/modules.php b/catalog/admin/includes/boxes/modules.php new file mode 100644 index 0000000..35ffc83 --- /dev/null +++ b/catalog/admin/includes/boxes/modules.php @@ -0,0 +1,37 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/reports.php b/catalog/admin/includes/boxes/reports.php new file mode 100644 index 0000000..d8fb6fd --- /dev/null +++ b/catalog/admin/includes/boxes/reports.php @@ -0,0 +1,34 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/taxes.php b/catalog/admin/includes/boxes/taxes.php new file mode 100644 index 0000000..abb05b3 --- /dev/null +++ b/catalog/admin/includes/boxes/taxes.php @@ -0,0 +1,36 @@ + + + + + + diff --git a/catalog/admin/includes/boxes/tools.php b/catalog/admin/includes/boxes/tools.php new file mode 100644 index 0000000..4b28f8d --- /dev/null +++ b/catalog/admin/includes/boxes/tools.php @@ -0,0 +1,40 @@ + + + + + + diff --git a/catalog/admin/includes/classes/box.php b/catalog/admin/includes/classes/box.php new file mode 100644 index 0000000..4ff551c --- /dev/null +++ b/catalog/admin/includes/classes/box.php @@ -0,0 +1,60 @@ + 'class="menuBoxHeading"', + 'text' => BOX_HEADING_TOOLS, + 'link' => tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('selected_box')) . 'selected_box=tools')); + + $contents = array(); + $contents[] = array('text' => SOME_TEXT); + + $box = new box; + echo $box->infoBox($heading, $contents); +*/ + + class box extends tableBlock { + function box() { + $this->heading = array(); + $this->contents = array(); + } + + function infoBox($heading, $contents) { + $this->table_row_parameters = 'class="infoBoxHeading"'; + $this->table_data_parameters = 'class="infoBoxHeading"'; + $this->heading = $this->tableBlock($heading); + + $this->table_row_parameters = ''; + $this->table_data_parameters = 'class="infoBoxContent"'; + $this->contents = $this->tableBlock($contents); + + return $this->heading . $this->contents; + } + + function menuBox($heading, $contents) { + $this->table_data_parameters = 'class="menuBoxHeading"'; + if (isset($heading[0]['link'])) { + $this->table_data_parameters .= ' onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . $heading[0]['link'] . '\'"'; + $heading[0]['text'] = ' ' . $heading[0]['text'] . ' '; + } else { + $heading[0]['text'] = ' ' . $heading[0]['text'] . ' '; + } + $this->heading = $this->tableBlock($heading); + + $this->table_data_parameters = 'class="menuBoxContent"'; + $this->contents = $this->tableBlock($contents); + + return $this->heading . $this->contents; + } + } +?> diff --git a/catalog/admin/includes/classes/currencies.php b/catalog/admin/includes/classes/currencies.php new file mode 100644 index 0000000..36cb904 --- /dev/null +++ b/catalog/admin/includes/classes/currencies.php @@ -0,0 +1,59 @@ +currencies = array(); + $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES); + while ($currencies = tep_db_fetch_array($currencies_query)) { + $this->currencies[$currencies['code']] = array('title' => $currencies['title'], + 'symbol_left' => $currencies['symbol_left'], + 'symbol_right' => $currencies['symbol_right'], + 'decimal_point' => $currencies['decimal_point'], + 'thousands_point' => $currencies['thousands_point'], + 'decimal_places' => $currencies['decimal_places'], + 'value' => $currencies['value']); + } + } + +// class methods + function format($number, $calculate_currency_value = true, $currency_type = DEFAULT_CURRENCY, $currency_value = '') { + if ($calculate_currency_value) { + $rate = ($currency_value) ? $currency_value : $this->currencies[$currency_type]['value']; + $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number * $rate, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; +// if the selected currency is in the european euro-conversion and the default currency is euro, +// the currency will displayed in the national currency and euro currency + if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) { + $format_string .= ' [' . $this->format($number, true, 'EUR') . ']'; + } + } else { + $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format($number, $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; + } + + return $format_string; + } + + function get_value($code) { + return $this->currencies[$code]['value']; + } + + function display_price($products_price, $products_tax, $quantity = 1) { + return $this->format(tep_add_tax($products_price, $products_tax) * $quantity); + } + } +?> diff --git a/catalog/admin/includes/classes/email.php b/catalog/admin/includes/classes/email.php new file mode 100644 index 0000000..a1e302e --- /dev/null +++ b/catalog/admin/includes/classes/email.php @@ -0,0 +1,578 @@ + + and can be found here: http://www.phpguru.org + + Renamed and Modified by Jan Wildeboer for osCommerce +*/ + + class email { + var $html; + var $text; + var $output; + var $html_text; + var $html_images; + var $image_types; + var $build_params; + var $attachments; + var $headers; + + function email($headers = '') { + if ($headers == '') $headers = array(); + + $this->html_images = array(); + $this->headers = array(); + + if (EMAIL_LINEFEED == 'CRLF') { + $this->lf = "\r\n"; + } else { + $this->lf = "\n"; + } + +/** + * If you want the auto load functionality + * to find other mime-image/file types, add the + * extension and content type here. + */ + + $this->image_types = array('gif' => 'image/gif', + 'jpg' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'bmp' => 'image/bmp', + 'png' => 'image/png', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'swf' => 'application/x-shockwave-flash'); + + $this->build_params['html_encoding'] = 'quoted-printable'; + $this->build_params['text_encoding'] = '7bit'; + $this->build_params['html_charset'] = constant('CHARSET'); + $this->build_params['text_charset'] = constant('CHARSET'); + $this->build_params['text_wrap'] = 998; + +/** + * Make sure the MIME version header is first. + */ + + $this->headers[] = 'MIME-Version: 1.0'; + + reset($headers); + while (list(,$value) = each($headers)) { + if (tep_not_null($value)) { + $this->headers[] = $value; + } + } + } + +/** + * This function will read a file in + * from a supplied filename and return + * it. This can then be given as the first + * argument of the the functions + * add_html_image() or add_attachment(). + */ + + function get_file($filename) { + $return = ''; + + if ($fp = fopen($filename, 'rb')) { + while (!feof($fp)) { + $return .= fread($fp, 1024); + } + fclose($fp); + + return $return; + } else { + return false; + } + } + +/** + * Function for extracting images from + * html source. This function will look + * through the html code supplied by add_html() + * and find any file that ends in one of the + * extensions defined in $obj->image_types. + * If the file exists it will read it in and + * embed it, (not an attachment). + * + * Function contributed by Dan Allen + */ + + function find_html_images($images_dir) { +// Build the list of image extensions + while (list($key, ) = each($this->image_types)) { + $extensions[] = $key; + } + + preg_match_all('/"([^"]+\.(' . implode('|', $extensions).'))"/Ui', $this->html, $images); + + for ($i=0; $ihtml = str_replace($images[1][$i], basename($images[1][$i]), $this->html); + } + } + + if (tep_not_null($html_images)) { +// If duplicate images are embedded, they may show up as attachments, so remove them. + $html_images = array_unique($html_images); + sort($html_images); + + for ($i=0; $iget_file($images_dir . $html_images[$i])) { + $content_type = $this->image_types[substr($html_images[$i], strrpos($html_images[$i], '.') + 1)]; + $this->add_html_image($image, basename($html_images[$i]), $content_type); + } + } + } + } + +/** + * Adds plain text. Use this function + * when NOT sending html email + */ + + function add_text($text = '') { + $this->text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text); + } + +/** + * Adds a html part to the mail. + * Also replaces image names with + * content-id's. + */ + + function add_html($html, $text = NULL, $images_dir = NULL) { + $this->html = tep_convert_linefeeds(array("\r\n", "\n", "\r"), '
', $html); + $this->html_text = tep_convert_linefeeds(array("\r\n", "\n", "\r"), $this->lf, $text); + + if (isset($images_dir)) $this->find_html_images($images_dir); + } + +/** + * Adds an image to the list of embedded + * images. + */ + + function add_html_image($file, $name = '', $c_type='application/octet-stream') { + $this->html_images[] = array('body' => $file, + 'name' => $name, + 'c_type' => $c_type, + 'cid' => md5(uniqid(time()))); + } + +/** + * Adds a file to the list of attachments. + */ + + function add_attachment($file, $name = '', $c_type='application/octet-stream', $encoding = 'base64') { + $this->attachments[] = array('body' => $file, + 'name' => $name, + 'c_type' => $c_type, + 'encoding' => $encoding); + } + +/** + * Adds a text subpart to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_text_part(&$obj, $text) { + function add_text_part(&$obj, $text) { + $params['content_type'] = 'text/plain'; + $params['encoding'] = $this->build_params['text_encoding']; + $params['charset'] = $this->build_params['text_charset']; + + if (is_object($obj)) { + return $obj->addSubpart($text, $params); + } else { + return new mime($text, $params); + } + } + +/** + * Adds a html subpart to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_html_part(&$obj) { + function add_html_part(&$obj) { + $params['content_type'] = 'text/html'; + $params['encoding'] = $this->build_params['html_encoding']; + $params['charset'] = $this->build_params['html_charset']; + + if (is_object($obj)) { + return $obj->addSubpart($this->html, $params); + } else { + return new mime($this->html, $params); + } + } + +/** + * Starts a message with a mixed part + */ + +/* HPDL PHP3 */ +// function &add_mixed_part() { + function add_mixed_part() { + $params['content_type'] = 'multipart/mixed'; + + return new mime('', $params); + } + +/** + * Adds an alternative part to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_alternative_part(&$obj) { + function add_alternative_part(&$obj) { + $params['content_type'] = 'multipart/alternative'; + + if (is_object($obj)) { + return $obj->addSubpart('', $params); + } else { + return new mime('', $params); + } + } + +/** + * Adds a html subpart to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_related_part(&$obj) { + function add_related_part(&$obj) { + $params['content_type'] = 'multipart/related'; + + if (is_object($obj)) { + return $obj->addSubpart('', $params); + } else { + return new mime('', $params); + } + } + +/** + * Adds an html image subpart to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_html_image_part(&$obj, $value) { + function add_html_image_part(&$obj, $value) { + $params['content_type'] = $value['c_type']; + $params['encoding'] = 'base64'; + $params['disposition'] = 'inline'; + $params['dfilename'] = $value['name']; + $params['cid'] = $value['cid']; + + $obj->addSubpart($value['body'], $params); + } + +/** + * Adds an attachment subpart to a mime_part object + */ + +/* HPDL PHP3 */ +// function &add_attachment_part(&$obj, $value) { + function add_attachment_part(&$obj, $value) { + $params['content_type'] = $value['c_type']; + $params['encoding'] = $value['encoding']; + $params['disposition'] = 'attachment'; + $params['dfilename'] = $value['name']; + + $obj->addSubpart($value['body'], $params); + } + +/** + * Builds the multipart message from the + * list ($this->_parts). $params is an + * array of parameters that shape the building + * of the message. Currently supported are: + * + * $params['html_encoding'] - The type of encoding to use on html. Valid options are + * "7bit", "quoted-printable" or "base64" (all without quotes). + * 7bit is EXPRESSLY NOT RECOMMENDED. Default is quoted-printable + * $params['text_encoding'] - The type of encoding to use on plain text Valid options are + * "7bit", "quoted-printable" or "base64" (all without quotes). + * Default is 7bit + * $params['text_wrap'] - The character count at which to wrap 7bit encoded data. + * Default this is 998. + * $params['html_charset'] - The character set to use for a html section. + * Default is iso-8859-1 + * $params['text_charset'] - The character set to use for a text section. + * - Default is iso-8859-1 + */ + +/* HPDL PHP3 */ +// function build_message($params = array()) { + function build_message($params = '') { + if ($params == '') $params = array(); + + if (count($params) > 0) { + reset($params); + while(list($key, $value) = each($params)) { + $this->build_params[$key] = $value; + } + } + + if (tep_not_null($this->html_images)) { + reset($this->html_images); + while (list(,$value) = each($this->html_images)) { + $this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html); + } + } + + $null = NULL; + $attachments = ((tep_not_null($this->attachments)) ? true : false); + $html_images = ((tep_not_null($this->html_images)) ? true : false); + $html = ((tep_not_null($this->html)) ? true : false); + $text = ((tep_not_null($this->text)) ? true : false); + + switch (true) { + case (($text == true) && ($attachments == false)): +/* HPDL PHP3 */ +// $message =& $this->add_text_part($null, $this->text); + $message = $this->add_text_part($null, $this->text); + break; + case (($text == false) && ($attachments == true) && ($html == false)): +/* HPDL PHP3 */ +// $message =& $this->add_mixed_part(); + $message = $this->add_mixed_part(); + + for ($i=0; $iattachments); $i++) { + $this->add_attachment_part($message, $this->attachments[$i]); + } + break; + case (($text == true) && ($attachments == true)): +/* HPDL PHP3 */ +// $message =& $this->add_mixed_part(); + $message = $this->add_mixed_part(); + $this->add_text_part($message, $this->text); + + for ($i=0; $iattachments); $i++) { + $this->add_attachment_part($message, $this->attachments[$i]); + } + break; + case (($html == true) && ($attachments == false) && ($html_images == false)): + if (tep_not_null($this->html_text)) { +/* HPDL PHP3 */ +// $message =& $this->add_alternative_part($null); + $message = $this->add_alternative_part($null); + $this->add_text_part($message, $this->html_text); + $this->add_html_part($message); + } else { +/* HPDL PHP3 */ +// $message =& $this->add_html_part($null); + $message = $this->add_html_part($null); + } + break; + case (($html == true) && ($attachments == false) && ($html_images == true)): + if (tep_not_null($this->html_text)) { +/* HPDL PHP3 */ +// $message =& $this->add_alternative_part($null); + $message = $this->add_alternative_part($null); + $this->add_text_part($message, $this->html_text); +/* HPDL PHP3 */ +// $related =& $this->add_related_part($message); + $related = $this->add_related_part($message); + } else { +/* HPDL PHP3 */ +// $message =& $this->add_related_part($null); +// $related =& $message; + $message = $this->add_related_part($null); + $related = $message; + } + $this->add_html_part($related); + + for ($i=0; $ihtml_images); $i++) { + $this->add_html_image_part($related, $this->html_images[$i]); + } + break; + case (($html == true) && ($attachments == true) && ($html_images == false)): +/* HPDL PHP3 */ +// $message =& $this->add_mixed_part(); + $message = $this->add_mixed_part(); + if (tep_not_null($this->html_text)) { +/* HPDL PHP3 */ +// $alt =& $this->add_alternative_part($message); + $alt = $this->add_alternative_part($message); + $this->add_text_part($alt, $this->html_text); + $this->add_html_part($alt); + } else { + $this->add_html_part($message); + } + + for ($i=0; $iattachments); $i++) { + $this->add_attachment_part($message, $this->attachments[$i]); + } + break; + case (($html == true) && ($attachments == true) && ($html_images == true)): +/* HPDL PHP3 */ +// $message =& $this->add_mixed_part(); + $message = $this->add_mixed_part(); + + if (tep_not_null($this->html_text)) { +/* HPDL PHP3 */ +// $alt =& $this->add_alternative_part($message); + $alt = $this->add_alternative_part($message); + $this->add_text_part($alt, $this->html_text); +/* HPDL PHP3 */ +// $rel =& $this->add_related_part($alt); + $rel = $this->add_related_part($alt); + } else { +/* HPDL PHP3 */ +// $rel =& $this->add_related_part($message); + $rel = $this->add_related_part($message); + } + $this->add_html_part($rel); + + for ($i=0; $ihtml_images); $i++) { + $this->add_html_image_part($rel, $this->html_images[$i]); + } + + for ($i=0; $iattachments); $i++) { + $this->add_attachment_part($message, $this->attachments[$i]); + } + break; + } + + if ( (isset($message)) && (is_object($message)) ) { + $output = $message->encode(); + $this->output = $output['body']; + + reset($output['headers']); + while (list($key, $value) = each($output['headers'])) { + $headers[] = $key . ': ' . $value; + } + + $this->headers = array_merge($this->headers, $headers); + + return true; + } else { + return false; + } + } + +/** + * Sends the mail. + */ + + function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') { + if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) { + return false; + } + + if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) { + return false; + } + + if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) { + return false; + } + + if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) { + return false; + } + + if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) { + return false; + } + + $to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr); + $from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr); + + if (is_string($headers)) { + $headers = explode($this->lf, trim($headers)); + } + + for ($i=0; $ioutput, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers)); + } else { + return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers)); + } + } + +/** + * Use this method to return the email + * in message/rfc822 format. Useful for + * adding an email to another email as + * an attachment. there's a commented + * out example in example.php. + * + * string get_rfc822(string To name, + * string To email, + * string From name, + * string From email, + * [string Subject, + * string Extra headers]) + */ + + function get_rfc822($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') { +// Make up the date header as according to RFC822 + $date = 'Date: ' . date('D, d M y H:i:s'); + $to = (($to_name != '') ? 'To: "' . $to_name . '" <' . $to_addr . '>' : 'To: ' . $to_addr); + $from = (($from_name != '') ? 'From: "' . $from_name . '" <' . $from_addr . '>' : 'From: ' . $from_addr); + + if (is_string($subject)) { + $subject = 'Subject: ' . $subject; + } + + if (is_string($headers)) { + $headers = explode($this->lf, trim($headers)); + } + + for ($i=0; $iheaders, $xtra_headers); + + return $date . $this->lf . $from . $this->lf . $to . $this->lf . $subject . $this->lf . implode($this->lf, $headers) . $this->lf . $this->lf . $this->output; + } + } +?> diff --git a/catalog/admin/includes/classes/language.php b/catalog/admin/includes/classes/language.php new file mode 100644 index 0000000..9a3c7fa --- /dev/null +++ b/catalog/admin/includes/classes/language.php @@ -0,0 +1,95 @@ + (detect_language.php v0.1 04/02/2002) +*/ + + class language { + var $languages, $catalog_languages, $browser_languages, $language; + + function language($lng = '') { + $this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic', + 'bg' => 'bg|bulgarian', + 'br' => 'pt[-_]br|brazilian portuguese', + 'ca' => 'ca|catalan', + 'cs' => 'cs|czech', + 'da' => 'da|danish', + 'de' => 'de([-_][[:alpha:]]{2})?|german', + 'el' => 'el|greek', + 'en' => 'en([-_][[:alpha:]]{2})?|english', + 'es' => 'es([-_][[:alpha:]]{2})?|spanish', + 'et' => 'et|estonian', + 'fi' => 'fi|finnish', + 'fr' => 'fr([-_][[:alpha:]]{2})?|french', + 'gl' => 'gl|galician', + 'he' => 'he|hebrew', + 'hu' => 'hu|hungarian', + 'id' => 'id|indonesian', + 'it' => 'it|italian', + 'ja' => 'ja|japanese', + 'ko' => 'ko|korean', + 'ka' => 'ka|georgian', + 'lt' => 'lt|lithuanian', + 'lv' => 'lv|latvian', + 'nl' => 'nl([-_][[:alpha:]]{2})?|dutch', + 'no' => 'no|norwegian', + 'pl' => 'pl|polish', + 'pt' => 'pt([-_][[:alpha:]]{2})?|portuguese', + 'ro' => 'ro|romanian', + 'ru' => 'ru|russian', + 'sk' => 'sk|slovak', + 'sr' => 'sr|serbian', + 'sv' => 'sv|swedish', + 'th' => 'th|thai', + 'tr' => 'tr|turkish', + 'uk' => 'uk|ukrainian', + 'tw' => 'zh[-_]tw|chinese traditional', + 'zh' => 'zh|chinese simplified'); + + $this->catalog_languages = array(); + $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); + while ($languages = tep_db_fetch_array($languages_query)) { + $this->catalog_languages[$languages['code']] = array('id' => $languages['languages_id'], + 'name' => $languages['name'], + 'image' => $languages['image'], + 'directory' => $languages['directory']); + } + + $this->browser_languages = ''; + $this->language = ''; + + $this->set_language($lng); + } + + function set_language($language) { + if ( (tep_not_null($language)) && (isset($this->catalog_languages[$language])) ) { + $this->language = $this->catalog_languages[$language]; + } else { + $this->language = $this->catalog_languages[DEFAULT_LANGUAGE]; + } + } + + function get_browser_language() { + $this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE')); + + for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) { + reset($this->languages); + while (list($key, $value) = each($this->languages)) { + if (eregi('^(' . $value . ')(;q=[0-9]\\.[0-9])?$', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) { + $this->language = $this->catalog_languages[$key]; + break 2; + } + } + } + } + } +?> diff --git a/catalog/admin/includes/classes/logger.php b/catalog/admin/includes/classes/logger.php new file mode 100644 index 0000000..7870407 --- /dev/null +++ b/catalog/admin/includes/classes/logger.php @@ -0,0 +1,52 @@ +timer_start(); + } + + function timer_start() { + if (defined("PAGE_PARSE_START_TIME")) { + $this->timer_start = PAGE_PARSE_START_TIME; + } else { + $this->timer_start = microtime(); + } + } + + function timer_stop($display = 'false') { + $this->timer_stop = microtime(); + + $time_start = explode(' ', $this->timer_start); + $time_end = explode(' ', $this->timer_stop); + + $this->timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3); + + $this->write(getenv('REQUEST_URI'), $this->timer_total . 's'); + + if ($display == 'true') { + return $this->timer_display(); + } + } + + function timer_display() { + return 'Parse Time: ' . $this->timer_total . 's'; + } + + function write($message, $type) { + error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' [' . $type . '] ' . $message . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); + } + } +?> diff --git a/catalog/admin/includes/classes/message_stack.php b/catalog/admin/includes/classes/message_stack.php new file mode 100644 index 0000000..3fbfdca --- /dev/null +++ b/catalog/admin/includes/classes/message_stack.php @@ -0,0 +1,71 @@ +add('Error: Error 1', 'error'); + $messageStack->add('Error: Error 2', 'warning'); + if ($messageStack->size > 0) echo $messageStack->output(); +*/ + + class messageStack extends tableBlock { + var $size = 0; + + function messageStack() { + global $messageToStack; + + $this->errors = array(); + + if (tep_session_is_registered('messageToStack')) { + for ($i = 0, $n = sizeof($messageToStack); $i < $n; $i++) { + $this->add($messageToStack[$i]['text'], $messageToStack[$i]['type']); + } + tep_session_unregister('messageToStack'); + } + } + + function add($message, $type = 'error') { + if ($type == 'error') { + $this->errors[] = array('params' => 'class="messageStackError"', 'text' => tep_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . ' ' . $message); + } elseif ($type == 'warning') { + $this->errors[] = array('params' => 'class="messageStackWarning"', 'text' => tep_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message); + } elseif ($type == 'success') { + $this->errors[] = array('params' => 'class="messageStackSuccess"', 'text' => tep_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . ' ' . $message); + } else { + $this->errors[] = array('params' => 'class="messageStackError"', 'text' => $message); + } + + $this->size++; + } + + function add_session($message, $type = 'error') { + global $messageToStack; + + if (!tep_session_is_registered('messageToStack')) { + tep_session_register('messageToStack'); + $messageToStack = array(); + } + + $messageToStack[] = array('text' => $message, 'type' => $type); + } + + function reset() { + $this->errors = array(); + $this->size = 0; + } + + function output() { + $this->table_data_parameters = 'class="messageBox"'; + return $this->tableBlock($this->errors); + } + } +?> diff --git a/catalog/admin/includes/classes/mime.php b/catalog/admin/includes/classes/mime.php new file mode 100644 index 0000000..d785b5d --- /dev/null +++ b/catalog/admin/includes/classes/mime.php @@ -0,0 +1,250 @@ + + and can be found here: http://www.phpguru.org + + Renamed and Modified by Jan Wildeboer for osCommerce +*/ + + class mime { + var $_encoding; + var $_subparts; + var $_encoded; + var $_headers; + var $_body; + +/** + * Constructor. + * + * Sets up the object. + * + * @param $body - The body of the mime part if any. + * @param $params - An associative array of parameters: + * content_type - The content type for this part eg multipart/mixed + * encoding - The encoding to use, 7bit, base64, or quoted-printable + * cid - Content ID to apply + * disposition - Content disposition, inline or attachment + * dfilename - Optional filename parameter for content disposition + * description - Content description + * @access public + */ + + function mime($body, $params = '') { + if ($params == '') $params = array(); + +// Make sure we use the correct linfeed sequence + if (EMAIL_LINEFEED == 'CRLF') { + $this->lf = "\r\n"; + } else { + $this->lf = "\n"; + } + + reset($params); + while (list($key, $value) = each($params)) { + switch ($key) { + case 'content_type': + $headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : ''); + break; + case 'encoding': + $this->_encoding = $value; + $headers['Content-Transfer-Encoding'] = $value; + break; + case 'cid': + $headers['Content-ID'] = '<' . $value . '>'; + break; + case 'disposition': + $headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : ''); + break; + case 'dfilename': + if (isset($headers['Content-Disposition'])) { + $headers['Content-Disposition'] .= '; filename="' . $value . '"'; + } else { + $dfilename = $value; + } + break; + case 'description': + $headers['Content-Description'] = $value; + break; + case 'charset': + if (isset($headers['Content-Type'])) { + $headers['Content-Type'] .= '; charset="' . $value . '"'; + } else { + $charset = $value; + } + break; + } + } + +// Default content-type + if (!isset($_headers['Content-Type'])) { + $_headers['Content-Type'] = 'text/plain'; + } + +// Assign stuff to member variables + $this->_encoded = array(); +/* HPDL PHP3 */ +// $this->_headers =& $headers; + $this->_headers = $headers; + $this->_body = $body; + } + +/** + * encode() + * + * Encodes and returns the email. Also stores + * it in the encoded member variable + * + * @return An associative array containing two elements, + * body and headers. The headers element is itself + * an indexed array. + * @access public + */ + + function encode() { +/* HPDL PHP3 */ +// $encoded =& $this->_encoded; + $encoded = $this->_encoded; + + if (tep_not_null($this->_subparts)) { + $boundary = '=_' . md5(uniqid(tep_rand()) . microtime()); + $this->_headers['Content-Type'] .= ';' . $this->lf . chr(9) . 'boundary="' . $boundary . '"'; + +// Add body parts to $subparts + for ($i=0; $i_subparts); $i++) { + $headers = array(); +/* HPDL PHP3 */ +// $tmp = $this->_subparts[$i]->encode(); + $_subparts = $this->_subparts[$i]; + $tmp = $_subparts->encode(); + + reset($tmp['headers']); + while (list($key, $value) = each($tmp['headers'])) { + $headers[] = $key . ': ' . $value; + } + + $subparts[] = implode($this->lf, $headers) . $this->lf . $this->lf . $tmp['body']; + } + + $encoded['body'] = '--' . $boundary . $this->lf . implode('--' . $boundary . $this->lf, $subparts) . '--' . $boundary.'--' . $this->lf; + } else { + $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . $this->lf; + } + +// Add headers to $encoded +/* HPDL PHP3 */ +// $encoded['headers'] =& $this->_headers; + $encoded['headers'] = $this->_headers; + + return $encoded; + } + +/** + * &addSubPart() + * + * Adds a subpart to current mime part and returns + * a reference to it + * + * @param $body The body of the subpart, if any. + * @param $params The parameters for the subpart, same + * as the $params argument for constructor. + * @return A reference to the part you just added. It is + * crucial if using multipart/* in your subparts that + * you use =& in your script when calling this function, + * otherwise you will not be able to add further subparts. + * @access public + */ + +/* HPDL PHP3 */ +// function &addSubPart($body, $params) { + function addSubPart($body, $params) { + $this->_subparts[] = new mime($body, $params); + + return $this->_subparts[count($this->_subparts) - 1]; + } + +/** + * _getEncodedData() + * + * Returns encoded data based upon encoding passed to it + * + * @param $data The data to encode. + * @param $encoding The encoding type to use, 7bit, base64, + * or quoted-printable. + * @access private + */ + + function _getEncodedData($data, $encoding) { + switch ($encoding) { + case '7bit': + return $data; + break; + case 'quoted-printable': + return $this->_quotedPrintableEncode($data); + break; + case 'base64': + return rtrim(chunk_split(base64_encode($data), 76, $this->lf)); + break; + } + } + +/** + * quoteadPrintableEncode() + * + * Encodes data to quoted-printable standard. + * + * @param $input The data to encode + * @param $line_max Optional max line length. Should + * not be more than 76 chars + * + * @access private + */ + + function _quotedPrintableEncode($input , $line_max = 76) { + $lines = preg_split("/\r\n|\r|\n/", $input); + $eol = $this->lf; + $escape = '='; + $output = ''; + + while (list(, $line) = each($lines)) { + $linlen = strlen($line); + $newline = ''; + + for ($i = 0; $i < $linlen; $i++) { + $char = substr($line, $i, 1); + $dec = ord($char); + +// convert space at eol only + if ( ($dec == 32) && ($i == ($linlen - 1)) ) { + $char = '=20'; + } elseif ($dec == 9) { +// Do nothing if a tab. + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { + $char = $escape . strtoupper(sprintf('%02s', dechex($dec))); + } + +// $this->lf is not counted + if ((strlen($newline) + strlen($char)) >= $line_max) { +// soft line break; " =\r\n" is okay + $output .= $newline . $escape . $eol; + $newline = ''; + } + $newline .= $char; + } + $output .= $newline . $eol; + } +// Don't want last crlf + $output = substr($output, 0, -1 * strlen($eol)); + + return $output; + } + } +?> diff --git a/catalog/admin/includes/classes/object_info.php b/catalog/admin/includes/classes/object_info.php new file mode 100644 index 0000000..c54ce35 --- /dev/null +++ b/catalog/admin/includes/classes/object_info.php @@ -0,0 +1,23 @@ +$key = tep_db_prepare_input($value); + } + } + } +?> diff --git a/catalog/admin/includes/classes/oe_order.php b/catalog/admin/includes/classes/oe_order.php new file mode 100644 index 0000000..7e5f78f --- /dev/null +++ b/catalog/admin/includes/classes/oe_order.php @@ -0,0 +1,148 @@ +info = array(); + $this->totals = array(); + $this->products = array(); + $this->customer = array(); + $this->delivery = array(); + + $this->query($order_id); + } +//Begin Order Editor modifications + function query($order_id) { + $order_query = tep_db_query("select * from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); + $order = tep_db_fetch_array($order_query); + + $totals_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); + while ($totals = tep_db_fetch_array($totals_query)) { + $this->totals[] = array( + 'title' => $totals['title'], + 'text' => $totals['text'], + 'class' => $totals['class'], + 'value' => $totals['value'], + 'sort_order' => $totals['sort_order'], + 'orders_total_id' => $totals['orders_total_id']); + } + + $this->info = array('currency' => $order['currency'], + 'currency_value' => $order['currency_value'], + 'payment_method' => $order['payment_method'], + 'cc_type' => $order['cc_type'], + 'cc_owner' => $order['cc_owner'], + 'cc_number' => $order['cc_number'], + 'cc_expires' => $order['cc_expires'], + 'shipping_tax' => $order['shipping_tax'], + 'date_purchased' => $order['date_purchased'], + 'orders_status' => $order['orders_status'], + 'last_modified' => $order['last_modified']); + + $this->customer = array('name' => $order['customers_name'], + 'company' => $order['customers_company'], + 'street_address' => $order['customers_street_address'], + 'suburb' => $order['customers_suburb'], + 'city' => $order['customers_city'], + 'postcode' => $order['customers_postcode'], + 'state' => $order['customers_state'], + 'country' => $order['customers_country'], + 'country_id' => tep_get_country_id($order['customers_country']), + 'zone_id' => tep_get_zone_id(tep_get_country_id($order['customers_country']), $order['customers_state']), + 'format_id' => $order['customers_address_format_id'], + 'telephone' => $order['customers_telephone'], + 'email_address' => $order['customers_email_address']); + + $this->delivery = array('name' => $order['delivery_name'], + 'company' => $order['delivery_company'], + 'street_address' => $order['delivery_street_address'], + 'suburb' => $order['delivery_suburb'], + 'city' => $order['delivery_city'], + 'postcode' => $order['delivery_postcode'], + 'state' => $order['delivery_state'], + 'country' => $order['delivery_country'], + 'country_id' => tep_get_country_id($order['delivery_country']), + 'zone_id' => tep_get_zone_id(tep_get_country_id($order['delivery_country']), $order['delivery_state']), + 'format_id' => $order['delivery_address_format_id']); + + $this->billing = array('name' => $order['billing_name'], + 'company' => $order['billing_company'], + 'street_address' => $order['billing_street_address'], + 'suburb' => $order['billing_suburb'], + 'city' => $order['billing_city'], + 'postcode' => $order['billing_postcode'], + 'state' => $order['billing_state'], + 'country' => $order['billing_country'], + 'country_id' => tep_get_country_id($order['billing_country']), + 'zone_id' => tep_get_zone_id(tep_get_country_id($order['billing_country']), $order['billing_state']), + 'format_id' => $order['billing_address_format_id']); + + + $countryid = tep_get_country_id($this->delivery["country"]); + $zoneid = tep_get_zone_id($countryid, $this->delivery["state"]); + + $index = 0; + $orders_products_query = tep_db_query(" + SELECT + op.orders_products_id, + op.products_name, + op.products_model, + op.products_price, + op.products_tax, + op.products_quantity, + op.final_price, + p.products_tax_class_id, + p.products_weight, + p.products_id + FROM " . TABLE_ORDERS_PRODUCTS . " op + LEFT JOIN " . TABLE_PRODUCTS . " p + ON op.products_id = p.products_id + WHERE orders_id = '" . (int)$order_id . "'"); + + while ($orders_products = tep_db_fetch_array($orders_products_query)) { + $this->products[$index] = array( + 'qty' => $orders_products['products_quantity'], + 'name' => $orders_products['products_name'], + 'model' => $orders_products['products_model'], + 'tax' => $orders_products['products_tax'], + 'tax_description' => tep_get_tax_description($orders_products['products_tax_class_id'], $countryid, $zoneid), + 'price' => $orders_products['products_price'], + 'final_price' => $orders_products['final_price'], + 'weight' => $orders_products['products_weight'], + //START MOD per visualizzare le quantità dei prodotti disponibili nella riga di descrizione del prodotto + 'magazzino' => $orders_products['products_id'], + //END MOD per visualizzare le quantità dei prodotti disponibili nella riga di descrizione del prodotto + 'orders_products_id' => $orders_products['orders_products_id']); + + + $subindex = 0; + $attributes_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); + if (tep_db_num_rows($attributes_query)) { + while ($attributes = tep_db_fetch_array($attributes_query)) { + $this->products[$index]['attributes'][$subindex] = + array('option' => $attributes['products_options'], + 'value' => $attributes['products_options_values'], + 'prefix' => $attributes['price_prefix'], + 'price' => $attributes['options_values_price'], + 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); + + $subindex++; + } + } + $index++; + } + } + } + //end Order Editor +?> diff --git a/catalog/admin/includes/classes/order.php b/catalog/admin/includes/classes/order.php new file mode 100644 index 0000000..25ea6e0 --- /dev/null +++ b/catalog/admin/includes/classes/order.php @@ -0,0 +1,106 @@ +info = array(); + $this->totals = array(); + $this->products = array(); + $this->customer = array(); + $this->delivery = array(); + + $this->query($order_id); + } + + function query($order_id) { + $order_query = tep_db_query("select customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_telephone, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); + $order = tep_db_fetch_array($order_query); + + $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); + while ($totals = tep_db_fetch_array($totals_query)) { + $this->totals[] = array('title' => $totals['title'], + 'text' => $totals['text']); + } + + $this->info = array('currency' => $order['currency'], + 'currency_value' => $order['currency_value'], + 'payment_method' => $order['payment_method'], + 'cc_type' => $order['cc_type'], + 'cc_owner' => $order['cc_owner'], + 'cc_number' => $order['cc_number'], + 'cc_expires' => $order['cc_expires'], + 'date_purchased' => $order['date_purchased'], + 'orders_status' => $order['orders_status'], + 'last_modified' => $order['last_modified']); + + $this->customer = array('name' => $order['customers_name'], + 'company' => $order['customers_company'], + 'street_address' => $order['customers_street_address'], + 'suburb' => $order['customers_suburb'], + 'city' => $order['customers_city'], + 'postcode' => $order['customers_postcode'], + 'state' => $order['customers_state'], + 'country' => $order['customers_country'], + 'format_id' => $order['customers_address_format_id'], + 'telephone' => $order['customers_telephone'], + 'email_address' => $order['customers_email_address']); + + $this->delivery = array('name' => $order['delivery_name'], + 'company' => $order['delivery_company'], + 'street_address' => $order['delivery_street_address'], + 'suburb' => $order['delivery_suburb'], + 'city' => $order['delivery_city'], + 'postcode' => $order['delivery_postcode'], + 'state' => $order['delivery_state'], + 'country' => $order['delivery_country'], + 'telephone' => $order['delivery_telephone'], //Rodax Software + 'format_id' => $order['delivery_address_format_id']); + + $this->billing = array('name' => $order['billing_name'], + 'company' => $order['billing_company'], + 'street_address' => $order['billing_street_address'], + 'suburb' => $order['billing_suburb'], + 'city' => $order['billing_city'], + 'postcode' => $order['billing_postcode'], + 'state' => $order['billing_state'], + 'country' => $order['billing_country'], + 'format_id' => $order['billing_address_format_id']); + + $index = 0; + $orders_products_query = tep_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); + while ($orders_products = tep_db_fetch_array($orders_products_query)) { + $this->products[$index] = array('qty' => $orders_products['products_quantity'], + 'name' => $orders_products['products_name'], + 'model' => $orders_products['products_model'], + 'tax' => $orders_products['products_tax'], + 'price' => $orders_products['products_price'], + 'final_price' => $orders_products['final_price']); + + $subindex = 0; + $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); + if (tep_db_num_rows($attributes_query)) { + while ($attributes = tep_db_fetch_array($attributes_query)) { + $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], + 'value' => $attributes['products_options_values'], + 'prefix' => $attributes['price_prefix'], + 'price' => $attributes['options_values_price']); + + $subindex++; + } + } + $index++; + } + } + } +?> diff --git a/catalog/admin/includes/classes/payment_module_info.php b/catalog/admin/includes/classes/payment_module_info.php new file mode 100644 index 0000000..177ac28 --- /dev/null +++ b/catalog/admin/includes/classes/payment_module_info.php @@ -0,0 +1,19 @@ +payment_code = $pmInfo_array['payment_code']; + + for ($i = 0, $n = sizeof($pmInfo_array) - 1; $i < $n; $i++) { + $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description from " . TABLE_CONFIGURATION . " where configuration_key = '" . $pmInfo_array[$i] . "'"); + $key_value = tep_db_fetch_array($key_value_query); + + $this->keys[$pmInfo_array[$i]]['title'] = $key_value['configuration_title']; + $this->keys[$pmInfo_array[$i]]['value'] = $key_value['configuration_value']; + $this->keys[$pmInfo_array[$i]]['description'] = $key_value['configuration_description']; + } + } + } +?> \ No newline at end of file diff --git a/catalog/admin/includes/classes/phplot.php b/catalog/admin/includes/classes/phplot.php new file mode 100644 index 0000000..c5c1a41 --- /dev/null +++ b/catalog/admin/includes/classes/phplot.php @@ -0,0 +1,2639 @@ + 0 + + var $point_size = 10; + var $point_shape = 'diamond'; //rect,circle,diamond,triangle,dot,line,halfline + var $error_bar_shape = 'tee'; //tee, line + var $error_bar_size = 5; //right left size of tee + var $error_bar_line_width = ''; //If set then use it, else use $line_width for thickness + var $error_bar_color = ''; + var $data_values; + + var $plot_border_type = 'full'; //left, none, full + var $plot_area_width = ''; + var $number_x_points; + var $plot_min_x; // Max and min of the plot area + var $plot_max_x= ''; // Max and min of the plot area + var $plot_min_y= ''; // Max and min of the plot area + var $plot_max_y = ''; // Max and min of the plot area + var $min_y = ''; + var $max_y = ''; + var $max_x = 10; //Must not be = 0; + var $y_precision = '1'; + var $x_precision = '1'; + var $si_units = ''; + +//Labels + var $draw_data_labels = '0'; + var $legend = ''; //an array + var $legend_x_pos = ''; + var $legend_y_pos = ''; + var $title_txt = ""; + var $y_label_txt = ''; + var $x_label_txt = ""; + +//DataAxis Labels (on each axis) + var $y_grid_label_type = 'data'; //data, none, time, other + var $y_grid_label_pos = 'plotleft'; //plotleft, plotright, yaxis, both + var $x_grid_label_type = 'data'; //data, title, none, time, other + var $draw_x_data_labels = ''; // 0=false, 1=true, ""=let program decide + var $x_time_format = "%H:%m:%s"; //See http://www.php.net/manual/html/function.strftime.html + var $x_datalabel_maxlength = 10; + +//Tick Formatting + var $tick_length = '10'; //pixels: tick length from axis left/downward + //tick_length2 to be implemented + //var $tick_length2 = ''; //pixels: tick length from axis line rightward/upward + var $draw_vert_ticks = 1; //1 = draw ticks, 0 = don't draw ticks + var $num_vert_ticks = ''; + var $vert_tick_increment=''; //Set num_vert_ticks or vert_tick_increment, not both. + var $vert_tick_position = 'both'; //plotright=(right of plot only), plotleft=(left of plot only), + //both = (both left and right of plot), yaxis=(crosses y axis) + var $horiz_tick_increment=''; //Set num_horiz_ticks or horiz_tick_increment, not both. + var $num_horiz_ticks=''; + var $skip_top_tick = '0'; + var $skip_bottom_tick = '0'; + +//Grid Formatting + var $draw_x_grid = 0; + var $draw_y_grid = 1; + + +//BEGIN CODE +////////////////////////////////////////////////////// + //Constructor: Setup Img pointer, Colors and Size of Image + function PHPlot($which_width=600,$which_height=400,$which_output_file="",$which_input_file="") { + + $this->SetRGBArray('2'); + $this->background_done = 0; //Set to 1 after background image first drawn + + if ($which_output_file != "") { $this->SetOutputFile($which_output_file); }; + + if ($which_input_file != "") { + $this->SetInputFile($which_input_file) ; + } else { + $this->SetImageArea($which_width, $which_height); + $this->InitImage(); + } + + if ( ($this->session_set == 1) && ($this->img == "") ) { //For sessions + //Do nothing + } else { + $this->SetDefaultColors(); + } + + $this->SetIndexColors(); + + } + + //Set up the image and colors + function InitImage() { + //if ($this->img) { + // ImageDestroy($this->img); + //} + $this->img = ImageCreate($this->image_width, $this->image_height); + return true; + } + + function SetBrowserCache($which_browser_cache) { //Submitted by Thiemo Nagel + $this->browser_cache = $which_browser_cache; + return true; + } + + function SetPrintImage($which_pi) { + $this->print_image = $which_pi; + return true; + } + + function SetIsInline($which_ii) { + $this->is_inline = $which_ii; + return true; + } + + function SetUseTTF($which_ttf) { + $this->use_ttf = $which_ttf; + return true; + } + + function SetTitleFontSize($which_tfs) { + //TTF + $this->title_ttffont_size = $which_tfs; //pt size + + //Non-TTF settings + if (($which_tfs > 5) && (!$this->use_ttf)) { + $this->DrawError('Non-TTF font size must be 1,2,3,4 or 5'); + return false; + } else { + $this->title_font = $which_tfs; + //$this->title_font_height = ImageFontHeight($which_tfs) // height in pixels + //$this->title_font_width = ImageFontWidth($which_tfs); // width in pixels + } + return true; + } + + function SetLineStyles($which_sls){ + $this->line_style = $which_sls; + return true; + } + + function SetLegend($which_leg){ + if (is_array($which_leg)) { + $this->legend = $which_leg; + return true; + } else { + $this->DrawError('Error: SetLegend argument must be an array'); + return false; + } + } + + function SetLegendPixels($which_x,$which_y,$which_type) { + //which_type not yet used + $this->legend_x_pos = $which_x; + $this->legend_y_pos = $which_y; + return true; + } + + function SetLegendWorld($which_x,$which_y,$which_type='') { + //which_type not yet used + //Must be called after scales are set up. + if ($this->scale_is_set != 1) { $this->SetTranslation(); }; + $this->legend_x_pos = $this->xtr($which_x); + $this->legend_y_pos = $this->ytr($which_y); + return true; + } +/* *************************************** + function SetFileFormat($which_file_format) { //Only works with PHP4 + $asked = strtolower($which_file_format); + if( $asked =="jpg" || $asked =="png" || $asked =="gif" || $asked =="wbmp" ) { + if( $asked=="jpg" && !(imagetypes() & IMG_JPG) ) + return false; + elseif( $asked=="png" && !(imagetypes() & IMG_PNG) ) + return false; + elseif( $asked=="gif" && !(imagetypes() & IMG_GIF) ) + return false; + elseif( $asked=="wbmp" && !(imagetypes() & IMG_WBMP) ) + return false; + else { + $this->img_format=$asked; + return true; + } + } + else + return false; + } + +*************************************** */ + function SetFileFormat($which_file_format) { + //eventually test to see if that is supported - if not then return false + $asked = strtolower(trim($which_file_format)); + if( ($asked=='jpg') || ($asked=='png') || ($asked=='gif') || ($asked=='wbmp') ) { + $this->file_format = $asked; + return true; + } else { + return false; + } + } + + function SetInputFile($which_input_file) { + //$this->SetFileFormat($which_frmt); + $size = GetImageSize($which_input_file); + $input_type = $size[2]; + + switch($input_type) { //After SetFileFormat is in lower case + case "1": + $im = @ImageCreateFromGIF ($which_input_file); + if (!$im) { // See if it failed + $this->PrintError("Unable to open $which_input_file as a GIF"); + return false; + } + break; + case "3": + $im = @ImageCreateFromPNG ($which_input_file); + if (!$im) { // See if it failed + $this->PrintError("Unable to open $which_input_file as a PNG"); + return false; + } + break; + case "2": + $im = @ImageCreateFromJPEG ($which_input_file); + if (!$im) { // See if it failed + $this->PrintError("Unable to open $which_input_file as a JPG"); + return false; + } + break; + default: + $this->PrintError('Please select wbmp,gif,jpg, or png for image type!'); + return false; + break; + } + + //Get Width and Height of Image + $this->SetImageArea($size[0],$size[1]); + + $this->img = $im; + + return true; + + } + + function SetOutputFile($which_output_file) { + $this->output_file = $which_output_file; + return true; + } + + function SetImageArea($which_iw,$which_ih) { + //Note this is now an Internal function - please set w/h via PHPlot() + $this->image_width = $which_iw; + $this->image_height = $which_ih; + + return true; + } + + + function SetYAxisPosition($which_pos) { + $this->y_axis_position = $which_pos; + return true; + } + function SetXAxisPosition($which_pos) { + $this->x_axis_position = $which_pos; + return true; + } + function SetXTimeFormat($which_xtf) { + $this->x_time_format = $which_xtf; + return true; + } + function SetXDataLabelMaxlength($which_xdlm) { + if ($which_xdlm >0 ) { + $this->x_datalabel_maxlength = $which_xdlm; + return true; + } else { + return false; + } + } + function SetXDataLabelAngle($which_xdla) { + $this->x_datalabel_angle = $which_xdla; + return true; + } + function SetXScaleType($which_xst) { + $this->xscale_type = $which_xst; + return true; + } + function SetYScaleType($which_yst) { + $this->yscale_type = $which_yst; + if ($this->x_axis_position <= 0) { + $this->x_axis_position = 1; + } + return true; + } + + function SetPrecisionX($which_prec) { + $this->x_precision = $which_prec; + return true; + } + function SetPrecisionY($which_prec) { + $this->y_precision = $which_prec; + return true; + } + + + function SetIndexColors() { //Internal Method called to set colors and preserve state + //These are the colors of the image that are used. They are initialized + //to work with sessions and PHP. + + $this->ndx_i_light = $this->SetIndexColor($this->i_light); + $this->ndx_i_dark = $this->SetIndexColor($this->i_dark); + $this->ndx_bg_color= $this->SetIndexColor($this->bg_color); + $this->ndx_plot_bg_color= $this->SetIndexColor($this->plot_bg_color); + + $this->ndx_title_color= $this->SetIndexColor($this->title_color); + $this->ndx_tick_color= $this->SetIndexColor($this->tick_color); + $this->ndx_label_color= $this->SetIndexColor($this->label_color); + $this->ndx_text_color= $this->SetIndexColor($this->text_color); + $this->ndx_light_grid_color= $this->SetIndexColor($this->light_grid_color); + $this->ndx_grid_color= $this->SetIndexColor($this->grid_color); + + reset($this->error_bar_color); + unset($ndx_error_bar_color); + $i = 0; + while (list(, $col) = each($this->error_bar_color)) { + $this->ndx_error_bar_color[$i] = $this->SetIndexColor($col); + $i++; + } + //reset($this->data_border_color); + unset($ndx_data_border_color); + $i = 0; + while (list(, $col) = each($this->data_border_color)) { + $this->ndx_data_border_color[$i] = $this->SetIndexColor($col); + $i++; + } + //reset($this->data_color); + unset($ndx_data_color); + $i = 0; + while (list(, $col) = each($this->data_color)) { + $this->ndx_data_color[$i] = $this->SetIndexColor($col); + $i++; + } + + return true; + } + + + function SetDefaultColors() { + + $this->i_light = array(194,194,194); + $this->i_dark = array(100,100,100); + $this->SetPlotBgColor(array(222,222,222)); + $this->SetBackgroundColor(array(200,222,222)); //can use rgb values or "name" values + $this->SetLabelColor('black'); + $this->SetTextColor('black'); + $this->SetGridColor('black'); + $this->SetLightGridColor(array(175,175,175)); + $this->SetTickColor('black'); + $this->SetTitleColor(array(0,0,0)); // Can be array or name + $this->data_color = array('blue','green','yellow','red','orange'); + $this->error_bar_color = array('blue','green','yellow','red','orange'); + $this->data_border_color = array('black'); + + $this->session_set = 1; //Mark it down for PHP session() usage. + } + + function PrintImage() { + + if ( ($this->browser_cache == 0) && ($this->is_inline == 0)) { //Submitted by Thiemo Nagel + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT'); + header('Cache-Control: no-cache, must-revalidate'); + header('Pragma: no-cache'); + } + + switch($this->file_format) { + case "png": + if ($this->is_inline == 0) { + Header('Content-type: image/png'); + } + if ($this->is_inline == 1 && $this->output_file != "") { + ImagePng($this->img,$this->output_file); + } else { + ImagePng($this->img); + } + break; + case "jpg": + if ($this->is_inline == 0) { + Header('Content-type: image/jpeg'); + } + if ($this->is_inline == 1 && $this->output_file != "") { + ImageJPEG($this->img,$this->output_file); + } else { + ImageJPEG($this->img); + } + break; + case "gif": + if ($this->is_inline == 0) { + Header('Content-type: image/gif'); + } + if ($this->is_inline == 1 && $this->output_file != "") { + ImageGIF($this->img,$this->output_file); + } else { + ImageGIF($this->img); + } + + break; + case "wbmp": + if ($this->is_inline == 0) { + Header('Content-type: image/wbmp'); + } + if ($this->is_inline == 1 && $this->output_file != "") { + ImageWBMP($this->img,$this->output_file); + } else { + ImageWBMP($this->img); + } + + break; + default: + $this->PrintError('Please select an image type!
'); + break; + } + ImageDestroy($this->img); + return true; + } + + + function DrawBackground() { + //if ($this->img == "") { $this->InitImage(); }; + if ($this->background_done == 0) { //Don't draw it twice if drawing two plots on one image + ImageFilledRectangle($this->img, 0, 0, + $this->image_width, $this->image_height, $this->ndx_bg_color); + $this->background_done = 1; + } + return true; + } + + function DrawImageBorder() { + switch ($this->image_border_type) { + case "raised": + ImageLine($this->img,0,0,$this->image_width-1,0,$this->ndx_i_light); + ImageLine($this->img,1,1,$this->image_width-2,1,$this->ndx_i_light); + ImageLine($this->img,0,0,0,$this->image_height-1,$this->ndx_i_light); + ImageLine($this->img,1,1,1,$this->image_height-2,$this->ndx_i_light); + ImageLine($this->img,$this->image_width-1,0,$this->image_width-1,$this->image_height-1,$this->ndx_i_dark); + ImageLine($this->img,0,$this->image_height-1,$this->image_width-1,$this->image_height-1,$this->ndx_i_dark); + ImageLine($this->img,$this->image_width-2,1,$this->image_width-2,$this->image_height-2,$this->ndx_i_dark); + ImageLine($this->img,1,$this->image_height-2,$this->image_width-2,$this->image_height-2,$this->ndx_i_dark); + break; + case "plain": + ImageLine($this->img,0,0,$this->image_width,0,$this->ndx_i_dark); + ImageLine($this->img,$this->image_width-1,0,$this->image_width-1,$this->image_height,$this->ndx_i_dark); + ImageLine($this->img,$this->image_width-1,$this->image_height-1,0,$this->image_height-1,$this->ndx_i_dark); + ImageLine($this->img,0,0,0,$this->image_height,$this->ndx_i_dark); + break; + default: + break; + } + return true; + } + + function SetPlotBorderType($which_pbt) { + $this->plot_border_type = $which_pbt; //left, none, anything else=full + } + + function SetImageBorderType($which_sibt) { + $this->image_border_type = $which_sibt; //raised, plain + } + + function SetDrawPlotAreaBackground($which_dpab) { + $this->draw_plot_area_background = $which_dpab; // 1=true or anything else=false + } + + function SetDrawDataLabels($which_ddl) { //Draw next to datapoints + $this->draw_data_labels = $which_ddl; // 1=true or anything else=false + } + + function SetDrawXDataLabels($which_dxdl) { //Draw on X Axis + $this->draw_x_data_labels = $which_dxdl; // 1=true or anything else=false + } + + function SetDrawYGrid($which_dyg) { + $this->draw_y_grid = $which_dyg; // 1=true or anything else=false + } + + function SetDrawXGrid($which_dxg) { + $this->draw_x_grid = $which_dxg; // 1=true or anything else=false + } + + function SetYGridLabelType($which_yglt) { + $this->y_grid_label_type = $which_yglt; + return true; + } + + function SetXGridLabelType($which_xglt) { + $this->x_grid_label_type = $which_xglt; + return true; + } + + function SetXLabel($xlbl) { + $this->x_label_txt = $xlbl; + return true; + } + function SetYLabel($ylbl) { + $this->y_label_txt = $ylbl; + return true; + } + function SetTitle($title) { + $this->title_txt = $title; + return true; + } + + //function SetLabels($xlbl,$ylbl,$title) { + // $this->title_txt = $title; + // $this->x_label_txt = $xlbl; + // $this->y_label_txt = $ylbl; + //} + + function DrawLabels() { + $this->DrawTitle(); + $this->DrawXLabel(); + $this->DrawYLabel(); + return true; + } + + function DrawXLabel() { + if ($this->use_ttf == 1) { + $xpos = $this->xtr(($this->plot_max_x + $this->plot_min_x)/2.0) ; + $ypos = $this->ytr($this->plot_min_y) + $this->x_label_height/2.0; + $this->DrawText($this->x_label_ttffont, $this->x_label_angle, + $xpos, $ypos, $this->ndx_label_color, $this->x_label_ttffont_size, $this->x_label_txt,'center'); + } else { + //$xpos = 0.0 - (ImageFontWidth($this->small_font)*strlen($this->x_label_txt)/2.0) + $this->xtr(($this->plot_max_x+$this->plot_min_x)/2.0) ; + $xpos = 0.0 + $this->xtr(($this->plot_max_x+$this->plot_min_x)/2.0) ; + $ypos = ($this->ytr($this->plot_min_y) + $this->x_label_height/2); + + $this->DrawText($this->small_font, $this->x_label_angle, + $xpos, $ypos, $this->ndx_label_color, "", $this->x_label_txt, 'center'); + + } + return true; + } + + function DrawYLabel() { + if ($this->use_ttf == 1) { + $size = $this->TTFBBoxSize($this->y_label_ttffont_size, 90, $this->y_label_ttffont, $this->y_label_txt); + $xpos = 8 + $size[0]; + $ypos = ($size[1])/2 + $this->ytr(($this->plot_max_y + $this->plot_min_y)/2.0) ; + $this->DrawText($this->y_label_ttffont, 90, + $xpos, $ypos, $this->ndx_label_color, $this->y_label_ttffont_size, $this->y_label_txt); + } else { + $xpos = 8; + $ypos = (($this->small_font_width*strlen($this->y_label_txt)/2.0) + + $this->ytr(($this->plot_max_y + $this->plot_min_y)/2.0) ); + $this->DrawText($this->small_font, 90, + $xpos, $ypos, $this->ndx_label_color, $this->y_label_ttffont_size, $this->y_label_txt); + } + return true; + } + + function DrawText($which_font,$which_angle,$which_xpos,$which_ypos,$which_color,$which_size,$which_text,$which_halign='left',$which_valign='') { + + if ($this->use_ttf == 1 ) { + $size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text); + if ($which_valign == 'bottom') { + $which_ypos = $which_ypos + ImageFontHeight($which_font); + } + if ($which_halign == 'center') { + $which_xpos = $which_xpos - $size[0]/2; + } + ImageTTFText($this->img, $which_size, $which_angle, + $which_xpos, $which_ypos, $which_color, $which_font, $which_text); + } else { + if ($which_valign == 'top') { + $which_ypos = $which_ypos - ImageFontHeight($which_font); + } + $which_text = ereg_replace("\r","",$which_text); + $str = split("\n",$which_text); //multiple lines submitted by Remi Ricard + $height = ImageFontHeight($which_font); + $width = ImageFontWidth($which_font); + if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss + for($i=0;$iimg, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color); + } + } else { + for($i=0;$iimg, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color); + } else { + ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color); + } + } + } + + } + return true; + + } + function DrawTitle() { + if ($this->use_ttf == 1 ) { + $xpos = ($this->plot_area[0] + $this->plot_area_width / 2); + $ypos = $this->y_top_margin/2; + $this->DrawText($this->title_ttffont, $this->title_angle, + $xpos, $ypos, $this->ndx_title_color, $this->title_ttffont_size, $this->title_txt,'center'); + } else { + $xpos = ($this->plot_area[0] + $this->plot_area_width / 2); + $ypos = ImageFontHeight($this->title_font); + $this->DrawText($this->title_font, $this->title_angle, + $xpos, $ypos, $this->ndx_title_color, '', $this->title_txt,'center'); + } + return true; + + } + + function DrawPlotAreaBackground() { + ImageFilledRectangle($this->img,$this->plot_area[0], + $this->plot_area[1],$this->plot_area[2],$this->plot_area[3], + $this->ndx_plot_bg_color); + } + + function SetBackgroundColor($which_color) { + $this->bg_color= $which_color; + $this->ndx_bg_color= $this->SetIndexColor($which_color); + return true; + } + function SetPlotBgColor($which_color) { + $this->plot_bg_color= $which_color; + $this->ndx_plot_bg_color= $this->SetIndexColor($which_color); + return true; + } + + function SetShading($which_s) { + $this->shading = $which_s; + return true; + } + + function SetTitleColor($which_color) { + $this->title_color= $which_color; + $this->ndx_title_color= $this->SetIndexColor($which_color); + return true; + } + + function SetTickColor ($which_color) { + $this->tick_color= $which_color; + $this->ndx_tick_color= $this->SetIndexColor($which_color); + return true; + } + + function SetLabelColor ($which_color) { + $this->label_color= $which_color; + $this->ndx_label_color= $this->SetIndexColor($which_color); + return true; + } + + function SetTextColor ($which_color) { + $this->text_color= $which_color; + $this->ndx_text_color= $this->SetIndexColor($which_color); + return true; + } + + function SetLightGridColor ($which_color) { + $this->light_grid_color= $which_color; + $this->ndx_light_grid_color= $this->SetIndexColor($which_color); + return true; + } + + function SetGridColor ($which_color) { + $this->grid_color = $which_color; + $this->ndx_grid_color= $this->SetIndexColor($which_color); + return true; + } + + function SetCharacterHeight() { + //to be set + return true; + } + + function SetPlotType($which_pt) { + $accepted = "bars,lines,linepoints,area,points,pie,thinbarline"; + $asked = trim($which_pt); + if (eregi($asked, $accepted)) { + $this->plot_type = $which_pt; + return true; + } else { + $this->DrawError('$which_pt not an acceptable plot type'); + return false; + } + } + + function FindDataLimits() { + //Text-Data is different than data-data graphs. For them what + // we have, instead of X values, is # of records equally spaced on data. + //text-data is passed in as $data[] = (title,y1,y2,y3,y4,...) + //data-data is passed in as $data[] = (title,x,y1,y2,y3,y4,...) + + $this->number_x_points = count($this->data_values); + + switch ($this->data_type) { + case "text-data": + $minx = 0; //valid for BAR TYPE GRAPHS ONLY + $maxx = $this->number_x_points - 1 ; //valid for BAR TYPE GRAPHS ONLY + $miny = (double) $this->data_values[0][1]; + $maxy = $miny; + if ($this->draw_x_data_labels == "") { + $this->draw_x_data_labels = 1; //labels_note1: prevent both data labels and x-axis labels being both drawn and overlapping + } + break; + default: //Everything else: data-data, etc. + $maxx = $this->data_values[0][1]; + $minx = $maxx; + $miny = $this->data_values[0][2]; + $maxy = $miny; + $maxy = $miny; + break; + } + + $max_records_per_group = 0; + $total_records = 0; + $mine = 0; //Maximum value for the -error bar (assume error bars always > 0) + $maxe = 0; //Maximum value for the +error bar (assume error bars always > 0) + + reset($this->data_values); + while (list($dat_key, $dat) = each($this->data_values)) { //for each X barchart setting + //foreach($this->data_values as $dat) //can use foreach only in php4 + + $tmp = 0; + $total_records += count($dat) - 1; // -1 for label + + switch ($this->data_type) { + case "text-data": + //Find the relative Max and Min + + while (list($key, $val) = each($dat)) { + if ($key != 0) { //$dat[0] = label + SetType($val,"double"); + if ($val > $maxy) { + $maxy = $val ; + } + if ($val < $miny) { + $miny = (double) $val ; + } + } + $tmp++; + } + break; + case "data-data": //X-Y data is passed in as $data[] = (title,x,y,y2,y3,...) which you can use for multi-dimentional plots. + + while (list($key, $val) = each($dat)) { + if ($key == 1) { //$dat[0] = label + SetType($val,"double"); + if ($val > $maxx) { + $maxx = $val; + } elseif ($val < $minx) { + $minx = $val; + } + } elseif ($key > 1) { + SetType($val,"double"); + if ($val > $maxy) { + $maxy = $val ; + } elseif ($val < $miny) { + $miny = $val ; + } + } + $tmp++; + } + $tmp = $tmp - 1; //# records per group + break; + case "data-data-error": //Assume 2-D for now, can go higher + //Regular X-Y data is passed in as $data[] = (title,x,y,error+,error-,y2,error2+,error2-) + + while (list($key, $val) = each($dat)) { + if ($key == 1) { //$dat[0] = label + SetType($val,'double'); + if ($val > $maxx) { + $maxx = $val; + } elseif ($val < $minx) { + $minx = $val; + } + } elseif ($key%3 == 2) { + SetType($val,'double'); + if ($val > $maxy) { + $maxy = $val ; + } elseif ($val < $miny) { + $miny = $val ; + } + } elseif ($key%3 == 0) { + SetType($val,'double'); + if ($val > $maxe) { + $maxe = $val ; + } + } elseif ($key%3 == 1) { + SetType($val,'double'); + if ($val > $mine) { + $mine = $val ; + } + } + $tmp++; + } + $maxy = $maxy + $maxe; + $miny = $miny - $mine; //assume error bars are always > 0 + + break; + default: + $this->PrintError('ERROR: unknown chart type'); + break; + } + if ($tmp > $max_records_per_group) { + $max_records_per_group = $tmp; + } + } + + + $this->min_x = $minx; + $this->max_x = $maxx; + $this->min_y = $miny; + $this->max_y = $maxy; + + + if ($max_records_per_group > 1) { + $this->records_per_group = $max_records_per_group - 1; + } else { + $this->records_per_group = 1; + } + + + //$this->data_count = $total_records ; + } // function FindDataLimits + + function SetMargins() { + ///////////////////////////////////////////////////////////////// + // When the image is first created - set the margins + // to be the standard viewport. + // The standard viewport is the full area of the view surface (or panel), + // less a margin of 4 character heights all round for labelling. + // It thus depends on the current character size, set by SetCharacterHeight(). + ///////////////////////////////////////////////////////////////// + + $str = split("\n",$this->title_txt); + $nbLines = count($str); + + if ($this->use_ttf == 1) { + $title_size = $this->TTFBBoxSize($this->title_ttffont_size, $this->title_angle, $this->title_ttffont, 'X'); //An array + if ($nbLines == 1) { + $this->y_top_margin = $title_size[1] * 4; + } else { + $this->y_top_margin = $title_size[1] * ($nbLines+3); + } + + //ajo working here + //$x_label_size = $this->TTFBBoxSize($this->x_label_ttffont_size, 0, $this->axis_ttffont, $this->x_label_txt); + + $this->y_bot_margin = $this->x_label_height ; + $this->x_left_margin = $this->y_label_width * 2 + $this->tick_length; + $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels + } else { + $title_size = array(ImageFontWidth($this->title_font) * strlen($this->title_txt),ImageFontHeight($this->title_font)); + //$this->y_top_margin = ($title_size[1] * 4); + if ($nbLines == 1) { + $this->y_top_margin = $title_size[1] * 4; + } else { + $this->y_top_margin = $title_size[1] * ($nbLines+3); + } + if ($this->x_datalabel_angle == 90) { + $this->y_bot_margin = 76.0; // Must be integer + } else { + $this->y_bot_margin = 66.0; // Must be integer + } + $this->x_left_margin = 77.0; // distance between left and start of x axis in pixels + $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels + } + +//exit; + $this->x_tot_margin = $this->x_left_margin + $this->x_right_margin; + $this->y_tot_margin = $this->y_top_margin + $this->y_bot_margin; + + if ($this->plot_max_x && $this->plot_max_y && $this->plot_area_width ) { //If data has already been analysed then set translation + $this->SetTranslation(); + } + } + + function SetMarginsPixels($which_lm,$which_rm,$which_tm,$which_bm) { + //Set the plot area using margins in pixels (left, right, top, bottom) + $this->SetNewPlotAreaPixels($which_lm,$which_tm,($this->image_width - $which_rm),($this->image_height - $which_bm)); + return true; + } + + function SetNewPlotAreaPixels($x1,$y1,$x2,$y2) { + //Like in GD 0,0 is upper left set via pixel Coordinates + $this->plot_area = array($x1,$y1,$x2,$y2); + $this->plot_area_width = $this->plot_area[2] - $this->plot_area[0]; + $this->plot_area_height = $this->plot_area[3] - $this->plot_area[1]; + $this->y_top_margin = $this->plot_area[1]; + if ($this->plot_max_x) { + $this->SetTranslation(); + } + return true; + } + + function SetPlotAreaPixels($x1,$y1,$x2,$y2) { + //Like in GD 0,0 is upper left + if (!$this->x_tot_margin) { + $this->SetMargins(); + } + if ($x2 && $y2) { + $this->plot_area = array($x1,$y1,$x2,$y2); + } else { + $this->plot_area = array($this->x_left_margin, $this->y_top_margin, + $this->image_width - $this->x_right_margin, + $this->image_height - $this->y_bot_margin + ); + } + $this->plot_area_width = $this->plot_area[2] - $this->plot_area[0]; + $this->plot_area_height = $this->plot_area[3] - $this->plot_area[1]; + + return true; + + } + + function SetPlotAreaWorld($xmin,$ymin,$xmax,$ymax) { + if (($xmin == "") && ($xmax == "")) { + //For automatic setting of data we need $this->max_x + if (!$this->max_y) { + $this->FindDataLimits() ; + } + if ($this->data_type == 'text-data') { //labels for text-data is done at data drawing time for speed. + $xmax = $this->max_x + 1 ; //valid for BAR CHART TYPE GRAPHS ONLY + $xmin = 0 ; //valid for BAR CHART TYPE GRAPHS ONLY + } else { + $xmax = $this->max_x * 1.02; + $xmin = $this->min_x; + } + + $ymax = ceil($this->max_y * 1.2); + if ($this->min_y < 0) { + $ymin = floor($this->min_y * 1.2); + } else { + $ymin = 0; + } + } + + $this->plot_min_x = $xmin; + $this->plot_max_x = $xmax; + + if ($ymin == $ymax) { + $ymax += 1; + } + if ($this->yscale_type == "log") { + //extra error checking + if ($ymin <= 0) { + $ymin = 1; + } + if ($ymax <= 0) { + $this->PrintError('Log plots need data greater than 0'); + } + } + $this->plot_min_y = $ymin; + $this->plot_max_y = $ymax; + + if ($ymax <= $ymin) { + $this->DrawError('Error in Data - max not gt min'); + } + +//Set the boundaries of the box for plotting in world coord +// if (!$this->x_tot_margin) { //We need to know the margins before we can calculate scale +// $this->SetMargins(); +// } + //For this we have to reset the scale + if ($this->plot_area_width) { + $this->SetTranslation(); + } + + return true; + + } //function SetPlotAreaWorld + + + function PrintError($error_message) { + // prints the error message to stdout and die + echo "

Fatal error: $error_message

"; + die; + } + + function DrawError($error_message) { + // prints the error message inline into + // the generated image + + if (($this->img) == "") { $this->InitImage(); } ; + + $ypos = $this->image_height/2; + + if ($this->use_ttf == 1) { + ImageRectangle($this->img, 0,0,$this->image_width,$this->image_height,ImageColorAllocate($this->img,255,255,255)); + ImageTTFText($this->img, $this->small_ttffont_size, 0, $xpos, $ypos, ImageColorAllocate($this->img,0,0,0), $this->axis_ttffont, $error_message); + } else { + ImageRectangle($this->img, 0,0,$this->image_width,$this->image_height,ImageColorAllocate($this->img,255,255,255)); + ImageString($this->img, $this->small_font,1,$ypos,$error_message, ImageColorAllocate($this->img,0,0,0)); + } + + $this->PrintImage(); + return true; + } + + function TTFBBoxSize($size, $angle, $font, $string) { + + //Assume angle < 90 + $arr = ImageTTFBBox($size, 0, $font, $string); + $flat_width = $arr[0] - $arr[2]; + $flat_height = abs($arr[3] - $arr[5]); + + // for 90deg: + // $height = $arr[5] - $arr[7]; + // $width = $arr[2] - $arr[4]; + + $angle = deg2rad($angle); + $width = ceil(abs($flat_width*cos($angle) + $flat_height*sin($angle))); //Must be integer + $height = ceil(abs($flat_width*sin($angle) + $flat_height*cos($angle))); //Must be integer + + return array($width, $height); + } + + function SetXLabelHeight() { + + if ($this->use_ttf == 1) { + //Space for the X Label + $size = $this->TTFBBoxSize($this->x_label_ttffont_size, 0, $this->axis_ttffont, $this->x_label_txt); + $tmp = $size[1]; + + //$string = Str_Repeat('w', $this->x_datalabel_maxlength); + $i = 0; + $string = ''; + while ($i < $this->x_datalabel_maxlength) { + $string .= 'w'; + $i++; + } + + //Space for the axis data labels + $size = $this->TTFBBoxSize($this->axis_ttffont_size, $this->x_datalabel_angle, $this->axis_ttffont, $string); + + $this->x_label_height = 2*$tmp + $size[1] + 4; + + } else { + //For Non-TTF fonts we can have only angles 0 or 90 + if ($this->x_datalabel_angle == 90) { + $this->x_label_height = $this->x_datalabel_maxlength * ImageFontWidth($this->small_font) / 1.5; + } else { + $this->x_label_height = 5 * ImageFontHeight($this->small_font); + } + } + + $this->SetMargins(); + + return true; + } //function SetXLabelHeight + + function SetYLabelWidth() { + //$ylab = sprintf("%6.1f %s",$i,$si_units[0]); //use for PHP2 compatibility + //the "." is for space. It isn't actually printed + $ylab = number_format($this->max_y, $this->y_precision, ".", ",") . $this->si_units . "."; + + if ($this->use_ttf == 1) { + $size = $this->TTFBBoxSize($this->axis_ttffont_size, 0, $this->axis_ttffont, $ylab); + } else { + $size[0] = StrLen($ylab) * $this->small_font_width * .6; + } + + $this->y_label_width = $size[0] * 2; +//echo "SYLW: $this->y_label_width
"; +//exit; + + $this->SetMargins(); + return true; + } + + function SetEqualXCoord() { + //for plots that have equally spaced x variables and multiple bars per x-point. + + $space = ($this->plot_area[2] - $this->plot_area[0]) / ($this->number_x_points * 2) * $this->group_frac_width; + $group_width = $space * 2; + $bar_width = $group_width / $this->records_per_group; + //I think that eventually this space variable will be replaced by just graphing x. + $this->data_group_space = $space; + $this->record_bar_width = $bar_width; + return true; + } + + function SetLabelScalePosition($which_blp) { + //0 to 1 + $this->label_scale_position = $which_blp; + return true; + } + + function SetErrorBarSize($which_ebs) { + //in pixels + $this->error_bar_size = $which_ebs; + return true; + } + + function SetErrorBarShape($which_ebs) { + //in pixels + $this->error_bar_shape = $which_ebs; + return true; + } + + function SetPointShape($which_pt) { + //in pixels + $this->point_shape = $which_pt; + return true; + } + + function SetPointSize($which_ps) { + //in pixels + SetType($which_ps,'integer'); + $this->point_size = $which_ps; + + if ($this->point_shape == "diamond" or $this->point_shape == "triangle") { + if ($this->point_size % 2 != 0) { + $this->point_size++; + } + } + return true; + } + + function SetDataType($which_dt) { + //The next three lines are for past compatibility. + if ($which_dt == "text-linear") { $which_dt = "text-data"; }; + if ($which_dt == "linear-linear") { $which_dt = "data-data"; }; + if ($which_dt == "linear-linear-error") { $which_dt = "data-data-error"; }; + + $this->data_type = $which_dt; //text-data, data-data, data-data-error + return true; + } + + function SetDataValues($which_dv) { + $this->data_values = $which_dv; +//echo $this->data_values + return true; + } + +//////////////COLORS + function SetRGBArray ($which_color_array) { + if ( is_array($which_color_array) ) { + //User Defined Array + $this->rgb_array = $which_color_array; + return true; + } elseif ($which_color_array == 2) { //Use the small predefined color array + $this->rgb_array = array( + "white" => array(255, 255, 255), + "snow" => array(255, 250, 250), + "PeachPuff" => array(255, 218, 185), + "ivory" => array(255, 255, 240), + "lavender" => array(230, 230, 250), + "black" => array( 0, 0, 0), + "DimGrey" => array(105, 105, 105), + "gray" => array(190, 190, 190), + "grey" => array(190, 190, 190), + "navy" => array( 0, 0, 128), + "SlateBlue" => array(106, 90, 205), + "blue" => array( 0, 0, 255), + "SkyBlue" => array(135, 206, 235), + "cyan" => array( 0, 255, 255), + "DarkGreen" => array( 0, 100, 0), + "green" => array( 0, 255, 0), + "YellowGreen" => array(154, 205, 50), + "yellow" => array(255, 255, 0), + "orange" => array(255, 165, 0), + "gold" => array(255, 215, 0), + "peru" => array(205, 133, 63), + "beige" => array(245, 245, 220), + "wheat" => array(245, 222, 179), + "tan" => array(210, 180, 140), + "brown" => array(165, 42, 42), + "salmon" => array(250, 128, 114), + "red" => array(255, 0, 0), + "pink" => array(255, 192, 203), + "maroon" => array(176, 48, 96), + "magenta" => array(255, 0, 255), + "violet" => array(238, 130, 238), + "plum" => array(221, 160, 221), + "orchid" => array(218, 112, 214), + "purple" => array(160, 32, 240), + "azure1" => array(240, 255, 255), + "aquamarine1" => array(127, 255, 212) + ); + return true; + } elseif ($which_color_array == 1) { + include("./rgb.inc.php"); //Get large $ColorArray + $this->rgb_array = $RGBArray; + } else { + $this->rgb_array = array("white" =>array(255,255,255), "black" => array(0,0,0)); + exit; + } + + return true; + } + + function SetColor($which_color) { + //obsoleted by SetRGBColor + SetRgbColor($which_color); + return true; + } + + function SetIndexColor($which_color) { //Color is passed in as anything + list ($r, $g, $b) = $this->SetRgbColor($which_color); //Translate to RGB + $index = ImageColorExact($this->img, $r, $g, $b); + if ($index == -1) { + //return ImageColorAllocate($this->img, $r, $g, $b); + //return ImageColorClosest($this->img, $r, $g, $b); + return ImageColorResolve($this->img, $r, $g, $b); //requires PHP 3.0.2 and later + } else { + return $index; + } + } + + function SetTransparentColor($which_color) { + ImageColorTransparent($this->img,$this->SetIndexColor($which_color)); + return true; + } + + function SetRgbColor($color_asked) { + //Returns an array in R,G,B format 0-255 + if ($color_asked == "") { $color_asked = array(0,0,0); }; + + if ( count($color_asked) == 3 ) { //already array of 3 rgb + $ret_val = $color_asked; + } else { // is asking for a color by string + if(substr($color_asked,0,1) == "#") { //asking in #FFFFFF format. + $ret_val = array(hexdec(substr($color_asked,1,2)), hexdec(substr($color_asked,3,2)), hexdec(substr($color,5,2))); + } else { + $ret_val = $this->rgb_array[$color_asked]; + } + } + return $ret_val; + } + + function SetDataColors($which_data,$which_border) { + //Set the data to be displayed in a particular color + if (!$which_data) { + $which_data = array(array(0,255,0),array(0,0,248),'yellow',array(255,0,0),'orange'); + $which_border = array('black'); + } + + $this->data_color = $which_data; //an array + $this->data_border_color = $which_border; //an array + + unset($this->ndx_data_color); + reset($this->data_color); //data_color can be an array of colors, one for each thing plotted + //while (list(, $col) = each($this->data_color)) + $i = 0; + while (list(, $col) = each($which_data)) { + $this->ndx_data_color[$i] = $this->SetIndexColor($col); + $i++; + } + + // border_color + //If we are also going to put a border on the data (bars, dots, area, ...) + // then lets also set a border color as well. + //foreach($this->data_border_color as $col) + unset($this->ndx_data_border_color); + reset($this->data_border_color); + $i = 0; + while (list(, $col) = each($this->data_border_color)) { + $this->ndx_data_border_color[$i] = $this->SetIndexColor($col); + $i++; + } + + //Set color of the error bars to be that of data if not already set. + if (!$this->error_bar_color) { + reset($which_data); + $this->SetErrorBarColors($which_data); + } + + return true; + + } //function SetDataColors + + function SetErrorBarColors($which_data) { + + //Set the data to be displayed in a particular color + + if ($which_data) { + $this->error_bar_color = $which_data; //an array + unset($this->ndx_error_bar_color); + reset($this->error_bar_color); //data_color can be an array of colors, one for each thing plotted + $i = 0; + while (list(, $col) = each($this->error_bar_color)) { + $this->ndx_error_bar_color[$i] = $this->SetIndexColor($col); + $i++; + } + return true; + } + return false; + } //function SetErrorBarColors + + + function DrawPlotBorder() { + switch ($this->plot_border_type) { + case "left" : + ImageLine($this->img, $this->plot_area[0],$this->ytr($this->plot_min_y), + $this->plot_area[0],$this->ytr($this->plot_max_y),$this->ndx_grid_color); + break; + case "none": + //Draw No Border + break; + default: + ImageRectangle($this->img, $this->plot_area[0],$this->ytr($this->plot_min_y), + $this->plot_area[2],$this->ytr($this->plot_max_y),$this->ndx_grid_color); + break; + } + $this->DrawYAxis(); + $this->DrawXAxis(); + return true; + } + + + function SetHorizTickIncrement($which_ti) { + //Use either this or NumHorizTicks to set where to place x tick marks + if ($which_ti) { + $this->horiz_tick_increment = $which_ti; //world coordinates + } else { + if (!$this->max_x) { + $this->FindDataLimits(); //Get maxima and minima for scaling + } + //$this->horiz_tick_increment = ( ceil($this->max_x * 1.2) - floor($this->min_x * 1.2) )/10; + $this->horiz_tick_increment = ($this->plot_max_x - $this->plot_min_x )/10; + } + $this->num_horiz_ticks = ''; //either use num_vert_ticks or vert_tick_increment, not both + return true; + } + + function SetDrawVertTicks($which_dvt) { + $this->draw_vert_ticks = $which_dvt; + return true; + } + + function SetVertTickIncrement($which_ti) { + //Use either this or NumVertTicks to set where to place y tick marks + if ($which_ti) { + $this->vert_tick_increment = $which_ti; //world coordinates + } else { + if (!$this->max_y) { + $this->FindDataLimits(); //Get maxima and minima for scaling + } + //$this->vert_tick_increment = ( ceil($this->max_y * 1.2) - floor($this->min_y * 1.2) )/10; + $this->vert_tick_increment = ($this->plot_max_y - $this->plot_min_y )/10; + } + $this->num_vert_ticks = ''; //either use num_vert_ticks or vert_tick_increment, not both + return true; + } + + function SetNumHorizTicks($which_nt) { + $this->num_horiz_ticks = $which_nt; + $this->horiz_tick_increment = ''; //either use num_horiz_ticks or horiz_tick_increment, not both + return true; + } + + function SetNumVertTicks($which_nt) { + $this->num_vert_ticks = $which_nt; + $this->vert_tick_increment = ''; //either use num_vert_ticks or vert_tick_increment, not both + return true; + } + function SetVertTickPosition($which_tp) { + $this->vert_tick_position = $which_tp; //plotleft, plotright, both, yaxis + return true; + } + function SetSkipBottomTick($which_sbt) { + $this->skip_bottom_tick = $which_sbt; + return true; + } + + function SetTickLength($which_tl) { + $this->tick_length = $which_tl; + return true; + } + + function DrawYAxis() { + //Draw Line at left side or at this->y_axis_position + if ($this->y_axis_position != "") { + $yaxis_x = $this->xtr($this->y_axis_position); + } else { + $yaxis_x = $this->plot_area[0]; + } + + ImageLine($this->img, $yaxis_x, $this->plot_area[1], + $yaxis_x, $this->plot_area[3], $this->ndx_grid_color); + //$yaxis_x, $this->plot_area[3], 9); + + if ($this->draw_vert_ticks == 1) { + $this->DrawVerticalTicks(); + } + + } //function DrawYAxis + + function DrawXAxis() { + //Draw Tick and Label for Y axis + $ylab =$this->FormatYTickLabel($this->x_axis_position); + if ($this->skip_bottom_tick != 1) { + $this->DrawVerticalTick($ylab,$this->x_axis_position); + } + + //Draw X Axis at Y=$x_axis_postion + ImageLine($this->img,$this->plot_area[0]+1,$this->ytr($this->x_axis_position), + $this->xtr($this->plot_max_x)-1,$this->ytr($this->x_axis_position),$this->ndx_tick_color); + + //X Ticks and Labels + if ($this->data_type != 'text-data') { //labels for text-data done at data drawing time for speed. + $this->DrawHorizontalTicks(); + } + return true; + } + + function DrawHorizontalTicks() { + //Ticks and lables are drawn on the left border of PlotArea. + //Left Bottom + ImageLine($this->img,$this->plot_area[0], + $this->plot_area[3]+$this->tick_length, + $this->plot_area[0],$this->plot_area[3],$this->ndx_tick_color); + + switch ($this->x_grid_label_type) { + case "title": + $xlab = $this->data_values[0][0]; + break; + case "data": + $xlab = number_format($this->plot_min_x,$this->x_precision,".",",") . "$this->si_units"; + break; + case "none": + $xlab = ''; + break; + case "time": //Time formatting suggested by Marlin Viss + $xlab = strftime($this->x_time_format,$this->plot_min_x); + break; + default: + //Unchanged from whatever format is passed in + $xlab = $this->plot_min_x; + break; + } + + if ($this->x_datalabel_angle == 90) { + $xpos = $this->plot_area[0] - $this->small_font_height/2; + $ypos = ( $this->small_font_width*strlen($xlab) + $this->plot_area[3] + $this->small_font_height); + ImageStringUp($this->img, $this->small_font,$xpos, $ypos, $xlab, $this->ndx_text_color); + } else { + $xpos = $this->plot_area[0] - $this->small_font_width*strlen($xlab)/2 ; + $ypos = $this->plot_area[3] + $this->small_font_height; + ImageString($this->img, $this->small_font,$xpos, $ypos, $xlab, $this->ndx_text_color); + } + + //Will be changed to allow for TTF fonts in data as well. + //$this->DrawText($this->small_font, $this->x_datalabel_angle, $xpos, $ypos, $this->ndx_title_color, '', $xlab); + + //Top + + if ($this->horiz_tick_increment) { + $delta_x = $this->horiz_tick_increment; + } elseif ($this->num_horiz_ticks) { + $delta_x = ($this->plot_max_x - $this->plot_min_x) / $this->num_horiz_ticks; + } else { + $delta_x =($this->plot_max_x - $this->plot_min_x) / 10 ; + } + + $i = 0; + $x_tmp = $this->plot_min_x; + SetType($x_tmp,'double'); + + while ($x_tmp <= $this->plot_max_x){ + //$xlab = sprintf("%6.1f %s",$min_x,$si_units[0]); //PHP2 past compatibility + switch ($this->x_grid_label_type) { + case "title": + $xlab = $this->data_values[$x_tmp][0]; + break; + case "data": + $xlab = number_format($x_tmp,$this->x_precision,".",",") . "$this->si_units"; + break; + case "none": + $xlab = ''; + break; + case "time": //Time formatting suggested by Marlin Viss + $xlab = strftime($this->x_time_format,$x_tmp); + break; + default: + //Unchanged from whatever format is passed in + $xlab = $x_tmp; + break; + } + + $x_pixels = $this->xtr($x_tmp); + + //Bottom Tick + ImageLine($this->img,$x_pixels,$this->plot_area[3] + $this->tick_length, + $x_pixels,$this->plot_area[3], $this->ndx_tick_color); + //Top Tick + //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length), + // $y_pixels,$this->xtr($this->plot_max_x)-1,$y_pixels,$this->ndx_tick_color); + + if ($this->draw_x_grid == 1) { + ImageLine($this->img,$x_pixels,$this->plot_area[1], + $x_pixels,$this->plot_area[3], $this->ndx_light_grid_color); + } + + if ($this->x_datalabel_angle == 90) { //Vertical Code Submitted by Marlin Viss + ImageStringUp($this->img, $this->small_font, + ( $x_pixels - $this->small_font_height/2), + ( $this->small_font_width*strlen($xlab) + $this->plot_area[3] + $this->small_font_height),$xlab, $this->ndx_text_color); + } else { + ImageString($this->img, $this->small_font, + ( $x_pixels - $this->small_font_width*strlen($xlab)/2) , + ( $this->small_font_height + $this->plot_area[3]),$xlab, $this->ndx_text_color); + } + + $i++; + $x_tmp += $delta_x; + } + + } // function DrawHorizontalTicks + + function FormatYTickLabel($which_ylab) { + switch ($this->y_grid_label_type) { + case "data": + $ylab = number_format($which_ylab,$this->y_precision,".",",") . "$this->si_units"; + break; + case "none": + $ylab = ''; + break; + case "time": + $ylab = strftime($this->y_time_format,$which_ylab); + break; + case "right": + //Make it right aligned + //$ylab = str_pad($which_ylab,$this->y_label_width," ",STR_PAD_LEFT); //PHP4 only + $sstr = "%".strlen($this->plot_max_y)."s"; + $ylab = sprintf($sstr,$which_ylab); + break; + default: + //Unchanged from whatever format is passed in + $ylab = $which_ylab; + break; + } + + return($ylab); + + } //function FormatYTickLabel + + function DrawVerticalTick($which_ylab,$which_ypos) { //ylab in world coord. + //Draw Just one Tick, called from DrawVerticalTicks + //Ticks and datalables can be left of plot only, right of plot only, + // both on the left and right of plot, or crossing a user defined Y-axis + // + //Its faster to draw both left and right ticks at same time + // than first left and then right. + + if ($this->y_axis_position != "") { + //Ticks and lables are drawn on the left border of yaxis + $yaxis_x = $this->xtr($this->y_axis_position); + } else { + //Ticks and lables are drawn on the left border of PlotArea. + $yaxis_x = $this->plot_area[0]; + } + + $y_pixels = $this->ytr($which_ypos); + + //Lines Across the Plot Area + if ($this->draw_y_grid == 1) { + ImageLine($this->img,$this->plot_area[0]+1,$y_pixels, + $this->plot_area[2]-1,$y_pixels,$this->ndx_light_grid_color); + } + + //Ticks to the Left of the Plot Area + if (($this->vert_tick_position == "plotleft") || ($this->vert_tick_position == "both") ) { + ImageLine($this->img,(-$this->tick_length+$yaxis_x), + $y_pixels,$yaxis_x, + $y_pixels, $this->ndx_tick_color); + } + + //Ticks to the Right of the Plot Area + if (($this->vert_tick_position == "plotright") || ($this->vert_tick_position == "both") ) { + ImageLine($this->img,($this->plot_area[2]+$this->tick_length), + $y_pixels,$this->plot_area[2], + $y_pixels,$this->ndx_tick_color); + } + + //Ticks on the Y Axis + if (($this->vert_tick_position == "yaxis") ) { + ImageLine($this->img,($yaxis_x - $this->tick_length), + $y_pixels,$yaxis_x,$y_pixels,$this->ndx_tick_color); + } + + //DataLabel +//ajo working + //$this->DrawText($this->y_label_ttffont, 0,($yaxis_x - $this->y_label_width - $this->tick_length/2), + // $y_pixels, $this->ndx_text_color, $this->axis_ttffont_size, $which_ylab); + ImageString($this->img, $this->small_font, ($yaxis_x - $this->y_label_width - $this->tick_length/2), + ( -($this->small_font_height/2.0) + $y_pixels),$which_ylab, $this->ndx_text_color); + } + + function DrawVerticalTicks() { + + if ($this->skip_top_tick != 1) { //If tick increment doesn't hit the top + //Left Top + //ImageLine($this->img,(-$this->tick_length+$this->xtr($this->plot_min_x)), + // $this->ytr($this->plot_max_y),$this->xtr($this->plot_min_x),$this->ytr($this->plot_max_y),$this->ndx_tick_color); + //$ylab = $this->FormatYTickLabel($plot_max_y); + + //Right Top + //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length), + // $this->ytr($this->plot_max_y),$this->xtr($this->plot_max_x-1),$this->ytr($this->plot_max_y),$this->ndx_tick_color); + + //Draw Grid Line at Top + ImageLine($this->img,$this->plot_area[0]+1,$this->ytr($this->plot_max_y), + $this->plot_area[2]-1,$this->ytr($this->plot_max_y),$this->ndx_light_grid_color); + + } + + if ($this->skip_bottom_tick != 1) { + //Right Bottom + //ImageLine($this->img,($this->xtr($this->plot_max_x)+$this->tick_length), + // $this->ytr($this->plot_min_y),$this->xtr($this->plot_max_x), + // $this->ytr($this->plot_min_y),$this->ndx_tick_color); + + //Draw Grid Line at Bottom of Plot + ImageLine($this->img,$this->xtr($this->plot_min_x)+1,$this->ytr($this->plot_min_y), + $this->xtr($this->plot_max_x),$this->ytr($this->plot_min_y),$this->ndx_light_grid_color); + } + + // maxy is always > miny so delta_y is always positive + if ($this->vert_tick_increment) { + $delta_y = $this->vert_tick_increment; + } elseif ($this->num_vert_ticks) { + $delta_y = ($this->plot_max_y - $this->plot_min_y) / $this->num_vert_ticks; + } else { + $delta_y =($this->plot_max_y - $this->plot_min_y) / 10 ; + } + + $y_tmp = $this->plot_min_y; + SetType($y_tmp,'double'); + if ($this->skip_bottom_tick == 1) { + $y_tmp += $delta_y; + } + + while ($y_tmp <= $this->plot_max_y){ + //For log plots: + if (($this->yscale_type == "log") && ($this->plot_min_y == 1) && + ($delta_y%10 == 0) && ($y_tmp == $this->plot_min_y)) { + $y_tmp = $y_tmp - 1; //Set first increment to 9 to get: 1,10,20,30,... + } + + $ylab = $this->FormatYTickLabel($y_tmp); + + $this->DrawVerticalTick($ylab,$y_tmp); + + $y_tmp += $delta_y; + } + + return true; + + } // function DrawVerticalTicks + + function SetTranslation() { + if ($this->xscale_type == "log") { + $this->xscale = ($this->plot_area_width)/(log10($this->plot_max_x) - log10($this->plot_min_x)); + } else { + $this->xscale = ($this->plot_area_width)/($this->plot_max_x - $this->plot_min_x); + } + if ($this->yscale_type == "log") { + $this->yscale = ($this->plot_area_height)/(log10($this->plot_max_y) - log10($this->plot_min_y)); + } else { + $this->yscale = ($this->plot_area_height)/($this->plot_max_y - $this->plot_min_y); + } + + // GD defines x=0 at left and y=0 at TOP so -/+ respectively + if ($this->xscale_type == "log") { + $this->plot_origin_x = $this->plot_area[0] - ($this->xscale * log10($this->plot_min_x) ); + } else { + $this->plot_origin_x = $this->plot_area[0] - ($this->xscale * $this->plot_min_x); + } + if ($this->yscale_type == "log") { + $this->plot_origin_y = $this->plot_area[3] + ($this->yscale * log10($this->plot_min_y)); + } else { + $this->plot_origin_y = $this->plot_area[3] + ($this->yscale * $this->plot_min_y); + } + + $this->scale_is_set = 1; + } // function SetTranslation + + function xtr($x_world) { + //Translate world coordinates into pixel coordinates + //The pixel coordinates are those of the ENTIRE image, not just the plot_area + //$x_pixels = $this->x_left_margin + ($this->image_width - $this->x_tot_margin)*(($x_world - $this->plot_min_x) / ($this->plot_max_x - $this->plot_min_x)) ; + //which with a little bit of math reduces to ... + if ($this->xscale_type == "log") { + $x_pixels = $this->plot_origin_x + log10($x_world) * $this->xscale ; + } else { + $x_pixels = $this->plot_origin_x + $x_world * $this->xscale ; + } + return($x_pixels); + } + + function ytr($y_world) { + // translate y world coord into pixel coord + if ($this->yscale_type == "log") { + $y_pixels = $this->plot_origin_y - log10($y_world) * $this->yscale ; //minus because GD defines y=0 at top. doh! + } else { + $y_pixels = $this->plot_origin_y - $y_world * $this->yscale ; + } + return ($y_pixels); + } + + + function DrawDataLabel($lab,$x_world,$y_world) { + //Depreciated. Use DrawText Instead. + //Data comes in in WORLD coordinates + //Draw data label near actual data point + //$y = $this->ytr($y_world) ; //in pixels + //$x = $this->xtr($x_world) ; + //$this->DrawText($which_font,$which_angle,$which_xpos,$which_ypos,$which_color,$which_size,$which_text,$which_halign='left'); + if ($this->use_ttf) { +//ajjjo + $lab_size = $this->TTFBBoxSize($this->axis_ttffont_size, $this->x_datalabel_angle, $this->axis_ttffont, $lab); //An array + $y = $this->ytr($y_world) - $lab_size[1] ; //in pixels + $x = $this->xtr($x_world) - $lab_size[0]/2; + ImageTTFText($this->img, $this->axis_ttffont_size, $this->x_datalabel_angle, $x, $y, $this->ndx_text_color, $this->axis_ttffont, $lab); + } else { + $lab_size = array($this->small_font_width*StrLen($lab), $this->small_font_height*3); + if ($this->x_datalabel_angle == 90) { + $y = $this->ytr($y_world) - $this->small_font_width*StrLen($lab); //in pixels + $x = $this->xtr($x_world) - $this->small_font_height; + ImageStringUp($this->img, $this->small_font,$x, $y ,$lab, $this->ndx_text_color); + } else { + $y = $this->ytr($y_world) - $this->small_font_height; //in pixels + $x = $this->xtr($x_world) - ($this->small_font_width*StrLen($lab))/2; + ImageString($this->img, $this->small_font,$x, $y ,$lab, $this->ndx_text_color); + } + } + + } + + function DrawXDataLabel($xlab,$xpos) { + //xpos comes in in PIXELS not in world coordinates. + //Draw an x data label centered at xlab + if ($this->use_ttf) { + $xlab_size = $this->TTFBBoxSize($this->axis_ttffont_size, + $this->x_datalabel_angle, $this->axis_ttffont, $xlab); //An array + $y = $this->plot_area[3] + $xlab_size[1] + 4; //in pixels + $x = $xpos - $xlab_size[0]/2; + ImageTTFText($this->img, $this->axis_ttffont_size, + $this->x_datalabel_angle, $x, $y, $this->ndx_text_color, $this->axis_ttffont, $xlab); + } else { + $xlab_size = array(ImageFontWidth($this->axis_font)*StrLen($xlab), $this->small_font_height*3); + if ($this->x_datalabel_angle == 90) { + $y = $this->plot_area[3] + ImageFontWidth($this->axis_font)*StrLen($xlab); //in pixels + $x = $xpos - ($this->small_font_height); + ImageStringUp($this->img, $this->axis_font,$x, $y ,$xlab, $this->ndx_text_color); + } else { + $y = $this->plot_area[3] + ImageFontHeight($this->axis_font); //in pixels + $x = $xpos - (ImageFontWidth($this->axis_font)*StrLen($xlab))/2; + ImageString($this->img, $this->axis_font,$x, $y ,$xlab, $this->ndx_text_color); + } + } + + } + + function DrawPieChart() { + //$pi = '3.14159265358979323846'; + $xpos = $this->plot_area[0] + $this->plot_area_width/2; + $ypos = $this->plot_area[1] + $this->plot_area_height/2; + $diameter = (min($this->plot_area_width, $this->plot_area_height)) ; + $radius = $diameter/2; + + ImageArc($this->img, $xpos, $ypos, $diameter, $diameter, 0, 360, $this->ndx_grid_color); + + $total = 0; + reset($this->data_values); + $tmp = $this->number_x_points - 1; + while (list($j, $row) = each($this->data_values)) { + //Get sum of each type + $color_index = 0; + $i = 0; + //foreach ($row as $v) + while (list($k, $v) = each($row)) { + if ($k != 0) { + if ($j == 0) { + $sumarr[$i] = $v; + } elseif ($j < $tmp) { + $sumarr[$i] += $v; + } else { + $sumarr[$i] += $v; + // NOTE! sum > 0 to make pie charts + $sumarr[$i] = abs($sumarr[$i]); + $total += $sumarr[$i]; + } + } + $i++; + } + } + + $color_index = 0; + $start_angle = 0; + + reset($sumarr); + $end_angle = 0; + while (list(, $val) = each($sumarr)) { + if ($color_index >= count($this->ndx_data_color)) $color_index=0; //data_color = array + $label_txt = number_format(($val / $total * 100), $this->y_precision, ".", ",") . "%"; + $val = 360 * ($val / $total); + + $end_angle += $val; + $mid_angle = $end_angle - ($val / 2); + + $slicecol = $this->ndx_data_color[$color_index]; + +//Need this again for FillToBorder + ImageArc($this->img, $xpos, $ypos, $diameter, $diameter, 0, 360, $this->ndx_grid_color); + + $out_x = $radius * cos(deg2rad($end_angle)); + $out_y = - $radius * sin(deg2rad($end_angle)); + + $mid_x = $xpos + ($radius/2 * cos(deg2rad($mid_angle))) ; + $mid_y = $ypos + (- $radius/2 * sin(deg2rad($mid_angle))); + + $label_x = $xpos + ($radius * cos(deg2rad($mid_angle))) * $this->label_scale_position; + $label_y = $ypos + (- $radius * sin(deg2rad($mid_angle))) * $this->label_scale_position; + + $out_x = $xpos + $out_x; + $out_y = $ypos + $out_y; + + ImageLine($this->img, $xpos, $ypos, $out_x, $out_y, $this->ndx_grid_color); + //ImageLine($this->img, $xpos, $ypos, $label_x, $label_y, $this->ndx_grid_color); + ImageFillToBorder($this->img, $mid_x, $mid_y, $this->ndx_grid_color, $slicecol); + + if ($this->use_ttf) { + ImageTTFText($this->img, $this->axis_ttffont_size, 0, $label_x, $label_y, $this->ndx_grid_color, $this->axis_ttffont, $label_txt); + } else { + ImageString($this->img, $this->small_font, $label_x, $label_y, $label_txt, $this->ndx_grid_color); + } + + $start_angle = $val; + + $color_index++; + } + + } + + function DrawLinesError() { + //Draw Lines with Error Bars - data comes in as array("title",x,y,error+,error-,y2,error2+,error2-,...); + $start_lines = 0; + + reset($this->data_values); + while (list(, $row) = each($this->data_values)) { + $color_index = 0; + $i = 0; + + while (list($key, $val) = each($row)) { +//echo "$key, $i, $val
"; + if ($key == 0) { + $lab = $val; + } elseif ($key == 1) { + $x_now = $val; + $x_now_pixels = $this->xtr($x_now); //Use a bit more memory to save 2N operations. + } elseif ($key%3 == 2) { + $y_now = $val; + $y_now_pixels = $this->ytr($y_now); + + //Draw Data Label + if ( $this->draw_data_labels == 1) { + $this->DrawDataLabel($lab,$x_now,$y_now); + } + + if ($color_index >= count($this->ndx_data_color)) { $color_index=0;}; + $barcol = $this->ndx_data_color[$color_index]; + $error_barcol = $this->ndx_error_bar_color[$color_index]; + +//echo "start = $start_lines
"; + if ($start_lines == 1) { + for ($width = 0; $width < $this->line_width; $width++) { + ImageLine($this->img, $x_now_pixels, $y_now_pixels + $width, + $lastx[$i], $lasty[$i] + $width, $barcol); + } + } + + $lastx[$i] = $x_now_pixels; + $lasty[$i] = $y_now_pixels; + $color_index++; + $i++; + $start_lines = 1; + } elseif ($key%3 == 0) { + $this->DrawYErrorBar($x_now,$y_now,$val,$this->error_bar_shape,$error_barcol); + } elseif ($key%3 == 1) { + $this->DrawYErrorBar($x_now,$y_now,-$val,$this->error_bar_shape,$error_barcol); + } + } + } + } + + function DrawDotsError() { + //Draw Dots - data comes in as array("title",x,y,error+,error-,y2,error2+,error2-,...); + reset($this->data_values); + while (list(, $row) = each($this->data_values)) { + $color_index = 0; + //foreach ($row as $v) + while (list($key, $val) = each($row)) { + if ($key == 0) { + } elseif ($key == 1) { + $xpos = $val; + } elseif ($key%3 == 2) { + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + $barcol = $this->ndx_data_color[$color_index]; + $error_barcol = $this->ndx_error_bar_color[$color_index]; + $ypos = $val; + + $color_index++; + $this->DrawDot($xpos,$ypos,$this->point_shape,$barcol); + } elseif ($key%3 == 0) { + $this->DrawYErrorBar($xpos,$ypos,$val,$this->error_bar_shape,$error_barcol); + } elseif ($key%3 == 1) { + $mine = $val ; + $this->DrawYErrorBar($xpos,$ypos,-$val,$this->error_bar_shape,$error_barcol); + } + } + } + + } + + function DrawDots() { + //Draw Dots - data comes in as array("title",x,y1,y2,y3,...); + reset($this->data_values); + while (list($j, $row) = each($this->data_values)) { + $color_index = 0; + //foreach ($row as $v) + while (list($k, $v) = each($row)) { + if ($k == 0) { + } elseif (($k == 1) && ($this->data_type == "data-data")) { + $xpos = $v; + } else { + if ($this->data_type == "text-data") { + $xpos = ($j+.5); + } + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + $barcol = $this->ndx_data_color[$color_index]; + + //if (is_numeric($v)) //PHP4 only + if ((strval($v) != "") ) { //Allow for missing Y data + $this->DrawDot($xpos,$v,$this->point_shape,$barcol); + } + $color_index++; + } + } + } + + } //function DrawDots + + function DrawDotSeries() { + //Depreciated: Use DrawDots + $this->DrawDots(); + } + + function DrawThinBarLines() { + //A clean,fast routine for when you just want charts like stock volume charts + //Data must be text-data since I didn't see a graphing need for equally spaced thin lines. + //If you want it - then write to afan@jeo.net and I might add it. + + if ($this->data_type != "data-data") { $this->DrawError('Data Type for ThinBarLines must be data-data'); }; + $y1 = $this->ytr($this->x_axis_position); + + reset($this->data_values); + while (list(, $row) = each($this->data_values)) { + $color_index = 0; + while (list($k, $v) = each($row)) { + if ($k == 0) { + $xlab = $v; + } elseif ($k == 1) { + $xpos = $this->xtr($v); + if ( ($this->draw_x_data_labels == 1) ) { //See "labels_note1 above. + $this->DrawXDataLabel($xlab,$xpos); + } + } else { + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + $barcol = $this->ndx_data_color[$color_index]; + + ImageLine($this->img,$xpos,$y1,$xpos,$this->ytr($v),$barcol); + $color_index++; + } + } + } + + } //function DrawThinBarLines + + function DrawYErrorBar($x_world,$y_world,$error_height,$error_bar_type,$color) { + $x1 = $this->xtr($x_world); + $y1 = $this->ytr($y_world); + $y2 = $this->ytr($y_world+$error_height) ; + + for ($width = 0; $width < $this->error_bar_line_width; $width++) { + ImageLine($this->img, $x1+$width, $y1 , $x1+$width, $y2, $color); + ImageLine($this->img, $x1-$width, $y1 , $x1-$width, $y2, $color); + } + switch ($error_bar_type) { + case "line": + break; + case "tee": + ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color); + break; + default: + ImageLine($this->img, $x1-$this->error_bar_size, $y2, $x1+$this->error_bar_size, $y2, $color); + break; + } + return true; + } + + function DrawDot($x_world,$y_world,$dot_type,$color) { + $half_point = $this->point_size / 2; + $x1 = $this->xtr($x_world) - $half_point; + $x2 = $this->xtr($x_world) + $half_point; + $y1 = $this->ytr($y_world) - $half_point; + $y2 = $this->ytr($y_world) + $half_point; + + switch ($dot_type) { + case "halfline": + ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $this->xtr($x_world), $this->ytr($y_world), $color); + break; + case "line": + ImageFilledRectangle($this->img, $x1, $this->ytr($y_world), $x2, $this->ytr($y_world), $color); + break; + case "rect": + ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color); + break; + case "circle": + ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color); + break; + case "dot": + ImageArc($this->img, $x1 + $half_point, $y1 + $half_point, $this->point_size, $this->point_size, 0, 360, $color); + ImageFillToBorder($this->img, $x1 + $half_point, $y1 + $half_point, $color, $color); + break; + case "diamond": + + $arrpoints = array( + $x1,$y1 + $half_point, + $x1 + $half_point, $y1, + $x2,$y1 + $half_point, + $x1 + $half_point, $y2 + ); + + ImageFilledPolygon($this->img, $arrpoints, 4, $color); + break; + case "triangle": + $arrpoints = array( $x1, $y1 + $half_point, + $x2, $y1 + $half_point, + $x1 + $half_point, $y2 + ); + ImageFilledPolygon($this->img, $arrpoints, 3, $color); + break; + default: + ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $color); + break; + } + return true; + } + + function SetErrorBarLineWidth($which_seblw) { + $this->error_bar_line_width = $which_seblw; + return true; + } + + + function SetLineWidth($which_lw) { + $this->line_width = $which_lw; + if (!$this->error_bar_line_width) { + $this->error_bar_line_width = $which_lw; + } + return true; + } + + function DrawArea() { + //Data comes in as $data[]=("title",x,y,...); + //Set first and last datapoints of area + $i = 0; + while ($i < $this->records_per_group) { + $posarr[$i][] = $this->xtr($this->min_x); //x initial + $posarr[$i][] = $this->ytr($this->x_axis_position); //y initial + $i++; + } + + reset($this->data_values); + while (list($j, $row) = each($this->data_values)) { + $color_index = 0; + //foreach ($row as $v) + while (list($k, $v) = each($row)) { + if ($k == 0) { + //Draw Data Labels + $xlab = SubStr($v,0,$this->x_datalabel_maxlength); + } elseif ($k == 1) { + $x = $this->xtr($v); + // DrawXDataLabel interferes with Numbers on x-axis + //$this->DrawXDataLabel($xlab,$x); + } else { + // Create Array of points for later + + $y = $this->ytr($v); + $posarr[$color_index][] = $x; + $posarr[$color_index][] = $y; + $color_index++; + } + } + } + + //Final_points + for ($i = 0; $i < $this->records_per_group; $i++) { + $posarr[$i][] = $this->xtr($this->max_x); //x final + $posarr[$i][] = $this->ytr($this->x_axis_position); //y final + } + + $color_index=0; + + //foreach($posarr as $row) + reset($posarr); + while (list(, $row) = each($posarr)) { + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + $barcol = $this->ndx_data_color[$color_index]; +//echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11],$row[12], $barcol
"; + ImageFilledPolygon($this->img, $row, (count($row)) / 2, $barcol); + $color_index++; + } +//exit; + + } + + function DrawAreaSeries() { + + //Set first and last datapoints of area + $i = 0; + while ($i < $this->records_per_group) { + $posarr[$i][] = $this->xtr(.5); //x initial + $posarr[$i][] = $this->ytr($this->x_axis_position); //y initial + $i++; + } + + reset($this->data_values); + while (list($j, $row) = each($this->data_values)) { + $color_index = 0; + //foreach ($row as $v) + while (list($k, $v) = each($row)) { + if ($k == 0) { + //Draw Data Labels + $xlab = SubStr($v,0,$this->x_datalabel_maxlength); + $this->DrawXDataLabel($xlab,$this->xtr($j + .5)); + } else { + // Create Array of points for later + + $x = round($this->xtr($j + .5 )); + $y = round($this->ytr($v)); + $posarr[$color_index][] = $x; + $posarr[$color_index][] = $y; + $color_index++; + } + } + } + + //Final_points + for ($i = 0; $i < $this->records_per_group; $i++) { + $posarr[$i][] = round($this->xtr($this->max_x + .5)); //x final + $posarr[$i][] = $this->ytr($this->x_axis_position); //y final + } + + $color_index=0; + + //foreach($posarr as $row) + reset($posarr); + while (list(, $row) = each($posarr)) { + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + $barcol = $this->ndx_data_color[$color_index]; +//echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11],$row[12], $barcol
"; + ImageFilledPolygon($this->img, $row, (count($row)) / 2, $barcol); + $color_index++; + } + + } + + function DrawLines() { + //Data comes in as $data[]=("title",x,y,...); + $start_lines = 0; + if ($this->data_type == "text-data") { + $lastx[0] = $this->xtr(0); + $lasty[0] = $this->xtr(0); + } + + //foreach ($this->data_values as $row) + reset($this->data_values); + while (list($j, $row) = each($this->data_values)) { + + $color_index = 0; + $i = 0; + //foreach ($row as $v) + while (list($k, $v) = each($row)) { + if ($k == 0) { + $xlab = SubStr($v,0,$this->x_datalabel_maxlength); + } elseif (($k == 1) && ($this->data_type == "data-data")) { + $x_now = $this->xtr($v); + } else { + //(double) $v; + // Draw Lines + if ($this->data_type == "text-data") { + $x_now = $this->xtr($j+.5); + } + + //if (is_numeric($v)) //PHP4 only + if ((strval($v) != "") ) { //Allow for missing Y data + $y_now = $this->ytr($v); + if ($color_index >= count($this->ndx_data_color)) { $color_index=0;} ; + $barcol = $this->ndx_data_color[$color_index]; + + if ($start_lines == 1) { + for ($width = 0; $width < $this->line_width; $width++) { + if ($this->line_style[$i] == "dashed") { + $this->DrawDashedLine($x_now, $y_now + $width, $lastx[$i], $lasty[$i] + $width, 4,4, $barcol); + } else { + ImageLine($this->img, $x_now, $y_now + $width, $lastx[$i], $lasty[$i] + $width, $barcol); + } + } + } + $lastx[$i] = $x_now; + } else { + $y_now = $lasty[$i]; + //Don't increment lastx[$i] + } + //$bordercol = $this->ndx_data_border_color[$colbarcount]; + + $lasty[$i] = $y_now; + $color_index++; + $i++; + } + //Now we are assured an x_value + if ( ($this->draw_x_data_labels == 1) && ($k == 1) ) { //See "labels_note1 above. + $this->DrawXDataLabel($xlab,$x_now); + } + } //while rows of data + $start_lines = 1; + } + } + + //Data comes in as $data[]=("title",x,y,e+,e-,y2,e2+,e2-,...); + + function DrawLineSeries() { + //This function is replaced by DrawLines + //Tests have shown not much improvement in speed by having separate routines for DrawLineSeries and DrawLines + //For ease of programming I have combined them + return false; + } //function DrawLineSeries + + function DrawDashedLine($x1pix,$y1pix,$x2pix,$y2pix,$dash_length,$dash_space,$color) { + //Code based on work by Ariel Garza and James Pine + //I've decided to have this be in pixels only as a replacement for ImageLine + //$x1pix = $this->xtr($x1); + //$y1pix = $this->ytr($y1); + //$x2pix = $this->xtr($x2); + //$y2pix = $this->ytr($y2); + + // Get the length of the line in pixels + $line_length = ceil (sqrt(pow(($x2pix - $x1pix),2) + pow(($y2pix - $y1pix),2)) ); + + $dx = ($x2pix - $x1pix) / $line_length; + $dy = ($y2pix - $y1pix) / $line_length; + $lastx = $x1pix; + $lasty = $y1pix; + + // Draw the dashed line + for ($i = 0; $i < $line_length; $i += ($dash_length + $dash_space)) { + $xpix = ($dash_length * $dx) + $lastx; + $ypix = ($dash_length * $dy) + $lasty; + + ImageLine($this->img,$lastx,$lasty,$xpix,$ypix,$color); + $lastx = $xpix + ($dash_space * $dx); + $lasty = $ypix + ($dash_space * $dy); + } + } // function DrawDashedLine + + function DrawBars() { + + if ($this->data_type != "text-data") { + $this->DrawError('Bar plots must be text-data: use function SetDataType("text-data")'); + } + + $xadjust = ($this->records_per_group * $this->record_bar_width )/4; + + reset($this->data_values); + while (list($j, $row) = each($this->data_values)) { + + $color_index = 0; + $colbarcount = 0; + $x_now = $this->xtr($j+.5); + + while (list($k, $v) = each($row)) { + if ($k == 0) { + //Draw Data Labels + $xlab = SubStr($v,0,$this->x_datalabel_maxlength); + $this->DrawXDataLabel($xlab,$x_now); + } else { + // Draw Bars ($v) + $x1 = $x_now - $this->data_group_space + ($k-1)*$this->record_bar_width; + $x2 = $x1 + $this->record_bar_width*$this->bar_width_adjust; + + if ($v < $this->x_axis_position) { + $y1 = $this->ytr($this->x_axis_position); + $y2 = $this->ytr($v); + } else { + $y1 = $this->ytr($v); + $y2 = $this->ytr($this->x_axis_position); + } + + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + if ($colbarcount >= count($this->ndx_data_border_color)) $colbarcount=0; + $barcol = $this->ndx_data_color[$color_index]; + $bordercol = $this->ndx_data_border_color[$colbarcount]; + + if ((strval($v) != "") ) { //Allow for missing Y data + if ($this->shading > 0) { + for($i=0;$i<($this->shading);$i++) { + //Shading set in SetDefaultColors + ImageFilledRectangle($this->img, $x1+$i, $y1-$i, $x2+$i, $y2-$i, $this->ndx_i_light); + } + } + + ImageFilledRectangle($this->img, $x1, $y1, $x2, $y2, $barcol); + ImageRectangle($this->img, $x1, $y1, $x2, $y2, $bordercol); + if ($this->draw_data_labels == '1') { //ajo + $y1 = $this->ytr($this->label_scale_position * $v); + //$this->DrawDataLabel($v,$j + .5,$v*$this->label_scale_position); + $this->DrawText($this->x_label_ttffont, $this->x_label_angle, + $x1+$this->record_bar_width/2, $y1, $this->ndx_label_color, $this->x_label_ttffont_size, $v,'center','top'); + } + } + + $color_index++; + $colbarcount++; + } + } + } + } //function DrawBars + + function DrawLegend($which_x1,$which_y1,$which_boxtype) { + //Base code submitted by Marlin Viss + $max_legend_length=0; + reset($this->legend); + while (list(,$leg) = each($this->legend)) { + $len = strlen($leg); + if ($max_legend_length < $len) { + $max_legend_length = $len; + } + } + + $line_spacing = 1.25; + $vert_margin = $this->small_font_height/2 ; + $dot_height = $this->small_font_height*$line_spacing - 1; + + //Upper Left + if ((!$which_x1) || (!$which_y1) ) { + $box_start_x = $this->plot_area[2] - $this->small_font_width*($max_legend_length+4); + $box_start_y = $this->plot_area[1] + 4; + } else { + $box_start_x = $which_x1; + $box_start_y = $which_y1; + } + + //Lower Right + $box_end_y = $box_start_y + $this->small_font_height*(count($this->legend)+1) + 2*$vert_margin; + //$box_end_x = $this->plot_area[2] - 5; + $box_end_x = $box_start_x + $this->small_font_width*($max_legend_length+4) - 5; + + + // Draw box for legend + ImageFilledRectangle($this->img, + $box_start_x, $box_start_y,$box_end_x, + $box_end_y, $this->ndx_bg_color); + ImageRectangle($this->img, + $box_start_x, $box_start_y,$box_end_x, + $box_end_y, $this->ndx_grid_color); + + $color_index=0; + $i = 0; + + + reset($this->legend); + + + while (list(,$leg) = each($this->legend)) { + $y_pos = $box_start_y + $this->small_font_height*($i)*($line_spacing) + $vert_margin; + + ImageString($this->img, $this->small_font, + $box_start_x + $this->small_font_width*( $max_legend_length - strlen($leg) + 1 ) , + $y_pos, + $leg, $this->ndx_text_color); + + if ($color_index >= count($this->ndx_data_color)) $color_index=0; + // Draw a box in the data color + ImageFilledRectangle($this->img, + $box_end_x - $this->small_font_width*2, + $y_pos + 1, $box_end_x - $this->small_font_width, + $y_pos + $dot_height, + $this->ndx_data_color[$color_index]); + + ImageRectangle($this->img, + $box_end_x - $this->small_font_width*2, + $y_pos + 1, $box_end_x - $this->small_font_width, + $y_pos + $dot_height, + $this->ndx_text_color); + $i++; + $color_index++; + } + } //function DrawLegend + + + function DrawGraph() { + + if (($this->img) == "") { + $this->DrawError('No Image Defined: DrawGraph'); + //$this->PHPlot(); + } + + if (! is_array($this->data_values)) { + $this->DrawBackground(); + $this->DrawError("No array of data in \$data_values"); + } else { + if (!$this->data_color) { + $this->SetDataColors(array('blue','green','yellow','red','orange','blue'),array('black')); + } + + $this->FindDataLimits(); //Get maxima and minima for scaling + + $this->SetXLabelHeight(); //Get data for bottom margin + + $this->SetYLabelWidth(); //Get data for left margin + + if (!$this->plot_area_width) { + $this->SetPlotAreaPixels('','','',''); //Set Margins + } + + if (!$this->plot_max_y) { //If not set by user call SetPlotAreaWorld, + $this->SetPlotAreaWorld('','','',''); + } + + if ($this->data_type == "text-data") { + $this->SetEqualXCoord(); + } + + $this->SetPointSize($this->point_size); + + $this->DrawBackground(); + $this->DrawImageBorder(); + + $this->SetTranslation(); + + if ($this->draw_plot_area_background == 1) { + $this->DrawPlotAreaBackground(); + } +//$foo = "$this->max_y, $this->min_y, $new_miny, $new_maxy, $this->x_label_height"; +//ImageString($this->img, 4, 20, 20, $foo, $this->ndx_text_color); + + switch ($this->plot_type) { + case "bars": + $this->DrawPlotBorder(); + $this->DrawLabels(); + $this->DrawBars(); + $this->DrawXAxis(); + break; + case "thinbarline": + $this->DrawPlotBorder(); + $this->DrawLabels(); + $this->DrawThinBarLines(); + break; + case "lines": + $this->DrawPlotBorder(); + $this->DrawLabels(); + if ( $this->data_type == "text-data") { + $this->DrawLines(); + } elseif ( $this->data_type == "data-data-error") { + $this->DrawLinesError(); + } else { + $this->DrawLines(); + } + break; + case "area": + $this->DrawPlotBorder(); + $this->DrawLabels(); + if ( $this->data_type == "text-data") { + $this->DrawAreaSeries(); + } else { + $this->DrawArea(); + } + break; + case "linepoints": + $this->DrawPlotBorder(); + $this->DrawLabels(); + if ( $this->data_type == "text-data") { + $this->DrawLines(); + $this->DrawDots(); + } elseif ( $this->data_type == "data-data-error") { + $this->DrawLinesError(); + $this->DrawDotsError(); + } else { + $this->DrawLines(); + $this->DrawDots(); + } + break; + case "points"; + $this->DrawPlotBorder(); + $this->DrawLabels(); + if ( $this->data_type == "text-data") { + $this->DrawDots(); + } elseif ( $this->data_type == "data-data-error") { + $this->DrawDotsError(); + } else { + $this->DrawDots(); + } + break; + case "pie": + $this->DrawPieChart(); + $this->DrawLabels(); + break; + default: + $this->DrawPlotBorder(); + $this->DrawLabels(); + $this->DrawBars(); + break; + } + + if ($this->legend) { + $this->DrawLegend($this->legend_x_pos,$this->legend_y_pos,''); + } + + } + if ($this->print_image == 1) { + $this->PrintImage(); + } + } //function DrawGraph + + } + +// $graph = new PHPlot; + +// $graph->DrawGraph(); + +?> diff --git a/catalog/admin/includes/classes/sessions.php b/catalog/admin/includes/classes/sessions.php new file mode 100644 index 0000000..fe35a3c --- /dev/null +++ b/catalog/admin/includes/classes/sessions.php @@ -0,0 +1,512 @@ +mod_name = $this->save_handler; + } + } + + class php3session_user { + var $open_func, $close_func, $read_func, $write_func, $destroy_func, $gc_func; + + function open($save_path, $sess_name) { + $func = $this->open_func; + if (function_exists($func)) { + return $func($save_path, $sess_name); + } + + return true; + } + + function close($save_path, $sess_name) { + $func = $this->close_func; + if (function_exists($func)) { + return $func(); + } + + return true; + } + + function read($sess_id) { + $func = $this->read_func; + + return $func($sess_id); + } + + function write($sess_id, $val) { + $func = $this->write_func; + + return $func($sess_id, $val); + } + + function destroy($sess_id) { + $func = $this->destroy_func; + if (function_exists($func)) { + return $func($sess_id); + } + + return true; + } + + function gc($max_lifetime) { + $func = $this->gc_func; + if (function_exists($func)) { + return $func($max_lifetime); + } + + return true; + } + } + + class php3session_files { + function open($save_path, $sess_name) { + return true; + } + + function close() { + return true; + } + + function read($sess_id) { + global $session; + +// Open, read in, close file with session data + $file = $session->save_path . '/sess_' . $sess_id; + if (!file_exists($file)) { +// Create it + touch($file); + } + $fp = fopen($file, 'r') or die('Could not open session file (' . $file . ').'); + $val = fread($fp, filesize($file)); + fclose($fp); + + return $val; + } + + function write($sess_id, $val) { + global $session; + +// Open, write to, close file with session data + $file = $session->save_path . '/sess_' . $sess_id; + $fp = fopen($file, 'w') or die('Could not write session file (' . $file . ')'); + $val = fputs($fp, $val); + fclose($fp); + + return true; + } + + function destroy($sess_id) { + global $session; + + $file = $session->save_path . '/sess_' . $sess_id; + unlink($file); + + return true; + } + + function gc($max_lifetime) { +// We return true, since all cleanup should be handled by +// an external entity (i.e. find -ctime x | xargs rm) + return true; + } + } + + function _session_create_id() { + return md5(uniqid(microtime())); + } + + function _session_cache_limiter() { + global $session; + + switch ($session->cache_limiter) { + case 'nocache': + header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); + header('Cache-Control: no-cache'); + header('Pragma: no-cache'); + break; + case 'private': + header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); + header(sprintf('Cache-Control: private, max-age=%s', $session->cache_expire * 60)); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(basename($GLOBALS['PHP_SELF']))) . ' GMT'); + break; + case 'public': + $now = time(); + $now += $session->cache_expire * 60; + $now = gmdate('D, d M Y H:i:s', $now) . ' GMT'; + header('Expires: ' . $now); + header(sprintf('Cache-Control: public, max-age=%s', $session->cache_expire * 60)); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime(basename($GLOBALS['PHP_SELF']))) . ' GMT'); + break; + default: + die('Caching method ' . $session->cache_limiter . ' not implemented.'); + } + } + + function _php_encode() { + global $session; + + $ret = ''; +// Create a string containing the serialized variables + for (reset($session->vars); list($i)=each($session->vars);) { + $ret .= $session->vars[$i] . $session->delimiter_value . serialize($GLOBALS[$session->vars[$i]]) . $session->delimiter; + } + + return $ret; + } + + function _php_decode($data) { + global $session; + + $data = trim($data); + $vars = explode($session->delimiter, $data); + +// Add the variables to the global namespace + for (reset($vars); list($i)=each($vars);) { + $tmp = explode($session->delimiter_value, $vars[$i]); + $name = trim($tmp[0]); + $value = trim($tmp[1]); + $GLOBALS[$name] = unserialize($value); + $session->vars[] = trim($name); + } + } + + function _wddx_encode($data) { + global $session; + + $ret = wddx_serialize_vars($session->vars); + + return $ret; + } + + function _wddx_decode($data) { + return wddx_deserialize($data); + } + + function session_name($name = '') { + global $session; + + if (empty($name)) { + return $session->name; + } + + $session->name = $name; + } + + function session_set_save_handler($open, $close, $read, $write, $destroy, $gc) { + global $session, $php3session_user; + + $php3session_user = new php3session_user; + $php3session_user->open_func = $open; + $php3session_user->close_func = $close; + $php3session_user->read_func = $read; + $php3session_user->write_func = $write; + $php3session_user->destroy_func = $destroy; + $php3session_user->gc_func = $gc; + $session->mod_name = 'php3session_user'; + } + + function session_module_name($name = '') { + global $session; + + if (empty($name)) { + return $session->mod_name; + } + + $session->mod_name = $name; + } + + function session_save_path($path = '') { + global $session; + + if(empty($path)) { + return $session->save_path; + } + + $session->save_path = $path; + } + + function session_id($id = '') { + global $session; + + if(empty($id)) { + return $session->id; + } + + $session->id = $id; + } + + function session_register($var) { + global $session; + + if ($session->nr_open_sessions == 0) { + session_start(); + } + + $session->vars[] = trim($var); + } + + function session_unregister($var) { + global $session; + + for (reset($session->vars); list($i)=each($session->vars);) { + if ($session->vars[$i] == trim($var)) { + unset($session->vars[$i]); + break; + } + } + } + + function session_is_registered($var) { + global $session; + + for (reset($session->vars); list($i)=each($session->vars);) { + if ($session->vars[$i] == trim($var)) { + return true; + } + } + + return false; + } + + function session_encode() { + global $session; + + $serializer = '_' . $session->serialize_handler . '_encode'; + $ret = $serializer(); + + return $ret; + } + + function session_decode($data) { + global $session; + + $serializer = '_' . $session->serialize_handler . '_decode'; + $ret = $serializer($data); + + return $ret; + } + + function session_start() { + global $session, $SID, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS; + +// Define the global variable $SID? + $define_sid = true; + +// Send the session cookie? + $send_cookie = true; + +// Is track_vars enabled? + $track_vars = ( (isset($HTTP_COOKIE_VARS)) || (isset($HTTP_GET_VARS)) || (isset($HTTP_POST_VARS)) ) ? true : false; + +// Check if session_start() has been called once already + if ($session->nr_open_sessions != 0) { + return false; + } + +// If our only resource is the global symbol_table, then check it. +// If track_vars are enabled, we prefer these, because they are more +// reliable, and we always know whether the user has accepted the +// cookie. + if ( (isset($GLOBALS[$session->name])) && (!empty($GLOBALS[$session->name])) && (!$track_vars) ) { + $session->id = $GLOBALS[$session->name]; + $send_cookie = false; + } + +// Now check the track_vars. Cookies are preferred, because initially +// cookie and get variables will be available. + if ( (empty($session->id)) && ($track_vars) ) { + if (isset($HTTP_COOKIE_VARS[$session->name])) { + $session->id = $HTTP_COOKIE_VARS[$session->name]; + $define_sid = false; + $send_cookie = false; + } + + if (isset($HTTP_GET_VARS[$session->name])) { + $session->id = $HTTP_GET_VARS[$session->name]; + } + + if (isset($HTTP_POST_VARS[$session->name])) { + $session->id = $HTTP_POST_VARS[$session->name]; + } + } + +/* +// Check the REQUEST_URI symbol for a string of the form +// '=' to allow URLs of the form +// http://yoursite/=/script.php + if (empty($session->id)) { + eregi($session->name . '=([^/]+)', $GLOBALS['REQUEST_URI'], $regs); + $regs[1] = trim($regs[1]); + if (!empty($regs[1])) { + $session->id = $regs[1]; + } + } +*/ + +// Check whether the current request was referred to by +// an external site which invalidates the previously found ID + if ( (!empty($session->id)) && ($session->referer_check) ) { + $url = parse_url($GLOBALS['HTTP_REFERER']); + if (trim($url['host']) != $GLOBALS['SERVER_NAME']) { + unset($session->id); + $send_cookie = true; + $define_sid = true; + } + } + +// Do we have an existing session ID? + if (empty($session->id)) { +// Create new session ID + $session->id = _session_create_id(); + } + +// Is use_cookies set to false? + if ( (!$session->use_cookies) && ($send_cookie) ) { + $define_sid = true; + $send_cookie = false; + } + +// Should we send a cookie? + if ($send_cookie) { + setcookie($session->name, $session->id, $session->cookie_lifetime, $session->cookie_path, $session->cookie_domain); + } + +// Should we define the SID? + if($define_sid) { + $SID = $session->name . '=' . $session->id; + } + + $session->nr_open_sessions++; + +// Send caching headers + +// Start session + $mod = $GLOBALS[$session->mod_name]; + if (!$mod->open($session->save_path, $session->name)) { + die('Failed to initialize session module.'); + } + +// Read session data + if ($val = $mod->read($session->id)) { +// Decode session data + session_decode($val); + } + +// Send HTTP cache headers + _session_cache_limiter(); + +// Check if we should clean up (call the garbage collection routines) + if ($session->gc_probability > 0) { + $randmax = getrandmax(); + $nrand = (int)(100 * tep_rand() / $randmax); + if ($nrand < $session->gc_probability) { + $mod->gc($session->gc_maxlifetime); + } + } + + if ($define_sid) { + define('SID', $SID); + } else { + define('SID', ''); + } + + return true; + } + + function session_destroy() { + global $session; + + if ($session->nr_open_sessions == 0) { + return false; + } + +// Destroy session + $mod = $GLOBALS[$session->mod_name]; + if (!$mod->destroy($session->id)) { + return false; + } + unset($session); + $session = new php3session; + + return true; + } + + function session_close() { + global $session, $SID; + + if ($session->nr_open_sessions == 0) { + return false; + } +// Encode session + $val = session_encode(); + $len = strlen($val); + +// Save session + $mod = $GLOBALS[$session->mod_name]; + if (!$mod->write($session->id, $val)) { + die('Session could not be saved.'); + } +// Close session + if ( (function_exists($session->mod_name . '->close')) && (!$mod->close()) ) { + die('Session could not be closed.'); + } + $SID = ''; + $session->nr_open_sessions--; + + return true; + } + + $session = new php3session; + $mod = $session->save_handler; + $$mod = new $mod; + + if ($session->auto_start) { + $ret = session_start() or die('Session could not be started.'); + } + + register_shutdown_function('session_close'); +?> diff --git a/catalog/admin/includes/classes/shopping_cart.php b/catalog/admin/includes/classes/shopping_cart.php new file mode 100644 index 0000000..a7a027b --- /dev/null +++ b/catalog/admin/includes/classes/shopping_cart.php @@ -0,0 +1,306 @@ +reset(); + } + + function restore_contents() { + global $customer_id; + + if (!$customer_id) return 0; + +// insert current cart contents in database + if ($this->contents) { + reset($this->contents); + while (list($products_id, ) = each($this->contents)) { + $qty = $this->contents[$products_id]['qty']; + $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); + if (!tep_db_num_rows($product_query)) { + tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); + if ($this->contents[$products_id]['attributes']) { + reset($this->contents[$products_id]['attributes']); + while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { + tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); + } + } + } else { + tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($qty) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); + } + } + } + +// reset per-session cart contents, but not the database contents + $this->reset(FALSE); + + $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); + while ($products = tep_db_fetch_array($products_query)) { + $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); +// attributes + $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); + while ($attributes = tep_db_fetch_array($attributes_query)) { + $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; + } + } + + $this->cleanup(); + } + + function reset($reset_database = FALSE) { + global $customer_id; + + $this->contents = array(); + $this->total = 0; + + if ($customer_id && $reset_database) { + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); + } + } + + function add_cart($products_id, $qty = '', $attributes = '') { + global $new_products_id_in_cart, $customer_id; + + $products_id = tep_get_uprid($products_id, $attributes); + + if ($this->in_cart($products_id)) { + $this->update_quantity($products_id, $qty, $attributes); + } else { + if ($qty == '') $qty = '1'; // if no quantity is supplied, then add '1' to the customers basket + + $this->contents[] = array($products_id); + $this->contents[$products_id] = array('qty' => $qty); +// insert into database + if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); + + if (is_array($attributes)) { + reset($attributes); + while (list($option, $value) = each($attributes)) { + $this->contents[$products_id]['attributes'][$option] = $value; +// insert into database + if ($customer_id) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')"); + } + } + $new_products_id_in_cart = $products_id; + tep_session_register('new_products_id_in_cart'); + } + $this->cleanup(); + } + + function update_quantity($products_id, $quantity = '', $attributes = '') { + global $customer_id; + + if ($quantity == '') return true; // nothing needs to be updated if theres no quantity, so we return true.. + + $this->contents[$products_id] = array('qty' => $quantity); +// update database + if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($quantity) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); + + if (is_array($attributes)) { + reset($attributes); + while (list($option, $value) = each($attributes)) { + $this->contents[$products_id]['attributes'][$option] = $value; +// update database + if ($customer_id) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); + } + } + } + + function cleanup() { + global $customer_id; + + reset($this->contents); + while (list($key,) = each($this->contents)) { + if ($this->contents[$key]['qty'] < 1) { + unset($this->contents[$key]); +// remove from database + if ($customer_id) { + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); + } + } + } + } + + function count_contents() { // get total number of items in cart + $total_items = 0; + if (is_array($this->contents)) { + reset($this->contents); + while (list($products_id, ) = each($this->contents)) { + $total_items += $this->get_quantity($products_id); + } + } + return $total_items; + } + + function get_quantity($products_id) { + if ($this->contents[$products_id]) { + return $this->contents[$products_id]['qty']; + } else { + return 0; + } + } + + function in_cart($products_id) { + if ($this->contents[$products_id]) { + return true; + } else { + return false; + } + } + + function remove($products_id) { + global $customer_id; + + unset($this->contents[$products_id]); +// remove from database + if ($customer_id) { + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); + } + } + + function remove_all() { + $this->reset(); + } + + function get_product_id_list() { + $product_id_list = ''; + if (is_array($this->contents)) + { + reset($this->contents); + while (list($products_id, ) = each($this->contents)) { + $product_id_list .= ', ' . $products_id; + } + } + return substr($product_id_list, 2); + } + + function calculate() { + $this->total = 0; + $this->weight = 0; + if (!is_array($this->contents)) return 0; + + reset($this->contents); + while (list($products_id, ) = each($this->contents)) { + $qty = $this->contents[$products_id]['qty']; + +// products price + $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . (int)tep_get_prid($products_id) . "'"); + if ($product = tep_db_fetch_array($product_query)) { + $prid = $product['products_id']; + $products_tax = tep_get_tax_rate($product['products_tax_class_id']); + $products_price = $product['products_price']; + $products_weight = $product['products_weight']; + + $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); + if (tep_db_num_rows ($specials_query)) { + $specials = tep_db_fetch_array($specials_query); + $products_price = $specials['specials_new_products_price']; + } + + $this->total += tep_add_tax($products_price, $products_tax) * $qty; + $this->weight += ($qty * $products_weight); + } + +// attributes price + if (isset($this->contents[$products_id]['attributes'])) { + reset($this->contents[$products_id]['attributes']); + while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { + $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); + $attribute_price = tep_db_fetch_array($attribute_price_query); + if ($attribute_price['price_prefix'] == '+') { + $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); + } else { + $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); + } + } + } + } + } + + function attributes_price($products_id) { + $attributes_price = 0; + + if (isset($this->contents[$products_id]['attributes'])) { + reset($this->contents[$products_id]['attributes']); + while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { + $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); + $attribute_price = tep_db_fetch_array($attribute_price_query); + if ($attribute_price['price_prefix'] == '+') { + $attributes_price += $attribute_price['options_values_price']; + } else { + $attributes_price -= $attribute_price['options_values_price']; + } + } + } + + return $attributes_price; + } + + function get_products() { + global $languages_id; + + if (!is_array($this->contents)) return 0; + $products_array = array(); + reset($this->contents); + while (list($products_id, ) = each($this->contents)) { + $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . (int)tep_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); + if ($products = tep_db_fetch_array($products_query)) { + $prid = $products['products_id']; + $products_price = $products['products_price']; + + $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); + if (tep_db_num_rows($specials_query)) { + $specials = tep_db_fetch_array($specials_query); + $products_price = $specials['specials_new_products_price']; + } + + $products_array[] = array('id' => $products_id, + 'name' => $products['products_name'], + 'model' => $products['products_model'], + 'price' => $products_price, + 'quantity' => $this->contents[$products_id]['qty'], + 'weight' => $products['products_weight'], + 'final_price' => ($products_price + $this->attributes_price($products_id)), + 'tax_class_id' => $products['products_tax_class_id'], + 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); + } + } + return $products_array; + } + + function show_total() { + $this->calculate(); + + return $this->total; + } + + function show_weight() { + $this->calculate(); + + return $this->weight; + } + + function unserialize($broken) { + for(reset($broken);$kv=each($broken);) { + $key=$kv['key']; + if (gettype($this->$key)!="user function") + $this->$key=$kv['value']; + } + } + + } +?> diff --git a/catalog/admin/includes/classes/split_page_results.php b/catalog/admin/includes/classes/split_page_results.php new file mode 100644 index 0000000..1c3823a --- /dev/null +++ b/catalog/admin/includes/classes/split_page_results.php @@ -0,0 +1,103 @@ + $num_pages) { + $current_page_number = $num_pages; + } + $offset = ($max_rows_per_page * ($current_page_number - 1)); + $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page; + } + + function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '', $page_name = 'page') { + global $PHP_SELF; + + if ( tep_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&'; + +// calculate number of pages needing links + $num_pages = ceil($query_numrows / $max_rows_per_page); + + $pages_array = array(); + for ($i=1; $i<=$num_pages; $i++) { + $pages_array[] = array('id' => $i, 'text' => $i); + } + + if ($num_pages > 1) { + $display_links = tep_draw_form('pages', basename($PHP_SELF), '', 'get'); + + if ($current_page_number > 1) { + $display_links .= '' . PREVNEXT_BUTTON_PREV . '  '; + } else { + $display_links .= PREVNEXT_BUTTON_PREV . '  '; + } + + $display_links .= sprintf(TEXT_RESULT_PAGE, tep_draw_pull_down_menu($page_name, $pages_array, $current_page_number, 'onChange="this.form.submit();"'), $num_pages); + + if (($current_page_number < $num_pages) && ($num_pages != 1)) { + $display_links .= '  ' . PREVNEXT_BUTTON_NEXT . ''; + } else { + $display_links .= '  ' . PREVNEXT_BUTTON_NEXT; + } + + if ($parameters != '') { + if (substr($parameters, -1) == '&') $parameters = substr($parameters, 0, -1); + $pairs = explode('&', $parameters); + while (list(, $pair) = each($pairs)) { + list($key,$value) = explode('=', $pair); + $display_links .= tep_draw_hidden_field(rawurldecode($key), rawurldecode($value)); + } + } + + if (SID) $display_links .= tep_draw_hidden_field(tep_session_name(), tep_session_id()); + + $display_links .= ''; + } else { + $display_links = sprintf(TEXT_RESULT_PAGE, $num_pages, $num_pages); + } + + return $display_links; + } + + function display_count($query_numrows, $max_rows_per_page, $current_page_number, $text_output) { + $to_num = ($max_rows_per_page * $current_page_number); + if ($to_num > $query_numrows) $to_num = $query_numrows; + $from_num = ($max_rows_per_page * ($current_page_number - 1)); + if ($to_num == 0) { + $from_num = 0; + } else { + $from_num++; + } + + return sprintf($text_output, $from_num, $to_num, $query_numrows); + } + } +?> diff --git a/catalog/admin/includes/classes/table_block.php b/catalog/admin/includes/classes/table_block.php new file mode 100644 index 0000000..b13c8c6 --- /dev/null +++ b/catalog/admin/includes/classes/table_block.php @@ -0,0 +1,80 @@ +table_border . '" width="' . $this->table_width . '" cellspacing="' . $this->table_cellspacing . '" cellpadding="' . $this->table_cellpadding . '"'; + if (tep_not_null($this->table_parameters)) $tableBox_string .= ' ' . $this->table_parameters; + $tableBox_string .= '>' . "\n"; + + for ($i=0, $n=sizeof($contents); $i<$n; $i++) { + $tableBox_string .= ' table_row_parameters)) $tableBox_string .= ' ' . $this->table_row_parameters; + if (isset($contents[$i]['params']) && tep_not_null($contents[$i]['params'])) $tableBox_string .= ' ' . $contents[$i]['params']; + $tableBox_string .= '>' . "\n"; + + if (isset($contents[$i][0]) && is_array($contents[$i][0])) { + for ($x=0, $y=sizeof($contents[$i]); $x<$y; $x++) { + if (isset($contents[$i][$x]['text']) && tep_not_null($contents[$i][$x]['text'])) { + $tableBox_string .= ' table_data_parameters)) { + $tableBox_string .= ' ' . $this->table_data_parameters; + } + $tableBox_string .= '>'; + if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= $contents[$i][$x]['form']; + $tableBox_string .= $contents[$i][$x]['text']; + if (isset($contents[$i][$x]['form']) && tep_not_null($contents[$i][$x]['form'])) $tableBox_string .= ''; + $tableBox_string .= '' . "\n"; + } + } + } else { + $tableBox_string .= ' table_data_parameters)) { + $tableBox_string .= ' ' . $this->table_data_parameters; + } + $tableBox_string .= '>' . $contents[$i]['text'] . '' . "\n"; + } + + $tableBox_string .= ' ' . "\n"; + } + + $tableBox_string .= '

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

$SelectCustomerBox
\n"; print "\n"; ?> \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

" . TEXT_OR_BY . "


\n"; print "\n"; ?>
customers_id); ?>
' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>

\ No newline at end of file diff --git a/catalog/admin/create_order_process.php b/catalog/admin/create_order_process.php new file mode 100644 index 0000000..0769e71 --- /dev/null +++ b/catalog/admin/create_order_process.php @@ -0,0 +1,158 @@ + + $customer_id, + 'customers_name' => $firstname . ' ' . $lastname, + 'customers_company' => $company, + 'customers_street_address' => $street_address, + 'customers_suburb' => $suburb, + 'customers_city' => $city, + 'customers_postcode' => $postcode, + 'customers_state' => $state, + 'customers_country' => $country, + 'customers_telephone' => $telephone, + 'customers_email_address' => $email_address, + 'customers_address_format_id' => $format_id, + 'delivery_name' => $firstname . ' ' . $lastname, + 'delivery_company' => $company, + 'delivery_street_address' => $street_address, + 'delivery_suburb' => $suburb, + 'delivery_city' => $city, + 'delivery_postcode' => $postcode, + 'delivery_state' => $state, + 'delivery_country' => $country, + 'delivery_address_format_id' => $format_id, + 'billing_name' => $firstname . ' ' . $lastname, + 'billing_company' => $company, + 'billing_street_address' => $street_address, + 'billing_suburb' => $suburb, + 'billing_city' => $city, + 'billing_postcode' => $postcode, + 'billing_state' => $state, + 'billing_country' => $country, + 'billing_address_format_id' => $format_id, + 'date_purchased' => 'now()', + 'orders_status' => DEFAULT_ORDERS_STATUS_ID, + 'currency' => $currency, + 'currency_value' => $currency_value, + 'payment_method' => $payment_method + ); + + + + + + //old + tep_db_perform(TABLE_ORDERS, $sql_data_array); + $insert_id = tep_db_insert_id(); + + + $sql_data_array = array('orders_id' => $insert_id, + //Comment out line you don't need + //'new_value' => $new_value, //for 2.2 + 'orders_status_id' => $new_value, //for MS1 or MS2 + 'date_added' => 'now()'); + tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); + + + $sql_data_array = array('orders_id' => $insert_id, + 'title' => TEXT_SUBTOTAL, + 'text' => $temp_amount, + 'value' => "0.00", + 'class' => "ot_subtotal", + 'sort_order' => "1"); + tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); + + + $sql_data_array = array('orders_id' => $insert_id, + 'title' => TEXT_DISCOUNT, + 'text' => $temp_amount, + 'value' => "0.00", + 'class' => "ot_customer_discount", + 'sort_order' => "2"); + tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); + + $sql_data_array = array('orders_id' => $insert_id, + 'title' => TEXT_DELIVERY, + 'text' => $temp_amount, + 'value' => "0.00", + 'class' => "ot_shipping", + 'sort_order' => "3"); + tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); + + $sql_data_array = array('orders_id' => $insert_id, + 'title' => TEXT_TAX, + 'text' => $temp_amount, + 'value' => "0.00", + 'class' => "ot_tax", + 'sort_order' => "4"); + tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); + + $sql_data_array = array('orders_id' => $insert_id, + 'title' => TEXT_TOTAL, + 'text' => $temp_amount, + 'value' => "0.00", + 'class' => "ot_total", + 'sort_order' => "5"); + tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); + + + tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $insert_id, 'SSL')); + + + require(DIR_WS_INCLUDES . 'application_bottom.php'); +?> \ No newline at end of file diff --git a/catalog/admin/currencies.php b/catalog/admin/currencies.php new file mode 100644 index 0000000..90c5836 --- /dev/null +++ b/catalog/admin/currencies.php @@ -0,0 +1,288 @@ + $title, + 'code' => $code, + 'symbol_left' => $symbol_left, + 'symbol_right' => $symbol_right, + 'decimal_point' => $decimal_point, + 'thousands_point' => $thousands_point, + 'decimal_places' => $decimal_places, + 'value' => $value); + + if ($action == 'insert') { + tep_db_perform(TABLE_CURRENCIES, $sql_data_array); + $currency_id = tep_db_insert_id(); + } elseif ($action == 'save') { + tep_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "currencies_id = '" . (int)$currency_id . "'"); + } + + if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) { + tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_CURRENCY'"); + } + + tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $currency_id)); + break; + case 'deleteconfirm': + $currencies_id = tep_db_prepare_input($HTTP_GET_VARS['cID']); + + $currency_query = tep_db_query("select currencies_id from " . TABLE_CURRENCIES . " where code = '" . DEFAULT_CURRENCY . "'"); + $currency = tep_db_fetch_array($currency_query); + + if ($currency['currencies_id'] == $currencies_id) { + tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'"); + } + + tep_db_query("delete from " . TABLE_CURRENCIES . " where currencies_id = '" . (int)$currencies_id . "'"); + + tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'])); + break; + case 'update': + $server_used = CURRENCY_SERVER_PRIMARY; + + $currency_query = tep_db_query("select currencies_id, code, title from " . TABLE_CURRENCIES); + while ($currency = tep_db_fetch_array($currency_query)) { + $quote_function = 'quote_' . CURRENCY_SERVER_PRIMARY . '_currency'; + $rate = $quote_function($currency['code']); + + if (empty($rate) && (tep_not_null(CURRENCY_SERVER_BACKUP))) { + $messageStack->add_session(sprintf(WARNING_PRIMARY_SERVER_FAILED, CURRENCY_SERVER_PRIMARY, $currency['title'], $currency['code']), 'warning'); + + $quote_function = 'quote_' . CURRENCY_SERVER_BACKUP . '_currency'; + $rate = $quote_function($currency['code']); + + $server_used = CURRENCY_SERVER_BACKUP; + } + + if (tep_not_null($rate)) { + tep_db_query("update " . TABLE_CURRENCIES . " set value = '" . $rate . "', last_updated = now() where currencies_id = '" . (int)$currency['currencies_id'] . "'"); + + $messageStack->add_session(sprintf(TEXT_INFO_CURRENCY_UPDATED, $currency['title'], $currency['code'], $server_used), 'success'); + } else { + $messageStack->add_session(sprintf(ERROR_CURRENCY_INVALID, $currency['title'], $currency['code'], $server_used), 'error'); + } + } + + tep_redirect(tep_href_link(FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $HTTP_GET_VARS['cID'])); + break; + case 'delete': + $currencies_id = tep_db_prepare_input($HTTP_GET_VARS['cID']); + + $currency_query = tep_db_query("select code from " . TABLE_CURRENCIES . " where currencies_id = '" . (int)$currencies_id . "'"); + $currency = tep_db_fetch_array($currency_query); + + $remove_currency = true; + if ($currency['code'] == DEFAULT_CURRENCY) { + $remove_currency = false; + $messageStack->add(ERROR_REMOVE_DEFAULT_CURRENCY, 'error'); + } + break; + } + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
+ + + '' . TEXT_INFO_HEADING_NEW_CURRENCY . ''); + + $contents = array('form' => tep_draw_form('currencies', FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . (isset($cInfo) ? '&cID=' . $cInfo->currencies_id : '') . '&action=insert')); + $contents[] = array('text' => TEXT_INFO_INSERT_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_TITLE . '
' . tep_draw_input_field('title')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_CODE . '
' . tep_draw_input_field('code')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . '
' . tep_draw_input_field('symbol_left')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_SYMBOL_RIGHT . '
' . tep_draw_input_field('symbol_right')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_DECIMAL_POINT . '
' . tep_draw_input_field('decimal_point')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_THOUSANDS_POINT . '
' . tep_draw_input_field('thousands_point')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_DECIMAL_PLACES . '
' . tep_draw_input_field('decimal_places')); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_VALUE . '
' . tep_draw_input_field('value')); + $contents[] = array('text' => '
' . tep_draw_checkbox_field('default') . ' ' . TEXT_INFO_SET_AS_DEFAULT); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'edit': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_CURRENCY . ''); + + $contents = array('form' => tep_draw_form('currencies', FILENAME_CURRENCIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->currencies_id . '&action=save')); + $contents[] = array('text' => TEXT_INFO_EDIT_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_TITLE . '
' . tep_draw_input_field('title', $cInfo->title)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_CODE . '
' . tep_draw_input_field('code', $cInfo->code)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . '
' . tep_draw_input_field('symbol_left', $cInfo->symbol_left)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_SYMBOL_RIGHT . '
' . tep_draw_input_field('symbol_right', $cInfo->symbol_right)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_DECIMAL_POINT . '
' . tep_draw_input_field('decimal_point', $cInfo->decimal_point)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_THOUSANDS_POINT . '
' . tep_draw_input_field('thousands_point', $cInfo->thousands_point)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_DECIMAL_PLACES . '
' . tep_draw_input_field('decimal_places', $cInfo->decimal_places)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_VALUE . '
' . tep_draw_input_field('value', $cInfo->value)); + if (DEFAULT_CURRENCY != $cInfo->code) $contents[] = array('text' => '
' . tep_draw_checkbox_field('default') . ' ' . TEXT_INFO_SET_AS_DEFAULT); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_CURRENCY . ''); + + $contents[] = array('text' => TEXT_INFO_DELETE_INTRO); + $contents[] = array('text' => '
' . $cInfo->title . ''); + $contents[] = array('align' => 'center', 'text' => '
' . (($remove_currency) ? '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '' : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (is_object($cInfo)) { + $heading[] = array('text' => '' . $cInfo->title . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_TITLE . ' ' . $cInfo->title); + $contents[] = array('text' => TEXT_INFO_CURRENCY_CODE . ' ' . $cInfo->code); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_SYMBOL_LEFT . ' ' . $cInfo->symbol_left); + $contents[] = array('text' => TEXT_INFO_CURRENCY_SYMBOL_RIGHT . ' ' . $cInfo->symbol_right); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_DECIMAL_POINT . ' ' . $cInfo->decimal_point); + $contents[] = array('text' => TEXT_INFO_CURRENCY_THOUSANDS_POINT . ' ' . $cInfo->thousands_point); + $contents[] = array('text' => TEXT_INFO_CURRENCY_DECIMAL_PLACES . ' ' . $cInfo->decimal_places); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_LAST_UPDATED . ' ' . tep_date_short($cInfo->last_updated)); + $contents[] = array('text' => TEXT_INFO_CURRENCY_VALUE . ' ' . number_format($cInfo->value, 8)); + $contents[] = array('text' => '
' . TEXT_INFO_CURRENCY_EXAMPLE . '
' . $currencies->format('30', false, DEFAULT_CURRENCY) . ' = ' . $currencies->format('30', true, $cInfo->code)); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + +currencies_id) ) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } + + if (DEFAULT_CURRENCY == $currency['code']) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + +
 
' . $currency['title'] . ' (' . TEXT_DEFAULT . ')' . $currency['title'] . 'currencies_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + + + + + + + +
display_count($currency_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CURRENCIES); ?>display_links($currency_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>
currencies_id . '&action=update') . '">' . tep_image_button('button_update_currencies.gif', IMAGE_UPDATE_CURRENCIES) . ''; } ?>currencies_id . '&action=new') . '">' . tep_image_button('button_new_currency.gif', IMAGE_NEW_CURRENCY) . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/customers.php b/catalog/admin/customers.php new file mode 100644 index 0000000..ff58b23 --- /dev/null +++ b/catalog/admin/customers.php @@ -0,0 +1,826 @@ + 0); + if ($entry_state_has_zones == true) { + $zone_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'"); + if (tep_db_num_rows($zone_query) == 1) { + $zone_values = tep_db_fetch_array($zone_query); + $entry_zone_id = $zone_values['zone_id']; + } else { + $error = true; + $entry_state_error = true; + } + } else { + if ($entry_state == false) { + $error = true; + $entry_state_error = true; + } + } + } + } + + if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { + $error = true; + $entry_telephone_error = true; + } else { + $entry_telephone_error = false; + } + + $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'"); + if (tep_db_num_rows($check_email)) { + $error = true; + $entry_email_address_exists = true; + } else { + $entry_email_address_exists = false; + } + + if ($error == false) { + + $sql_data_array = array('customers_firstname' => $customers_firstname, + 'customers_lastname' => $customers_lastname, + 'customers_email_address' => $customers_email_address, + 'customers_telephone' => $customers_telephone, + 'customers_fax' => $customers_fax, + 'customers_newsletter' => $customers_newsletter); + + if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender; + if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob); + + tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'"); + + tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'"); + + if ($entry_zone_id > 0) $entry_state = ''; + + $sql_data_array = array('entry_firstname' => $customers_firstname, + 'entry_lastname' => $customers_lastname, + 'entry_street_address' => $entry_street_address, + 'entry_postcode' => $entry_postcode, + 'entry_city' => $entry_city, + 'entry_country_id' => $entry_country_id); + + if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company; + if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb; + + if (ACCOUNT_STATE == 'true') { + if ($entry_zone_id > 0) { + $sql_data_array['entry_zone_id'] = $entry_zone_id; + $sql_data_array['entry_state'] = ''; + } else { + $sql_data_array['entry_zone_id'] = '0'; + $sql_data_array['entry_state'] = $entry_state; + } + } + + tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'"); + + tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id)); + + } else if ($error == true) { + $cInfo = new objectInfo($HTTP_POST_VARS); + $processed = true; + } + + break; + case 'deleteconfirm': + $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']); + + if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) { + $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'"); + while ($reviews = tep_db_fetch_array($reviews_query)) { + tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'"); + } + + tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'"); + } else { + tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'"); + } + + tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'"); + tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'"); + + tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')))); + break; + default: + $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'"); + $customers = tep_db_fetch_array($customers_query); + $cInfo = new objectInfo($customers); + } + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + + +
+ + + +
+ '1', 'text' => ENTRY_NEWSLETTER_YES), + array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO)); +?> + + + + + + + customers_default_address_id); ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE . ' ' . ENTRY_GENDER_ERROR; + } else { + echo ($cInfo->customers_gender == 'm') ? MALE : FEMALE; + echo tep_draw_hidden_field('customers_gender'); + } + } else { + echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE; + } +?>
+customers_firstname, 'maxlength="32"') . ' ' . ENTRY_FIRST_NAME_ERROR; + } else { + echo $cInfo->customers_firstname . tep_draw_hidden_field('customers_firstname'); + } + } else { + echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'maxlength="32"', true); + } +?>
+customers_lastname, 'maxlength="32"') . ' ' . ENTRY_LAST_NAME_ERROR; + } else { + echo $cInfo->customers_lastname . tep_draw_hidden_field('customers_lastname'); + } + } else { + echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'maxlength="32"', true); + } +?>
+ +customers_dob), 'maxlength="10"') . ' ' . ENTRY_DATE_OF_BIRTH_ERROR; + } else { + echo $cInfo->customers_dob . tep_draw_hidden_field('customers_dob'); + } + } else { + echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'maxlength="10"', true); + } +?>
+customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR; + } elseif ($entry_email_address_check_error == true) { + echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR; + } elseif ($entry_email_address_exists == true) { + echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS; + } else { + echo $customers_email_address . tep_draw_hidden_field('customers_email_address'); + } + } else { + echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"', true); + } +?>
+ + + + +
+entry_company, 'maxlength="32"') . ' ' . ENTRY_COMPANY_ERROR; + } else { + echo $cInfo->entry_company . tep_draw_hidden_field('entry_company'); + } + } else { + echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="32"'); + } +?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+entry_street_address, 'maxlength="64"') . ' ' . ENTRY_STREET_ADDRESS_ERROR; + } else { + echo $cInfo->entry_street_address . tep_draw_hidden_field('entry_street_address'); + } + } else { + echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'maxlength="64"', true); + } +?>
+entry_suburb, 'maxlength="32"') . ' ' . ENTRY_SUBURB_ERROR; + } else { + echo $cInfo->entry_suburb . tep_draw_hidden_field('entry_suburb'); + } + } else { + echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'maxlength="32"'); + } +?>
+entry_postcode, 'maxlength="8"') . ' ' . ENTRY_POST_CODE_ERROR; + } else { + echo $cInfo->entry_postcode . tep_draw_hidden_field('entry_postcode'); + } + } else { + echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true); + } +?>
+entry_city, 'maxlength="32"') . ' ' . ENTRY_CITY_ERROR; + } else { + echo $cInfo->entry_city . tep_draw_hidden_field('entry_city'); + } + } else { + echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'maxlength="32"', true); + } +?>
+entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state); + if ($error == true) { + if ($entry_state_error == true) { + if ($entry_state_has_zones == true) { + $zones_array = array(); + $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name"); + while ($zones_values = tep_db_fetch_array($zones_query)) { + $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']); + } + echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR; + } else { + echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR; + } + } else { + echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state'); + } + } else { + echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)); + } + +?>
+entry_country_id) . ' ' . ENTRY_COUNTRY_ERROR; + } else { + echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id'); + } + } else { + echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id); + } +?>
+ + + + + + + + +
+customers_telephone, 'maxlength="32"') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR; + } else { + echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone'); + } + } else { + echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"', true); + } +?>
+customers_fax . tep_draw_hidden_field('customers_fax'); + } else { + echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"'); + } +?>
+ + + + +
+customers_newsletter == '1') { + echo ENTRY_NEWSLETTER_YES; + } else { + echo ENTRY_NEWSLETTER_NO; + } + echo tep_draw_hidden_field('customers_newsletter'); + } else { + echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0')); + } +?>
' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+ + + + + +
+ + + '' . TEXT_INFO_HEADING_DELETE_CUSTOMER . ''); + + $contents = array('form' => tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=deleteconfirm')); + $contents[] = array('text' => TEXT_DELETE_INTRO . '

' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ''); + if (isset($cInfo->number_of_reviews) && ($cInfo->number_of_reviews) > 0) $contents[] = array('text' => '
' . tep_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($cInfo) && is_object($cInfo)) { + $heading[] = array('text' => '' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '' . tep_image_button('button_orders.gif', IMAGE_ORDERS) . '' . tep_image_button('button_email.gif', IMAGE_EMAIL) . ''); + $contents[] = array('text' => '
' . TEXT_DATE_ACCOUNT_CREATED . ' ' . tep_date_short($cInfo->date_account_created)); + $contents[] = array('text' => '
' . TEXT_DATE_ACCOUNT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->date_account_last_modified)); + $contents[] = array('text' => '
' . TEXT_INFO_DATE_LAST_LOGON . ' ' . tep_date_short($cInfo->date_last_logon)); + $contents[] = array('text' => '
' . TEXT_INFO_NUMBER_OF_LOGONS . ' ' . $cInfo->number_of_logons); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name); + $contents[] = array('text' => '
' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews); + } + break; + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + +customers_id)) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + + +
 
customers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + + + + + + +
display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?>display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?>
' . tep_image_button('button_reset.gif', IMAGE_RESET) . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/define_language.php b/catalog/admin/define_language.php new file mode 100644 index 0000000..96d4558 --- /dev/null +++ b/catalog/admin/define_language.php @@ -0,0 +1,193 @@ + $languages[$i]['directory'], + 'text' => $languages[$i]['name']); + } + + if (!$lng_exists) $HTTP_GET_VARS['lngdir'] = $language; +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + + +
+reset(); + $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $file), 'error'); + echo $messageStack->output(); + } + +?> + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; } else { echo '' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; } ?>
' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+ + +read()) { + if (substr($file, strrpos($file, '.')) == $file_extension) { + echo ' ' . "\n"; + if (!$left) { + echo ' ' . "\n" . + ' ' . "\n"; + } + $left = !$left; + } + } + $dir->close(); + } +?> + +
' . $file . '
' . tep_image_button('button_file_manager.gif', IMAGE_FILE_MANAGER) . ''; ?>
+ + + + + +
+ + + diff --git a/catalog/admin/easypopulate.php b/catalog/admin/easypopulate.php new file mode 100644 index 0000000..794699b --- /dev/null +++ b/catalog/admin/easypopulate.php @@ -0,0 +1,2541 @@ + 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 = false; + +// **** 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 + +// *** Excel safe output *** +// this setting will supersede the previous $separator setting and create a file +// that excel will import without spanning cells from embedded commas. +global $excel_safe_output; +$excel_safe_output = false; // default is: false +if ($excel_safe_output == true) { $separator = ","; } + +// *** Preserve Tabs, Carriage returns and Line feeds *** +// this setting will preserve the special chars that can cause problems in +// a text based output. When used with $excel_safe_output, it will safely +// preserve these elements in the export and import. +global $preserve_tabs_cr_lf; +$preserve_tabs_cr_lf = false; // default is: false + +// **** 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 + +// *** Show settings on EP page *** +global $show_ep_settings; +$show_ep_settings = false; // default is: false + + + +// **************************************** +// 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 +//******************************* +//******************************* + + +//******************************* +// 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'); + } +//******************************* + +// modify tableBlock for use here. + class epbox extends tableBlock { + // constructor + function epbox($contents, $direct_ouput = true) { + $this->table_width = ''; + if (!empty($contents) && $direct_ouput == true) { + echo $this->tableBlock($contents); + } + } + // only member function + function output($contents) { + return $this->tableBlock($contents); + } + } + + +// 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', + 'v_products_upc' + ); + +//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 == 'activestream' 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); + + // $EXPORT_TIME=time(); // start export time when export is started. + $EXPORT_TIME = strftime('%Y%b%d-%H%I'); + if ($dltype=="froogle"){ + $EXPORT_TIME = "FroogleEP" . $EXPORT_TIME; + } else { + $EXPORT_TIME = "EP" . $EXPORT_TIME; + } + + // 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; + + if ($download == 'activestream'){ + header("Content-type: application/vnd.ms-excel"); + header("Content-disposition: attachment; filename=$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".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; + } + + $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
"; + + $thetext = $row[$key]; + // kill the carriage returns and tabs in the descriptions, they're killing me! + if ($preserve_tabs_cr_lf == false || $dltype == 'froogle') { + $thetext = str_replace("\r",' ',$thetext); + $thetext = str_replace("\n",' ',$thetext); + $thetext = str_replace("\t",' ',$thetext); + } + if ($excel_safe_output == true && $dltype != 'froogle') { + // use quoted values and escape the embedded quotes for excel safe output. + $therow .= '"'.str_replace('"','""',$thetext).'"' . $separator; + } else { + // and put the text into the output separated by $separator defined above + $therow .= $thetext . $separator; + } + } + + // lop off the trailing tab, then append the end of row indicator + $therow = substr($therow,0,strlen($therow)-1) . $endofrow; + + if ($download == 'activestream'){ + echo $therow; + } else { + $filestring .= $therow; + } + // grab the next row from the db + $row = tep_db_fetch_array($result); + } + + // now either stream it to them or put it in the temp directory + if ($download == 'activestream'){ + die(); + } elseif ($download == 'stream'){ + //******************************* + // STREAM FILE + //******************************* + header("Content-type: application/vnd.ms-excel"); + header("Content-disposition: attachment; filename=$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".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(); + } elseif ($download == 'tempfile') { + //******************************* + // PUT FILE IN TEMP DIR + //******************************* + $tmpfname = $tempdir . "$EXPORT_TIME" . (($excel_safe_output == true)?".csv":".txt"); + //unlink($tmpfname); + $fp = fopen( $tmpfname, "w+"); + fwrite($fp, $filestring); + fclose($fp); + echo "You can get your file in the Tools/File Manager here: " . $tempdir . "EP" . $EXPORT_TIME . (($excel_safe_output == true)?".csv":".txt"); + die(); + } +} // *** END *** download section +?> + + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + +
+ + +
+ +

+ +"; + echo "File uploaded.
"; + echo "Temporary filename: " . $usrfl . "
"; + echo "User filename: " . $usrfl_name . "
"; + echo "Size: " . $usrfl_size . "
"; + + // get the entire file into an array + $readed = file($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, $tempdir); + } + + echo "

"; + echo "Filename: " . $localfile . "
"; + + // get the entire file into an array + $readed = file($tempdir . $localfile); + } + + if ($excel_safe_output == true) { + // do excel safe input + unset($readed); // kill array setup with above code + $readed = array(); // start a new one for excel_safe_output + $fp = fopen($tempdir . ($usrfl?$usrfl_name:$localfile),'r') or die('##Can not open CSV file for reading. Script will terminate.
'); // open file + while($line = fgetcsv($fp,32768,$separator)) // read new line (max 32K bytes) + { + unset($line[(sizeof($line)-1)]); // remove EOREOR at the end of the array + $readed[] = $line; // add to array we will process later + } + $theheaders_array = $readed[0]; // pull out header line + fclose($fp); // close file + + } else { + // do normal EP input + // 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


"; + $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, $tempdir); + } + + $infp = fopen($tempdir . $usrfl_name, "r"); + + //toprow has the field headers + $toprow = fgets($infp,32768); + + $filecount = 1; + + echo "Creating file EP_Split" . $filecount . ".txt ... "; + $tmpfname = $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...
"; + $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 = $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...

"; + fclose($fp); + fclose($infp); + + echo "You can download your split files in the Tools/Files under " . $tempdir; + +} + +?> +

+ + + + + + + + + +
+
+

Upload and Import EP File

+

+ + + +
+

+
+ +
+

Upload and Split EP File

+

+ + + +
+

+
+ +
+

Import EP file from Temp Dir

+

+ + +
+

+
+ +

Export EP or Froogle Products File

+

+ + + + +
array( "id" => 'activestream', 'text' => 'Download on-the-fly' ), 1 => array( "id" => 'stream', 'text' => 'Create then Download' ), 2 => array( "id" => 'tempfile', 'text' => 'Create in Temp Dir' ))); + echo ' a ' . tep_draw_pull_down_menu('dltype',array( 0 => array( "id" => 'full', 'text' => 'Complete' ), 1 => array( "id" => 'custom', 'text' => 'Custom' ), 2 => array( "id" => 'priceqty', 'text' => 'Price/Qty' ), 3 => array( "id" => 'catagory', 'text' => 'Categories' ), 4 => array( "id" => 'attrib', 'text' => 'Attributes' ), 5 => array( "id" => 'froogle', 'text' => 'Froogle' )),'custom','onChange="return switchForm(this);"'); + echo ' ' . (($excel_safe_output == true)?".csv":".txt") . ' file (model number is always included).'; + + $cells = array(); + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_name', 'show', true) . ' name' . '
'); + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_description', 'show', (!empty($_GET['epcust_description'])?true:false)) . ' description' . '
'); + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_url', 'show', (!empty($_GET['epcust_url'])?true:false)) . ' url' . '
'); + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_image', 'show', (!empty($_GET['epcust_image'])?true:false)) . ' image' . '
'); + if ($products_with_attributes == true) { + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_attributes', 'show', (!empty($_GET['epcust_attributes'])?true:false)) . ' attributes' . '
'); + } + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_category', 'show', (!empty($_GET['epcust_category'])?true:false)) . ' categories' . '
'); + $cells[0][] = array('text' => '
' . tep_draw_checkbox_field('epcust_manufacturer', 'show', (!empty($_GET['epcust_manufacturer'])?true:false)) . ' manufacturer' . '
'); + + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_price', 'show', true) . ' price' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_quantity', 'show', (!empty($_GET['epcust_quantity'])?true:false)) . ' quantity' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_weight', 'show', (!empty($_GET['epcust_weight'])?true:false)) . ' weight' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_tax_class', 'show', (!empty($_GET['epcust_tax_class'])?true:false)) . ' tax class' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_avail', 'show', (!empty($_GET['epcust_avail'])?true:false)) . ' available' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_date_added', 'show', (!empty($_GET['epcust_date_added'])?true:false)) . ' date added' . '
'); + $cells[1][] = array('text' => '
' . tep_draw_checkbox_field('epcust_status', 'show', (!empty($_GET['epcust_status'])?true:false)) . ' status' . '
'); + + $bigbox = new epbox('',false); + $bigbox->table_parameters = 'id="customtable" style="border: 1px solid #CCCCCC; padding: 2px; margin: 3px;"'; + echo $bigbox->output($cells); + + $manufacturers_array = array(); + $manufacturers_array[] = array( "id" => '', 'text' => '- manufacturer -' ); + $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name"); + while ($manufacturers = tep_db_fetch_array($manufacturers_query)) { + $manufacturers_array[] = array( "id" => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name'] ); + } + + $status_array = array(array( "id" => '', 'text' => '- status -' ),array( "id" => '1', 'text' => 'active' ),array( "id" => '0', 'text' => 'disabled' )); + + echo 'filter by: ' . tep_draw_pull_down_menu('epcust_category_filter', array_merge(array( 0 => array( "id" => '', 'text' => '- category -' )), tep_get_category_tree())); + echo ' ' . tep_draw_pull_down_menu('epcust_manufacturer_filter', $manufacturers_array) . ' '; + echo ' ' . tep_draw_pull_down_menu('epcust_status_filter', $status_array) . ' '; + + echo tep_draw_input_field('submit', 'Build File', ' style="padding: 0px"', false, 'submit'); + ?>
+



+ + Quick Links +
+

Create then Download Files
+ Create entire file in server memory then stream download after completed.

+

+ Download Complete file to edit
+ Download Model/Price/Qty file to edit
+ Download Model/Category file to edit
+ Download Froogle file
+ + + Download Model/Attributes file
+ + +


+
+

Create Files in Temp Dir
+ Create entire file in server memory then save to Temp Dir after completed.

+

+ Create Complete file in temp dir
+ Create Model/Price/Qty file in temp dir
+ Create Model/Category file in temp dir
+ Create Froogle file in temp dir
+ + + Create Model/Attributes file in temp dir
+ + +


+
+ +

Settings

+
+

Temp Dir:
+

+

Split files on: + records

+

Model Num Size: +

+

Price with tax: +

+

Replace quotes: +

+

Field seperator: +

+

Excel safe output: +

+

Preserve tab/cr/lf: +

+

Category depth: +

+

Enable attributes: +

+

SEF Froogle URLS: +

+ +
+
Please see the manual in this contribution's package for help in changing these settings.
+
+ +
+
+ + + +

 

+

 


+

+ + + $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)); +}; +////// +////// +// ep_create_filelayout() +/////////////////////////////////////// +function ep_create_filelayout($dltype){ + global $filelayout, $filelayout_count, $filelayout_sql, $langcode, $fileheaders, $max_categories; + global $attribute_options_array; + // 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. + + // build filters + $sql_filter = ''; + if (!empty($_GET['epcust_category_filter'])) { + $sub_categories = array(); + $categories_query_addition = 'ptoc.categories_id = ' . (int)$_GET['epcust_category_filter'] . ''; + tep_get_sub_categories($sub_categories, $_GET['epcust_category_filter']); + foreach ($sub_categories AS $ckey => $category ) { + $categories_query_addition .= ' or ptoc.categories_id = ' . (int)$category . ''; + } + $sql_filter .= ' and (' . $categories_query_addition . ')'; + } + if ($_GET['epcust_manufacturer_filter']!='') { + $sql_filter .= ' and p.manufacturers_id = ' . (int)$_GET['epcust_manufacturer_filter']; + } + if ($_GET['epcust_status_filter']!='') { + $sql_filter .= ' and p.products_status = ' . (int)$_GET['epcust_status_filter']; + } + + 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(); + + $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++; + } + // VJ product attribs end + + $header_array['v_manufacturers_name'] = $iii++; + + $filelayout = array_merge($filelayout, $header_array); + + // 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 + " . $sql_filter; + + 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 'custom': + $iii = 0; + $filelayout = array( 'v_products_model' => $iii++ ); + if (!empty($_GET['epcust_upc'])) { + $filelayout = array_merge($filelayout , array( 'v_products_upc' => $iii++ )); + } + if (!empty($_GET['epcust_status'])) { + $filelayout = array_merge($filelayout , array( 'v_status' => $iii++ )); + } + + foreach ($langcode as $key => $lang){ + $l_id = $lang['id']; + if (!empty($_GET['epcust_name'])) { + $filelayout = array_merge($filelayout , array( 'v_products_name_' . $l_id => $iii++ )); + } + if (!empty($_GET['epcust_description'])) { + $filelayout = array_merge($filelayout , array( 'v_products_description_' . $l_id => $iii++ )); + } + if (!empty($_GET['epcust_url'])) { + $filelayout = array_merge($filelayout , array( 'v_products_url_' . $l_id => $iii++ )); + } + } + + if (!empty($_GET['epcust_image'])) { + $filelayout = array_merge($filelayout , array( 'v_products_image' => $iii++ )); + } + + if (!empty($_GET['epcust_shopping_sites'])) { + foreach($shopping_sites as $skey => $shopping_site ) { + $filelayout = array_merge($filelayout , array( + 'v_shopping_sites_' . strtolower( str_replace(array(' ','.','/','_','-','\''), array('','','','','',''), $shopping_site['shopping_sites_title']) ) => $iii++ + )); + } + } + + if (!empty($_GET['epcust_attributes'])) { + // VJ product attribs begin + $languages = tep_get_languages(); + + $attribute_options_count = 1; + foreach ($attribute_options_array as $attribute_options_values) { + $filelayout = array_merge($filelayout , array( 'v_attribute_options_id_' . $attribute_options_count => $iii++ )); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $filelayout = array_merge($filelayout , array( 'v_attribute_options_name_' . $attribute_options_count . '_' . $languages[$i]['id'] => $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)) { + $filelayout = array_merge($filelayout , array( 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ )); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $filelayout = array_merge($filelayout , array( 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $languages[$i]['id'] => $iii++ )); + } + $filelayout = array_merge($filelayout , array( 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ )); + //// attributes stock add start + if ( $products_attributes_stock == true ) { + $filelayout = array_merge($filelayout , array( 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count => $iii++ )); + } + //// attributes stock add end + $attribute_values_count++; + } + $attribute_options_count++; + } + // VJ product attribs end + } + if (!empty($_GET['epcust_price'])) { + $filelayout = array_merge($filelayout , array( 'v_products_price' => $iii++ )); + } + if (!empty($_GET['epcust_cost'])) { + $filelayout = array_merge($filelayout , array( 'v_products_cost' => $iii++ )); + } + if (!empty($_GET['epcust_quantity'])) { + $filelayout = array_merge($filelayout , array( 'v_products_quantity' => $iii++ )); + } + if (!empty($_GET['epcust_weight'])) { + $filelayout = array_merge($filelayout , array( 'v_products_weight' => $iii++ )); + } + if (!empty($_GET['epcust_date_added'])) { + $filelayout = array_merge($filelayout , array( 'v_date_added' => $iii++ )); + } + if (!empty($_GET['epcust_avail'])) { + $filelayout = array_merge($filelayout , array( 'v_date_avail' => $iii++ )); + } + if (!empty($_GET['epcust_manufacturer'])) { + $filelayout = array_merge($filelayout , array( 'v_manufacturers_name' => $iii++ )); + } + if (!empty($_GET['epcust_category'])) { + // 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++)); + } + } + if (!empty($_GET['epcust_tax_class'])) { + $filelayout = array_merge($filelayout , array( 'v_tax_class_title' => $iii++ )); + } + if (!empty($_GET['epcust_comment'])) { + $filelayout = array_merge($filelayout , array( 'v_products_comment' => $iii++ )); + } + + $filelayout_sql = "SELECT + p.products_id as v_products_id, + p.products_model as v_products_model, + p.products_status as v_status, + p.products_price as v_products_price, + p.products_quantity as v_products_quantity, + p.products_weight as v_products_weight, + p.products_image as v_products_image, + p.manufacturers_id as v_manufacturers_id, + 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, + 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 + " . $sql_filter; + 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_price as v_products_price, + 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 + " . $sql_filter; + 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++; + + 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++; + } + + $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); + +} + +////// +////// +// walk() +/////////////////////////////////////// +function walk( $item1 ) { + global $filelayout, $filelayout_count, $modelsize; + global $active, $inactive, $langcode, $default_these, $deleteit, $zero_qty_inactive; + global $epdlanguage_id, $price_with_tax, $replace_quotes; + global $default_images, $default_image_manufacturer, $default_image_product, $default_image_category; + global $separator, $max_categories; + global $excel_safe_output; + // first we clean up the row of data + + + if ($excel_safe_output == true) { + $items = $item1; + } else { + // chop blanks from each end + $item1 = ltrim(rtrim($item1)); + + // blow it into an array, splitting on the tabs + $items = explode($separator, $item1); + } + + // make sure all non-set things are set to ''; + // and strip the quotes from the start and end of the stings. + // escape any special chars for the database. + foreach( $filelayout as $key=> $value){ + $i = $filelayout[$key]; + if (isset($items[$i]) == false) { + $items[$i]=''; + } else { + // Check to see if either of the magic_quotes are turned on or off; + // And apply filtering accordingly. + if (function_exists('ini_get')) { + //echo "Getting ready to check magic quotes
"; + if (ini_get('magic_quotes_runtime') == 1){ + // The magic_quotes_runtime are on, so lets account for them + // check if the last character is a quote; + // if it is, chop off the quotes. + if (substr($items[$i],-1) == '"'){ + $items[$i] = substr($items[$i],2,strlen($items[$i])-4); + } + // now any remaining doubled double quotes should be converted to one doublequote + $items[$i] = str_replace('\"\"',""",$items[$i]); + if ($replace_quotes){ + $items[$i] = str_replace('\"',""",$items[$i]); + $items[$i] = str_replace("\'","'",$items[$i]); + } + } else { // no magic_quotes are on + // check if the last character is a quote; + // if it is, chop off the 1st and last character of the string. + if (substr($items[$i],-1) == '"'){ + $items[$i] = substr($items[$i],1,strlen($items[$i])-2); + } + // now any remaining doubled double quotes should be converted to one doublequote + $items[$i] = str_replace('""',""",$items[$i]); + if ($replace_quotes){ + $items[$i] = str_replace('"',""",$items[$i]); + $items[$i] = str_replace("'","'",$items[$i]); + } + } + } + } + } +/* + if ( $items['v_status'] == $deleteit ){ + // they want to delete this product. + echo "Deleting product " . $items['v_products_model'] . " from the database
"; + // Get the ID + + // kill in the products_to_categories + + // Kill in the products table + + return; // we're done deleteing! + } +*/ + // now do a query to get the record's current contents + $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_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 + p.products_model = '" . $items[$filelayout['v_products_model']] . "' AND + ptoc.categories_id = subc.categories_id + "; + + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + + + while ($row){ + // OK, since we got a row, the item already exists. + // Let's get all the data we need and fill in all the fields that need to be defaulted to the current values + // for each language, get the description and set the vals + foreach ($langcode as $key => $lang){ + //echo "Inside defaulting loop"; + //echo "key is $key
"; + //echo "langid is " . $lang['id'] . "
"; +// $sql2 = "SELECT products_name, products_description +// FROM ".TABLE_PRODUCTS_DESCRIPTION." +// WHERE +// products_id = " . $row['v_products_id'] . " AND +// language_id = '" . $lang['id'] . "' +// "; + $sql2 = "SELECT * + FROM ".TABLE_PRODUCTS_DESCRIPTION." + WHERE + products_id = " . $row['v_products_id'] . " AND + language_id = '" . $lang['id'] . "' + "; + $result2 = tep_db_query($sql2); + $row2 = tep_db_fetch_array($result2); + // Need to report from ......_name_1 not ..._name_0 + $row['v_products_name_' . $lang['id']] = $row2['products_name']; + $row['v_products_description_' . $lang['id']] = $row2['products_description']; + $row['v_products_url_' . $lang['id']] = $row2['products_url']; + + // support for Linda's Header Controller 2.0 here + if(isset($filelayout['v_products_head_title_tag_' . $lang['id'] ])){ + $row['v_products_head_title_tag_' . $lang['id']] = $row2['products_head_title_tag']; + $row['v_products_head_desc_tag_' . $lang['id']] = $row2['products_head_desc_tag']; + $row['v_products_head_keywords_tag_' . $lang['id']] = $row2['products_head_keywords_tag']; + } + // end support for Header Controller 2.0 + } + + // start with v_categories_id + // Get the category description + // set the appropriate variable name + // if parent_id is not null, then follow it up. + $thecategory_id = $row['v_categories_id']; + + 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; + } + } else { + $temprow['v_categories_name_' . $categorylevel] = ''; + } + } + // temprow has the old style low to high level categories. + $newlevel = 1; + // let's turn them into high to low level categories + for( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel--){ + if ($temprow['v_categories_name_' . $categorylevel] != ''){ + $row['v_categories_name_' . $newlevel++] = $temprow['v_categories_name_' . $categorylevel]; + } + } + + 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']; + } + + //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 true + $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']); + if ($price_with_tax){ + $row['v_products_price'] = round($row['v_products_price'] + ($row['v_products_price'] * $row_tax_multiplier / 100),2); + } + + // now create the internal variables that will be used + // the $$thisvar is on purpose: it creates a variable named what ever was in $thisvar and sets the value + foreach ($default_these as $thisvar){ + $$thisvar = $row[$thisvar]; + } + + $row = tep_db_fetch_array($result); + } + + // this is an important loop. What it does is go thru all the fields in the incoming file and set the internal vars. + // Internal vars not set here are either set in the loop above for existing records, or not set at all (null values) + // the array values are handled separatly, although they will set variables in this loop, we won't use them. + foreach( $filelayout as $key => $value ){ + $$key = $items[ $value ]; + } + + // so how to handle these? we shouldn't built the array unless it's been giving to us. + // The assumption is that if you give us names and descriptions, then you give us name and description for all applicable languages + foreach ($langcode as $lang){ + //echo "Langid is " . $lang['id'] . "
"; + $l_id = $lang['id']; + if (isset($filelayout['v_products_name_' . $l_id ])){ + //we set dynamically the language values + $v_products_name[$l_id] = $items[$filelayout['v_products_name_' . $l_id]]; + $v_products_description[$l_id] = $items[$filelayout['v_products_description_' . $l_id ]]; + $v_products_url[$l_id] = $items[$filelayout['v_products_url_' . $l_id ]]; + // support for Linda's Header Controller 2.0 here + if(isset($filelayout['v_products_head_title_tag_' . $l_id])){ + $v_products_head_title_tag[$l_id] = $items[$filelayout['v_products_head_title_tag_' . $l_id]]; + $v_products_head_desc_tag[$l_id] = $items[$filelayout['v_products_head_desc_tag_' . $l_id]]; + $v_products_head_keywords_tag[$l_id] = $items[$filelayout['v_products_head_keywords_tag_' . $l_id]]; + } + // end support for Header Controller 2.0 + } + } + //elari... we get the tax_clas_id from the tax_title + //on screen will still be displayed the tax_class_title instead of the id.... + if ( isset( $v_tax_class_title) ){ + $v_tax_class_id = tep_get_tax_title_class_id($v_tax_class_title); + } + //we check the tax rate of this tax_class_id + $row_tax_multiplier = tep_get_tax_class_rate($v_tax_class_id); + + //And we recalculate price without the included tax... + //Since it seems display is made before, the displayed price will still include tax + //This is same problem for the tax_clas_id that display tax_class_title + if ($price_with_tax){ + $v_products_price = round( $v_products_price / (1 + ( $row_tax_multiplier * $price_with_tax/100) ), 4); + } + + // if they give us one category, they give us all 6 categories + unset ($v_categories_name); // default to not set. + if ( isset( $filelayout['v_categories_name_1'] ) ){ + $newlevel = 1; + for( $categorylevel=6; $categorylevel>0; $categorylevel--){ + if ( $items[$filelayout['v_categories_name_' . $categorylevel]] != ''){ + $v_categories_name[$newlevel++] = $items[$filelayout['v_categories_name_' . $categorylevel]]; + } + } + while( $newlevel < $max_categories+1){ + $v_categories_name[$newlevel++] = ''; // default the remaining items to nothing + } + } + + if (ltrim(rtrim($v_products_quantity)) == '') { + $v_products_quantity = 1; + } + if ($v_date_avail == '') { +// $v_date_avail = "CURRENT_TIMESTAMP"; + $v_date_avail = "NULL"; + } else { + // we put the quotes around it here because we can't put them into the query, because sometimes + // we will use the "current_timestamp", which can't have quotes around it. + $v_date_avail = '"' . $v_date_avail . '"'; + } + + if ($v_date_added == '') { + $v_date_added = "CURRENT_TIMESTAMP"; + } else { + // we put the quotes around it here because we can't put them into the query, because sometimes + // we will use the "current_timestamp", which can't have quotes around it. + $v_date_added = '"' . $v_date_added . '"'; + } + + + // default the stock if they spec'd it or if it's blank + $v_db_status = '1'; // default to active + if ($v_status == $inactive){ + // they told us to deactivate this item + $v_db_status = '0'; + } + if ($zero_qty_inactive && $v_products_quantity == 0) { + // if they said that zero qty products should be deactivated, let's deactivate if the qty is zero + $v_db_status = '0'; + } + + if ($v_manufacturer_id==''){ + $v_manufacturer_id="NULL"; + } + + if (trim($v_products_image)==''){ + $v_products_image = $default_image_product; + } + + if (strlen($v_products_model) > $modelsize ){ + echo "" . strlen($v_products_model) . $v_products_model . "... ERROR! - Too many characters in the model number.
+ 12 is the maximum on a standard OSC install.
+ Your maximum product_model length is set to $modelsize
+ You can either shorten your model numbers or increase the size of the field in the database.
"; + die(); + } + + // OK, we need to convert the manufacturer's name into id's for the database + if ( isset($v_manufacturers_name) && $v_manufacturers_name != '' ){ + $sql = "SELECT man.manufacturers_id + FROM ".TABLE_MANUFACTURERS." as man + WHERE + man.manufacturers_name = '" . $v_manufacturers_name . "'"; + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + if ( $row != '' ){ + foreach( $row as $item ){ + $v_manufacturer_id = $item; + } + } else { + // to add, we need to put stuff in categories and categories_description + $sql = "SELECT MAX( manufacturers_id) max FROM ".TABLE_MANUFACTURERS; + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + $max_mfg_id = $row['max']+1; + // default the id if there are no manufacturers yet + if (!is_numeric($max_mfg_id) ){ + $max_mfg_id=1; + } + + // Uncomment this query if you have an older 2.2 codebase + /* + $sql = "INSERT INTO ".TABLE_MANUFACTURERS."( + manufacturers_id, + manufacturers_name, + manufacturers_image + ) VALUES ( + $max_mfg_id, + '$v_manufacturers_name', + '$default_image_manufacturer' + )"; + */ + + // Comment this query out if you have an older 2.2 codebase + $sql = "INSERT INTO ".TABLE_MANUFACTURERS."( + manufacturers_id, + manufacturers_name, + manufacturers_image, + date_added, + last_modified + ) VALUES ( + $max_mfg_id, + '$v_manufacturers_name', + '$default_image_manufacturer', + CURRENT_TIMESTAMP, + CURRENT_TIMESTAMP + )"; + $result = tep_db_query($sql); + $v_manufacturer_id = $max_mfg_id; + } + } + // if the categories names are set then try to update them + if ( isset($v_categories_name_1)){ + // start from the highest possible category and work our way down from the parent + $v_categories_id = 0; + $theparent_id = 0; + for ( $categorylevel=$max_categories+1; $categorylevel>0; $categorylevel-- ){ + $thiscategoryname = $v_categories_name[$categorylevel]; + if ( $thiscategoryname != ''){ + // we found a category name in this field + + // now the subcategory + $sql = "SELECT cat.categories_id + FROM ".TABLE_CATEGORIES." as cat, + ".TABLE_CATEGORIES_DESCRIPTION." as des + WHERE + cat.categories_id = des.categories_id AND + des.language_id = $epdlanguage_id AND + cat.parent_id = " . $theparent_id . " AND + des.categories_name = '" . $thiscategoryname . "'"; + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + if ( $row != '' ){ + foreach( $row as $item ){ + $thiscategoryid = $item; + } + } else { + // to add, we need to put stuff in categories and categories_description + $sql = "SELECT MAX( categories_id) max FROM ".TABLE_CATEGORIES; + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + $max_category_id = $row['max']+1; + if (!is_numeric($max_category_id) ){ + $max_category_id=1; + } + $sql = "INSERT INTO ".TABLE_CATEGORIES."( + categories_id, + categories_image, + parent_id, + sort_order, + date_added, + last_modified + ) VALUES ( + $max_category_id, + '$default_image_category', + $theparent_id, + 0, + CURRENT_TIMESTAMP + ,CURRENT_TIMESTAMP + )"; + $result = tep_db_query($sql); + $sql = "INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION."( + categories_id, + language_id, + categories_name + ) VALUES ( + $max_category_id, + '$epdlanguage_id', + '$thiscategoryname' + )"; + $result = tep_db_query($sql); + $thiscategoryid = $max_category_id; + } + // the current catid is the next level's parent + $theparent_id = $thiscategoryid; + $v_categories_id = $thiscategoryid; // keep setting this, we need the lowest level category ID later + } + } + } + + if ($v_products_model != "") { + // products_model exists! + array_walk($items, 'print_el'); + + // First we check to see if this is a product in the current db. + $result = tep_db_query("SELECT products_id FROM ".TABLE_PRODUCTS." WHERE (products_model = '". $v_products_model . "')"); + + if (tep_db_num_rows($result) == 0) { + // insert into products + + $sql = "SHOW TABLE STATUS LIKE '".TABLE_PRODUCTS."'"; + $result = tep_db_query($sql); + $row = tep_db_fetch_array($result); + $max_product_id = $row['Auto_increment']; + if (!is_numeric($max_product_id) ){ + $max_product_id=1; + } + $v_products_id = $max_product_id; + echo " !New Product!
"; + + $query = "INSERT INTO ".TABLE_PRODUCTS." ( + products_image, + products_model, + products_price, + products_status, + products_last_modified, + products_date_added, + products_date_available, + products_tax_class_id, + products_weight, + products_quantity, + manufacturers_id) + VALUES ( + '$v_products_image',"; + + // unmcomment these lines if you are running the image mods + /* + $query .= . $v_products_mimage . '", "' + . $v_products_bimage . '", "' + . $v_products_subimage1 . '", "' + . $v_products_bsubimage1 . '", "' + . $v_products_subimage2 . '", "' + . $v_products_bsubimage2 . '", "' + . $v_products_subimage3 . '", "' + . $v_products_bsubimage3 . '", "' + */ + + $query .=" '$v_products_model', + '$v_products_price', + '$v_db_status', + CURRENT_TIMESTAMP, + $v_date_added, + $v_date_avail, + '$v_tax_class_id', + '$v_products_weight', + '$v_products_quantity', + '$v_manufacturer_id') + "; + $result = tep_db_query($query); + } else { + // existing product, get the id from the query + // and update the product data + $row = tep_db_fetch_array($result); + $v_products_id = $row['products_id']; + echo " Updated
"; + $row = tep_db_fetch_array($result); + $query = 'UPDATE '.TABLE_PRODUCTS.' + SET + products_price="'.$v_products_price. + '" ,products_image="'.$v_products_image; + + // uncomment these lines if you are running the image mods +/* + $query .= + '" ,products_mimage="'.$v_products_mimage. + '" ,products_bimage="'.$v_products_bimage. + '" ,products_subimage1="'.$v_products_subimage1. + '" ,products_bsubimage1="'.$v_products_bsubimage1. + '" ,products_subimage2="'.$v_products_subimage2. + '" ,products_bsubimage2="'.$v_products_bsubimage2. + '" ,products_subimage3="'.$v_products_subimage3. + '" ,products_bsubimage3="'.$v_products_bsubimage3; +*/ + + $query .= '", products_weight="'.$v_products_weight . + '", products_tax_class_id="'.$v_tax_class_id . + '", products_date_available= ' . $v_date_avail . + ', products_date_added= ' . $v_date_added . + ', products_last_modified=CURRENT_TIMESTAMP + , products_quantity="' . $v_products_quantity . + '" ,manufacturers_id=' . $v_manufacturer_id . + ' , products_status=' . $v_db_status . ' + WHERE + (products_id = "'. $v_products_id . '")'; + + $result = tep_db_query($query); + } + + // the following is common in both the updating an existing product and creating a new product + if ( isset($v_products_name)){ + foreach( $v_products_name as $key => $name){ + if ($name!=''){ + $sql = "SELECT * FROM ".TABLE_PRODUCTS_DESCRIPTION." WHERE + products_id = $v_products_id AND + language_id = " . $key; + $result = tep_db_query($sql); + if (tep_db_num_rows($result) == 0) { + // nope, this is a new product description + $result = tep_db_query($sql); + $sql = + "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION." + (products_id, + language_id, + products_name, + products_description, + products_url) + VALUES ( + '" . $v_products_id . "', + " . $key . ", + '". addslashes($name) . "', + '". addslashes($v_products_description[$key]) . "', + '". $v_products_url[$key] . "' + )"; + // support for Linda's Header Controller 2.0 + if (isset($v_products_head_title_tag)){ + // override the sql if we're using Linda's contrib + $sql = + "INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION." + (products_id, + language_id, + products_name, + products_description, + products_url, + products_head_title_tag, + products_head_desc_tag, + products_head_keywords_tag) + VALUES ( + '" . $v_products_id . "', + " . $key . ", + '". addslashes($name) . "', + '". addslashes($v_products_description[$key]) . "', + '". $v_products_url[$key] . "', + '". $v_products_head_title_tag[$key] . "', + '". $v_products_head_desc_tag[$key] . "', + '". $v_products_head_keywords_tag[$key] . "')"; + } + // end support for Linda's Header Controller 2.0 + $result = tep_db_query($sql); + } else { + // already in the description, let's just update it + $sql = + "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET + products_name='" . addslashes($name) . "', + products_description='" . addslashes($v_products_description[$key]) . "', + products_url='" . $v_products_url[$key] . "' + WHERE + products_id = '$v_products_id' AND + language_id = '$key'"; + // support for Lindas Header Controller 2.0 + if (isset($v_products_head_title_tag)){ + // override the sql if we're using Linda's contrib + $sql = + "UPDATE ".TABLE_PRODUCTS_DESCRIPTION." SET + products_name = '" . addslashes($name) . "', + products_description = '" . addslashes($v_products_description[$key]) . "', + products_url = '" . $v_products_url[$key] ."', + products_head_title_tag = '" . $v_products_head_title_tag[$key] ."', + products_head_desc_tag = '" . $v_products_head_desc_tag[$key] ."', + products_head_keywords_tag = '" . $v_products_head_keywords_tag[$key] ."' + WHERE + products_id = '$v_products_id' AND + language_id = '$key'"; + } + // end support for Linda's Header Controller 2.0 + $result = tep_db_query($sql); + } + } + } + } + + if (isset($v_categories_id)){ + //find out if this product is listed in the category given + $result_incategory = tep_db_query('SELECT + '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id, + '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id + FROM + '.TABLE_PRODUCTS_TO_CATEGORIES.' + WHERE + '.TABLE_PRODUCTS_TO_CATEGORIES.'.products_id='.$v_products_id.' AND + '.TABLE_PRODUCTS_TO_CATEGORIES.'.categories_id='.$v_categories_id); + + if (tep_db_num_rows($result_incategory) == 0) { + // nope, this is a new category for this product + $res1 = tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (products_id, categories_id) + VALUES ("' . $v_products_id . '", "' . $v_categories_id . '")'); + } else { + // already in this category, nothing to do! + } + } + + // for the separate prices per customer (SPPC) module + $ll=1; + if (isset($v_customer_price_1)){ + + if (($v_customer_group_id_1 == '') AND ($v_customer_price_1 != '')) { + echo "ERROR - v_customer_group_id and v_customer_price must occur in pairs"; + die(); + } + // they spec'd some prices, so clear all existing entries + $result = tep_db_query(' + DELETE + FROM + '.TABLE_PRODUCTS_GROUPS.' + WHERE + products_id = ' . $v_products_id + ); + // and insert the new record + if ($v_customer_price_1 != ''){ + $result = tep_db_query(' + INSERT INTO + '.TABLE_PRODUCTS_GROUPS.' + VALUES + ( + ' . $v_customer_group_id_1 . ', + ' . $v_customer_price_1 . ', + ' . $v_products_id . ', + ' . $v_products_price .' + )' + ); + } + if ($v_customer_price_2 != ''){ + $result = tep_db_query(' + INSERT INTO + '.TABLE_PRODUCTS_GROUPS.' + VALUES + ( + ' . $v_customer_group_id_2 . ', + ' . $v_customer_price_2 . ', + ' . $v_products_id . ', + ' . $v_products_price . ' + )' + ); + } + if ($v_customer_price_3 != ''){ + $result = tep_db_query(' + INSERT INTO + '.TABLE_PRODUCTS_GROUPS.' + VALUES + ( + ' . $v_customer_group_id_3 . ', + ' . $v_customer_price_3 . ', + ' . $v_products_id . ', + ' . $v_products_price . ' + )' + ); + } + if ($v_customer_price_4 != ''){ + $result = tep_db_query(' + INSERT INTO + '.TABLE_PRODUCTS_GROUPS.' + VALUES + ( + ' . $v_customer_group_id_4 . ', + ' . $v_customer_price_4 . ', + ' . $v_products_id . ', + ' . $v_products_price . ' + )' + ); + } + + } + // end: separate prices per customer (SPPC) module + + // VJ product attribs begin + if (isset($v_attribute_options_id_1)){ + $attribute_rows = 1; // master row count + + $languages = tep_get_languages(); + + // product options count + $attribute_options_count = 1; + $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count; + + while (isset($$v_attribute_options_id_var) && !empty($$v_attribute_options_id_var)) { + // remove product attribute options linked to this product before proceeding further + // this is useful for removing attributes linked to a product + $attributes_clean_query = "delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "'"; + + tep_db_query($attributes_clean_query); + + $attribute_options_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "'"; + + $attribute_options_values = tep_db_query($attribute_options_query); + + // option table update begin + if ($attribute_rows == 1) { + // insert into options table if no option exists + if (tep_db_num_rows($attribute_options_values) <= 0) { + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $lid = $languages[$i]['id']; + + $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid; + + if (isset($$v_attribute_options_name_var)) { + $attribute_options_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')"; + + $attribute_options_insert = tep_db_query($attribute_options_insert_query); + } + } + } else { // update options table, if options already exists + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $lid = $languages[$i]['id']; + + $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid; + + if (isset($$v_attribute_options_name_var)) { + $attribute_options_update_lang_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "' and language_id ='" . (int)$lid . "'"; + + $attribute_options_update_lang_values = tep_db_query($attribute_options_update_lang_query); + + // if option name doesn't exist for particular language, insert value + if (tep_db_num_rows($attribute_options_update_lang_values) <= 0) { + $attribute_options_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')"; + + $attribute_options_lang_insert = tep_db_query($attribute_options_lang_insert_query); + } else { // if option name exists for particular language, update table + $attribute_options_update_query = "update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . $$v_attribute_options_name_var . "' where products_options_id ='" . (int)$$v_attribute_options_id_var . "' and language_id = '" . (int)$lid . "'"; + + $attribute_options_update = tep_db_query($attribute_options_update_query); + } + } + } + } + } + // option table update end + + // product option values count + $attribute_values_count = 1; + $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; + + while (isset($$v_attribute_values_id_var) && !empty($$v_attribute_values_id_var)) { + $attribute_values_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "'"; + + $attribute_values_values = tep_db_query($attribute_values_query); + + // options_values table update begin + if ($attribute_rows == 1) { + // insert into options_values table if no option exists + if (tep_db_num_rows($attribute_values_values) <= 0) { + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $lid = $languages[$i]['id']; + + $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid; + + if (isset($$v_attribute_values_name_var)) { + $attribute_values_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')"; + + $attribute_values_insert = tep_db_query($attribute_values_insert_query); + } + } + + + // insert values to pov2po table + $attribute_values_pov2po_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "')"; + + $attribute_values_pov2po = tep_db_query($attribute_values_pov2po_query); + } else { // update options table, if options already exists + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $lid = $languages[$i]['id']; + + $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid; + + if (isset($$v_attribute_values_name_var)) { + $attribute_values_update_lang_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "' and language_id ='" . (int)$lid . "'"; + + $attribute_values_update_lang_values = tep_db_query($attribute_values_update_lang_query); + + // if options_values name doesn't exist for particular language, insert value + if (tep_db_num_rows($attribute_values_update_lang_values) <= 0) { + $attribute_values_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')"; + + $attribute_values_lang_insert = tep_db_query($attribute_values_lang_insert_query); + } else { // if options_values name exists for particular language, update table + $attribute_values_update_query = "update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . $$v_attribute_values_name_var . "' where products_options_values_id ='" . (int)$$v_attribute_values_id_var . "' and language_id = '" . (int)$lid . "'"; + + $attribute_values_update = tep_db_query($attribute_values_update_query); + } + } + } + } + } + // options_values table update end + + // options_values price update begin + $v_attribute_values_price_var = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count; + + if (isset($$v_attribute_values_price_var) && ($$v_attribute_values_price_var != '')) { + $attribute_prices_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id ='" . (int)$$v_attribute_options_id_var . "' and options_values_id = '" . (int)$$v_attribute_values_id_var . "'"; + + $attribute_prices_values = tep_db_query($attribute_prices_query); + + $attribute_values_price_prefix = ($$v_attribute_values_price_var < 0) ? '-' : '+'; + + // options_values_prices table update begin + // insert into options_values_prices table if no price exists + if (tep_db_num_rows($attribute_prices_values) <= 0) { + $attribute_prices_insert_query = "insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$v_products_id . "', '" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "', '" . (float)$$v_attribute_values_price_var . "', '" . $attribute_values_price_prefix . "')"; + + $attribute_prices_insert = tep_db_query($attribute_prices_insert_query); + } else { // update options table, if options already exists + $attribute_prices_update_query = "update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $$v_attribute_values_price_var . "', price_prefix = '" . $attribute_values_price_prefix . "' where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "' and options_values_id ='" . (int)$$v_attribute_values_id_var . "'"; + + $attribute_prices_update = tep_db_query($attribute_prices_update_query); + } + } + // options_values price update end + +//////// attributes stock add start + $v_attribute_values_stock_var = 'v_attribute_values_stock_' . $attribute_options_count . '_' . $attribute_values_count; + + if (isset($$v_attribute_values_stock_var) && ($$v_attribute_values_stock_var != '')) { + + $stock_attributes = $$v_attribute_options_id_var.'-'.$$v_attribute_values_id_var; + + $attribute_stock_query = tep_db_query("select products_stock_quantity from " . TABLE_PRODUCTS_STOCK . " where products_id = '" . (int)$v_products_id . "' and products_stock_attributes ='" . $stock_attributes . "'"); + + // insert into products_stock_quantity table if no stock exists + if (tep_db_num_rows($attribute_stock_query) <= 0) { + $attribute_stock_insert_query =tep_db_query("insert into " . TABLE_PRODUCTS_STOCK . " (products_id, products_stock_attributes, products_stock_quantity) values ('" . (int)$v_products_id . "', '" . $stock_attributes . "', '" . (int)$$v_attribute_values_stock_var . "')"); + + } else { // update options table, if options already exists + $attribute_stock_insert_query = tep_db_query("update " . TABLE_PRODUCTS_STOCK. " set products_stock_quantity = '" . (int)$$v_attribute_values_stock_var . "' where products_id = '" . (int)$v_products_id . "' and products_stock_attributes = '" . $stock_attributes . "'"); + + // turn on stock tracking on products_options table + $stock_tracking_query = tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_track_stock = '1' where products_options_id = '" . (int)$$v_attribute_options_id_var . "'"); + + } + } +//////// attributes stock add end + + + + + $attribute_values_count++; + $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count; + } + + $attribute_options_count++; + $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count; + } + + $attribute_rows++; + } + // VJ product attribs end + + } else { + // this record was missing the product_model + array_walk($items, 'print_el'); + echo "

No products_model field in record. This line was not imported
"; + echo "
"; + } +// end of row insertion code +} + +require(DIR_WS_INCLUDES . 'application_bottom.php'); +?> diff --git a/catalog/admin/easypopulate_functions.php b/catalog/admin/easypopulate_functions.php new file mode 100644 index 0000000..1ef943d --- /dev/null +++ b/catalog/admin/easypopulate_functions.php @@ -0,0 +1,61 @@ + $_FILES[$filename]['name'], + 'type' => $_FILES[$filename]['type'], + 'size' => $_FILES[$filename]['size'], + 'tmp_name' => $_FILES[$filename]['tmp_name']); + } elseif (isset($GLOBALS['HTTP_POST_FILES'][$filename])) { + global $HTTP_POST_FILES; + + $uploaded_file = array('name' => $HTTP_POST_FILES[$filename]['name'], + 'type' => $HTTP_POST_FILES[$filename]['type'], + 'size' => $HTTP_POST_FILES[$filename]['size'], + 'tmp_name' => $HTTP_POST_FILES[$filename]['tmp_name']); + } else { + $uploaded_file = array('name' => $GLOBALS[$filename . '_name'], + 'type' => $GLOBALS[$filename . '_type'], + 'size' => $GLOBALS[$filename . '_size'], + 'tmp_name' => $GLOBALS[$filename]); + } + +return $uploaded_file; +} + +// the $filename parameter is an array with the following elements: +// name, type, size, tmp_name +function tep_copy_uploaded_file($filename, $target) { + if (substr($target, -1) != '/') $target .= '/'; + + $target .= $filename['name']; + + move_uploaded_file($filename['tmp_name'], $target); +} + +//// +// Recursively go through the categories and retreive all sub-categories IDs +// TABLES: categories +if (!function_exists(tep_get_sub_categories)) { + function tep_get_sub_categories(&$categories, $categories_id) { + $sub_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'"); + while ($sub_categories = tep_db_fetch_array($sub_categories_query)) { + if ($sub_categories['categories_id'] == 0) return true; + $categories[sizeof($categories)] = $sub_categories['categories_id']; + if ($sub_categories['categories_id'] != $categories_id) { + tep_get_sub_categories($categories, $sub_categories['categories_id']); + } + } + } +} +?> diff --git a/catalog/admin/edit_orders.php b/catalog/admin/edit_orders.php new file mode 100644 index 0000000..d3fc1e4 --- /dev/null +++ b/catalog/admin/edit_orders.php @@ -0,0 +1,2300 @@ + $orders_status['orders_status_id'], + 'text' => $orders_status['orders_status_name']); + $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; + } + + $action = (isset($_GET['action']) ? $_GET['action'] : 'edit'); + + // Update Inventory Quantity + if (tep_not_null($action)) { + switch ($action) { + + // 1. UPDATE ORDER ############################################################################################### + case 'update_order': + + $oID = tep_db_prepare_input($_GET['oID']); + $order = new oe_order($oID); + $status = tep_db_prepare_input($_POST['status']); + + // Set this Session's variables + $_SESSION['billing_same_as_customer'] = $_POST['billing_same_as_customer']; + $_SESSION['shipping_same_as_billing'] = $_POST['shipping_same_as_billing']; + + //tax business + $default_tax_name = tep_get_tax_description($default_tax_class, $_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id']); + + //figure out the new currency value + $currency_value_query = tep_db_query("SELECT + value FROM " . TABLE_CURRENCIES . " WHERE code = '" . $_POST['update_info_payment_currency'] . "'"); + $currency_value = tep_db_fetch_array($currency_value_query); + + //figure out the country, state + $update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']); + $update_customer_country = tep_get_country_name($_POST['update_customer_country_id']); + $update_billing_state = tep_get_zone_name($_POST['update_billing_country_id'], $_POST['update_billing_zone_id'], $_POST['update_billing_state']); + $update_billing_country = tep_get_country_name($_POST['update_billing_country_id']); + $update_delivery_state = tep_get_zone_name($_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id'], $_POST['update_delivery_state']); + $update_delivery_country = tep_get_country_name($_POST['update_delivery_country_id']); + + + // 1.1 UPDATE ORDER INFO ##### + + $UpdateOrders = "UPDATE " . TABLE_ORDERS . " SET + customers_name = '" . tep_db_prepare_input($_POST['update_customer_name']) . "', + customers_company = '" . tep_db_prepare_input($_POST['update_customer_company']) . "', + customers_street_address = '" . tep_db_prepare_input($_POST['update_customer_street_address']) . "', + customers_suburb = '" . tep_db_prepare_input($_POST['update_customer_suburb']) . "', + customers_city = '" . tep_db_prepare_input($_POST['update_customer_city']) . "', + customers_state = '" . tep_db_prepare_input($update_customer_state) . "', + customers_postcode = '" . tep_db_prepare_input($_POST['update_customer_postcode']) . "', + customers_country = '" . tep_db_prepare_input($update_customer_country) . "', + customers_telephone = '" . tep_db_prepare_input($_POST['update_customer_telephone']) . "', + customers_email_address = '" . tep_db_prepare_input($_POST['update_customer_email_address']) . "',"; + + $UpdateOrders .= " + billing_name = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name'])) . "', + billing_company = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company'])) . "', + billing_street_address = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address'])) . "', + billing_suburb = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb'])) . "', + billing_city = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city'])) . "', + billing_state = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state)) . "', + billing_postcode = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode'])) . "', + billing_country = '" . tep_db_prepare_input((($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country)) . "',"; + + $UpdateOrders .= " + delivery_name = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_name'] : $_POST['update_billing_name']) : $_POST['update_delivery_name'])) . "', + delivery_company = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_company'] : $_POST['update_billing_company']) : $_POST['update_delivery_company'])) . "', + delivery_street_address = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address']) : $_POST['update_delivery_street_address'])) . "', + delivery_suburb = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb']) : $_POST['update_delivery_suburb'])) . "', + delivery_city = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_city'] : $_POST['update_billing_city']) : $_POST['update_delivery_city'])) . "', + delivery_state = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_state : $update_billing_state) : $update_delivery_state)) . "', + delivery_postcode = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode']) : $_POST['update_delivery_postcode'])) . "', + delivery_country = '". tep_db_prepare_input((($_POST['shipping_same_as_billing'] == 'on') ? (($_POST['billing_same_as_customer'] == 'on') ? $update_customer_country : $update_billing_country) : $update_delivery_country)) . "',"; + + $UpdateOrders .= " + payment_method = '" . tep_db_prepare_input($_POST['update_info_payment_method']) . "', + currency = '" . tep_db_prepare_input($_POST['update_info_payment_currency']) . "', + currency_value = '" . tep_db_prepare_input($currency_value['value']) . "', + cc_type = '" . tep_db_prepare_input($_POST['update_info_cc_type']) . "', + cc_owner = '" . tep_db_prepare_input($_POST['update_info_cc_owner']) . "', + cc_number = '" . tep_db_prepare_input($_POST['update_info_cc_number']) . "', + cc_expires = '" . tep_db_prepare_input($_POST['update_info_cc_expires']) . "', + shipping_tax = '" . tep_db_prepare_input($_POST['update_shipping_tax']) . "'"; + + $UpdateOrders .= " where orders_id = '" . tep_db_prepare_input($_GET['oID']) . "';"; + + tep_db_query($UpdateOrders); + $order_updated = true; + + // 1.2 UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY ##### + + $check_status_query = tep_db_query("SELECT + customers_name, customers_email_address, orders_status, date_purchased + FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'"); + $check_status = tep_db_fetch_array($check_status_query); + + if (($check_status['orders_status'] != $_POST['status']) || (tep_not_null($_POST['comments']))) { + + tep_db_query("UPDATE " . TABLE_ORDERS . " SET + orders_status = '" . tep_db_input($_POST['status']) . "', + last_modified = now() + WHERE orders_id = '" . (int)$oID . "'"); + + // Notify Customer ? + $customer_notified = '0'; + if (isset($_POST['notify']) && ($_POST['notify'] == 'on')) { + $notify_comments = ''; + if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) { + $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comments']) . "\n\n"; + } + $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]) . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE2); + tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); + $customer_notified = '1'; + } + + tep_db_query("INSERT into " . TABLE_ORDERS_STATUS_HISTORY . " + (orders_id, orders_status_id, date_added, customer_notified, comments) + values ('" . tep_db_input($_GET['oID']) . "', + '" . tep_db_input($_POST['status']) . "', + now(), + " . tep_db_input($customer_notified) . ", + '" . tep_db_input($_POST['comments']) . "')"); + } + + // 1.3 UPDATE PRODUCTS ##### + $RunningSubTotal = 0; + $RunningTax = array($default_tax_name => 0); + + // Do pre-check for subtotal field existence + $ot_subtotal_found = false; + $ot_total_found = false; + if (is_array ($_POST['update_totals'])) { + foreach($_POST['update_totals'] as $total_details) { + extract($total_details,EXTR_PREFIX_ALL,"ot"); + if($ot_class == "ot_subtotal") { + $ot_subtotal_found = true; + break; + } + + if($ot_class == "ot_total"){ + $ot_total_found = true; + break; + } + }//end foreach() + }//end if (is_array()) + + // 1.3.1 Update orders_products Table + if (is_array ($_POST['update_products'])){ + foreach($_POST['update_products'] as $orders_products_id => $products_details) { + if (!tep_not_null($products_details["qty"])) $products_details["qty"] = 0; + + // 1.3.1.1 Update Inventory Quantity + $order_query = tep_db_query("SELECT products_id, products_quantity + FROM " . TABLE_ORDERS_PRODUCTS . " + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_id = '$orders_products_id'"); + $order = tep_db_fetch_array($order_query); + + // First we do a stock check + + if ($products_details["qty"] != $order['products_quantity']){ + $quantity_difference = ($products_details["qty"] - $order['products_quantity']); + if (STOCK_LIMITED == 'true'){ + tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET + products_quantity = products_quantity - " . $quantity_difference . ", + products_ordered = products_ordered + " . $quantity_difference . " + WHERE products_id = '" . (int)$order['products_id'] . "'"); + } else { + tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET + products_ordered = products_ordered + " . $quantity_difference . " + WHERE products_id = '" . (int)$order['products_id'] . "'"); + } + } + + //Then we check if the product should be deleted + if (isset($products_details['delete'])){ + //update quantities first + if (STOCK_LIMITED == 'true'){ + tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET + products_quantity = products_quantity + " . $products_details["qty"] . ", + products_ordered = products_ordered - " . $products_details["qty"] . " + WHERE products_id = '" . (int)$order['products_id'] . "'"); + } else { + tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET + products_ordered = products_ordered - " . $products_details["qty"] . " + WHERE products_id = '" . (int)$order['products_id'] . "'"); + } + + //then delete the little bugger + $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS . " + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_id = '$orders_products_id';"; + tep_db_query($Query); + + // and all its attributes + if(isset($products_details[attributes])) + { + $Query = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_id = '$orders_products_id';"; + tep_db_query($Query); + + $Query2 = "DELETE FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_id = '$orders_products_id';"; + tep_db_query($Query2); + } + + + + }// end of if (isset($products_details['delete'])) + + else { // if we don't delete, we update + $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET + products_model = '" . $products_details["model"] . "', + products_name = '" . tep_html_quotes($products_details["name"]) . "', + products_price = '" . $products_details["price"] . "', + final_price = '" . $products_details["final_price"] . "', + products_tax = '" . $products_details["tax"] . "', + products_quantity = '" . $products_details["qty"] . "' + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_id = '$orders_products_id';"; + tep_db_query($Query); + + //update subtotal and total during update function + if (DISPLAY_PRICE_WITH_TAX == 'true') { + $RunningSubTotal += (($products_details['tax']/100 + 1) * ($products_details['qty'] * $products_details['final_price'])); + } else { + $RunningSubTotal += $products_details["qty"] * $products_details["final_price"]; + } + + $RunningTax[$products_details['tax_description']] += (($products_details['tax']/100) * ($products_details['qty'] * $products_details['final_price'])); + + // Update Any Attributes + if(isset($products_details[attributes])) + { foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details) { + $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set + products_options = '" . $attributes_details["option"] . "', + products_options_values = '" . $attributes_details["value"] . "', + options_values_price ='" . $attributes_details["price"] . "', + price_prefix ='" . $attributes_details["prefix"] . "' + where orders_products_attributes_id = '$orders_products_attributes_id';"; + tep_db_query($Query); + }//end of foreach($products_details["attributes"] + }// end of if(isset($products_details[attributes])) + }// end of if/else (isset($products_details['delete'])) + + }//end of foreach + }//end of if (is_array()) + + //1.3.5 + //update any downloads that may exist + if (is_array($_POST['update_downloads'])) { + foreach($_POST['update_downloads'] as $orders_products_download_id => $download_details) { + $Query = "UPDATE " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET + orders_products_filename = '" . $download_details["filename"] . "', + download_maxdays = '" . $download_details["maxdays"] . "', + download_count = '" . $download_details["maxcount"] . "' + WHERE orders_id = '" . (int)$oID . "' + AND orders_products_download_id = '$orders_products_download_id';"; + tep_db_query($Query); + } + } + + // 1.4 UPDATE SHIPPING, CUSTOM FEES, DISOUNTS, TAXES, AND TOTALS ##### + + // 1.4.0.1 Shipping Tax + + if (is_array ($_POST['update_totals'])){ + foreach($_POST['update_totals'] as $total_index => $total_details) + { + extract($total_details,EXTR_PREFIX_ALL,"ot"); + if($ot_class == "ot_shipping")//a good place to add in custom total components + { + if (DISPLAY_PRICE_WITH_TAX == 'true') {//the shipping charge includes tax + $RunningTax[$default_tax_name] += ($ot_value * $_POST['update_shipping_tax']) / ($_POST['update_shipping_tax'] + 100); + } else { //shipping tax is in addition to the shipping charge + $RunningTax[$default_tax_name] += (($_POST['update_shipping_tax'] / 100) * $ot_value); + } + } + } + } + + //1.4.1.0 + $RunningTotal = 0; + $sort_order = 0; + + // 1.4.1.1 If ot_tax doesn't exist, but $RunningTax has been calculated, create an appropriate entry in the db and add tax to the subtotal or total as appropriate + if (array_sum($RunningTax) != 0) { + foreach ($RunningTax as $key => $val) { + + if (is_array ($_POST['update_totals'])){//1 + foreach($_POST['update_totals'] as $total_details) {//2 + extract($total_details,EXTR_PREFIX_ALL,"ot"); + $ot_tax_found = 0; + if (($ot_class == "ot_tax") && (preg_replace("/:$/","",$ot_title) == $key)) + {//3 + $ot_tax_found = 1; + break; + }//end 3 + }//end 2 + +//bizzarro code needed to input text value into db properly +//I still don't understand why +//text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "', +//isn't adequate. Maybe I never will + if ($ot_class == "ot_total" || $ot_class == "ot_tax" || $ot_class == "ot_subtotal" || + $ot_class == "ot_shipping" || $ot_class == "ot_custom" || $ot_class == "ot_loworderfee") { + $order = new oe_order($oID); + // $RunningTax[$default_tax_name] += 0 * $products_details['tax'] / $order->info['currency_value'] / 100 ; + }//end bizarro code + + }// end 1 + + if (($val > 0) && ($ot_tax_found != 1)) { + $sort_order++; + $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET + orders_id = '" . (int)$oID . "', + title ='" . $key . ":', + text = '" . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . "', + value = '" . $val . "', + class = 'ot_tax', + sort_order = '2'"; + tep_db_query($Query); + $ot_tax_found = 1; + + if (DISPLAY_PRICE_WITH_TAX != 'true') { + $RunningTotal += $val; + } //end if (DISPLAY_PRICE_WITH_TAX != 'true') + } //end if (($val > 0) && ($ot_tax_found != 1)) { + } //end foreach ($RunningTax as $key => $val) + } //end if (array_sum($RunningTax) != 0) + + ////////////////////OPTIONAL- create entries for subtotal and/or total if none exists + /* + //1.4.1.2 + /////////////////////////Add in subtotal to db if it doesn't already exist + if (($RunningSubTotal >0) && ($ot_subtotal_found != true)) { + $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET + orders_id = "' . (int)$oID . '", + title ="' . ENTRY_SUB_TOTAL . '", + text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '", + value = "' . $RunningSubTotal . '", + class = "ot_subtotal", + sort_order = "1"'; + tep_db_query($Query); + $ot_subtotal_found = true; + $RunningTotal += $RunningSubTotal; + } + + //1.4.1.3 + /////////////////////////Add in total to db if it doesn't already exist + if (($RunningTotal >0) && ($ot_total_found != true)) { + $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET + orders_id = "' . (int)$oID . '", + title ="' . ENTRY_TOTAL . '", + text = "' . $currencies->format($RunningTotal, true, $order->info['currency'], $order->info['currency_value']) . '", + value = "' . $RunningTotal . '", + class = "ot_total", + sort_order = "4"'; + tep_db_query($Query); + $ot_total_found = true; + } + */ + //////////////////////////end optional section + + // 1.4.2. Summing up total + if (is_array ($_POST['update_totals'])) { + foreach($_POST['update_totals'] as $total_index => $total_details) { + + extract($total_details,EXTR_PREFIX_ALL,"ot"); + if (trim($ot_title)) { + $sort_order++; + + if ($ot_class == "ot_subtotal") { + $ot_value = $RunningSubTotal; + } + + if ($ot_class == "ot_tax") { + $ot_value = $RunningTax[preg_replace("/:$/","",$ot_title)]; + } + + if ($ot_class == "ot_total") { + $ot_value = $RunningTotal; + + if ( !$ot_subtotal_found ) + { // There was no subtotal on this order, lets add the running subtotal in. + $ot_value += $RunningSubTotal; + } + } + + // Set $ot_text (display-formatted value) + $order = new oe_order($oID); + $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']); + + if ($ot_class == "ot_total") { + $ot_text = "" . $ot_text . ""; + } + + if($ot_total_id > 0) { // Already in database --> Update + $Query = "UPDATE " . TABLE_ORDERS_TOTAL . " SET + title = '" . $ot_title . "', + text = '" . $ot_text . "', + value = '" . $ot_value . "', + sort_order = '" . $sort_order . "' + WHERE orders_total_id = '". $ot_total_id . "' + AND orders_id = '" . (int)$oID . "'"; + tep_db_query($Query); + } else { // New Insert (ie ot_custom) + $Query = "INSERT INTO " . TABLE_ORDERS_TOTAL . " SET + orders_id = '" . (int)$oID . "', + title = '" . $ot_title . "', + text = '" . $ot_text . "', + value = '" . $ot_value . "', + class = '" . $ot_class . "', + sort_order = '" . $sort_order . "'"; + tep_db_query($Query); + } + + if ($ot_class == "ot_tax") { + + if (DISPLAY_PRICE_WITH_TAX != 'true') { + //we don't add tax to the total here because it's already added to the subtotal + $RunningTotal += $ot_value; + } + } else { + $RunningTotal += $ot_value; + } + } + + if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total")) { // value = 0 => Delete Total Piece + + $Query = "DELETE from " . TABLE_ORDERS_TOTAL . " + WHERE orders_id = '" . (int)$oID . "' + AND orders_total_id = '$ot_total_id'"; + tep_db_query($Query); + } + + } +}//end if (is_array()) + + // 1.5 SUCCESS MESSAGE ##### + + if ($order_updated) { + $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); + } + + tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit')); + + break; + + // 2. ADD A PRODUCT ############################################################################################### + case 'add_product': + + if($_POST['step'] == 4) + { + // 2.1 GET ORDER INFO ##### + + $oID = tep_db_prepare_input($_GET['oID']); + $order = new oe_order($oID); + $AddedOptionsPrice = 0; + + //tax business + $default_tax_name = tep_get_tax_description($default_tax_class, $order->delivery['country_id'], $order->delivery['zone_id']); + + // 2.1.1 Get Product Attribute Info + if(is_array ($_POST['add_product_options'])) + { + foreach($_POST['add_product_options'] as $option_id => $option_value_id) + { + $result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " + pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po + ON po.products_options_id=pa.options_id + LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov + ON pov.products_options_values_id=pa.options_values_id + WHERE products_id=" . $_POST['add_product_products_id'] . " + and options_id=" . $option_id . " + and options_values_id=" . $option_value_id . " + and po.language_id = '" . (int)$languages_id . "' + and pov.language_id = '" . (int)$languages_id . "'"); + + $row = tep_db_fetch_array($result); + if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "opt"); + if ($opt_price_prefix == '-') + {$AddedOptionsPrice -= $opt_options_values_price;} + else //default to positive + {$AddedOptionsPrice += $opt_options_values_price;} + $option_value_details[$option_id][$option_value_id] = array ( + "options_values_price" => $opt_options_values_price, + "price_prefix" => $opt_price_prefix); + $option_names[$option_id] = $opt_products_options_name; + $option_values_names[$option_value_id] = $opt_products_options_values_name; + + //add on for downloads + if (DOWNLOAD_ENABLED == 'true') { + $download_query_raw ="select products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount + from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " + where products_attributes_id='" . $opt_products_attributes_id . "'"; + + $download_query = tep_db_query($download_query_raw); + if (tep_db_num_rows($download_query) > 0) { + $download = tep_db_fetch_array($download_query); + $filename[$option_id] = $download['products_attributes_filename']; + $maxdays[$option_id] = $download['products_attributes_maxdays']; + $maxcount[$option_id] = $download['products_attributes_maxcount']; + } //end if (tep_db_num_rows($download_query) > 0) { + } //end if (DOWNLOAD_ENABLED == 'true') { + //end downloads + + } //end foreach($_POST['add_product_options'] as $option_id => $option_value_id) + } //end if(is_array ($_POST['add_product_options'])) + + // 2.1.2 Get Product Info + $InfoQuery = "SELECT + p.products_model, p.products_price, pd.products_name, p.products_tax_class_id + from " . TABLE_PRODUCTS . " p + LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd + ON pd.products_id=p.products_id + WHERE p.products_id=" . $_POST['add_product_products_id'] . " + AND pd.language_id = '" . (int)$languages_id . "'"; + $result = tep_db_query($InfoQuery); + + $row = tep_db_fetch_array($result); + if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "p"); + + // 2.1.3 Pull specials price from db if there is an active offer + $special_price = tep_db_query(" + SELECT specials_new_products_price + FROM " . TABLE_SPECIALS . " + WHERE products_id =". $_POST['add_product_products_id'] . " + AND status"); + $new_price = tep_db_fetch_array($special_price); + + if ($new_price) + { $p_products_price = $new_price['specials_new_products_price']; } + + // 2.2 UPDATE ORDER #### + $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS . " SET + orders_id = '" . (int)$oID . "', + products_id = '" . $_POST['add_product_products_id'] . "', + products_model = '" . $p_products_model . "', + products_name = '" . tep_html_quotes($p_products_name) . "', + products_price = '". $p_products_price . "', + final_price = '" . ($p_products_price + $AddedOptionsPrice) . "', + products_tax = '" . tep_get_tax_rate($p_products_tax_class_id, $countryid, $zoneid) . "', + products_quantity = '" . $_POST['add_product_quantity'] . "'"; + tep_db_query($Query); + $new_product_id = tep_db_insert_id(); + + // 2.2.1 Update inventory Quantity + //This is only done if store is set up to use stock + if (STOCK_LIMITED == 'true'){ + tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET + products_quantity = products_quantity - " . $_POST['add_product_quantity'] . " + WHERE products_id = '" . $_POST['add_product_products_id'] . "'"); + } + + //2.2.1.1 Update products_ordered info + tep_db_query ("UPDATE " . TABLE_PRODUCTS . " SET + products_ordered = products_ordered + " . $_POST['add_product_quantity'] . " + WHERE products_id = '" . $_POST['add_product_products_id'] . "'"); + + //2.2.1.2 keep a record of the products attributes + if (is_array ($_POST['add_product_options'])) { + foreach($_POST['add_product_options'] as $option_id => $option_value_id) { + $Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " SET + orders_id = '" . (int)$oID . "', + orders_products_id = '" . $new_product_id . "', + products_options = '" . $option_names[$option_id] . "', + products_options_values = '" . + tep_db_input($option_values_names[$option_value_id]) . "', + + options_values_price = '" . + $option_value_details[$option_id][$option_value_id]['options_values_price'] . "', + + price_prefix = '" . + $option_value_details[$option_id][$option_value_id]['price_prefix'] . "'"; + + tep_db_query($Query); + + //add on for downloads + if (DOWNLOAD_ENABLED == 'true' && isset($filename[$option_id])) { + + $Query2 = "INSERT INTO " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " SET + orders_id = '" . (int)$oID . "', + orders_products_id = '" . $new_product_id . "', + orders_products_filename = '" . $filename[$option_id] . "', + download_maxdays = '" . $maxdays[$option_id] . "', + download_count = '" . $maxcount[$option_id] . "'"; + + tep_db_query($Query2); + + } //end if (DOWNLOAD_ENABLED == 'true') { + //end downloads + + } + } + + // 2.2.2 Calculate Tax and Sub-Totals + $order = new oe_order($oID); + $RunningSubTotal = 0; + $RunningTax = array($default_tax_name => 0); + + //just adding in shipping tax, don't mind me + $ot_shipping_query = tep_db_query(" + SELECT value + FROM " . TABLE_ORDERS_TOTAL . " + WHERE orders_id = '" . (int)$oID . "' + AND class = 'ot_shipping'"); + + while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) { + $ot_shipping_value = $ot_shipping_info['value']; + + if (DISPLAY_PRICE_WITH_TAX == 'true') { + $RunningTax[$default_tax_name] += ($ot_shipping_value * $order->info['shipping_tax'] / ($order->info['shipping_tax'] + 100)); + } else { + $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value); + + }// end if (DISPLAY_PRICE_WITH_TAX == 'true') { + }// end while + + // end shipping tax calcs + + for ($i=0; $iproducts); $i++) { + + // This calculatiion of Subtotal and Tax is part of the 'add a product' process + if (DISPLAY_PRICE_WITH_TAX == 'true') { + $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); + } else { + $RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']); + } + + $RunningTax[$order->products[$i]['tax_description']] += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); + + }// end of for ($i=0; $iproducts); $i++) { + + + + // 2.2.2.1 Tax + foreach ($RunningTax as $key => $val) { + $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set + text = "' . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . '", + value = "' . $val . '" + WHERE class= "ot_tax" + AND (title = "' . $key . ':" OR title = "' . $key . '") + AND orders_id= "' . (int)$oID . '"'; + tep_db_query($Query); + } + + + // 2.2.2.2 Sub-Total + $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET + text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '", + value = "' . $RunningSubTotal . '" + WHERE class="ot_subtotal" + AND orders_id= "' . (int)$oID . '"'; + tep_db_query($Query); + + // 2.2.2.3 Total + if (DISPLAY_PRICE_WITH_TAX == 'true') { + $Query = 'SELECT sum(value) + AS total_value from ' . TABLE_ORDERS_TOTAL . ' + WHERE class != "ot_total" + AND class != "ot_tax" + AND orders_id= "' . (int)$oID . '"'; + $result = tep_db_query($Query); + $row = tep_db_fetch_array($result); + $Total = $row['total_value']; + } else { + $Query = 'SELECT sum(value) + AS total_value from ' . TABLE_ORDERS_TOTAL . ' + WHERE class != "ot_total" + AND orders_id= "' . (int)$oID . '"'; + $result = tep_db_query($Query); + $row = tep_db_fetch_array($result); + $Total = $row['total_value']; + } + + $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set + text = "' . $currencies->format($Total, true, $order->info['currency'], $order->info['currency_value']) . '", + value = "' . $Total . '" + WHERE class="ot_total" and orders_id= "' . (int)$oID . '"'; + tep_db_query($Query); + + // 2.3 REDIRECTION ##### + tep_redirect(tep_href_link(FILENAME_ORDERS_EDIT, tep_get_all_get_params(array('action')) . 'action=edit')); + + } + + break; + + } +} + + if (($action == 'edit') && isset($_GET['oID'])) { + $oID = tep_db_prepare_input($_GET['oID']); + + $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); + $order_exists = true; + if (!tep_db_num_rows($orders_query)) { + $order_exists = false; + $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); + } + } + + //oh, and by the way.... + if (($action == 'edit') && ($order_exists == true)) $order = new oe_order($oID); + + //and, we're off.... + ?> + + +> + + + + + + + + + + + + +<?php echo TITLE; ?> + + + + + + + + +

+ + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +' . "\n"; +} +?> +
+ + + + + + +
info['date_purchased']) . ')'; ?>' . tep_image_button('button_details.gif', IMAGE_EDIT) . ' ' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . ' ' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . ' ' . tep_image_button('button_back.gif', IMAGE_BACK) . ' '; ?>
+ + + + + + + + +
   
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
,customer['country_id']), $order->customer['zone_id']); ?>
customer['country']), 'onchange="update_zone(this.form, \'update_customer_country_id\', \'update_customer_zone_id\', \'customerStateInput\', \'customerStateMenu\');"'); ?>
'>
+ + + + + + + + + +
+ + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
,delivery['country_id']), $order->delivery['zone_id']); ?>
delivery['country']), 'onchange="update_zone(this.form, \'update_delivery_country_id\', \'update_delivery_zone_id\', \'deliveryStateInput\', \'deliveryStateMenu\');"'); ?>
+
+ +
  + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
,billing['country_id']), $order->billing['zone_id']); ?>
billing['country']), 'onchange="update_zone(this.form, \'update_billing_country_id\', \'update_billing_zone_id\', \'billingStateInput\', \'billingStateMenu\');"'); ?>
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ read()) { + if (!is_dir( $module_directory . $file)) { + if (substr($file, strrpos($file, '.')) == $file_extension) { + $directory_array[] = $file; + } + } + } + sort($directory_array); + $dir->close(); + } + + // For each available payment module, check if enabled + for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) { + $file = $directory_array[$i]; + + include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/payment/' . $file); + include($module_directory . $file); + + $class = substr($file, 0, strrpos($file, '.')); + if (tep_class_exists($class)) { + $module = new $class; + if ($module->check() > 0) { + // If module enabled create array of titles + $enabled_payment[] = array('id' => $module->title, 'text' => $module->title); + + //if the payment method is the same as the payment module title then don't add it to dropdown menu + if ($module->title == $order->info['payment_method']) { + $paymentMatchExists='true'; + } + } + } + } + //just in case the payment method found in db is not the same as the payment module title then make it part of the dropdown array or else it cannot be the selected default value + if ($paymentMatchExists !='true') { + $enabled_payment[] = array('id' => $order->info['payment_method'], 'text' => $order->info['payment_method']); + } + $enabled_payment[] = array('id' => 'Other', 'text' => 'Other'); + //draw the dropdown menu for payment methods and default to the order value + echo tep_draw_pull_down_menu('update_info_payment_method', $enabled_payment, $order->info['payment_method'], 'id="update_info_payment_method" onChange="init()"'); + } + else { + //draw the input field for payment methods and default to the order value +?> + currencies); + $currencies_array = array(); + while (list($key, $value) = each($currencies->currencies)) { + $currencies_array[] = array('id' => $key, 'text' => $value['title']); + } + +echo tep_draw_pull_down_menu('update_info_payment_currency', $currencies_array, $order->info['currency'], 'id="update_info_payment_currency" onChange="currency()"'); + +?> + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + products); $i++) { + //calculate total weight + $products_weight = array($order->products[$i]['weight'] * $order->products[$i]['qty']); + foreach ($products_weight as $key => $value); + $total_weight += $value; + //end total weight + $orders_products_id = $order->products[$i]['orders_products_id']; + $RowStyle = "dataTableContent"; + echo ' ' . "\n" . + ' \n" . + ' \n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' .//MOD mag view ************************************************ + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } +?> +
' . "
' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-qty' />
' . ""; + + // Has Attributes? + if (sizeof($order->products[$i]['attributes']) > 0) { + for ($j=0; $jproducts[$i]['attributes']); $j++) { + $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id']; + echo '
  - ' . "" . ': ' . "" . ': ' . "products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\">" . ': ' . "products[$i]['tax_description'] . "', '" . $orders_products_attributes_id . "')\" id='p". $orders_products_id . "a" . $orders_products_attributes_id . "'>"; + echo ''; + } //end for ($j=0; $jproducts[$i]['attributes']); $j++) { + + //Has downloads? + + if (DOWNLOAD_ENABLED == 'true') { + $downloads_count = 1; + $d_index = 0; + $download_query_raw ="SELECT * + FROM " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " + WHERE orders_products_id='" . $orders_products_id . "' + AND orders_id='" . (int)$oID . "' + ORDER BY orders_products_download_id"; + + $download_query = tep_db_query($download_query_raw); + + // + if (isset($downloads->products)) unset($downloads->products); + // + + if (tep_db_num_rows($download_query) > 0) { + while ($download = tep_db_fetch_array($download_query)) { + + $downloads->products[$d_index] = array( + 'id' => $download['orders_products_download_id'], + 'filename' => $download['orders_products_filename'], + 'maxdays' => $download['download_maxdays'], + 'maxcount' => $download['download_count']); + + $d_index++; + + } + } + + for ($mm=0; $mmproducts); $mm++) { + $id = $downloads->products[$mm]['id']; + echo '
'; + echo '' . ENTRY_DOWNLOAD_COUNT . $downloads_count . ""; + echo '
' . "\n"; + echo ' - ' . ENTRY_DOWNLOAD_FILENAME . ": "; + echo '
' . "\n"; + echo ' - ' . ENTRY_DOWNLOAD_MAXDAYS . ": "; + echo '
' . "\n"; + echo ' - ' . ENTRY_DOWNLOAD_MAXCOUNT . ": "; + echo ' ' . "\n"; + echo '
'; + $downloads_count++; + } //end for ($mm=0; $mmproducts[$i]['attributes']) > 0) { + + echo '
' . "" . '' . tep_get_products_inventory_stock($order->products[$i]['magazzino']). '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-tax' />" . + "" . + "products[$i]['final_price'] / 100 * $order->products[$i]['qty']), 4, '.', '') . "'>" . + '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price' />" . '' . "products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-final_price' />" . '' . "products[$i]['tax']/100) + 1)), 4, '.', '') . "' onKeyUp=\"updatePrices('price_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-price_incl' />" . '' . "products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_excl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_excl' />" . '' . "products[$i]['tax']/100) + 1))) * $order->products[$i]['qty'], 4, '.', '') . "' onKeyUp=\"updatePrices('total_incl', 'p" . $orders_products_id . "', '" . $order->products[$i]['tax_description'] . "')\" id='p" . $orders_products_id . "-total_incl' />" . '' . + "products[$i]['qty']), 2, '.', '') . "' id='p" . $orders_products_id . "-total_weight' readonly='readonly'>" . "" . '
' . tep_draw_separator('pixel_trans.gif', '1', '1') . '
+
+ + + + +
' . tep_image_button('button_add_article.gif', ADDING_TITLE) . ''; ?>
+
+ + + + + + + + +
   
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +totals); $i++) { + $TotalsLengthArray[] = array("Name" => $order->totals[$i]['title']); + } + reset($TotalsLengthArray); + foreach($TotalsLengthArray as $TotalIndex => $TotalDetails) { + if (strlen($TotalDetails["Name"]) > $max_length) { + $max_length = strlen($TotalDetails["Name"]); + } + } +// END OF MAKING ALL INPUT FIELDS THE SAME LENGTH + + $TotalsArray = array(); + for ($i=0; $itotals); $i++) { + $TotalsArray[] = array( + "Name" => $order->totals[$i]['title'], + "Price" => number_format($order->totals[$i]['value'], 2, '.', ''), + "Class" => $order->totals[$i]['class'], + "TotalID" => $order->totals[$i]['orders_total_id']); + + $TotalsArray[] = array( + "Name" => "", + "Price" => "", + "Class" => "ot_custom", + "TotalID" => "0"); + } + + array_pop($TotalsArray); + foreach($TotalsArray as $TotalIndex => $TotalDetails) + { + $TotalStyle = "smallText"; + + if ($TotalDetails["Class"] == "ot_total" || $TotalDetails["Class"] == "ot_subtotal") { + $id = $TotalDetails["Class"];//subtotal and total should each only exist once + + } elseif ($TotalDetails["Class"] == "ot_tax") { + $id = preg_replace("/:$/", "", $TotalDetails["Name"]) . '-total'; + + } elseif ($TotalDetails["Class"] == "ot_shipping") { + $id = $TotalDetails["Class"] . $TotalIndex; + + } else { + $id = $TotalDetails["Class"] . $TotalIndex; + } + + if(//tax, subtotal, and total are not editable, but have all the same format + $TotalDetails["Class"] == "ot_total" || + $TotalDetails["Class"] == "ot_subtotal" || + $TotalDetails["Class"] == "ot_tax") + { + + echo ' ' . "\n" . + ' ' . + ' ' . + ' ' . "\n"; + } else { //the other total components are editable + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } + } + + ?> +
'; ?>
+ delivery["state"]); + $default_tax_name = tep_get_tax_description($default_tax_class, $countryid, $zoneid); + //default tax class is set at the top of the file + echo $default_tax_name; ?>')" value="info['shipping_tax']); ?>" id="shipping_tax_rate" /> +
' . $TotalDetails["Name"] . '' . + "" . + "" . + "" . + "\n" . + "" . '' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . + '
' . "" . '' . "" . + "" . + "" . + ' ' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . + '
+ +
+ + + + + + + + + + + +' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' \n"; + } else { + echo tep_image(DIR_WS_ICONS . 'cross.gif', ICON_CROSS) . "\n"; + } + echo ' ' . "\n" . + ' ' . "\n"; + echo ' ' . "\n" . + ' ' . "\n"; + echo ' ' . "\n"; + } +} else { + echo ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; +} +?> +
   
' . tep_datetime_short($orders_history['date_added']) . ' '; + if ($orders_history['customer_notified'] == '1') { + echo tep_image(DIR_WS_ICONS . 'tick.gif', ICON_TICK) . " ' . $orders_status_array[$orders_history['orders_status_id']] . ' ' . nl2br(tep_db_output($orders_history['comments'])) . ' 
' . TEXT_NO_ORDER_HISTORY . '
+ +
+ + + + + + + + + + + + +
 
+ + + + + + + + + + + + + +
info['orders_status']); ?>
+
  + +
+
+ + + + + + + + +
   
+
+ + + + + + +
)' . tep_image_button('button_back.gif', IMAGE_BACK) . ''; ?>
+
' . "\n"; + + ?> + + +' . tep_draw_form('quick_find', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + + // Step 2: Choose Options + if( (($_GET['step'] > 1) && ($_GET['add_product_products_id'] > 0)) || (($_POST['step'] > 1) && ($_POST['add_product_products_id'] > 0)) ) + + { + // Get Options for Products + $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $_GET['add_product_products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'"); + $products_attributes = tep_db_fetch_array($products_attributes_query); + if ($products_attributes['total'] == 0) { + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + $_POST['step'] = 3; + } + else //product options exist + { + echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action'] . '&add_product_products_id=' . $_GET['add_product_products_id']) . "\n"; + echo ''; + echo '' . "\n"; + echo '' . "\n"; + } + echo '' . "\n"; + } + + // Step 3: Confirm + if($_POST['step'] > 2) + { + echo '' . tep_draw_form('addProduct', FILENAME_ORDERS_EDIT,'oID=' . $_GET['oID'] . '&action=' . $_GET['action']) . "\n"; + echo ''; + echo ''; + echo ''; + echo '' . "\n"; + echo '' . "\n"; + } + echo '
' . ADDPRODUCT_TEXT_STEP . ' 1:'; + if (isset($_GET['add_product_products_id'])) { + $form_product_name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $_GET['add_product_products_id'] . "' and language_id = '" . (int)$languages_id . "'"); + $form_product_name = tep_db_fetch_array($form_product_name_query); + echo ' ' . ''; + }else{ + echo ' ' . ''; + } + echo '' . "\n"; + echo '
 
' . ADDPRODUCT_TEXT_STEP . ' 2: ' . ADDPRODUCT_TEXT_OPTIONS_NOTEXIST . '
' . ADDPRODUCT_TEXT_STEP . ' 2: '; + $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . $_GET['add_product_products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name"); + while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { + $products_options_array = array(); + $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . $_GET['add_product_products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'"); + while ($products_options = tep_db_fetch_array($products_options_query)) { + $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']); + if ($products_options['options_values_price'] != '0') { + $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; + } + } + + if(isset($_POST['add_product_options'])) { + $selected_attribute = $_POST['add_product_options'][$products_options_name['products_options_id']]; + } else { + $selected_attribute = false; + } + + echo $products_options_name['products_options_name'] . ':' . "\n"; + echo tep_draw_pull_down_menu('add_product_options[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '
' . "\n"; + } + + echo '
'; + echo ''; + echo ''; + echo '
 
' . ADDPRODUCT_TEXT_STEP . ' 3: ' . ADDPRODUCT_TEXT_CONFIRM_QUANTITY . ''; + if(is_array ($_POST['add_product_options'])) + { + foreach($_POST['add_product_options'] as $option_id => $option_value_id) + { + echo ''; + } + } + echo ''; + echo ''; + echo '
+ + + + +
+ + + \ No newline at end of file diff --git a/catalog/admin/file_manager.php b/catalog/admin/file_manager.php new file mode 100644 index 0000000..3504674 --- /dev/null +++ b/catalog/admin/file_manager.php @@ -0,0 +1,348 @@ +add(sprintf(ERROR_DIRECTORY_NOT_WRITEABLE, $current_path), 'error'); + } + break; + case 'edit': + if (strstr($HTTP_GET_VARS['info'], '..')) tep_redirect(tep_href_link(FILENAME_FILE_MANAGER)); + + $file_writeable = true; + if (!is_writeable($current_path . '/' . $HTTP_GET_VARS['info'])) { + $file_writeable = false; + $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $current_path . '/' . $HTTP_GET_VARS['info']), 'error'); + } + break; + case 'delete': + if (strstr($HTTP_GET_VARS['info'], '..')) tep_redirect(tep_href_link(FILENAME_FILE_MANAGER)); + break; + } + } + + $in_directory = substr(substr(DIR_FS_DOCUMENT_ROOT, strrpos(DIR_FS_DOCUMENT_ROOT, '/')), 1); + $current_path_array = explode('/', $current_path); + $document_root_array = explode('/', DIR_FS_DOCUMENT_ROOT); + $goto_array = array(array('id' => DIR_FS_DOCUMENT_ROOT, 'text' => $in_directory)); + for ($i=0, $n=sizeof($current_path_array); $i<$n; $i++) { + if ((isset($document_root_array[$i]) && ($current_path_array[$i] != $document_root_array[$i])) || !isset($document_root_array[$i])) { + $goto_array[] = array('id' => implode('/', array_slice($current_path_array, 0, $i+1)), 'text' => $current_path_array[$i]); + } + } +?> + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + +read()) { + if ( ($file != '.') && ($file != 'CVS') && ( ($file != '..') || ($current_path != DIR_FS_DOCUMENT_ROOT) ) ) { + $file_size = number_format(filesize($current_path . '/' . $file)) . ' bytes'; + + $permissions = tep_get_file_permissions(fileperms($current_path . '/' . $file)); + if ($showuser) { + $user = @posix_getpwuid(fileowner($current_path . '/' . $file)); + $group = @posix_getgrgid(filegroup($current_path . '/' . $file)); + } else { + $user = $group = array(); + } + + $contents[] = array('name' => $file, + 'is_dir' => is_dir($current_path . '/' . $file), + 'last_modified' => strftime(DATE_TIME_FORMAT, filemtime($current_path . '/' . $file)), + 'size' => $file_size, + 'permissions' => $permissions, + 'user' => $user['name'], + 'group' => $group['name']); + } + } + + function tep_cmp($a, $b) { + return strcmp( ($a['is_dir'] ? 'D' : 'F') . $a['name'], ($b['is_dir'] ? 'D' : 'F') . $b['name']); + } + usort($contents, 'tep_cmp'); +?> + + + + + +
+ + + + + +
' . $current_path . ''; ?>
+ + + + + + + + + + + + + + +
' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''; ?>
+ + + '' . $fInfo->name . ''); + + $contents = array('form' => tep_draw_form('file', FILENAME_FILE_MANAGER, 'info=' . urlencode($fInfo->name) . '&action=deleteconfirm')); + $contents[] = array('text' => TEXT_DELETE_INTRO); + $contents[] = array('text' => '
' . $fInfo->name . ''); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'new_folder': + $heading[] = array('text' => '' . TEXT_NEW_FOLDER . ''); + + $contents = array('form' => tep_draw_form('folder', FILENAME_FILE_MANAGER, 'action=insert')); + $contents[] = array('text' => TEXT_NEW_FOLDER_INTRO); + $contents[] = array('text' => '
' . TEXT_FILE_NAME . '
' . tep_draw_input_field('folder_name')); + $contents[] = array('align' => 'center', 'text' => '
' . (($directory_writeable == true) ? tep_image_submit('button_save.gif', IMAGE_SAVE) : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'upload': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_UPLOAD . ''); + + $contents = array('form' => tep_draw_form('file', FILENAME_FILE_MANAGER, 'action=processuploads', 'post', 'enctype="multipart/form-data"')); + $contents[] = array('text' => TEXT_UPLOAD_INTRO); + + $file_upload = ''; + for ($i=1; $i<6; $i++) $file_upload .= tep_draw_file_field('file_' . $i) . '
'; + + $contents[] = array('text' => '
' . $file_upload); + $contents[] = array('align' => 'center', 'text' => '
' . (($directory_writeable == true) ? tep_image_submit('button_upload.gif', IMAGE_UPLOAD) : '') . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($fInfo) && is_object($fInfo)) { + $heading[] = array('text' => '' . $fInfo->name . ''); + + if (!$fInfo->is_dir) $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . ''); + $contents[] = array('text' => '
' . TEXT_FILE_NAME . ' ' . $fInfo->name . ''); + if (!$fInfo->is_dir) $contents[] = array('text' => '
' . TEXT_FILE_SIZE . ' ' . $fInfo->size . ''); + $contents[] = array('text' => '
' . TEXT_LAST_MODIFIED . ' ' . $fInfo->last_modified); + } + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + + + + +name)) { + if ($fInfo->is_dir) { + echo ' ' . "\n"; + $onclick_link = 'goto=' . $goto_link; + } else { + echo ' ' . "\n"; + $onclick_link = 'info=' . urlencode($fInfo->name) . '&action=edit'; + } + } else { + echo ' ' . "\n"; + $onclick_link = 'info=' . urlencode($contents[$i]['name']); + } + + if ($contents[$i]['is_dir']) { + if ($contents[$i]['name'] == '..') { + $icon = tep_image(DIR_WS_ICONS . 'previous_level.gif', ICON_PREVIOUS_LEVEL); + } else { + $icon = (isset($fInfo) && is_object($fInfo) && ($contents[$i]['name'] == $fInfo->name) ? tep_image(DIR_WS_ICONS . 'current_folder.gif', ICON_CURRENT_FOLDER) : tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER)); + } + $link = tep_href_link(FILENAME_FILE_MANAGER, 'goto=' . $goto_link); + } else { + $icon = tep_image(DIR_WS_ICONS . 'file_download.gif', ICON_FILE_DOWNLOAD); + $link = tep_href_link(FILENAME_FILE_MANAGER, 'action=download&filename=' . urlencode($contents[$i]['name'])); + } +?> + + + + + + + + + + + + +
 
' . $icon . ' ' . $contents[$i]['name']; ?>' . tep_image(DIR_WS_ICONS . 'delete.gif', ICON_DELETE) . ' '; if (isset($fInfo) && is_object($fInfo) && ($fInfo->name == $contents[$i]['name'])) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + +
' . tep_image_button('button_reset.gif', IMAGE_RESET) . ''; ?>' . tep_image_button('button_upload.gif', IMAGE_UPLOAD) . ' ' . tep_image_button('button_new_file.gif', IMAGE_NEW_FILE) . ' ' . tep_image_button('button_new_folder.gif', IMAGE_NEW_FOLDER) . ''; ?>
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/geo_zones.php b/catalog/admin/geo_zones.php new file mode 100644 index 0000000..59104bf --- /dev/null +++ b/catalog/admin/geo_zones.php @@ -0,0 +1,353 @@ + + +> + + +<?php echo TITLE; ?> + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + +
' . tep_get_geo_zone_name($HTTP_GET_VARS['zone']) . ''; ?>
+ + + '' . TEXT_INFO_HEADING_NEW_SUB_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&' . (isset($HTTP_GET_VARS['sID']) ? 'sID=' . $HTTP_GET_VARS['sID'] . '&' : '') . 'saction=insert_sub')); + $contents[] = array('text' => TEXT_INFO_NEW_SUB_ZONE_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY . '
' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(TEXT_ALL_COUNTRIES), '', 'onChange="update_zone(this.form);"')); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_ZONE . '
' . tep_draw_pull_down_menu('zone_id', tep_prepare_country_zones_pull_down())); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'edit': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_SUB_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&sID=' . $sInfo->association_id . '&saction=save_sub')); + $contents[] = array('text' => TEXT_INFO_EDIT_SUB_ZONE_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY . '
' . tep_draw_pull_down_menu('zone_country_id', tep_get_countries(TEXT_ALL_COUNTRIES), $sInfo->zone_country_id, 'onChange="update_zone(this.form);"')); + $contents[] = array('text' => '
' . TEXT_INFO_COUNTRY_ZONE . '
' . tep_draw_pull_down_menu('zone_id', tep_prepare_country_zones_pull_down($sInfo->zone_country_id), $sInfo->zone_id)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_SUB_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list&spage=' . $HTTP_GET_VARS['spage'] . '&sID=' . $sInfo->association_id . '&saction=deleteconfirm_sub')); + $contents[] = array('text' => TEXT_INFO_DELETE_SUB_ZONE_INTRO); + $contents[] = array('text' => '
' . $sInfo->countries_name . ''); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($sInfo) && is_object($sInfo)) { + $heading[] = array('text' => '' . $sInfo->countries_name . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . ''); + $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->date_added)); + if (tep_not_null($sInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->last_modified)); + } + break; + } + } else { + switch ($action) { + case 'new_zone': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_NEW_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=insert_zone')); + $contents[] = array('text' => TEXT_INFO_NEW_ZONE_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_ZONE_NAME . '
' . tep_draw_input_field('geo_zone_name')); + $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . tep_draw_input_field('geo_zone_description')); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'edit_zone': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_EDIT_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=save_zone')); + $contents[] = array('text' => TEXT_INFO_EDIT_ZONE_INTRO); + $contents[] = array('text' => '
' . TEXT_INFO_ZONE_NAME . '
' . tep_draw_input_field('geo_zone_name', $zInfo->geo_zone_name)); + $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . tep_draw_input_field('geo_zone_description', $zInfo->geo_zone_description)); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + case 'delete_zone': + $heading[] = array('text' => '' . TEXT_INFO_HEADING_DELETE_ZONE . ''); + + $contents = array('form' => tep_draw_form('zones', FILENAME_GEO_ZONES, 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $zInfo->geo_zone_id . '&action=deleteconfirm_zone')); + $contents[] = array('text' => TEXT_INFO_DELETE_ZONE_INTRO); + $contents[] = array('text' => '
' . $zInfo->geo_zone_name . ''); + $contents[] = array('align' => 'center', 'text' => '
' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' ' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . ''); + break; + default: + if (isset($zInfo) && is_object($zInfo)) { + $heading[] = array('text' => '' . $zInfo->geo_zone_name . ''); + + $contents[] = array('align' => 'center', 'text' => '' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '' . ' ' . tep_image_button('button_details.gif', IMAGE_DETAILS) . ''); + $contents[] = array('text' => '
' . TEXT_INFO_NUMBER_ZONES . ' ' . $zInfo->num_zones); + $contents[] = array('text' => '
' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($zInfo->date_added)); + if (tep_not_null($zInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($zInfo->last_modified)); + $contents[] = array('text' => '
' . TEXT_INFO_ZONE_DESCRIPTION . '
' . $zInfo->geo_zone_description); + } + break; + } + } + + if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) { + echo ' ' . "\n"; + } +?> + +
+ + + + + + + +association_id)) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + + + + +
 
association_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + +
display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['spage'], TEXT_DISPLAY_NUMBER_OF_COUNTRIES); ?>display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['spage'], 'zpage=' . $HTTP_GET_VARS['zpage'] . '&zID=' . $HTTP_GET_VARS['zID'] . '&action=list', 'spage'); ?>
' . tep_image_button('button_back.gif', IMAGE_BACK) . ' ' . tep_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
+ + + + + + + 0) { + $zones['num_zones'] = $num_zones['num_zones']; + } else { + $zones['num_zones'] = 0; + } + + $zInfo = new objectInfo($zones); + } + if (isset($zInfo) && is_object($zInfo) && ($zones['geo_zone_id'] == $zInfo->geo_zone_id)) { + echo ' ' . "\n"; + } else { + echo ' ' . "\n"; + } +?> + + + + + + + + + + +
 
' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . ' ' . $zones['geo_zone_name']; ?>geo_zone_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . ''; } ?> 
+ + + + +
display_count($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['zpage'], TEXT_DISPLAY_NUMBER_OF_TAX_ZONES); ?>display_links($zones_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['zpage'], '', 'zpage'); ?>
geo_zone_id . '&action=new_zone') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . ''; ?>
+ +
' . "\n"; + + $box = new box; + echo $box->infoBox($heading, $contents); + + echo '
+ + + + + +
+ + + diff --git a/catalog/admin/images/Thumbs.db b/catalog/admin/images/Thumbs.db new file mode 100644 index 0000000..e117521 Binary files /dev/null and b/catalog/admin/images/Thumbs.db differ diff --git a/catalog/admin/images/ani_send_email.gif b/catalog/admin/images/ani_send_email.gif new file mode 100644 index 0000000..a61022b Binary files /dev/null and b/catalog/admin/images/ani_send_email.gif differ diff --git a/catalog/admin/images/cal_close_small.gif b/catalog/admin/images/cal_close_small.gif new file mode 100644 index 0000000..e5994d2 Binary files /dev/null and b/catalog/admin/images/cal_close_small.gif differ diff --git a/catalog/admin/images/cal_date_down.gif b/catalog/admin/images/cal_date_down.gif new file mode 100644 index 0000000..4b4eed4 Binary files /dev/null and b/catalog/admin/images/cal_date_down.gif differ diff --git a/catalog/admin/images/cal_date_over.gif b/catalog/admin/images/cal_date_over.gif new file mode 100644 index 0000000..7e29a4f Binary files /dev/null and b/catalog/admin/images/cal_date_over.gif differ diff --git a/catalog/admin/images/cal_date_up.gif b/catalog/admin/images/cal_date_up.gif new file mode 100644 index 0000000..b4b9084 Binary files /dev/null and b/catalog/admin/images/cal_date_up.gif differ diff --git a/catalog/admin/images/cal_del_small.gif b/catalog/admin/images/cal_del_small.gif new file mode 100644 index 0000000..48632c4 Binary files /dev/null and b/catalog/admin/images/cal_del_small.gif differ diff --git a/catalog/admin/images/categories/Thumbs.db b/catalog/admin/images/categories/Thumbs.db new file mode 100644 index 0000000..5897d2c Binary files /dev/null and b/catalog/admin/images/categories/Thumbs.db differ diff --git a/catalog/admin/images/categories/catalog.gif b/catalog/admin/images/categories/catalog.gif new file mode 100644 index 0000000..e5f4b05 Binary files /dev/null and b/catalog/admin/images/categories/catalog.gif differ diff --git a/catalog/admin/images/categories/configuration.gif b/catalog/admin/images/categories/configuration.gif new file mode 100644 index 0000000..e50dcc2 Binary files /dev/null and b/catalog/admin/images/categories/configuration.gif differ diff --git a/catalog/admin/images/categories/customers.gif b/catalog/admin/images/categories/customers.gif new file mode 100644 index 0000000..bd1f334 Binary files /dev/null and b/catalog/admin/images/categories/customers.gif differ diff --git a/catalog/admin/images/categories/localization.gif b/catalog/admin/images/categories/localization.gif new file mode 100644 index 0000000..517d69e Binary files /dev/null and b/catalog/admin/images/categories/localization.gif differ diff --git a/catalog/admin/images/categories/location.gif b/catalog/admin/images/categories/location.gif new file mode 100644 index 0000000..c29520a Binary files /dev/null and b/catalog/admin/images/categories/location.gif differ diff --git a/catalog/admin/images/categories/modules.gif b/catalog/admin/images/categories/modules.gif new file mode 100644 index 0000000..e7e3f11 Binary files /dev/null and b/catalog/admin/images/categories/modules.gif differ diff --git a/catalog/admin/images/categories/reports.gif b/catalog/admin/images/categories/reports.gif new file mode 100644 index 0000000..f4a82c1 Binary files /dev/null and b/catalog/admin/images/categories/reports.gif differ diff --git a/catalog/admin/images/categories/tools.gif b/catalog/admin/images/categories/tools.gif new file mode 100644 index 0000000..bb55c3a Binary files /dev/null and b/catalog/admin/images/categories/tools.gif differ diff --git a/catalog/admin/images/graph_hbar_blue.gif b/catalog/admin/images/graph_hbar_blue.gif new file mode 100644 index 0000000..3833bd7 Binary files /dev/null and b/catalog/admin/images/graph_hbar_blue.gif differ diff --git a/catalog/admin/images/graph_hbar_red.gif b/catalog/admin/images/graph_hbar_red.gif new file mode 100644 index 0000000..bef4a88 Binary files /dev/null and b/catalog/admin/images/graph_hbar_red.gif differ diff --git a/catalog/admin/images/graphs/.cvsignore b/catalog/admin/images/graphs/.cvsignore new file mode 100644 index 0000000..caa8b09 --- /dev/null +++ b/catalog/admin/images/graphs/.cvsignore @@ -0,0 +1,12 @@ +banner_infobox-*.png +banner_daily-*.png +banner_monthly-*.png +banner_yearly-*.png +banner_infobox-*.jpg +banner_daily-*.jpg +banner_monthly-*.jpg +banner_yearly-*.jpg +banner_infobox-*.gif +banner_daily-*.gif +banner_monthly-*.gif +banner_yearly-*.gif diff --git a/catalog/admin/images/graphs/Thumbs.db b/catalog/admin/images/graphs/Thumbs.db new file mode 100644 index 0000000..7858aa7 Binary files /dev/null and b/catalog/admin/images/graphs/Thumbs.db differ diff --git a/catalog/admin/images/graphs/banner_infobox-1.png b/catalog/admin/images/graphs/banner_infobox-1.png new file mode 100644 index 0000000..50c3ed2 Binary files /dev/null and b/catalog/admin/images/graphs/banner_infobox-1.png differ diff --git a/catalog/admin/images/graphs/dummy b/catalog/admin/images/graphs/dummy new file mode 100644 index 0000000..e69de29 diff --git a/catalog/admin/images/header_administration.gif b/catalog/admin/images/header_administration.gif new file mode 100644 index 0000000..3f08845 Binary files /dev/null and b/catalog/admin/images/header_administration.gif differ diff --git a/catalog/admin/images/header_checkout.gif b/catalog/admin/images/header_checkout.gif new file mode 100644 index 0000000..9b5bd81 Binary files /dev/null and b/catalog/admin/images/header_checkout.gif differ diff --git a/catalog/admin/images/header_support.gif b/catalog/admin/images/header_support.gif new file mode 100644 index 0000000..382c0f1 Binary files /dev/null and b/catalog/admin/images/header_support.gif differ diff --git a/catalog/admin/images/icon_arrow_right.gif b/catalog/admin/images/icon_arrow_right.gif new file mode 100644 index 0000000..9d8bc1d Binary files /dev/null and b/catalog/admin/images/icon_arrow_right.gif differ diff --git a/catalog/admin/images/icon_info.gif b/catalog/admin/images/icon_info.gif new file mode 100644 index 0000000..7bfbc62 Binary files /dev/null and b/catalog/admin/images/icon_info.gif differ diff --git a/catalog/admin/images/icon_popup.gif b/catalog/admin/images/icon_popup.gif new file mode 100644 index 0000000..3d60f42 Binary files /dev/null and b/catalog/admin/images/icon_popup.gif differ diff --git a/catalog/admin/images/icon_reset.gif b/catalog/admin/images/icon_reset.gif new file mode 100644 index 0000000..bd1c0cb Binary files /dev/null and b/catalog/admin/images/icon_reset.gif differ diff --git a/catalog/admin/images/icon_save.gif b/catalog/admin/images/icon_save.gif new file mode 100644 index 0000000..93f2afa Binary files /dev/null and b/catalog/admin/images/icon_save.gif differ diff --git a/catalog/admin/images/icon_status_green.gif b/catalog/admin/images/icon_status_green.gif new file mode 100644 index 0000000..964a742 Binary files /dev/null and b/catalog/admin/images/icon_status_green.gif differ diff --git a/catalog/admin/images/icon_status_green_light.gif b/catalog/admin/images/icon_status_green_light.gif new file mode 100644 index 0000000..46e0a02 Binary files /dev/null and b/catalog/admin/images/icon_status_green_light.gif differ diff --git a/catalog/admin/images/icon_status_red.gif b/catalog/admin/images/icon_status_red.gif new file mode 100644 index 0000000..3f8c2fe Binary files /dev/null and b/catalog/admin/images/icon_status_red.gif differ diff --git a/catalog/admin/images/icon_status_red_light.gif b/catalog/admin/images/icon_status_red_light.gif new file mode 100644 index 0000000..f264494 Binary files /dev/null and b/catalog/admin/images/icon_status_red_light.gif differ diff --git a/catalog/admin/images/icon_status_yellow.gif b/catalog/admin/images/icon_status_yellow.gif new file mode 100644 index 0000000..9cef3b8 Binary files /dev/null and b/catalog/admin/images/icon_status_yellow.gif differ diff --git a/catalog/admin/images/icons/Thumbs.db b/catalog/admin/images/icons/Thumbs.db new file mode 100644 index 0000000..0a4a17d Binary files /dev/null and b/catalog/admin/images/icons/Thumbs.db differ diff --git a/catalog/admin/images/icons/cross.gif b/catalog/admin/images/icons/cross.gif new file mode 100644 index 0000000..76d55a2 Binary files /dev/null and b/catalog/admin/images/icons/cross.gif differ diff --git a/catalog/admin/images/icons/current_folder.gif b/catalog/admin/images/icons/current_folder.gif new file mode 100644 index 0000000..ba2d7b0 Binary files /dev/null and b/catalog/admin/images/icons/current_folder.gif differ diff --git a/catalog/admin/images/icons/delete.gif b/catalog/admin/images/icons/delete.gif new file mode 100644 index 0000000..100f1e7 Binary files /dev/null and b/catalog/admin/images/icons/delete.gif differ diff --git a/catalog/admin/images/icons/error.gif b/catalog/admin/images/icons/error.gif new file mode 100644 index 0000000..d0e4f43 Binary files /dev/null and b/catalog/admin/images/icons/error.gif differ diff --git a/catalog/admin/images/icons/file.gif b/catalog/admin/images/icons/file.gif new file mode 100644 index 0000000..3122567 Binary files /dev/null and b/catalog/admin/images/icons/file.gif differ diff --git a/catalog/admin/images/icons/file_download.gif b/catalog/admin/images/icons/file_download.gif new file mode 100644 index 0000000..83e5e95 Binary files /dev/null and b/catalog/admin/images/icons/file_download.gif differ diff --git a/catalog/admin/images/icons/folder.gif b/catalog/admin/images/icons/folder.gif new file mode 100644 index 0000000..b55d830 Binary files /dev/null and b/catalog/admin/images/icons/folder.gif differ diff --git a/catalog/admin/images/icons/locked.gif b/catalog/admin/images/icons/locked.gif new file mode 100644 index 0000000..d23d2a1 Binary files /dev/null and b/catalog/admin/images/icons/locked.gif differ diff --git a/catalog/admin/images/icons/preview.gif b/catalog/admin/images/icons/preview.gif new file mode 100644 index 0000000..7e01028 Binary files /dev/null and b/catalog/admin/images/icons/preview.gif differ diff --git a/catalog/admin/images/icons/previous_level.gif b/catalog/admin/images/icons/previous_level.gif new file mode 100644 index 0000000..1ff3913 Binary files /dev/null and b/catalog/admin/images/icons/previous_level.gif differ diff --git a/catalog/admin/images/icons/statistics.gif b/catalog/admin/images/icons/statistics.gif new file mode 100644 index 0000000..98c0c6c Binary files /dev/null and b/catalog/admin/images/icons/statistics.gif differ diff --git a/catalog/admin/images/icons/success.gif b/catalog/admin/images/icons/success.gif new file mode 100644 index 0000000..daaebdf Binary files /dev/null and b/catalog/admin/images/icons/success.gif differ diff --git a/catalog/admin/images/icons/tick.gif b/catalog/admin/images/icons/tick.gif new file mode 100644 index 0000000..3851940 Binary files /dev/null and b/catalog/admin/images/icons/tick.gif differ diff --git a/catalog/admin/images/icons/unlocked.gif b/catalog/admin/images/icons/unlocked.gif new file mode 100644 index 0000000..b767637 Binary files /dev/null and b/catalog/admin/images/icons/unlocked.gif differ diff --git a/catalog/admin/images/icons/warning.gif b/catalog/admin/images/icons/warning.gif new file mode 100644 index 0000000..904485c Binary files /dev/null and b/catalog/admin/images/icons/warning.gif differ diff --git a/catalog/admin/images/oscommerce.gif b/catalog/admin/images/oscommerce.gif new file mode 100644 index 0000000..5a6a3c2 Binary files /dev/null and b/catalog/admin/images/oscommerce.gif differ diff --git a/catalog/admin/images/pixel_black.gif b/catalog/admin/images/pixel_black.gif new file mode 100644 index 0000000..f1d566b Binary files /dev/null and b/catalog/admin/images/pixel_black.gif differ diff --git a/catalog/admin/images/pixel_trans.gif b/catalog/admin/images/pixel_trans.gif new file mode 100644 index 0000000..e7749f2 Binary files /dev/null and b/catalog/admin/images/pixel_trans.gif differ diff --git a/catalog/admin/includes/application_bottom.php b/catalog/admin/includes/application_bottom.php new file mode 100644 index 0000000..5a598cc --- /dev/null +++ b/catalog/admin/includes/application_bottom.php @@ -0,0 +1,20 @@ +timer_stop(DISPLAY_PAGE_PARSE_TIME); + } +?> \ No newline at end of file diff --git a/catalog/admin/includes/application_top.php b/catalog/admin/includes/application_top.php new file mode 100644 index 0000000..27267f5 --- /dev/null +++ b/catalog/admin/includes/application_top.php @@ -0,0 +1,208 @@ +set_language($HTTP_GET_VARS['language']); + } else { + $lng->get_browser_language(); + } + + $language = $lng->language['directory']; + $languages_id = $lng->language['id']; + } + +// include the language translations + require(DIR_WS_LANGUAGES . $language . '.php'); + $current_page = basename($PHP_SELF); + if (file_exists(DIR_WS_LANGUAGES . $language . '/' . $current_page)) { + include(DIR_WS_LANGUAGES . $language . '/' . $current_page); + } + +// define our localization functions + require(DIR_WS_FUNCTIONS . 'localization.php'); + +// Include validation functions (right now only email address) + require(DIR_WS_FUNCTIONS . 'validations.php'); + +// setup our boxes + require(DIR_WS_CLASSES . 'table_block.php'); + require(DIR_WS_CLASSES . 'box.php'); + +// initialize the message stack for output messages + require(DIR_WS_CLASSES . 'message_stack.php'); + $messageStack = new messageStack; + +// split-page-results + require(DIR_WS_CLASSES . 'split_page_results.php'); + +// entry/item info classes + require(DIR_WS_CLASSES . 'object_info.php'); + +// email classes + require(DIR_WS_CLASSES . 'mime.php'); + require(DIR_WS_CLASSES . 'email.php'); + +// file uploading class + require(DIR_WS_CLASSES . 'upload.php'); + +// calculate category path + if (isset($HTTP_GET_VARS['cPath'])) { + $cPath = $HTTP_GET_VARS['cPath']; + } else { + $cPath = ''; + } + + if (tep_not_null($cPath)) { + $cPath_array = tep_parse_category_path($cPath); + $cPath = implode('_', $cPath_array); + $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; + } else { + $current_category_id = 0; + } + +// default open navigation box + if (!tep_session_is_registered('selected_box')) { + tep_session_register('selected_box'); + $selected_box = 'configuration'; + } + + if (isset($HTTP_GET_VARS['selected_box'])) { + $selected_box = $HTTP_GET_VARS['selected_box']; + } + +// the following cache blocks are used in the Tools->Cache section +// ('language' in the filename is automatically replaced by available languages) + $cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true), + array('title' => TEXT_CACHE_MANUFACTURERS, 'code' => 'manufacturers', 'file' => 'manufacturers_box-language.cache', 'multiple' => true), + array('title' => TEXT_CACHE_ALSO_PURCHASED, 'code' => 'also_purchased', 'file' => 'also_purchased-language.cache', 'multiple' => true) + ); + +// check if a default currency is set + if (!defined('DEFAULT_CURRENCY')) { + $messageStack->add(ERROR_NO_DEFAULT_CURRENCY_DEFINED, 'error'); + } + +// check if a default language is set + if (!defined('DEFAULT_LANGUAGE')) { + $messageStack->add(ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error'); + } + + if (function_exists('ini_get') && ((bool)ini_get('file_uploads') == false) ) { + $messageStack->add(WARNING_FILE_UPLOADS_DISABLED, 'warning'); + } +?> diff --git a/catalog/admin/includes/boxes/catalog.php b/catalog/admin/includes/boxes/catalog.php new file mode 100644 index 0000000..6721fb4 --- /dev/null +++ b/catalog/admin/includes/boxes/catalog.php @@ -0,0 +1,39 @@ + + +
+ BOX_HEADING_CATALOG, + 'link' => tep_href_link(FILENAME_CATEGORIES, 'selected_box=catalog')); + + if ($selected_box == 'catalog') { + $contents[] = array('text' => '' . BOX_CATALOG_CATEGORIES_PRODUCTS . '
' . + '' . BOX_CATALOG_CATEGORIES_PRODUCTS_ATTRIBUTES . '
' . + + 'Easy Populate
'. + '' . BOX_CATALOG_MANUFACTURERS . '
' . + '' . BOX_CATALOG_REVIEWS . '
' . + '' . BOX_CATALOG_SPECIALS . '
' . + '' . BOX_CATALOG_PRODUCTS_EXPECTED . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_CONFIGURATION, + 'link' => tep_href_link(FILENAME_CONFIGURATION, 'gID=1&selected_box=configuration')); + + if ($selected_box == 'configuration') { + $cfg_groups = ''; + $configuration_groups_query = tep_db_query("select configuration_group_id as cgID, configuration_group_title as cgTitle from " . TABLE_CONFIGURATION_GROUP . " where visible = '1' order by sort_order"); + while ($configuration_groups = tep_db_fetch_array($configuration_groups_query)) { + $cfg_groups .= '' . $configuration_groups['cgTitle'] . '
'; + } + + $contents[] = array('text' => $cfg_groups); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_CUSTOMERS, + 'link' => tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers')); + + if ($selected_box == 'customers') { + $contents[] = array('text' => '' . BOX_CUSTOMERS_CUSTOMERS . '
' . + '' . BOX_CUSTOMERS_ORDERS . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_LOCALIZATION, + 'link' => tep_href_link(FILENAME_CURRENCIES, 'selected_box=localization')); + + if ($selected_box == 'localization') { + $contents[] = array('text' => '' . BOX_LOCALIZATION_CURRENCIES . '
' . + '' . BOX_LOCALIZATION_LANGUAGES . '
' . + '' . BOX_LOCALIZATION_ORDERS_STATUS . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_MODULES, + 'link' => tep_href_link(FILENAME_MODULES, 'set=payment&selected_box=modules')); + + if ($selected_box == 'modules') { + $contents[] = array('text' => '' . BOX_MODULES_PAYMENT . '
' . + '' . BOX_MODULES_SHIPPING . '
' . + // START STS 4.1 + '' . BOX_MODULES_STS . '
' . + // END STS 4.1 + '' . BOX_MODULES_ORDER_TOTAL . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_REPORTS, + 'link' => tep_href_link(FILENAME_STATS_PRODUCTS_VIEWED, 'selected_box=reports')); + + if ($selected_box == 'reports') { + $contents[] = array('text' => '' . BOX_REPORTS_PRODUCTS_VIEWED . '
' . + '' . BOX_REPORTS_PRODUCTS_PURCHASED . '
' . + '' . BOX_REPORTS_ORDERS_TOTAL . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_LOCATION_AND_TAXES, + 'link' => tep_href_link(FILENAME_COUNTRIES, 'selected_box=taxes')); + + if ($selected_box == 'taxes') { + $contents[] = array('text' => '' . BOX_TAXES_COUNTRIES . '
' . + '' . BOX_TAXES_ZONES . '
' . + '' . BOX_TAXES_GEO_ZONES . '
' . + '' . BOX_TAXES_TAX_CLASSES . '
' . + '' . BOX_TAXES_TAX_RATES . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
+ BOX_HEADING_TOOLS, + 'link' => tep_href_link(FILENAME_BACKUP, 'selected_box=tools')); + + if ($selected_box == 'tools') { + $contents[] = array('text' => '' . BOX_TOOLS_BACKUP . '
' . + '' . BOX_TOOLS_BANNER_MANAGER . '
' . + '' . BOX_TOOLS_CACHE . '
' . + '' . BOX_TOOLS_DEFINE_LANGUAGE . '
' . + '' . BOX_TOOLS_FILE_MANAGER . '
' . + '' . BOX_TOOLS_MAIL . '
' . + '' . BOX_TOOLS_NEWSLETTER_MANAGER . '
' . + '' . BOX_TOOLS_SERVER_INFO . '
' . + '' . BOX_TOOLS_WHOS_ONLINE . ''); + } + + $box = new box; + echo $box->menuBox($heading, $contents); +?> +
' . "\n"; + + if ($form_set == true) $tableBox_string .= '' . "\n"; + + return $tableBox_string; + } + } +?> diff --git a/catalog/admin/includes/classes/upload.php b/catalog/admin/includes/classes/upload.php new file mode 100644 index 0000000..aee7931 --- /dev/null +++ b/catalog/admin/includes/classes/upload.php @@ -0,0 +1,180 @@ +set_file($file); + $this->set_destination($destination); + $this->set_permissions($permissions); + $this->set_extensions($extensions); + + $this->set_output_messages('direct'); + + if (tep_not_null($this->file) && tep_not_null($this->destination)) { + $this->set_output_messages('session'); + + if ( ($this->parse() == true) && ($this->save() == true) ) { + return true; + } else { + return false; + } + } + } + + function parse() { + global $messageStack; + + if (isset($_FILES[$this->file])) { + $file = array('name' => $_FILES[$this->file]['name'], + 'type' => $_FILES[$this->file]['type'], + 'size' => $_FILES[$this->file]['size'], + 'tmp_name' => $_FILES[$this->file]['tmp_name']); + } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) { + global $HTTP_POST_FILES; + + $file = array('name' => $HTTP_POST_FILES[$this->file]['name'], + 'type' => $HTTP_POST_FILES[$this->file]['type'], + 'size' => $HTTP_POST_FILES[$this->file]['size'], + 'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']); + } else { + $file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''), + 'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''), + 'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''), + 'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : '')); + } + + if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { + if (sizeof($this->extensions) > 0) { + if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) { + if ($this->message_location == 'direct') { + $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error'); + } else { + $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error'); + } + + return false; + } + } + + $this->set_file($file); + $this->set_filename($file['name']); + $this->set_tmp_filename($file['tmp_name']); + + return $this->check_destination(); + } else { + if ($this->message_location == 'direct') { + $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning'); + } else { + $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning'); + } + + return false; + } + } + + function save() { + global $messageStack; + + if (substr($this->destination, -1) != '/') $this->destination .= '/'; + + if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) { + chmod($this->destination . $this->filename, $this->permissions); + + if ($this->message_location == 'direct') { + $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); + } else { + $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); + } + + return true; + } else { + if ($this->message_location == 'direct') { + $messageStack->add(ERROR_FILE_NOT_SAVED, 'error'); + } else { + $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error'); + } + + return false; + } + } + + function set_file($file) { + $this->file = $file; + } + + function set_destination($destination) { + $this->destination = $destination; + } + + function set_permissions($permissions) { + $this->permissions = octdec($permissions); + } + + function set_filename($filename) { + $this->filename = $filename; + } + + function set_tmp_filename($filename) { + $this->tmp_filename = $filename; + } + + function set_extensions($extensions) { + if (tep_not_null($extensions)) { + if (is_array($extensions)) { + $this->extensions = $extensions; + } else { + $this->extensions = array($extensions); + } + } else { + $this->extensions = array(); + } + } + + function check_destination() { + global $messageStack; + + if (!is_writeable($this->destination)) { + if (is_dir($this->destination)) { + if ($this->message_location == 'direct') { + $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); + } else { + $messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); + } + } else { + if ($this->message_location == 'direct') { + $messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); + } else { + $messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); + } + } + + return false; + } else { + return true; + } + } + + function set_output_messages($location) { + switch ($location) { + case 'session': + $this->message_location = 'session'; + break; + case 'direct': + default: + $this->message_location = 'direct'; + break; + } + } + } +?> diff --git a/catalog/admin/includes/column_left.php b/catalog/admin/includes/column_left.php new file mode 100644 index 0000000..c0a8b7b --- /dev/null +++ b/catalog/admin/includes/column_left.php @@ -0,0 +1,21 @@ + diff --git a/catalog/admin/includes/database_tables.php b/catalog/admin/includes/database_tables.php new file mode 100644 index 0000000..64998c6 --- /dev/null +++ b/catalog/admin/includes/database_tables.php @@ -0,0 +1,58 @@ + diff --git a/catalog/admin/includes/filenames.php b/catalog/admin/includes/filenames.php new file mode 100644 index 0000000..617b6a1 --- /dev/null +++ b/catalog/admin/includes/filenames.php @@ -0,0 +1,59 @@ + \ No newline at end of file diff --git a/catalog/admin/includes/footer.php b/catalog/admin/includes/footer.php new file mode 100644 index 0000000..8d7e787 --- /dev/null +++ b/catalog/admin/includes/footer.php @@ -0,0 +1,43 @@ + +
+ + + + + + + + + + +
+ +E-Commerce Engine Copyright © 2005 osCommerce
+osCommerce provides no warranty and is redistributable under the GNU General Public License +
Powered by osCommerce
diff --git a/catalog/admin/includes/form_check.js.php b/catalog/admin/includes/form_check.js.php new file mode 100644 index 0000000..0b9a2b1 --- /dev/null +++ b/catalog/admin/includes/form_check.js.php @@ -0,0 +1,150 @@ + + + \ No newline at end of file diff --git a/catalog/admin/includes/functions/compatibility.php b/catalog/admin/includes/functions/compatibility.php new file mode 100644 index 0000000..99bcd5c --- /dev/null +++ b/catalog/admin/includes/functions/compatibility.php @@ -0,0 +1,156 @@ + 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val; + + return (array)$array_merged; + } + } + + if (!function_exists('array_shift')) { + function array_shift(&$array) { + $i = 0; + $shifted_array = array(); + reset($array); + while (list($key, $value) = each($array)) { + if ($i > 0) { + $shifted_array[$key] = $value; + } else { + $return = $array[$key]; + } + $i++; + } + $array = $shifted_array; + + return $return; + } + } + + if (!function_exists('array_reverse')) { + function array_reverse($array) { + $reversed_array = array(); + + for ($i=sizeof($array)-1; $i>=0; $i--) { + $reversed_array[] = $array[$i]; + } + + return $reversed_array; + } + } + + if (!function_exists('array_slice')) { + function array_slice($array, $offset, $length = '0') { + $length = abs($length); + + if ($length == 0) { + $high = sizeof($array); + } else { + $high = $offset+$length; + } + + for ($i=$offset; $i<$high; $i++) { + $new_array[$i-$offset] = $array[$i]; + } + + return $new_array; + } + } +?> diff --git a/catalog/admin/includes/functions/database.php b/catalog/admin/includes/functions/database.php new file mode 100644 index 0000000..8c452d9 --- /dev/null +++ b/catalog/admin/includes/functions/database.php @@ -0,0 +1,155 @@ +' . $errno . ' - ' . $error . '

' . $query . '

[TEP STOP]

'); + } + + function tep_db_query($query, $link = 'db_link') { + global $$link, $logger; + + if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { + if (!is_object($logger)) $logger = new logger; + $logger->write($query, 'QUERY'); + } + + $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error()); + + if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { + if (mysql_error()) $logger->write(mysql_error(), 'ERROR'); + } + + return $result; + } + + function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') { + reset($data); + if ($action == 'insert') { + $query = 'insert into ' . $table . ' ('; + while (list($columns, ) = each($data)) { + $query .= $columns . ', '; + } + $query = substr($query, 0, -2) . ') values ('; + reset($data); + while (list(, $value) = each($data)) { + switch ((string)$value) { + case 'now()': + $query .= 'now(), '; + break; + case 'null': + $query .= 'null, '; + break; + default: + $query .= '\'' . tep_db_input($value) . '\', '; + break; + } + } + $query = substr($query, 0, -2) . ')'; + } elseif ($action == 'update') { + $query = 'update ' . $table . ' set '; + while (list($columns, $value) = each($data)) { + switch ((string)$value) { + case 'now()': + $query .= $columns . ' = now(), '; + break; + case 'null': + $query .= $columns .= ' = null, '; + break; + default: + $query .= $columns . ' = \'' . tep_db_input($value) . '\', '; + break; + } + } + $query = substr($query, 0, -2) . ' where ' . $parameters; + } + + return tep_db_query($query, $link); + } + + function tep_db_fetch_array($db_query) { + return mysql_fetch_array($db_query, MYSQL_ASSOC); + } + + function tep_db_result($result, $row, $field = '') { + return mysql_result($result, $row, $field); + } + + function tep_db_num_rows($db_query) { + return mysql_num_rows($db_query); + } + + function tep_db_data_seek($db_query, $row_number) { + return mysql_data_seek($db_query, $row_number); + } + + function tep_db_insert_id() { + return mysql_insert_id(); + } + + function tep_db_free_result($db_query) { + return mysql_free_result($db_query); + } + + function tep_db_fetch_fields($db_query) { + return mysql_fetch_field($db_query); + } + + function tep_db_output($string) { + return htmlspecialchars($string); + } + + function tep_db_input($string, $link = 'db_link') { + global $$link; + + if (function_exists('mysql_real_escape_string')) { + return mysql_real_escape_string($string, $$link); + } elseif (function_exists('mysql_escape_string')) { + return mysql_escape_string($string); + } + + return addslashes($string); + } + + function tep_db_prepare_input($string) { + if (is_string($string)) { + return trim(stripslashes($string)); + } elseif (is_array($string)) { + reset($string); + while (list($key, $value) = each($string)) { + $string[$key] = tep_db_prepare_input($value); + } + return $string; + } else { + return $string; + } + } +?> diff --git a/catalog/admin/includes/functions/general.php b/catalog/admin/includes/functions/general.php new file mode 100644 index 0000000..821832f --- /dev/null +++ b/catalog/admin/includes/functions/general.php @@ -0,0 +1,1310 @@ +timer_stop(); + } + + exit; + } + +//// +// Parse the data used in the html tags to ensure the tags will not break + function tep_parse_input_field_data($data, $parse) { + return strtr(trim($data), $parse); + } + + function tep_output_string($string, $translate = false, $protected = false) { + if ($protected == true) { + return htmlspecialchars($string); + } else { + if ($translate == false) { + return tep_parse_input_field_data($string, array('"' => '"')); + } else { + return tep_parse_input_field_data($string, $translate); + } + } + } + + function tep_output_string_protected($string) { + return tep_output_string($string, false, true); + } + + function tep_sanitize_string($string) { + $string = ereg_replace(' +', ' ', $string); + + return preg_replace("/[<>]/", '_', $string); + } + + function tep_customers_name($customers_id) { + $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'"); + $customers_values = tep_db_fetch_array($customers); + + return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname']; + } + + function tep_get_path($current_category_id = '') { + global $cPath_array; + + if ($current_category_id == '') { + $cPath_new = implode('_', $cPath_array); + } else { + if (sizeof($cPath_array) == 0) { + $cPath_new = $current_category_id; + } else { + $cPath_new = ''; + $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'"); + $last_category = tep_db_fetch_array($last_category_query); + + $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); + $current_category = tep_db_fetch_array($current_category_query); + + if ($last_category['parent_id'] == $current_category['parent_id']) { + for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) { + $cPath_new .= '_' . $cPath_array[$i]; + } + } else { + for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) { + $cPath_new .= '_' . $cPath_array[$i]; + } + } + + $cPath_new .= '_' . $current_category_id; + + if (substr($cPath_new, 0, 1) == '_') { + $cPath_new = substr($cPath_new, 1); + } + } + } + + return 'cPath=' . $cPath_new; + } + + function tep_get_all_get_params($exclude_array = '') { + global $HTTP_GET_VARS; + + if ($exclude_array == '') $exclude_array = array(); + + $get_url = ''; + + reset($HTTP_GET_VARS); + while (list($key, $value) = each($HTTP_GET_VARS)) { + if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&'; + } + + return $get_url; + } + + function tep_date_long($raw_date) { + if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; + + $year = (int)substr($raw_date, 0, 4); + $month = (int)substr($raw_date, 5, 2); + $day = (int)substr($raw_date, 8, 2); + $hour = (int)substr($raw_date, 11, 2); + $minute = (int)substr($raw_date, 14, 2); + $second = (int)substr($raw_date, 17, 2); + + return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year)); + } + +//// +// Output a raw date string in the selected locale date format +// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS +// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers + function tep_date_short($raw_date) { + if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; + + $year = substr($raw_date, 0, 4); + $month = (int)substr($raw_date, 5, 2); + $day = (int)substr($raw_date, 8, 2); + $hour = (int)substr($raw_date, 11, 2); + $minute = (int)substr($raw_date, 14, 2); + $second = (int)substr($raw_date, 17, 2); + + if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { + return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); + } else { + return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); + } + + } + + function tep_datetime_short($raw_datetime) { + if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false; + + $year = (int)substr($raw_datetime, 0, 4); + $month = (int)substr($raw_datetime, 5, 2); + $day = (int)substr($raw_datetime, 8, 2); + $hour = (int)substr($raw_datetime, 11, 2); + $minute = (int)substr($raw_datetime, 14, 2); + $second = (int)substr($raw_datetime, 17, 2); + + return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); + } + + function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) { + global $languages_id; + + if (!is_array($category_tree_array)) $category_tree_array = array(); + if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP); + + if ($include_itself) { + $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'"); + $category = tep_db_fetch_array($category_query); + $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']); + } + + $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name"); + while ($categories = tep_db_fetch_array($categories_query)) { + if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']); + $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array); + } + + return $category_tree_array; + } + + function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') { + global $currencies, $languages_id; + + if ($exclude == '') { + $exclude = array(); + } + + $select_string = ''; + + return $select_string; + } + + function tep_options_name($options_id) { + global $languages_id; + + $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'"); + $options_values = tep_db_fetch_array($options); + + return $options_values['products_options_name']; + } + + function tep_values_name($values_id) { + global $languages_id; + + $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'"); + $values_values = tep_db_fetch_array($values); + + return $values_values['products_options_values_name']; + } + + function tep_info_image($image, $alt, $width = '', $height = '') { + if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) { + $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height); + } else { + $image = TEXT_IMAGE_NONEXISTENT; + } + + return $image; + } + + function tep_break_string($string, $len, $break_char = '-') { + $l = 0; + $output = ''; + for ($i=0, $n=strlen($string); $i<$n; $i++) { + $char = substr($string, $i, 1); + if ($char != ' ') { + $l++; + } else { + $l = 0; + } + if ($l > $len) { + $l = 1; + $output .= $break_char; + } + $output .= $char; + } + + return $output; + } + + function tep_get_country_name($country_id) { + $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'"); + + if (!tep_db_num_rows($country_query)) { + return $country_id; + } else { + $country = tep_db_fetch_array($country_query); + return $country['countries_name']; + } + } + + function tep_get_zone_name($country_id, $zone_id, $default_zone) { + $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'"); + if (tep_db_num_rows($zone_query)) { + $zone = tep_db_fetch_array($zone_query); + return $zone['zone_name']; + } else { + return $default_zone; + } + } + + function tep_not_null($value) { + if (is_array($value)) { + if (sizeof($value) > 0) { + return true; + } else { + return false; + } + } else { + if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) { + return true; + } else { + return false; + } + } + } + + function tep_browser_detect($component) { + global $HTTP_USER_AGENT; + + return stristr($HTTP_USER_AGENT, $component); + } + + function tep_tax_classes_pull_down($parameters, $selected = '') { + $select_string = ''; + + return $select_string; + } + + function tep_geo_zones_pull_down($parameters, $selected = '') { + $select_string = ''; + + return $select_string; + } + + function tep_get_geo_zone_name($geo_zone_id) { + $zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'"); + + if (!tep_db_num_rows($zones_query)) { + $geo_zone_name = $geo_zone_id; + } else { + $zones = tep_db_fetch_array($zones_query); + $geo_zone_name = $zones['geo_zone_name']; + } + + return $geo_zone_name; + } + + function tep_address_format($address_format_id, $address, $html, $boln, $eoln) { + $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'"); + $address_format = tep_db_fetch_array($address_format_query); + + $company = tep_output_string_protected($address['company']); + if (isset($address['firstname']) && tep_not_null($address['firstname'])) { + $firstname = tep_output_string_protected($address['firstname']); + $lastname = tep_output_string_protected($address['lastname']); + } elseif (isset($address['name']) && tep_not_null($address['name'])) { + $firstname = tep_output_string_protected($address['name']); + $lastname = ''; + } else { + $firstname = ''; + $lastname = ''; + } + $street = tep_output_string_protected($address['street_address']); + $suburb = tep_output_string_protected($address['suburb']); + $city = tep_output_string_protected($address['city']); + $state = tep_output_string_protected($address['state']); + if (isset($address['country_id']) && tep_not_null($address['country_id'])) { + $country = tep_get_country_name($address['country_id']); + + if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) { + $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state); + } + } elseif (isset($address['country']) && tep_not_null($address['country'])) { + $country = tep_output_string_protected($address['country']); + } else { + $country = ''; + } + $postcode = tep_output_string_protected($address['postcode']); + $zip = $postcode; + + if ($html) { +// HTML Mode + $HR = '
'; + $hr = '
'; + if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults + $CR = '
'; + $cr = '
'; + $eoln = $cr; + } else { // Use values supplied + $CR = $eoln . $boln; + $cr = $CR; + } + } else { +// Text Mode + $CR = $eoln; + $cr = $CR; + $HR = '----------------------------------------'; + $hr = '----------------------------------------'; + } + + $statecomma = ''; + $streets = $street; + if ($suburb != '') $streets = $street . $cr . $suburb; + if ($country == '') $country = tep_output_string_protected($address['country']); + if ($state != '') $statecomma = $state . ', '; + + $fmt = $address_format['format']; + eval("\$address = \"$fmt\";"); + + if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) { + $address = $company . $cr . $address; + } + + return $address; + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + // + // Function : tep_get_zone_code + // + // Arguments : country country code string + // zone state/province zone_id + // def_state default string if zone==0 + // + // Return : state_prov_code state/province code + // + // Description : Function to retrieve the state/province code (as in FL for Florida etc) + // + //////////////////////////////////////////////////////////////////////////////////////////////// + function tep_get_zone_code($country, $zone, $def_state) { + + $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'"); + + if (!tep_db_num_rows($state_prov_query)) { + $state_prov_code = $def_state; + } + else { + $state_prov_values = tep_db_fetch_array($state_prov_query); + $state_prov_code = $state_prov_values['zone_code']; + } + + return $state_prov_code; + } + + function tep_get_uprid($prid, $params) { + $uprid = $prid; + if ( (is_array($params)) && (!strstr($prid, '{')) ) { + while (list($option, $value) = each($params)) { + $uprid = $uprid . '{' . $option . '}' . $value; + } + } + + return $uprid; + } + + function tep_get_prid($uprid) { + $pieces = explode('{', $uprid); + + return $pieces[0]; + } + + function tep_get_languages() { + $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); + while ($languages = tep_db_fetch_array($languages_query)) { + $languages_array[] = array('id' => $languages['languages_id'], + 'name' => $languages['name'], + 'code' => $languages['code'], + 'image' => $languages['image'], + 'directory' => $languages['directory']); + } + + return $languages_array; + } + + function tep_get_category_name($category_id, $language_id) { + $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'"); + $category = tep_db_fetch_array($category_query); + + return $category['categories_name']; + } + + function tep_get_orders_status_name($orders_status_id, $language_id = '') { + global $languages_id; + + if (!$language_id) $language_id = $languages_id; + $orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'"); + $orders_status = tep_db_fetch_array($orders_status_query); + + return $orders_status['orders_status_name']; + } + + function tep_get_orders_status() { + global $languages_id; + + $orders_status_array = array(); + $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id"); + while ($orders_status = tep_db_fetch_array($orders_status_query)) { + $orders_status_array[] = array('id' => $orders_status['orders_status_id'], + 'text' => $orders_status['orders_status_name']); + } + + return $orders_status_array; + } + + function tep_get_products_name($product_id, $language_id = 0) { + global $languages_id; + + if ($language_id == 0) $language_id = $languages_id; + $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); + $product = tep_db_fetch_array($product_query); + + return $product['products_name']; + } + + function tep_get_products_description($product_id, $language_id) { + $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); + $product = tep_db_fetch_array($product_query); + + return $product['products_description']; + } + + function tep_get_products_url($product_id, $language_id) { + $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'"); + $product = tep_db_fetch_array($product_query); + + return $product['products_url']; + } + +//// +// Return the manufacturers URL in the needed language +// TABLES: manufacturers_info + function tep_get_manufacturer_url($manufacturer_id, $language_id) { + $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'"); + $manufacturer = tep_db_fetch_array($manufacturer_query); + + return $manufacturer['manufacturers_url']; + } + +//// +// Wrapper for class_exists() function +// This function is not available in all PHP versions so we test it before using it. + function tep_class_exists($class_name) { + if (function_exists('class_exists')) { + return class_exists($class_name); + } else { + return true; + } + } + +//// +// Count how many products exist in a category +// TABLES: products, products_to_categories, categories + function tep_products_in_category_count($categories_id, $include_deactivated = false) { + $products_count = 0; + + if ($include_deactivated) { + $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'"); + } else { + $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'"); + } + + $products = tep_db_fetch_array($products_query); + + $products_count += $products['total']; + + $childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'"); + if (tep_db_num_rows($childs_query)) { + while ($childs = tep_db_fetch_array($childs_query)) { + $products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated); + } + } + + return $products_count; + } + +//// +// Count how many subcategories exist in a category +// TABLES: categories + function tep_childs_in_category_count($categories_id) { + $categories_count = 0; + + $categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'"); + while ($categories = tep_db_fetch_array($categories_query)) { + $categories_count++; + $categories_count += tep_childs_in_category_count($categories['categories_id']); + } + + return $categories_count; + } + +//// +// Returns an array with countries +// TABLES: countries + function tep_get_countries($default = '') { + $countries_array = array(); + if ($default) { + $countries_array[] = array('id' => '', + 'text' => $default); + } + $countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name"); + while ($countries = tep_db_fetch_array($countries_query)) { + $countries_array[] = array('id' => $countries['countries_id'], + 'text' => $countries['countries_name']); + } + + return $countries_array; + } + +//// +// return an array with country zones + function tep_get_country_zones($country_id) { + $zones_array = array(); + $zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' order by zone_name"); + while ($zones = tep_db_fetch_array($zones_query)) { + $zones_array[] = array('id' => $zones['zone_id'], + 'text' => $zones['zone_name']); + } + + return $zones_array; + } + + function tep_prepare_country_zones_pull_down($country_id = '') { +// preset the width of the drop-down for Netscape + $pre = ''; + if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) { + for ($i=0; $i<45; $i++) $pre .= ' '; + } + + $zones = tep_get_country_zones($country_id); + + if (sizeof($zones) > 0) { + $zones_select = array(array('id' => '', 'text' => PLEASE_SELECT)); + $zones = array_merge($zones_select, $zones); + } else { + $zones = array(array('id' => '', 'text' => TYPE_BELOW)); +// create dummy options for Netscape to preset the height of the drop-down + if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) { + for ($i=0; $i<9; $i++) { + $zones[] = array('id' => '', 'text' => $pre); + } + } + } + + return $zones; + } + +//// +// Get list of address_format_id's + function tep_get_address_formats() { + $address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id"); + $address_format_array = array(); + while ($address_format_values = tep_db_fetch_array($address_format_query)) { + $address_format_array[] = array('id' => $address_format_values['address_format_id'], + 'text' => $address_format_values['address_format_id']); + } + return $address_format_array; + } + +//// +// Alias function for Store configuration values in the Administration Tool + function tep_cfg_pull_down_country_list($country_id) { + return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id); + } + + function tep_cfg_pull_down_zone_list($zone_id) { + return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id); + } + + function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') { + $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); + + $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); + $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title"); + while ($tax_class = tep_db_fetch_array($tax_class_query)) { + $tax_class_array[] = array('id' => $tax_class['tax_class_id'], + 'text' => $tax_class['tax_class_title']); + } + + return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id); + } + +//// +// Function to read in text area in admin + function tep_cfg_textarea($text) { + return tep_draw_textarea_field('configuration_value', false, 35, 5, $text); + } + + function tep_cfg_get_zone_name($zone_id) { + $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'"); + + if (!tep_db_num_rows($zone_query)) { + return $zone_id; + } else { + $zone = tep_db_fetch_array($zone_query); + return $zone['zone_name']; + } + } + +//// +// Sets the status of a banner + function tep_set_banner_status($banners_id, $status) { + if ($status == '1') { + return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'"); + } elseif ($status == '0') { + return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'"); + } else { + return -1; + } + } + +//// +// Sets the status of a product + function tep_set_product_status($products_id, $status) { + if ($status == '1') { + return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); + } elseif ($status == '0') { + return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'"); + } else { + return -1; + } + } + +//// +// Sets the status of a product on special + function tep_set_specials_status($specials_id, $status) { + if ($status == '1') { + return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'"); + } elseif ($status == '0') { + return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'"); + } else { + return -1; + } + } + +//// +// Sets timeout for the current script. +// Cant be used in safe mode. + function tep_set_time_limit($limit) { + if (!get_cfg_var('safe_mode')) { + set_time_limit($limit); + } + } + +//// +// Alias function for Store configuration values in the Administration Tool + function tep_cfg_select_option($select_array, $key_value, $key = '') { + $string = ''; + + for ($i=0, $n=sizeof($select_array); $i<$n; $i++) { + $name = ((tep_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value'); + + $string .= '
tep_datetime_short(date('Y-m-d H:i:s')), + 'system' => $system, + 'kernel' => $kernel, + 'host' => $host, + 'ip' => gethostbyname($host), + 'uptime' => @exec('uptime'), + 'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE'], + 'php' => PHP_VERSION, + 'zend' => (function_exists('zend_version') ? zend_version() : ''), + 'db_server' => DB_SERVER, + 'db_ip' => gethostbyname(DB_SERVER), + 'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''), + 'db_date' => tep_datetime_short($db['datetime'])); + } + + function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) { + global $languages_id; + + if (!is_array($categories_array)) $categories_array = array(); + + if ($from == 'product') { + $categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'"); + while ($categories = tep_db_fetch_array($categories_query)) { + if ($categories['categories_id'] == '0') { + $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP); + } else { + $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); + $category = tep_db_fetch_array($category_query); + $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']); + if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index); + $categories_array[$index] = array_reverse($categories_array[$index]); + } + $index++; + } + } elseif ($from == 'category') { + $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); + $category = tep_db_fetch_array($category_query); + $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']); + if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index); + } + + return $categories_array; + } + + function tep_output_generated_category_path($id, $from = 'category') { + $calculated_category_path_string = ''; + $calculated_category_path = tep_generate_category_path($id, $from); + for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) { + for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) { + $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . ' > '; + } + $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '
'; + } + $calculated_category_path_string = substr($calculated_category_path_string, 0, -4); + + if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP; + + return $calculated_category_path_string; + } + + function tep_get_generated_category_path_ids($id, $from = 'category') { + $calculated_category_path_string = ''; + $calculated_category_path = tep_generate_category_path($id, $from); + for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) { + for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) { + $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_'; + } + $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '
'; + } + $calculated_category_path_string = substr($calculated_category_path_string, 0, -4); + + if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP; + + return $calculated_category_path_string; + } + + function tep_remove_category($category_id) { + $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); + $category_image = tep_db_fetch_array($category_image_query); + + $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'"); + $duplicate_image = tep_db_fetch_array($duplicate_image_query); + + if ($duplicate_image['total'] < 2) { + if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) { + @unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']); + } + } + + tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); + tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'"); + tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'"); + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + } + + function tep_remove_product($product_id) { + $product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); + $product_image = tep_db_fetch_array($product_image_query); + + $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'"); + $duplicate_image = tep_db_fetch_array($duplicate_image_query); + + if ($duplicate_image['total'] < 2) { + if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) { + @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']); + } + } + + tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "'"); + tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); + tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); + tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "'"); + tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'"); + tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "' or products_id like '" . (int)$product_id . "{%'"); + + $product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'"); + while ($product_reviews = tep_db_fetch_array($product_reviews_query)) { + tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'"); + } + tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'"); + + if (USE_CACHE == 'true') { + tep_reset_cache_block('categories'); + tep_reset_cache_block('also_purchased'); + } + } + + function tep_remove_order($order_id, $restock = false) { + if ($restock == 'on') { + $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); + while ($order = tep_db_fetch_array($order_query)) { + tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'"); + } + } + + tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); + tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); + tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'"); + tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'"); + tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'"); + } + + function tep_reset_cache_block($cache_block) { + global $cache_blocks; + + for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) { + if ($cache_blocks[$i]['code'] == $cache_block) { + if ($cache_blocks[$i]['multiple']) { + if ($dir = @opendir(DIR_FS_CACHE)) { + while ($cache_file = readdir($dir)) { + $cached_file = $cache_blocks[$i]['file']; + $languages = tep_get_languages(); + for ($j=0, $k=sizeof($languages); $j<$k; $j++) { + $cached_file_unlink = ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file); + if (ereg('^' . $cached_file_unlink, $cache_file)) { + @unlink(DIR_FS_CACHE . $cache_file); + } + } + } + closedir($dir); + } + } else { + $cached_file = $cache_blocks[$i]['file']; + $languages = tep_get_languages(); + for ($i=0, $n=sizeof($languages); $i<$n; $i++) { + $cached_file = ereg_replace('-language', '-' . $languages[$i]['directory'], $cached_file); + @unlink(DIR_FS_CACHE . $cached_file); + } + } + break; + } + } + } + + function tep_get_file_permissions($mode) { +// determine type + if ( ($mode & 0xC000) == 0xC000) { // unix domain socket + $type = 's'; + } elseif ( ($mode & 0x4000) == 0x4000) { // directory + $type = 'd'; + } elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link + $type = 'l'; + } elseif ( ($mode & 0x8000) == 0x8000) { // regular file + $type = '-'; + } elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file + $type = 'b'; + } elseif ( ($mode & 0x2000) == 0x2000) { // character special file + $type = 'c'; + } elseif ( ($mode & 0x1000) == 0x1000) { // named pipe + $type = 'p'; + } else { // unknown + $type = '?'; + } + +// determine permissions + $owner['read'] = ($mode & 00400) ? 'r' : '-'; + $owner['write'] = ($mode & 00200) ? 'w' : '-'; + $owner['execute'] = ($mode & 00100) ? 'x' : '-'; + $group['read'] = ($mode & 00040) ? 'r' : '-'; + $group['write'] = ($mode & 00020) ? 'w' : '-'; + $group['execute'] = ($mode & 00010) ? 'x' : '-'; + $world['read'] = ($mode & 00004) ? 'r' : '-'; + $world['write'] = ($mode & 00002) ? 'w' : '-'; + $world['execute'] = ($mode & 00001) ? 'x' : '-'; + +// adjust for SUID, SGID and sticky bit + if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S'; + if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S'; + if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T'; + + return $type . + $owner['read'] . $owner['write'] . $owner['execute'] . + $group['read'] . $group['write'] . $group['execute'] . + $world['read'] . $world['write'] . $world['execute']; + } + + function tep_remove($source) { + global $messageStack, $tep_remove_error; + + if (isset($tep_remove_error)) $tep_remove_error = false; + + if (is_dir($source)) { + $dir = dir($source); + while ($file = $dir->read()) { + if ( ($file != '.') && ($file != '..') ) { + if (is_writeable($source . '/' . $file)) { + tep_remove($source . '/' . $file); + } else { + $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error'); + $tep_remove_error = true; + } + } + } + $dir->close(); + + if (is_writeable($source)) { + rmdir($source); + } else { + $messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error'); + $tep_remove_error = true; + } + } else { + if (is_writeable($source)) { + unlink($source); + } else { + $messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error'); + $tep_remove_error = true; + } + } + } + +//// +// Output the tax percentage with optional padded decimals + function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) { + if (strpos($value, '.')) { + $loop = true; + while ($loop) { + if (substr($value, -1) == '0') { + $value = substr($value, 0, -1); + } else { + $loop = false; + if (substr($value, -1) == '.') { + $value = substr($value, 0, -1); + } + } + } + } + + if ($padding > 0) { + if ($decimal_pos = strpos($value, '.')) { + $decimals = strlen(substr($value, ($decimal_pos+1))); + for ($i=$decimals; $i<$padding; $i++) { + $value .= '0'; + } + } else { + $value .= '.'; + for ($i=0; $i<$padding; $i++) { + $value .= '0'; + } + } + } + + return $value; + } + + function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) { + if (SEND_EMAILS != 'true') return false; + + // Instantiate a new mail object + $message = new email(array('X-Mailer: osCommerce')); + + // Build the text version + $text = strip_tags($email_text); + if (EMAIL_USE_HTML == 'true') { + $message->add_html($email_text, $text); + } else { + $message->add_text($text); + } + + // Send message + $message->build_message(); + $message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject); + } + + function tep_get_tax_class_title($tax_class_id) { + if ($tax_class_id == '0') { + return TEXT_NONE; + } else { + $classes_query = tep_db_query("select tax_class_title from " . TABLE_TAX_CLASS . " where tax_class_id = '" . (int)$tax_class_id . "'"); + $classes = tep_db_fetch_array($classes_query); + + return $classes['tax_class_title']; + } + } + + function tep_banner_image_extension() { + if (function_exists('imagetypes')) { + if (imagetypes() & IMG_PNG) { + return 'png'; + } elseif (imagetypes() & IMG_JPG) { + return 'jpg'; + } elseif (imagetypes() & IMG_GIF) { + return 'gif'; + } + } elseif (function_exists('imagecreatefrompng') && function_exists('imagepng')) { + return 'png'; + } elseif (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) { + return 'jpg'; + } elseif (function_exists('imagecreatefromgif') && function_exists('imagegif')) { + return 'gif'; + } + + return false; + } + +//// +// Wrapper function for round() for php3 compatibility + function tep_round($value, $precision) { + if (PHP_VERSION < 4) { + $exp = pow(10, $precision); + return round($value * $exp) / $exp; + } else { + return round($value, $precision); + } + } + +//// +// Add tax to a products price + function tep_add_tax($price, $tax) { + global $currencies; + + if (DISPLAY_PRICE_WITH_TAX == 'true') { + return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax); + } else { + return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); + } + } + +// Calculates Tax rounding the result + function tep_calculate_tax($price, $tax) { + global $currencies; + + return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); + } + +//// +// Returns the tax rate for a zone / class +// TABLES: tax_rates, zones_to_geo_zones + function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) { + global $customer_zone_id, $customer_country_id; + + if ( ($country_id == -1) && ($zone_id == -1) ) { + if (!tep_session_is_registered('customer_id')) { + $country_id = STORE_COUNTRY; + $zone_id = STORE_ZONE; + } else { + $country_id = $customer_country_id; + $zone_id = $customer_zone_id; + } + } + + $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . (int)$country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . (int)$zone_id . "') AND tr.tax_class_id = '" . (int)$class_id . "' GROUP BY tr.tax_priority"); + if (tep_db_num_rows($tax_query)) { + $tax_multiplier = 0; + while ($tax = tep_db_fetch_array($tax_query)) { + $tax_multiplier += $tax['tax_rate']; + } + return $tax_multiplier; + } else { + return 0; + } + } + +//// +// Returns the tax rate for a tax class +// TABLES: tax_rates + function tep_get_tax_rate_value($class_id) { + $tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority"); + if (tep_db_num_rows($tax_query)) { + $tax_multiplier = 0; + while ($tax = tep_db_fetch_array($tax_query)) { + $tax_multiplier += $tax['tax_rate']; + } + return $tax_multiplier; + } else { + return 0; + } + } + + function tep_call_function($function, $parameter, $object = '') { + if ($object == '') { + return call_user_func($function, $parameter); + } elseif (PHP_VERSION < 4) { + return call_user_method($function, $object, $parameter); + } else { + return call_user_func(array($object, $function), $parameter); + } + } + + function tep_get_zone_class_title($zone_class_id) { + if ($zone_class_id == '0') { + return TEXT_NONE; + } else { + $classes_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$zone_class_id . "'"); + $classes = tep_db_fetch_array($classes_query); + + return $classes['geo_zone_name']; + } + } + + function tep_cfg_pull_down_zone_classes($zone_class_id, $key = '') { + $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); + + $zone_class_array = array(array('id' => '0', 'text' => TEXT_NONE)); + $zone_class_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name"); + while ($zone_class = tep_db_fetch_array($zone_class_query)) { + $zone_class_array[] = array('id' => $zone_class['geo_zone_id'], + 'text' => $zone_class['geo_zone_name']); + } + + return tep_draw_pull_down_menu($name, $zone_class_array, $zone_class_id); + } + + function tep_cfg_pull_down_order_statuses($order_status_id, $key = '') { + global $languages_id; + + $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value'); + + $statuses_array = array(array('id' => '0', 'text' => TEXT_DEFAULT)); + $statuses_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_name"); + while ($statuses = tep_db_fetch_array($statuses_query)) { + $statuses_array[] = array('id' => $statuses['orders_status_id'], + 'text' => $statuses['orders_status_name']); + } + + return tep_draw_pull_down_menu($name, $statuses_array, $order_status_id); + } + + function tep_get_order_status_name($order_status_id, $language_id = '') { + global $languages_id; + + if ($order_status_id < 1) return TEXT_DEFAULT; + + if (!is_numeric($language_id)) $language_id = $languages_id; + + $status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$order_status_id . "' and language_id = '" . (int)$language_id . "'"); + $status = tep_db_fetch_array($status_query); + + return $status['orders_status_name']; + } + +//// +// Return a random value + function tep_rand($min = null, $max = null) { + static $seeded; + + if (!$seeded) { + mt_srand((double)microtime()*1000000); + $seeded = true; + } + + if (isset($min) && isset($max)) { + if ($min >= $max) { + return $min; + } else { + return mt_rand($min, $max); + } + } else { + return mt_rand(); + } + } + +// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n) + function tep_convert_linefeeds($from, $to, $string) { + if ((PHP_VERSION < "4.0.5") && is_array($from)) { + return ereg_replace('(' . implode('|', $from) . ')', $to, $string); + } else { + return str_replace($from, $to, $string); + } + } + + function tep_string_to_int($string) { + return (int)$string; + } + +//// +// Parse and secure the cPath parameter values + function tep_parse_category_path($cPath) { +// make sure the category IDs are integers + $cPath_array = array_map('tep_string_to_int', explode('_', $cPath)); + +// make sure no duplicate category IDs exist which could lock the server in a loop + $tmp_array = array(); + $n = sizeof($cPath_array); + for ($i=0; $i<$n; $i++) { + if (!in_array($cPath_array[$i], $tmp_array)) { + $tmp_array[] = $cPath_array[$i]; + } + } + + return $tmp_array; + } +?> diff --git a/catalog/admin/includes/functions/html_graphs.php b/catalog/admin/includes/functions/html_graphs.php new file mode 100644 index 0000000..e8cb2d1 --- /dev/null +++ b/catalog/admin/includes/functions/html_graphs.php @@ -0,0 +1,568 @@ +'', + 'hlabel'=>'', + 'type'=>'', + 'cellpadding'=>'', + 'cellspacing'=>'', + 'border'=>'', + 'width'=>'', + 'background'=>'', + 'vfcolor'=>'', + 'hfcolor'=>'', + 'vbgcolor'=>'', + 'hbgcolor'=>'', + 'vfstyle'=>'', + 'hfstyle'=>'', + 'noshowvals'=>'', + 'scale'=>'', + 'namebgcolor'=>'', + 'valuebgcolor'=>'', + 'namefcolor'=>'', + 'valuefcolor'=>'', + 'namefstyle'=>'', + 'valuefstyle'=>'', + 'doublefcolor'=>''); + + return($vals); + } + +//// +// prints out the table header and graph labels + function start_graph($vals, $names) { + $start_graph_string = '' . $vals['hlabel'] . '' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } + + return $start_graph_string; + } + +//// +// prints out the table footer + function end_graph() { + return '
' . $vals['vlabel'] . '
' . "\n"; + } + +//// +// sets the default values for the $vals array + function hv_graph_defaults($vals) { + if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000'; + if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000'; + if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF'; + if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF'; + if (!$vals['cellpadding']) $vals['cellpadding'] = '0'; + if (!$vals['cellspacing']) $vals['cellspacing'] = '0'; + if (!$vals['border']) $vals['border'] = '0'; + if (!$vals['scale']) $vals['scale'] = '1'; + if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF'; + if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF'; + if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000'; + if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000'; + if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666'; + + return $vals; + } + +//// +// prints out the actual data for the horizontal chart + function horizontal_graph($names, $values, $bars, $vals) { + $horizontal_graph_string = ''; + for($i = 0, $n = sizeof($values); $i < $n; $i++) { + $horizontal_graph_string .= ' ' . "\n" . + ' ' . $names[$i] . '' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + '  ' . "\n" . + ' ' . "\n" . + ''; + } else { + $horizontal_graph_string .= ''; + } + + if (!$vals['noshowvals']) { + $horizontal_graph_string .= '(' . $values[$i] . ')'; + } + + $horizontal_graph_string .= '' . "\n" . + ' ' . "\n"; + } // endfor + + return $horizontal_graph_string; + } + +//// +// prints out the actual data for the vertical chart + function vertical_graph($names, $values, $bars, $vals) { + $vertical_graph_string = ' ' . "\n"; + + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $vertical_graph_string .= ' (' . $values[$i] . ')
'; + } + + $vertical_graph_string .= '' . "\n"; + } // endfor + + $vertical_graph_string .= ' ' . "\n" . + ' ' . "\n"; + + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $vertical_graph_string .= ' ' . $names[$i] . '' . "\n"; + } // endfor + + $vertical_graph_string .= ' ' . "\n"; + + return $vertical_graph_string; + } + +//// +// prints out the actual data for the double horizontal chart + function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) { + $double_horizontal_graph_string = ''; + for($i = 0, $n = sizeof($values); $i < $n; $i++) { + $double_horizontal_graph_string .= ' ' . "\n" . + ' ' . $names[$i] . '' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' '; + } else { + $double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">'; + } + + $double_horizontal_graph_string .= ''; + +// decide if the value in bar is a color code or image. + if (ereg('^#', $bars[$i])) { + $double_horizontal_graph_string .= '' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + '
 
'; + } else { + $double_horizontal_graph_string .= ''; + } + + if (!$vals['noshowvals']) { + $double_horizontal_graph_string .= '(' . $values[$i] . ')'; + } + + $double_horizontal_graph_string .= '
' . "\n" . + ' ' . "\n" . + ' '; + + if (!$vals['noshowvals']) { + $double_horizontal_graph_string .= '(' . $dvalues[$i] . ')'; + } + + $double_horizontal_graph_string .= '' . "\n" . + ' ' . "\n"; + } // endfor + + return $double_horizontal_graph_string; + } + +//// +// prints out the actual data for the double vertical chart + function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) { + $double_vertical_graph_string = ' ' . "\n"; + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $double_vertical_graph_string .= ' ' . "\n" . + ' (' . $values[$i] . ')
'; + } + + $double_vertical_graph_string .= '' . "\n" . + ' (' . $dvalues[$i] . ')
'; + } + + $double_vertical_graph_string .= '' . "\n" . + ' ' . "\n" . + ' ' . "\n"; + } // endfor + + $double_vertical_graph_string .= ' ' . "\n" . + ' ' . "\n"; + + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $double_vertical_graph_string .= ' ' . $names[$i] . '' . "\n"; + } // endfor + + $double_vertical_graph_string .= ' ' . "\n"; + + return $double_vertical_graph_string; + } + +//// +// draws a double vertical bar graph for the banner views vs clicks statistics + function tep_banner_graph_infoBox($banner_id, $days) { + $names = array(); + $values = array(); + $dvalues = array(); + + $banner_stats_query = tep_db_query("select dayofmonth(banners_history_date) as name, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and to_days(now()) - to_days(banners_history_date) < " . $days . " order by banners_history_date"); + while ($banner_stats = tep_db_fetch_array($banner_stats_query)) { + $names[] = $banner_stats['name']; + $values[] = $banner_stats['value']; + $dvalues[] = $banner_stats['dvalue']; + } + $largest = @max($values); + + $bars = array(); + $dbars = array(); + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; + $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; + } + + $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, + 'hlabel'=>TEXT_BANNERS_LAST_3_DAYS, + 'type'=>'3', + 'cellpadding'=>'', + 'cellspacing'=>'1', + 'border'=>'', + 'width'=>'', + 'vfcolor'=>'#ffffff', + 'hfcolor'=>'#ffffff', + 'vbgcolor'=>'#81a2b6', + 'hbgcolor'=>'#81a2b6', + 'vfstyle'=>'Verdana, Arial, Helvetica', + 'hfstyle'=>'Verdana, Arial, Helvetica', + 'scale'=>100/$largest, + 'namebgcolor'=>'#f3f5fe', + 'valuebgcolor'=>'#f3f5fe', + 'namefcolor'=>'', + 'valuefcolor'=>'#0000d0', + 'namefstyle'=>'Verdana, Arial, Helvetica', + 'valuefstyle'=>'', + 'doublefcolor'=>'#ff7339'); + + return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); + } + +//// +// draws a double vertical bar graph for the banner views vs clicks statistics + function tep_banner_graph_yearly($banner_id) { + global $banner, $HTTP_GET_VARS; + + $banner_stats_query = tep_db_query("select year(banners_history_date) as year, sum(banners_shown) as value, sum(banners_clicked) as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' group by year(banners_history_date)"); + while ($banner_stats = tep_db_fetch_array($banner_stats_query)) { + $names[] = $banner_stats['year']; + $values[] = (($banner_stats['value']) ? $banner_stats['value'] : '0'); + $dvalues[] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0'); + } + + $largest = @max($values); + + $bars = array(); + $dbars = array(); + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; + $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; + } + + $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, + 'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner['banners_title']), + 'type'=>'3', + 'cellpadding'=>'', + 'cellspacing'=>'1', + 'border'=>'', + 'width'=>'', + 'vfcolor'=>'#ffffff', + 'hfcolor'=>'#ffffff', + 'vbgcolor'=>'#81a2b6', + 'hbgcolor'=>'#81a2b6', + 'vfstyle'=>'Verdana, Arial, Helvetica', + 'hfstyle'=>'Verdana, Arial, Helvetica', + 'scale'=>100/$largest, + 'namebgcolor'=>'#f3f5fe', + 'valuebgcolor'=>'#f3f5fe', + 'namefcolor'=>'', + 'valuefcolor'=>'#0000d0', + 'namefstyle'=>'Verdana, Arial, Helvetica', + 'valuefstyle'=>'', + 'doublefcolor'=>'#ff7339'); + + return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); + } + +//// +// draws a double vertical bar graph for the banner views vs clicks statistics + function tep_banner_graph_monthly($banner_id) { + global $banner, $HTTP_GET_VARS; + + $year = (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y')); + + for ($i=1; $i<13; $i++) { + $names[] = strftime('%b', mktime(0,0,0,$i)); + $values[] = '0'; + $dvalues[] = '0'; + } + + $banner_stats_query = tep_db_query("select month(banners_history_date) as banner_month, sum(banners_shown) as value, sum(banners_clicked) as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and year(banners_history_date) = '" . $year . "' group by month(banners_history_date)"); + while ($banner_stats = tep_db_fetch_array($banner_stats_query)) { + $names[($banner_stats['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats['banner_month'])); + $values[($banner_stats['banner_month']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0'); + $dvalues[($banner_stats['banner_month']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0'); + } + + $largest = @max($values); + + $bars = array(); + $dbars = array(); + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; + $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; + } + + $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, + 'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner['banners_title'], date('Y')), + 'type'=>'3', + 'cellpadding'=>'', + 'cellspacing'=>'1', + 'border'=>'', + 'width'=>'', + 'vfcolor'=>'#ffffff', + 'hfcolor'=>'#ffffff', + 'vbgcolor'=>'#81a2b6', + 'hbgcolor'=>'#81a2b6', + 'vfstyle'=>'Verdana, Arial, Helvetica', + 'hfstyle'=>'Verdana, Arial, Helvetica', + 'scale'=>100/$largest, + 'namebgcolor'=>'#f3f5fe', + 'valuebgcolor'=>'#f3f5fe', + 'namefcolor'=>'', + 'valuefcolor'=>'#0000d0', + 'namefstyle'=>'Verdana, Arial, Helvetica', + 'valuefstyle'=>'', + 'doublefcolor'=>'#ff7339'); + + return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); + } + +//// +// draws a double vertical bar graph for the banner views vs clicks statistics + function tep_banner_graph_daily($banner_id) { + global $banner, $HTTP_GET_VARS; + + $year = (isset($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y')); + $month = (isset($HTTP_GET_VARS['month']) ? $HTTP_GET_VARS['month'] : date('n')); + + $days = (date('t', mktime(0,0,0,$month))+1); + $stats = array(); + for ($i=1; $i<$days; $i++) { + $names[] = $i; + $values[] = '0'; + $dvalues[] = '0'; + } + + $banner_stats_query = tep_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'"); + while ($banner_stats = tep_db_fetch_array($banner_stats_query)) { + $names[($banner_stats['banner_day']-1)] = $banner_stats['banner_day']; + $values[($banner_stats['banner_day']-1)] = (($banner_stats['value']) ? $banner_stats['value'] : '0'); + $dvalues[($banner_stats['banner_day']-1)] = (($banner_stats['dvalue']) ? $banner_stats['dvalue'] : '0'); + } + + $largest = @max($values); + + $bars = array(); + $dbars = array(); + for ($i = 0, $n = sizeof($values); $i < $n; $i++) { + $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; + $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; + } + + $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, + 'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year), + 'type'=>'3', + 'cellpadding'=>'', + 'cellspacing'=>'1', + 'border'=>'', + 'width'=>'', + 'vfcolor'=>'#ffffff', + 'hfcolor'=>'#ffffff', + 'vbgcolor'=>'#81a2b6', + 'hbgcolor'=>'#81a2b6', + 'vfstyle'=>'Verdana, Arial, Helvetica', + 'hfstyle'=>'Verdana, Arial, Helvetica', + 'scale'=>100/$largest, + 'namebgcolor'=>'#f3f5fe', + 'valuebgcolor'=>'#f3f5fe', + 'namefcolor'=>'', + 'valuefcolor'=>'#0000d0', + 'namefstyle'=>'Verdana, Arial, Helvetica', + 'valuefstyle'=>'', + 'doublefcolor'=>'#ff7339'); + + return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); + } +?> diff --git a/catalog/admin/includes/functions/html_output.php b/catalog/admin/includes/functions/html_output.php new file mode 100644 index 0000000..89f00a6 --- /dev/null +++ b/catalog/admin/includes/functions/html_output.php @@ -0,0 +1,297 @@ +

Error!

Unable to determine the page link!

Function used:

tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')
'); + } + if ($connection == 'NONSSL') { + $link = HTTP_SERVER . DIR_WS_ADMIN; + } elseif ($connection == 'SSL') { + if (ENABLE_SSL == 'true') { + $link = HTTPS_SERVER . DIR_WS_ADMIN; + } else { + $link = HTTP_SERVER . DIR_WS_ADMIN; + } + } else { + die('

Error!

Unable to determine connection method on a link!

Known methods: NONSSL SSL

Function used:

tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')
'); + } + if ($parameters == '') { + $link = $link . $page . '?' . SID; + } else { + $link = $link . $page . '?' . $parameters . '&' . SID; + } + + while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); + + return $link; + } + + function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') { + if ($connection == 'NONSSL') { + $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; + } elseif ($connection == 'SSL') { + if (ENABLE_SSL_CATALOG == 'true') { + $link = HTTPS_CATALOG_SERVER . DIR_WS_CATALOG; + } else { + $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; + } + } else { + die('

Error!

Unable to determine connection method on a link!

Known methods: NONSSL SSL

Function used:

tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')
'); + } + if ($parameters == '') { + $link .= $page; + } else { + $link .= $page . '?' . $parameters; + } + + while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); + + return $link; + } + +//// +// The HTML image wrapper function + function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { + $image = ' '"', '\'' => ''', '<' => '<', '>' => '>')) . ''; + } + $field .= ''; + + if ($required == true) $field .= TEXT_FIELD_REQUIRED; + + return $field; + } +?> diff --git a/catalog/admin/includes/functions/languages.php b/catalog/admin/includes/functions/languages.php new file mode 100644 index 0000000..97829a8 --- /dev/null +++ b/catalog/admin/includes/functions/languages.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/catalog/admin/includes/functions/localization.php b/catalog/admin/includes/functions/localization.php new file mode 100644 index 0000000..c7e81cd --- /dev/null +++ b/catalog/admin/includes/functions/localization.php @@ -0,0 +1,40 @@ + 0) { + return $match[3]; + } else { + return false; + } + } + + function quote_xe_currency($to, $from = DEFAULT_CURRENCY) { + $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to); + + $match = array(); + + preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match); + + if (sizeof($match) > 0) { + return $match[1]; + } else { + return false; + } + } +?> diff --git a/catalog/admin/includes/functions/oe_functions.php b/catalog/admin/includes/functions/oe_functions.php new file mode 100644 index 0000000..a3029da --- /dev/null +++ b/catalog/admin/includes/functions/oe_functions.php @@ -0,0 +1,134 @@ +", $string); + return $string; + + } +///end function tep_html_no_oe_quote + +//// + +/// Begin mods for Order Editor +// Return the tax description for a zone / class +// TABLES: tax_rates; + + function tep_get_tax_description($class_id, $country_id, $zone_id) { + $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority"); + if (tep_db_num_rows($tax_query)) { + $tax_description = ''; + while ($tax = tep_db_fetch_array($tax_query)) { + $tax_description .= $tax['tax_description'] . ' + '; + } + $tax_description = substr($tax_description, 0, -3); + + return $tax_description; + } else { + return ENTRY_TAX; + } + } + +//// + +// Function : tep_get_country_id + // Arguments : country_name country name string + // Return : country_id + // Description : Function to retrieve the country_id based on the country's name + function tep_get_country_id($country_name) { + $country_id_query = tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_name = '" . $country_name . "'"); + if (!tep_db_num_rows($country_id_query)) { + return 0; + } + else { + $country_id_row = tep_db_fetch_array($country_id_query); + return $country_id_row['countries_id']; + } + } + + // Function : tep_get_zone_id + // Arguments : country_id country id string zone_name state/province name + // Return : zone_id + // Description : Function to retrieve the zone_id based on the zone's name + function tep_get_zone_id($country_id, $zone_name) { + $zone_id_query = tep_db_query("select * from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and (zone_name = '" . $zone_name . "' OR zone_code = '" . $zone_name . "')"); + if (!tep_db_num_rows($zone_id_query)) { + return 0; + } + else { + $zone_id_row = tep_db_fetch_array($zone_id_query); + return $zone_id_row['zone_id']; + } + } + +// Function : tep_html_quotes + // Arguments : string any string + // Return : string with single quotes converted to html equivalent + // Description : Function to change quotes to HTML equivalents for form inputs. + function tep_html_quotes($string) { + return str_replace("'", "'", $string); + } + + + ///this is a modified version of tep_js_zone_list designed for Order Editor + ///originally written by Josh Dechant for the MOECTOE suite + ///tweaked by djmonkey1 for Order Editor 2.7 and up + function tep_oe_js_zone_list($country, $form, $field, $id, $id2) { + $countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id"); + $num_country = 1; + $output_string = ''; + while ($countries = tep_db_fetch_array($countries_query)) { + if ($num_country == 1) { + $output_string .= ' if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; + } else { + $output_string .= ' } else if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; + } + + $states_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $countries['zone_country_id'] . "' order by zone_name"); + + $num_state = 1; + while ($states = tep_db_fetch_array($states_query)) { + if ($num_state == '1') $output_string .= ' ' . $form . '[' . $field . '].options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n"; + $output_string .= ' ' . $form . '[' . $field . '].options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n"; + $num_state++; + } + $output_string .= ' setStateVisibility(' . $id . ', "hidden", ' . $id2 . ');' . "\n"; + $num_country++; + } + $output_string .= ' } else {' . "\n" . + ' ' . $form . '[' . $field . '].options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" . + ' setStateVisibility(' . $id . ', "visible", ' . $id2 . ');' . "\n" . + ' }' . "\n"; + + return $output_string; + } + + //This function is written by Drako and is used to get the stock of a item knowing the product_ID + function tep_get_products_inventory_stock($product_id) { + $product_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'"); + $product = tep_db_fetch_array($product_query); + + return $product['products_quantity']; + } + //END + +/////end +?> \ No newline at end of file diff --git a/catalog/admin/includes/functions/sessions.php b/catalog/admin/includes/functions/sessions.php new file mode 100644 index 0000000..9cda320 --- /dev/null +++ b/catalog/admin/includes/functions/sessions.php @@ -0,0 +1,115 @@ + '" . time() . "'"); + + $value = tep_db_fetch_array($qid); + if ($value['value']) { + return $value['value']; + } + + return false; + } + + function _sess_write($key, $val) { + global $SESS_LIFE; + + $expiry = time() + $SESS_LIFE; + $value = $val; + + $qid = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'"); + $total = tep_db_fetch_array($qid); + + if ($total['total'] > 0) { + return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'"); + } else { + return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')"); + } + } + + function _sess_destroy($key) { + return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'"); + } + + function _sess_gc($maxlifetime) { + tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'"); + + return true; + } + + session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc'); + } + + function tep_session_start() { + return session_start(); + } + + function tep_session_register($variable) { + return session_register($variable); + } + + function tep_session_is_registered($variable) { + return session_is_registered($variable); + } + + function tep_session_unregister($variable) { + return session_unregister($variable); + } + + function tep_session_id($sessid = '') { + if ($sessid != '') { + return session_id($sessid); + } else { + return session_id(); + } + } + + function tep_session_name($name = '') { + if ($name != '') { + return session_name($name); + } else { + return session_name(); + } + } + + function tep_session_close() { + if (function_exists('session_close')) { + return session_close(); + } + } + + function tep_session_destroy() { + return session_destroy(); + } + + function tep_session_save_path($path = '') { + if ($path != '') { + return session_save_path($path); + } else { + return session_save_path(); + } + } +?> diff --git a/catalog/admin/includes/functions/validations.php b/catalog/admin/includes/functions/validations.php new file mode 100644 index 0000000..c2cb33c --- /dev/null +++ b/catalog/admin/includes/functions/validations.php @@ -0,0 +1,122 @@ +@,;:\.\\\"\[]"; + $atom = "$valid_chars+"; + $quoted_user='(\"[^\"]*\")'; + $word = "($atom|$quoted_user)"; + $user_pat = "^$word(\.$word)*$"; + $ip_domain_pat='^\[([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\]$'; + $domain_pat = "^$atom(\.$atom)*$"; + + if (eregi($mail_pat, $email, $components)) { + $user = $components[1]; + $domain = $components[2]; + // validate user + if (eregi($user_pat, $user)) { + // validate domain + if (eregi($ip_domain_pat, $domain, $ip_components)) { + // this is an IP address + for ($i=1;$i<=4;$i++) { + if ($ip_components[$i] > 255) { + $valid_address = false; + break; + } + } + } + else { + // Domain is a name, not an IP + if (eregi($domain_pat, $domain)) { + /* domain name seems valid, but now make sure that it ends in a valid TLD or ccTLD + and that there's a hostname preceding the domain or country. */ + $domain_components = explode(".", $domain); + // Make sure there's a host name preceding the domain. + if (sizeof($domain_components) < 2) { + $valid_address = false; + } else { + $top_level_domain = strtolower($domain_components[sizeof($domain_components)-1]); + // Allow all 2-letter TLDs (ccTLDs) + if (eregi('^[a-z][a-z]$', $top_level_domain) != 1) { + $tld_pattern = ''; + // Get authorized TLDs from text file + $tlds = file(DIR_WS_INCLUDES . 'tld.txt'); + while (list(,$line) = each($tlds)) { + // Get rid of comments + $words = explode('#', $line); + $tld = trim($words[0]); + // TLDs should be 3 letters or more + if (eregi('^[a-z]{3,}$', $tld) == 1) { + $tld_pattern .= '^' . $tld . '$|'; + } + } + // Remove last '|' + $tld_pattern = substr($tld_pattern, 0, -1); + if (eregi("$tld_pattern", $top_level_domain) == 0) { + $valid_address = false; + } + } + } + } + else { + $valid_address = false; + } + } + } + else { + $valid_address = false; + } + } + else { + $valid_address = false; + } + if ($valid_address && ENTRY_EMAIL_ADDRESS_CHECK == 'true') { + if (!checkdnsrr($domain, "MX") && !checkdnsrr($domain, "A")) { + $valid_address = false; + } + } + return $valid_address; + } +?> diff --git a/catalog/admin/includes/general.js b/catalog/admin/includes/general.js new file mode 100644 index 0000000..882a74a --- /dev/null +++ b/catalog/admin/includes/general.js @@ -0,0 +1,28 @@ +function SetFocus() { + if (document.forms.length > 0) { + var field = document.forms[0]; + for (i=0; iSetFileFormat($banner_extension); + $graph->SetIsInline(1); + $graph->SetPrintImage(0); + + $graph->SetSkipBottomTick(1); + $graph->SetDrawYGrid(1); + $graph->SetPrecisionY(0); + $graph->SetPlotType('lines'); + + $graph->SetPlotBorderType('left'); + $graph->SetTitleFontSize('4'); + $graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year)); + + $graph->SetBackgroundColor('white'); + + $graph->SetVertTickPosition('plotleft'); + $graph->SetDataValues($stats); + $graph->SetDataColors(array('blue','red'),array('blue', 'red')); + + $graph->DrawGraph(); + + $graph->PrintImage(); +?> diff --git a/catalog/admin/includes/graphs/banner_infobox.php b/catalog/admin/includes/graphs/banner_infobox.php new file mode 100644 index 0000000..c399bda --- /dev/null +++ b/catalog/admin/includes/graphs/banner_infobox.php @@ -0,0 +1,47 @@ +SetFileFormat($banner_extension); + $graph->SetIsInline(1); + $graph->SetPrintImage(0); + + $graph->draw_vert_ticks = 0; + $graph->SetSkipBottomTick(1); + $graph->SetDrawXDataLabels(0); + $graph->SetDrawYGrid(0); + $graph->SetPlotType('bars'); + $graph->SetDrawDataLabels(1); + $graph->SetLabelScalePosition(1); + $graph->SetMarginsPixels(15,15,15,30); + + $graph->SetTitleFontSize('4'); + $graph->SetTitle('TEXT_BANNERS_LAST_3_DAYS'); + + $graph->SetDataValues($stats); + $graph->SetDataColors(array('blue','red'),array('blue', 'red')); + + $graph->DrawGraph(); + + $graph->PrintImage(); +?> diff --git a/catalog/admin/includes/graphs/banner_monthly.php b/catalog/admin/includes/graphs/banner_monthly.php new file mode 100644 index 0000000..e47ac02 --- /dev/null +++ b/catalog/admin/includes/graphs/banner_monthly.php @@ -0,0 +1,51 @@ +SetFileFormat($banner_extension); + $graph->SetIsInline(1); + $graph->SetPrintImage(0); + + $graph->SetSkipBottomTick(1); + $graph->SetDrawYGrid(1); + $graph->SetPrecisionY(0); + $graph->SetPlotType('lines'); + + $graph->SetPlotBorderType('left'); + $graph->SetTitleFontSize('4'); + $graph->SetTitle(sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner['banners_title'], $year)); + + $graph->SetBackgroundColor('white'); + + $graph->SetVertTickPosition('plotleft'); + $graph->SetDataValues($stats); + $graph->SetDataColors(array('blue','red'),array('blue', 'red')); + + $graph->DrawGraph(); + + $graph->PrintImage(); +?> diff --git a/catalog/admin/includes/graphs/banner_yearly.php b/catalog/admin/includes/graphs/banner_yearly.php new file mode 100644 index 0000000..4004849 --- /dev/null +++ b/catalog/admin/includes/graphs/banner_yearly.php @@ -0,0 +1,45 @@ +SetFileFormat($banner_extension); + $graph->SetIsInline(1); + $graph->SetPrintImage(0); + + $graph->SetSkipBottomTick(1); + $graph->SetDrawYGrid(1); + $graph->SetPrecisionY(0); + $graph->SetPlotType('lines'); + + $graph->SetPlotBorderType('left'); + $graph->SetTitleFontSize('4'); + $graph->SetTitle(sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner['banners_title'])); + + $graph->SetBackgroundColor('white'); + + $graph->SetVertTickPosition('plotleft'); + $graph->SetDataValues($stats); + $graph->SetDataColors(array('blue','red'),array('blue', 'red')); + + $graph->DrawGraph(); + + $graph->PrintImage(); +?> diff --git a/catalog/admin/includes/header.php b/catalog/admin/includes/header.php new file mode 100644 index 0000000..6ccdc2e --- /dev/null +++ b/catalog/admin/includes/header.php @@ -0,0 +1,26 @@ +size > 0) { + echo $messageStack->output(); + } +?> + + + + + + + + + +
' . tep_image(DIR_WS_IMAGES . 'header_support.gif', HEADER_TITLE_SUPPORT_SITE, '50', '50') . '  ' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_ONLINE_CATALOG, '53', '50') . '  ' . tep_image(DIR_WS_IMAGES . 'header_administration.gif', HEADER_TITLE_ADMINISTRATION, '50', '50') . ''; ?>  
  ' . HEADER_TITLE_TOP . ''; ?>' . HEADER_TITLE_SUPPORT_SITE . '  |  ' . HEADER_TITLE_ONLINE_CATALOG . '  |  ' . HEADER_TITLE_ADMINISTRATION . ''; ?>  
\ No newline at end of file diff --git a/catalog/admin/includes/javascript/calendar.css b/catalog/admin/includes/javascript/calendar.css new file mode 100644 index 0000000..1415562 --- /dev/null +++ b/catalog/admin/includes/javascript/calendar.css @@ -0,0 +1,123 @@ +/* +* Popup Calendar Styles +*/ +.head { + font-family: arial; + font-size: 12px; + font-weight: normal; +} + +.text { + font-family: arial; + font-size: 12px; + font-weight: normal; + padding: 2px; +} + +#popupcalendar { + width: 185px; + height:130px; + left: 0px; + top: 0px; + background-color: black; + position: absolute; + visibility: hidden; +} + + +a.cal-DayLink { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + text-decoration: none; + color: black; + background-color: transparent; +} +a.cal-DayLink:hover { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: bold; + text-decoration: none; + background-color: transparent; + color: Blue; +} +a.cal-DayLink:active { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + text-decoration: none; + background-color: transparent; + color: #0066FF; +} +.cal-TextBox{ + color: Black; + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + background-color: #FFFFCC; +} + +a.cal-TodayLink { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: bold; + text-decoration: none; + color: red; + background-color: transparent; +} +a.cal-TodayLink:hover { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: bold; + text-decoration: none; + background-color: transparent; + color: Blue; +} +a.cal-TodayLink:active { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: bold; + text-decoration: none; + background-color: transparent; + color: #0066FF; +} + +.cal-GreyDate { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + text-decoration: none; + background-color: #FFFFCC; + color: #999999; +} + +.cal-GreyInvalidDate { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + text-decoration: line-through; + background-color: #FFFFCC; + color: #999999; +} + +.cal-DayCell { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: normal; + background-color:White; /*#FFFFCC;*/ +} + +.cal-HeadCell { + font-family: Verdana, Arial, sans-serif; + font-size: 8pt; + font-weight: bold; + background-color: #99CCCC;/* #CCCC99; */ +} + +.cal-Table{ + border-top-color: #99CCCC; + border-left-color: #99CCCC; + border-right-color: #99CCCC; + border-bottom-color: #99CCCC; + background-color:black; +} \ No newline at end of file diff --git a/catalog/admin/includes/javascript/calendarcode.js b/catalog/admin/includes/javascript/calendarcode.js new file mode 100644 index 0000000..635f5ff --- /dev/null +++ b/catalog/admin/includes/javascript/calendarcode.js @@ -0,0 +1,466 @@ +/* + * Bazillyo's Spiffy DHTML Popup Calendar v. 1.0 © 2000 S. Ousta + * - freeware with this comment + * - for download size, you can strip all spaces & comments except the © notices + * - Thanks to Chris for the domlay() function + * - this requires calendarcode.js, calendar.css, and calendarTest.htm + * - works in IE4.x, IE5.x, NS4.75 possibly 4.x, NS6 (with slight cosmetic issues) + * - Netscape does display some controls overtop of the layer so layout is important + * + */ + +// initialiZe variables... +var ppcIE=((navigator.appName == "Microsoft Internet Explorer") || ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion)==5))); +var ppcNN6=((navigator.appName == "Netscape") && (parseInt(navigator.appVersion)==5)); +//var ppcIE=(navigator.appName == "Microsoft Internet Explorer"); +var ppcNN=((navigator.appName == "Netscape")&&(document.layers)); +var ppcX = 4; +var ppcY = 4; + +var IsCalendarVisible; +var calfrmName; +var maxYearList; +var minYearList; +var todayDate = new Date; +var curDate = new Date; +var curImg; +var curDateBox; +var minDate = new Date; +var maxDate = new Date; +var hideDropDowns; +var IsUsingMinMax; +var FuncsToRun; +var img_del; +var img_close; +img_del=new Image(); +img_del.src="./images/cal_del_small.gif"; +img_close=new Image(); +img_close.src="./images/cal_close_small.gif"; + +minYearList=todayDate.getFullYear()-10; +maxYearList=todayDate.getFullYear()+10; +IsCalendarVisible=false; + +img_Date_UP=new Image(); +img_Date_UP.src="./images/cal_date_up.gif"; + +img_Date_OVER=new Image(); +img_Date_OVER.src="./images/cal_date_over.gif"; + +img_Date_DOWN=new Image(); +img_Date_DOWN.src="./images/cal_date_down.gif"; + + +function calSwapImg(whatID, NewImg,override) { + if (document.images) { + if (!( IsCalendarVisible && override )) { + document.images[whatID].src = eval(NewImg + ".src"); + } + } + window.status=' '; + return true; +} + +function getOffsetLeft (el) { + var ol = el.offsetLeft; + while ((el = el.offsetParent) != null) + ol += el.offsetLeft; + return ol+130; +} + +function getOffsetTop (el) { + var ot = el.offsetTop; + while((el = el.offsetParent) != null) + ot += el.offsetTop; + return ot-50; +} + +function showCalendar(frmName, dteBox,btnImg, hideDrops, MnDt, MnMo, MnYr, MxDt, MxMo, MxYr,runFuncs) { + hideDropDowns = hideDrops; + FuncsToRun = runFuncs; + calfrmName = frmName; + if (IsCalendarVisible) { + hideCalendar(); + } + else { + if (document.images['calbtn1']!=null ) document.images['calbtn1'].src=img_del.src; + if (document.images['calbtn2']!=null ) document.images['calbtn2'].src=img_close.src; + + if (hideDropDowns) {toggleDropDowns('hidden');} + if ((MnDt!=null) && (MnMo!=null) && (MnYr!=null) && (MxDt!=null) && (MxMo!=null) && (MxYr!=null)) { + IsUsingMinMax = true; + minDate.setDate(MnDt); + minDate.setMonth(MnMo-1); + minDate.setFullYear(MnYr); + maxDate.setDate(MxDt); + maxDate.setMonth(MxMo-1); + maxDate.setFullYear(MxYr); + } + else { + IsUsingMinMax = false; + } + + curImg = btnImg; + curDateBox = dteBox; + if ( ppcIE ) { + ppcX = getOffsetLeft(document.images[btnImg]); + ppcY = getOffsetTop(document.images[btnImg]) + document.images[btnImg].height; + } + else if (ppcNN){ + ppcX = document.images[btnImg].x + 90; + ppcY = document.images[btnImg].y - 45; + } + + domlay('popupcalendar',1,ppcX,ppcY,Calendar(todayDate.getMonth(),todayDate.getFullYear())); + + //domlay('popupcalendar',1,ppcX,ppcY,Calendar(curDate.getMonth(),curDate.getFullYear())); + + IsCalendarVisible = true; + } +} + +function toggleDropDowns(showHow){ + var i; var j; + for (i=0;i