function vam_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 = vam_rand(0, 9); } else { $char = chr(vam_rand(0, 255)); } if ($type == 'mixed') { if (preg_match('/^[a-z0-9]$/i', $char)) { $rand_value .= $char; } } elseif ($type == 'chars') { if (preg_match('/^[a-z]$/i', $char)) { $rand_value .= $char; } } elseif ($type == 'digits') { if (preg_match('/^[0-9]$/', $char)) { $rand_value .= $char; } } } return $rand_value; }
function vam_random_name() { $letters = 'abcdefghijklmnopqrstuvwxyz'; $dirname = '.'; $length = floor(vam_rand(16, 20)); for ($i = 1; $i <= $length; $i++) { $q = floor(vam_rand(1, 26)); $dirname .= $letters[$q]; } return $dirname; }
function vam_random_select($query) { $random_product = ''; $random_query = vam_db_query($query); $num_rows = vam_db_num_rows($random_query); if ($num_rows > 0) { $random_row = vam_rand(0, $num_rows - 1); vam_db_data_seek($random_query, $random_row); $random_product = vam_db_fetch_array($random_query); } return $random_product; }
function vam_random_charcode($length) { $arraysize = 10; // $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'); $chars = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $code = ''; for ($i = 1; $i <= $length; $i++) { $j = floor(vam_rand(0, $arraysize)); $code .= $chars[$j]; } return $code; }
function session_start() { global $session, $SID, $_COOKIE, $_GET, $_POST; // Define the global variable $SID? $define_sid = true; // Send the session cookie? $send_cookie = true; // Is track_vars enabled? $track_vars = isset($_COOKIE) || isset($_GET) || isset($_POST) ? true : false; // Check if session_start() has been called once already if ($session->nr_open_sessions != 0) { return false; } // If our only resource is the global symbol_table, then check it. // If track_vars are enabled, we prefer these, because they are more // reliable, and we always know whether the user has accepted the // cookie. if (isset($GLOBALS[$session->name]) && !empty($GLOBALS[$session->name]) && !$track_vars) { $session->id = $GLOBALS[$session->name]; $send_cookie = false; } // Now check the track_vars. Cookies are preferred, because initially // cookie and get variables will be available. if (empty($session->id) && $track_vars) { if (isset($_COOKIE[$session->name])) { $session->id = $_COOKIE[$session->name]; $define_sid = false; $send_cookie = false; } if (isset($_GET[$session->name])) { $session->id = $_GET[$session->name]; } if (isset($_POST[$session->name])) { $session->id = $_POST[$session->name]; } } /* // Check the REQUEST_URI symbol for a string of the form // '<session-name>=<session-id>' to allow URLs of the form // http://yoursite/<session-name>=<session-id>/script.php if (empty($session->id)) { preg_match('/'.$session->name . '=([^/]+)/i', $GLOBALS['REQUEST_URI'], $regs); $regs[1] = trim($regs[1]); if (!empty($regs[1])) { $session->id = $regs[1]; } } */ // Check whether the current request was referred to by // an external site which invalidates the previously found ID if (!empty($session->id) && $session->referer_check) { $url = parse_url($_SERVER['HTTP_REFERER']); if (trim($url['host']) != $_SERVER['SERVER_NAME']) { unset($session->id); $send_cookie = true; $define_sid = true; } } // Do we have an existing session ID? if (empty($session->id)) { // Create new session ID $session->id = _session_create_id(); } // Is use_cookies set to false? if (!$session->use_cookies && $send_cookie) { $define_sid = true; $send_cookie = false; } // Should we send a cookie? if ($send_cookie) { setcookie($session->name, $session->id, $session->cookie_lifetime, $session->cookie_path, $session->cookie_domain); } // Should we define the SID? if ($define_sid) { $SID = $session->name . '=' . $session->id; } $session->nr_open_sessions++; // Send caching headers // Start session $mod = $GLOBALS[$session->mod_name]; if (!$mod->open($session->save_path, $session->name)) { die('Failed to initialize session module.'); } // Read session data if ($val = $mod->read($session->id)) { // Decode session data session_decode($val); } // Send HTTP cache headers _session_cache_limiter(); // Check if we should clean up (call the garbage collection routines) if ($session->gc_probability > 0) { $randmax = getrandmax(); $nrand = (int) (100 * vam_rand() / $randmax); if ($nrand < $session->gc_probability) { $mod->gc($session->gc_maxlifetime); } } if ($define_sid) { define('SID', $SID); } else { define('SID', ''); } return true; }
function vvcode_render_code($code) { if (!empty($code)) { // load fonts $ttf = array(); if ($dir = opendir(DIR_WS_INCLUDES . 'fonts/')) { while (($file = readdir($dir)) !== false) { if (is_file(DIR_WS_INCLUDES . 'fonts/' . $file) and strstr($file, '.ttf')) { $ttf[] = DIR_FS_CATALOG . '/includes/fonts/' . $file; } } closedir($dir); } $width = 240; $height = 50; $imgh = imagecreate($width, $height); // BOF - Tomcraft - 2009-11-06 - Set VVCODE Colors back to default // BOF - Dokuman - 2009-10-14 - Set VVCODE Colors to default template color $fonts = imagecolorallocate($imgh, vam_rand(0, 255), vam_rand(0, 255), vam_rand(0, 255)); $lines = imagecolorallocate($imgh, vam_rand(0, 255), vam_rand(0, 255), vam_rand(0, 255)); $background = imagecolorallocate($imgh, vam_rand(0, 255), vam_rand(0, 255), vam_rand(0, 255)); /* $fonts = imagecolorallocate($imgh, 137, 55, 105); $lines = imagecolorallocate($imgh, 222, 222, 222); $background = imagecolorallocate($imgh, 180, 180, 180); */ // EOF - Dokuman - 2009-10-14 - Set VVCODE Colors to default template color // BOF - Tomcraft - 2009-11-06 - Set VVCODE Colors back to default imagefill($imgh, 0, 0, $background); $x = vam_rand(0, 20); $y = vam_rand(20, 40); for ($i = $x, $z = $y; $i < $width && $z < $width;) { imageLine($imgh, $i, 0, $z, $height, $lines); $i += $x; $z += $y; } $x = vam_rand(0, 20); $y = vam_rand(20, 40); for ($i = $x, $z = $y; $i < $width && $z < $width;) { imageLine($imgh, $z, 0, $i, $height, $lines); $i += $x; $z += $y; } $x = vam_rand(0, 10); $y = vam_rand(10, 20); for ($i = $x, $z = $y; $i < $height && $z < $height;) { imageLine($imgh, 0, $i, $width, $z, $lines); $i += $x; $z += $y; } $x = vam_rand(0, 10); $y = vam_rand(10, 20); for ($i = $x, $z = $y; $i < $height && $z < $height;) { imageLine($imgh, 0, $z, $width, $i, $lines); $i += $x; $z += $y; } for ($i = 0; $i < strlen($code); $i++) { $font = $ttf[(int) vam_rand(0, count($ttf) - 1)]; $size = vam_rand(30, 36); $rand = vam_rand(1, 20); $direction = vam_rand(0, 1); if ($direction == 0) { $angle = 0 - $rand; } else { $angle = $rand; } if (function_exists('imagettftext')) { imagettftext($imgh, $size, $angle, 15 + 36 * $i, 38, $fonts, $font, substr($code, $i, 1)); } else { $tc = ImageColorAllocate($imgh, 0, 0, 0); //Schriftfarbe - schwarz ImageString($imgh, $size, 26 + 36 * $i, 20, substr($code, $i, 1), $tc); } } header('Content-Type: image/jpeg'); imagejpeg($imgh); imagedestroy($imgh); } }
(c) 2004 xt:Commerce (last_viewed.php,v 1.4 2003/08/13); xt-commerce.com (c) 2004 xt:Commerce (last_viewed.php,v 1.4 2003/08/13); xt-commerce.com Released under the GNU General Public License ---------------------------------------------------------------------------------------*/ $box = new vamTemplate(); $box->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/'); $box_content = ''; if (isset($_SESSION[tracking][products_history][0])) { // include needed functions require_once DIR_FS_INC . 'vam_rand.inc.php'; require_once DIR_FS_INC . 'vam_get_path.inc.php'; require_once DIR_FS_INC . 'vam_get_products_name.inc.php'; $max = count($_SESSION[tracking][products_history]); $max--; $random_last_viewed = vam_rand(0, $max); //fsk18 lock $fsk_lock = ''; if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') { $fsk_lock = ' and p.products_fsk18!=1'; } if (GROUP_CHECK == 'true') { $group_check = " and p.group_permission_" . $_SESSION['customers_status']['customers_status_id'] . "=1 "; } $random_query = "select p.products_id,\n pd.products_name,\n p.products_price,\n p.products_tax_class_id,\n p.products_image,\n p2c.categories_id,\n p.products_vpe,\n\t\t\t\t p.products_vpe_status,\n\t\t\t\t p.products_vpe_value,\n cd.categories_name \n from \n " . TABLE_PRODUCTS . " p,\n " . TABLE_PRODUCTS_DESCRIPTION . " pd,\n " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,\n " . TABLE_CATEGORIES_DESCRIPTION . " cd\n where p.products_status = '1' \n and p.products_id = '" . (int) $_SESSION[tracking][products_history][$random_last_viewed] . "'\n and pd.products_id = '" . (int) $_SESSION[tracking][products_history][$random_last_viewed] . "'\n and p2c.products_id = '" . (int) $_SESSION[tracking][products_history][$random_last_viewed] . "'\n and pd.language_id = '" . $_SESSION['languages_id'] . "'\n and cd.categories_id = p2c.categories_id\n " . $group_check . "\n " . $fsk_lock . "\n and cd.language_id = '" . $_SESSION['languages_id'] . "'"; $random_query = vamDBquery($random_query); $random_product = vam_db_fetch_array($random_query, true); $random_products_price = $vamPrice->GetPrice($random_product['products_id'], $format = true, 1, $random_product['products_tax_class_id'], $random_product['products_price']); $category_path = vam_get_path($random_product['categories_id']); if ($random_product['products_name'] != '') { $box->assign('box_content', $product->buildDataArray($random_product));