Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.21 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 3.5.0.0
  8. * @ Author : DeZender
  9. * @ Release on : 22.06.2018
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. spl_autoload_register('adsw_autoload');
  15.  
  16. if (!function_exists('pr')) {
  17. function pr($any)
  18. {
  19. print_r('<pre><code>');
  20. print_r($any);
  21. print_r('</code></pre>');
  22. }
  23. }
  24.  
  25. adsw\module\Create::init();
  26. add_action('init', 'adsw_init_db');
  27. adsw\Api\REST::instance();
  28. add_action('init', 'adsw_pays_handler_notify', 1);
  29. add_action('init', 'adsw_pays_handler_cancel', 1);
  30. add_action('add_log', 'adsw_add_activities', 10, 6);
  31. add_action('adsw_output_admin_update_notification_html', 'adsw_output_admin_update_notification_html', 10, 2);
  32. add_action('adsw_output_admin_update_notification_plain', 'adsw_output_admin_update_notification_plain', 10, 2);
  33. add_action('admin_footer', 'adsw_do_show_notify');
  34. add_filter('mce_external_plugins', 'edit_imager_register_tinymce_javascript');
  35. function adsw_autoload($className)
  36. {
  37. $className = ltrim($className, '\\');
  38. $fileName = '';
  39.  
  40. if ($lastNsPos = strrpos($className, '\\')) {
  41. $namespace = substr($className, 0, $lastNsPos);
  42. $className = substr($className, $lastNsPos + 1);
  43. $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
  44. }
  45.  
  46. $fileName .= $className . '.php';
  47. $file = ADSW_PATH . 'includes/' . $fileName;
  48.  
  49. if (file_exists($file)) {
  50. require $file;
  51. }
  52. }
  53.  
  54. function adsw_init_db()
  55. {
  56. global $wpdb;
  57. $wpdb->adsw_ali_meta = $wpdb->prefix . 'adsw_ali_meta';
  58. $wpdb->adsw_activities = $wpdb->prefix . 'adsw_activities';
  59. $wpdb->adsw_search_analytics = $wpdb->prefix . 'adsw_search_analytics';
  60. }
  61.  
  62. function adsw_prepare_attr($attr)
  63. {
  64. if (!$attr || count($attr) <= 0) {
  65. return false;
  66. }
  67.  
  68. $foo = array();
  69.  
  70. foreach ($attr as $item) {
  71. $foo[] = array('name' => sanitize_text_field($item->attr_name), 'value' => sanitize_text_field($item->attr_value));
  72. }
  73.  
  74. return $foo;
  75. }
  76.  
  77. function adsw_prepare_var_slug($str)
  78. {
  79. return substr(md5($str), 0, 22);
  80. }
  81.  
  82. function adsw_get_HtmlElement($html, $startOfElement, $endOfElement)
  83. {
  84. $startingPosition = strpos($html, $startOfElement);
  85. $endPosition = strpos($html, $endOfElement, $startingPosition);
  86. $foundElement = substr($html, $startingPosition, $endPosition);
  87.  
  88. return $foundElement;
  89. }
  90.  
  91. function adsw_is_package($package)
  92. {
  93. return (in_array($package, array('piece', 'lot')) ? $package : 'lot');
  94. }
  95.  
  96. function adsw_get_image_by_id($id, $size = 'thumbnail')
  97. {
  98. $img = wp_get_attachment_image_src($id, $size, false);
  99.  
  100. if ($img) {
  101. return $img[0];
  102. }
  103.  
  104. return false;
  105. }
  106.  
  107. function adsw_list_categories()
  108. {
  109. return array(3 => __('Apparel & accessories', 'adsw'), 34 => __('Automobiles & motorcycles', 'adsw'), 66 => __('Beauty & Health', 'adsw'), 7 => __('Computer & Networking', 'adsw'), 44 => __('Consumer Electronics', 'adsw'), __('Electrical Equipment & Supplies', 'adsw'), 200214161 => __('Fine & Fashion Jewelry', 'adsw'), 2 => __('Food', 'adsw'), 1503 => __('Furniture', 'adsw'), 200003655 => __('Hair & Accessories', 'adsw'), 42 => __('Hardware', 'adsw'), 6 => __('Home Appliances', 'adsw'), 13 => __('Home Improvement', 'adsw'), 200003590 => __('Industry & Business', 'adsw'), 1509 => __('Jewelry & Accessories', 'adsw'), 39 => __('Lights & Lighting', 'adsw'), 1524 => __('Luggage & Bags', 'adsw'), 200060006 => __('Market', 'adsw'), 100003070 => __("Men's Clothing & Accessories", 'adsw'), 200214151 => __("Men's Fashion", 'adsw'), 1501 => __('Mother & Kids', 'adsw'), 200000875 => __('Novelty & Special Use', 'adsw'), 21 => __('Office & School Supplies', 'adsw'), 30 => __('Security & Protection', 'adsw'), 322 => __('Shoes', 'adsw'), 18 => __('Sports & Entertainment', 'adsw'), 1420 => __('Tools', 'adsw'), 26 => __('Toys & Hobbies', 'adsw'), 1511 => __('Watches', 'adsw'), 100003235 => __('Weddings & Events', 'adsw'), 100003109 => __("Women's Clothing & Accessories", 'adsw'), 200214142 => __("Women's Fashion", 'adsw'));
  110. }
  111.  
  112. function adsw_search_category_by_id($id)
  113. {
  114. $foo = adsw_list_categories();
  115.  
  116. return (isset($foo[$id]) ? $foo[$id] : $id);
  117. }
  118.  
  119. function adsw_dropdown_categories($name = 'alicategories', $class = '', $selected = '')
  120. {
  121. $categories = adsw_list_categories();
  122. $output = sprintf('<select name="%1$s" id="%1$s" class="%2$s">', $name, $class);
  123.  
  124. foreach ($categories as $key => $val) {
  125. $select = ($key == $selected ? 'selected="selected"' : '');
  126. $output .= sprintf('<option value="%s" %s>%s</option>', $key, $select, $val);
  127. }
  128. $output .= '</select>';
  129.  
  130. return $output;
  131. }
  132.  
  133. function adsw_get_post_excerpt($text)
  134. {
  135. $text = strip_shortcodes($text);
  136. $text = apply_filters('the_content', $text);
  137. $text = str_replace(']]>', ']]>', $text);
  138. $excerpt_length = apply_filters('excerpt_length', 55);
  139. $text = wp_trim_words($text, $excerpt_length, ' ...');
  140.  
  141. return $text;
  142. }
  143.  
  144. function adsw_list_lang()
  145. {
  146. return array('en' => 'English', 'ar' => 'العربية', 'de' => 'Deutsch', 'es' => 'Español', 'fr' => 'Français', 'id' => 'Indonesia', 'it' => 'Italiano', 'ja' => '日本語', 'ko' => '한국어', 'nl' => 'Nederlands', 'pl' => 'Polskie', 'pt' => 'Português do Brasil', 'ru' => 'Русский', 'th' => 'ไทย', 'tr' => 'Türkçe', 'vi' => 'Tiếng Việt', 'he' => 'עִבְרִית');
  147. }
  148.  
  149. function adsw_post_status_colors($status = '', $name = '')
  150. {
  151. $foo = array('colors' => array('importlist' => '#5cb85c', 'draft' => '#2ea2cc', 'pending' => '#7ad03a', 'private' => '#ffba00', 'future' => '#aaaaaa', 'protected' => '#d54e21', 'sticky' => '#9859b9', 'page_on_front' => '#000000', 'page_for_posts' => '#000000', 'archive' => '#a67c52'), 'icons' => array('importlist' => 'dashicons-clipboard', 'draft' => 'dashicons-edit', 'pending' => 'dashicons-format-chat', 'private' => 'dashicons-lock', 'future' => 'dashicons-calendar-alt', 'protected' => 'dashicons-admin-network', 'sticky' => 'dashicons-star-filled', 'page_on_front' => 'dashicons-admin-home', 'page_for_posts' => 'dashicons-admin-post', 'archive' => 'dashicons-archive'));
  152.  
  153. if (isset($foo['colors'][$status])) {
  154. $label = sprintf('<span style="background:%s" class="%s states"><span class="dashicons %s"></span> %s</span>', $foo['colors'][$status], $status, $foo['icons'][$status], $name);
  155.  
  156. return $label;
  157. }
  158.  
  159. return false;
  160. }
  161.  
  162. function adsw_pays_handler_notify()
  163. {
  164. if (!isset($_GET['ads_pays_notify'])) {
  165. return false;
  166. }
  167.  
  168. $key = 'key';
  169. $prefix = 'ads';
  170. $handlers_p = $_GET[$prefix . '_' . $key];
  171. $note = get_option($prefix . '-license');
  172. $uri = md5(get_bloginfo('url') . '/');
  173. $vendor = md5(md5($note . $uri) . $uri);
  174.  
  175. if (isset($handlers_p) && md5($_GET['ads_pays_notify'] . $handlers_p) == $vendor) {
  176. update_option('_random_hash', $vendor, false);
  177. }
  178.  
  179. exit();
  180. }
  181.  
  182. function adsw_pays_handler_cancel()
  183. {
  184. if (!isset($_GET['ads_cancel_notify'])) {
  185. return false;
  186. }
  187.  
  188. $key = 'key';
  189. $prefix = 'ads';
  190. $handlers_p = $_GET[$prefix . '_' . $key];
  191. $note = get_option($prefix . '-license');
  192. $noti = get_option('_random_hash');
  193. $uri = md5(get_bloginfo('url') . '/');
  194. $vendor = md5(md5($note . $uri) . $uri);
  195.  
  196. if (isset($handlers_p) && (md5($_GET['ads_cancel_notify'] . $handlers_p) == $vendor || $noti == md5($_GET['ads_cancel_notify'] . $handlers_p))) {
  197. delete_option('_random_hash');
  198. }
  199.  
  200. exit();
  201. }
  202.  
  203. function adsw_list_tracking()
  204. {
  205. return array('17track' => array('title' => '17Track', 'url' => 'http://www.17track.net/?nums='), 'aftership' => array('title' => 'Aftership', 'url' => 'https://track.aftership.com/'), 'сainiao' => array('title' => 'Cainiao', 'url' => 'https://global.cainiao.com/detail.htm?mailNoList='));
  206. }
  207.  
  208. function adsw_list_options_tracking()
  209. {
  210. $foo = array();
  211.  
  212. foreach (adsw_list_tracking() as $key => $val) {
  213. $foo[$key] = $val['title'];
  214. }
  215.  
  216. return $foo;
  217. }
  218.  
  219. function adsw_get_tracking_url($key)
  220. {
  221. $args = adsw_list_tracking();
  222.  
  223. if (!isset($args[$key])) {
  224. $key = '17track';
  225. }
  226.  
  227. return $args[$key]['url'];
  228. }
  229.  
  230. function adsw_listDisappearsProduct()
  231. {
  232. return array('doNothing' => __('Do nothing', 'adsw'), 'zero' => __('Set quantity to zero', 'adsw'), 'draft' => __('Send to Draft/Restore', 'adsw'));
  233. }
  234.  
  235. function adsw_listDisappearsVariant()
  236. {
  237. return array('doNothing' => __('Do nothing', 'adsw'), 'zero' => __('Set quantity to zero', 'adsw'), 'disable' => __('Disable/Enable', 'adsw'));
  238. }
  239.  
  240. function adsw_listCostChanges()
  241. {
  242. return array('doNothing' => __('Do nothing', 'adsw'), 'update' => __('Update Automatically', 'adsw'));
  243. }
  244.  
  245. function adsw_listStockChanges()
  246. {
  247. return array('doNothing' => __('Do nothing', 'adsw'), 'update' => __('Update Automatically', 'adsw'));
  248. }
  249.  
  250. function adsw_listIntervals()
  251. {
  252. return array('daily' => __('Once daily', 'adsw'), 'weekly' => __('Once weekly', 'adsw'), 'month' => __('Once monthly', 'adsw'));
  253. }
  254.  
  255. function adsw_list_prod_type()
  256. {
  257. return array('' => __('All Categories', 'adsw'), 'categories' => __('Select categories', 'adsw'));
  258. }
  259.  
  260. function adsw_listReviewMinRating()
  261. {
  262. return array(5 => __('Only 5 stars', 'adsw'), 4 => __('4 stars and higher', 'adsw'), 3 => __('3 stars and higher', 'adsw'), 2 => __('2 stars and higher', 'adsw'), 1 => __('1 star and higher', 'adsw'));
  263. }
  264.  
  265. function adsw_listReviewCount()
  266. {
  267. return array(20 => __('up to 20', 'adsw'), 40 => __('up to 40', 'adsw'), 60 => __('up to 60', 'adsw'), 80 => __('up to 80', 'adsw'), 100 => __('up to 100', 'adsw'));
  268. }
  269.  
  270. function adsw_add_activities($args, $anonce = '', $type = '', $status = 'info', $post_id = 0, $hash = null)
  271. {
  272. global $wpdb;
  273.  
  274. if (is_array($args) || is_object($args)) {
  275. $args = serialize($args);
  276. }
  277.  
  278. $wpdb->insert($wpdb->adsw_activities, array('post_id' => $post_id, 'product_data' => $args, 'type' => $type, 'date' => date('Y-m-d H:i:s'), 'status' => $status, 'anonce' => $anonce), array('%d', '%s', '%s', '%s', '%s', '%s'));
  279. }
  280.  
  281. function adsw_output_admin_update_notification_html($products, $settings)
  282. {
  283. if (!$products) {
  284. $text = '<table>';
  285. $text .= '<thead>';
  286. $text .= '<tr><th>' . __('All products are up to date.', 'adsw') . '</th></tr>';
  287. $text .= '<thead>';
  288. $text .= '</table>';
  289. .............................................................................
  290. ...............................................
  291. ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement