Beispiel #1
0
function modify_feature()
{
    global $mysql;
    $selected_feature = $_REQUEST['selected_feature'];
    $subaction = $_REQUEST['subaction'];
    $id = implode(',', $selected_feature);
    if (empty($id)) {
        return msg(array("type" => "error", "text" => "Не выбран ID!"));
    }
    switch ($subaction) {
        case 'mass_delete':
            $del = true;
            break;
    }
    if (isset($del)) {
        $mysql->query("delete from " . prefix . "_eshop_features where id in ({$id})");
        $mysql->query("delete from " . prefix . "_eshop_categories_features where feature_id in ({$id})");
        $mysql->query("delete from " . prefix . "_eshop_options where feature_id in ({$id})");
        msg(array("type" => "info", "info" => "Записи с ID{$id} удалены!"));
    }
    generate_features_cache(true);
}
Beispiel #2
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;
}
Beispiel #3
0
function import_yml($yml_url)
{
    global $tpl, $mysql, $twig, $parse, $SYSTEM_FLAGS;
    include_once dirname(__FILE__) . '/import.class.php';
    $file = file_get_contents($_REQUEST['yml_url']);
    $xml = new SimpleXMLElement($file);
    unset($file);
    unset($_SESSION['cats'], $_SESSION['cats_uf_ids'], $_SESSION['update'], $_SESSION['offers'], $_SESSION['IDS'], $_SESSION['j'], $_SESSION['page'], $_SESSION['work']);
    foreach ($xml->shop->offers->offer as $key => $offer) {
        $_SESSION['work'][] = (int) $offer->attributes()->id;
    }
    $ctg = new YMLCategory();
    $ctg->GetFromSite();
    $ctg->GetFromXML($xml->shop->categories->category);
    $ofs = new YMLOffer();
    foreach ($xml->shop->offers->offer as $key => $offer) {
        $oif = (int) $offer->attributes()->id;
        $name = iconv('utf-8', 'windows-1251', (string) $offer->name);
        if ($name == "") {
            $name = iconv('utf-8', 'windows-1251', trim((string) $offer->model . " " . (string) $offer->barcode));
        }
        if ($name != "") {
            $url = strtolower($parse->translit($name, 1, 1));
            $url = str_replace("/", "-", $url);
        }
        if ($url) {
            $prd_row = $mysql->record("select * from " . prefix . "_eshop_products where url = " . db_squote($url) . " limit 1");
            if (!is_array($prd_row)) {
                $oid = $ofs->Add($offer, $name, $url);
                $ofs->eco('Добавлен товар: ' . $name . '<br>');
            } else {
                $oid = $ofs->Update($prd_row['id'], $offer);
                $ofs->eco('Обновлен товар: ' . $name . '<br>');
            }
        }
    }
    generate_catz_cache(true);
    generate_features_cache(true);
}