Jump to content
Latest News: (loading..)

vmn

Members
  • Content count

    78
  • Joined

  • Last visited

Profile Information

  • Real Name
    Veli-Matti
  • Gender
    Male

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. vmn

    Store Mode BS

    Works for me, too.
  2. vmn

    Store Mode BS

    I forgot to point out, that I only plan to use and have tested the "offline" mode. I use a local environment to develop and test my changes. "Logoff customers Do you want to logoff customers? Applies on all modes except online." This does not apply to "offline" mode. After noticing the above, I also wanted to clarify what happens, if a customer has a non-empty shopping cart, in case of maintenance. This is my new maintenance message text: define('TEXT_MAINTENANCE_MESSAGE_ENGLISH', 'We are currently maintaining the Web Shop.<br><br>We apologize for any inconvenience this may cause.<br><br><strong>If your shopping cart was not empty, it will be preserved as follows</strong>:<ul style="text-align:left"><li>logged in customers:<strong> always</strong> (even if you close your browser)</li><li>others: <strong>unless</strong> you close your browser</li></ul>'); I checked the html source with W3C Markup Validation Service (https://validator.w3.org/). Based on the results I made the following changes in maintenance.php: -after header("Retry-After: 3600"); -added header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); -replaced <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> -with <!DOCTYPE html> -removed <meta http-equiv="Cache-Control" content="no-cache"> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <meta name="HandheldFriendly" content="true"> I tested the offline mode with my Android phone. No problems with scaling down the output. -replaced <style type="text/css"> -with <style> Buttons without a form: -replaced <form> <input type="button" class="button" value="Continue" onclick="window.location.href='<?php echo dirname($_SERVER["REQUEST_URI"])."/index.php?language=en";?>'" /> </form> -with <button class="button" onclick="window.location.href='<?php echo dirname($_SERVER["REQUEST_URI"])."/index.php?language=en";?>'">Continue</button>
  3. vmn

    Store Mode BS

    Sorry for the delay. I updated to 1.2.1. Looks good, thanks.
  4. vmn

    Store Mode BS

    Thanks @raiwa. Please find below my answers to your comments. If one knows how this addon works, it may be possible to view htaccess backups by accessing them directly. This only applies to php files. <Files *.php> Order Deny,Allow Deny from all </Files> So, I prefer Require ip <allowed ip's> .htaccess RewriteRule is using 302. 302 = Found 307 = Temporary Redirect I prefer 307. What's the point of hiding the backtime information, if it's empty?
  5. vmn

    Store Mode BS

    Hello again @raiwa. I understand you are busy, but maybe you'll find some time to look at my findings. 1. I did not find any other php 7.x related issues. 2. Wouldn't it be better to use 307 instead of 302? 3. The only way I managed to prevent Firefox cacheing the redirect was to comment out the line ExpiresDefault "access plus 2 days" in the .htaccess for the maintenance period. Then I remove the comment when returning back to online. I'm using the stock .htcasses: <IfModule mod_expires.c> ... ExpiresDefault "access plus 2 days" </IfModule> This is my version of the function ht_store_mode_add_to_htaccess (changes marked with //VMN): function ht_store_mode_add_to_htaccess($mode_text) { if ( isset($_GET['module']) && $_GET['module'] == 'ht_store_mode') { //VMN set the back_time variable in maintenance.php from url //VMNif ( is_file(DIR_FS_CATALOG . 'maintenance.php') ) { //VMN $maintenance_file = file_get_contents(DIR_FS_CATALOG . 'maintenance.php'); //VMN $maintenance_file = preg_replace('%\$back_time = \'(.*)\';%', '\$back_time = \'' . MODULE_HEADER_TAGS_STORE_MODE_BACK_TIME . '\';', $maintenance_file); //VMN file_put_contents(DIR_FS_CATALOG . 'maintenance.php', $maintenance_file); //VMN} // update the allowed IPs list $allowed_ips_array = array(); $offline_rewrite = null; $allowed_ips_array = explode(',', MODULE_HEADER_TAGS_STORE_MODE_ALLOWED_IPS); if (!in_array(getenv('REMOTE_ADDR'), $allowed_ips_array)) { $ip_list = getenv('REMOTE_ADDR') . ',' . MODULE_HEADER_TAGS_STORE_MODE_ALLOWED_IPS; tep_db_query("update `configuration` set `configuration_value` = '" . $ip_list . "' where `configuration_key` = 'MODULE_HEADER_TAGS_STORE_MODE_ALLOWED_IPS'"); $allowed_ips_array = explode(',', $ip_list); } // define the .htaccess rewrite rules if (MODULE_HEADER_TAGS_STORE_MODE_BACK_TIME != '') { $back_time = MODULE_HEADER_TAGS_STORE_MODE_BACK_TIME; } else { $back_time = date('H:i', strtotime('now +2 hour')); } if ( strpos(MODULE_HEADER_TAGS_STORE_MODE, 'offline') > -1 ) { $offline_rewrite = '#Store Mode Begin' . "\n" . '<IfModule mod_rewrite.c>' . "\n" . ' RewriteEngine on' . "\n" . ' RewriteBase ' . ((getenv('HTTPS') == 'on')? DIR_WS_CATALOG : DIR_WS_HTTPS_CATALOG) . "\n" . ' RewriteRule ^' . ((getenv('HTTPS') == 'on')? str_replace(DIR_WS_CATALOG, '', DIR_WS_ADMIN) : str_replace(DIR_WS_HTTPS_CATALOG, '', DIR_WS_HTTPS_ADMIN)) . ' - [L,NC]' . "\n"; foreach ($allowed_ips_array as $ip) { if (MODULE_HEADER_TAGS_STORE_MODE == 'offline-test') { // define the allowed IPs redirect rules for test mode $i++; $offline_rewrite .= ' RewriteCond %{REMOTE_ADDR} ^' . str_replace('.', '\.', $ip) . '$' . ($i < sizeof($allowed_ips_array)? ' [OR]' : '') . "\n"; } elseif (MODULE_HEADER_TAGS_STORE_MODE == 'offline') {// define the allowed IPs exclude redirect rules for normal mode $offline_rewrite .= ' RewriteCond %{REMOTE_ADDR} !^' . str_replace('.', '\.', $ip) . '$' . "\n"; } } $offline_rewrite .= ' RewriteCond %{REQUEST_URI} !maintenance.php$ [NC]' . "\n" . ' RewriteCond %{REQUEST_URI} !.(jpe?g?|png|gif|css|js) [NC]' . "\n" . ' RewriteRule .* maintenance.php?back_time=' . $back_time. ' [R=307,L]' . "\n" . //VMN '</IfModule>' . "\n" . '#Store Mode End' . "\n\n"; // update the .htaccess file $file = file_get_contents(DIR_FS_CATALOG . '.htaccess'); if ( strpos($file, 'RewriteRule .* maintenance.php? [R=307,L]') === false ) { //VMN htaccess_backup('backup_htaccess'); } elseif ( strpos($file, 'RewriteRule .* maintenance.php? [R=307,L]') > 0 ) { //VMN $file = preg_replace('@#Store Mode Begin((?:.|[\r\n])+?)#Store Mode End\n\n@', '', $file); } $file = preg_replace('@ExpiresDefault@','#ExpiresDefault',$file); //VMN $content = $offline_rewrite . $file; file_put_contents(DIR_FS_CATALOG . '.htaccess', $content); } elseif ( (strpos(MODULE_HEADER_TAGS_STORE_MODE, 'offline') === false ) && isset($_GET['module']) && $_GET['module'] == 'ht_store_mode' ) { // remove rewrite rules $file = file_get_contents(DIR_FS_CATALOG . '.htaccess'); $file = preg_replace('@#Store Mode Begin((?:.|[\r\n])+?)#Store Mode End\n\n@', '', $file); $file = preg_replace('@#ExpiresDefault@','ExpiresDefault',$file); //VMN file_put_contents(DIR_FS_CATALOG . '.htaccess', $file); } } return nl2br(implode("\n", explode(';', $mode_text))); } 4. The back_time is set in maintenance.php as follows: $back_time = ''; if (isset($_GET['back_time'])) { $back_time = $_GET['back_time']; } if ($back_time == '') { $back_time = date('H:i', strtotime('now +2 hour')); } Best regards, Veli-Matti
  6. vmn

    Store Mode BS

    Hi Rainer and thanks again for a very useful addon. I've got some comments. For Php 7.x: in includes/modules/header_tags/ht_store_mode.php -replace while (list($id, $value) = each($lng->catalog_languages)) { -with foreach($lng->catalog_languages as $key => $value) { I noticed that the folder htaccess_backups is browsable. This is what I did in includes/modules/header_tags/ht_store_mode.php. I replaced the function htaccess_backup with this code: // function create htaccess backup function htaccess_backup($bkup_name) { $separator = ((substr(DIR_FS_CATALOG, -1) != '/') ? '/' : ''); $backupDir = DIR_FS_CATALOG . $separator . 'htaccess_backups'; $backupDir .= '/'; // create backup dir if(!is_dir($backupDir)) mkdir($backupDir, 0755); // create .htaccess protection containing allowed ip's $htaccessfile = $backupDir . '.htaccess'; $allowed_ips_array = explode(',', MODULE_HEADER_TAGS_STORE_MODE_ALLOWED_IPS); $htaccess = ''; foreach ($allowed_ips_array as $ip) { $htaccess .= 'Require ip ' . $ip . "\n"; } file_put_contents($htaccessfile, $htaccess); $htaccessfileOrig = DIR_FS_CATALOG . $separator . '.htaccess'; $htaccessfileBkup = $backupDir . $bkup_name; $result = copy($htaccessfileOrig, $htaccessfileBkup); } I also wanted to add a button to check the shop availability status, as follows: In maintenance.php - find define('TEXT_MAINTENANCE_CONTACT_ENGLISH', '<br><br><a href="mailto: %s ?Subject=Store Offline" target="_top">Contact</a>'); - add after define('TEXT_MAINTENANCE_STATUS_ENGLISH', '<br><br>To verify the site status ... Click Continue<br><br>'); - find </style> - add before .button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 10px 22px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; border-radius: 8px; } - find if ( defined('TEXT_MAINTENANCE_CONTACT_ENGLISH') && TEXT_MAINTENANCE_CONTACT_ENGLISH != '' && $store_mail != '' ) { echo sprintf(TEXT_MAINTENANCE_CONTACT_ENGLISH, $store_mail); } - add after if ( defined('TEXT_MAINTENANCE_STATUS_ENGLISH') && TEXT_MAINTENANCE_STATUS_ENGLISH ) { echo TEXT_MAINTENANCE_STATUS_ENGLISH; ?> <form> <input type="button" class="button" value="Continue" onclick="window.location.href='<?php echo dirname($_SERVER["REQUEST_URI"])."/index.php?language=en";?>'" /> </form> <?php } After putting the shop online again this seems to work pretty well in Chrome and Edge, but not always in Firefox, especially with Firefox with multiple tabs/windows open. Firefox keeps cacheing pages very stubbornly. All comments are welcome!
  7. vmn

    Article Manager v1.0

    More comments: in admin/articles.php ====================================== replace spiffyCal with datepicker. -remove the following around line 695: <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css"> <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script> <script language="javascript"> <!-- var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_article", "articles_date_available","btnDate1","<?php echo $aInfo->articles_date_available; ?>",scBTNMODE_CUSTOMBLUE); --> </script> -find around line 731 <tr> <td class="smallText"><?php echo TEXT_ARTICLES_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td> <td class="smallText" align="left"><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td> </tr> -replace with <tr> <td class="smallText"><?php echo TEXT_ARTICLES_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td> <td class="main"><?php echo tep_draw_input_field('articles_date_available', $aInfo->articles_date_available, 'id="articles_date_available"'); ?></td> </tr> -find around line 865 </table></form> -replace with </table> <script type="text/javascript"> $('#articles_date_available').datepicker({ dateFormat: 'yy-mm-dd' }); </script> </form> -delete the folder admin/includes/javascript/ ====================================== When duplicating an article with "articles_date_available" NULL, the duplcate article's "articles_date_available" will be "0000-00-00 00:00:00". When you later modify the duplicated article, the "articles_date_added" will be "0000-00-00 00:00:00". -find around line 357 tep_db_query("insert into " . TABLE_ARTICLES . " (articles_date_added, articles_date_available, articles_status, articles_is_blog, articles_sort_order, authors_id) values (now(), '" . tep_db_input($article['articles_date_available']) . "', '0', '" . (int)$sort_order . "', '" . (int)$article['authors_id'] . "')"); -replace with (this also fixes the missing value of "articles_is_blog" retrieved in the previous SELECT) tep_db_query("insert into " . TABLE_ARTICLES . " (articles_date_added, articles_date_available, articles_status, articles_is_blog, articles_sort_order, authors_id) values (now(), " . (isset($article['articles_date_available']) ? "'" . tep_db_input($article['articles_date_available']) . "'" : 'DEFAULT') . ",'0','" . tep_db_input($article['articles_is_blog']) . "', '" .(int)$sort_order . "', '" . (int)$article['authors_id'] . "')");
  8. vmn

    Article Manager v1.0

    @jackmc I think that for a relatively short string like this, my first solution works pretty well. To be on the safer side, I set MAX_ARTICLE_ABSTRACT_LENGTH=500. The article description should be quite short anyway.
  9. vmn

    Article Manager v1.0

    This simpler solution may still break the html. I reverted back to my first solution.
  10. vmn

    Article Manager v1.0

    A little simpler and presumably faster solution for $articles_head_desc_tag truncation: if (DISPLAY_ABSTRACT_ARTICLE_LISTING == 'true') { $articles_head_desc_tag = $articles_listing['articles_head_desc_tag']; if (strlen($articles_listing['articles_head_desc_tag']) > MAX_ARTICLE_ABSTRACT_LENGTH) { $last_tag = strrchr($articles_head_desc_tag,'<'); $articles_head_desc_tag = substr($articles_head_desc_tag,0, MAX_ARTICLE_ABSTRACT_LENGTH); $articles_head_desc_tag .= ' ... ' . $last_tag; } ?> <div class="main" style="padding-left:15px"><?php echo clean_html_comments($articles_head_desc_tag); ?></div> <?php }
  11. vmn

    Article Manager v1.0

    Some comments regarding Articles Manager V 1.57_8: ====================== in articles.php I could not find any definition for $articles_all_split. This condition: if (ARTICLE_LIST_FILTER) { should be: if (ARTICLE_LIST_FILTER != 'false') ====================== in includes/modules/article_listing.php this code: if (DISPLAY_ABSTRACT_ARTICLE_LISTING == 'true') { ?> <div class="main" style="padding-left:15px"><?php echo clean_html_comments(substr($articles_listing['articles_head_desc_tag'],0, MAX_ARTICLE_ABSTRACT_LENGTH)) . ((strlen($articles_listing['articles_head_desc_tag']) >= MAX_ARTICLE_ABSTRACT_LENGTH) ? '...' : ''); ?></div> <?php } breaks the html, if MAX_ARTICLE_ABSTRACT_LENGTH is exceeded. I noticed this when one $articles_listing['articles_head_desc_tag'] contained <div> ... </div> We should preserve all html tags even if the string gets truncated. I found one solution here: https://gist.github.com/JayWood/348752b568ecd63ae5ce Maybe you guys can find a better solution. This seems to work for me (incl. Finnish language). I have no idea of possible performance impact. if (DISPLAY_ABSTRACT_ARTICLE_LISTING == 'true') { $articles_head_desc_tag = $articles_listing['articles_head_desc_tag']; if (strlen($articles_listing['articles_head_desc_tag']) > MAX_ARTICLE_ABSTRACT_LENGTH) { $articles_head_desc_tag = substr($articles_head_desc_tag,0, MAX_ARTICLE_ABSTRACT_LENGTH); $articles_head_desc_tag .= ' ... '; libxml_use_internal_errors(true); $dom = new \DOMDocument; $dom->loadHTML($articles_head_desc_tag); // Strip wrapping <html> and <body> tags $mock = new \DOMDocument; $body = $dom->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $mock->appendChild($mock->importNode($child, true)); } $articles_head_desc_tag = trim($mock->saveHTML()); } ?> <div class="main" style="padding-left:15px"><?php echo clean_html_comments($articles_head_desc_tag); ?></div> <?php }
  12. I just uploaded an addon enabling language support in Bootstrap Datepicker: https://apps.oscommerce.com/WKqEE&amp;modular-boostrap-datepicker-i18n-bs
  13. Good point. The modular approach can now be found as an addon: https://apps.oscommerce.com/KgXJi&amp;modular-image-descriptions-bs&amp;c=images
  14. One bug so far. Escape slashes in the product name as follows: in includes/modules/header_tags/ht_product_colorbox.php find $(this).parent().attr("title", "' .$product_info['products_name'].'<br>" + $(this).attr("alt")); replace with $(this).parent().attr("title", "' .addslashes($product_info['products_name']).'<br>" + $(this).attr("alt")); and in admin/categories.php find $(this).parent().attr("title", "<?php echo $pInfo->products_name. '<br>';?>" + $(this).attr("alt")); replace with $(this).parent().attr("title", "<?php echo addslashes($pInfo->products_name). '<br>';?>" + $(this).attr("alt"));
  15. Here are some catalog screen shots related to my previous post: catalog.screens.shots.zip
×