OSCommerce Instalacja

Pomoc techniczna oscommerce znajduje się na http://www.oscommerce.info/ oraz http://www.pomoc-oscommerce.pl/porady.html . Ściągamy z internetu wersję zlokalizowaną , np. ze strony http://www.marrrecki.pl/.

Sklep po instalacji ma kodowanie iso-8859-2 . Aby zmienić na utf8 edytujemy plik includes/languages/polish.php i zamieniamy iso-8859-2 na utf-8 :

  setlocale(LC_TIME, "pl_PL.UTF-8", "polish"); 
  mb_internal_encoding("UTF-8");

  define('CHARSET', 'UTF-8"><META NAME="Authors" CONTENT="www.oscommerce.pl , http://maq.w-s.pl');

W katalogu /admin)/includes/functions/database.php dodajemy mysql_query("SET NAMES 'UTF8'", $$link); po liniach
if (USE_PCONNECT == 'true') {
      $$link = mysql_pconnect($server, $username, $password);
    } else {
      $$link = mysql_connect($server, $username, $password);
    }

Dla wszystkich polskich katalogów musimy przeprowadzić konwersję pod linuksem :

recode iso8859-2..utf-8 *.php

W polskiej paczce językowej niektóre pliki płatności mają błędy. Prawidłowe pliki znajdzimy tutaj : http://www.pomoc-oscommerce.pl/download/moduly-platnosci.html .

Następne kroki są opcjonalne - opis w języku angielskim

In catalog/includes/functions/general.php replace the complete function tep_parse_search_string with:
    function tep_parse_search_string($search_str = '', &$objects) {
    $search_str = trim(mb_strtolower($search_str));

// Break up $search_str on whitespace; quoted string will be reconstructed later
    $pieces = mb_split('[[:space:]]+', $search_str);
    $objects = array();
    $tmpstring = '';
    $flag = '';

    for ($k=0; $k<count($pieces); $k++) {
      while (mb_substr($pieces[$k], 0, 1) == '(') {
        $objects[] = '(';
        if (mb_strlen($pieces[$k]) > 1) {
          $pieces[$k] = mb_substr($pieces[$k], 1);
        } else {
          $pieces[$k] = '';
        }
      }

      $post_objects = array();

      while (mb_substr($pieces[$k], -1) == ')')  {
        $post_objects[] = ')';
        if (mb_strlen($pieces[$k]) > 1) {
          $pieces[$k] = mb_substr($pieces[$k], 0, -1);
        } else {
          $pieces[$k] = '';
        }
      }

// Check individual words

      if ( (mb_substr($pieces[$k], -1) != '"') && (mb_substr($pieces[$k], 0, 1) != '"') ) {
        $objects[] = trim($pieces[$k]);

        for ($j=0; $j<count($post_objects); $j++) {
          $objects[] = $post_objects[$j];
        }
      } else {
/* This means that the $piece is either the beginning or the end of a string.
   So, we'll slurp up the $pieces and stick them together until we get to the
   end of the string or run out of pieces.
*/

// Add this word to the $tmpstring, starting the $tmpstring
        $tmpstring = trim(mb_ereg_replace('"', ' ', $pieces[$k]));

// Check for one possible exception to the rule. That there is a single quoted word.
        if (mb_substr($pieces[$k], -1 ) == '"') {
// Turn the flag off for future iterations
          $flag = 'off';

          $objects[] = trim($pieces[$k]);

          for ($j=0; $j<count($post_objects); $j++) {
            $objects[] = $post_objects[$j];
          }

          unset($tmpstring);

// Stop looking for the end of the string and move onto the next word.
          continue;
        }

// Otherwise, turn on the flag to indicate no quotes have been found attached to this word in the string.
        $flag = 'on';

// Move on to the next word
        $k++;

// Keep reading until the end of the string as long as the $flag is on

        while ( ($flag == 'on') && ($k < count($pieces)) ) {
          while (mb_substr($pieces[$k], -1) == ')') {
            $post_objects[] = ')';
            if (mb_strlen($pieces[$k]) > 1) {
              $pieces[$k] = mb_substr($pieces[$k], 0, -1);
            } else {
              $pieces[$k] = '';
            }
          }

// If the word doesn't end in double quotes, append it to the $tmpstring.
          if (mb_substr($pieces[$k], -1) != '"') {
// Tack this word onto the current string entity
            $tmpstring .= ' ' . $pieces[$k];

// Move on to the next word
            $k++;
            continue;
          } else {
/* If the $piece ends in double quotes, strip the double quotes, tack the
   $piece onto the tail of the string, push the $tmpstring onto the $haves,
   kill the $tmpstring, turn the $flag "off", and return.
*/
            $tmpstring .= ' ' . trim(mb_ereg_replace('"', ' ', $pieces[$k]));

// Push the $tmpstring onto the array of stuff to search for
            $objects[] = trim($tmpstring);

            for ($j=0; $j<count($post_objects); $j++) {
              $objects[] = $post_objects[$j];
            }

            unset($tmpstring);

// Turn off the flag to exit the loop
            $flag = 'off';
          }
        }
      }
    }

// add default logical operators if needed
    $temp = array();
    for($i=0; $i<(count($objects)-1); $i++) {
      $temp[] = $objects[$i];
      if ( ($objects[$i] != 'and') &&
           ($objects[$i] != 'or') &&
           ($objects[$i] != '(') &&
           ($objects[$i+1] != 'and') &&
           ($objects[$i+1] != 'or') &&
           ($objects[$i+1] != ')') ) {
        $temp[] = ADVANCED_SEARCH_DEFAULT_OPERATOR;
      }
    }
    $temp[] = $objects[$i];
    $objects = $temp;

    $keyword_count = 0;
    $operator_count = 0;
    $balance = 0;
    for($i=0; $i<count($objects); $i++) {
      if ($objects[$i] == '(') $balance --;
      if ($objects[$i] == ')') $balance ++;
      if ( ($objects[$i] == 'and') || ($objects[$i] == 'or') ) {
        $operator_count ++;
      } elseif ( ($objects[$i]) && ($objects[$i] != '(') && ($objects[$i] != ')') ) {
        $keyword_count ++;
      }
    }

    if ( ($operator_count < $keyword_count) && ($balance == 0) ) {
      return true;
    } else {
      return false;
    }
  }

Correct the function tep_break_string (catalog(admin)/includes/functions/general.php):
  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;
  }
to:
  function tep_break_string($string, $len, $break_char = '-') {
    $l = 0;
    $output = '';
    for ($i=0, $n=mb_strlen($string); $i<$n; $i++) {
      $char = mb_substr($string, $i, 1);
      if ($char != ' ') {
        $l++;
      } else {
        $l = 0;
      }
      if ($l > $len) {
        $l = 1;
        $output .= $break_char;
      }
      $output .= $char;
    }

    return $output;
  }
In catalog/(admin/)/includes/classes/email.php change:
     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);
      $from = (($from_name != '') ? '"' . $from_name . '" ' : $from_addr);
to:
      if ((mb_strstr($to_name, "\n") != false) || (mb_strstr($to_name, "\r") != false)) {
        return false;
      }

      if ((mb_strstr($to_addr, "\n") != false) || (mb_strstr($to_addr, "\r") != false)) {
        return false;
      }

      if ((mb_strstr($subject, "\n") != false) || (mb_strstr($subject, "\r") != false)) {
        return false;
      }

      if ((mb_strstr($from_name, "\n") != false) || (mb_strstr($from_name, "\r") != false)) {
        return false;
      }

      if ((mb_strstr($from_addr, "\n") != false) || (mb_strstr($from_addr, "\r") != false)) {
        return false;
      }

      $tommod_encoding = strtolower(constant('CHARSET'));
      if($tommod_encoding=="utf-8"){
      mb_internal_encoding("utf-8");
      $subject = mb_encode_mimeheader($subject, "utf-8", "q");
      $from_name = '';
      $to_name = '';


      if(mb_ereg("<", $from_addr))
      {
      $froma = mb_split("<", $from_addr);
      $from_addr = str_replace(">", "", $froma[1]);
      }
     
      if(mb_ereg("<", $to_addr))
      {
      $toa = mb_split("<", $to_addr);
      $to_addr = str_replace(">", "", $toa[1]);
      }     
      }

      $to = (($to_name != '') ? '"' . $to_name . '" ' : $to_addr);
      $from = (($from_name != '') ? '"' . $from_name . '" ' : $from_addr);

Ostatnio zmieniany czwartek, 14 listopad 2013 12:21

Dodatkowe informacje

  • technika: oscommerce

Więcej w tej kategorii:

Początek strony