Exemplo n.º 1
0
function olc_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 = olc_rand(0, 9);
        } else {
            $char = chr(olc_rand(0, 255));
        }
        if ($type == 'mixed') {
            if (eregi('^[a-z0-9]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'chars') {
            if (eregi('^[a-z]$', $char)) {
                $rand_value .= $char;
            }
        } elseif ($type == 'digits') {
            if (ereg('^[0-9]$', $char)) {
                $rand_value .= $char;
            }
        }
    }
    return $rand_value;
}
function olc_random_select($query, $rows = 1)
{
    global $random_rows;
    $random_product = '';
    $random_query = olc_db_query($query);
    $num_rows = olc_db_num_rows($random_query);
    if ($num_rows > 1) {
        $num_rows1 = $num_rows - 1;
        for ($row = 1; $row <= $rows; $row++) {
            $tries = 0;
            $random_row = olc_rand(0, $num_rows1);
            $random_row_store = "|" . $random_row . "|";
            $include_row = true;
            while (!(strpos($random_rows, $random_row_store) === false)) {
                $tries++;
                if ($tries > 10) {
                    $include_row = false;
                    break;
                } else {
                    $random_row = olc_rand(0, $num_rows1);
                }
            }
            if ($include_row) {
                $random_rows .= $random_row_store;
                olc_db_data_seek($random_query, $random_row);
                $random_product[] = olc_db_fetch_array($random_query);
            }
        }
    } else {
        if ($num_rows > 0) {
            $random_product[] = olc_db_fetch_array($random_query);
        }
    }
    return $random_product;
}
Exemplo n.º 3
0
function olc_random_name()
{
    $letters = 'abcdefghijklmnopqrstuvwxyz';
    $dirname = '.';
    $length = floor(olc_rand(16, 20));
    for ($i = 1; $i <= $length; $i++) {
        $q = floor(olc_rand(1, 26));
        $dirname .= $letters[$q];
    }
    return $dirname;
}
function olc_random_charcode($length)
{
    $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');
    $code = '';
    for ($i = 1; $i <= $length; $i++) {
        $j = floor(olc_rand(0, $arraysize));
        $code .= $chars[$j];
    }
    return $code;
}
Exemplo n.º 5
0
 /**
  * encode()
  * 
  * Encodes and returns the email. Also stores
  * it in the encoded member variable
  *
  * @return An associative array containing two elements,
  *         body and headers. The headers element is itself
  *         an indexed array.
  * @access public
  */
 function encode()
 {
     /* HPDL PHP3 */
     //      $encoded =& $this->_encoded;
     $encoded = $this->_encoded;
     if (olc_not_null($this->_subparts)) {
         $boundary = '=_' . md5(uniqid(olc_rand()) . microtime());
         $this->_headers['Content-Type'] .= ';' . $this->lf . chr(9) . 'boundary="' . $boundary . '"';
         // Add body parts to $subparts
         for ($i = 0; $i < count($this->_subparts); $i++) {
             $headers = array();
             /* HPDL PHP3 */
             //          $tmp = $this->_subparts[$i]->encode();
             $_subparts = $this->_subparts[$i];
             $tmp = $_subparts->encode();
             reset($tmp['headers']);
             while (list($key, $value) = each($tmp['headers'])) {
                 $headers[] = $key . ': ' . $value;
             }
             $subparts[] = implode($this->lf, $headers) . $this->lf . $this->lf . $tmp['body'];
         }
         $encoded['body'] = '--' . $boundary . $this->lf . implode('--' . $boundary . $this->lf, $subparts) . '--' . $boundary . '--' . $this->lf;
     } else {
         $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . $this->lf;
     }
     // Add headers to $encoded
     /* HPDL PHP3 */
     //      $encoded['headers'] =& $this->_headers;
     $encoded['headers'] = $this->_headers;
     return $encoded;
 }
    $border = SLIDESHOW_PRODUCTS_BORDER;
    $show_controls = SLIDESHOW_PRODUCTS_CONTROLS;
} else {
    $slideshow_text = 'slideshow';
    $slideshow_dir = DIR_WS_IMAGES . $slideshow_text . SLASH;
    if (is_dir($slideshow_dir)) {
        $slideshow_file = $slideshow_dir . $slideshow_text . '.txt';
        if (is_file($slideshow_file)) {
            $slide = file($slideshow_file);
            $slides = sizeof($slide);
            if ($slides > 1) {
                while (true) {
                    $slide_select = $_SESSION[$last_slide_text];
                    while ($slide_select == $_SESSION[$last_slide_text]) {
                        //Select slide
                        $slide_select = olc_rand(1, $slides);
                    }
                    $_SESSION[$last_slide_text] = $slide_select;
                    $curren_slide = explode('|', trim($slide[$slide_select]));
                    $slideshow_file = $slideshow_dir . trim($curren_slide[0]);
                    if (is_file($slideshow_file)) {
                        break;
                    }
                }
                $width = @getimagesize($slideshow_file);
                $height = max($width[1], SLIDESHOW_IMAGES_HEIGHT);
                $width = max($width[0], SLIDESHOW_IMAGES_WIDTH);
                $border = trim($curren_slide[2]);
                if (IS_IE) {
                    $sep = NEW_LINE . NEW_LINE;
                } else {
Exemplo n.º 7
0
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(strtoupper($file), '.TTF')) {
                    $ttf[] = DIR_FS_CATALOG . '/includes/fonts/' . $file;
                }
            }
            closedir($dir);
        }
        $width = 240;
        $height = 50;
        $imgh = imagecreate($width, $height);
        $fonts = imagecolorallocate($imgh, 112, 112, 112);
        $lines = imagecolorallocate($imgh, 220, 148, 02);
        $background = imagecolorallocate($imgh, 196, 196, 196);
        imagefill($imgh, 0, 0, $background);
        $x = olc_rand(0, 20);
        $y = olc_rand(20, 40);
        for ($i = $x, $z = $y; $i < $width && $z < $width;) {
            imageLine($imgh, $i, 0, $z, $height, $lines);
            $i += $x;
            $z += $y;
        }
        $x = olc_rand(0, 20);
        $y = olc_rand(20, 40);
        for ($i = $x, $z = $y; $i < $width && $z < $width;) {
            imageLine($imgh, $z, 0, $i, $height, $lines);
            $i += $x;
            $z += $y;
        }
        $x = olc_rand(0, 10);
        $y = olc_rand(10, 20);
        for ($i = $x, $z = $y; $i < $height && $z < $height;) {
            imageLine($imgh, 0, $i, $width, $z, $lines);
            $i += $x;
            $z += $y;
        }
        $x = olc_rand(0, 10);
        $y = olc_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) olc_rand(0, count($ttf) - 1)];
            $size = olc_rand(30, 36);
            $rand = olc_rand(1, 20);
            $direction = olc_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);
    }
}
Exemplo n.º 8
0
 function process_button()
 {
     global $order, $currencies;
     //, $xtPrice;
     //error_reporting(E_ALL);
     $my_currency = $_SESSION['currency'];
     $worldpay_url = olc_session_name() . '=' . olc_session_id();
     //		$total = number_format($xtPrice->olcCalculateCurr($order->info['total']), $xtPrice->get_decimal_places($_SESSION['currency']), '.', '');
     $total = number_format($order->info['total'] - $order->info['shipping_cost'], $currencies->get_decimal_places($my_currency));
     $process_button_string = olc_draw_hidden_field('instId', MODULE_PAYMENT_WORLDPAY_ID) . olc_draw_hidden_field('currency', $_SESSION['currency']) . olc_draw_hidden_field('desc', 'Purchase from ' . STORE_NAME) . olc_draw_hidden_field('cartId', $worldpay_url) . olc_draw_hidden_field('amount', $total);
     // Pre Auth Mod 3/1/2002 - Graeme Conkie
     if (MODULE_PAYMENT_WORLDPAY_USEPREAUTH == TRUE_STRING_S) {
         $process_button_string .= olc_draw_hidden_field('authMode', MODULE_PAYMENT_WORLDPAY_PREAUTH);
     }
     // Ian-san: Create callback and language links here 6/4/2003:
     $language_code_raw = olc_db_query("select code from " . TABLE_LANGUAGES . " where languages_id ='" . $_SESSION['languages_id'] . APOS);
     $language_code_array = olc_db_fetch_array($language_code_raw);
     $language_code = $language_code_array['code'];
     $address = htmlspecialchars($order->customer['street_address'] . NEW_LINE . $order->customer['suburb'] . NEW_LINE . $order->customer['city'] . NEW_LINE . $order->customer['state'], ENT_QUOTES);
     //W. Kaiser - Enhance WP security
     include_once DIR_FS_INC . 'olc_rand.php';
     $worldpay_id = olc_rand(10000, 100000000000);
     $_SESSION['worldpay_id'] = $worldpay_id;
     $process_button_string .= olc_draw_hidden_field('testMode', MODULE_PAYMENT_WORLDPAY_MODE) . olc_draw_hidden_field('name', $order->customer['firstname'] . ' ' . $order->customer['lastname']) . olc_draw_hidden_field('address', $address) . olc_draw_hidden_field('postcode', $order->customer['postcode']) . olc_draw_hidden_field('country', $order->customer['country']['iso_code_2']) . olc_draw_hidden_field('tel', $order->customer['telephone']) . olc_draw_hidden_field('myvar', $worldpay_id) . olc_draw_hidden_field('fax', $order->customer['fax']) . olc_draw_hidden_field('email', $order->customer['email_address']) . olc_draw_hidden_field('lang', $language_code) . olc_draw_hidden_field('MC_callback', olc_href_link('wpcallback.php') . olc_draw_hidden_field('MC_OLCsid', olc_session_id()));
     //W. Kaiser - Enhance WP security
     // Ian-san: Added MD5 here 6/4/2003:
     if ('MODULE_PAYMENT_WORLDPAY_USEMD5' == '1') {
         $md5_signature_fields = 'amount:language:email';
         $md5_signature = MODULE_PAYMENT_WORLDPAY_MD5KEY . ':' . number_format($order->info['total'] * $currencies->get_value($currency), $currencies->get_decimal_places($currency), '.', '') . ':' . $language_code . ':' . $order->customer['email_address'];
         $md5_signature_md5 = md5($md5_signature);
         $process_button_string .= olc_draw_hidden_field('signatureFields', $md5_signature_fields) . olc_draw_hidden_field('signature', $md5_signature_md5);
     }
     return $process_button_string;
 }
Exemplo n.º 9
0
             if (!$lowest_id) {
                 $product_query_text = SELECT . 'min(products_id) as ' . $lowest_text . ', max(products_id) as ' . $highest_text . SQL_FROM . TABLE_PRODUCTS . SQL_WHERE . $status_cond;
                 $product_query = olc_db_query($product_query_text);
                 $product_query = olc_db_fetch_array($product_query);
                 $lowest_id = $product_query[$lowest_text];
                 $highest_id = $product_query[$highest_text];
                 $_SESSION[$lowest_text] = $lowest_id;
                 $_SESSION[$highest_text] = $highest_id;
             }
             $highest_id = $_SESSION[$highest_text];
             $total_products = olc_db_num_rows($product_query);
             $product_condition = $status_cond;
             if ($total_products > SPIDER_FOOD_ROWS) {
                 $groups = (int) ($total_products / SPIDER_FOOD_ROWS);
                 include_once DIR_FS_INC . 'olc_rand.inc.php';
                 $modulo_value = (int) olc_rand(1, $groups);
                 if ($modulo_value > 1) {
                     $product_condition .= 'MOD(pd.products_id,' . $modulo_value . ')=0 LIMIT ' . SPIDER_FOOD_ROWS;
                 }
             }
         }
     }
 }
 $product_meta_query_text = "select\n\t\t\tp.products_image,\n\t\t\tpd.products_id,\n\t\t\tpd.products_name,\n\t\t\tpd.products_meta_title,\n\t\t\tpd.products_meta_description,\n\t\t\tpd.products_meta_keywords,\n\t\t\tpd.products_description,\n\t\t\tpd.products_short_description from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id" . " where language_id = '" . SESSION_LANGUAGE_ID . APOS;
 $sep = ' - ';
 if ($product_condition) {
     $product_meta_query_text .= ' and ' . $product_condition;
 }
 $product_meta_query = olc_db_query($product_meta_query_text);
 //$num_rows = mysql_num_rows($product_meta_query);
 if (NOT_IS_AJAX_PROCESSING) {
---------------------------------------------------------------------------------------*/
//W. Kaiser - AJAX
// include needed files
require_once DIR_FS_INC . 'olc_rand.inc.php';
$products_id_main = (int) $_GET['products_id'];
if (isset($products_id_main)) {
    //W. Kaiser - Baseprice
    $sql_select = "select distinct\n\t\tp.products_fsk18,\n\t\tp.products_id,\n\t\tp.products_model,\n\t\tp.products_image,\n\t  p.products_date_added,\n\t  p.products_date_available,\n\t\tp.products_shippingtime,\n\t  p.products_uvp,\n\t  p.products_vpe,\n\t  p.products_vpe_status,\n\t  p.products_vpe_value,\n\t\tp.products_min_order_quantity,\n\t\tp.products_min_order_vpe,\n\t  p.products_baseprice_show,\n\t  p.products_baseprice_value\n\t\tfrom ";
    $sql_where = "\n\t\twhere p.products_status=1\n\t\tand p.products_price >= 0\n\t\t#group_fsk18#\n\t\t";
    unset($module_smarty);
    $products_listing_template = EMPTY_STRING;
    $smarty_config_section = "also_purchased";
    $products_listing_simple = true;
    $products_use_random_data = false;
    $heading_text = EMPTY_STRING;
    $total_also_purchased = olc_rand(5, 8);
    //Nr. of products to display
    for ($loop = 0; $loop <= 1; $loop++) {
        $loop0 = $loop == 0;
        if ($loop0) {
            $Entries = MAX_DISPLAY_ALSO_PURCHASED;
            $products_listing_sql = $sql_select . TABLE_ORDERS_PRODUCTS . " opa, " . TABLE_ORDERS_PRODUCTS . " opb, " . TABLE_ORDERS . " o, " . TABLE_PRODUCTS . " p" . $sql_where . "\n\t\t\t\tand opa.products_id = '" . $products_id_main . "'\n\t\t\t\tand opb.products_id != '" . $products_id_main . "'\n\t\t\t\tand opa.orders_id = opb.orders_id\n\t\t\t\tand opb.products_id = p.products_id\n\t\t\t\tand opb.orders_id = o.orders_id\n\t\t\t\tgroup by p.products_id order by o.date_purchased desc limit " . MAX_DISPLAY_ALSO_PURCHASED;
        } else {
            $Entries = "100000";
            $products_listing_sql = $sql_select . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c" . $sql_where . "\n\t\t\t\tand p.products_id = p2c.products_id\n\t\t\t\tand p.products_id !='" . $products_id_main . "'\n\t\t\t\tand c.categories_id = p2c.categories_id\n\t\t\t\tand c.categories_status=1 order by\n\t\t\t\tp.products_date_added asc limit " . $Entries;
        }
        //W. Kaiser - Baseprice
        include DIR_FS_INC . 'olc_prepare_products_listing_info.inc.php';
        if ($loop0) {
            $random_records = max($total_also_purchased - $my_products_listing_entries, 0);
            if ($random_records == 0) {
Exemplo n.º 11
0
function session_start()
{
    global $session, $SID, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
    // Define the global variable $SID?
    $define_sid = true;
    // Send the session cookie?
    $send_cookie = true;
    // Is track_vars enabled?
    $track_vars = isset($HTTP_COOKIE_VARS) || isset($HTTP_GET_VARS) || isset($HTTP_POST_VARS) ? 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($HTTP_COOKIE_VARS[$session->name])) {
            $session->id = $HTTP_COOKIE_VARS[$session->name];
            $define_sid = false;
            $send_cookie = false;
        }
        if (isset($HTTP_GET_VARS[$session->name])) {
            $session->id = $HTTP_GET_VARS[$session->name];
        }
        if (isset($HTTP_POST_VARS[$session->name])) {
            $session->id = $HTTP_POST_VARS[$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)) {
    eregi($session->name . '=([^/]+)', $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($GLOBALS['HTTP_REFERER']);
        if (trim($url['host']) != $GLOBALS['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 * olc_rand() / $randmax);
        if ($nrand < $session->gc_probability) {
            $mod->gc($session->gc_maxlifetime);
        }
    }
    if ($define_sid) {
        define('SID', $SID);
    } else {
        define('SID', '');
    }
    return true;
}
based on:
(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
(c) 2002-2003 osCommerce(specials.php,v 1.30 2003/02/10); www.oscommerce.com
(c) 2003	    nextcommerce (specials.php,v 1.10 2003/08/17); www.nextcommerce.org
(c) 2004      XT - Commerce; www.xt-commerce.com

Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
if (isset($_SESSION[TRACKING][PRODUCTS_HISTORY][0])) {
    olc_smarty_init($box_smarty, $cache_id);
    // include needed functions
    require_once DIR_FS_INC . 'olc_rand.inc.php';
    require_once DIR_FS_INC . 'olc_get_path.inc.php';
    require_once DIR_FS_INC . 'olc_get_products_name.inc.php';
    $max = count($_SESSION[TRACKING][PRODUCTS_HISTORY]) - 1;
    $random_last_viewed = olc_rand(0, $max);
    //fsk18 lock
    if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
        $fsk_lock = ' and p.products_fsk18!=1';
    }
    if (DO_GROUP_CHECK) {
        $group_check = " and p." . SQL_GROUP_CONDITION;
    }
    $products_id = (int) $_SESSION[TRACKING][PRODUCTS_HISTORY][$random_last_viewed];
    $random_query = SELECT . "\n\tp.products_id,\n\tpd.products_name,\n\tp.products_price,\n\tp.products_tax_class_id,\n\tp.products_image,\n\tp.products_vpe,\n\tp.products_vpe_status,\n\tp.products_vpe_value,\n\tp2c.categories_id,\n\tcd.categories_name\n\tfrom " . TABLE_PRODUCTS . " p,\t" . TABLE_PRODUCTS_DESCRIPTION . " pd," . TABLE_PRODUCTS_TO_CATEGORIES . " p2c,\t" . TABLE_CATEGORIES_DESCRIPTION . " cd\n\twhere\n\tp.products_status = 1\n\tand p.products_id = " . $products_id . "\n\tand pd.products_id = " . $products_id . "\n\tand p2c.products_id = " . $products_id . "\n\tand pd.language_id = " . SESSION_LANGUAGE_ID . "\n\tand cd.categories_id = p2c.categories_id " . $group_check . $fsk_lock . "\n\tand cd.language_id = " . SESSION_LANGUAGE_ID;
    $random_query = olc_db_query($random_query);
    $random_product = olc_db_fetch_array($random_query, true);
    if (CUSTOMER_SHOW_PRICE) {
        $random_products_price = abs($random_product['products_price']);
        $tax_class = $random_product['products_tax_class_id'];
        if (OL_COMMERCE) {