コード例 #1
0
 function getProposal($vendor)
 {
     $cat = LibCatalog::getInstance();
     $cat->noCity = true;
     $q = "{$cat->selectProposal()} AND i.vendor={$vendor}  ORDER BY sort DESC";
     return DB::select($q)->toArray();
 }
コード例 #2
0
ファイル: Board.class.php プロジェクト: AlexanderWhi/tplshop2
 function actDefault()
 {
     $data = array('category' => 0);
     $page = new Page($this->cfg('PAGE_SIZE'));
     $condition = "b.status=1 AND date_to>='" . date('Y-m-d') . "'";
     if ($c = $this->getUriIntVal('catalog')) {
         $condition .= " AND b.category={$c}";
         $rs = DB::select("SELECT * FROM sc_shop_catalog WHERE id={$c}");
         if ($rs->next()) {
             $this->setPageTitle($rs->get('name'));
         }
         $data['category'] = $c;
     }
     if ($this->getUriIntVal('my')) {
         $condition .= " AND b.userid={$this->getUserId()}";
     }
     $queryStr = "SELECT COUNT(*) as c FROM sc_shop_board b WHERE {$condition}";
     $rs = DB::select($queryStr);
     if ($rs->next()) {
         $page->all = $rs->getInt("c");
     }
     $order = " ORDER BY time DESC";
     $queryStr = "SELECT b.*,u.name,c.name AS c_name,c.id AS c_id FROM sc_shop_board b\r\n\t\t\tLEFT JOIN sc_users u ON u.u_id=b.userid \r\n\t\t\tLEFT JOIN sc_shop_catalog c ON c.id=b.category \r\n\t\tWHERE {$condition} {$order} LIMIT " . $page->getBegin() . "," . $page->per;
     $rs = DB::select($queryStr)->toArray();
     $data['rs'] = $rs;
     $data['pg'] = $page;
     $data['catalog_tree'] = LibCatalog::getInstance()->getCatalogTree();
     $data['date_to'] = date('Y-m-d', time() + 3600 * 24 * 30);
     $this->setCommonCont();
     $this->display($data, dirname(__FILE__) . '/board.tpl.php');
 }
コード例 #3
0
 function getQuery($key)
 {
     $search = explode(' ', trim(preg_replace('/\\s+/', ' ', $this->search)));
     if (in_array($key, array('public', 'news'))) {
         $cond = " type IN('{$key}') \r\n\t\t\t\t\tAND (state='main' OR state='public') ";
         //				$relev=" MATCH nws_title, nws_content,nws_desc AGAINST ('".$this->search."') ";
         //				$cond.=" AND (content ILIKE '%".SQL::slashes($this->search)."%' OR title ILIKE '%".SQL::slashes($this->search)."%' OR description ILIKE '%".SQL::slashes($this->search)."%')";
         $subCond = array();
         foreach ($search as $s) {
             $subCond[] = "(content LIKE '%" . SQL::slashes($s) . "%' OR title LIKE '%" . SQL::slashes($s) . "%' OR description LIKE '%" . SQL::slashes($s) . "%')";
         }
         //				$cond.=" AND (".implode(' OR ',$subCond).")";
         $cond .= " AND (" . implode(' AND ', $subCond) . ")";
         $q = "SELECT id ,title, description FROM sc_news WHERE " . $cond . " ";
         $countQ = "SELECT COUNT(id) AS c FROM sc_news WHERE " . $cond;
         $href = "/news/view/";
         $title = "Статьи";
     }
     if ($key == 'gallery') {
         $cond = " type='gallery' \r\n\t\t\t\t\t";
         $subCond = array();
         foreach ($search as $s) {
             $subCond[] = "(text LIKE '%" . SQL::slashes($s) . "%' OR name LIKE '%" . SQL::slashes($s) . "%' OR description LIKE '%" . SQL::slashes($s) . "%')";
         }
         //				$cond.=" AND (".implode(' OR ',$subCond).")";
         $cond .= " AND (" . implode(' AND ', $subCond) . ")";
         $q = "SELECT id ,name as title, description FROM sc_gallery WHERE " . $cond . " ";
         $countQ = "SELECT COUNT(id) AS c FROM sc_gallery WHERE " . $cond;
         $href = "/gallery/";
         $title = "Галлерея";
     }
     if ($key == 'content') {
         //				$cond=" mod_content_id=c_id AND (mod_location LIKE 'main' OR  mod_location LIKE 'footer' OR  mod_location LIKE 'top')
         //						AND (mod_name ILIKE '%".SQL::slashes($this->search)."%' OR mod_title ILIKE '%".SQL::slashes($this->search)."%' OR c_text ILIKE '%".SQL::slashes($this->search)."%')";
         //				$cond=" c_name ILIKE '%'||mod_alias||'%' AND mod_alias <>'/'";
         $cond = " mod_alias LIKE CONCAT('%',c_name,'%') AND mod_title<>'' AND c_text<>''";
         //				$cond=" mod_alias =c_name ";
         //				$cond.=" AND (mod_location LIKE '%main%' OR  mod_location LIKE '%footer%' OR  mod_location LIKE '%top%')";
         //				$cond.=" AND (mod_name ILIKE '%".SQL::slashes($this->search)."%' OR mod_title ILIKE '%".SQL::slashes($this->search)."%' OR c_text ILIKE '%".SQL::slashes($this->search)."%')";
         $subCond = array();
         foreach ($search as $s) {
             $subCond[] = "(mod_name LIKE '%" . SQL::slashes($s) . "%' OR mod_title LIKE '%" . SQL::slashes($s) . "%' OR c_text LIKE '%" . SQL::slashes($s) . "%')";
         }
         //				$cond.=" AND (".implode(' OR ',$subCond).")";
         $cond .= " AND (" . implode(' AND ', $subCond) . ")";
         //				$q="SELECT mod_alias AS id,mod_title AS title,mod_description AS description FROM sc_content,sc_module WHERE ".$cond." ";
         $q = "SELECT c_name AS id,mod_title AS title,mod_description AS description FROM sc_content,sc_module WHERE " . $cond . " ";
         $countQ = "SELECT COUNT(c_id) AS c FROM sc_content,sc_module WHERE " . $cond;
         $href = "";
         $title = "Разделы сайта";
     }
     if ($key == 'catalog') {
         $cond = "";
         //				$cond.=" AND (g.name ILIKE '%".SQL::slashes($this->search)."%' OR g.description ILIKE '%".SQL::slashes($this->search)."%' OR c.name ILIKE '%".SQL::slashes($this->search)."%' )";
         $subCond = array();
         foreach ($search as $s) {
             $subCond[] = "(i.name LIKE '%" . SQL::slashes($s) . "%' OR i.description LIKE '%" . SQL::slashes($s) . "%' )";
         }
         //				$cond.=" AND (".implode(' OR ',$subCond).")";
         $cond .= " AND (" . implode(' AND ', $subCond) . ")";
         $cat = LibCatalog::getInstance();
         $q = "SELECT g.*, g.id AS id, g.name AS title, g.description AS description FROM sc_shop_item g WHERE " . $cond . "";
         $q = "{$cat->select()} " . $cond . "";
         $countQ = "{$cat->selectCount()} " . $cond;
         $href = "/catalog/goods/";
         $title = "Товары";
     }
     return array($q, $countQ, $href, $title);
 }
コード例 #4
0
 function getBasket()
 {
     return LibCatalog::getInstance()->getBasket();
 }
コード例 #5
0
 function actSend()
 {
     global $post;
     $item = $post->getArray('item');
     $cat = LibCatalog::getInstance();
     if ($item) {
         $rs = DB::select("SELECT * FROM sc_users WHERE  u_id IN(" . implode(',', $item) . ")");
         while ($rs->next()) {
             $rs1 = DB::select("SELECT * FROM sc_shop_item i,sc_shop_proposal p WHERE vendor={$rs->get('u_id')}\r\n\t\t\t\t{$cat->proposalCond()}\r\n\t\t\t\t\r\n\t\t\t\t")->toArray();
             $goods = $this->render(array('rs' => $rs1), dirname(__FILE__) . '/goods.snd.php');
             $password = '******';
             if ($post->getInt('with_pass')) {
                 $password = substr(md5(time() . $rs->get('mail')), 0, 8);
                 DB::update('sc_users', array('password' => md5($password)), "u_id={$rs->get('u_id')}");
             }
             $notice = array('name' => $rs->get('name'), 'login' => $rs->get('login'), 'password' => $password, 'goods' => $goods, 'href' => "http://{$_SERVER['HTTP_HOST']}/");
             $this->sendTemplateMail($rs->get('mail'), 'notice_check_vendor', $notice);
         }
     }
     echo printJSON(array('msg' => 'Отправлено'));
     exit;
 }
コード例 #6
0
ファイル: Main.class.php プロジェクト: AlexanderWhi/tplshop2
 function getMainCat()
 {
     return LibCatalog::getInstance()->getCatalogTree();
 }
コード例 #7
0
" value="<?php 
    echo isset($_GET['search']) ? Html::encode(trim($_GET['search'])) : '';
    ?>
"><!--
                --><button type="submit">Найти</button>
            </form>
        <?php 
}
?>
        <!--/search-->
        <a href="/catalog/basket/" id="basket-blk"><?php 
include_once 'modules/catalog/basket_content_container.php';
?>
</a>
        <a id="favorites" href="/catalog/favorite/">Избранное <?php 
echo count(LibCatalog::getFav());
?>
</a>	
    </div>


</div>

<div id="top-menu">
    <div class="wrapper">
        <ul>
            <?php 
foreach ($this->getMenu('top') as $item) {
    ?>
<li class="<?php 
    echo trim($item['mod_alias'], '/');
コード例 #8
0
 static function getFav()
 {
     if (!empty(self::$fav)) {
         return self::$fav;
     }
     if (!empty($_COOKIE['favorite']) && ($favorite = json_decode(stripslashes($_COOKIE['favorite']), true)) && is_array($favorite)) {
         return self::$fav = $favorite;
     }
     return array();
 }
コード例 #9
0
 function actAddFav()
 {
     global $post;
     $count = LibCatalog::addFav($post->getInt('id'));
     echo printJSON(array('count' => $count));
     exit;
 }