Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for Zend Encoder/SafeGuard & PhpExpress)
- *
- * @ Version : 1.1.6.0
- * @ Author : DeZender
- * @ Release on : 02.06.2013
- * @ Official site : http://DeZender.Net
- *
- */
- class items {
- public $uploadFileDirectory = '';
- public $foundRows = 0;
- public $attributesWhere = '';
- public $attributeCategoriesWhere = '';
- public $usersWhere = '';
- public function __construct() {
- $this->uploadFileDirectory = 'items/';
- }
- public function getAll($start = 0, $limit = 0, $where = '', $order = '`datetime` ASC') {
- global $mysql;
- $limitQuery = '';
- if ($limit != 0) {
- $limitQuery = ( ( ' LIMIT ' . $start . ',' ) . $limit . ' ' );
- }
- if ($where != '') {
- $where = ' WHERE ' . $where;
- }
- $mysql->query( '
- SELECT SQL_CALC_FOUND_ROWS *,
- (SELECT GROUP_CONCAT(`categories` SEPARATOR \'|\') FROM `items_to_category` WHERE `item_id` = `items`.`id`) AS `categories`
- FROM `items`
- ' . $where . '
- ORDER BY ' . $order . '
- ' . $limitQuery . '
- ' );
- if ($mysql->num_rows( ) == 0) {
- return false;
- }
- $this->usersWhere = '';
- $return = array( );
- while ($d = $mysql->fetch_array( )) {
- $categories = explode( '|', $d['categories'] );
- unset( $d['categories'] );
- $d['categories'] = array( );
- $row = 0;
- foreach ($categories as $cat) {
- $categories1 = explode( ',', $cat );
- foreach ($categories1 as $c) {
- $c = trim( $c );
- if ($c != '') {
- $d['categories'][$row][$c] = $c;
- }
- }
- $row++;
- }
- $return[$d['id']] = $d;
- if ($this->usersWhere != '') {
- $this->usersWhere .= ' OR ';
- }
- $this->usersWhere .= ' `user_id` = \'' . intval( $d['user_id'] ) . '\' ';
- }
- $this->foundRows = $mysql->getFoundRows( );
- return $return;
- }
- public function getAllForUpdate($start = 0, $limit = 0, $where = '', $order = '`datetime` ASC') {
- global $mysql;
- $limitQuery = '';
- if ($limit != 0) {
- $limitQuery = ( ( ' LIMIT ' . $start . ',' ) . $limit . ' ' );
- }
- if ($where != '') {
- $where = ' WHERE ' . $where;
- }
- $mysql->query( '
- SELECT SQL_CALC_FOUND_ROWS *
- FROM `temp_items`
- ' . $where . '
- ORDER BY ' . $order . '
- ' . $limitQuery . '
- ' );
- if ($mysql->num_rows( ) == 0) {
- return false;
- }
- $whereQuery = '';
- $return = array( );
- while ($d = $mysql->fetch_array( )) {
- $return[$d['id']] = $d;
- }
- $this->foundRows = $mysql->getFoundRows( );
- return $return;
- }
- public function get($id, $active = false) {
- global $mysql;
- global $meta;
- $percents = 0;
- if (isset( $meta['prepaid_price_discount'] )) {
- $percents = (int)$meta['prepaid_price_discount'];
- }
- $extended_price = 1;
- if (isset( $meta['extended_price'] )) {
- $extended_price = (int)$meta['extended_price'];
- }
- $sql = '
- SELECT *
- FROM `items`
- WHERE `id` = \'' . intval( $id ) . '\'
- ';
- if ($active) {
- $sql .= ' AND `status` = \'active\'';
- }
- $mysql->query( $sql );
- if ($mysql->num_rows( ) == 0) {
- return false;
- }
- $return = $mysql->fetch_array( );
- if (strpos( $percents, '%' ) !== false) {
- $return['prepaid_price'] = $return['price'] - $return['price'] / 100 * (int)$percents;
- $return['your_profit'] = (int)$return['price'] / 100 * (int)$percents;
- } else {
- $return['prepaid_price'] = $return['price'] - (int)$percents;
- $return['your_profit'] = (int)$percents;
- }
- $return['extended_price'] = $return['price'] * $extended_price;
- $mysql->query( '
- SELECT
- *
- FROM
- `items_to_category`
- WHERE
- `item_id` = \'' . intval( $id ) . '\'
- ' );
- $return['categories'] = array( );
- if (0 < $mysql->num_rows( )) {
- $row = 0;
- while ($ca = $mysql->fetch_array( )) {
- $categories = explode( ',', $ca['categories'] );
- foreach ($categories as $c) {
- $c = trim( $c );
- if ($c != '') {
- $return['categories'][$row][$c] = $c;
- }
- }
- $row++;
- }
- }
- $mysql->query( '
- SELECT *
- FROM `items_tags` AS it
- JOIN `tags` AS t
- ON t.`id` = it.`tag_id`
- WHERE it.`item_id` = \'' . intval( $id ) . '\'
- ' );
- if (0 < $mysql->num_rows( )) {
- while ($d = $mysql->fetch_array( )) {
- $return['tags'][$d['type']][$d['tag_id']] = $d['name'];
- }
- }
- $mysql->query( '
- SELECT *
- FROM `items_attributes`
- WHERE `item_id` = \'' . intval( $id ) . '\'
- ' );
- if (0 < $mysql->num_rows( )) {
- while ($d = $mysql->fetch_array( )) {
- if (isset( $return['attributes'][$d['category_id']] )) {
- if (!is_array( $return['attributes'][$d['category_id']] )) {
- $val = $return['attributes'][$d['category_id']];
- unset( $return['attributes'][$d['category_id']] );
- $return['attributes'][$d['category_id']][$val] = $val;
- }
- $return['attributes'][$d['category_id']][$d['attribute_id']] = $d['attribute_id'];
- if ($this->attributesWhere != '') {
- $this->attributesWhere .= ' OR ';
- }
- $this->attributesWhere .= ' `id` = \'' . intval( $d['attribute_id'] ) . '\' ';
- } else {
- $return['attributes'][$d['category_id']] = $d['attribute_id'];
- if ($this->attributeCategoriesWhere != '') {
- $this->attributeCategoriesWhere .= ' OR ';
- }
- $this->attributeCategoriesWhere .= ' `id` = \'' . intval( $d['category_id'] ) . '\' ';
- if ($this->attributesWhere != '') {
- $this->attributesWhere .= ' OR ';
- }
- $this->attributesWhere .= ' `id` = \'' . intval( $d['attribute_id'] ) . '\' ';
- }
- }
- }
- return $return;
- }
- public function getForUpdate($id) {
- global $mysql;
- $mysql->query( '
- SELECT *
- FROM `temp_items`
- WHERE `id` = \'' . intval( $id ) . '\'
- ' );
- if ($mysql->num_rows( ) == 0) {
- return false;
- }
- $return = $mysql->fetch_array( );
- $mysql->query( '
- SELECT *
- FROM `temp_items_tags` AS it
- JOIN `tags` AS t
- ON t.`id` = it.`tag_id`
- WHERE it.`item_id` = \'' . intval( $return['item_id'] ) . '\'
- ' );
- if (0 < $mysql->num_rows( )) {
- while ($d = $mysql->fetch_array( )) {
- $return['tags'][$d['type']][$d['tag_id']] = $d['name'];
- .........................................................................
- ....................................
- .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement