/**
 * write out a file to disk
 *
 * @param string $filename
 * @param string $contents
 * @param boolean $create_dirs
 * @return boolean
 */
function smarty_core_write_file($params, &$smarty)
{
    $_dirname = dirname($params['filename']);

    if ($params['create_dirs']) {
        $_params = array('dir' => $_dirname);
        MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.create_dir_structure.php');
        smarty_core_create_dir_structure($_params, $smarty);
    }

    // write to tmp file, then rename it to avoid file locking race condition
    $_tmp_file = tempnam($_dirname, 'wrt');

    if (!($fd = @fopen($_tmp_file, 'wb'))) {
        $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
        if (!($fd = @fopen($_tmp_file, 'wb'))) {
            $smarty->trigger_error("problem writing temporary file '$_tmp_file'");
            return false;
        }
    }

    fwrite($fd, $params['contents']);
    fclose($fd);

    if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
        // On platforms and filesystems that cannot overwrite with rename()
        // delete the file before renaming it -- because windows always suffers
        // this, it is short-circuited to avoid the initial rename() attempt
        @unlink($params['filename']);
        @rename($_tmp_file, $params['filename']);
    }
    @chmod($params['filename'], $smarty->_file_perms);

    return true;
}
/**
 * Smarty {html_js_inputbox} function plugin
 *
 * File:       function.html_js_inputbox.php<br>
 * Type:       function<br>
 * Name:       js_inputbox<br>
 * Date:       06.Oct.2005<br>
 * Purpose:    Prints out a list of text input types<br>
 * Examples:
 * <pre>
 * {html_js_inputbox values=$ids}
 * {html_js_inputbox class='inputbox' name='searchword' value=$lang.text }
 * </pre>
 * @author r23 <*****@*****.**>
 * @version    1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_js_inputbox($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $class = 'inputbox';
    $name = 'keywords';
    $size = '20';
    $maxlength = '40';
    $value = 'search...';
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'class':
            case 'name':
            case 'value':
                ${$_key} = (string) $_val;
                break;
            case 'size':
            case 'maxlength':
                ${$_key} = intval($_val);
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("html_js_inputbox: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    return '<input class="' . $class . '" type="text" name="' . $name . '" size="' . $size . '" maxlength="' . $maxlength . '"  value="' . $value . '"  onblur="if(this.value==\'\') this.value=\'' . $value . '\';" onfocus="if(this.value==\'' . $value . '\') this.value=\'\';" />';
}
/**
 * Smarty {oos_address_label} function plugin
 *
 * Type:     function
 * Name:     oos_address_label
 * Version:  1.0
 * -------------------------------------------------------------
 */

function smarty_function_oos_address_label($params, &$smarty)
{

    $customers_id = '';
    $address_id = 1;
    $html = true;
    $boln = '';
    $eoln = '<br>';

    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    MyOOS_CoreApi::requireOnce('lib/smarty-plugins/myoos/function.oos_address_format.php');

    foreach($params as $_key => $_val) {
      $$_key = smarty_function_escape_special_chars($_val);
    }

    $dbconn =& oosDBGetConn();
    $oostable =& oosDBGetTables();

    $address_result = $dbconn->Execute("SELECT entry_firstname AS firstname, entry_lastname AS lastname, entry_company AS company, entry_street_address AS street_address, entry_suburb AS suburb, entry_city AS city, entry_postcode AS postcode, entry_state AS state, entry_zone_id AS zone_id, entry_country_id AS country_id FROM " . $oostable['address_book'] . " WHERE customers_id = '" . (int)$customers_id . "' AND address_book_id = '" . (int)$address_id . "'");
    $address = $address_result->fields;

    $format_id = oos_get_address_format_id($address['country_id']);


    return smarty_function_oos_address_format(array('address_format_id' => $format_id,
                                                    'address'   => $address,
                                                    'html'      => $html),
                                                  $smarty);


}
/**
 * Smarty {html_get_link} function plugin
 *
 * Type:     function
 * Name:     html_get_link
 * @Version: $Revision: 1.3 $ - changed by $Author: r23 $ on $Date: 2009/10/23 15:56:54 $
 * -------------------------------------------------------------
 */

function smarty_function_html_get_link($params, &$smarty)
{

    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $connection = 'NONSSL';

    foreach($params as $_key => $_val) {
      switch($_key) {
        case 'connection':
            $$_key = (string)$_val;
            break;

        default:
            break;
       }
    }

    if ($connection == 'NONSSL') {
      $link = OOS_HTTP_SERVER . OOS_SHOP;
    } elseif ($connection == 'SSL') {
      if (ENABLE_SSL == '1') {
        $link = OOS_HTTPS_SERVER . OOS_SHOP;
      } else {
        $link = OOS_HTTP_SERVER . OOS_SHOP;
      }
    } else {
      $smarty->trigger_error("html_get_link: Unable to determine the page link!", E_USER_NOTICE);
    }

    $link .= 'index.php';

    return $link;
}
function smarty_prefilter_improvetypo($content, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty-plugins/myoos/shared.improvetypo.php');

	return smarty_improvetypo($content);

}
function smarty_core_smarty_include_php($params, &$smarty)
{   
    $_params = array('resource_name' => $params['smarty_file']);
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_php_resource.php');
    smarty_core_get_php_resource($_params, $smarty);
    $_smarty_resource_type = $_params['resource_type'];
    $_smarty_php_resource = $_params['php_resource'];

    if (!empty($params['smarty_assign'])) {
        ob_start();
        if ($_smarty_resource_type == 'file') {
            $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
        } else {
            $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
        }
        $smarty->assign($params['smarty_assign'], ob_get_contents());
        ob_end_clean();
    } else {
        if ($_smarty_resource_type == 'file') {
            $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
        } else {
            $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
        }
    }
}
/**
 * Retrieves PHP script resource
 *
 * sets $php_resource to the returned resource
 * @param string $resource
 * @param string $resource_type
 * @param  $php_resource
 * @return boolean
 */

function smarty_core_get_php_resource(&$params, &$smarty)
{

    $params['resource_base_path'] = $smarty->trusted_dir;
    $smarty->_parse_resource_name($params, $smarty);

    /*
     * Find out if the resource exists.
     */

    if ($params['resource_type'] == 'file') {
        $_readable = false;
        if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
            $_readable = true;
        } else {
            // test for file in include_path
            $_params = array('file_path' => $params['resource_name']);
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_include_path.php');
            if(smarty_core_get_include_path($_params, $smarty)) {
                $_include_path = $_params['new_file_path'];
                $_readable = true;
            }
        }
    } elseif ($params['resource_type'] != 'file') {
        $_template_source = null;
        $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
            && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
                                    array($params['resource_name'], &$_template_source, &$smarty));
    }

    /*
     * Set the error function, depending on which class calls us.
     */
    if (method_exists($smarty, '_syntax_error')) {
        $_error_funcc = '_syntax_error';
    } else {
        $_error_funcc = 'trigger_error';
    }

    if ($_readable) {
        if ($smarty->security) {
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.is_trusted.php');
            if (!smarty_core_is_trusted($params, $smarty)) {
                $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
                return false;
            }
        }
    } else {
        $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
        return false;
    }

    if ($params['resource_type'] == 'file') {
        $params['php_resource'] = $params['resource_name'];
    } else {
        $params['php_resource'] = $_template_source;
    }
    return true;
}
/**
 * Smarty {debug} function plugin
 *
 * Type:     function<br>
 * Name:     debug<br>
 * Date:     July 1, 2002<br>
 * Purpose:  popup debug window
 * @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
 *       (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string output from {@link Smarty::_generate_debug_output()}
 */
function smarty_function_debug($params, &$smarty)
{
    if (isset($params['output'])) {
        $smarty->assign('_smarty_debug_output', $params['output']);
    }
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.display_debug_console.php');
    return smarty_core_display_debug_console(null, $smarty);
}
 function create_plugin_instance()
 {
     $aPages = oos_get_pages();
     if (isset($_GET['page']) && $_GET['page'] != $aPages['info_down_for_maintenance']) {
         MyOOS_CoreApi::redirect(oos_href_link($aPages['info_down_for_maintenance'], '', 'NONSSL', true, false));
     }
     return true;
 }
 function create_plugin_instance()
 {
     MyOOS_CoreApi::requireOnce('functions/function_banner.php');
     // auto activate and expire banners
     oos_activate_banners();
     oos_expire_banners();
     return true;
 }
function smarty_outputfilter_highlight($source, &$smarty)
{
    $highlight = $_REQUEST['highlight'];
    if (isset($_GET['keywords'])) {
        $highlight .= oos_var_prep_for_os($_GET['keywords']);
    }
    $highlight = strip_tags($highlight);
    $sStrSize = strlen($highlight);
    if ($sStrSize <= 5) {
        return $source;
    }
    if (eregi(oos_server_get_var('HTTP_HOST'), oos_server_get_var('HTTP_REFERER'))) {
        if (!isset($highlight) || empty($highlight)) {
            return $source;
        }
    } else {
        MyOOS_CoreApi::requireOnce('classes/class_referrer.php');
        $referrer = new referrer();
        $highlight .= $referrer->getKeywords();
    }
    $words = $highlight;
    if (!isset($highlight) || empty($highlight)) {
        return $source;
    }
    // Pull out the script blocks
    preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
    $_script_blocks = $match[0];
    $source = preg_replace("!<script[^>]+>.*?</script>!is", '@@@=====@@@', $source);
    preg_match_all("!<a onmouseo[^>]+>.*!is", $source, $match);
    $_onmouse_block = $match[0];
    $source = preg_replace("!<a onmouseo[^>]+>.*!is", '@@@#=====#@@@', $source);
    // pull out all html tags
    preg_match_all("'<[\\/\\!]*?[^<>]*'si", $source, $match);
    $_tag_blocks = $match[0];
    $source = preg_replace("'<[\\/\\!]*?[^<>]*'si", '@@@:=====:@@@', $source);
    // This array is used to choose colors for supplied highlight terms
    $colorArr = array('#ffff66', '#ff9999', '#A0FFFF', '#ff66ff', '#99ff99');
    // Wrap all the highlight words with tags bolding them and changing
    // their background colors
    $wordArr = split(" ", addslashes($words));
    $i = 0;
    foreach ($wordArr as $word) {
        $word = preg_quote($word);
        $source = preg_replace('~(' . $word . ')~si', '<span style="color:black;background-color:' . $colorArr[$i] . ';">$1</span>', $source);
        $i++;
    }
    // replace script blocks
    foreach ($_script_blocks as $curr_block) {
        $source = preg_replace("!@@@=====@@@!", $curr_block, $source, 1);
    }
    foreach ($_onmouse_block as $curr_block) {
        $source = preg_replace("!@@@#=====#@@@!", $curr_block, $source, 1);
    }
    foreach ($_tag_blocks as $curr_block) {
        $source = preg_replace("!@@@:=====:@@@!", $curr_block, $source, 1);
    }
    return $source;
}
 function create_plugin_instance()
 {
     $aFilename = oos_get_filename();
     $aModules = oos_get_modules();
     if ($_GET['file'] != $aFilename['info_down_for_maintenance']) {
         MyOOS_CoreApi::redirect(oos_href_link($aModules['info'], $aFilename['info_down_for_maintenance'], '', 'NONSSL', true, false));
     }
     return true;
 }
/**
 * Smarty {css_back_button} function plugin
 *
 * Type:     function
 * Name:     css_back_button
 * @Version:  $Revision: 1.1 $ - changed by $Author: r23 $ on $Date: 2008/01/09 22:03:20 $
 */

function smarty_function_css_back_button($params, &$smarty)
{
    global $oEvent, $spider_kill_sid;

    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $title = '';
    $color = 'btnR green';


    foreach($params as $_key => $_val) {
      switch($_key) {

        case 'title':
            $$_key = (string)$_val;
            break;

        case 'color':
            $$_key = (string)$_val;
            break;

        default:
          break;
       }
    }

    $aPages = oos_get_pages();

    if (count($_SESSION['navigation']->path)-2 > 0) {
      $back = count($_SESSION['navigation']->path)-2;
      $link = oos_href_link($_SESSION['navigation']->path[$back]['page'], $_SESSION['navigation']->path[$back]['get'].'&amp;history_back=true', $_SESSION['navigation']->path[$back]['mode']);
    } else {
      if (strstr(HTTP_SERVER, $_SERVER['HTTP_REFERER'])) {
        $link = $_SERVER['HTTP_REFERER'];
      } else {
        $link = oos_href_link($aPages['main']);
      }
    }

    while ( (substr($link, -5) == '&amp;') || (substr($link, -1) == '?') ) {
      if (substr($link, -1) == '?') {
        $link = substr($link, 0, -1);
      } else {
        $link = substr($link, 0, -5);
      }
    }


    $title = decode($title);

    return '<a href="' . $link . '" title="' . $title . '" class="' . $color . '">' . $title . '</a>';


  }
function smarty_function_oos_cost($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $price = '';
    $tax = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    print $oCurrencies->format(oos_add_tax($price, $tax));
}
/**
 * Replace cached inserts with the actual results
 *
 * @param string $results
 * @return string
 */
function smarty_core_process_cached_inserts($params, &$smarty)
{
    preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
                   $params['results'], $match);
    list($cached_inserts, $insert_args) = $match;

    for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
        if ($smarty->debugging) {
            $_params = array();
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php');
            $debug_start_time = smarty_core_get_microtime($_params, $smarty);
        }

        $args = unserialize($insert_args[$i]);
        $name = $args['name'];

        if (isset($args['script'])) {
            $_params = array('resource_name' => $smarty->_dequote($args['script']));
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_php_resource.php');
            if(!smarty_core_get_php_resource($_params, $smarty)) {
                return false;
            }
            $resource_type = $_params['resource_type'];
            $php_resource = $_params['php_resource'];


            if ($resource_type == 'file') {
                $smarty->_include($php_resource, true);
            } else {
                $smarty->_eval($php_resource);
            }
        }

        $function_name = $smarty->_plugins['insert'][$name][0];
        if (empty($args['assign'])) {
            $replace = $function_name($args, $smarty);
        } else {
            $smarty->assign($args['assign'], $function_name($args, $smarty));
            $replace = '';
        }

        $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i]));
        if ($smarty->debugging) {
            $_params = array();
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php');
            $smarty->_smarty_debug_info[] = array('type'      => 'insert',
                                                'filename'  => 'insert_'.$name,
                                                'depth'     => $smarty->_inclusion_depth,
                                                'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
        }
    }

    return $params['results'];
}
/**
 * Handle insert tags
 *
 * @param array $args
 * @return string
 */
function smarty_core_run_insert_handler($params, &$smarty)
{

    MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php');
    if ($smarty->debugging) {
        $_params = array();
        $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
    }

    if ($smarty->caching) {
        $_arg_string = serialize($params['args']);
        $_name = $params['args']['name'];
        if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
            $smarty->_cache_info['insert_tags'][$_name] = array('insert',
                                                             $_name,
                                                             $smarty->_plugins['insert'][$_name][1],
                                                             $smarty->_plugins['insert'][$_name][2],
                                                             !empty($params['args']['script']) ? true : false);
        }
        return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
    } else {
        if (isset($params['args']['script'])) {
            $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_php_resource.php');
            if(!smarty_core_get_php_resource($_params, $smarty)) {
                return false;
            }

            if ($_params['resource_type'] == 'file') {
                $smarty->_include($_params['php_resource'], true);
            } else {
                $smarty->_eval($_params['php_resource']);
            }
            unset($params['args']['script']);
        }

        $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
        $_content = $_funcname($params['args'], $smarty);
        if ($smarty->debugging) {
            $_params = array();
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php');
            $smarty->_smarty_debug_info[] = array('type'      => 'insert',
                                                'filename'  => 'insert_'.$params['args']['name'],
                                                'depth'     => $smarty->_inclusion_depth,
                                                'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
        }

        if (!empty($params['args']["assign"])) {
            $smarty->assign($params['args']["assign"], $_content);
        } else {
            return $_content;
        }
    }
}
 function create_plugin_instance()
 {
     if (!isset($_SESSION['customer_id']) || !is_numeric($_SESSION['customer_id'])) {
         $aPages = oos_get_pages();
         if (isset($_GET['page']) && $_GET['page'] != $aPages['login']) {
             $_SESSION['navigation']->set_snapshot();
             MyOOS_CoreApi::redirect(oos_href_link($aPages['login'], '', 'SSL'));
         }
     }
     return true;
 }
 function create_plugin_instance()
 {
     if (!isset($_SESSION['customer_id'])) {
         $aFilename = oos_get_filename();
         $aModules = oos_get_modules();
         if ($_GET['mp'] != $aModules['user']) {
             $_SESSION['navigation']->set_snapshot();
             MyOOS_CoreApi::redirect(oos_href_link($aModules['user'], $aFilename['login'], '', 'SSL'));
         }
     }
     return true;
 }
/**
 * Smarty {html_options} function plugin
 *
 * Type:     function<br>
 * Name:     html_options<br>
 * Input:<br>
 *           - name       (optional) - string default "select"
 *           - values     (required if no options supplied) - array
 *           - options    (required if no values supplied) - associative array
 *           - selected   (optional) - string default not set
 *           - output     (required if not options supplied) - array
 * Purpose:  Prints the list of <option> tags generated from
 *           the passed parameters
 * @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
 *      (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_options($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $name = null;
    $values = null;
    $options = null;
    $selected = array();
    $output = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
                ${$_key} = (string) $_val;
                break;
            case 'options':
                ${$_key} = (array) $_val;
                break;
            case 'values':
            case 'output':
                ${$_key} = array_values((array) $_val);
                break;
            case 'selected':
                ${$_key} = array_map('strval', array_values((array) $_val));
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    if (!isset($options) && !isset($values)) {
        return '';
    }
    /* raise error here? */
    $_html_result = '';
    if (isset($options)) {
        foreach ($options as $_key => $_val) {
            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
        }
    } else {
        foreach ($values as $_i => $_key) {
            $_val = isset($output[$_i]) ? $output[$_i] : '';
            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
        }
    }
    if (!empty($name)) {
        $_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
    }
    return $_html_result;
}
/**
 * Smarty {oos_add_tax} function plugin
 *
 * Type:     function
 * Name:     oos_get_zone_name
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_add_tax($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    if ($_SESSION['member']->group['show_price_tax'] == 1) {
        return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + oos_calculate_tax($price, $tax);
    } else {
        return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    }
}
/**
 * Smarty {html_image_submit} function plugin
 *
 * Type:     function<br>
 * Name:     html_image_submit<br>
 * Date:     September 15, 2003
 * Input:<br>
 *         - button = button (and path) of image (required)
 *         - border = border width (optional, default 0)
 *         - height = image height (optional, default actual height)
 *         - basedir = base directory
 *
 * Examples: {html_image_submit image="masthead.gif"}
 * @author r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 */
function smarty_function_html_customer_image_submit($params, &$smarty)
{


    if ($_SESSION['member']->group['show_price'] != 1) {
      return '';
    }

    MyOOS_CoreApi::requireOnce('lib/smarty-plugins/myoos/function.html_image_submit.php');

    return smarty_function_html_image_submit($params, $smarty);

}
/**
 * Smarty {swap_product_image} function plugin
 *
 * Type:     function<br>
 * Name:     swap_product_image<br>
 * Date:     Oct 09, 2006<br>
 * Purpose:  format HTML tags for the image<br>
 * Input:<br>
 *         - image = image width (optional, default actual width)
 *         - border = border width (optional, default 0)
 *         - height = image height (optional, default actual height)
 *
 * Examples: {swap_product_image id="featured" image=$random.products_image alt=$random.products_name|strip_tags}
 * Output:   <img id="featured" src="images/product_image.jpg" border="0" alt="products_name" onmouseover="imgSwap(this)" onmouseout="imgSwap(this)"/>
 * @author   r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_swap_product_image($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $basedir = OOS_IMAGES;
    $height = SMALL_IMAGE_HEIGHT;
    $width = SMALL_IMAGE_WIDTH;
    $border = 0;
    $alt = '';
    $image = '';
    $extra = '';

    $sLanguage = oos_var_prep_for_os($_SESSION['language']);

    foreach($params as $_key => $_val) {
      switch($_key) {
        case 'id':
        case 'image':
        case 'border':
        case 'height':
        case 'width':
        case 'basedir':
        case 'alt':
           if (!is_array($_val)) {
             $$_key = smarty_function_escape_special_chars($_val);
           } else {
             $smarty->trigger_error("small_product_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
           }
           break;

        default:
           if (!is_array($_val)) {
             $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
           } else {
             $smarty->trigger_error("small_product_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
           }
           break;
      }
    }

    $image = $basedir . $image;

    if ((empty($image) || ($image == OOS_IMAGES)) && (IMAGE_REQUIRED == '0')) {
        return false;
    }

    return '<img id="'.$id.'" src="'.$image.'" alt="'.$alt.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' onmouseover="imgSwap(this)" onmouseout="imgSwap(this)" />';

}
/**
 * assemble filepath of requested plugin
 *
 * @param string $type
 * @param string $name
 * @return string|false
 */
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
    static $_filepaths_cache = array();

    $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
    if (isset($_filepaths_cache[$_plugin_filename])) {
        return $_filepaths_cache[$_plugin_filename];
    }
    $_return = false;

    foreach ((array)$smarty->plugins_dir as $_plugin_dir) {

        $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;

        // see if path is relative
        if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
            $_relative_paths[] = $_plugin_dir;
            // relative path, see if it is in the SMARTY_DIR
            if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
                $_return = SMARTY_DIR . $_plugin_filepath;
                break;
            }
        }
        // try relative to cwd (or absolute)
        if (@is_readable($_plugin_filepath)) {
            $_return = $_plugin_filepath;
            break;
        }
    }

    if($_return === false) {
        // still not found, try PHP include_path
        if(isset($_relative_paths)) {
            foreach ((array)$_relative_paths as $_plugin_dir) {

                $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;

                $_params = array('file_path' => $_plugin_filepath);
                MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_include_path.php');
                if(smarty_core_get_include_path($_params, $smarty)) {
                    $_return = $_params['new_file_path'];
                    break;
                }
            }
        }
    }
    $_filepaths_cache[$_plugin_filename] = $_return;
    return $_return;
}
/**
 * Smarty {oos_check_stock} function plugin
 *
 * Type:     function
 * Name:     oos_check_stock
 * Version:  1.0
 * -------------------------------------------------------------
 */
function smarty_function_oos_check_stock($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $products_id = '';
    $products_quantity = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    $stock_left = oos_get_products_stock($products_id) - $products_quantity;
    $out_of_stock = '';
    if ($stock_left < 0) {
        $out_of_stock = '<span class="oos-MarkProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
    }
    return $out_of_stock;
}
 function create_plugin_instance()
 {
     global $oCurrencies;
     MyOOS_CoreApi::requireOnce('classes/class_currencies.php');
     $oCurrencies = new currencies();
     // currency
     if (!isset($_SESSION['currency']) || isset($_GET['currency']) || USE_DEFAULT_LANGUAGE_CURRENCY == '1' && LANGUAGE_CURRENCY != $_SESSION['currency']) {
         if (isset($_GET['currency']) && oos_currency_exits($_GET['currency'])) {
             $_SESSION['currency'] = oos_var_prep_for_os($_GET['currency']);
         } else {
             $_SESSION['currency'] = USE_DEFAULT_LANGUAGE_CURRENCY == '1' ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
         }
     }
     return true;
 }
function smarty_function_oos_display_price($params, &$smarty)
{
    global $oCurrencies;
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');
    $price = '';
    $tax = '';
    $qty = '';
    $calculate_currency_value = true;
    $currency = '';
    $currency_value = '';
    foreach ($params as $_key => $_val) {
        ${$_key} = smarty_function_escape_special_chars($_val);
    }
    print $oCurrencies->format(oos_add_tax($price, $tax) * $qty, $calculate_currency_value, $currency, $currency_value);
}
    function create_plugin_instance() {

      MyOOS_CoreApi::requireOnce('classes/class_url_rewrite.php');

      if (isset($_GET['rewrite'])) {
        $sUrl = oos_server_get_var('QUERY_STRING');
      }

      if (!empty($sUrl)) {

        while (strstr($sUrl, '&amp;'))  $sUrl = str_replace('&amp;', '&', $sUrl);
        while (strstr($sUrl, '&&')) $sUrl = str_replace('&&', '&', $sUrl);

        $sUrl = str_replace('?', '/', $sUrl);
        $sUrl = str_replace('=', '/', $sUrl);
        $sUrl = str_replace('&', '/', $sUrl);
        $sPathInfo = trim($sUrl, '/');
      } else {
        $sPathInfo = oos_server_get_var('PATH_INFO');
      }

      if (isset($sPathInfo) && (strlen($sPathInfo) > 1)) {
        $_SERVER['PHP_SELF'] = str_replace($sPathInfo, '', $_SERVER['PHP_SELF']);
        $aVars = explode('/', substr($sPathInfo, 1));

        $aGet = array();

        $nArrayCountVars = count($aVars);
        for ($i=0, $n=$nArrayCountVars; $i<$n; $i++) {
          if (!isset($aVars[$i+1])) $aVars[$i+1] = '';

          if (strpos($aVars[$i], '[]')) {
            $aGet[substr($aVars[$i], 0, -2)][] = $aVars[$i+1];
          } else {
            $_GET[$aVars[$i]] = $aVars[$i+1];
          }
          $i++;
        }

        if (count($aGet) > 0) {
          foreach ($aGet as $sKey => $sValue) {
            $_GET[$sKey] = $sValue;
          }
        }
      }

      return true;
    }
function smarty_core_rm_auto($params, &$smarty)
{
    if (!@is_dir($params['auto_base']))
      return false;

    if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
        $_params = array(
            'dirname' => $params['auto_base'],
            'level' => 0,
            'exp_time' => $params['exp_time']
        );
        MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.rmdir.php');
        $_res = smarty_core_rmdir($_params, $smarty);
    } else {
        $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);

        if(isset($params['auto_source'])) {
            if (isset($params['extensions'])) {
                $_res = false;
                foreach ((array)$params['extensions'] as $_extension)
                    $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
            } else {
                $_res = $smarty->_unlink($_tname, $params['exp_time']);
            }
        } elseif ($smarty->use_sub_dirs) {
            $_params = array(
                'dirname' => $_tname,
                'level' => 1,
                'exp_time' => $params['exp_time']
            );
            MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.rmdir.php');
            $_res = smarty_core_rmdir($_params, $smarty);
        } else {
            // remove matching file names
            $_handle = opendir($params['auto_base']);
            $_res = true;
            while (false !== ($_filename = readdir($_handle))) {
                if($_filename == '.' || $_filename == '..') {
                    continue;
                } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
                    $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
                }
            }
        }
    }

    return $_res;
}
/**
 * Smarty {html_iframe} function plugin
 *
 * Type:     function<br>
 * Name:     html_image_button<br>
 * Date:     September 15, 2003
 * Input:<br>
 *         - button = button (and path) of image (required)
 *         - border = border width (optional, default 0)
 *         - height = image height (optional, default actual height)
 *         - basedir = base directory
 *
 * Examples: {html_iframe doc="gpl.html" class="license" frameborder="0" scrolling="auto"}
 * @author r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_iframe($params, &$smarty)
{
    MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php');

    $doc = '';
    $class = 'license';
    $frameborder = 0;
    $height = '';
    $scrolling = 'auto';
    $extra = '';
    // $sTheme = oos_var_prep_for_os($_SESSION['theme']);
    $sLanguage = oos_var_prep_for_os($_SESSION['language']);
    $dir = OOS_SHOP . OOS_MEDIA . $sLanguage . '/';

    foreach($params as $_key => $_val) {
        switch($_key) {

            case 'doc':
            case 'class':
            case 'frameborder':
            case 'scrolling':
                if(!is_array($_val)) {
                 $$_key = smarty_function_escape_special_chars($_val);
                } else {
                  $smarty->trigger_error("html_iframe: attribute '$_key' cannot be an array", E_USER_NOTICE);
                }
                break;

            default:
                if(!is_array($_val)) {
                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
                } else {
                    $smarty->trigger_error("html_iframe: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }

    if (empty($doc)) {
        $smarty->trigger_error("html_iframe: missing 'doc' parameter", E_USER_NOTICE);
        return;
    }

    return '<iframe src="'.$dir.$doc.'" class="'.$class.'" frameborder="'.$frameborder.'" scrolling="'.$scrolling.'"'.$extra.' /></iframe>';


}
 function create_plugin_instance()
 {
     global $oBreadcrumb, $aLang, $aCategoryPath;
     $dbconn =& oosDBGetConn();
     $oostable =& oosDBGetTables();
     $aPages = oos_get_pages();
     // include the breadcrumb class and start the breadcrumb trail
     MyOOS_CoreApi::requireOnce('classes/class_breadcrumb.php');
     $oBreadcrumb = new breadcrumb();
     if (isset($_GET['page']) && $_GET['page'] == $aPages['main'] || !isset($_GET['page'])) {
         $oBreadcrumb->add($aLang['header_title_top'], oos_href_link($aPages['main']), bookmark);
     } else {
         $oBreadcrumb->add($aLang['header_title_top'], oos_href_link($aPages['main']));
     }
     // add category names or the manufacturer name to the breadcrumb trail
     if (isset($aCategoryPath) && count($aCategoryPath) > 0) {
         $nLanguageID = isset($_SESSION['language_id']) ? $_SESSION['language_id'] + 0 : 1;
         $nArrayCountCategoryPath = count($aCategoryPath);
         $nCount = $nArrayCountCategoryPath;
         for ($i = 0, $n = $nArrayCountCategoryPath; $i < $n; $i++) {
             $nCount = $nCount - 1;
             $categories_descriptiontable = $oostable['categories_description'];
             $categories_sql = "SELECT categories_name\n                                   FROM {$categories_descriptiontable}\n                                   WHERE categories_id = '" . intval($aCategoryPath[$i]) . "'\n                                   AND categories_languages_id = '" . intval($nLanguageID) . "'";
             $categories = $dbconn->Execute($categories_sql);
             if ($categories->RecordCount() > 0) {
                 if (isset($_GET['page']) && $_GET['page'] == $aPages['shop'] && $nCount == 0) {
                     $oBreadcrumb->add($categories->fields['categories_name'], oos_href_link($aPages['shop'], 'categories=' . implode('_', array_slice($aCategoryPath, 0, $i + 1))), bookmark);
                 } else {
                     $oBreadcrumb->add($categories->fields['categories_name'], oos_href_link($aPages['shop'], 'categories=' . implode('_', array_slice($aCategoryPath, 0, $i + 1))));
                 }
             } else {
                 break;
             }
         }
     } elseif (isset($_GET['manufacturers_id']) && is_numeric($_GET['manufacturers_id'])) {
         $manufacturers_id = intval($_GET['manufacturers_id']);
         $manufacturerstable = $oostable['manufacturers'];
         $manufacturers_sql = "SELECT manufacturers_name\n                                  FROM {$manufacturerstable}\n                                  WHERE manufacturers_id = '" . intval($manufacturers_id) . "'";
         $manufacturers = $dbconn->Execute($manufacturers_sql);
         if ($manufacturers->RecordCount() > 0) {
             $oBreadcrumb->add($aLang['header_title_catalog'], oos_href_link($aPages['shop']));
             $oBreadcrumb->add($manufacturers->fields['manufacturers_name'], oos_href_link($aPages['shop'], 'manufacturers_id=' . intval($_GET['manufacturers_id'])), bookmark);
         }
     }
     return true;
 }