function xtc_create_random_value($length, $type = 'mixed')
{
    if ($type != 'mixed' && $type != 'chars' && $type != 'digits') {
        return false;
    }
    $rand_value = '';
    while (strlen($rand_value) < $length) {
        if ($type == 'digits') {
            $char = xtc_rand(0, 9);
        } else {
            $char = chr(xtc_rand(0, 255));
        }
        if ($type == 'mixed') {
            if (preg_match('/^[a-z0-9]$/i', $char)) {
                $rand_value .= $char;
            }
            // Hetfield - 2009-08-19 - replaced deprecated function eregi with preg_match to be ready for PHP >= 5.3
        } elseif ($type == 'chars') {
            if (preg_match('/^[a-z]$/i', $char)) {
                $rand_value .= $char;
            }
            // Hetfield - 2009-08-19 - replaced deprecated function eregi with preg_match to be ready for PHP >= 5.3
        } elseif ($type == 'digits') {
            if (preg_match('/^[0-9]$/', $char)) {
                $rand_value .= $char;
            }
            // Hetfield - 2009-08-19 - replaced deprecated function ereg with preg_match to be ready for PHP >= 5.3
        }
    }
    return $rand_value;
}
function xtc_random_name()
{
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(xtc_rand(16, 20));
    for ($i = 1; $i <= $length; $i++) {
        $q = floor(xtc_rand(1, 26));
        $dirname .= $letters[$q];
    }
    return $dirname;
}
function xtc_random_select($query)
{
    $random_product = '';
    $random_query = xtc_db_query($query);
    $num_rows = xtc_db_num_rows($random_query);
    if ($num_rows > 0) {
        $random_row = xtc_rand(0, $num_rows - 1);
        xtc_db_data_seek($random_query, $random_row);
        $random_product = xtc_db_fetch_array($random_query);
    }
    return $random_product;
}
function xtc_random_charcode($length)
{
    //BOF - Dokuman - 2009-09-04: Captchas only uppercase and do not use chars like "O,0,1,7,I,J"
    //$arraysize = 34;
    //$chars = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9');
    $arraysize = 28;
    $chars = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '8', '9');
    //EOF - Dokuman - 2009-09-04: Captchas only uppercase and do not use chars like "O,0,1,I,J"
    $code = '';
    for ($i = 1; $i <= $length; $i++) {
        $j = floor(xtc_rand(0, $arraysize));
        $code .= $chars[$j];
    }
    return $code;
}
   Copyright (c) 2003 XT-Commerce
   -----------------------------------------------------------------------------------------

   Released under the GNU General Public License 
   ---------------------------------------------------------------------------------------*/
$box_smarty = new smarty();
$box_smarty->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/');
$box_content = '';
if (isset($_SESSION['tracking']['products_history'][0])) {
    // include needed functions
    require_once DIR_FS_INC . 'xtc_rand.inc.php';
    require_once DIR_FS_INC . 'xtc_get_path.inc.php';
    require_once DIR_FS_INC . 'xtc_get_products_name.inc.php';
    $max = count($_SESSION['tracking']['products_history']);
    $max--;
    $random_last_viewed = xtc_rand(0, $max);
    //fsk18 lock
    $fsk_lock = '';
    if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
        $fsk_lock = ' and p.products_fsk18!=1';
    }
    $group_check = '';
    //DokuMan - 2010-03-12 - set undefined variable
    if (GROUP_CHECK == 'true') {
        $group_check = " and p.group_permission_" . $_SESSION['customers_status']['customers_status_id'] . "=1 ";
    }
    //BOF - Dokuman - 2010-01-29 - category name selection included in one select statement
    /*
    	$random_query = "select p.products_id,
                                              pd.products_name,
                                              p.products_price,