function olc_get_templates(&$templates_dir, $strip_extension = false, $pattern = EMPTY_STRING)
{
    if (!is_dir($templates_dir)) {
        if (CHECK_UNIFIED_TEMPLATES) {
            $templates_dir = str_replace(FULL_TEMPLATE_PATH, FULL_COMMON_TEMPLATE, $templates_dir);
            $notemplate = !is_dir($templates_dir);
        } else {
            $notemplate = true;
        }
        if ($notemplate) {
            my_error_handler(E_USER_ERROR, ILLEGAL_DIRECTORY . $templates_dir);
        }
    }
    $files = array();
    if ($dir = opendir($templates_dir)) {
        $check_mask = $pattern != EMPTY_STRING;
        $add_to_files = true;
        $id_text = 'id';
        $text_text = 'text';
        while ($file = readdir($dir)) {
            if (is_file($templates_dir . $file)) {
                if ($file != INDEX_HTML) {
                    if ($check_mask) {
                        $add_to_files = strpos($file, $pattern) === false;
                    }
                    if ($strip_extension) {
                        $file = str_replace(HTML_EXT, EMPTY_STRING, $file);
                    }
                    if ($add_to_files) {
                        $files[] = array($id_text => $file, $text_text => $file);
                    } else {
                        $files[0] = array($id_text => $file, $text_text => $file);
                        break;
                    }
                }
                //if
            }
            //if
        }
        // while
        closedir($dir);
    }
    return $files;
}
function olc_db_error($query = EMPTY_STRING, $errno = 0, $error = EMPTY_STRING)
{
    if ($error == EMPTY_STRING) {
        if (USE_ADODB === true) {
            global ${$link};
            $errno = ${$link}->ErrorNo();
            if ($errno) {
                $error = ${$link}->ErrorMsg();
            }
        } else {
            $errno = mysql_errno();
            if ($errno) {
                $error = mysql_error();
            }
        }
    }
    if ($errno) {
        $error = $errno . ' - ' . $error . HTML_BR . $query;
        my_error_handler(E_USER_ERROR, $error);
    } else {
        return EMPTY_STRING;
    }
}
        var_dump($arg->key());
        var_dump($arg->current());
    } else {
        var_dump($arg);
    }
    return true;
}
function test()
{
    static $arg = 0;
    var_dump($arg++);
    return true;
}
$it = new RecursiveArrayIterator(array(1, array(21, 22), 3));
var_dump(iterator_apply($it, 'test', NULL));
echo "===ARGS===\n";
var_dump(iterator_apply($it, 'test_arg', array($it)));
echo "===RECURSIVE===\n";
$it = new RecursiveIteratorIterator($it);
var_dump(iterator_apply($it, 'test'));
echo "===ERRORS===\n";
try {
    var_dump(iterator_apply($it, 'test', 1));
} catch (Error $e) {
    my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
}
var_dump(iterator_apply($it, 'non_existing_function'));
var_dump(iterator_apply($it, 'non_existing_function', NULL, 2));
?>
===DONE===
function olc_href_link($page = '', $parameters = '', $connection = NONSSL, $add_session_id = true, $search_engine_safe = true, $create_ajax_link = true, $force_server_inclusion = false, $allow_ssl = true)
{
    global $session_started, $http_domain, $https_domain, $use_catalog_link, $request_type, $make_onclick_link;
    global $box_assignments, $box_relations, $box_constants, $currencies;
    global $seo_categories, $seo_search, $seo_replace, $smarty, $breadcrumb;
    if (olc_not_null($page)) {
        $separator = QUESTION;
        if (olc_not_null($parameters)) {
            /*
            if (!USE_SEO)
            {
            	if (strpos($parameters,HTML_AMP)===false)
            	{
            		$parameters=str_replace(AMP,HTML_AMP,$parameters);
            	}
            }
            */
            $link = $page . $separator . $parameters;
            $separator = AMP;
        } else {
            $link = $page;
        }
        $server = HTTP_SERVER;
        if ($connection == SSL || getenv(HTTPS) != null) {
            if (IS_ADMIN_FUNCTION) {
                $allow_ssl = true;
            } else {
                $allow_ssl = ENABLE_SSL;
            }
            if ($allow_ssl) {
                $server = HTTPS_SERVER;
            }
        }
        /*
        if (strpos($page,'http')===false)
        {
        	if (IS_ADMIN_FUNCTION && !$use_catalog_link)
        	{
        		$link_dir = DIR_WS_ADMIN;
        	}
        	else
        	{
        		$link_dir = DIR_WS_CATALOG;
        	}
        	$link=$link_dir.$link;
        }
        */
        if (NOT_IS_ADMIN_FUNCTION) {
            if (ADD_SESSION_ID) {
                if ($add_session_id) {
                    if (defined('SID') && olc_not_null(SID)) {
                        $sid = SID;
                    } elseif ($server) {
                        if ($http_domain != $https_domain) {
                            $sid = session_name() . '=' . session_id();
                        }
                    }
                }
            }
            if (strpos($_SERVER['PHP_SELF'], SLASH . "admin") === false) {
                // User mode!
                // Add the session id when moving from different HTTP and HTTPS servers, or when SID is defined
                if (olc_check_agent()) {
                    $sid = NULL;
                }
                if (isset($sid)) {
                    $link .= $separator . $sid;
                }
                if ($search_engine_safe) {
                    if (strpos($link, DIR_WS_PRODUCT_IMAGES) == false) {
                        $link = olc_seo_url($link);
                    }
                }
                //W. Kaiser - AJAX
                if (!defined('USE_AJAX')) {
                    // include the AJAX-related code
                    require DIR_WS_INCLUDES . 'ajax' . PHP;
                }
            }
        }
        $not_is_pop_up_link = strpos($parameters, "pop_up") === false;
        if (USE_AJAX) {
            //			$link=str_replace(DIR_WS_CATALOG,EMPTY_STRING,$link);
            /*
            if ($create_ajax_link)
            {
            //				$check_link=strpos($page,FILENAME_PRODUCT_INFO)!==false;
            //				if (!$check_link)
            //				{
            //				if (NOT_IS_ADMIN_FUNCTION)
            //				{
            //				$check_link=strpos($page,FILENAME_DEFAULT)!==false;
            //				}
            //				}
            //				if ($check_link)
            //				{
            //				$onclick="javascript:onclick="javascript:;
            //				if (strpos($page,AJAX_REQUEST)===false)
            //				{
            //
            //				}
            //				}
            }
            */
        } else {
            //$link=$server.$link;
            if ($make_onclick_link) {
                if ($not_is_pop_up_link) {
                    $link = "document.location.href='" . $link . APOS;
                }
                $make_onclick_link = false;
            }
        }
        //W. Kaiser - AJAX
        if (IS_MULTI_SHOP) {
            $link = olc_set_multi_shop_dir_info($link);
        }
        $link = str_replace(HTML_AMP, AMP, $link);
        $link = str_replace(AMP . AMP, AMP, $link);
        $link = str_replace(QUESTION . AMP, QUESTION, $link);
        $link = str_replace(AMP, HTML_AMP, $link);
        return $link;
    } else {
        my_error_handler(E_USER_ERROR, TEXT_ERROR_LINK_NOT_DEFINED);
    }
}
            $s = 'box_NAVIGATION';
            $box_relations[$s] = $s;
            $box_constants['SHOW_NAVIGATION'] = true;
        } else {
            if ($is_mystery) {
                $init_error_code = '$ini_error=TEXT_ERROR_MISSING_INI_FILE.$file.QUOTE';
            }
            //			else
            //			{
            //				$ini_error=TEXT_ERROR_MISSING_INI_DATA;
            //			}
        }
        if ($ini_error_code) {
            include_once 'lang' . SLASH . SESSION_LANGUAGE . SLASH . SESSION_LANGUAGE . PHP;
            eval($ini_error_code . SEMI_COLON);
            my_error_handler(E_ERROR, str_replace(DIR_FS_CATALOG, EMPTY_STRING, $ini_error));
        } else {
            $_SESSION[$box_relations_text] = $box_relations;
            $_SESSION[$box_constants_text] = $box_constants;
        }
    }
}
$s = '_box';
if ($layout_definition) {
    $layout_definition = TRUE_STRING_S;
    //Assign box display constants
    while (list($key, $value) = each($_SESSION[$box_constants_text])) {
        define($key, $value);
    }
    define('BOX_NAME', BOX . 'NAME');
    define('BOX_NAV_AREA_MIDDLE', 'm');
function olc_smarty_init(&$smarty, &$cacheid, $full_init = true)
{
    global $http_protocol, $server;
    //Set common Smarty data
    if (defined('CURRENT_TEMPLATE')) {
        define('FULL_CURRENT_TEMPLATE', TEMPLATE_PATH . CURRENT_TEMPLATE . SLASH);
    } else {
        $tpl_path = $tpl_path;
    }
    if (!is_object($smarty)) {
        //Create smarty elements
        $smarty = new Smarty();
    }
    $tpl_path = FULL_CURRENT_TEMPLATE;
    $template_dir = 'templates';
    $template_c_dir = 'cache/templates_c' . SLASH;
    $compile_dir = 'cache/templates_c/' . CURRENT_TEMPLATE;
    $config_dir = 'lang';
    $cache_dir = 'cache';
    if (IS_ADMIN_FUNCTION) {
        $compile_dir = ADMIN_PATH_PREFIX . $compile_dir;
        $smarty->cache_dir = ADMIN_PATH_PREFIX . $cache_dir;
        //$config_dir=ADMIN_PATH_PREFIX.$config_dir;
        $template_dir = ADMIN_PATH_PREFIX . $template_dir;
        $tpl_path = ADMIN_PATH_PREFIX . $tpl_path;
        $smarty->assign('tpl_path_catalog', $tpl_path);
        $tpl_path .= "admin" . SLASH;
    }
    $smarty->cache_dir = $cache_dir;
    $smarty->compile_dir = $compile_dir;
    $smarty->config_dir = $config_dir;
    $smarty->template_dir = $template_dir;
    if ($full_init) {
        $not_have_dir = !is_dir($compile_dir);
        if ($not_have_dir) {
            $compile_dirs = array($compile_dir, $template_c_dir);
            for ($i = 0, $n = sizeof($compile_dirs); $i < $n; $i++) {
                $compile_dir = $compile_dirs[$i];
                @mkdir($compile_dir);
                $ok_rights = is_dir($compile_dir);
                if ($ok_rights) {
                    $ok_rights = decoct(fileperms($compile_dir)) >= 0777;
                    $error = TEXT_SMARTY_COMPILE_DIR_RIGHTS;
                } else {
                    $error = TEXT_NO_SMARTY_COMPILE_DIR;
                }
                if (!$ok_rights) {
                    if (IS_ADMIN_FUNCTION) {
                        $lang_dir = $config_dir . SLASH . SESSION_LANGUAGE . SLASH;
                        require ADMIN_PATH_PREFIX . $lang_dir . SESSION_LANGUAGE . PHP;
                    }
                    my_error_handler(E_USER_ERROR, sprintf($error, $compile_dir));
                }
            }
        } else {
            $ok_rights = decoct(fileperms($compile_dir)) >= 0777;
        }
        if ($ok_rights) {
            /*
            $traceArr = debug_backtrace();
            $s = str_replace('\\',SLASH,strtolower($traceArr[0]['file']));
            $s = str_replace(strtolower(DIR_FS_CATALOG),EMPTY_STRING,$s);
            $smarty->assign('initted_in',$s.COLON.$traceArr[0]['line']);
            */
            $smarty->assign('tpl_path', $tpl_path);
            $smarty->assign('PROJECT_VERSION', PROJECT_VERSION);
            $smarty->assign('OL_COMMERCE', true);
            $smarty->assign('USE_AJAX', USE_AJAX);
            $smarty->assign('FORM_END', '</form>');
            $use_caching = USE_CACHE == TRUE_STRING_S;
            if ($use_caching) {
                $smarty->cache_lifetime = CACHE_LIFETIME;
                $smarty->cache_modified_check = CACHE_CHECK;
                $caret = "^";
                $cacheid = SESSION_LANGUAGE_ID . $caret . CUSTOMER_ID . $caret . str_replace(DOT, "%", $_SERVER['REMOTE_ADDR'] . $caret . CURRENT_SCRIPT);
            }
            if (defined('SESSION_LANGUAGE')) {
                $smarty->assign('language', SESSION_LANGUAGE);
                $smarty->assign('HTTP_PROTOCOL', $http_protocol);
                $smarty->assign('SERVER', $server);
                $s = 'SMARTY_CACHE_ID';
                if (defined($s)) {
                    $text_footer = $_SESSION[$text_footer_text];
                } else {
                    define($s, $cacheid);
                    $text_footer_text = 'text_footer';
                    $text_footer = $_SESSION[$text_footer_text];
                    if (!$text_footer) {
                        $text_footer = olc_get_smarty_config_variable($smarty, 'index', 'text_footer');
                        $text_footer = str_replace(HASH, STORE_NAME, $text_footer) . PROJECT_VERSION . HTML_A_END;
                        $s = 'GENERAL_DISCLAIMER';
                        if (defined($s)) {
                            if (GENERAL_DISCLAIMER) {
                                $text_footer .= HTML_BR . '<font style="font-weight:normal">' . constant($s) . '</font>';
                            }
                        }
                        $_SESSION[$text_footer_text] = $text_footer;
                    }
                }
                $smarty->assign($text_footer_text, $text_footer);
            }
        } else {
            my_error_handler(E_USER_ERROR, sprintf(TEXT_SMARTY_COMPILE_DIR_RIGHTS, $compile_dir));
        }
    }
    $smarty->caching = $use_caching;
}
$sep = '\',\'';
$onchange = ' onchange="' . $form_name . '.submit()' . QUOTE;
$hidden_text = '_hidden';
$template_text = 'template';
$auto_resubmit_text = 'auto_resubmit';
$images_dir = $catalog_dir_remote . DIR_WS_PRODUCT_IMAGES;
$template_dir = ADMIN_PATH_PREFIX . TEMPLATE_PATH . CURRENT_TEMPLATE_MODULE . 'ebay' . SLASH;
if (!is_dir($template_dir)) {
    if (CHECK_UNIFIED_TEMPLATES) {
        $template_dir = str_replace(FULL_CURRENT_TEMPLATE, FULL_COMMON_TEMPLATE, $template_dir);
        $notemplate = !is_dir($template_dir);
    } else {
        $notemplate = true;
    }
    if ($notemplate) {
        my_error_handler(E_USER_ERROR, AUCTIONS_LIST_ERROR_NO_TEMPLATE . $template_dir . QUOTE);
    }
}
//check for errors, and set values
if ($category_id || $choose || $search) {
    //get all products for dropdown
    if (!$search && ($category_id && $category_id != TEXT_ALL_CATEGORIES)) {
        $cat_table = ", " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ";
        $cat_where = "\n\t\t and\n\t\t p2c.products_id=p.products_id and\n\t\t p2c.categories_id='" . $category_id . APOS;
    } else {
        $cat_table = EMPTY_STRING;
        if ($search) {
            $like = " LIKE '%" . $search . "%'";
            $cat_where = "\n\t\t\t and (\n\t\t\t pd.products_name" . $like . " or\n\t\t\t pd.products_short_description" . $like . " or\n\t\t\t pd.products_description" . $like . RPAREN;
        } else {
            $cat_where = EMPTY_STRING;