示例#1
0
function LoadVariables()
{
    $tpath = locatePluginTemplates(array(':'), 'eshop', pluginGetVariable('eshop', 'localsource'));
    return parse_ini_file($tpath[':'] . '/variables.ini', true);
}
示例#2
0
function plugin_m_eshop_catz_tree($overrideTemplateName)
{
    global $config, $twig;
    $eshop_dir = get_plugcfg_dir('eshop');
    generate_catz_cache();
    if (file_exists($eshop_dir . '/cache_catz.php')) {
        $tVars = unserialize(file_get_contents($eshop_dir . '/cache_catz.php'));
        if ($overrideTemplateName) {
            $templateName = 'block/' . $overrideTemplateName;
        } else {
            $templateName = 'block/block_cats_tree';
        }
        $tpath = locatePluginTemplates(array($templateName), 'eshop', pluginGetVariable('eshop', 'localsource'));
        $xt = $twig->loadTemplate($tpath[$templateName] . $templateName . '.tpl');
        $output = $xt->render($tVars);
    } else {
        $output = '';
    }
    return $output;
}
示例#3
0
function options()
{
    global $tpl, $mysql, $cron, $twig;
    $tpath = locatePluginTemplates(array('config/main', 'config/general.from'), 'eshop', 1);
    $tVars = array();
    if (isset($_REQUEST['submit'])) {
        pluginSetVariable('eshop', 'count', intval($_REQUEST['count']));
        pluginSetVariable('eshop', 'count_search', secure_html($_REQUEST['count_search']));
        pluginSetVariable('eshop', 'count_stocks', secure_html($_REQUEST['count_stocks']));
        pluginSetVariable('eshop', 'views_count', $_REQUEST['views_count']);
        pluginSetVariable('eshop', 'bidirect_linked_products', $_REQUEST['bidirect_linked_products']);
        pluginSetVariable('eshop', 'approve_comments', $_REQUEST['approve_comments']);
        pluginSetVariable('eshop', 'sort_comments', $_REQUEST['sort_comments']);
        pluginSetVariable('eshop', 'integrate_gsmg', $_REQUEST['integrate_gsmg']);
        pluginSetVariable('eshop', 'max_image_size', intval($_REQUEST['max_image_size']));
        pluginSetVariable('eshop', 'width_thumb', intval($_REQUEST['width_thumb']));
        pluginSetVariable('eshop', 'width', intval($_REQUEST['width']));
        pluginSetVariable('eshop', 'height', intval($_REQUEST['height']));
        pluginSetVariable('eshop', 'ext_image', check_php_str($_REQUEST['ext_image']));
        pluginSetVariable('eshop', 'pre_width', intval($_REQUEST['pre_width']));
        pluginSetVariable('eshop', 'catz_max_image_size', intval($_REQUEST['catz_max_image_size']));
        pluginSetVariable('eshop', 'catz_width_thumb', intval($_REQUEST['catz_width_thumb']));
        pluginSetVariable('eshop', 'catz_width', intval($_REQUEST['catz_width']));
        pluginSetVariable('eshop', 'catz_height', intval($_REQUEST['catz_height']));
        pluginSetVariable('eshop', 'catz_ext_image', check_php_str($_REQUEST['catz_ext_image']));
        pluginSetVariable('eshop', 'email_notify_orders', $_REQUEST['email_notify_orders']);
        pluginSetVariable('eshop', 'email_notify_comments', $_REQUEST['email_notify_comments']);
        pluginSetVariable('eshop', 'email_notify_back', $_REQUEST['email_notify_back']);
        pluginSetVariable('eshop', 'description_delivery', $_REQUEST['description_delivery']);
        pluginSetVariable('eshop', 'description_order', $_REQUEST['description_order']);
        pluginSetVariable('eshop', 'description_phones', $_REQUEST['description_phones']);
        pluginsSaveConfig();
        redirect_eshop('?mod=extra-config&plugin=eshop&action=options');
    }
    $views_cnt = intval(pluginGetVariable('eshop', 'views_count'));
    if ($views_cnt == 2) {
        $cron_row = $cron->getConfig();
        foreach ($cron_row as $key => $value) {
            if ($value['plugin'] == 'eshop' && $value['handler'] == 'eshop_views') {
                $cron_min = $value['min'];
                $cron_hour = $value['hour'];
                $cron_day = $value['day'];
                $cron_month = $value['month'];
            }
        }
        if (!isset($cron_min)) {
            $cron_min = '0,15,30,45';
        }
        if (!isset($cron_hour)) {
            $cron_hour = '*';
        }
        if (!isset($cron_day)) {
            $cron_day = '*';
        }
        if (!isset($cron_month)) {
            $cron_month = '*';
        }
        $cron->unregisterTask('eshop', 'eshop_views');
        $cron->registerTask('eshop', 'eshop_views', $cron_min, $cron_hour, $cron_day, $cron_month, '*');
    } else {
        $cron->unregisterTask('eshop', 'eshop_views');
    }
    $count = pluginGetVariable('eshop', 'count');
    $count_search = pluginGetVariable('eshop', 'count_search');
    $count_stocks = pluginGetVariable('eshop', 'count_stocks');
    $views_count = pluginGetVariable('eshop', 'views_count');
    $views_count = '<option value="0" ' . ($views_count == 0 ? 'selected' : '') . '>Нет</option><option value="1" ' . ($views_count == 1 ? 'selected' : '') . '>Да</option><option value="2" ' . ($views_count == 2 ? 'selected' : '') . '>Отложенное</option>';
    $bidirect_linked_products = pluginGetVariable('eshop', 'bidirect_linked_products');
    $bidirect_linked_products = '<option value="0" ' . ($bidirect_linked_products == 0 ? 'selected' : '') . '>Нет</option><option value="1" ' . ($bidirect_linked_products == 1 ? 'selected' : '') . '>Да</option>';
    $approve_comments = pluginGetVariable('eshop', 'approve_comments');
    $approve_comments = '<option value="0" ' . ($approve_comments == 0 ? 'selected' : '') . '>Нет</option><option value="1" ' . ($approve_comments == 1 ? 'selected' : '') . '>Да</option>';
    $sort_comments = pluginGetVariable('eshop', 'sort_comments');
    $sort_comments = '<option value="0" ' . ($sort_comments == 0 ? 'selected' : '') . '>Новые снизу</option><option value="1" ' . ($sort_comments == 1 ? 'selected' : '') . '>Новые сверху</option>';
    $integrate_gsmg = pluginGetVariable('eshop', 'integrate_gsmg');
    $integrate_gsmg = '<option value="0" ' . ($integrate_gsmg == 0 ? 'selected' : '') . '>Нет</option><option value="1" ' . ($integrate_gsmg == 1 ? 'selected' : '') . '>Да</option>';
    $max_image_size = pluginGetVariable('eshop', 'max_image_size');
    $width_thumb = pluginGetVariable('eshop', 'width_thumb');
    $width = pluginGetVariable('eshop', 'width');
    $height = pluginGetVariable('eshop', 'height');
    $ext_image = pluginGetVariable('eshop', 'ext_image');
    $pre_width = pluginGetVariable('eshop', 'pre_width');
    $catz_max_image_size = pluginGetVariable('eshop', 'catz_max_image_size');
    $catz_width_thumb = pluginGetVariable('eshop', 'catz_width_thumb');
    $catz_width = pluginGetVariable('eshop', 'catz_width');
    $catz_height = pluginGetVariable('eshop', 'catz_height');
    $catz_ext_image = pluginGetVariable('eshop', 'catz_ext_image');
    $email_notify_orders = pluginGetVariable('eshop', 'email_notify_orders');
    $email_notify_comments = pluginGetVariable('eshop', 'email_notify_comments');
    $email_notify_back = pluginGetVariable('eshop', 'email_notify_back');
    $description_delivery = pluginGetVariable('eshop', 'description_delivery');
    $description_order = pluginGetVariable('eshop', 'description_order');
    $description_phones = pluginGetVariable('eshop', 'description_phones');
    $tEntry = array('count' => $count, 'count_search' => $count_search, 'count_stocks' => $count_stocks, 'views_count' => $views_count, 'bidirect_linked_products' => $bidirect_linked_products, 'approve_comments' => $approve_comments, 'sort_comments' => $sort_comments, 'integrate_gsmg' => $integrate_gsmg, 'max_image_size' => $max_image_size, 'width_thumb' => $width_thumb, 'width' => $width, 'height' => $height, 'ext_image' => $ext_image, 'pre_width' => $pre_width, 'catz_max_image_size' => $catz_max_image_size, 'catz_width_thumb' => $catz_width_thumb, 'catz_width' => $catz_width, 'catz_height' => $catz_height, 'catz_ext_image' => $catz_ext_image, 'email_notify_orders' => $email_notify_orders, 'email_notify_comments' => $email_notify_comments, 'email_notify_back' => $email_notify_back, 'description_delivery' => $description_delivery, 'description_order' => $description_order, 'description_phones' => $description_phones);
    $xt = $twig->loadTemplate($tpath['config/general.from'] . 'config/' . 'general.from.tpl');
    $tVars = array('entries' => isset($tEntry) ? $tEntry : '');
    $xg = $twig->loadTemplate($tpath['config/main'] . 'config/' . 'main.tpl');
    $tVars = array('entries' => $xt->render($tVars), 'php_self' => $PHP_SELF, 'plugin_url' => admin_url . '/admin.php?mod=extra-config&plugin=eshop', 'skins_url' => skins_url, 'admin_url' => admin_url, 'home' => home, 'current_title' => 'Настройки');
    print $xg->render($tVars);
}
         $src = imagecreatefromgif($tempFile);
     }
 }
 list($width, $height) = getimagesize($tempFile);
 $newwidth = pluginGetVariable('eshop', 'width_thumb');
 $newheight = $height / $width * $newwidth;
 $tmp = imagecreatetruecolor($newwidth, $newheight);
 imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
 $thumbname = $targetThumb;
 if (file_exists($thumbname)) {
     unlink($thumbname);
 }
 imagejpeg($tmp, $thumbname, $pre_quality >= 10 && $pre_quality <= 100 ? $pre_quality : 100);
 imagedestroy($src);
 imagedestroy($tmp);
 $newwidth = pluginGetVariable('eshop', 'pre_width');
 if (isset($newwidth) && $newwidth != '0') {
     if ($extension == "jpg" || $extension == "jpeg") {
         $src = imagecreatefromjpeg($tempFile);
     } else {
         if ($extension == "png") {
             $src = imagecreatefrompng($tempFile);
         } else {
             $src = imagecreatefromgif($tempFile);
         }
     }
     list($width, $height) = getimagesize($tempFile);
     $newheight = $height / $width * $newwidth;
     $tmp = imagecreatetruecolor($newwidth, $newheight);
     imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
     $thumbname = $targetFile;
示例#5
0
 function onShow(&$output)
 {
     global $userROW, $mysql, $twig;
     if (pluginGetVariable('eshop', 'integrate_gsmg') == "1") {
         $lm = $mysql->record("select date(from_unixtime(max(date))) as pd from " . prefix . "_eshop_products");
         foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_categories ORDER BY position, id") as $rows) {
             $cat_link = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $rows['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $rows['url']));
             $new_output .= "<url>";
             $new_output .= "<loc>" . home . $cat_link . "</loc>";
             $new_output .= "<priority>" . floatval(pluginGetVariable('gsmg', 'catp_pr')) . "</priority>";
             $new_output .= "<lastmod>" . $lm['pd'] . "</lastmod>";
             $new_output .= "<changefreq>daily</changefreq>";
             $new_output .= "</url>";
         }
         $query = "select * from " . prefix . "_eshop_products where active = 1 order by id desc";
         foreach ($mysql->select($query) as $rec) {
             $link = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $rec['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $rec['url']));
             $new_output .= "<url>";
             $new_output .= "<loc>" . home . $link . "</loc>";
             $new_output .= "<priority>" . floatval(pluginGetVariable('gsmg', 'news_pr')) . "</priority>";
             $new_output .= "<lastmod>" . strftime("%Y-%m-%d", max($rec['editdate'], $rec['date'])) . "</lastmod>";
             $new_output .= "<changefreq>daily</changefreq>";
             $new_output .= "</url>";
         }
         $output = $output . $new_output;
     }
 }
示例#6
0
function breadcrumbs()
{
    global $lang, $catz, $catmap, $template, $CurrentHandler, $config, $SYSTEM_FLAGS, $tpl, $systemAccessURL, $twig;
    $tpath = locatePluginTemplates(array('breadcrumbs'), 'breadcrumbs', pluginGetVariable('breadcrumbs', 'template_source'));
    $location = array();
    $location_last = '';
    # processing 404 page
    if ($SYSTEM_FLAGS['info']['title']['group'] == $lang['404.title']) {
        $link = str_replace(array('{home_url}', '{home_title}'), array($config['home_url'], $lang['bc:mainpage']), $lang['bc:page_404']);
        $location[] = array('url' => $config['home_url'], 'title' => $lang['bc:mainpage'], 'link' => $link);
        $location_last = $lang['404.title'];
    } else {
        if ($CurrentHandler) {
            $params = $CurrentHandler['params'];
            $pluginName = $CurrentHandler['pluginName'];
        }
        # generate main page with or without link
        $main_page = $systemAccessURL != '/' ? str_replace(array('{home_url}', '{home_title}'), array($config['home_url'], $lang['bc:mainpage']), $lang['bc:page_404']) : $lang['bc:mainpage'];
        $location[] = array('url' => $systemAccessURL != '/' ? $config['home_url'] : '', 'title' => $systemAccessURL != '/' ? $lang['bc:mainpage'] : $lang['bc:mainpage'], 'link' => $main_page);
        $location_last = $main_page;
        # if category
        if ($CurrentHandler['handlerName'] == 'by.category') {
            $location_last = GetCategories($catz[$params['category']]['id'], true);
            # show full path [if requested]
            if ($catz[$params['category']]['parent'] != 0 && !pluginGetVariable('breadcrumbs', 'block_full_path')) {
                $id = $catz[$params['category']]['parent'];
                do {
                    $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $catz[$params['category']]['alt'], 'catid' => $catz[$params['category']]['id'])), 'title' => $catz[$params['category']]['name'], 'link' => GetCategories($id, false));
                    $id = $catz[$catmap[$id]]['parent'];
                } while ($id != 0);
                $location = array_merge($location, array_reverse($location_tmp));
            }
        } elseif ($params['year']) {
            # if we have only year then $year = plain text, if we have month then $year = link
            $year = !$params['month'] ? $params['year'] : str_replace(array('{year_url}', '{year}'), array(generateLink('news', 'by.year', array('year' => $params['year'])), $params['year']), $lang['bc:by.year']);
            $month_p = LangDate("F", mktime(0, 0, 0, $params['month'], 7, 0));
            # if we have only year and month then $month = plain text, if we have day then $month = link
            $month = !$params['day'] ? $month_p : str_replace(array('{month_url}', '{month_p}'), array(generateLink('news', 'by.month', array('year' => $params['year'], 'month' => $params['month'])), $month_p), $lang['bc:by.month']);
            $day = $params['day'];
            $location_last = $year;
            if ($params['month']) {
                $location[] = array('url' => !$params['month'] ? '' : generateLink('news', 'by.year', array('year' => $params['year'])), 'title' => !$params['month'] ? $params['year'] : $params['year'], 'link' => $year);
                $location_last = $month;
            }
            if ($params['day']) {
                $location[] = array('url' => !$params['day'] ? '' : generateLink('news', 'by.month', array('year' => $params['year'], 'month' => $params['month'])), 'title' => !$params['day'] ? $month_p : $month_p, 'link' => $month);
                $location_last = $day;
            }
            # plugin, static, etc.
        } elseif ($pluginName != 'news') {
            if ($pluginName == "static") {
                $location_last = $SYSTEM_FLAGS['info']['title']['item'];
            } elseif ($pluginName == 'uprofile' && $CurrentHandler['handlerName'] == 'edit' || $pluginName == 'search') {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'];
            } elseif ($pluginName == 'uprofile' && $CurrentHandler['handlerName'] == 'show') {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'] . ' ' . $SYSTEM_FLAGS['info']['title']['item'];
            } elseif ($pluginName == 'core' && in_array($CurrentHandler['handlerName'], array('registration', 'lostpassword', 'login'))) {
                $location_last = $SYSTEM_FLAGS['info']['title']['group'];
            } elseif ($params['plugin'] || $pluginName) {
                # if plugin provide put some info
                if ($SYSTEM_FLAGS['info']['breadcrumbs']) {
                    # plugin name becomes link
                    $count = count($SYSTEM_FLAGS['info']['breadcrumbs']) - 1;
                    # all items except last become links
                    for ($i = 0; $i < $count; $i++) {
                        $link = str_replace(array('{plugin_url}', '{plugin}'), array($SYSTEM_FLAGS['info']['breadcrumbs'][$i]['link'], $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text']), $lang['bc:plugin']);
                        $location[] = array('url' => $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['link'], 'title' => $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text'], 'link' => $link);
                    }
                    # last item becomes plain text
                    $location_last = $SYSTEM_FLAGS['info']['breadcrumbs'][$i]['text'];
                } else {
                    $link = str_replace(array('{plugin_url}', '{plugin}'), array(generatePluginLink($params['plugin'], '', array(), array(), false, true), $SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin'] ? $SYSTEM_FLAGS['info']['title']['group'] : $params['plugin']), $lang['bc:plugin']);
                    $location[] = array('url' => generatePluginLink($params['plugin'], '', array(), array(), false, true), 'title' => $SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin'] ? $SYSTEM_FLAGS['info']['title']['group'] : $params['plugin'], 'link' => $link);
                    if ($SYSTEM_FLAGS['info']['title']['group'] != $lang['loc_plugin']) {
                        $location_last = $SYSTEM_FLAGS['info']['title']['group'];
                    } else {
                        $location_last = $params['plugin'];
                    }
                }
            }
            # full news
        } elseif ($CurrentHandler['pluginName'] == 'news' && $CurrentHandler['handlerName'] == 'news') {
            $catids = $SYSTEM_FLAGS['news']['db.categories'];
            $location_last = $SYSTEM_FLAGS['info']['title']['item'];
            if (count($catids) != 1 || pluginGetVariable('breadcrumbs', 'block_full_path')) {
                if ($CurrentHandler['params']['category'] != 'none') {
                    foreach ($catids as $cid) {
                        foreach ($catz as $cc) {
                            if ($cc['id'] == $cid) {
                                $location[] = array('url' => generateLink('news', 'by.category', array('category' => $cc['alt'], 'catid' => $cc['id'])), 'title' => $cc['name'], 'link' => GetCategories($cc['id'], false));
                            }
                        }
                    }
                }
            } else {
                $id = $catz[$params['category']]['parent'];
                $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $catz[$params['category']]['alt'], 'catid' => $catz[$params['category']]['id'])), 'title' => $catz[$params['category']]['name'], 'link' => GetCategories($catz[$params['category']]['id'], false));
                while ($id != 0) {
                    foreach ($catz as $cc) {
                        if ($cc['id'] == $id) {
                            $location_tmp[] = array('url' => generateLink('news', 'by.category', array('category' => $cc['alt'], 'catid' => $cc['id'])), 'title' => $cc['name'], 'link' => GetCategories($cc['id'], false));
                            $id = $catz[$cc['alt']]['parent'];
                        }
                    }
                }
                $location = array_merge($location, array_reverse($location_tmp));
            }
        }
    }
    $tVars = array('location' => $location, 'location_last' => $location_last, 'separator' => $separator);
    $xt = $twig->loadTemplate($tpath['breadcrumbs'] . 'breadcrumbs.tpl');
    $template['vars']['breadcrumbs'] = $xt->render($tVars);
}
示例#7
0
<?php

/*
 * Configuration file for plugin "Breadcrumbs" for Next Generation CMS 0.9.3
 * Copyright (C) 2010-2011 Alexey N. Zhukov (http://digitalplace.ru)
 * web:    http://digitalplace.ru
 * e-mail: zhukov.alexei@gmail.com
 */
pluginsLoadConfig();
LoadPluginLang('breadcrumbs', 'config', '', 'bc', ':');
$cfg = array();
array_push($cfg, array('descr' => $lang['bc:description']));
array_push($cfg, array('name' => 'block_full_path', 'title' => $lang['bc:block_full_path'], 'type' => 'select', 'values' => array(1 => $lang['yesa'], 0 => $lang['noa']), 'value' => pluginGetVariable($plugin, 'block_full_path')));
$cfgX = array();
array_push($cfgX, array('name' => 'template_source', 'title' => $lang['bc:template_source_title'], 'type' => 'select', 'values' => array('0' => $lang['bc:template_source_site'], '1' => $lang['bc:template_source_plugin']), 'value' => intval(pluginGetVariable($plugin, 'template_source'))));
array_push($cfg, array('mode' => 'group', 'title' => $lang['bc:template_source'], 'entries' => $cfgX));
if ($_REQUEST['action'] == 'commit') {
    commit_plugin_config_changes($plugin, $cfg);
    print_commit_complete($plugin);
} else {
    generate_config_page($plugin, $cfg);
}
示例#8
0
 /**
  * Добавляем элемент
  * @param $offer
  * @return bool
  */
 function Add($offer, $name, $url)
 {
     global $tpl, $mysql, $twig, $parse, $SYSTEM_FLAGS, $config;
     $description = iconv('utf-8', 'windows-1251', (string) $offer->description);
     $PROP = array();
     $PROP['id'] = (int) $offer->attributes()->id;
     $PROP['name'] = $name;
     $PROP['url'] = $url;
     $PROP['meta_title'] = $name;
     $PROP['annotation'] = str_replace('&nbsp;', ' ', $description);
     $PROP['date'] = time() + $config['date_adjust'] * 60;
     $PROP['editdate'] = $PROP['date'];
     $vnames = array();
     foreach ($PROP as $k => $v) {
         $vnames[] = $k . ' = ' . db_squote($v);
     }
     $result = $mysql->query('INSERT INTO ' . prefix . '_eshop_products SET ' . implode(', ', $vnames) . ' ');
     if ($result) {
         $qid = $mysql->lastid('eshop_products');
         if (count($offer->picture) > 0) {
             $pictures = $this->xml2array($offer->picture);
             $inx_img = 0;
             foreach ($pictures as $picture) {
                 try {
                     $rootpath = $_SERVER['DOCUMENT_ROOT'];
                     $url = substr($picture, 0, strpos($picture, '?') ? strpos($picture, '?') : strlen($picture));
                     $name = basename($url);
                     $file_path = $rootpath . "/uploads/eshop/products/temp/{$name}";
                     file_put_contents($file_path, file_get_contents($url));
                     $fileParts = pathinfo($file_path);
                     $extension = $fileParts['extension'];
                     $extensions = array_map('trim', explode(',', pluginGetVariable('eshop', 'ext_image')));
                     $pre_quality = pluginGetVariable('eshop', 'pre_quality');
                     if (!in_array($extension, $extensions)) {
                         return "0";
                     }
                     // CREATE THUMBNAIL
                     if ($extension == "jpg" || $extension == "jpeg") {
                         $src = imagecreatefromjpeg($file_path);
                     } else {
                         if ($extension == "png") {
                             $src = imagecreatefrompng($file_path);
                         } else {
                             $src = imagecreatefromgif($file_path);
                         }
                     }
                     list($width, $height) = getimagesize($file_path);
                     $newwidth = pluginGetVariable('eshop', 'width_thumb');
                     if ($width > $newwidth) {
                         $newheight = $height / $width * $newwidth;
                         $tmp = imagecreatetruecolor($newwidth, $newheight);
                         imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
                         $thumbname = $rootpath . "/uploads/eshop/products/temp/thumb/{$name}";
                         if (file_exists($thumbname)) {
                             unlink($thumbname);
                         }
                         imagejpeg($tmp, $thumbname, $pre_quality >= 10 && $pre_quality <= 100 ? $pre_quality : 100);
                         imagedestroy($src);
                         imagedestroy($tmp);
                     } else {
                         if ($extension == "jpg" || $extension == "jpeg") {
                             $src = imagecreatefromjpeg($file_path);
                         } else {
                             if ($extension == "png") {
                                 $src = imagecreatefrompng($file_path);
                             } else {
                                 $src = imagecreatefromgif($file_path);
                             }
                         }
                         imagejpeg($src, $file_path, $pre_quality >= 10 && $pre_quality <= 100 ? $pre_quality : 100);
                         $thumbname = $rootpath . "/uploads/eshop/products/temp/thumb/{$name}";
                         copy($file_path, $thumbname);
                         imagedestroy($src);
                     }
                     $newwidth = pluginGetVariable('eshop', 'pre_width');
                     if (isset($newwidth) && $newwidth != '0') {
                         if ($extension == "jpg" || $extension == "jpeg") {
                             $src = imagecreatefromjpeg($file_path);
                         } else {
                             if ($extension == "png") {
                                 $src = imagecreatefrompng($file_path);
                             } else {
                                 $src = imagecreatefromgif($file_path);
                             }
                         }
                         list($width, $height) = getimagesize($file_path);
                         $newheight = $height / $width * $newwidth;
                         $tmp = imagecreatetruecolor($newwidth, $newheight);
                         imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
                         $thumbname = $file_path;
                         imagejpeg($tmp, $thumbname, $pre_quality >= 10 && $pre_quality <= 100 ? $pre_quality : 100);
                         imagedestroy($src);
                         imagedestroy($tmp);
                     }
                     $img = $name;
                     $timestamp = time();
                     $iname = $timestamp . "-" . $img;
                     @mkdir($_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/' . $qid . '/', 0777);
                     @mkdir($_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/' . $qid . '/thumb', 0777);
                     $temp_name = $_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/temp/' . $img;
                     $current_name = $_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/' . $qid . '/' . $iname;
                     rename($temp_name, $current_name);
                     $temp_name = $_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/temp/thumb/' . $img;
                     $current_name = $_SERVER['DOCUMENT_ROOT'] . '/uploads/eshop/products/' . $qid . '/thumb/' . $iname;
                     rename($temp_name, $current_name);
                     $mysql->query("INSERT INTO " . prefix . "_eshop_images (`filepath`, `product_id`, `position`) VALUES ('{$iname}','{$qid}','{$inx_img}')");
                     $inx_img += 1;
                 } catch (Exception $ex) {
                     $this->eco('Ошибка: ' . $ex . '<br>');
                     return "0";
                 }
             }
         }
         $category_id = (int) $offer->categoryId;
         if ($category_id != 0) {
             $mysql->query("INSERT INTO " . prefix . "_eshop_products_categories (`product_id`, `category_id`) VALUES ('{$qid}','{$category_id}')");
         }
         $price = (string) $offer->price;
         $currencyId = (string) $offer->currencyId;
         $stock = "5";
         if (isset($price)) {
             foreach ($SYSTEM_FLAGS['eshop']['currency'] as $currency) {
                 if ($currencyId == "RUR") {
                     $currencyId = "RUB";
                 }
                 if ($currency['code'] == $currencyId) {
                     $price = $price / $SYSTEM_FLAGS['eshop']['currency'][0]['rate_from'] * $currency['rate_from'];
                 }
             }
             $mysql->query("DELETE FROM " . prefix . "_eshop_variants WHERE product_id='{$qid}'");
             $mysql->query("INSERT INTO " . prefix . "_eshop_variants (`product_id`, `price`, `stock`) VALUES ('{$qid}', '{$price}', '{$stock}')");
         }
         $returnArr = array();
         $returnArr[] = array_merge(['value' => $PROP['id']], array('name' => 'source_id'));
         foreach ($offer->children() as $element) {
             if (mb_strtolower($element->getName()) == 'param') {
                 $returnArr[] = array_merge(['value' => (string) $element], $this->getElementAttributes($element));
             }
             if (mb_strtolower($element->getName()) == 'url') {
                 $returnArr[] = array_merge(['value' => (string) $element], array('name' => 'source_url'));
             }
         }
         foreach ($returnArr as $el) {
             $f_name = iconv('utf-8', 'windows-1251', $el['name']);
             $feature_row = $mysql->record("select * from " . prefix . "_eshop_features where name = " . db_squote($f_name) . " limit 1");
             if (!is_array($feature_row)) {
                 $mysql->query('INSERT INTO ' . prefix . '_eshop_features (name) VALUES (' . db_squote($f_name) . ')');
                 $rowID = $mysql->lastid('eshop_features');
                 $f_key = $rowID;
             } else {
                 $f_key = $feature_row['id'];
             }
             $f_value = iconv('utf-8', 'windows-1251', $el['value']);
             if ($f_value != "") {
                 $mysql->query("INSERT INTO " . prefix . "_eshop_options (`product_id`, `feature_id`, `value`) VALUES ('{$qid}','{$f_key}','{$f_value}')");
             }
         }
     }
 }
示例#9
0
function social_config()
{
    global $tpl, $mysql, $lang, $twig;
    $tpath = locatePluginTemplates(array('config/main', 'config/social'), 'guestbook', 1);
    if (isset($_REQUEST['submit'])) {
        pluginSetVariable('guestbook', 'vk_client_id', secure_html($_REQUEST['vk_client_id']));
        pluginSetVariable('guestbook', 'vk_client_secret', secure_html($_REQUEST['vk_client_secret']));
        pluginSetVariable('guestbook', 'facebook_client_id', secure_html($_REQUEST['facebook_client_id']));
        pluginSetVariable('guestbook', 'facebook_client_secret', secure_html($_REQUEST['facebook_client_secret']));
        pluginSetVariable('guestbook', 'google_client_id', secure_html($_REQUEST['google_client_id']));
        pluginSetVariable('guestbook', 'google_client_secret', secure_html($_REQUEST['google_client_secret']));
        pluginSetVariable('guestbook', 'instagram_client_id', secure_html($_REQUEST['instagram_client_id']));
        pluginSetVariable('guestbook', 'instagram_client_secret', secure_html($_REQUEST['instagram_client_secret']));
        pluginsSaveConfig();
        msg(array("text" => $lang['gbconfig']['msgo_settings_saved']));
    }
    $vk_client_id = pluginGetVariable('guestbook', 'vk_client_id');
    $vk_client_secret = pluginGetVariable('guestbook', 'vk_client_secret');
    $facebook_client_id = pluginGetVariable('guestbook', 'facebook_client_id');
    $facebook_client_secret = pluginGetVariable('guestbook', 'facebook_client_secret');
    $google_client_id = pluginGetVariable('guestbook', 'google_client_id');
    $google_client_secret = pluginGetVariable('guestbook', 'google_client_secret');
    $instagram_client_id = pluginGetVariable('guestbook', 'instagram_client_id');
    $instagram_client_secret = pluginGetVariable('guestbook', 'instagram_client_secret');
    $xt = $twig->loadTemplate($tpath['config/social'] . 'config/social.tpl');
    $tVars = array('skins_url' => skins_url, 'home' => home, 'tpl_home' => admin_url, 'vk_client_id' => $vk_client_id, 'vk_client_secret' => $vk_client_secret, 'facebook_client_id' => $facebook_client_id, 'facebook_client_secret' => $facebook_client_secret, 'google_client_id' => $google_client_id, 'google_client_secret' => $google_client_secret, 'instagram_client_id' => $instagram_client_id, 'instagram_client_secret' => $instagram_client_secret);
    $xg = $twig->loadTemplate($tpath['config/main'] . 'config/main.tpl');
    $tVars = array('entries' => $xt->render($tVars));
    print $xg->render($tVars);
}
示例#10
0
function main_prd($params)
{
    global $tpl, $template, $twig, $SYSTEM_FLAGS, $config, $userROW, $mysql, $twigLoader;
    $results = array();
    $params = arrayCharsetConvert(1, $params);
    $number = $params['number'];
    $mode = $params['mode'];
    $cat = $params['cat'];
    $overrideTemplateName = $params['template'];
    $prd_per_page = $number;
    $page = $params['page'];
    switch ($params['action']) {
        // **** ADD NEW ITEM INTO compare ****
        case 'show':
            $conditions = array();
            if (isset($cat) && !empty($cat)) {
                array_push($conditions, "c.id IN (" . $cat . ") ");
            }
            array_push($conditions, "p.active = 1");
            if ($number < 1 || $number > 100) {
                $number = 5;
            }
            switch ($mode) {
                case 'view':
                    $orderby = " ORDER BY p.view DESC ";
                    break;
                case 'last':
                    $orderby = " ORDER BY p.editdate DESC ";
                    break;
                case 'stocked':
                    array_push($conditions, "p.stocked = 1");
                    $orderby = " ORDER BY p.editdate DESC ";
                    break;
                case 'featured':
                    array_push($conditions, "p.featured = 1");
                    $orderby = " ORDER BY p.editdate DESC ";
                    break;
                case 'rnd':
                    $cacheDisabled = true;
                    $orderby = " ORDER BY RAND() DESC ";
                    break;
                default:
                    $mode = 'last';
                    $orderby = " ORDER BY p.editdate DESC ";
                    break;
            }
            $fSort = " " . $orderby;
            $sqlQPart = "FROM " . prefix . "_eshop_products p LEFT JOIN " . prefix . "_eshop_products_categories pc ON p.id = pc.product_id LEFT JOIN " . prefix . "_eshop_categories c ON pc.category_id = c.id " . (count($conditions) ? "WHERE " . implode(" AND ", $conditions) : '') . $fSort;
            $sqlQCount = "SELECT COUNT(p.id) " . $sqlQPart;
            $sqlQ = "SELECT p.id AS id, p.url as url, p.code AS code, p.name AS name, p.annotation AS annotation, p.body AS body, p.active AS active, p.featured AS featured, p.stocked AS stocked, p.position AS position, p.meta_title AS meta_title, p.meta_keywords AS meta_keywords, p.meta_description AS meta_description, p.date AS date, p.editdate AS editdate, p.views AS views, c.id AS cid, c.url as curl, c.name AS category " . $sqlQPart;
            $entries = array();
            $pageNo = intval($page) ? $page : 0;
            if ($pageNo < 1) {
                $pageNo = 1;
            }
            if (!$start_from) {
                $start_from = ($pageNo - 1) * $prd_per_page;
            }
            $count = $mysql->result($sqlQCount);
            $countPages = ceil($count / $prd_per_page);
            $cmp_array = array();
            foreach ($SYSTEM_FLAGS["eshop"]["compare"]["entries"] as $cmp_row) {
                $cmp_array[] = $cmp_row['linked_fld'];
            }
            foreach ($mysql->select($sqlQ . ' LIMIT ' . $start_from . ', ' . $prd_per_page) as $row) {
                $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url']));
                $catlink = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $row['curl'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $row['curl']));
                $cmp_flag = in_array($row['id'], $cmp_array);
                $entries[$row['id']] = array('id' => $row['id'], 'code' => $row['code'], 'name' => $row['name'], 'annotation' => $row['annotation'], 'body' => $row['body'], 'active' => $row['active'], 'featured' => $row['featured'], 'meta_title' => $row['meta_title'], 'meta_keywords' => $row['meta_keywords'], 'meta_description' => $row['meta_description'], 'fulllink' => $fulllink, 'date' => empty($row['date']) ? '' : $row['date'], 'editdate' => empty($row['editdate']) ? '' : $row['editdate'], 'views' => $row['views'], 'cat_name' => $row['category'], 'cid' => $row['cid'], 'catlink' => $catlink, 'compare' => $cmp_flag, 'home' => home, 'tpl_url' => home . '/templates/' . $config['theme']);
            }
            $entries_array_ids = array_keys($entries);
            if (isset($entries_array_ids) && !empty($entries_array_ids)) {
                $entries_string_ids = implode(',', $entries_array_ids);
                foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_images i WHERE i.product_id IN (' . $entries_string_ids . ') ORDER BY i.position, i.id') as $irow) {
                    $entries[$irow['product_id']]['images'][] = $irow;
                }
                foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_variants v WHERE v.product_id IN (' . $entries_string_ids . ') ORDER BY v.position, v.id') as $vrow) {
                    $entries[$vrow['product_id']]['variants'][] = $vrow;
                }
            }
            $tVars = array('info' => isset($info) ? $info : '', 'entries' => isset($entries) ? $entries : '', 'tpl_url' => home . '/templates/' . $config['theme'], 'tpl_home' => admin_url);
            if ($overrideTemplateName) {
                $templateName = 'block/' . $overrideTemplateName;
            } else {
                $templateName = 'block/main_block_eshop';
            }
            // Determine paths for all template files
            $tpath = locatePluginTemplates(array($templateName), 'eshop', pluginGetVariable('eshop', 'localsource'));
            // Preload template configuration variables
            @templateLoadVariables();
            $tVars['mode'] = $mode;
            $tVars['number'] = $number;
            $tVars['tpl_url'] = tpl_url;
            $tVars['home'] = home;
            $tVars['pagesss'] = generateLP(array('current' => $pageNo, 'count' => $countPages, 'url' => '#', 'tpl' => $templateName . '_pages'));
            $xt = $twig->loadTemplate($tpath[$templateName] . $templateName . '.tpl');
            if (empty($row)) {
                $results = array('prd_main' => 2, 'prd_main_text' => iconv('Windows-1251', 'UTF-8', 'Нет продукции!'), 'prd_main_pages_text' => iconv('Windows-1251', 'UTF-8', ''));
            } else {
                $results = array('prd_main' => 100, 'prd_main_text' => iconv('Windows-1251', 'UTF-8', $xt->render($tVars)), 'prd_main_pages_text' => iconv('Windows-1251', 'UTF-8', $tVars['pagesss']));
            }
            break;
    }
    return array('status' => 1, 'errorCode' => 0, 'data' => $results);
}
示例#11
0
function ebasket_add_fast_order($linked_ds, $linked_id, $title, $price, $count, $type, $order, $xfld = array())
{
    global $mysql, $userROW, $twig, $template, $ip;
    $SQL['name'] = $order['name'];
    $SQL['email'] = $order['email'];
    $SQL['phone'] = $order['phone'];
    $SQL['address'] = $order['address'];
    $SQL['comment'] = "";
    $SQL['dt'] = time() + $config['date_adjust'] * 60;
    $SQL['ip'] = $ip;
    $SQL['type'] = $type;
    $SQL['paid'] = 0;
    $SQL['total_price'] = round($price * $count, 2);
    if (isset($userROW)) {
        $SQL['author_id'] = $userROW['id'];
    }
    $SQL['uniqid'] = substr(str_shuffle(MD5(microtime())), 0, 10);
    $vnames = array();
    foreach ($SQL as $k => $v) {
        $vnames[] = $k . ' = ' . db_squote($v);
    }
    $mysql->query('INSERT INTO ' . prefix . '_eshop_orders SET ' . implode(', ', $vnames) . ' ');
    $qid = $mysql->lastid('eshop_orders');
    $mysql->query("INSERT INTO " . prefix . "_eshop_order_basket (`order_id`, `linked_id`, `title`, `count`, `price`, `linked_fld`) VALUES (" . db_squote($qid) . ", " . db_squote($linked_id) . ", " . db_squote($title) . ", " . db_squote($count) . ", " . db_squote($price) . ", " . db_squote(serialize($xfld)) . " )");
    // mail notify
    $filter = array();
    if ($qid) {
        $filter[] = '(order_id = ' . db_squote($qid) . ')';
    }
    foreach ($mysql->select("select * from " . prefix . "_eshop_order_basket where " . join(" or ", $filter), 1) as $rec) {
        $total += round($rec['price'] * $rec['count'], 2);
        $rec['sum'] = sprintf('%9.2f', round($rec['price'] * $rec['count'], 2));
        $rec['xfields'] = unserialize($rec['linked_fld']);
        unset($rec['linked_fld']);
        $basket[] = $rec;
    }
    $notify_tpath = locatePluginTemplates(array('mail/lfeedback'), 'eshop', pluginGetVariable('eshop', 'localsource'));
    $notify_xt = $twig->loadTemplate($notify_tpath['mail/lfeedback'] . 'mail/' . 'lfeedback.tpl');
    $pVars = array('recs' => count($basket), 'entries' => $basket, 'total' => sprintf('%9.2f', $total), 'vnames' => $SQL);
    $mailBody = $notify_xt->render($pVars);
    $mailSubject = "Новый заказ с сайта";
    $mailTo = pluginGetVariable('eshop', 'email_notify_orders');
    $mail_from = pluginGetVariable('eshop', 'email_notify_back');
    if ($mail_from == "") {
        $mail_from = false;
    }
    if ($mailTo != "") {
        sendEmailMessage($mailTo, $mailSubject, $mailBody, $filename = false, $mail_from, $ctype = 'text/html');
    }
    return array('status' => 1, 'errorCode' => 0, 'data' => 'Item added into ebasket', 'update' => '');
}
示例#12
0
function guestbook_social()
{
    global $config, $template, $tpl, $mysql;
    session_start();
    $providers = array('Vkontakte', 'Facebook', 'Google', 'Instagram');
    $auth_config = array("base_url" => home . "/engine/plugins/guestbook/lib/hybridauth/", "providers" => array("Vkontakte" => array("enabled" => true, "keys" => array("id" => pluginGetVariable('guestbook', 'vk_client_id'), "secret" => pluginGetVariable('guestbook', 'vk_client_secret'))), "Facebook" => array("enabled" => true, "keys" => array("id" => pluginGetVariable('guestbook', 'facebook_client_id'), "secret" => pluginGetVariable('guestbook', 'facebook_client_secret')), "scope" => "email", "display" => "popup", "auth_type" => "reauthenticate"), "Google" => array("enabled" => true, "keys" => array("id" => pluginGetVariable('guestbook', 'google_client_id'), "secret" => pluginGetVariable('guestbook', 'google_client_secret')), "scope" => "https://www.googleapis.com/auth/userinfo.profile", "display" => "popup", "approval_prompt" => "force"), "Instagram" => array("enabled" => true, "keys" => array("id" => pluginGetVariable('guestbook', 'instagram_client_id'), "secret" => pluginGetVariable('guestbook', 'instagram_client_secret')))));
    if (isset($_GET['provider']) && in_array($_GET['provider'], $providers)) {
        $provider = $_GET['provider'];
        require_once $_SERVER['DOCUMENT_ROOT'] . '/engine/plugins/guestbook/lib/hybridauth/Hybrid/Auth.php';
        try {
            $hybridauth = new Hybrid_Auth($auth_config);
            $adapter = $hybridauth->authenticate($provider);
        } catch (Exception $e) {
            echo "<script>self.close();</script>\n";
        }
        $user_profile = $adapter->getUserProfile();
        // print_r($user_profile);
        // exit;
        $profile = $provider == 'Instagram' ? 'https://www.instagram.com/' . $user_profile->username : $user_profile->profileURL;
        $photo = $user_profile->photoURL;
        if (!empty($photo)) {
            // Prevent duplicate uploads
            $exist = $mysql->record("SELECT id FROM " . prefix . "_images WHERE description = " . db_squote($profile) . " LIMIT 1");
            if (!empty($exist['id'])) {
                $rowID = $exist;
            } else {
                addToFiles('newavatar', $photo);
                @(include_once root . 'includes/classes/upload.class.php');
                // UPLOAD AVATAR
                if ($_FILES['newavatar']['name']) {
                    $imanage = new image_managment();
                    $fname = $provider . '_' . time() . '_' . strtolower($_FILES['newavatar']['name']);
                    if (!strpos($fname, '.jpg')) {
                        $fname .= '.jpg';
                    }
                    $ftmp = $_FILES['newavatar']['tmp_name'];
                    $mysql->query("INSERT INTO " . prefix . "_images (name, orig_name, description, folder, date, owner_id, category) VALUES (" . db_squote($fname) . ", " . db_squote($fname) . ", " . db_squote($profile) . ", '', unix_timestamp(now()), '1', '0')");
                    $rowID = $mysql->record("select LAST_INSERT_ID() as id");
                    if (copy($ftmp, $config['images_dir'] . $fname)) {
                        $sz = $imanage->get_size($config['images_dir'] . $fname);
                        $mysql->query("update " . prefix . "_images set width=" . db_squote($sz['1']) . ", height=" . db_squote($sz['2']) . " where id = " . db_squote($rowID['id']) . " ");
                    }
                }
            }
            $adapter->logout();
            echo "<script>window.opener.document.getElementById('" . $provider . "_li').className += 'active'; " . "window.opener.document.getElementById('" . $provider . "_id').value = " . $rowID['id'] . "; self.close();</script>\n";
        }
    }
}