CVE-2018-17552 (PHP, published 2018-10-03T20:29Z)
Description: value: SQL Injection in login.php in Naviwebs Navigate CMS 2.8 allows remote attackers to bypass authentication via the navigate-user cookie.
Severity: HIGH (CVSS v3 base score: 9.8)
Weakness: CWE-89 \u2014 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
Repository: https://github.com/NavigateCMS/Navigate-CMS
Files changed:
lib/core/core.php
lib/core/database.class.php
lib/core/language.class.php
lib/core/user.class.php
lib/layout/layout.class.php
lib/layout/navibars.class.php
lib/layout/naviforms.class.php
lib/packages/about/about.php
lib/packages/blocks/block.class.php
lib/packages/blocks/block_group.class.php
lib/packages/blocks/blocks.php
lib/packages/brands/brand.class.php
lib/packages/comments/comment.class.php
lib/packages/comments/comments.php
lib/packages/coupons/coupon.class.php
lib/packages/dashboard/dashboard.php
lib/packages/extensions/extension.class.php
lib/packages/extensions/extensions.php
lib/packages/feeds/feed.class.php
lib/packages/feeds/feeds.php
lib/packages/files/file.class.php
lib/packages/files/files.php
lib/packages/grid_notes/grid_notes.class.php
lib/packages/items/item.class.php
lib/packages/items/items.php
lib/packages/orders/order.class.php
lib/packages/orders/orders.php
lib/packages/paths/path.class.php
lib/packages/payment_methods/payment_method.class.php
lib/packages/permissions/permission.class.php
lib/packages/products/product.class.php
lib/packages/products/products.php
lib/packages/properties/property.class.php
lib/packages/properties/property.layout.php
lib/packages/shipping_methods/shipping_method.class.php
lib/packages/shipping_methods/shipping_methods.php
lib/packages/structure/structure.class.php
lib/packages/structure/structure.php
lib/packages/templates/template.class.php
lib/packages/templates/templates.php
lib/packages/themes/theme.class.php
lib/packages/themes/themes.php
lib/packages/users/users.php
lib/packages/users_log/users_log.class.php
lib/packages/webdictionary/webdictionary.class.php
lib/packages/webdictionary/webdictionary_history.class.php
lib/packages/websites/website.class.php
lib/packages/websites/websites.php
lib/packages/webuser_votes/webuser_vote.class.php
lib/packages/webusers/webuser.class.php
lib/packages/webusers/webuser_group.class.php
lib/webgets/blocks.php
lib/webgets/comments.php
lib/webgets/conditional.php
lib/webgets/contact.php
lib/webgets/content.php
lib/webgets/gallery.php
lib/webgets/list.php
lib/webgets/liveedit.php
lib/webgets/menu.php
lib/webgets/metatags.php
lib/webgets/product.php
lib/webgets/properties.php
lib/webgets/search.php
lib/webgets/tags.php
lib/webgets/votes.php
lib/webgets/webuser.php
login.php
web/nvweb_plugins.php
web/nvweb_routes.php
web/nvweb_templates.php
web/nvweb_xmlrpc.php
Commit message: * security fix: replace string filtering by parameterization in almost all queries


Vulnerable code:
                $where = 'codename = '.protect($fid);
            $DB->query('SELECT *
                          FROM nv_functions
                         WHERE '.$where.'
                           AND enabled = 1');
        $background_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.background_color") . ' AND website = ' . protect($website->id), 'id DESC');
        $text_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.text_color") . ' AND website = ' . protect($website->id), 'id DESC');
        $title_color_db = $DB->query_single('value', 'nv_permissions', 'name = ' . protect("nvweb.comments.titles_color") . ' AND website = ' . protect($website->id), 'id DESC');
	 * @param string $fetch_mode How to retrieve the data: "object" or "array" 
	public function query($sql, $fetch_mode='object')
			$statement = $this->db->query($sql);
	public function query_single($column, $table, $where = '1=1', $order = '')
            $stm = $this->db->query('SELECT ' . $column . ' FROM ' . $table . ' WHERE ' . $where . $order . ' LIMIT 1');
		if(empty($rs)) 	return NULL;
		else			return $rs[0][0];
	public function	queryLimit($cols, $table, $where="1=1", $order="", $offset=0, $max=100)
			$statement = $this->db->query($sql);
		$DB->query('SELECT * FROM nv_languages WHERE code = '.protect($code));
		
		if($DB->query('SELECT * 
						 FROM nv_users 
						WHERE LOWER(username) = '.protect($user)))
                    user = '.protect($this->id).' AND
                    website = '.protect($website->id).' AND 
                    name = '.protect($name)
		$user_profile_name = $DB->query_single('name', 'nv_profiles', 'id='.protect($user->profile));
					$actions[$search_form_pos][] = '<form method="GET" action="#" onsubmit=" navitable_quicksearch($(\'#navigate-quicksearch\').val()); return false;">';
			'<a href="http://www.tinymce.com" target="_blank">TinyMCE 4.8.0c</a><br />'
                    ' website = '.$website->id.' AND 
                      type = '.protect($theme_blocks[$b]['id'])
				
               SET block_types = '.protect($array).'
			 WHERE id = '.$website->id
            WHERE website = '.protect($website->id),
		if($DB->query('SELECT * FROM nv_block_groups
						WHERE code = '.protect($code).'
						  AND website = '.$website->id))
            'website = '.protect($website->id),
             WHERE website = '.protect($website->id),
			$DB->query('SELECT path as id, path as label, path as value
						 WHERE path LIKE '.protect('%'.$_REQUEST['term'].'%').' 
						'array');
        $DB->query('SELECT * FROM nv_brands WHERE website = '.protect($website->id), 'object');
			 WHERE website = '.protect($website->id),
            ' website = '.protect($website->id).' AND
	        'website = '.protect($website->id).' AND status = 3'
             WHERE website = '.protect($website->id).'
                WHERE website = ' . $this->website . '
                  AND object_type = ' . protect($this->object_type) . '
                  AND object_id = ' . protect($this->object_id) . '
                  AND subscribed = 1
            ');
            WHERE website = '.protect($website->id).' 
            AND user = '.protect($webuser_id).'
            $DB->query('SELECT id, username as text
						  FROM nv_webusers
						 WHERE username LIKE '.protect('%'.$_REQUEST['username'].'%').'
						 AND website = '.$website->id.'
				      ORDER BY username ASC
					     LIMIT 30',
                'array');
            $DB->query('SELECT c.id, c.date_created, c.name, u.username, c.message
						  FROM nv_comments c
						  LEFT JOIN nv_webusers u ON c.user = u.id
						 WHERE
						    c.website = '.$website->id.' AND
						    c.object_type = '.protect($_REQUEST['object_type']).' AND
						    c.object_id = '.protect($_REQUEST['object_id']).' AND
						    c.date_created <= '.$_REQUEST['maxdate'].' AND
						    c.id <> '.$_REQUEST['exclude'].' AND						     
						    (   c.name LIKE ' . protect('%' . $_REQUEST['search'] . '%') . ' OR
						        c.message LIKE ' . protect('%' . $_REQUEST['search'] . '%') . ' OR
						        u.username LIKE ' . protect('%' . $_REQUEST['search'] . '%') . '
                            )                          
				      ORDER BY c.date_created DESC
					     LIMIT 30',
                'array');
            $DB->query('SELECT c.*
						  FROM nv_comments c
						  LEFT JOIN nv_webusers u ON c.user = u.id
						 WHERE
						    c.website = '.$website->id.' AND
						    c.id = '.protect($_REQUEST['id']));
			$DB->query('SELECT DISTINCT node_id as id, text as label, text as value
						  FROM nv_webdictionary
						 WHERE node_type = '.protect($_REQUEST['object_type']).'
						   AND subtype = "title"
						   AND website = '.$website->id.' 
						   AND text LIKE '.protect('%'.$_REQUEST['title'].'%').'
				      ORDER BY text ASC
					     LIMIT 30',
						'array'
        $DB->query('SELECT * FROM nv_coupons WHERE website = '.protect($website->id), 'object');
                    website = '.protect($website->id).' AND
                    webuser = '.protect($webuser).' AND 
                    coupon = '.protect($this->id)
                    website = '.protect($website->id).' AND
                    coupon = '.protect($this->id)
            WHERE website = '.protect($website->id).' AND
                  code = '.protect($code),
            'object'
//	$stats['pages_available'] = $DB->query_single('COUNT(DISTINCT object_id)', 'nv_paths', 'website = '.protect($website->id).' GROUP BY object_id');
                 WHERE p.website = '.protect($website->id).'
         WHERE i.website = '.protect($website->id).'
//	$stats['pages_viewed'] = $DB->query_single('SUM(i.views)', 'nv_items i', 'website = '.protect($website->id));
    $stats['comments_count'] = $DB->query_single('COUNT(*)', 'nv_comments', 'website = '.protect($website->id));
    $stats['comments_torevise'] = $DB->query_single('COUNT(*)', 'nv_comments', 'website = '.protect($website->id).' AND status = -1');
			 WHERE i.website = '.protect($website->id).'
			 WHERE s.website = '.protect($website->id).'
         WHERE i.website = '.protect($website->id).'
           AND p.website = '.protect($website->id).'
         WHERE s.website = '.protect($website->id).'
           AND p.website = '.protect($website->id).'
                 nvwd.lang = '.protect($website->languages_published[0]).'
      WHERE nvc.website = '.$website->id.'
	  ORDER BY nvc.date_created DESC LIMIT '.$comments_limit
        .. WHERE nvc.website = '.protect($website->id).'
                <span data-field="date"></span> 
                <span data-field="username"><strong>'.$public_wall_notes[$e]['username'].'</strong></span>
          SELECT * FROM nv_extensions
          WHERE website = '.protect($this->website).'
            AND extension = '.protect($this->code)
                 WHERE id = '.protect($this->id)
                     AND lang = '.protect($current_language).'
                     AND extension = '.protect($this->code)
             WHERE website = '.protect($website->id),
            $extension_has_options = empty($list[$i]['options']);
    $navibars->add_actions(		array(	'<a href="#" onclick="javascript: navigate_media_browser();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/images.png"> '.t(36, 'Media').'</a>'	));

    $navibars->add_actions(	array(	'<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> '.t(34, 'Save').'</a>'	)    );
                           AND d.lang = '.protect($current['lang']).'
                        OFFSET 0');
        $DB->query('SELECT * FROM nv_feeds WHERE website = '.protect($website->id), 'object');
			$path = $_REQUEST['path'];
			$id = $_REQUEST['id'];
			
			$DB->query('SELECT type, object_id, lang
	 					  FROM nv_paths
						 WHERE path = '.protect($path).'
						   AND website = '.$website->id);
		$DB->query('  SELECT * FROM nv_files
					   WHERE name LIKE '.protect('%'.$text.'%').'
					     AND website = '.$wid.'
					ORDER BY '.$orderby);
			$wid = $website->id;		
            $text = ' AND name LIKE '.protect('%'.$text.'%');
		$DB->query('  SELECT SQL_CALC_FOUND_ROWS * FROM nv_files
					   WHERE type = '.protect($media).'
					     AND enabled = 1
						 AND website = '.$wid.'
						 '.$text.'
					ORDER BY '.$orderby.'
					   LIMIT '.$limit.' 
					  OFFSET '.$offset);
        $DB->query('SELECT * FROM nv_files WHERE website = '.protect($website->id), 'object');
    $layout->add_script('
             AND item_type = '.protect($item_type).'
             AND item_id = '.protect($item_id).'
             ORDER BY date_created DESC'
                  AND item_type = '.protect($item_type).' 
                  AND item_id = '.protect($item_id).'
                  AND note = ""
            ');
                  WHERE gn.website = '.protect($website->id).'
                    AND gn.item_type = '.protect($type).'
                    AND gn.item_id IN ('.implode(",", $ids).')
                  ORDER BY gn.item_id ASC, gn.date_created DESC'
            WHERE gn.website = ".protect($website->id)."
              AND gn.item_type = ".protect($item_type)."
              AND gn.item_id = ".protect($id)."
              AND gn.user = u.id ".
              $extra."
            ORDER BY gn.date_created DESC"
                WHERE website = '.protect($website->id).'
                  AND id = '.protect($id).'
                WHERE website = '.protect($website->id).'
                  AND item_type = '.protect($object_type).'
                  AND item_id = '.protect($object_id).'
                LIMIT 1'
            WHERE website = '.protect($website->id),
                ' id = '.protect($this->category).' AND website = '.$website->id
                     WHERE website = ' . protect($this->website) . '
                       AND object_id = ' . protect($this->id) . '
        $DB->query('SELECT * FROM nv_items WHERE website = '.protect($website->id), 'object');
                    $tag = $_REQUEST['tag'];
                    $lang = $_REQUEST['lang'];

                                    AND d.lang = '.protect($lang).'
                                    AND d.website = '.$website->id.'
                                 WHERE website = ' . $website->id . '
                                   AND lang = ' . protect($lang) . '
                                   AND FIND_IN_SET('.protect($tag).', text) > 0
                        ORDER BY i.id DESC
                    ');
                            $category_text = '[ '.strtolower(t(100, 'Free')).' ]';
			$DB->query('SELECT id, date_created, autosave
						  FROM nv_webdictionary_history
						 WHERE node_type = "item"
						   AND subtype = '.protect('section-'.$_REQUEST['section']).'
						   AND lang = '.protect($_GET['lang']).'
						   AND node_id = '.protect($_REQUEST['id']).'
						   AND website = '.$website->id.' 
				      ORDER BY date_created DESC',
						'array');		
				   AND lang = '.protect($_REQUEST['lang']).'
				   AND website = '.$website->id.'
				   AND text LIKE '.protect('%'.$_REQUEST['title'].'%').'
				'array'
							   AND website = '.$website->id.' 
							   AND id = '.protect($_REQUEST['id']),							   
				$DB->query('SELECT text
							  FROM nv_webdictionary
							 WHERE node_type = "item"
							   AND subtype = '.protect('section-'.$_REQUEST['section']).'
							   AND lang = '.protect($_REQUEST['lang']).'
							   AND website = '.$website->id.' 
							   AND node_id = '.protect($_REQUEST['node_id']),
							'array');
				$DB->query('SELECT text
							  FROM nv_webdictionary
							 WHERE node_type = "property-item"
							   AND subtype = '.protect('property-'.$_REQUEST['section'].'-'.$_REQUEST['lang']).'
							   AND lang = '.protect($_REQUEST['lang']).'
							   AND website = '.$website->id.'
							   AND node_id = '.protect($_REQUEST['node_id']),
							'array');

			$DB->query('SELECT file
						  FROM nv_templates
						 WHERE enabled = 1
						   AND id = '.protect($_REQUEST['id']).'
						   AND website = '.$website->id,
						'array');
			$id = $_REQUEST['id'];
			
			$DB->query('SELECT type, object_id, lang
	 					  FROM nv_paths
						 WHERE path = '.protect($path).'
						   AND website = '.$website->id);
				 WHERE username LIKE '.protect('%'.$_REQUEST['username'].'%').'
				'array
			');
                $template_filter = ' AND nvi.template = '.protect($_REQUEST['template']).' ';
                $template_filter = ' AND nvi.association = '.protect($_REQUEST['association']).' ';
                $template_filter = ' AND nvi.embedding = '.protect($_REQUEST['embedding']).' ';

            $text = $_REQUEST['title'];
            if(!empty($_REQUEST['term'])) // tagit request
                $text = $_REQUEST['term'];
            
				   AND nvw.website = '.$website->id.'
				   AND ( nvw.text LIKE ' . protect('%' . $text . '%') . ' 
				        OR
				        ( nvi.id LIKE  ' . protect('%' . $text . '%') . ' 
				          AND
				          nvw.lang = '.protect($website->languages_published[0]).'
				        )
				       )
            $DB->query($sql, 'array');
						'	website = '.protect($website->id).' AND 
			$template_id = $DB->query_single('template', 'nv_structure', ' id = '.protect($item->category).' AND website = '.$website->id);
			$DB->query('SELECT nvc.*, nvwu.username, nvwu.avatar
						  FROM nv_comments nvc
						 LEFT OUTER JOIN nv_webusers nvwu 
						 			  ON nvwu.id = nvc.user
						 WHERE nvc.website = '.protect($website->id).'
						   AND nvc.object_type = "item"
						   AND nvc.object_id = '.protect($item->id).'
						ORDER BY nvc.date_created ASC
						LIMIT 500');
            WHERE `order` = '.protect($this->id).' 
            'reference = '.protect($reference).' AND website = "'.$website_id.'"'
        $DB->query('SELECT * FROM nv_orders WHERE website = '.protect($website->id), 'object');
						 WHERE username LIKE '.protect('%'.$_REQUEST['username'].'%').'
						   AND website = '.$website->id.'
                        'array');
			 WHERE type = '.protect($type).'
			   AND object_id = '.protect($object_id).'
			   AND website = '.$website_id
			$website_id = $website->id;
	    if(empty($object_id)) throw new Exception('ERROR path: No ID!');
			WHERE type = '.protect($type).'
			  AND object_id = '.protect($object_id).'
			  AND website = '.$website_id
    	  	if(empty($path)) continue;
  			if(!$ok) throw new Exception($DB->get_last_error());
			WHERE website = '.protect($website->id),
        $DB->query('SELECT * FROM nv_payment_methods WHERE website = '.protect($website->id), 'object');
            $ws_query = ' AND website = '.protect($website);
             WHERE name = '.protect($name).'
               AND profile = '.intval($profile_id).'
               AND user = '.intval($user_id).
            $ws_query
                WHERE profile = '.protect($object->profile).'
                  AND (website = 0 OR website = '.protect($ws).')'
                 WHERE user = '.protect($object->id).'
                   AND (website = 0 OR website = '.protect($ws).')'
                 WHERE profile = '.protect($object->id).'
                 AND (website = 0 OR website = '.protect($ws).')'
                     WHERE website = ' . protect($this->website) . '
                       AND object_id = ' . protect($this->id) . '
			$like = ' LIKE '.protect('%'.$text.'%');

			$DB->query('SELECT DISTINCT (nvw.node_id)
						 FROM nv_webdictionary nvw
						 WHERE nvw.node_type = "product"
						   AND nvw.website = '.$website->id.'
						   AND nvw.text '.$like, 'array');
			$cols[] = 'p.id' . $like;
        $DB->query('SELECT * FROM nv_products WHERE website = '.protect($website->id), 'object');
                    $tag = $_REQUEST['tag'];
                    $lang = $_REQUEST['lang'];

                                    AND d.lang = '.protect($lang).'
                                    AND d.website = '.$website->id.'
                                 WHERE website = ' . $website->id . '
                                   AND lang = ' . protect($lang) . '
                                   AND FIND_IN_SET('.protect($tag).', text) > 0
                        ORDER BY p.id DESC
                    ');
					$where      =   ' p.website = '.$website->id;
					$sql = ' SELECT SQL_CALC_FOUND_ROWS
					                p.*, d.text as title, d.lang as language,
                                    u.username as author_username,
                                    (   SELECT COUNT(*)
                                        FROM nv_comments cm
                                        WHERE cm.object_type = "product"
                                          AND cm.object_id = p.id
                                          AND cm.website = '.$website->id.'
                                    ) as comments
							   FROM nv_products p
						  LEFT JOIN nv_webdictionary d
						  		 	 ON p.id = d.node_id
								 	AND d.node_type = "product"
									AND d.subtype = "title"
									AND d.lang = '.protect($website->languages_list[0]).'
									AND d.website = '.$website->id.'
						  LEFT JOIN nv_users u
						  			 ON u.id = p.author
							  WHERE '.$where.'							   
						   ORDER BY '.$orderby.' 
							  LIMIT '.$max.'
							 OFFSET '.$offset;

					if(!$DB->query($sql, 'array'))
						throw new Exception($DB->get_last_error());
			$DB->query('SELECT id, date_created, autosave
						  FROM nv_webdictionary_history
						 WHERE node_type = "product"
						   AND subtype = '.protect('section-'.$_REQUEST['section']).'
						   AND lang = '.protect($_GET['lang']).'
						   AND node_id = '.protect($_REQUEST['id']).'
						   AND website = '.$website->id.' 
				      ORDER BY date_created DESC',
						'array');		
				   AND lang = '.protect($_REQUEST['lang']).'
				   AND website = '.$website->id.'
				   AND text LIKE '.protect('%'.$_REQUEST['title'].'%').'
				'array'
				$DB->query('SELECT text
							  FROM nv_webdictionary_history
							 WHERE node_type = "product"
							   AND website = '.$website->id.' 
							   AND id = '.protect($_REQUEST['id']),							   
							'array');	
				$DB->query('SELECT text
							  FROM nv_webdictionary
							 WHERE node_type = "product"
							   AND subtype = '.protect('section-'.$_REQUEST['section']).'
							   AND lang = '.protect($_REQUEST['lang']).'
							   AND website = '.$website->id.' 
							   AND node_id = '.protect($_REQUEST['node_id']),
							'array');
				$DB->query('SELECT text
							  FROM nv_webdictionary
							 WHERE node_type = "property-product"
							   AND subtype = '.protect('property-'.$_REQUEST['section'].'-'.$_REQUEST['lang']).'
							   AND lang = '.protect($_REQUEST['lang']).'
							   AND website = '.$website->id.'
							   AND node_id = '.protect($_REQUEST['node_id']),
							'array');
			$path = $_REQUEST['path'];

                 WHERE path = '.protect($path).'
                   AND website = '.$website->id
                 WHERE sku = '.protect($sku).'
                   AND website = '.$website->id
				 WHERE username LIKE '.protect('%'.$_REQUEST['username'].'%').'
				'array
			');
            $template_filter = '';

	        if(!empty($_REQUEST['template']))
                $template_filter = ' AND nvp.template = '.protect($_REQUEST['template']).' ';

            
				   AND nvw.website = '.$website->id.'
				   AND ( nvw.text LIKE ' . protect('%' . $text . '%') . ' 
				        OR
				        ( nvp.id LIKE  ' . protect('%' . $text . '%') . ' 
				          AND
				          nvw.lang = '.protect($website->languages_published[0]).'
				        )
            $DB->query($sql, 'array');
				         nvb.name LIKE ' . protect('%' . $text . '%') . '    OR
				         nvb.id LIKE   ' . protect('%' . $text . '%') . '
            $DB->query($sql, 'array');
                 WHERE nvc.website = '.protect($website->id).'
                   AND nvc.object_id = '.protect($item->id).'
                $element = ' AND element = '.protect($element);
            if($DB->query('
                   SELECT *
                   FROM nv_properties
                   WHERE template = '.protect($code).'
                   '.$element.'
                     AND website = '.$website_id.'
                   ORDER BY position ASC, id ASC'
                )
            )
                    ' code = '.protect($code).' AND website = '.$website->id
                $block_group_id = $DB->query_single('id', 'nv_block_groups', ' blocks LIKE '.protect('%'.$item_uid.'%').' AND website = '.$website->id);
                $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = '.protect($object_id).' AND website = '.$website->id);
 			 WHERE element = '.protect($object_type).'
			   AND node_id = '.protect($object_id).
			   (empty($item_uid)? '' : ' AND ( node_uid = '.protect($item_uid).' OR node_uid = "" OR node_uid IS NULL )').'
			   AND website = '.$website->id,
            'array'
                $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = '.protect($code).' AND website = '.$website->id);
                $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = '.protect($object_id).' AND website = '.$website->id);
                    WHERE property_id = '.protect($property->id).'
                      AND element = '.protect($object_type).'
                      AND node_id = '.protect($object_id).
                      (empty($object_uid)? '' : ' AND node_uid = '.protect($object_uid)).'
                      AND website = '.$website->id
                $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = '.protect($code).' AND website = '.$ws->id);
                	  WHERE property_id = '.protect($property->id).'
                        AND element = '.protect($property_object_type).'
                        AND node_id = '.protect($object_id).
                        (empty($node_uid)? '' : ' AND node_uid = '.protect($node_uid)).'
                        AND website = '.$ws->id
                  WHERE website = '.$website_id.'
                    AND element = '.protect($element_type).'
                    AND node_id = '.intval($element_id).'
        ');
        $DB->query('SELECT name
					FROM nv_countries
		 			WHERE lang = '.protect($lang).'
					  AND country_code = '.protect($code));
		$DB->query('SELECT '.$code.' AS country_code, name
					FROM nv_countries
		 			WHERE lang = '.protect($lang).'
					ORDER BY name ASC');
            $country_query = ' AND r.country = '.protect($country_id);
        $DB->query('SELECT name
					FROM nv_countries_regions
		 			WHERE `numeric` = '.protect($code));
            WHERE website = '.protect($website->id).'
              AND property_id = '.protect($property).'
              AND value = '.protect($value),
            'object');
        $DB->query('SELECT * FROM nv_properties WHERE website = '.protect($website->id), 'object');
        $DB->query('SELECT * FROM nv_properties_items WHERE website = '.protect($website->id), 'object');
                            '    node_type = "structure" AND
                                        website = "' . $ws->id . '" AND
                                        node_id = ' . protect($cid) . ' AND
                                        subtype = "title" AND
                                        lang = "' . $ws->languages_published[0] . '"'
                        '   node_type = "item" AND
                        website = "'.$ws->id.'" AND
                        node_id = '.protect($cid).' AND
                        subtype = "title" AND
                        lang = "'.$ws->languages_published[0].'"'
        $DB->query('SELECT * FROM nv_shipping_methods WHERE website = '.protect($website->id), 'object');
                    $country_id = $DB->query_single('`numeric`', 'nv_countries', 'country_code = '.protect($country_code));
                $rate_regions[] = $DB->query_single('name', 'nv_countries_regions', '`numeric` = ' . protect($rr));
                 WHERE parent = '.protect($this->parent).'
                   AND website = '.protect($this->website)
            ' category = '.protect($this->id).' AND
              website = '.protect($this->website).' AND
        $DB->query('SELECT * FROM nv_structure WHERE website = '.protect($website->id), 'object');
			$id = $_REQUEST['id'];
			$DB->query('SELECT type, object_id, lang
	 					  FROM nv_paths
						 WHERE path = '.protect($path).'
						   AND website = '.$website->id);
                $language_filter = ' AND nvw.lang = '.protect($_REQUEST['lang']);
				            (nvi.association = "category" AND nvi.embedding=0)
				   AND nvw.website = '.$website->id.'
				   AND nvw.text LIKE '.protect('%'.$text.'%').'
				'array'
                $language_filter = ' AND nvw.lang = '.protect($_REQUEST['lang']);
				   AND nvw.website = '.$website->id.'
				   AND nvw.text LIKE '.protect('%'.$text.'%').'
					   AND lang = '.protect($_REQUEST['lang']).'
					   AND website = '.$website->id.'
					   AND text LIKE '.protect('%'.$_REQUEST['title'].'%').'
					'array'
				$DB->query('SELECT text
							  FROM nv_webdictionary
							 WHERE node_type = "property-structure"
							   AND subtype = '.protect('property-'.$_REQUEST['section'].'-'.$_REQUEST['lang']).'
							   AND lang = '.protect($_REQUEST['lang']).'
							   AND website = '.$website->id.'
							   AND node_id = '.protect($_REQUEST['node_id']),
							'array');
                                        <small>('.strtolower(t(84, 'Parent')).')</small> '.$parent->dictionary[$website->languages_list[0]]["title"].
                                        <small>('.strtolower(t(501, 'Previous')).')</small> '.$previous_brother_title.
                                        <small>('.strtolower(t(502, 'Next')).')</small> '.$next_brother_title.
        $DB->query('SELECT * FROM nv_templates WHERE website = '.protect($website->id), 'object');
				 WHERE website = '.protect($website->id),
                   WHERE website = '.$website->id.'
                     AND lang = '.protect($current_language).'
                     AND theme = '.protect($this->name)
				$template_id = $DB->query_single('template', 'nv_structure', ' id = '.protect($tmp->category).' AND website = '.$website->id);
                        ' id = '.protect($real[$el_id]->category).' AND 
								  website = '.$ws->id
            $usages = $DB->query_single('COUNT(*)', 'nv_websites', ' theme = '.protect($_REQUEST['theme']));
        0	=> json_decode('{"code": "", "name": "('.strtolower(t(581, "None")).') ---> 1234567"}'),
			WHERE nvul.user = '.protect($user->id).'
			  AND nvul.website = '.protect($website->id).'
			  					   AND nvulm.website = '.protect($website->id).'
			  					   AND nvulm.user = '.protect($user->id).'
			WHERE nvul.user = '.protect($user->id).'
			  AND nvul.function = '.protect($function).'
			  AND nvul.action = '.protect($action).'
			  AND nvul.website = '.protect($website->id).'
			  					   AND nvulm.website = '.protect($website->id).'
			  					   AND nvulm.user = '.protect($user->id).'
			LIMIT '.$limit
							  AND node_type = '.protect('global').'
							  AND website = '.$website->id))
					   AND extension = '.protect($this->extension).'
					   AND subtype = '.protect($this->subtype).'
					   AND website = '.$website->id
				if(!is_array($data)) $data = array();
					$this->text[$item->lang] = $item->text;
					   AND theme = '.protect($theme->name).'
					   AND subtype = '.protect($this->subtype).'
					   AND website = '.$website->id
				$node_id_filter .= ' AND node_id = '.intval($this->node_id);
				$node_id_filter .= ' AND node_uid = '.intval($this->node_uid);
					WHERE website = '.protect($this->website).'
					  AND subtype = '.protect($this->subtype).'
					  AND theme = '.protect($this->theme).' 
					  AND extension = '.protect($this->extension).' 
					  AND node_type = '.protect($this->node_type).
					  $node_id_filter
        $node_id_filter = "";
                $node_id_filter .= ' AND node_id = '.intval($this->node_id);
                $node_id_filter .= ' AND node_uid = '.intval($this->node_uid);
				WHERE subtype = '.protect($this->subtype).'
				  AND node_type = '.protect($this->node_type).'
				  AND theme = '.protect($this->theme).'
				  AND extension = '.protect($this->extension).'
				  AND website = '.protect($this->website).
				  $node_id_filter
				' subtype = '.protect($this->subtype).'
				       AND node_type = '.protect($this->node_type).'
					   AND website = '.$this->website
			 WHERE node_type = '.protect($node_type).'
			   AND node_id = '.protect($node_id).
            (empty($node_uid)? '' : ' AND ( node_uid = '.protect($node_uid).' OR node_uid = "" OR node_uid IS NULL )')
                     WHERE node_type = '.protect($node_type).'
                       AND node_id = '.protect($node_id).'
                       AND website = '.$website_id.'
                       AND lang = '.protect($lang).'
                       AND subtype IN ('.implode(",", array_map(function($k){ return protect($k);}, $subtypes)).')'
                $DB->execute('
                    DELETE FROM nv_webdictionary
                     WHERE node_type = '.protect($node_type).'
                       AND node_id = '.protect($node_id).'
                       AND website = '.$website_id.'
                       AND lang = '.protect($lang).'
                       AND subtype IN ('.implode(",", array_map(function($k){ return protect($k);}, $subtypes)).')
                       AND node_uid = '.protect($node_uid)
                 WHERE node_type = '.protect($node_type).'
                   AND node_id = '.protect($node_id).'
                   AND website = '.$website_id
					$DB->execute('
		                DELETE FROM nv_webdictionary
						WHERE node_id = '.protect($id).'
						  AND node_type = '.protect('global').'
						  AND lang = '.protect($language).'
						  AND website = '.$website->id.'
						LIMIT 1
					');
						WHERE subtype = '.protect($id).'
						  AND node_type = '.protect("theme").'
						  AND theme = '.protect($object).'
						  AND lang = '.protect($language).'
						  AND website = '.$website->id.'
						LIMIT 1
					');
					$DB->execute('
		                DELETE FROM nv_webdictionary
						WHERE subtype = '.protect($id).'
						  AND node_type = '.protect("extension").'
						  AND extension = '.protect($object).'
						  AND lang = '.protect($language).'
						  AND website = '.$website->id.'
						LIMIT 1
					');
        $DB->query('SELECT * FROM nv_webdictionary WHERE website = '.protect($website->id), 'object');
					if($litem=='<p><br _mce_bogus="1"></p>') continue;	// tinymce empty contents, no need to save it
					// has the text been changed since last save?
						'   node_id = '.protect($node_id).' AND
							website = '.protect($website_id).' AND
							lang = '.protect($lang).' AND
							subtype = '.protect($subtype).' AND
							node_type = '.protect($node_type).' AND
							autosave = '.protect(($autosave)? '1' : '0').'
						 ORDER BY date_created DESC
						'
								WHERE node_id = '.protect($node_id).' AND
									  website = '.protect($website_id).' AND
										 lang = '.protect($lang).' AND
									  subtype = '.protect($subtype).' AND
									node_type = '.protect($node_type).' AND
								 date_created < '.(core_time() - 86400 * 7)
			 WHERE node_type = '.protect($node_type).'
			   AND node_id = '.protect($node_id).'
			 ORDER BY date_created ASC'
			WHERE website = '.protect($website->id),
        $DB->query('SELECT * FROM nv_websites WHERE id = '.protect($website->id), 'object');
						 WHERE p.website = '.protect($website->id).' AND
						       p.lang = '.protect($lang).' AND
						            p.path LIKE '.protect('%'.$text.'%').'  OR  
									d.text LIKE '.protect('%'.$text.'%').' 
						 LIMIT 10
					');
			$DB->query('SELECT path as id, path as label, path as value
						 WHERE path LIKE '.protect('%'.$_REQUEST['term'].'%').'
						   AND website = '.protect($_REQUEST['wid']).'
						'array');
				    AND text LIKE '.protect("%navigate_download.php%").'
        0	=> json_decode('{"code": "", "name": "('.strtolower(t(581, "None")).') ---> 1234567"}'),
             WHERE website = '.protect($website->id).'
			   AND object  = '.protect($object).'
               AND object_id = '.protect($object_id).'
		 ');
		$DB->queryLimit('wuv.id AS id, wuv.date AS date, wuv.webuser AS webuser, wu.username AS username', 
						'nv_webuser_votes wuv, nv_webusers wu', 
						'	 wuv.website = '.protect($website->id).'
					   	 AND wuv.object  = '.protect($object).'
 					   	 AND wuv.object_id = '.protect($object_id).'
					   	 AND wu.id = wuv.webuser',
						$orderby, 
						$offset, 
						$limit);
		$fromDate = 0;
			$fromDate = time() - $since*24*60*60;
             WHERE website = '.protect($website->id).'
			   AND object  = '.protect($object).'
               AND object_id = '.protect($object_id).' 
			   AND date > '.$fromDate.'
			 ORDER BY date ASC
        ');
				 WHERE webuser = '.intval($webuser).'
				   AND object  = '.protect($object).'
				   AND object_id = '.protect($object_id)
				   SET `value`	=  '.protect($value).',
						date 	=  '.protect(core_time()).'
				 WHERE id = '.$webuser_vote_id
			   SET votes = '.protect($votes).',
			   	   score = '.protect($score).'
			 WHERE id = '.protect($object_id)
		$DB->query('SELECT COUNT(*) as votes, SUM(value) as score
					  FROM nv_webuser_votes
					 WHERE object_id = '.protect($object_id).'
					   AND object = '.protect($object).'
					   AND website = '.$website->id);	
        $DB->query('SELECT * FROM nv_webuser_votes WHERE website = '.protect($website->id), 'object');
        $ok = $DB->query('SELECT * FROM nv_webusers WHERE cookie_hash = '.protect($hash));
            ' network = '.protect($network).' AND '.
            ' network_user_id = '.protect($network_user_id)
			$website_check = 'AND website  = '.protect($website);

		if($DB->query('SELECT * 
						 FROM nv_webusers 
						WHERE ( access = 0 OR
						 		(access = 2 AND 
						 			(access_begin = 0 OR access_begin < '.time().') AND 
						 			(access_end = 0 OR access_end > '.time().') 
					            )
					           )
						  '.$website_check.'
						  AND LOWER(username) = '.protect($username))
		)
            'website = '.intval($website).' AND email = '.protect($email)
			 WHERE email = '.protect($email).'
			   AND activation_key = '.protect($hash).'
		');
			 WHERE email = '.protect($email).'
			   AND activation_key = '.protect($hash).'
		');
            ' network = '.protect($network).' AND '.
            ' network_user_id = '.protect($network_user_id)
		if($DB->query('SELECT COUNT(*) as total
					   FROM nv_webusers 
					   WHERE LOWER(username) = '.protect($username).'
					   	 AND website = '.$website_id))
                    WHERE website = ' . protect($website->id) . '
            WHERE website = '.protect($website->id), 'array');
        $DB->query('SELECT * FROM nv_webusers WHERE website = '.protect($website->id), 'object');
                      AND nw.website = '.protect($website->id),
                    WHERE website = '.protect($website->id));
                    WHERE website = '.protect($website->id));
                    WHERE website = '.protect($website->id),
                $query_type = ' AND type = '.protect($vars['type']);
                   AND website = '.$website->id.'
                   AND (date_published = 0 OR date_published < '.core_time().')
                   AND (date_unpublish = 0 OR date_unpublish > '.core_time().')
                   AND id = '.protect($vars['id'])
                 WHERE type = '.protect($vars['type']).'
                   AND website = '.$website->id.'
                   AND (date_published = 0 OR date_published < '.core_time().')
                   AND (date_unpublish = 0 OR date_unpublish > '.core_time().')
                ORDER BY position ASC
            ');
                 WHERE type = '.protect($vars['type']).'
                   AND website = '.$website->id.'
                   AND (date_published = 0 OR date_published < '.core_time().')
                   AND (date_unpublish = 0 OR date_unpublish > '.core_time().')
              ORDER BY position ASC
            ');
        		$fixed_rows_ids = array(0);
                 WHERE type = '.protect($vars['type']).'
                   AND website = '.$website->id.'
                   AND (date_published = 0 OR date_published < '.core_time().')
                   AND (date_unpublish = 0 OR date_unpublish > '.core_time().')
                   AND id NOT IN('.implode(",", $fixed_rows_ids).')
                 ORDER BY RAND()
            ');
             WHERE nvc.website = '.protect($website->id).'
               AND nvc.object_type = '.protect($object_type).'
               AND nvc.object_id = '.protect($object_id).'
           OFFSET ' . $offset
             WHERE nvc.website = ' . protect($website->id) . '
               AND nvc.object_type = '.protect($object_type).'
               AND nvc.object_id = '.protect($object_id).'
           OFFSET ' . $offset
                                 nvwd.lang = '.protect($current['lang']).'
				 WHERE nvc.website = '.protect($website->id).'
			   OFFSET '.$offset);
                 WHERE i.category IN('.implode(",", $categories).')
                   AND i.website = '.$website->id.'
                   AND (i.date_published = 0 OR i.date_published < '.core_time().')
                   AND (i.date_unpublish = 0 OR i.date_unpublish > '.core_time().')
                   AND (s.date_published = 0 OR s.date_published < '.core_time().')
                   AND (s.date_unpublish = 0 OR s.date_unpublish > '.core_time().')
                   AND d.lang = '.protect($current['lang']).'
                 OFFSET 0'
				 WHERE website = '.protect($website->id).'
				   AND object_id = '.protect($item->id).'
				   AND status = 0
            ');
    $background_color_db = $DB->query_single('value', 'nv_permissions', 'name = '.protect("nvweb.contact.background_color").' AND website = '.protect($website->id), 'id DESC');
    $text_color_db = $DB->query_single('value', 'nv_permissions', 'name = '.protect("nvweb.contact.text_color").' AND website = '.protect($website->id), 'id DESC');
    $title_color_db = $DB->query_single('value', 'nv_permissions', 'name = '.protect("nvweb.contact.titles_color").' AND website = '.protect($website->id), 'id DESC');
				 WHERE website = '.protect($website->id).'
				   AND object_id = '.protect($object_id).'
			   AND d.lang = '.protect($current['lang']).'
        '.$limit
             WHERE category = '.protect($current['object']->id).'
               AND website = '.$website->id.'
                                          search_nwdi.website = ' . protect($website->id) . ' AND
                                            search_npi.website = ' . protect($website->id) . ' AND
                                          search_nwdi.website = ' . protect($website->id) . ' AND
                                            search_npi.website = ' . protect($website->id) . ' AND
			 WHERE s.id IN('.implode(",", $categories).')
			   AND s.website = '.$website->id.'
			   AND (s.date_published = 0 OR s.date_published < '.core_time().')
			   AND (s.date_unpublish = 0 OR s.date_unpublish > '.core_time().')
			   AND d.lang = '.protect($current['lang']).'
			OFFSET '.$offset
			 WHERE p.category IN('.implode(",", $categories).')
			   AND p.website = '.$website->id.'
			   AND (s.date_published = 0 OR s.date_published < '.core_time().')
			   AND (s.date_unpublish = 0 OR s.date_unpublish > '.core_time().')
			   AND d.lang = '.protect($current['lang']).'
        $DB->query($query);
                     WHERE i.category IN('.implode(",", $categories).')
                       AND i.website = '.$website->id.'
                       AND (i.date_published = 0 OR i.date_published < '.core_time().')
                       AND (i.date_unpublish = 0 OR i.date_unpublish > '.core_time().')
                       AND (s.date_published = 0 OR s.date_published < '.core_time().')
                       AND (s.date_unpublish = 0 OR s.date_unpublish > '.core_time().')
                       AND d.lang = '.protect($current['lang']).'                       
                     LIMIT 1
                ');
             WHERE website = '.protect($website->id).'
			 WHERE i.category IN('.implode(",", $categories).')
			   AND i.website = '.$website->id.'
			   AND (i.date_published = 0 OR i.date_published < '.core_time().')
			   AND (i.date_unpublish = 0 OR i.date_unpublish > '.core_time().')
			   AND (s.date_published = 0 OR s.date_published < '.core_time().')
			   AND (s.date_unpublish = 0 OR s.date_unpublish > '.core_time().')
			   AND d.lang = '.protect($current['lang']).'
		$DB->query($query);
    // now we have all elements that will be shown in the list
                        ' category = '.protect($item->id).' AND
                          website = '.protect($item->website).' AND
                        ');
		                    $email = $DB->query_single('email', 'nv_webusers', 'id = '.protect($item->user));
			                    $gravatar_hash = md5( strtolower( trim( $item->email ) ) );
								 WHERE category = '.protect($current['category']).'
								   AND website = '.$website->id.'
            $last = $DB->query_single('parent', 'nv_structure', ' id = '.protect($last));
		$DB->query('SELECT node_id, text
					  FROM nv_webdictionary 
					 WHERE node_type = "structure"
					   AND subtype = "title" 
					   AND lang = '.protect($current['lang']).'
					   AND website = '.$website->id);		
		$DB->query('SELECT object_id, path
					  FROM nv_paths 
					 WHERE type = "structure"
					   AND lang = '.protect($current['lang']).'
					   AND website = '.$website->id);		
			   AND lang = '.protect($current['lang']).'
			   AND website = '.$website->id
		$DB->query('SELECT * 
					  FROM nv_structure
					 WHERE parent = '.protect($parent).' 
					   AND website = '.$website->id.' 
					  ORDER BY position ASC');
                ' node_type = '.protect($current['type']).' AND
				    node_id = '.protect($current['object']->id).' AND
					subtype = '.protect('title').' AND
					website = '.$website->id.' AND
					   lang = '.protect($current['lang'])
				 WHERE website = '.protect($website->id).'
				   AND object_id = '.protect($object_id).'
			   AND d.lang = '.protect($current['lang']).'
        '.$limit
					$vars['template'] = $DB->query_single('template', 'nv_items', ' id = '.protect($vars['id']));
                    $vars['type'] = $DB->query_single('type', 'nv_blocks', ' id = '.protect($vars['id']));
				$category_template = $DB->query_single('template', 'nv_structure', ' id = '.protect($vars['id']));
			    $file = $DB->query_single('name', 'nv_files', ' id = '.protect($property->value).' AND website = '.$website->id);
                                                    p.website = '.protect($website->id).' AND
			                                p.website = '.protect($website->id).' AND
                   AND wd.website = ' . protect($website->id) . '			  
                   AND d.website = ' . protect($website->id) . '
        $extra.= ' AND text LIKE '.protect('%'.$search.'%'); // note: we will need to pass another filter after exploding the tags
          WHERE website = '.$website->id.'
            AND node_type IN("'.implode('","', $types).'")
            AND lang = '.protect($lang).'
        'array'
                    ' website = '.protect($website->id).'
					  AND webuser = '.protect($webuser->id).'
					  AND object = '.protect($current['type']).'
					  AND object_id = '.protect($current['id'])
                        ' email = '.protect($email).'
                          AND website = '.$website->id
                  website = '.protect($website->id).'
                        email = '.protect($email).' OR
                        username = '.protect(mb_strtolower($username)).'
                    )'
                        ' email = '.protect($email).'
                          AND website = '.$website->id
            ' LOWER(username) = '.protect($username).'
                              AND website = '.$website->id
            ' LOWER(username) = ' . protect($email) . '
                                    AND website = ' . $website->id
    $nuid = $DB->query_single('id', 'nv_users', 'cookie_hash = '.protect($_COOKIE['navigate-user']));
// is a recover password request?
        ' username = '.protect($value).' OR
                 email = '.protect($value)
            'activation_key = '.protect($value)
                     WHERE website = '.protect($website->id).'
		 WHERE subdomain = '.protect($subdomain).'
		   AND ( domain = '.protect($domain).' OR domain = '.protect($idn->encode($domain)).' ) 
	 ');
							 WHERE id = '.protect($current['id']).'
								   WHERE id = '.$current['id'].' 
							 WHERE id = '.protect($current['id']).'
								   WHERE id = '.$current['id'].' 
				WHERE path = '.protect('/'.$route).' AND 
				ORDER BY id DESC'
                                            WHERE id = '.protect($current['id']).' 
                                     WHERE id = '.protect($current['id']).'
                                           WHERE id = '.$current['id'].' 
                                     WHERE id = '.protect($current['id']).'
                                           WHERE id = '.$current['id'].' 
                'website = '.protect($website->id).'
                 AND template = '.protect($template_type).'
                 AND (date_unpublish = 0 OR date_unpublish > '.core_time().')'
                'website = '.protect($website->id).'
                 AND template = '.protect($template_type).'
                 AND (date_unpublish = 0 OR date_unpublish > '.core_time().')'
		' type = '.protect($type).'
		   AND object_id = '.protect($id).'
		   AND lang = '.protect($lang).'
		   AND website = '.$website->id
				   AND lang = '.protect($session['lang']).'
				   AND theme = '.protect($website->theme).' 
				   AND lang = '.protect($session['lang']).'
				   AND website = '.$website->id
			   );		
								   AND lang = '.protect($current['lang']).'
								   AND website = '.$website->id
				 WHERE website = '.protect($website_id).'
					           AND w.text LIKE '.protect($category_name).'
					   )
				');

Fixed code:
            $query_params = NULL;
            {
            }
            {
                $where = 'codename = :codename';
                $query_params = array(':codename' => $fid);
            }
            $DB->query(
                'SELECT * FROM nv_functions WHERE '.$where.' AND enabled = 1',
                'object',
                $query_params
            );
        $background_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.comments.background_color" AND website = ' . intval($website->id), 'id DESC');
        $text_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.comments.text_color" AND website = ' . intval($website->id), 'id DESC');
        $title_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.comments.titles_color" AND website = ' . intval($website->id), 'id DESC');
	 * @param string $fetch_mode How to retrieve the data: "object" or "array"
     * @param array $parameters SQL query parameters associative array
	public function query($sql, $fetch_mode='object', $parameters=array())
		    if(empty($parameters))
            {
			    $statement = $this->db->query($sql);
            }
            else
            {
                $statement = $this->db->prepare($sql);
                $statement->execute($parameters);
            }
     * @param array $parameters SQL query parameters associative array
	public function query_single($column, $table, $where = '1=1', $order = '', $parameters=array())
        $sql = 'SELECT ' . $column . ' FROM ' . $table . ' WHERE ' . $where . $order . ' LIMIT 1';

            if(empty($parameters))
            {
                $stm = $this->db->query($sql);
            }
            else
            {
                $stm = $this->db->prepare($sql);
                $stm->execute($parameters);
            }
		if(empty($rs))
		{
            return NULL;
        }
		else
        {
            return $rs[0][0];
        }
	public function	queryLimit($cols, $table, $where="1=1", $order="", $offset=0, $max=100, $parameters=array())
			if(empty($parameters))
            {
                $statement = $this->db->query($sql);
            }
            else
            {
                $statement = $this->db->prepare($sql);
                $statement->execute($parameters);
            }

		$DB->query(
		    'SELECT * FROM nv_languages WHERE code = :code',
            'object',
            array(':code' => $code)
        );
        $found = $DB->query(
            'SELECT * FROM nv_users WHERE LOWER(username) = :username',
            'object',
            array(':username' => $user)
        );

		if(!empty($found))
                    user = :user AND
                    website = :website AND 
                    name = :name',
            'object',
            array(
                ':user' => $this->id,
                ':website' => $website->id,
                ':name' => $name
            )
		$user_profile_name = $DB->query_single(
		    'name',
            'nv_profiles',
            'id = :user_profile',
            'NULL',
            array(':user_profile' => $user->profile)
        );
                159: "'.t(159, 'Name').'",
					$actions[$search_form_pos][] = '<form method="GET" action="#" onsubmit=" if(typeof(navitable_quicksearch)==\'function\') { navitable_quicksearch($(\'#navigate-quicksearch\').val()); return false; } else return true;">';
                    if(!text) return;
			'<a href="http://www.tinymce.com" target="_blank">TinyMCE 4.8.3</a><br />'
                    ' website = :wid AND type = :type',
                    NULL,
                     array(
                        ':wid' => $website->id,
                        ':type' => $theme_blocks[$b]['id']
                     )

               SET block_types = :block_types
			 WHERE id = :wid',
            array(
                ':wid' => $website->id,
                ':block_types' => $array
            )
            WHERE website = '.intval($website->id),
        $found = $DB->query(
            'SELECT * FROM nv_block_groups
                  WHERE code = :code
                    AND website = '.$website->id,
            'object',
            array(
                ':code' => $code
            )
        );

		if($found)
            'website = '.intval($website->id),
             WHERE website = '.intval($website->id),
			$DB->query(
			    'SELECT path as id, path as label, path as value
						 WHERE path LIKE :path 
                'array',
                array(
                    ':path' => '%' . $_REQUEST['term'] . '%'
                ));
        $DB->query('SELECT * FROM nv_brands WHERE website = '.intval($website->id), 'object');
			 WHERE website = '.intval($website->id),
            ' website = '.intval($website->id).' AND
	        'website = '.intval($website->id).' AND status = 3'
             WHERE website = '.intval($website->id).'
                WHERE website = :wid
                  AND object_type = :otype
                  AND object_id = :oid
                  AND subscribed = 1',
                'object',
                array(
                    ':wid' => $this->website,
                    ':otype' => $this->object_type,
                    ':oid' => $this->object_id
                ));
            WHERE website = '.intval($website->id).' 
            AND user = '.intval($webuser_id).'
            $DB->query(
                'SELECT id, username as text
                      FROM nv_webusers
                     WHERE username LIKE :username
                     AND website = :wid
                  ORDER BY username ASC
                     LIMIT 30',
                'array',
                array(
                    ':wid' => $website->id,
                    ':username' => '%' . $_REQUEST['username'] . '%'
                )
            );
            $DB->query(
                'SELECT c.id, c.date_created, c.name, u.username, c.message
                      FROM nv_comments c
                      LEFT JOIN nv_webusers u ON c.user = u.id
                     WHERE
                        c.website = :wid AND
                        c.object_type = :object_type AND
                        c.object_id = :object_id AND
                        c.date_created <= :maxdate AND
                        c.id <> :exclude AND						     
                        (   c.name LIKE :text OR
                            c.message LIKE :text OR
                            u.username LIKE :text
                        )                          
                  ORDER BY c.date_created DESC
                     LIMIT 30',
                'array',
                array(
                    ':wid' => $website->id,
                    ':object_type' => $_REQUEST['object_type'],
                    ':object_id' => $_REQUEST['object_id'],
                    ':date_created' => $_REQUEST['maxdate'],
                    ':exclude' => $_REQUEST['exclude'],
                    ':text' => '%' . $_REQUEST['search'] . '%'
                )
            );
            $DB->query(
                'SELECT c.*
                      FROM nv_comments c
                      LEFT JOIN nv_webusers u ON c.user = u.id
                     WHERE
                        c.website = '.$website->id.' AND
                        c.id = '.intval($_REQUEST['id'])
            );
			$DB->query(
			    'SELECT DISTINCT node_id as id, text as label, text as value
                      FROM nv_webdictionary
                      WHERE node_type = :object_type
                       AND subtype = "title"
                       AND website = :wid 
                       AND text LIKE :text
                      ORDER BY text ASC
                      LIMIT 30',
                    'array',
                    array(
                        ':object_type' => $_REQUEST['object_type'],
                        ':wid' => $website->id,
                        ':text' => '%'.$_REQUEST['title'].'%'
                    )
        $DB->query('SELECT * FROM nv_coupons WHERE website = '.intval($website->id), 'object');
                    website = '.intval($website->id).' AND
                    webuser = '.intval($webuser).' AND 
                    coupon = '.intval($this->id)
                    website = '.intval($website->id).' AND
                    coupon = '.intval($this->id)
            WHERE website = :wid AND
                  code = :code',
            'object',
            array(
                ':wid' => $website->id,
                ':code' => $code
            )
//	$stats['pages_available'] = $DB->query_single('COUNT(DISTINCT object_id)', 'nv_paths', 'website = '.intval($website->id).' GROUP BY object_id');
                 WHERE p.website = '.intval($website->id).'
         WHERE i.website = '.intval($website->id).'
//	$stats['pages_viewed'] = $DB->query_single('SUM(i.views)', 'nv_items i', 'website = '.intval($website->id));
    $stats['comments_count'] = $DB->query_single('COUNT(*)', 'nv_comments', 'website = '.intval($website->id));
    $stats['comments_torevise'] = $DB->query_single('COUNT(*)', 'nv_comments', 'website = '.intval($website->id).' AND status = -1');
			 WHERE i.website = '.intval($website->id).'
			 WHERE s.website = '.intval($website->id).'
         WHERE i.website = '.intval($website->id).'
           AND p.website = '.intval($website->id).'
         WHERE s.website = '.intval($website->id).'
           AND p.website = '.intval($website->id).'
                 nvwd.lang = :lang
      WHERE nvc.website = :wid
	  ORDER BY nvc.date_created DESC LIMIT '.intval($comments_limit),
        'object',
        array(
            ':wid' => $website->id,
            ':lang' => $website->languages_published[0]
        )
        .. WHERE nvc.website = '.intval($website->id).'

                <span data-field="date">date</span> 
                <span data-field="username"><strong>username</strong></span>
            SELECT * FROM nv_extensions
            WHERE website = :wid
              AND extension = :code',
            'object',
            array(
                ':wid' => $this->website,
                ':code' => $this->code
            )
                 WHERE id = '.intval($this->id)
                     AND lang = :lang
                     AND extension = :code',
                    'object',
                    array(
                        ':lang' => $current_language,
                        ':code' => $this->code
                    )
             WHERE website = '.intval($website->id),
            $extension_has_options = !empty($list[$i]['options']);
    $navibars->add_actions(
        array(
            '<a href="#" onclick="javascript: navigate_media_browser();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/images.png"> '.t(36, 'Media').'</a>'
        )
    );

    $navibars->add_actions(
        array(
            '<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> '.t(34, 'Save').'</a>'
        )
    );
                           AND d.lang = :lang
                        OFFSET 0',
                'object',
                array(
                    ':lang' => $current['lang']
                )
            );
        $DB->query('SELECT * FROM nv_feeds WHERE website = '.intval($website->id), 'object');
			$DB->query(
			    'SELECT type, object_id, lang
                      FROM nv_paths
                     WHERE path = :path
                       AND website = :wid',
                'object',
                array(
                    ':wid' => $this->website,
                    'path' => $_REQUEST['path']
                )
            );
		$DB->query(
		    'SELECT * FROM nv_files
			  	   WHERE name LIKE :text
				     AND website = :wid
				ORDER BY '.$orderby,
            'object',
            array(
                ':wid' => $wid,
                ':text' => '%' . $text . '%'
            )
        );
        {
			$wid = $website->id;
        }
        {
        }

        $query_params = array(
            ':wid' => $wid,
            ':type' => $media,
        );
		$text_search = "";
        {
            $text_search = ' AND name LIKE :text';
            $query_params[':text'] = '%' . $text . '%';
        }
		$DB->query(
		    'SELECT SQL_CALC_FOUND_ROWS * FROM nv_files
			  WHERE type = :type
                 AND enabled = 1
                 AND website = :wid 
                 '.$text_search.'
            ORDER BY '.$orderby.'
               LIMIT '.$limit.' 
              OFFSET '.$offset,
            'object',
            $query_params
        );
        $DB->query('SELECT * FROM nv_files WHERE website = '.intval($website->id), 'object');
    $layout->add_script('    
             AND item_type = :item_type
             AND item_id = :item_id
             ORDER BY date_created DESC',
            NULL,
            array(
                ':item_type' => $item_type,
                ':item_id' => $item_id
            )
                  AND item_type = :item_type 
                  AND item_id = :item_id
                  AND note = ""',
                array(
                    ':item_type' => $item_type,
                    ':item_id' => $item_id
                )
            );
                  WHERE gn.website = :wid
                    AND gn.item_type = :item_type
                    AND gn.item_id IN (:item_ids)
                  ORDER BY gn.item_id ASC, gn.date_created DESC',
                'object',
                array(
                    ':wid' => $website->id,
                    ':item_type' => $type,
                    ':item_ids' => implode(",", $ids)
                )
            WHERE gn.website = ".intval($website->id)."
              AND gn.item_type = :item_type
              AND gn.item_id = :item_id
              AND gn.user = u.id 
              ".$extra."
            ORDER BY gn.date_created DESC",
            'object',
            array(
                ':item_type' => $item_type,
                ':item_id' => $id
            )
                WHERE website = '.intval($website->id).'
                  AND id = '.intval($id).'
                WHERE website = :wid
                  AND item_type = :object_type
                  AND item_id = :object_id
                LIMIT 1',
            array(
                ':wid' => $website->id,
                ':object_type' => $object_type,
                ':object_id' => $object_id
            )
            WHERE website = '.intval($website->id),
                ' id = '.intval($this->category).' AND website = '.intval($website->id)
                     WHERE website = ' . intval($this->website) . '
                       AND object_id = ' . intval($this->id) . '
        $DB->query('SELECT * FROM nv_items WHERE website = '.intval($website->id), 'object');
                                    AND d.lang = :lang
                                    AND d.website = :wid
                                 WHERE website = :wid
                                   AND lang = :lang
                                   AND FIND_IN_SET(:tag, text) > 0
                        ORDER BY i.id DESC',
                        'object',
                        array(
                            ':lang' => $_REQUEST['lang'],
                            ':wid' => $website->id,
                            ':tag' => $_REQUEST['tag']
                        )
                    );
                            $category_text = '[ '.mb_strtolower(t(100, 'Free')).' ]';
			$DB->query(
			    'SELECT id, date_created, autosave
                      FROM nv_webdictionary_history
                     WHERE node_type = "item"
                       AND subtype = :subtype
                       AND lang = :lang 
                       AND node_id = :node_id
                       AND website = :wid 
                  ORDER BY date_created DESC',
                    'array',
                array(
                    ':wid' => $website->id,
                    ':node_id' => $_REQUEST['id'],
                    ':lang' => $_REQUEST['lang'],
                    ':subtype' => 'section-'.$_REQUEST['section']
                )
            );
				   AND lang = :lang
				   AND website = :wid
				   AND text LIKE :text
				'array',
                array(
                    ':wid' => $website->id,
                    ':lang' => $_REQUEST['lang'],
                    ':text' => '%'.$_REQUEST['title'].'%'
                )
							   AND website = '.intval($website->id).' 
							   AND id = '.intval($_REQUEST['id']),
				$DB->query(
				    'SELECT text
                          FROM nv_webdictionary
                         WHERE node_type = "item"
                           AND subtype = :subtype
                           AND lang = :lang
                           AND website = :wid 
                           AND node_id = :node_id',
                    'array',
                    array(
                        ':wid' => $website->id,
                        ':lang' => $_REQUEST['lang'],
                        ':node_id' => $_REQUEST['node_id'],
                        ':subtype' => 'section-'.$_REQUEST['section']
                    )
                );
				$DB->query(
				    'SELECT text
                          FROM nv_webdictionary
                         WHERE node_type = "property-item"
                           AND subtype = :subtype
                           AND lang = :lang
                           AND website = :wid 
                           AND node_id = :node_id',
                        'array',
                        array(
                            ':wid' => $website->id,
                            ':lang' => $_REQUEST['lang'],
                            ':node_id' => $_REQUEST['node_id'],
                            ':subtype' => 'property-'.$_REQUEST['section'].'-'.$_REQUEST['lang']
                        )
                    );
                
			$DB->query(
			    'SELECT file
                    FROM nv_templates
                   WHERE enabled = 1
                     AND id = '.intval($_REQUEST['id']).'
                     AND website = '.intval($website->id),
                'array'
            );

			$DB->query(
			    'SELECT type, object_id, lang
	 				  FROM nv_paths
					 WHERE path = :path
					   AND website = :wid',
                    'object',
                    array(
                        ':path' => $path,
                        ':wid' => $website->id
                    )
                );
				 WHERE username LIKE :username
				'array',
				array(
				    ':username' => '%' . $_REQUEST['username'] . '%'
                )
			);
            $text = $_REQUEST['title'];
            if(!empty($_REQUEST['term'])) // tagit request
                $text = $_REQUEST['term'];

            $query_params = array(
                ':wid' => $website->id,
                ':lang' => $website->languages_published[0],
                ':text' => '%' . $text . '%'
            );

            {
                $template_filter = ' AND nvi.template = :template ';
                $query_params[':template'] = $_REQUEST['template'];
            }
            {
                $template_filter = ' AND nvi.association = :association ';
                $query_params[':association'] = $_REQUEST['association'];
            }
            {
                $template_filter = ' AND nvi.embedding = :embedding ';
                $query_params[':embedding'] = $_REQUEST['embedding'];
            }

				   AND nvw.website = :wid
				   AND ( nvw.text LIKE :text 
				         OR ( nvi.id LIKE :text AND nvw.lang = :lang )
				   )
            $DB->query($sql, 'array', $query_params);
						'	website = '.intval($website->id).' AND 
			$template_id = $DB->query_single('template', 'nv_structure', ' id = '.intval($item->category).' AND website = '.intval($website->id));
			$DB->query(
			    'SELECT nvc.*, nvwu.username, nvwu.avatar
                      FROM nv_comments nvc
                     LEFT OUTER JOIN nv_webusers nvwu 
                                  ON nvwu.id = nvc.user
                     WHERE nvc.website = '.intval($website->id).'
                       AND nvc.object_type = "item"
                       AND nvc.object_id = '.intval($item->id).'
                    ORDER BY nvc.date_created ASC
                    LIMIT 500'
            );
            WHERE `order` = '.intval($this->id).' 
            'reference = :reference AND website = :wid',
            NULL,
            array(
                ':wid' => $website_id,
                ':reference' => $reference
            )
        $DB->query('SELECT * FROM nv_orders WHERE website = '.intval($website->id), 'object');
						 WHERE username LIKE :username
						   AND website = :wid
                        'array',
                        array(
                            ':wid' => $website->id,
                            ':username' => '%' . $_REQUEST['username'] . '%'
                        )
                    );
			 WHERE type = :type
			   AND object_id = :object_id
			   AND website = :wid',
            'object',
            array(
                ':wid' => $website_id,
                ':object_id' => $object_id,
                ':type' => $type
            )
		{
            $website_id = $website->id;
        }
	    if(empty($object_id))
        {
            throw new Exception('ERROR path: No ID!');
        }
			WHERE type = :type
			  AND object_id = :object_id
			  AND website = :wid',
            array(
                ':wid' => $website_id,
                ':object_id' => $object_id,
                ':type' => $type
            )
        {
        }
    	  	if(empty($path))
            {
                continue;
            }
  			if(!$ok)
            {
                throw new Exception($DB->get_last_error());
            }
			WHERE website = '.intval($website->id),
        $DB->query('SELECT * FROM nv_payment_methods WHERE website = '.intval($website->id), 'object');
            $ws_query = ' AND website = '.intval($website);
             WHERE name = :name 
               AND profile = :profile_id 
               AND user = :user_id',
            $ws_query,
            'object',
            array(
                ':name' => $name,
                ':profile_id' => intval($profile_id),
                ':user_id' => intval($user_id)
            )
                WHERE profile = :profile
                  AND (website = 0 OR website = :wid)',
                'object',
                array(
                    ':profile' => $object->profile,
                    ':wid' => $ws
                )
                 WHERE user = :object_id
                   AND (website = 0 OR website = :wid)',
            'object',
                array(
                    ':wid' => $ws,
                    ':object_id' => $object->id
                )
                 WHERE profile = :object_id
                 AND (website = 0 OR website = :wid)',
                'object',
                array(
                    ':wid' => $ws,
                    ':object_id' => $object->id
                )
                     WHERE website = ' . intval($this->website) . '
                       AND object_id = ' . intval($this->id) . '
			$DB->query(
			    'SELECT DISTINCT (nvw.node_id)
                     FROM nv_webdictionary nvw
                     WHERE nvw.node_type = "product"
                       AND nvw.website = '.$website->id.'
                       AND nvw.text LIKE :text',
                'array',
                array(
                    ':text' => '%'.$text.'%'
                )
            );
			$cols[] = 'p.id LIKE ' .  protect('%'.$text.'%').' ';
        $DB->query('SELECT * FROM nv_products WHERE website = '.intval($website->id), 'object');
                                    AND d.lang = :lang
                                    AND d.website = :wid
                                 WHERE website = :wid
                                   AND lang = :lang
                                   AND FIND_IN_SET(:tag, text) > 0
                        ORDER BY p.id DESC',
                        'object',
                        array(
                            ':wid' => $website->id,
                            ':lang' => $_REQUEST['lang'],
                            ':tag' => $_REQUEST['tag']
                        )
                    );
					$where      =   ' p.website = :wid';
                    $query_params = array(
                        ':wid' => $website->id,
                        ':lang' => $website->languages_list[0]
                    );

					$ok = $DB->query(
					    'SELECT SQL_CALC_FOUND_ROWS
                                p.*, d.text as title, d.lang as language,
                                u.username as author_username,
                                (   SELECT COUNT(*)
                                    FROM nv_comments cm
                                    WHERE cm.object_type = "product"
                                      AND cm.object_id = p.id
                                      AND cm.website = :wid
                                ) as comments
                           FROM nv_products p
                      LEFT JOIN nv_webdictionary d
                                 ON p.id = d.node_id
                                AND d.node_type = "product"
                                AND d.subtype = "title"
                                AND d.lang = :lang
                                AND d.website = :wid
                      LEFT JOIN nv_users u
                                 ON u.id = p.author
                          WHERE '.$where.'							   
                       ORDER BY '.$orderby.' 
                          LIMIT '.$max.'
                         OFFSET '.$offset,
                        'array',
                        $query_params
                    );

					if(!$ok)
					{
                        throw new Exception($DB->get_last_error());
                    }
			$DB->query(
			    'SELECT id, date_created, autosave
                      FROM nv_webdictionary_history
                     WHERE node_type = "product"
                       AND subtype = :subtype
                       AND lang = :lang
                       AND node_id = :node_id
                       AND website = :wid 
                  ORDER BY date_created DESC',
                'array',
                array(
                    ':wid' => $website->id,
                    ':lang' => $_REQUEST['lang'],
                    ':node_id' => $_REQUEST['id'],
                    ':subtype' => 'section-'.$_REQUEST['section']
                )
            );
				   AND lang = :lang
				   AND website = :wid
				   AND text LIKE :text
				'array',
                array(
                    ':wid' => $website->id,
                    ':lang' => $_REQUEST['lang'],
                    ':text' => '%' . $_REQUEST['title'] . '%'
                )
				$DB->query(
				    'SELECT text
                          FROM nv_webdictionary_history
                         WHERE node_type = "product"
                           AND website = '.intval($website->id).' 
                           AND id = '.intval($_REQUEST['id']),
                    'array'
                );
				$DB->query(
				    'SELECT text
                          FROM nv_webdictionary
                         WHERE node_type = "product"
                           AND subtype = :subtype
                           AND lang = :lang
                           AND website = :wid 
                           AND node_id = :node_id',
                    'array',
                    array(
                        ':wid' => $website->id,
                        ':lang' => $_REQUEST['lang'],
                        ':subtype' => 'section-'.$_REQUEST['section'],
                        ':node_id' => $_REQUEST['node_id']
                    )
                );
				$DB->query(
				    'SELECT text
                          FROM nv_webdictionary
                         WHERE node_type = "property-product"
                           AND subtype = :subtype
                           AND lang = :lang
                           AND website = :wid
                           AND node_id = :node_id',
                    'array',
                    array(
                        ':subtype' => 'property-'.$_REQUEST['section'].'-'.$_REQUEST['lang'],
                        ':lang' => $_REQUEST['lang'],
                        ':wid' => $website->id,
                        ':node_id' => $_REQUEST['node_id']
                    )
                );
                 WHERE path = :path
                   AND website = :wid',
            'object',
                array(
                    ':wid' => $website->id,
                    ':path' => $_REQUEST['path']
                )
                 WHERE sku = :sku
                   AND website = :wid',
            'object',
                array(
                    ':sku' => $sku,
                    ':wid' => $website->id
                )
				 WHERE username LIKE :username
				'array',
                array(
                    ':username' => '%'.$_REQUEST['username'].'%'
                )
            );
            {
            }

            $query_params = array(
                ':wid' => $website->id,
                ':lang' => $website->languages_published[0],
                ':text' => '%' . $text . '%'
            );

            $template_filter = '';
            if(!empty($_REQUEST['template']))
            {
                $template_filter = ' AND nvp.template = :template ';
                $query_params[':template'] = $_REQUEST['template'];
            }

				   AND nvw.website = :wid
				   AND ( nvw.text LIKE :text 
				        OR ( nvp.id LIKE :text AND nvw.lang = :lang )
            $DB->query($sql, 'array', $query_params);
				         nvb.name LIKE :text OR
				         nvb.id LIKE :text
            $DB->query(
                $sql,
                'array',
                array(
                    ':text' => '%' . $text . '%'
                )
            );
    {
    }
                 WHERE nvc.website = '.intval($website->id).'
                   AND nvc.object_id = '.intval($item->id).'
            $query_params = array(
                ':template' => $code,
                ':wid' => $website_id
            );

            {
                $element = ' AND element = :element ';
                $query_params[':element'] = $element;
            }
            {
            }
            $ok = $DB->query(
            'SELECT * FROM nv_properties
                 WHERE template = :template
                  '.$element.'
                  AND website = :wid
                ORDER BY position ASC, id ASC',
                'object',
                $query_params
            );

            if($ok)
                    ' code = :code AND website = :wid',
                    NULL,
                    array(
                        ':wid' => $website->id,
                        ':code' => $code
                    )
                $block_group_id = $DB->query_single(
                    'id',
                    'nv_block_groups',
                    ' blocks LIKE :uid AND website = :wid',
                    NULL,
                    array(
                        ':wid' => $website->id,
                        ':uid' => '%'.$item_uid.'%'
                    )
                );
                $block_group_id = $DB->query_single(
                    'MAX(id)',
                    'nv_block_groups',
                    ' code = :object_id AND website = :wid',
                    null,
                    array(
                        ':wid' => $website->id,
                        ':object_id' => $object_id
                    )
                );
        $query_params = array(
            ':wid' => $website->id,
            ':object_type' => $object_type,
            ':object_id' => $object_id
        );

        $uid_filter = '';
        if(!empty($item_uid))
        {
            $uid_filter = ' AND ( node_uid = :node_uid OR node_uid = "" OR node_uid IS NULL )';
            $query_params[':node_uid'] = $item_uid;
        }

 			 WHERE element = :object_type
			   AND node_id = :object_id
			   '.$uid_filter.'			   
			   AND website = :wid',
            'array',
            $query_params
                $block_group_id = $DB->query_single(
                    'MAX(id)',
                    'nv_block_groups',
                    ' code = :code AND website = :wid',
                    null,
                    array(
                        ':wid' => $website->id,
                        ':code' => $code
                    )
                );
                $block_group_id = $DB->query_single(
                    'MAX(id)',
                    'nv_block_groups',
                    ' code = :object_id AND website = :wid',
                    null,
                    array(
                        ':wid' => $website->id,
                        ':object_id' => $object_id
                    )
                );
            $query_params = array(
                ':wid' => $website->id,
                ':property_id' => $property->id,
                ':object_type' => $object_type,
                ':object_id' => $object_id
            );

            $uid_filter = '';
            if(!empty($object_uid))
            {
                $uid_filter = ' AND node_uid = :object_uid ';
                $query_params[':object_uid'] = $object_uid;
            }

                    WHERE property_id = :property_id
                      AND element = :object_type
                      AND node_id = :object_id
                      '.$uid_filter.'
                      AND website = :wid',
                $query_params
                $block_group_id = $DB->query_single(
                    'MAX(id)',
                    'nv_block_groups',
                    ' code = :code AND website = :wid',
                    null,
                    array(
                        ':code' => $code,
                        ':wid' => $ws->id
                    )
                );

            $query_params = array(
                ':wid' => $ws->id,
                ':object_id' => $object_id,
                ':pr_object_type' => $property_object_type,
                ':pr_id' => $property->id
            );

            $uid_filter = '';
            if(!empty($node_uid))
            {
                $uid_filter = ' AND node_uid = :node_uid ';
                $query_params[':node_uid'] = $node_uid;
            }

                	  WHERE property_id = :pr_id
                        AND element = :pr_object_type
                        AND node_id = :object_id                        
                        AND website = :wid
                        '.$uid_filter,
                $query_params
                  WHERE website = :wid
                    AND element = :e_type
                    AND node_id = :e_id ',
            array(
                ':wid' => $website_id,
                ':e_type' => $element_type,
                ':e_id' => $element_id
            )
        );
        $DB->query(
            'SELECT name
			 	  FROM nv_countries
		 		  WHERE lang = :lang
				    AND country_code = :ccode',
            'object',
            array(
                ':ccode' => $code,
                ':lang' => $lang
            )
        );
		$DB->query(
		    'SELECT '.$code.' AS country_code, name
			  	  FROM nv_countries
		 		  WHERE lang = :lang
				  ORDER BY name ASC',
            'object',
            array(
                ':lang' => $lang
            )
        );
            $country_query = ' AND r.country = '.intval($country_id);
        $DB->query(
            'SELECT name
			  	  FROM nv_countries_regions
		 		  WHERE `numeric` = '.intval($code)
        );
            WHERE website = '.intval($website->id).'
              AND property_id = :property_id 
              AND value = :value',
            'object',
            array(
                ':proeprty_id' => $property,
                ':value' => $value
            )
        );
        $DB->query('SELECT * FROM nv_properties WHERE website = '.intval($website->id), 'object');
        $DB->query('SELECT * FROM nv_properties_items WHERE website = '.intval($website->id), 'object');
                            '    
                                node_type = "structure" AND
                                website = :wid AND
                                node_id = :node_id AND
                                subtype = "title" AND
                                lang = :lang',
                            NULL,
                            array(
                                ':wid' => $ws->id,
                                ':lang' => $ws->languages_published[0],
                                ':node_id' => $cid
                            )
                        '   
                            node_type = "item" AND
                            website = :wid AND
                            node_id = :node_id AND
                            subtype = "title" AND
                            lang = :lang',
                        NULL,
                        array(
                            ':wid' => $ws->id,
                            ':node_id' => $cid,
                            ':lang' => $ws->languages_published[0]
                        )
        $DB->query('SELECT * FROM nv_shipping_methods WHERE website = '.intval($website->id), 'object');
                    $country_id = $DB->query_single(
                        '`numeric`',
                        'nv_countries',
                        'country_code = :ccode',
                        null,
                        array(
                            ':ccode' => $country_code
                        )
                    );
            {
                $rate_regions[] = $DB->query_single(
                    'name',
                    'nv_countries_regions',
                    '`numeric` = ' . intval($rr)
                );
            }
                 WHERE parent = '.intval($this->parent).'
                   AND website = '.intval($this->website)
            ' category = '.intval($this->id).' AND
              website = '.intval($this->website).' AND
        $DB->query('SELECT * FROM nv_structure WHERE website = '.intval($website->id), 'object');
			$DB->query(
			    'SELECT type, object_id, lang
	 			 	   FROM nv_paths
					  WHERE path = :path 
					    AND website = :wid',
                'object',
                array(
                    ':wid' => $website->id,
                    ':path' => $path
                ));
            $query_params = array(
                ':wid' => $website->id,
                ':text' => '%' . $text . '%'
            );

            {
                $language_filter = ' AND nvw.lang = :lang ';
                $query_params[':lang'] = $_REQUEST['lang'];
            }
				            (nvi.association = "category" AND nvi.embedding = 0)
				   AND nvw.website = :wid
				   AND nvw.text LIKE :text
				'array',
                $query_params
            $query_params = array(
                ':wid' => $website->id,
                ':text' => '%'.$text.'%'
            );

            {
                $language_filter = ' AND nvw.lang = :lang ';
                $query_params[':lang'] = $_REQUEST['lang'];
            }
				   AND nvw.website = :wid
				   AND nvw.text LIKE :text
					   AND lang = :lang 
					   AND website = :wid
					   AND text LIKE :text
					'array',
                array(
                    ':wid' => $website->id,
                    ':lang' => $_REQUEST['lang'],
                    ':text' => '%'.$_REQUEST['title'].'%'
                )
				$DB->query(
				    'SELECT text
                      FROM nv_webdictionary
                     WHERE node_type = "property-structure"
                       AND subtype = :subtype
                       AND lang = :lang							   
                       AND website = :wid
                       AND node_id = :node_id',
                    'array',
                    array(
                        ':wid' => $website->id,
                        ':lang' => $_REQUEST['lang'],
                        ':subtype' => 'property-'.$_REQUEST['section'].'-'.$_REQUEST['lang'],
                        ':node_id' => $_REQUEST['node_id']
                    ));
                                        <small>('.mb_strtolower(t(84, 'Parent')).')</small> '.$parent->dictionary[$website->languages_list[0]]["title"].
                                        <small>('.mb_strtolower(t(501, 'Previous')).')</small> '.$previous_brother_title.
                                        <small>('.mb_strtolower(t(502, 'Next')).')</small> '.$next_brother_title.
        $DB->query('SELECT * FROM nv_templates WHERE website = '.intval($website->id), 'object');
				 WHERE website = '.intval($website->id),
                   WHERE website = :wid
                     AND lang = :lang
                     AND theme = :theme',
                    'object',
                    array(
                        ':wid' => $website->id,
                        ':lang' => $current_language,
                        ':theme' => $this->name
                    )
                {
                }
				$template_id = $DB->query_single(
				    'template',
                    'nv_structure',
                    ' id = :category AND website = :wid',
                    null,
                    array(
                        ':wid' => $website->id,
                        ':category' => $tmp->category
                    )
                );
                        ' id = '.intval($real[$el_id]->category).' AND 
								  website = '.intval($ws->id)
            $usages = $DB->query_single(
                'COUNT(*)',
                'nv_websites',
                ' theme = :theme',
                null,
                array(
                    ':theme' => $_REQUEST['theme']
                )
            );
        0	=> json_decode('{"code": "", "name": "('.mb_strtolower(t(581, "None")).') ---> 1234567"}'),
			WHERE nvul.user = '.intval($user->id).'
			  AND nvul.website = '.intval($website->id).'
			  					   AND nvulm.website = '.intval($website->id).'
			  					   AND nvulm.user = '.intval($user->id).'
			WHERE nvul.user = :user_id
			  AND nvul.function = :function
			  AND nvul.action = :action
			  AND nvul.website = :wid
			  					   AND nvulm.website = :wid
			  					   AND nvulm.user = :user_id
			LIMIT '.$limit,
        'object',
            array(
                ':wid' => $website->id,
                ':action' => $action,
                ':function' => $function,
                ':user_id' => $user->id
            )
							  AND node_type = "global"
							  AND website = '.intval($website->id))
            )
					   AND extension = :extension
					   AND subtype = :subtype
					   AND website = :wid',
                    'object',
                    array(
                        ':wid' => $website->id,
                        ':subtype' => $this->subtype,
                        ':extension' => $this->extension
                    )
				if(!is_array($data))
				{
				    $data = array();
                }
                {
                    $this->text[$item->lang] = $item->text;
                }
					   AND theme = :theme 
					   AND subtype = :subtype 
					   AND website = :wid',
                    'object',
                    array(
                        ':wid' => $website->id,
                        ':subtype' => $this->subtype,
                        ':theme' => $theme->name
                    )
		    $query_params = array(
                ':wid' => $this->website,
                ':subtype' => $this->subtype,
                ':theme' => $this->theme,
                ':extension' => $this->extension,
                ':node_type' => $this->node_type
            );

            {
				$node_id_filter .= ' AND node_id = :node_id ';
				$query_params[':node_id'] = $this->node_id;
            }
            {
				$node_id_filter .= ' AND node_uid = :node_uid ';
                $query_params[':node_uid'] = $this->node_uid;
            }
					WHERE website = :wid 
					  AND subtype = :subtype
					  AND theme = :theme  
					  AND extension = :extension  
					  AND node_type = :node_type
					  '.$node_id_filter,
                $query_params
        $node_filter = "";
		    $query_params = array(
                ':wid' => $this->website,
                ':extension' => $this->extension,
                ':theme' => $this->theme,
                ':node_type' => $this->node_type,
                ':subtype' => $this->subtype
            );

            {
                $node_filter .= ' AND node_id = :node_id ';
                $query_params[':node_id'] = $this->node_id;
            }
            {
                $node_filter .= ' AND node_uid = :node_uid ';
                $query_params[':node_uid'] = $this->node_uid;
            }
				WHERE subtype = :subtype
				  AND node_type = :node_type
				  AND theme = :theme 
				  AND extension = :extension 
				  AND website = :wid
				  '.$node_filter,
                $query_params
				' subtype = :subtype 
				       AND node_type = :node_type 
					   AND website = :wid',
                null,
                array(
                    ':wid' => $this->website,
                    ':subtype' => $this->subtype,
                    ':node_type' => $this->node_type
                )

		$query_params = array(
            ':node_type' => $node_type,
            ':node_id' => $node_id
        );

		$uid_filter = '';
		if(!empty($node_uid))
        {
            $uid_filter = ' AND ( node_uid = :node_uid OR node_uid = "" OR node_uid IS NULL )';
            $query_params[':node_uid'] = $node_uid;
        }

			 WHERE node_type = :node_type
			   AND node_id = :node_id 
            '.$uid_filter,
            'object',
            $query_params
                     WHERE node_type = :node_type
                       AND node_id = :node_id 
                       AND website = :wid 
                       AND lang = :lang
                       AND subtype IN (:subtype)',
                    array(
                        ':wid' => $website_id,
                        ':lang' => $lang,
                        ':node_id' => $node_id,
                        ':node_type' => $node_type,
                        ':subtype' => implode(",", array_map(function($k){ return protect($k);}, $subtypes))
                    )
                $DB->execute(
                    'DELETE FROM nv_webdictionary
                         WHERE node_type = :node_type
                           AND node_id = :node_id 
                           AND website = :wid 
                           AND lang = :lang
                           AND subtype IN (:subtype)
                           AND node_uid = :node_uid',
                    array(
                        ':wid' => $website_id,
                        ':lang' => $lang,
                        ':node_id' => $node_id,
                        ':node_type' => $node_type,
                        ':subtype' => implode(",", array_map(function($k){ return protect($k);}, $subtypes)),
                        ':node_uid' => $node_uid
                    )
                 WHERE node_type = :node_type 
                   AND node_id = :node_id 
                   AND website = :wid',
                array(
                    ':wid' => $website_id,
                    ':node_type' => $node_type,
                    ':node_id' => $node_id
                )
					$DB->execute(
                    'DELETE FROM nv_webdictionary
						WHERE node_id = :id 
						  AND node_type = "global"
						  AND lang = :lang 
						  AND website = :wid
						LIMIT 1',
                        array(
                            ':wid' => $website->id,
                            ':lang' => $language,
                            ':id' => $id
                        )
                    );
						WHERE subtype = :id 
						  AND node_type = "theme"
						  AND theme = :object
						  AND lang = :lang 
						  AND website = :wid
						LIMIT 1',
                        array(
                            ':wid' => $website->id,
                            ':lang' => $language,
                            ':object' => $object,
                            ':id' => $id
                        )
                    );
					$DB->execute(
                    'DELETE FROM nv_webdictionary
						WHERE subtype = :id
						  AND node_type = "extension"
						  AND extension = :object 
						  AND lang = :lang
						  AND website = :wid
						LIMIT 1',
                        array(
                            ':id' => $id,
                            ':object' => $object,
                            ':lang' => $language,
                            ':wid' => $website->id
                        )
                    );
        $DB->query('SELECT * FROM nv_webdictionary WHERE website = '.intval($website->id), 'object');
					if($litem=='<p><br _mce_bogus="1"></p>')
                    {
                        // equals to tinymce empty content, so no need to save it
                        continue;
                    }
					// has the text been changed since the last save?
						'   
						    node_id = :node_id AND
							website = :wid AND
							lang = :lang AND
							subtype = :subtype AND
							node_type = :node_type AND
							autosave = '.(($autosave)? '1' : '0').'
						 ORDER BY date_created DESC',
                        null,
                        array(
                            ':wid' => $website_id,
                            ':node_id' => $node_id,
                            ':lang' => $lang,
                            ':subtype' => $subtype,
                            ':node_type' => $node_type
                        )
								WHERE node_id = :node_id AND
									  website = :wid AND
										 lang = :lang AND
									  subtype = :subtype AND
									node_type = :node_type AND
								 date_created < '.(core_time() - 86400 * 7),
                                array(
                                    ':wid' => $website_id,
                                    ':lang' => $lang,
                                    ':node_id' => $node_id,
                                    ':node_type' => $node_type,
                                    ':subtype' => $subtype
                                )
			 WHERE node_type = :node_type 
			   AND node_id = :node_id
			 ORDER BY date_created ASC',
            'object',
            array(
                ':node_type' => $node_type,
                ':node_id' => $node_id
            )
			WHERE website = '.intval($website->id),
        $DB->query('SELECT * FROM nv_websites WHERE id = '.intval($website->id), 'object');
						 WHERE p.website = :website_id AND
						       p.lang = :lang AND
						            p.path LIKE :text  OR  
									d.text LIKE :text 
						 LIMIT 10',
                        'object',
                        array(
					        ':website_id' => $website->id,
                            ':lang' => $lang,
                            ':text' => '%' . $text . '%'
                        )
                    );
			$DB->query(
			    'SELECT path as id, path as label, path as value
						 WHERE path LIKE :term
						   AND website = :website_id
                'array',
                array(
                    ':website_id' => $_REQUEST['wid'],
                    ':term' => '%'.$_REQUEST['term'].'%'
                ));
				    AND text LIKE "%navigate_download.php%"
        0	=> json_decode('{"code": "", "name": "('.mb_strtolower(t(581, "None")).') ---> 1234567"}'),
             WHERE website = :wid
			   AND object  = :object
               AND object_id = :object_id
		 ',
            'object',
            array(
                ':wid' => $website->id,
                ':object' => $object,
                ':object_id' => $object_id
            )
        );
		$DB->queryLimit(
		    'wuv.id AS id, wuv.date AS date, wuv.webuser AS webuser, wu.username AS username',
			'nv_webuser_votes wuv, nv_webusers wu',
			'	 
			    wuv.website = :wid 
			    AND wuv.object  = :object 
 				AND wuv.object_id = :object_id
				AND wu.id = wuv.webuser',
            $orderby,
            $offset,
            $limit,
            array(
                ':wid' => $website->id,
                ':object' => $object,
                ':object_id' => $object_id
            )
        );
		$from_date = 0;
			$from_date = time() - $since * 24*60*60;
             WHERE website = :wid
			   AND object  = :object
               AND object_id = :object_id 
			   AND date > :from_date
			 ORDER BY date ASC',
            'object',
            array(
                ':wid' => $website->id,
                ':object' => $object,
                ':object_id' => $object_id,
                ':from_date' => $from_date
            )
        );
				 WHERE webuser = :webuser 
				   AND object  = :object
				   AND object_id = :object_id',
        'object',
                array(
                    ':webuser' => $webuser,
                    ':object' => $object,
                    ':object_id' => $object_id
                )
				   SET `value`	=  :value,
						date 	=  :time
				 WHERE id = :wu_vote_id',
                array(
                    ':wu_vote_id' => $webuser_vote_id,
                    ':time' => core_time(),
                    ':value' => $value
                )
			   SET  votes = :votes, 
			        score = :score
			 WHERE id = :object_id',
            array(
                ':votes' => $votes,
                ':score' => $score,
                ':object_id' => $object_id
            )
		$DB->query(
		    'SELECT COUNT(*) as votes, SUM(value) as score
                  FROM nv_webuser_votes
                 WHERE object_id = :object_id
                   AND object = :object
                   AND website = :wid',
            'object',
            array(
                ':wid' => $website->id,
                ':object' => $object,
                ':object_id' => $object_id
            ));
        $DB->query('SELECT * FROM nv_webuser_votes WHERE website = '.intval($website->id), 'object');
        $ok = $DB->query(
            'SELECT * FROM nv_webusers WHERE cookie_hash = :hash',
            'object',
            array(
                ':hash' => $hash
            )
        );

        {
        }
            ' network = :network AND network_user_id = :network_uid',
            null,
            array(
                ':network' => $network,
                ':network_uid' => $network_user_id
            )
        {
        }
			$website_check = 'AND website  = '.intval($website);

		$ok = $DB->query(
		    'SELECT * 
                     FROM nv_webusers 
                    WHERE ( access = 0 OR
                            (access = 2 AND 
                                (access_begin = 0 OR access_begin < '.time().') AND 
                                (access_end = 0 OR access_end > '.time().') 
                            )
                           )
                      '.$website_check.'
                      AND LOWER(username) = :username',
        'object',
            array(
                ':username' => $username
            )
        );

		if($ok)
            'website = :wid AND email = :email',
            null,
            array(
                ':wid' => $website,
                ':email' => $email
            )
			 WHERE email = :email
			   AND activation_key = :hash',
            'object',
            array(
                ':email' => $email,
                ':hash' => $hash
            )
        );
			 WHERE email = :email
			   AND activation_key = :hash',
            'object',
            array(
                ':email' => $email,
                ':hash' => $hash
            )
        );
            ' network = :network AND '.
            ' network_user_id = :network_uid',
            null,
            array(
                ':network' => $network,
                ':network_uid' => $network_user_id
            )
		if($DB->query(
		    'SELECT COUNT(*) as total
                   FROM nv_webusers 
                   WHERE LOWER(username) = :username
                     AND website = :wid',
                array(
                    ':wid' => $website_id,
                    ':username' => $username
                )
            )
        )
                    WHERE website = ' . intval($website->id) . '
            WHERE website = '.intval($website->id), 'array');
        $DB->query('SELECT * FROM nv_webusers WHERE website = '.intval($website->id), 'object');
                      AND nw.website = '.intval($website->id),
                    WHERE website = '.intval($website->id));
                    WHERE website = '.intval($website->id));
                    WHERE website = '.intval($website->id),
            $query_params = array(
                ':wid' => $website->id,
                ':time' => core_time(),
                ':id' => $vars['id']
            );

            {
                $query_type = ' AND type = :type';
                $query_params[':type'] = $vars['type'];
            }
                   AND website = :wid
                   AND (date_published = 0 OR date_published < :time)
                   AND (date_unpublish = 0 OR date_unpublish > :time)
                   AND id = :id',
                'object',
                $query_params
            $query_params = array(
                ':wid' => $website->id,
                ':time' => core_time(),
                ':type' => $vars['type']
            );

                 WHERE type = :type
                   AND website = :wid
                   AND (date_published = 0 OR date_published < :time)
                   AND (date_unpublish = 0 OR date_unpublish > :time)
                ORDER BY position ASC',
                'object',
                $query_params
            );
            $query_params = array(
                ':wid' => $website->id,
                ':time' => core_time(),
                ':type' => $vars['type']
            );

                 WHERE type = :type
                   AND website = :wid
                   AND (date_published = 0 OR date_published < :time)
                   AND (date_unpublish = 0 OR date_unpublish > :time)
              ORDER BY position ASC',
                'object',
                $query_params
            );
            {
                $fixed_rows_ids = array(0);
            }

        	$query_params[':fr_ids'] = implode(",", $fixed_rows_ids);
                 WHERE type = :type
                   AND website = :wid
                   AND (date_published = 0 OR date_published < :time)
                   AND (date_unpublish = 0 OR date_unpublish > :time)
                   AND id NOT IN(:fr_ids)
                 ORDER BY RAND()',
                $query_params
            );
             WHERE nvc.website = :wid 
               AND nvc.object_type = :object_type
               AND nvc.object_id = :object_id 
           OFFSET ' . $offset,
            'object',
            array(
                ':wid' => $website->id,
                ':object_type' => $object_type,
                ':object_id' => $object_id
            )
             WHERE nvc.website = :wid
               AND nvc.object_type = :object_type
               AND nvc.object_id = :object_id 
           OFFSET ' . $offset,
            'object',
            array(
                ':wid' => $website->id,
                ':object_type' => $object_type,
                ':object_id' => $object_id
            )
                                 nvwd.lang = :lang
				 WHERE nvc.website = :wid
			   OFFSET '.$offset,
        array(
            ':wid' => $website->id,
            ':lang' => $current['lang']
        )
    );
                 WHERE i.category IN(:categories)
                   AND i.website = :wid
                   AND (i.date_published = 0 OR i.date_published < :time)
                   AND (i.date_unpublish = 0 OR i.date_unpublish > :time)
                   AND (s.date_published = 0 OR s.date_published < :time)
                   AND (s.date_unpublish = 0 OR s.date_unpublish > :time)
                   AND d.lang = :lang
                 OFFSET 0',
            'object',
                array(
                    ':wid' => $website->id,
                    ':lang' => $current['lang'],
                    ':categories' => implode(",", $categories),
                    ':time' => core_time()
                )
				 WHERE website = :wid
				   AND object_id = :item_id
				   AND status = 0',
                'object',
                array(
                    ':wid' => $website->id,
                    ':item_id' => $item->id
                )
            );
    $background_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.contact.background_color" AND website = '.intval($website->id), 'id DESC');
    $text_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.contact.text_color" AND website = '.intval($website->id), 'id DESC');
    $title_color_db = $DB->query_single('value', 'nv_permissions', 'name = "nvweb.contact.titles_color" AND website = '.intval($website->id), 'id DESC');
				 WHERE website = '.intval($website->id).'
				   AND object_id = '.intval($object_id).'
			   AND d.lang = :lang
        '.$limit,
        'object',
        array(
            ':lang' => $current['lang']
        )
             WHERE category = '.intval($current['object']->id).'
               AND website = '.intval($website->id).'
                                          search_nwdi.website = ' . intval($website->id) . ' AND
                                            search_npi.website = ' . intval($website->id) . ' AND
                                          search_nwdi.website = ' . intval($website->id) . ' AND
                                            search_npi.website = ' . intval($website->id) . ' AND
			 WHERE s.id IN(:categories)
			   AND s.website = :wid
			   AND (s.date_published = 0 OR s.date_published < :time)
			   AND (s.date_unpublish = 0 OR s.date_unpublish > :time)
			   AND d.lang = :lang
			OFFSET '.$offset,
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang'],
                ':time' => core_time(),
                ':categories' => implode(",", $categories)
            )
			 WHERE p.category IN(:categories)
			   AND p.website = :wid
			   AND (s.date_published = 0 OR s.date_published < :time)
			   AND (s.date_unpublish = 0 OR s.date_unpublish > :time)
			   AND d.lang = :lang
        $DB->query(
            $query,
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang'],
                ':time' => core_time(),
                ':categories' => implode(",", $categories)
            )
        );
                     WHERE i.category IN(:categories)
                       AND i.website = :wid
                       AND (i.date_published = 0 OR i.date_published < :time)
                       AND (i.date_unpublish = 0 OR i.date_unpublish > :time)
                       AND (s.date_published = 0 OR s.date_published < :time)
                       AND (s.date_unpublish = 0 OR s.date_unpublish > :time)
                       AND d.lang = :lang                       
                     LIMIT 1',
                    'object',
                    array(
                        ':wid' => $website->id,
                        ':lang' => $current['lang'],
                        ':time' => core_time(),
                        ':categories' => implode(",", $categories)
                    ));
             WHERE website = '.intval($website->id).'
			 WHERE i.category IN(:categories)
			   AND i.website = :wid
			   AND (i.date_published = 0 OR i.date_published < :time)
			   AND (i.date_unpublish = 0 OR i.date_unpublish > :time)
			   AND (s.date_published = 0 OR s.date_published < :time)
			   AND (s.date_unpublish = 0 OR s.date_unpublish > :time)
			   AND d.lang = :lang
		$DB->query(
		    $query,
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang'],
                ':time' => core_time(),
                ':categories' => implode(",", $categories)
            )
        );
    // now we have all elements that will be shown in the list (if any)
    if(empty($rs))
    {
        $rs = array();
    }

                        ' category = '.intval($item->id).' AND
                          website = '.intval($item->website).' AND
                    ');
		                    $email = $DB->query_single('email', 'nv_webusers', 'id = '.intval($item->user));
                            {
                                $gravatar_hash = md5( strtolower( trim( $item->email ) ) );
                            }
								 WHERE category = '.intval($current['category']).'
								   AND website = '.intval($website->id).'
            $last = $DB->query_single('parent', 'nv_structure', ' id = '.intval($last));
		$DB->query(
		    'SELECT node_id, text
                  FROM nv_webdictionary 
                 WHERE node_type = "structure"
                   AND subtype = "title" 
                   AND lang = :lang
                   AND website = :wid',
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang']
            )
        );
		$DB->query(
		    'SELECT object_id, path
                  FROM nv_paths 
                 WHERE type = "structure"
                   AND lang = :lang
                   AND website = :wid',
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang']
            )
        );
			   AND lang = :lang
			   AND website = :wid',
            'object',
            array(
                ':wid' => $website->id,
                ':lang' => $current['lang']
            )
		$DB->query(
		    'SELECT * 
                  FROM nv_structure
                 WHERE parent = '.intval($parent).' 
                   AND website = '.intval($website->id).' 
                  ORDER BY position ASC'
        );
                ' node_type = :type AND
				    node_id = :object_id AND
					subtype = "title" AND
					website = :wid AND
					   lang = :lang',
                null,
                array(
                    ':wid' => $website->id,
                    ':lang' => $current['lang'],
                    ':object_id' => $current['object']->id,
                    ':type' => $current['type']
                )
				 WHERE website = '.intval($website->id).'
				   AND object_id = '.intval($object_id).'
			   AND d.lang = :lang
        '.$limit,
        'object',
        array(
            ':lang' => $current['lang']
        )
					$vars['template'] = $DB->query_single('template', 'nv_items', ' id = '.intval($vars['id']));
                    $vars['type'] = $DB->query_single('type', 'nv_blocks', ' id = '.intval($vars['id']));
				$category_template = $DB->query_single('template', 'nv_structure', ' id = '.intval($vars['id']));
			    $file = $DB->query_single('name', 'nv_files', ' id = '.intval($property->value).' AND website = '.intval($website->id));
                                                    p.website = '.intval($website->id).' AND
			                                p.website = '.intval($website->id).' AND
                   AND wd.website = ' . intval($website->id) . '			  
                   AND d.website = ' . intval($website->id) . '
    $query_params = array(
        ':wid' => $website->id,
        ':lang' => $lang,
        ':types' => implode(',', $types)
    );

    {
        $extra .= ' AND text LIKE :search'; // note: we will need to pass another filter after exploding the tags
        $query_params[':search'] = '%' . $search . '%';
    }
          WHERE website = :wid
            AND node_type IN(:types)
            AND lang = :lang 
        'array',
        $query_params
                    ' website = :wid
					  AND webuser = :webuser_id
					  AND object = :type
					  AND object_id = :object_id',
                    null,
                    array(
                        ':wid' => $website->id,
                        ':webuser_id' => $webuser->id,
                        ':type' => $current['type'],
                        ':object_id' => $current['id']
                    )
                        ' email = :email
                          AND website = :wid',
                        null,
                        array(
                            ':wid' => $website->id,
                            ':email' => $email
                        )
                  website = :wid
                        email = :email OR
                        username = :username
                    )',
                    'object',
                    array(
                        ':wid' => $website->id,
                        ':email' => $email,
                        ':username' => mb_strtolower($username)
                    )
                        ' email = :email
                          AND website = :wid',
                        null,
                        array(
                            ':wid' => $website->id,
                            ':email' => $email
                        )
            ' LOWER(username) = :username AND website = :wid',
            null,
            array(
                ':wid' => $website->id,
                ':username' => $username
            )
            ' LOWER(username) = :email AND website = :wid',
            null,
            array(
                ':wid' => $website->id,
                ':email' => $email
            )
    $nuid = $DB->query_single(
        'id',
        'nv_users',
        'cookie_hash = :cookie_hash',
        NULL,
        array(':cookie_hash' => $_COOKIE['navigate-user'])
    );
// is it a recover password request?
        ' username = :value OR email = :value',
        NULL,
        array(':value' => $value)
            'activation_key = :activation_key',
            NULL,
            array(':activation_key' => $value)
                     WHERE website = '.intval($website->id).'
		 WHERE subdomain = :subdomain
		   AND ( domain = :domain OR domain = :idn_domain ) 
	 ',
        'object',
        array(
            ':subdomain' => $subdomain,
            ':domain' => $domain,
            ':idn_domain' => $idn->encode($domain)
        ));
							 WHERE id = '.intval($current['id']).'
								   WHERE id = '.intval($current['id']).' 
							 WHERE id = '.intval($current['id']).'
								   WHERE id = '.intval($current['id']).' 
				WHERE path = :route AND 
				ORDER BY id DESC',
                'object',
                array(':route' => '/' . $route)
                                            WHERE id = '.intval($current['id']).' 
                                     WHERE id = '.intval($current['id']).'
                                           WHERE id = '.intval($current['id']).' 
                                     WHERE id = '.intval($current['id']).'
                                           WHERE id = '.intval($current['id']).' 
                'website = :website_id
                 AND template = :template_type
                 AND (date_unpublish = 0 OR date_unpublish > '.core_time().')',
                NULL,
                array(
                    ':website_id' => $website->id,
                    ':template_type' => $template_type
                )
                'website = :website_id
                 AND template = :template_type
                 AND (date_unpublish = 0 OR date_unpublish > '.core_time().')',
                NULL,
                array(
                   ':website_id' => $website->id,
                   ':template_type' => $template_type
                )
		' type = :type
		   AND object_id = :object_id
		   AND lang = :lang
		   AND website = '.$website->id,
        NULL,
        array(
            ':type' => $type,
            ':object_id' => $id,
            ':lang' => $lang
        )
				   AND lang = :lang
				   AND theme = :ws_theme 
				   AND lang = :lang
				   AND website = '.$website->id,
        'object',
        array(
            ':lang' => $session['lang'],
            ':ws_theme' => $website->theme,
        )
    );
								   AND lang = :lang
								   AND website = '.$website->id,
                                NULL,
                                array(
                                    ':lang' => $current['lang']
                                )
				 WHERE website = '.intval($website_id).'
					           AND w.text LIKE :category_name
					   )',
                    'object',
                    array(':category_name' => $category_name)
                );