Exemplo n.º 1
0
function eshop_infovars_show()
{
    global $CurrentHandler, $SYSTEM_FLAGS, $template, $lang, $mysql, $twig, $userROW, $ngCookieDomain;
    $SYSTEM_FLAGS["eshop"]["description_delivery"] = pluginGetVariable('eshop', 'description_delivery');
    $SYSTEM_FLAGS["eshop"]["description_order"] = pluginGetVariable('eshop', 'description_order');
    $SYSTEM_FLAGS["eshop"]["description_phones"] = pluginGetVariable('eshop', 'description_phones');
    $eshop_dir = get_plugcfg_dir('eshop');
    generate_currency_cache();
    if (file_exists($eshop_dir . '/cache_currency.php')) {
        $currency_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_currency.php'));
    } else {
        $currency_tEntry = array();
    }
    /*
        $currency_link = checkLinkAvailable('eshop', 'currency')?
                generateLink('eshop', 'currency', array()):
                generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'currency'), array());
    
        $currency_tEntry = array();
        foreach ($mysql->select("SELECT * FROM ".prefix."_eshop_currencies WHERE enabled = 1 ORDER BY position, id") as $row)
        {
            $row['currency_link'] = $currency_link."?id=".$row['id'];
            $currency_tEntry[] = $row;
        }
    */
    $SYSTEM_FLAGS["eshop"]["currency"] = $currency_tEntry;
    $current_currency = array();
    if (!isset($_COOKIE['ngCurrencyID'])) {
        $ngCurrencyID = $currency_tEntry[0]['id'];
        $current_currency = $currency_tEntry[0];
        @setcookie('ngCurrencyID', $ngCurrencyID, time() + 86400 * 365, '/', $ngCookieDomain, 0, 1);
    } else {
        $ngCurrencyID = $_COOKIE['ngCurrencyID'];
        foreach ($currency_tEntry as $cc) {
            if ($cc['id'] == $ngCurrencyID) {
                $current_currency = $cc;
            }
        }
        if (empty($current_currency)) {
            $current_currency = $currency_tEntry[0];
        }
    }
    $SYSTEM_FLAGS["eshop"]["current_currency"] = $current_currency;
    generate_catz_cache();
    if (file_exists($eshop_dir . '/cache_catz.php')) {
        $catz_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_catz.php'));
    } else {
        $catz_tEntry = array();
    }
    $SYSTEM_FLAGS["eshop"]["catz"] = $catz_tEntry;
    generate_features_cache();
    if (file_exists($eshop_dir . '/cache_features.php')) {
        $features_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_features.php'));
    } else {
        $features_tEntry = array();
    }
    $SYSTEM_FLAGS["eshop"]["features"] = $features_tEntry;
    generate_categories_features_cache();
    if (file_exists($eshop_dir . '/cache_categories_features.php')) {
        $categories_features_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_categories_features.php'));
    } else {
        $categories_features_tEntry = array();
    }
    $SYSTEM_FLAGS["eshop"]["categories_features"] = $categories_features_tEntry;
    $twig->addFunction('IsCatFeatures', new Twig_Function_Function('IsCatFeatures'));
    $filter = array();
    if (is_array($userROW)) {
        $filter[] = '(user_id = ' . db_squote($userROW['id']) . ')';
    }
    if (isset($_COOKIE['ngTrackID']) && $_COOKIE['ngTrackID'] != '') {
        $filter[] = '(cookie = ' . db_squote($_COOKIE['ngTrackID']) . ')';
    }
    $compare_link = checkLinkAvailable('eshop', 'compare') ? generateLink('eshop', 'compare', array()) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'compare'), array());
    $basket_link = checkLinkAvailable('eshop', 'ebasket_list') ? generateLink('eshop', 'ebasket_list', array()) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'ebasket_list'), array());
    if (count($filter) > 0) {
        $tCount = 0;
        $tEntries = array();
        foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_compare WHERE " . join(" or ", $filter) . "") as $row) {
            $tEntries[] = $row;
            $tCount += 1;
        }
        $compare_tVars = array('count' => $tCount, 'link' => $compare_link, 'entries' => $tEntries);
        $tCount = 0;
        $tPrice = 0;
        $tEntries = array();
        foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_ebasket WHERE " . join(" or ", $filter) . "") as $row) {
            $tEntries[] = $row;
            $tCount += 1;
            $tPrice += $row['price'] * $row['count'];
        }
        $basket_tVars = array('count' => $tCount, 'price' => $tPrice, 'entries' => $tEntries, 'basket_link' => $basket_link);
    } else {
        $compare_tVars = array('count' => 0, 'link' => $compare_link, 'entries' => array());
        $basket_tVars = array('count' => 0, 'price' => 0, 'entries' => array(), 'basket_link' => $basket_link);
    }
    $SYSTEM_FLAGS["eshop"]["compare"] = $compare_tVars;
    $SYSTEM_FLAGS["eshop"]["basket"] = $basket_tVars;
}
Exemplo n.º 2
0
function del_currency($params)
{
    global $mysql;
    $id = intval($_REQUEST['id']);
    if (empty($id)) {
        return msg(array("type" => "error", "text" => "Ошибка, вы не выбрали что хотите удалить"));
    }
    if ($id == "1") {
        return msg(array("type" => "error", "text" => "Ошибка, вы не можете уалить основную валюту"));
    }
    $mysql->query("DELETE FROM " . prefix . "_eshop_currencies WHERE id = {$id}");
    generate_currency_cache(true);
    msg(array("type" => "info", "info" => "Валюта удалена"));
}
Exemplo n.º 3
0
function update_currency()
{
    global $tpl, $mysql, $twig, $parse, $SYSTEM_FLAGS;
    $rates_array = array();
    foreach ($SYSTEM_FLAGS['eshop']['currency'] as $currency) {
        if ($currency['code'] != "USD") {
            $code = $currency['code'];
            $q = $code . "_USD";
            $q_url = "http://free.currencyconverterapi.com/api/v3/convert?q=" . $q . "&compact=ultra";
            $get_rate = (array) json_decode(file_get_contents($q_url));
            $mysql->query('UPDATE ' . prefix . '_eshop_currencies SET rate_from = ' . db_squote($get_rate[$q]) . ' WHERE code =' . db_squote($code) . ' ');
            $rates_array[$q] = $get_rate[$q];
        }
    }
    generate_currency_cache(true);
    $rates_str = "";
    foreach ($rates_array as $k => $v) {
        $rates_str .= $k . ' = ' . $v . "<br/><br/>";
    }
    return $rates_str;
}