Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.50 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for Zend Encoder/SafeGuard & PhpExpress)
  6. *
  7. * @ Version : 1.1.6.0
  8. * @ Author : DeZender
  9. * @ Release on : 02.06.2013
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class items {
  15. public $uploadFileDirectory = '';
  16. public $foundRows = 0;
  17. public $attributesWhere = '';
  18. public $attributeCategoriesWhere = '';
  19. public $usersWhere = '';
  20.  
  21. public function __construct() {
  22. $this->uploadFileDirectory = 'items/';
  23. }
  24.  
  25. public function getAll($start = 0, $limit = 0, $where = '', $order = '`datetime` ASC') {
  26. global $mysql;
  27.  
  28. $limitQuery = '';
  29.  
  30. if ($limit != 0) {
  31. $limitQuery = ( ( ' LIMIT ' . $start . ',' ) . $limit . ' ' );
  32. }
  33.  
  34.  
  35. if ($where != '') {
  36. $where = ' WHERE ' . $where;
  37. }
  38.  
  39. $mysql->query( '
  40. SELECT SQL_CALC_FOUND_ROWS *,
  41. (SELECT GROUP_CONCAT(`categories` SEPARATOR \'|\') FROM `items_to_category` WHERE `item_id` = `items`.`id`) AS `categories`
  42. FROM `items`
  43. ' . $where . '
  44. ORDER BY ' . $order . '
  45. ' . $limitQuery . '
  46. ' );
  47.  
  48. if ($mysql->num_rows( ) == 0) {
  49. return false;
  50. }
  51.  
  52. $this->usersWhere = '';
  53. $return = array( );
  54.  
  55. while ($d = $mysql->fetch_array( )) {
  56. $categories = explode( '|', $d['categories'] );
  57. unset( $d['categories'] );
  58. $d['categories'] = array( );
  59. $row = 0;
  60. foreach ($categories as $cat) {
  61. $categories1 = explode( ',', $cat );
  62. foreach ($categories1 as $c) {
  63. $c = trim( $c );
  64.  
  65. if ($c != '') {
  66. $d['categories'][$row][$c] = $c;
  67. }
  68. }
  69.  
  70. $row++;
  71. }
  72.  
  73. $return[$d['id']] = $d;
  74.  
  75. if ($this->usersWhere != '') {
  76. $this->usersWhere .= ' OR ';
  77. }
  78.  
  79. $this->usersWhere .= ' `user_id` = \'' . intval( $d['user_id'] ) . '\' ';
  80. }
  81.  
  82. $this->foundRows = $mysql->getFoundRows( );
  83. return $return;
  84. }
  85.  
  86. public function getAllForUpdate($start = 0, $limit = 0, $where = '', $order = '`datetime` ASC') {
  87. global $mysql;
  88.  
  89. $limitQuery = '';
  90.  
  91. if ($limit != 0) {
  92. $limitQuery = ( ( ' LIMIT ' . $start . ',' ) . $limit . ' ' );
  93. }
  94.  
  95.  
  96. if ($where != '') {
  97. $where = ' WHERE ' . $where;
  98. }
  99.  
  100. $mysql->query( '
  101. SELECT SQL_CALC_FOUND_ROWS *
  102. FROM `temp_items`
  103. ' . $where . '
  104. ORDER BY ' . $order . '
  105. ' . $limitQuery . '
  106. ' );
  107.  
  108. if ($mysql->num_rows( ) == 0) {
  109. return false;
  110. }
  111.  
  112. $whereQuery = '';
  113. $return = array( );
  114.  
  115. while ($d = $mysql->fetch_array( )) {
  116. $return[$d['id']] = $d;
  117. }
  118.  
  119. $this->foundRows = $mysql->getFoundRows( );
  120. return $return;
  121. }
  122.  
  123. public function get($id, $active = false) {
  124. global $mysql;
  125. global $meta;
  126.  
  127. $percents = 0;
  128.  
  129. if (isset( $meta['prepaid_price_discount'] )) {
  130. $percents = (int)$meta['prepaid_price_discount'];
  131. }
  132.  
  133. $extended_price = 1;
  134.  
  135. if (isset( $meta['extended_price'] )) {
  136. $extended_price = (int)$meta['extended_price'];
  137. }
  138.  
  139. $sql = '
  140. SELECT *
  141. FROM `items`
  142. WHERE `id` = \'' . intval( $id ) . '\'
  143. ';
  144.  
  145. if ($active) {
  146. $sql .= ' AND `status` = \'active\'';
  147. }
  148.  
  149. $mysql->query( $sql );
  150.  
  151. if ($mysql->num_rows( ) == 0) {
  152. return false;
  153. }
  154.  
  155. $return = $mysql->fetch_array( );
  156.  
  157. if (strpos( $percents, '%' ) !== false) {
  158. $return['prepaid_price'] = $return['price'] - $return['price'] / 100 * (int)$percents;
  159. $return['your_profit'] = (int)$return['price'] / 100 * (int)$percents;
  160. } else {
  161. $return['prepaid_price'] = $return['price'] - (int)$percents;
  162. $return['your_profit'] = (int)$percents;
  163. }
  164.  
  165. $return['extended_price'] = $return['price'] * $extended_price;
  166. $mysql->query( '
  167. SELECT
  168. *
  169. FROM
  170. `items_to_category`
  171. WHERE
  172. `item_id` = \'' . intval( $id ) . '\'
  173. ' );
  174. $return['categories'] = array( );
  175.  
  176. if (0 < $mysql->num_rows( )) {
  177. $row = 0;
  178.  
  179. while ($ca = $mysql->fetch_array( )) {
  180. $categories = explode( ',', $ca['categories'] );
  181. foreach ($categories as $c) {
  182. $c = trim( $c );
  183.  
  184. if ($c != '') {
  185. $return['categories'][$row][$c] = $c;
  186. }
  187. }
  188.  
  189. $row++;
  190. }
  191. }
  192.  
  193. $mysql->query( '
  194. SELECT *
  195. FROM `items_tags` AS it
  196. JOIN `tags` AS t
  197. ON t.`id` = it.`tag_id`
  198. WHERE it.`item_id` = \'' . intval( $id ) . '\'
  199. ' );
  200.  
  201. if (0 < $mysql->num_rows( )) {
  202. while ($d = $mysql->fetch_array( )) {
  203. $return['tags'][$d['type']][$d['tag_id']] = $d['name'];
  204. }
  205. }
  206.  
  207. $mysql->query( '
  208. SELECT *
  209. FROM `items_attributes`
  210. WHERE `item_id` = \'' . intval( $id ) . '\'
  211. ' );
  212.  
  213. if (0 < $mysql->num_rows( )) {
  214. while ($d = $mysql->fetch_array( )) {
  215. if (isset( $return['attributes'][$d['category_id']] )) {
  216. if (!is_array( $return['attributes'][$d['category_id']] )) {
  217. $val = $return['attributes'][$d['category_id']];
  218. unset( $return['attributes'][$d['category_id']] );
  219. $return['attributes'][$d['category_id']][$val] = $val;
  220. }
  221.  
  222. $return['attributes'][$d['category_id']][$d['attribute_id']] = $d['attribute_id'];
  223.  
  224. if ($this->attributesWhere != '') {
  225. $this->attributesWhere .= ' OR ';
  226. }
  227.  
  228. $this->attributesWhere .= ' `id` = \'' . intval( $d['attribute_id'] ) . '\' ';
  229. } else {
  230. $return['attributes'][$d['category_id']] = $d['attribute_id'];
  231.  
  232. if ($this->attributeCategoriesWhere != '') {
  233. $this->attributeCategoriesWhere .= ' OR ';
  234. }
  235.  
  236. $this->attributeCategoriesWhere .= ' `id` = \'' . intval( $d['category_id'] ) . '\' ';
  237.  
  238. if ($this->attributesWhere != '') {
  239. $this->attributesWhere .= ' OR ';
  240. }
  241.  
  242. $this->attributesWhere .= ' `id` = \'' . intval( $d['attribute_id'] ) . '\' ';
  243. }
  244. }
  245. }
  246.  
  247. return $return;
  248. }
  249.  
  250. public function getForUpdate($id) {
  251. global $mysql;
  252.  
  253. $mysql->query( '
  254. SELECT *
  255. FROM `temp_items`
  256. WHERE `id` = \'' . intval( $id ) . '\'
  257. ' );
  258.  
  259. if ($mysql->num_rows( ) == 0) {
  260. return false;
  261. }
  262.  
  263. $return = $mysql->fetch_array( );
  264. $mysql->query( '
  265. SELECT *
  266. FROM `temp_items_tags` AS it
  267. JOIN `tags` AS t
  268. ON t.`id` = it.`tag_id`
  269. WHERE it.`item_id` = \'' . intval( $return['item_id'] ) . '\'
  270. ' );
  271.  
  272. if (0 < $mysql->num_rows( )) {
  273. while ($d = $mysql->fetch_array( )) {
  274. $return['tags'][$d['type']][$d['tag_id']] = $d['name'];
  275. .........................................................................
  276. ....................................
  277. .............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement