Example #1
0
function check_server()
{
    if (!check_writeable(MAD_PATH . '/conf/')) {
        return false;
    }
    if (!check_writeable(MAD_PATH . '/data/creative/')) {
        return false;
    }
    if (!check_xml()) {
        return false;
    }
    if (!check_mbstring()) {
        return false;
    }
    return true;
}
function get_userreg_30_days()
{
    global $db;
    $xml = "userreg_30_days.xml";
    if (!check_xml($xml)) {
        $datelist = array();
        for ($i = 30; $i >= 1; $i--) {
            $day = date("m/d", strtotime("-{$i} day"));
            $datelist[$day] = 0;
        }
        $result = $db->query("SELECT * FROM " . table('members_log') . " WHERE log_type=1000 and  log_addtime>" . strtotime("-30 day"));
        while ($row = $db->fetch_array($result)) {
            $date = date("m/d", $row['log_addtime']);
            $datelist[$date]++;
        }
        write_xml($xml, $datelist);
    }
}
function fn_yml_get_rees46_yml($filename)
{
    $arr_category = array();
    $company = Registry::get('addons.my_yml.company_name');
    $location = Registry::get('config.http_location');
    $lmod = date('Y-m-d H:i');
    $modification = Registry::get('addons.rees46.modification');
    header("Content-Type: text/xml;charset=utf-8");
    /*============================================================================*/
    // Вывод заголовка файла
    $f = fopen($filename, "wb");
    fwrite($f, '<?xml version="1.0" encoding="utf-8"?>' . chr(10));
    fwrite($f, '<!DOCTYPE yml_catalog SYSTEM "shops.dtd">' . chr(10));
    fwrite($f, '<yml_catalog date="' . $lmod . '">' . chr(10));
    fwrite($f, '<shop>' . chr(10));
    /*============================================================================*/
    // Вывод данных о компании
    fwrite($f, chr(9) . '<name>' . Registry::get('settings.Company.company_name') . '</name>' . chr(10));
    fwrite($f, chr(9) . '<company>' . Registry::get('settings.Company.company_name') . '</company>' . chr(10));
    fwrite($f, chr(9) . '<url>' . $location . '</url>' . chr(10));
    /*============================================================================*/
    fwrite($f, chr(9) . '<currencies>' . chr(10));
    //        <currency id="RUR" rate="1"/>
    //        <currency id="USD" rate="CBRF"/>
    //        <currency id="EUR" rate="CBRF" plus="3"/>
    //        <currency id="UAH" rate="5.6"/>
    //        <currency id="KZT" rate="0.19"/>
    // Получаем список валют (только активных)
    $currencies = db_get_array("SELECT * FROM ?:currencies WHERE status='A'", USERGROUP_ALL);
    foreach ($currencies as $currency) {
        fwrite($f, chr(9) . chr(9) . '<currency id="' . $currency['currency_code'] . '" rate="' . $currency['coefficient'] . '"/>' . chr(10));
    }
    fwrite($f, chr(9) . '</currencies>' . chr(10));
    /*============================================================================*/
    // Загружаем дерево разделов каталога
    recursive_category(0, $f, $arr_category);
    /*============================================================================*/
    fwrite($f, chr(9) . '<offers>' . chr(10));
    /*----------------------------------------------------------------------------*/
    //        <offer id="12341" type="vendor.model" available="true" bid="13">
    //            <url>http://best.seller.ru/product_page.asp?pid=12344</url>
    //            <price>700</price>
    //            <currencyId>USD</currencyId>
    //            <categoryId> 6 </categoryId>
    //            <picture>http://best.seller.ru/img/device12345.jpg</picture>
    //            <delivery> true </delivery>
    //            <local_delivery_cost>300</local_delivery_cost>
    //            <typePrefix> Принтер </typePrefix>
    //            <vendor> НP </vendor>
    //            <vendorCode> Q7533A </vendorCode>
    //            <model> Color LaserJet 3000</model>
    //            <description>
    //                A4, 64Mb, 600x600 dpi, USB 2.0, 29стр/мин ч/б / 15стр/мин цв, лотки на 100л и 250л, плотность до 175г/м, до 60000 стр/месяц
    //            </description>
    //            <manufacturer_warranty>true</manufacturer_warranty>
    //            <country_of_origin>Япония</country_of_origin>
    //        </offer>
    $query = "SELECT DISTINCT\n                p.product_id AS id,\n                pdesc.product AS name,\n                pdesc.full_description AS descript\n\t\tFROM cscart_products AS p\n\t\t\tLEFT JOIN cscart_product_features_values AS pfval\n\t\t\tON p.product_id = pfval.product_id\n\t\t\tLEFT JOIN cscart_product_descriptions AS pdesc\n            \t\tON p.product_id=pdesc.product_id\n                        LEFT JOIN cscart_product_prices AS prices\n                        ON p.product_id = prices.product_id\n\t\tWHERE pdesc.lang_code='RU' AND p.status='A' AND p.amount > 0 AND prices.price > 0";
    $products = db_get_array($query, USERGROUP_ALL);
    foreach ($products as $product) {
        $offer = 'offer id="' . $product['id'] . '" available="true"';
        fwrite($f, chr(9) . chr(9) . '<' . $offer . '>' . chr(10));
        //        // пишем ссылку на страницу.
        fwrite($f, chr(9) . chr(9) . chr(9) . '<url>' . fn_url(htmlentities('products.view?product_id=' . $product["id"])) . '</url>' . chr(10));
        // вытаскиваем цену товара
        $query = "SELECT price FROM\n                      cscart_product_prices\n                      WHERE product_id=" . $product['id'] . " AND usergroup_id=0";
        $line1 = db_get_row($query);
        $i = intval($line1['price']);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<price>' . $i . '</price>' . chr(10));
        // здесь ставится валюта цены. в данном случае рубли
        $query = "SELECT currency_code AS currency FROM cscart_currencies WHERE is_primary='Y'";
        $line1 = db_get_row($query);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<currencyId>' . $line1['currency'] . '</currencyId>' . chr(10));
        // список категорий для маркета именовали через ID категорий, и теперь получаем
        // ID категории конкретного товара
        $query = "SELECT category_id FROM\n                    cscart_products_categories WHERE product_id=" . $product['id'] . " AND link_type='M' ORDER BY category_id";
        $result1 = db_get_array($query);
        if (count($result1) > 0) {
            $line1 = db_get_row($query);
        }
        fwrite($f, chr(9) . chr(9) . chr(9) . '<categoryId>' . $line1['category_id'] . '</categoryId>' . chr(10));
        // изображения.
        $img = fn_get_image_pairs($product["id"], "product", "M", false, true);
        fwrite($f, chr(9) . chr(9) . chr(9) . '<picture>' . $img["detailed"]["http_image_path"] . '</picture>' . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . '<delivery>true</delivery>' . chr(10));
        $query = "SELECT \n\t\tp.product_id AS id,\n                pfvdesc.variant AS vendor\n\tFROM cscart_products AS p\n                LEFT JOIN cscart_product_features_values AS pfval\n                ON pfval.product_id = p.product_id\n                LEFT JOIN cscart_product_feature_variant_descriptions AS pfvdesc\n                ON pfvdesc.variant_id = pfval.variant_id\n                LEFT JOIN cscart_product_features_descriptions AS pfdesc\n                ON pfdesc.feature_id = pfval.feature_id \n\tWHERE p.product_id =" . $product['id'] . " AND pfval.feature_id AND \n\t\t(pfdesc.description LIKE 'brand' OR \n\t\tpfdesc.description LIKE 'vendor' OR\n\t\tpfdesc.description LIKE 'бренд' OR\n\t\tpfdesc.description LIKE 'брэнд' OR\n\t\tpfdesc.description LIKE 'производитель' OR\n\t\tpfdesc.description LIKE 'торговая марка' OR\n\t\tpfdesc.description LIKE 'вендор')";
        $line = db_get_row($query);
        if (!empty($line['vendor'])) {
            $vendor = check_xml($line['vendor']);
        }
        if (!empty($vendor)) {
            fwrite($f, chr(9) . chr(9) . chr(9) . '<vendor>' . $vendor . '</vendor>' . chr(10));
        }
        // описание получаем из  короткого описания товара
        fwrite($f, chr(9) . chr(9) . chr(9) . '<name> ' . check_xml($product["name"]) . '</name>' . chr(10));
        // описание
        fwrite($f, chr(9) . chr(9) . chr(9) . '<description>' . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . check_xml(strip_tags($product["descript"])) . chr(10));
        fwrite($f, chr(9) . chr(9) . chr(9) . '</description>' . chr(10));
        if ($modification && $modification != 'none') {
            $query = "SELECT \n\t\t\t\tfd.description AS description,\n\t\t\t\tfvard.variant AS variant\n\t\t\t  FROM cscart_product_features_values AS fv\n\t\t\t  LEFT JOIN cscart_product_features_descriptions AS fd\n\t\t\t\tON fd.feature_id = fv.feature_id\n\t\t\t  LEFT JOIN cscart_product_feature_variants AS fvar\n\t\t\t\tON fvar.feature_id = fv.feature_id\n\t\t\t  LEFT JOIN cscart_product_feature_variant_descriptions AS fvard\n\t\t\t\tON fvard.variant_id = fvar.variant_id\n\t\t\tLEFT JOIN cscart_product_features AS pf\n\t\t\t\tON pf.feature_id = fv.feature_id\n\t\t\t  WHERE\n\t\t\t\tfv.product_id = " . $product['id'] . " AND\n\t\t\t\t(fd.description LIKE 'пол' OR fd.description LIKE 'gender') AND\n\t\t\t\tfv.variant_id = fvar.variant_id AND\n\t\t\t\tpf.status = 'A'";
            $line = db_get_row($query);
            $gender = '';
            if (!empty($line['variant'])) {
                $gender = $line['variant'];
                $gender = mb_substr(mb_strtolower($gender), 0, 4);
                if ($gender == 'male' || $gender == 'мужс') {
                    $gender = 'm';
                } elseif ($gender == 'fema' || $gender == 'женс') {
                    $gender = 'f';
                } else {
                    $gender = '';
                }
            }
            $query = "SELECT DISTINCT optvd.variant_name AS name\n\t\t\t\tFROM (\n\t\t\t\t\t(SELECT\topt.option_id AS option_id,\n\t\t\t\t\t\topt.product_id AS product_id,\n\t\t\t        \t\topt.status AS status\n\t\t\t\t\tFROM cscart_product_options AS opt)\n\t\t\t\t\tUNION\n\t\t\t\t\t(SELECT\topt.option_id AS option_id,\n\t\t\t\t\t\topt.product_id AS product_id,\n\t\t\t        \t\tNULL\n\t\t\t\t\tFROM cscart_product_global_option_links AS opt)\n\t\t\t\t\tORDER BY product_id\n\t\t\t        ) AS opt\n\t\t\t\tLEFT JOIN cscart_product_options_descriptions AS optd\n\t\t\t\t\tON optd.option_id = opt.option_id\n\t\t\t\tLEFT JOIN cscart_product_option_variants AS optv\n\t\t\t\t\tON optv.option_id = opt.option_id\n\t\t\t\tLEFT JOIN cscart_product_option_variants_descriptions AS optvd\n\t\t\t\t\tON optvd.variant_id = optv.variant_id\n\t\t\tWHERE\topt.product_id = " . $product['id'] . " AND\n\t\t\t\t(opt.status = 'A' OR opt.status IS NULL) AND\n\t\t\t\t(optd.option_name LIKE 'size' OR\n\t\t\t\toptd.option_name LIKE 'размер')\n\t\t\tORDER BY name";
            $sizes = db_get_array($query, USERGROUP_ALL);
            switch ($modification) {
                case 'fashion':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<fashion>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        if (!empty($sizes) && !empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<sizes>' . chr(10));
                            foreach ($sizes as $size) {
                                $size_items = mb_strtolower($size['name']);
                                $size_item = '';
                                if (!is_numeric($size_items)) {
                                    if ($size_items == 'xx small' || $size_items == 'xxs') {
                                        $size_item = 'XXS';
                                    }
                                    if ($size_items == 'x small' || $size_items == 'xs') {
                                        $size_item = 'XS';
                                    }
                                    if ($size_items == 'small' || $size_items == 's') {
                                        $size_item = 'S';
                                    }
                                    if ($size_items == 'medium' || $size_items == 'm') {
                                        $size_item = 'M';
                                    }
                                    if ($size_items == 'large' || $size_items == 'l') {
                                        $size_item = 'L';
                                    }
                                    if ($size_items == 'x large' || $size_items == 'xl') {
                                        $size_item = 'XL';
                                    }
                                    if ($size_items == 'xx large' || $size_items == 'xxl') {
                                        $size_item = 'XXL';
                                    }
                                    if ($size_items == 'xxx large' || $size_items == 'xxxl') {
                                        $size_item = 'XXXL';
                                    }
                                } else {
                                    $size_item = $size_items;
                                }
                                if (!empty($size_item)) {
                                    fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . '<size>' . $size_item . '</size>' . chr(10));
                                }
                            }
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '</sizes>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</fashion>' . chr(10));
                    }
                    break;
                case 'cosmetic':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<cosmetic>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</cosmetic>' . chr(10));
                    }
                    break;
                case 'child':
                    if (!empty($gender)) {
                        fwrite($f, chr(9) . chr(9) . chr(9) . '<child>' . chr(10));
                        if (!empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<gender>' . $gender . '</gender>' . chr(10));
                        }
                        if (!empty($sizes) && !empty($gender)) {
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '<sizes>' . chr(10));
                            foreach ($sizes as $size) {
                                $size_items = mb_strtolower($size['name']);
                                $size_item = '';
                                if (!is_numeric($size_items)) {
                                    if ($size_items == 'xx small' || $size_items == 'xxs') {
                                        $size_item = 'XXS';
                                    }
                                    if ($size_items == 'x small' || $size_items == 'xs') {
                                        $size_item = 'XS';
                                    }
                                    if ($size_items == 'small' || $size_items == 's') {
                                        $size_item = 'S';
                                    }
                                    if ($size_items == 'medium' || $size_items == 'm') {
                                        $size_item = 'M';
                                    }
                                    if ($size_items == 'large' || $size_items == 'l') {
                                        $size_item = 'L';
                                    }
                                    if ($size_items == 'x large' || $size_items == 'xl') {
                                        $size_item = 'XL';
                                    }
                                    if ($size_items == 'xx large' || $size_items == 'xxl') {
                                        $size_item = 'XXL';
                                    }
                                    if ($size_items == 'xxx large' || $size_items == 'xxxl') {
                                        $size_item = 'XXXL';
                                    }
                                } else {
                                    $size_item = $size_items;
                                }
                                if (!empty($size_item)) {
                                    fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . '<size>' . $size_item . '</size>' . chr(10));
                                }
                            }
                            fwrite($f, chr(9) . chr(9) . chr(9) . chr(9) . '</sizes>' . chr(10));
                        }
                        fwrite($f, chr(9) . chr(9) . chr(9) . '</child>' . chr(10));
                    }
                    break;
            }
        }
        fwrite($f, chr(9) . chr(9) . '</offer>' . chr(10));
    }
    /*----------------------------------------------------------------------------*/
    /*----------------------------------------------------------------------------*/
    fwrite($f, chr(9) . '</offers>' . chr(10));
    /*============================================================================*/
    fwrite($f, '</shop>' . chr(10));
    fwrite($f, '</yml_catalog>' . chr(10));
    fclose($f);
    readfile($filename);
    exit;
}
Example #4
0
                        <div class="widget-content">
                            <p>If you'd like to enable File-Based caching to speed up your mAdserve ad server, please
                                make sure that the caching directory <strong><?php 
        echo MAD_PATH;
        ?>
                                    /data/cache/</strong> is writeable. (eg. CHMOD 777)</p>
                        </div>

                    </div>
                <?php 
    }
    ?>

                <?php 
    if (!check_xml()) {
        ?>
                    <div class="widget">

                        <div class="widget-header">
                            <span class="icon-x-alt"></span>

                            <h3>Required: SimpleXML PHP Extension</h3>
                        </div>

                        <div class="widget-content">
                            <p>It seems that the SimpleXML Extension is not loaded in your PHP Installation. mAdserve
                                requires SimpleXML, and you can find instructions on how to install it <a
                                    href="http://php.net/manual/en/book.simplexml.php" target="_blank">here.</a></p>
                        </div>
                    </div>