PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-shopping-cart/display-items.php

http://cartonbank.googlecode.com/
PHP | 1189 lines | 937 code | 163 blank | 89 comment | 216 complexity | 39d0773d488d2d2652cc63ce0566d9e4 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, LGPL-2.1, AGPL-1.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <style>
  2. .tdc2{
  3. text-align:center;
  4. line-height:1em;
  5. background-color:#FFFFFF;
  6. padding:2px;
  7. }
  8. td.r{
  9. text-align: right;
  10. vertical-align: top;
  11. width: 150px;
  12. }
  13. td.ralt{
  14. text-align: right;
  15. background-color:#FFFF00;
  16. vertical-align: top;
  17. }
  18. td.lalt{
  19. text-align: left;
  20. background-color:#FFFF00;
  21. vertical-align: top;
  22. }
  23. </style>
  24. <?php
  25. // Filter for authors
  26. // pokazh($current_user->wp_capabilities['author'],"wp_capabilities"); // ?????
  27. // pokazh($current_user->wp_capabilities['administrator'],"wp_capabilities"); ?????
  28. global $user_brand;
  29. $_SITEURL = get_option('siteurl');
  30. if (isset($current_user->ID) && is_numeric($current_user->ID))
  31. {
  32. $user_id = $current_user->ID;
  33. $sql = "SELECT * FROM `wp_product_brands` where user_id=".$user_id;
  34. $user_brand = $wpdb->get_results($sql,ARRAY_A);
  35. }
  36. if (isset($user_brand[0]['id']))
  37. {
  38. $user_brand = $user_brand[0]['id'];
  39. }
  40. else
  41. {
  42. $user_brand = 0;
  43. }
  44. $author_group_sql = " AND `wp_product_list`.`brand` = '".$user_brand."' ";
  45. if (isset($current_user->wp_capabilities['administrator']))
  46. {
  47. $author_group_sql = "";
  48. }
  49. if (isset($current_user->wp_capabilities['editor']))
  50. {
  51. $author_group_sql = "";
  52. }
  53. $category_data = null;
  54. $basepath = str_replace("/wp-admin", "" , getcwd());
  55. $basepath = str_replace("\\wp-admin", "" , $basepath);
  56. $imagedir = $basepath."/wp-content/plugins/wp-shopping-cart/images/";
  57. $product_images = $basepath."/wp-content/plugins/wp-shopping-cart/product_images/";
  58. $filedir = $basepath."/wp-content/plugins/wp-shopping-cart/files/";
  59. $preview_clips_dir = $basepath."/wp-content/plugins/wp-shopping-cart/preview_clips/";
  60. $image = '';
  61. global $authors;
  62. // update preview
  63. if (isset($_GET['updateimage']))
  64. {
  65. $id = $_GET['updateimage'];
  66. $fileid_data = $wpdb->get_results("SELECT `file` FROM `wp_product_list` WHERE `id` = '$id' LIMIT 1",ARRAY_A);
  67. $fileid = $fileid_data[0]['file'];
  68. $file_data = $wpdb->get_results("SELECT * FROM `wp_product_files` WHERE `id` = '$fileid' LIMIT 1",ARRAY_A);
  69. $idhash = $file_data[0]['idhash'];
  70. if (file_exists($filedir.$idhash))
  71. {
  72. $mimetype = $file_data[0]['mimetype'];
  73. $filename = $file_data[0]['filename'];
  74. $height = get_option('product_image_height');
  75. $width = get_option('product_image_width');
  76. $imagedir = $basepath."/wp-content/plugins/wp-shopping-cart/images/";
  77. $product_images = $basepath."/wp-content/plugins/wp-shopping-cart/product_images/";
  78. $filedir = $basepath."/wp-content/plugins/wp-shopping-cart/files/";
  79. copy($filedir.$idhash, $imagedir.$filename); // icon
  80. copy($filedir.$idhash, $product_images.$filename); // preview
  81. $imgsize = getimagesize($product_images.$filename);
  82. $file_w = $imgsize[0];
  83. $file_h = $imgsize[1];
  84. //ales here we replace slides to that from LG
  85. $chwidth = get_option('lg_pictwidth'); // crop size
  86. $chheight = get_option('lg_pictheight'); // crop size
  87. //$thatdir = $product_images; //destination dir
  88. $ifolder = ''; //subfolder for artist
  89. $file = $filename; //
  90. $resample_quality = 100; //image quality
  91. // slide
  92. al_create_resized_file($chwidth, $chheight, $product_images, $ifolder, $file, $resample_quality);
  93. // watremark
  94. $wm = $basepath."/img/watermark.png";
  95. wtrmark($product_images.$file,$wm);
  96. // icon
  97. al_create_cropped_file(140, 140, $imagedir, $ifolder, $file, $resample_quality);
  98. }
  99. else
  100. {
  101. echo "<div class='error'><b>WARNING:</b> original file is not found at: ".$filedir.$idhash." <br /></div>";
  102. }
  103. }
  104. // add product
  105. if(isset($_POST['submit_action']) && $_POST['submit_action'] == 'add') {
  106. if($_FILES['file']['name'] != null) {
  107. //upload_and_resize_and_watermark_images();
  108. //transliterate file
  109. $_FILES['file']['name'] = rus2translit($_FILES['file']['name']);
  110. //rename the file
  111. $_FILES['file']['name'] = uniqid('', true).$_FILES['file']['name'];
  112. //ales default upload
  113. if(!is_dir($product_images))
  114. {
  115. mkdir($product_images);
  116. }
  117. if(function_exists("getimagesize"))
  118. {
  119. switch(isset($_POST['image_resize']) && $_POST['image_resize'])
  120. {
  121. case 2:
  122. $height = $_POST['height'];
  123. $width = $_POST['width'];
  124. break;
  125. default:
  126. $height = get_option('product_image_height');
  127. $width = get_option('product_image_width');
  128. break;
  129. }
  130. copy($_FILES['file']['tmp_name'], $product_images.$_FILES['file']['name']);
  131. copy($_FILES['file']['tmp_name'], $imagedir.$_FILES['file']['name']);
  132. $imgsize = getimagesize($product_images.$_FILES['file']['name']);
  133. $file_w = $imgsize[0];
  134. $file_h = $imgsize[1];
  135. //ales here we replace slides to that from LG
  136. $chwidth = get_option('lg_pictwidth'); // crop size
  137. $chheight = get_option('lg_pictheight'); // crop size
  138. $thatdir = $product_images; //destination dir
  139. $ifolder = ''; //subfolder for artist
  140. $file = $_FILES['file']['name']; //
  141. $resample_quality = 100; //image quality
  142. al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
  143. $wm = $basepath."/wp-content/plugins/wp-shopping-cart/images/watermark.png";
  144. wtrmark($thatdir.$file,$wm);
  145. // ales here we replace thumbs to that from LG
  146. $chwidth = $width; // crop size
  147. $chheight = $height; // crop size
  148. $thatdir = $imagedir; //destination dir
  149. al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
  150. $image = $wpdb->escape($_FILES['file']['name']);
  151. /// ales
  152. }
  153. else {
  154. move_uploaded_file($_FILES['file']['tmp_name'], ($imagedir.$_FILES['file']['name']));
  155. $image = $wpdb->escape($_FILES['file']['name']);
  156. }
  157. ///ales
  158. $timestamp = time();
  159. $wpdb->query("INSERT INTO `wp_product_files` ( `id` , `filename` , `mimetype` , `idhash` , `date` , `width`, `height`) VALUES ( '' , '', '', '', '$timestamp', '', '');");
  160. $fileid_raw = $wpdb->get_results("SELECT `id` FROM `wp_product_files` WHERE `date` = '$timestamp'",ARRAY_A);
  161. $fileid = $fileid_raw[0]['id'];
  162. $idhash = sha1($fileid);
  163. $mimetype = $_FILES['file']['type'];
  164. $splitname = explode(".",$_FILES['file']['name']);
  165. $splitname = array_reverse($splitname);
  166. $filename = $_FILES['file']['name'];
  167. if(move_uploaded_file($_FILES['file']['tmp_name'],($filedir.$idhash)))
  168. {
  169. $wpdb->query("UPDATE `wp_product_files` SET `filename` = '".$filename."', `mimetype` = '$mimetype', `idhash` = '$idhash', `width` = '$file_w', `height` = '$file_h' WHERE `id` = '$fileid' LIMIT 1");
  170. }
  171. $file = $fileid;
  172. }
  173. else
  174. {
  175. $file = '0';
  176. }
  177. if(isset($_POST['display_frontpage']) && $_POST['display_frontpage'] == "yes")
  178. {
  179. $display_frontpage = 1;
  180. }
  181. else
  182. {
  183. $display_frontpage = 0;
  184. }
  185. $temadnya = '0';
  186. $visible = '0';
  187. $approved = Null;
  188. if (isset($_POST['temadnya']) && $_POST['temadnya'] == 'on')
  189. {$temadnya = '1';} else {$temadnya = '0';}
  190. if (isset($_POST['approved']) && $_POST['approved'] == 'on')
  191. {$approved = '1';} else {$approved = '0';}
  192. if (isset($_POST['visible']) && $_POST['visible'] == 'on')
  193. $visible = '1';
  194. if (isset($_POST['colored']) && $_POST['colored'] == 'on'){$colored = '1'; }
  195. else{$colored="0";}
  196. if (isset($_POST['not_for_sale']) && $_POST['not_for_sale'] == 'on'){$not_for_sale = '1'; }
  197. else{$not_for_sale="0";}
  198. if (isset($_POST['portfolio']) && $_POST['portfolio'] == 'on'){$portfolio = '1'; }
  199. else{$portfolio="0";}
  200. if (isset($_POST['license1']) && $_POST['license1'] == 'on'){$license1 = '1'; }
  201. else{$license1="0";}
  202. if (isset($_POST['license2']) && $_POST['license2'] == 'on'){$license2 = '1'; }
  203. else{$license2="0";}
  204. if (isset($_POST['license3']) && $_POST['license3'] == 'on'){$license3 = '1'; }
  205. else{$license3="0";}
  206. // TODO: take it off to the SQL table
  207. // License prices
  208. // Category group 1
  209. $l1_price_cat1_default = 250;
  210. $l2_price_cat1_default = 500;
  211. $l3_price_cat1_default = 2500;
  212. // Category group 2
  213. $l1_price_cat2_default = 250;
  214. $l2_price_cat2_default = 500;
  215. $l3_price_cat2_default = 2500;
  216. //UPDATE `wp_product_list` SET l1_price = 200 WHERE id in (SELECT product_id from `wp_item_category_associations` WHERE category_id in (4,14,5,11));
  217. $category_id = $wpdb->escape($_POST['category'][0]);
  218. /*
  219. pokazh($category_id,"category_id");
  220. pokazh($_POST['category'],"_POST['category']");
  221. */
  222. switch($category_id)
  223. {
  224. case 4:
  225. case 14:
  226. case 5:
  227. case 11:
  228. $l1_price = $l1_price_cat1_default;
  229. $l2_price = $l2_price_cat1_default;
  230. $l3_price = $l3_price_cat1_default;
  231. break;
  232. case 13:
  233. case 8:
  234. case 15:
  235. case 6:
  236. $l1_price = $l1_price_cat2_default;
  237. $l2_price = $l2_price_cat2_default;
  238. $l3_price = $l3_price_cat2_default;
  239. break;
  240. default:
  241. $l1_price = $l1_price_cat1_default;
  242. $l2_price = $l2_price_cat1_default;
  243. $l3_price = $l3_price_cat1_default;
  244. break;
  245. }
  246. // unset not available licences
  247. if (!isset($license1)||$license1=='0'){$l1_price = '0';}
  248. if (!isset($license2)||$license2=='0'){$l2_price = '0';}
  249. if (!isset($license3)||$license3=='0'){$l3_price = '0';}
  250. if (isset($_POST['brand']) && is_numeric($_POST['brand']))
  251. {$_brand = $wpdb->escape($_POST['brand']);}
  252. else {$_brand = $user_brand;}
  253. $insertsql = "INSERT INTO `wp_product_list` ( `id`, `name`, `description`, `additional_description`, `file` , `image` , `category`, `brand`, `display_frontpage`, `visible`, `approved`, `color`, `not_for_sale`, `l1_price`, `l2_price`, `l3_price`) VALUES ('', '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."', '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."', '".$wpdb->escape(correct_comma(removeCrLf(htmlspecialchars($_POST['additional_description']))))."','".$file."', '".$image."', '".$category_id."', '".$_brand."', '$display_frontpage', '$visible', NULL, '$colored', '$not_for_sale', $l1_price, $l2_price, $l3_price);";
  254. // To send HTML mail, the Content-type header must be set
  255. $headers = 'MIME-Version: 1.0' . "\r\n";
  256. $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  257. $headers .= 'From: CartoonBank Robot <cartoonbank.ru@gmail.com>' . "\r\n";
  258. //mail($to, $subject, $message, $headers);
  259. //mail("igor.aleshin@gmail.com","new cartoon added",print_r($insertsql,true),$headers);
  260. if($wpdb->query($insertsql))
  261. {
  262. $new_id = mysql_insert_id();
  263. $product_id = $new_id;
  264. //mail("igor.aleshin@gmail.com","????????? ???????? ".$new_id,$new_id);
  265. $sql_purgery = "insert into al_editors_votes (image_id, up, down) values ('".$new_id."','0','0')";
  266. $wpdb->query($sql_purgery);
  267. if (get_option('editors_notification_send')=='1')
  268. {
  269. // aleshin
  270. $Current_ID = 16;
  271. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  272. mail("igor.aleshin@gmail.com","????? ???????? ? ????????!",$votecontent,$headers);
  273. // bogorad
  274. $Current_ID = 11;
  275. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  276. mail("vbogorad@mail.ru","????? ???????? ? ????????!",$votecontent,$headers);
  277. // shilov
  278. $Current_ID = 21;
  279. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  280. mail("vfshilov@gmail.com","????? ???????? ? ????????!",$votecontent,$headers);
  281. // popov
  282. $Current_ID = 90;
  283. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  284. mail("popov.a.a@bk.ru","????? ???????? ? ????????!",$votecontent,$headers);
  285. // alexandrov
  286. $Current_ID = 2;
  287. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  288. mail("Alexandrov_Vasil@mail.ru","????? ???????? ? ????????!",$votecontent,$headers);
  289. // elkin
  290. $Current_ID = 38;
  291. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  292. mail("elkin99@yandex.ru","????? ???????? ? ????????!",$votecontent,$headers);
  293. // stepanov
  294. $Current_ID = 62;
  295. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  296. mail("stevladimir@yandex.ru","????? ???????? ? ????????!",$votecontent,$headers);
  297. // sergeev
  298. $Current_ID = 28;
  299. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  300. mail("aserg48@gmail.com","????? ???????? ? ????????!",$votecontent,$headers);
  301. // smagin
  302. $Current_ID = 23;
  303. $votecontent = "<html><head><title>Please vote!</title></head><body><a href='".$_SITEURL."/wp-admin/admin.php?page=purgatory/purgatory.php'>?????? ? ????????</a><br /><b>".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['name'])))."</b><br />".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."<br />[".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['additional_description'])))."]<br /><img src='".$_SITEURL."/wp-content/plugins/wp-shopping-cart/product_images/".$image."'> <br /><br /> <div> ???????????? ?? ???????:<br/> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=5' target='_blank'>5 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=4' target='_blank'>4 - ??????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=3' target='_blank'>3 - ???????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=2' target='_blank'>2 - ?????</a> <a style='display:block;padding:4px;margin:4px;size:24px;' href='".$_SITEURL."/wp-content/plugins/purgatory/moder_vote.php?ip=".$Current_ID."&id=".$new_id."&vote=1' target='_blank'>1 - ?????</a> </div> </body></html>";
  304. mail("m_smagin@mail.ru","????? ???????? ? ????????!",$votecontent,$headers);
  305. }
  306. if(isset ($_FILES['extra_image']) && ($_FILES['extra_image'] != null) && function_exists('edit_submit_extra_images'))
  307. {
  308. $var = edit_submit_extra_images($product_id);
  309. }
  310. $variations_procesor = new nzshpcrt_variations;
  311. if(isset($_POST['variation_values']) && $_POST['variation_values'] != null)
  312. {
  313. $variations_procesor->add_to_existing_product($product_id,$_POST['variation_values']);
  314. }
  315. $counter = 0;
  316. $item_list = '';
  317. if(count($_POST['category']) > 0)
  318. {
  319. foreach($_POST['category'] as $category_id)
  320. {
  321. $sql_delete = "DELETE `wp_item_category_associations`.* FROM `wp_item_category_associations` WHERE `product_id` = '".$product_id."'";
  322. $wpdb->query($sql_delete);
  323. $wpdb->query("INSERT INTO `wp_item_category_associations` ( `id` , `product_id` , `category_id` ) VALUES ('', '".$product_id."', '".$category_id."');");
  324. }
  325. }
  326. else
  327. {
  328. $default_cat = get_option('default_category');
  329. $check_existing = $wpdb->get_var("SELECT `id` FROM `wp_item_category_associations` WHERE `product_id` = ".$product_id." LIMIT 1");
  330. if($check_existing == null)
  331. {
  332. $wpdb->query("INSERT INTO `wp_item_category_associations` ( `id` , `product_id` , `category_id` ) VALUES ('', '".$product_id."', '".$default_cat."');");
  333. }
  334. }
  335. // insert temadnya
  336. if ($temadnya == '1') // insert category 777
  337. {
  338. $sql_temadnya = "insert into `wp_item_category_associations` (product_id, category_id) values ('".$product_id."','777')";
  339. $res = $wpdb->query($sql_temadnya);
  340. }
  341. $display_added_product = "filleditform(".$product_id.");";
  342. echo "<div class='updated'><p align='center'>???? ????????</p></div>";
  343. }
  344. else
  345. {
  346. echo "<div class='updated'><p align='center'>???? ?? ????????!</p></div>";
  347. }
  348. }
  349. if(isset($_GET['submit_action']) && $_GET['submit_action'] == "remove_set")
  350. {
  351. if(is_numeric($_GET['product_id']) && is_numeric($_GET['variation_assoc_id']))
  352. {
  353. $product_id = $_GET['product_id'];
  354. $variation_assoc_id = $_GET['variation_assoc_id'];
  355. $variation_association = $wpdb->get_results("SELECT * FROM `wp_variation_associations` WHERE `id` = '$variation_assoc_id' LIMIT 1",ARRAY_A);
  356. if($variation_association != null)
  357. {
  358. $variation_association = $variation_association[0];
  359. $variation_id = $variation_association['variation_id'];
  360. $delete_variation_sql = "DELETE FROM `wp_variation_associations` WHERE `id` = '$variation_assoc_id' LIMIT 1";
  361. $delete_value_sql = "DELETE FROM `wp_variation_values_associations` WHERE `product_id` = '$product_id' AND `variation_id` = '$variation_id'";
  362. $wpdb->query($delete_variation_sql);
  363. $wpdb->query($delete_value_sql);
  364. echo "<div class='updated'><p align='center'>".TXT_WPSC_PRODUCTHASBEENEDITED."</p></div>";
  365. }
  366. }
  367. }
  368. // edit product
  369. if(isset($_POST['submit_action']) && $_POST['submit_action'] == "edit")
  370. {
  371. //transliterate file
  372. $_FILES['file']['name'] = rus2translit($_FILES['file']['name']);
  373. //rename the file
  374. $_FILES['file']['name'] = uniqid('', true).$_FILES['file']['name'];
  375. $id = $_POST['prodid'];
  376. if(function_exists('edit_submit_extra_images'))
  377. {
  378. if(($_FILES['extra_image'] != null))
  379. {
  380. $var = edit_submit_extra_images($id);
  381. }
  382. }
  383. if(function_exists('edit_extra_images'))
  384. {
  385. $var = edit_extra_images($id);
  386. }
  387. //$basepath = str_replace("/wp-admin", "" , getcwd()); this defined at the top of the page
  388. $imagedir = $basepath."/wp-content/plugins/wp-shopping-cart/images/";
  389. $product_images = $basepath."/wp-content/plugins/wp-shopping-cart/product_images/";
  390. $filedir = $basepath."/wp-content/plugins/wp-shopping-cart/files/";
  391. $preview_clips_dir = $basepath."/wp-content/plugins/wp-shopping-cart/preview_clips/";
  392. if(($_FILES['file']['tmp_name'] != null) && ($_FILES['file']['name'] != null))
  393. {
  394. $id = $_POST['prodid'];
  395. $fileid_data = $wpdb->get_results("SELECT `file` FROM `wp_product_list` WHERE `id` = '$id' LIMIT 1",ARRAY_A);
  396. $fileid = $fileid_data[0]['file'];
  397. $file_data = $wpdb->get_results("SELECT `id`,`idhash` FROM `wp_product_files` WHERE `id` = '$fileid' LIMIT 1",ARRAY_A);
  398. $idhash = $file_data[0]['idhash'];
  399. $mimetype = $_FILES['file']['type'];
  400. $filename = $_FILES['file']['name'];
  401. if(!is_dir($product_images))
  402. {
  403. mkdir($product_images);
  404. }
  405. if(function_exists("getimagesize"))
  406. {
  407. switch(isset ($_POST['image_resize']) && $_POST['image_resize'])
  408. {
  409. case 2:
  410. $height = $_POST['height'];
  411. $width = $_POST['width'];
  412. break;
  413. default:
  414. $height = get_option('product_image_height');
  415. $width = get_option('product_image_width');
  416. break;
  417. }
  418. copy($_FILES['file']['tmp_name'], $product_images.$_FILES['file']['name']);
  419. copy($_FILES['file']['tmp_name'], $imagedir.$_FILES['file']['name']);
  420. $imgsize = getimagesize($product_images.$_FILES['file']['name']);
  421. $file_w = $imgsize[0];
  422. $file_h = $imgsize[1];
  423. //ales here we replace slides to that from LG
  424. $chwidth = get_option('lg_pictwidth'); // crop size
  425. $chheight = get_option('lg_pictheight'); // crop size
  426. $thatdir = $product_images; //destination dir
  427. $ifolder = ''; //subfolder for artist
  428. $file = $_FILES['file']['name']; //
  429. $resample_quality = 100; //image quality
  430. al_create_resized_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
  431. $wm = $basepath."/wp-content/plugins/wp-shopping-cart/images/watermark.png";
  432. wtrmark($thatdir.$file,$wm);
  433. // ales here we replace thumbs to that from LG
  434. $chwidth = $width; // crop size
  435. $chheight = $height; // crop size
  436. $thatdir = $imagedir; //destination dir
  437. al_create_cropped_file($chwidth, $chheight, $thatdir, $ifolder, $file, $resample_quality);
  438. $image = $wpdb->escape($_FILES['file']['name']);
  439. /// ales
  440. }
  441. else {
  442. move_uploaded_file($_FILES['file']['tmp_name'], ($imagedir.$_FILES['file']['name']));
  443. $image = $wpdb->escape($_FILES['file']['name']);
  444. }
  445. //include("image_processing.php");
  446. if(move_uploaded_file($_FILES['file']['tmp_name'],($filedir.$idhash)))
  447. {
  448. $wpdb->query("UPDATE `wp_product_files` SET `filename` = '".$filename."', `mimetype` = '$mimetype', `width` = '$file_w', `height` = '$file_h' WHERE `id` = '".$file_data[0]['id']."' LIMIT 1");
  449. }
  450. }
  451. if(is_numeric($_POST['prodid']))
  452. {
  453. if(isset($_POST['image_resize']) && ($_POST['image_resize'] > 0) && ($image === ''))
  454. {
  455. $imagesql = "SELECT `image` FROM `wp_product_list` WHERE `id`=".$_POST['prodid']." LIMIT 1";
  456. $imagedata = $wpdb->get_results($imagesql,ARRAY_A);
  457. if($imagedata[0]['image'] != '')
  458. {
  459. $imagepath = $imagedir . $imagedata[0]['image'];
  460. switch($_POST['image_resize'])
  461. {
  462. case 0:
  463. $height = get_option('product_image_height');
  464. $width = get_option('product_image_width');
  465. break;
  466. case 1:
  467. $height = get_option('product_image_height');
  468. $width = get_option('product_image_width');
  469. break;
  470. case 2:
  471. $height = $_POST['height'];
  472. $width = $_POST['width'];
  473. break;
  474. }
  475. include("image_resize.php");
  476. }
  477. }
  478. if(is_numeric($_POST['prodid']))
  479. {
  480. $counter = 0;
  481. $item_list = '';
  482. if(count($_POST['category']) > 0)
  483. {
  484. foreach($_POST['category'] as $category_id)
  485. {
  486. $check_existing = $wpdb->get_var("SELECT `id` FROM `wp_item_category_associations` WHERE `product_id` = ".$id." AND `category_id` = '$category_id' LIMIT 1");
  487. if($check_existing == null)
  488. {
  489. $wpdb->query("INSERT INTO `wp_item_category_associations` ( `id` , `product_id` , `category_id` ) VALUES ('', '".$id."', '".$category_id."');");
  490. }
  491. if($counter > 0)
  492. {
  493. $item_list .= ", ";
  494. }
  495. $item_list .= "'".$category_id."'";
  496. $counter++;
  497. }
  498. }
  499. else
  500. {
  501. $item_list = "'0'";
  502. }
  503. $sql_delete_query = "DELETE FROM `wp_item_category_associations` WHERE `product_id`= '$id' AND `category_id` NOT IN (".$item_list.")";
  504. $wpdb->query($sql_delete_query);
  505. }
  506. if(isset($_POST['display_frontpage']) && $_POST['display_frontpage'] == "yes")
  507. {
  508. $display_frontpage = 1;
  509. }
  510. else
  511. {
  512. $display_frontpage = 0;
  513. }
  514. $visible = '0';
  515. if (isset($_POST['visible']) && $_POST['visible'] == 'on')
  516. $visible = '1';
  517. if (isset($_POST['approved']) && $_POST['approved'] == 'on')
  518. {$approved = '1';} else {$approved = Null;}
  519. if (isset($_POST['colored']) && $_POST['colored'] == 'on'){$colored = '1';}
  520. else {$colored = '0';}
  521. if (isset($_POST['temadnya']) && $_POST['temadnya'] == 'on'){$temadnya = '1';}
  522. else {$temadnya = '0';}
  523. if (isset($_POST['not_for_sale']) && $_POST['not_for_sale'] == 'on'){$not_for_sale = '1';}
  524. else {$not_for_sale = '0';}
  525. if (isset($_POST['license1']) && $_POST['license1'] == 'on'){$license1 = '1'; }
  526. else{$license1="0";}
  527. if (isset($_POST['license2']) && $_POST['license2'] == 'on'){$license2 = '1'; }
  528. else{$license2="0";}
  529. if (isset($_POST['license3']) && $_POST['license3'] == 'on'){$license3 = '1'; }
  530. else{$license3="0";}
  531. // TODO: take it off to the SQL table
  532. // License prices
  533. // Category group 1
  534. $l1_price_cat1_default = 250;
  535. $l2_price_cat1_default = 500;
  536. $l3_price_cat1_default = 2500;
  537. // Category group 2
  538. $l1_price_cat2_default = 250;
  539. $l2_price_cat2_default = 500;
  540. $l3_price_cat2_default = 2500;
  541. //UPDATE `wp_product_list` SET l1_price = 200 WHERE id in (SELECT product_id from `wp_item_category_associations` WHERE category_id in (4,14,5,11));
  542. $category_id = $wpdb->escape($_POST['category']);
  543. switch($category_id)
  544. {
  545. case 4:
  546. case 14:
  547. case 5:
  548. case 11:
  549. $l1_price = $l1_price_cat1_default;
  550. $l2_price = $l2_price_cat1_default;
  551. $l3_price = $l3_price_cat1_default;
  552. break;
  553. case 13:
  554. case 8:
  555. case 15:
  556. case 6:
  557. $l1_price = $l1_price_cat2_default;
  558. $l2_price = $l2_price_cat2_default;
  559. $l3_price = $l3_price_cat2_default;
  560. break;
  561. default:
  562. $l1_price = $l1_price_cat1_default;
  563. $l2_price = $l2_price_cat1_default;
  564. $l3_price = $l3_price_cat1_default;
  565. break;
  566. }
  567. // unset not available licences
  568. if (!isset($license1)||$license1=='0'){$l1_price = '0';}
  569. if (!isset($license2)||$license2=='0'){$l2_price = '0';}
  570. if (!isset($license3)||$license3=='0'){$l3_price = '0';}
  571. //
  572. if (isset($_POST['brand']) && is_numeric($_POST['brand']))
  573. {$_brand = $_POST['brand'];}
  574. else
  575. {$_brand = $user_brand;}
  576. if (isset($current_user->wp_capabilities['author']) && $current_user->wp_capabilities['author']==1)
  577. {
  578. $updatesql = "UPDATE `wp_product_list` SET `name` = '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['title'])))."', `description` = '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."', `additional_description` = '".$wpdb->escape(correct_comma(removeCrLf(htmlspecialchars($_POST['additional_description']))))."', `category` = '".$wpdb->escape($_POST['category'][0])."', `brand` = '".$_brand."', `display_frontpage`='$display_frontpage', `visible`='$visible',`color`='$colored', `not_for_sale`='$not_for_sale', `l1_price`='$l1_price', `l2_price`='$l2_price', `l3_price`='$l3_price' WHERE `id`='".$_POST['prodid']."' LIMIT 1";
  579. }
  580. else
  581. {
  582. $updatesql = "UPDATE `wp_product_list` SET `name` = '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['title'])))."', `description` = '".$wpdb->escape(removeCrLf(htmlspecialchars($_POST['description'])))."', `additional_description` = '".$wpdb->escape(correct_comma(removeCrLf(htmlspecialchars($_POST['additional_description']))))."', `category` = '".$wpdb->escape($_POST['category'][0])."', `brand` = '".$_brand."', `display_frontpage`='$display_frontpage', `visible`='$visible', `approved`='$approved', `color`='$colored', `not_for_sale`='$not_for_sale', `l1_price`='$l1_price', `l2_price`='$l2_price', `l3_price`='$l3_price' WHERE `id`='".$_POST['prodid']."' LIMIT 1";
  583. }
  584. $wpdb->query($updatesql);
  585. // update temadnya
  586. if ($temadnya == '1') // insert category 777
  587. {
  588. $sql_temadnya = "insert into `wp_item_category_associations` (product_id, category_id) values ('".$_POST['prodid']."','777')";
  589. $wpdb->query($sql_temadnya);
  590. }
  591. elseif ($temadnya == '0') // remove category 777
  592. {
  593. $sql_temadnya = "delete from `wp_item_category_associations` where product_id=".$_POST['prodid']." and category_id='777'";
  594. $wpdb->query($sql_temadnya);
  595. }
  596. if($image != null)
  597. {
  598. $updatesql2 = "UPDATE `wp_product_list` SET `image` = '".$image."' WHERE `id`='".$_POST['prodid']."' LIMIT 1";
  599. $wpdb->query($updatesql2);
  600. }
  601. if(isset($_POST['deleteimage']) && $_POST['deleteimage'] == 1)
  602. {
  603. $updatesql2 = "UPDATE `wp_product_list` SET `image` = '' WHERE `id`='".$_POST['prodid']."' LIMIT 1";
  604. $wpdb->query($updatesql2);
  605. }
  606. $variations_procesor = new nzshpcrt_variations;
  607. if(isset($_POST['variation_values']) && $_POST['variation_values'] != null)
  608. {
  609. $variations_procesor->add_to_existing_product($_POST['prodid'],$_POST['variation_values']);
  610. }
  611. if(isset($_POST['edit_variation_values']) && $_POST['edit_variation_values'] != null)
  612. {
  613. $variations_procesor->edit_product_values($_POST['prodid'],$_POST['edit_variation_values']);
  614. }
  615. if(isset($_POST['edit_add_variation_values']) && $_POST['edit_add_variation_values'] != null)
  616. {
  617. $variations_procesor->edit_add_product_values($_POST['prodid'],$_POST['edit_add_variation_values']);
  618. }
  619. echo "<div class='updated'><p align='center'>".TXT_WPSC_PRODUCTHASBEENEDITED."</p></div>";
  620. }
  621. }
  622. if(isset($_GET['deleteid']) && is_numeric($_GET['deleteid']))
  623. {
  624. if (isset($current_user->wp_capabilities['administrator']) && $current_user->wp_capabilities['administrator']==1)
  625. {
  626. $deletesql = "UPDATE `wp_product_list` SET `active` = '0' WHERE `id`='".$_GET['deleteid']."' LIMIT 1";
  627. $wpdb->query($deletesql);
  628. }
  629. if (isset($current_user->wp_capabilities['editor']) && $current_user->wp_capabilities['editor']==1)
  630. {
  631. $deletesql = "UPDATE `wp_product_list` SET `active` = '0' WHERE `id`='".$_GET['deleteid']."' LIMIT 1";
  632. $wpdb->query($deletesql);
  633. }
  634. if (isset($current_user->wp_capabilities['author']) && $current_user->wp_capabilities['author']==1)
  635. {
  636. $deletesql = "UPDATE `wp_product_list` SET `active` = '0' WHERE `id`='".$_GET['deleteid']."' LIMIT 1";
  637. $wpdb->query($deletesql);
  638. }
  639. }
  640. /*
  641. * Gets the product list, commented to make it stick out more, as it is hard to notice
  642. */
  643. $items_on_page = 15;
  644. if(isset($_GET['offset']) && is_numeric($_GET['offset']))
  645. {
  646. $offset = $_GET['offset'];
  647. }
  648. else
  649. {
  650. $offset = 0;
  651. }
  652. if(current_user_can('publish_posts'))
  653. $visiblesql = " ";
  654. else
  655. $visiblesql = " AND `wp_product_list`.`visible`='1' ";
  656. $exclude_category_777 = " ";
  657. if(isset($_GET['catid']) && is_numeric($_GET['catid']))
  658. {
  659. // if we are getting items from only one category
  660. $sql = "SELECT `wp_product_list`.*,`wp_product_list`.`category` AS `category_id` FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql.$author_group_sql.$exclude_category_777." AND `wp_product_list`.`category`='".$_GET['catid']."' order by wp_product_list.id DESC LIMIT ".$offset.",".$items_on_page;
  661. $category_count = $wpdb->get_results("SELECT COUNT(id) as count FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql." AND `wp_product_list`.`category`='".$_GET['catid']."'",ARRAY_A);
  662. }
  663. else if (isset($_GET['brand']) && is_numeric($_GET['brand']))
  664. {
  665. // if we are getting items from only one brand
  666. $sql = "SELECT `wp_product_list`.*,`wp_product_list`.`category` AS `category_id` FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql.$author_group_sql.$exclude_category_777." AND `wp_product_list`.`brand`='".$_GET['brand']."' order by wp_product_list.id DESC LIMIT ".$offset.",".$items_on_page;
  667. $category_count = $wpdb->get_results("SELECT COUNT(id) as count FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql." AND `wp_product_list`.`brand`='".$_GET['brand']."'",ARRAY_A);
  668. }
  669. else
  670. {
  671. // if not, get everything that is not deleted (denoted by the active column, 1 = present, 0 = deleted, no real deletion because that would screw up the product log)
  672. $sql = "SELECT `wp_product_list`.*, `wp_product_list`.`category` AS `category_id` FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql.$author_group_sql.$exclude_category_777." order by wp_product_list.id DESC LIMIT ".$offset.",".$items_on_page;
  673. $category_count = $wpdb->get_results("SELECT COUNT(id) as count FROM `wp_product_list` WHERE `wp_product_list`.`active`='1' ".$visiblesql.$author_group_sql.";",ARRAY_A);
  674. }
  675. $product_list = $wpdb->get_results($sql,ARRAY_A) ;
  676. $items_count = $category_count[0]['count'];
  677. ?>
  678. <div class="wrap">
  679. <h2><?php echo TXT_WPSC_DISPLAYPRODUCTS;?></h2>
  680. <?php
  681. echo "???????: ";
  682. echo topcategorylist($offset);
  683. echo (" ??? ".al_brandslist());
  684. ?>
  685. ?:<input type="text" value="000" id='editpicid' style="width:60px;">
  686. <a href="#" class="button add-new-h2" onclick="var editpicid=document.getElementById('editpicid').value;filleditform(editpicid.replace(/(^\s+)|(\s+$)/g, ''));return false;">??????????

Large files files are truncated, but you can click here to view the full file