Advertisement
vovan333

worst php shitcode ever

Feb 12th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.55 KB | None | 0 0
  1.  
  2.         // extension code start
  3.  
  4.             $fullName           = $this->request->post['firstname'];
  5.             $phoneNum           = $this->request->post['telephone'];
  6.             $email              = $this->request->post['email'];
  7.             $enableSubscription = $this->request->post['newsletter'];
  8.             $shippingMethod     = $this->request->post['shipping_method'];
  9.             $paymentMethod      = $this->request->post['payment_method'];
  10.             $address            = $this->request->post['address'];
  11.  
  12.             $enableSubscription = $enableSubscription == 1 ? "Да" : "Нет";
  13.  
  14.             $total = "";
  15.             $products = $this->cart->getProducts();
  16.  
  17.             foreach ($products as $product)
  18.             {
  19.                 $total .= "<tr>";
  20.                 $size = $product["option"][0]["value"];
  21.                 $total .= '<td>'.$product["name"].'</td>';
  22.                 $total .= '<td>'.$product["model"].'</td>';
  23.                 $total .= '<td>'.$size.'</td>';
  24.                 $total .= '<td>'.$product["quantity"].'</td>';
  25.                 $total .= '<td>'.$product["price"].'</td>';
  26.                 $total .= '<td>'.$product["total"].'</td>';
  27.                 $total .="</tr>";
  28.             }
  29.  
  30.             $subject = "Заказ товара";
  31.             $text =
  32.             "
  33.                 <html>
  34.                     <head>
  35.                        <style>
  36.                            tr, table
  37.                            {
  38.                                border-spacing: 0;
  39.                            }
  40.  
  41.                            td
  42.                            {
  43.                                border-spacing: 0;
  44.                                border: 1px solid #aaa;
  45.                                padding: 5px;
  46.                                text-align:center;
  47.                                font-size: 14px;
  48.                            }
  49.  
  50.                            .TableHead
  51.                            {
  52.                                background: #eee;
  53.                            }
  54.  
  55.                            .TableHead > tr > td
  56.                            {
  57.                                font-size: initial;
  58.                            }
  59.                        </style>
  60.                     </head>
  61.                     <body>
  62.                         <h2>Вам пришел заказ!</h2>
  63.                         Ф.И.О: $fullName <br/>
  64.                         Номер телефона: $phoneNum <br/>
  65.                         E-Mail: $email <br/>
  66.                         Подписка: $enableSubscription <br/>
  67.                         $shippingMethod <br/>
  68.                         Метод оплаты: $paymentMethod <br/>
  69.                         Адрес доставки: $address <br/>
  70.                         <h3>Заказанные товары: </h3>
  71.                        <table>
  72.                            <thead>
  73.                                <tr class='TableHead'>
  74.                                    <td cellspacing='0'><b>Товар</b></td>
  75.                                    <td cellspacing='0'><b>Модель</b></td>
  76.                                    <td cellspacing='0'><b>Размер</b></td>
  77.                                    <td cellspacing='0'><b>Количество</b></td>
  78.                                    <td cellspacing='0'><b>Цена</b></td>
  79.                                    <td cellspacing='0'><b>Итого</b></td>
  80.                                </tr>
  81.                            </thead>
  82.                            <tbody>
  83.                                $total
  84.                            </tbody>
  85.                        </table>
  86.                    </body>
  87.                </html>
  88.            ";
  89.  
  90.             $b24Text =
  91.             "
  92.                <html>
  93.                    <head>
  94.                    </head>
  95.                    <body>
  96.                        <h2>Вам пришел заказ!</h2>
  97.                        Ф.И.О: $fullName <br/>
  98.                        Номер телефона: $phoneNum <br/>
  99.                        E-Mail: $email <br/>
  100.                        Подписка: $enableSubscription <br/>
  101.                        $shippingMethod <br/>
  102.                        Метод оплаты: $paymentMethod <br/>
  103.                        Адрес доставки: $address <br/>
  104.                        <h3>Заказанные товары: </h3>
  105.                        <table>
  106.                            <thead>
  107.                                <tr class='TableHead'>
  108.                                    <td cellspacing='0'><b>Товар</b></td>
  109.                                    <td cellspacing='0'><b>Модель</b></td>
  110.                                    <td cellspacing='0'><b>Размер</b></td>
  111.                                    <td cellspacing='0'><b>Количество</b></td>
  112.                                    <td cellspacing='0'><b>Цена</b></td>
  113.                                    <td cellspacing='0'><b>Итого</b></td>
  114.                                </tr>
  115.                            </thead>
  116.                            <tbody>
  117.                                $total
  118.                            </tbody>
  119.                        </table>
  120.                    </body>
  121.                </html>
  122.            ";
  123.  
  124.             $reciever = $this->config->get('config_email');
  125.             $headers  = 'MIME-Version: 1.0' . "\r\n";
  126.             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  127.  
  128.             mail($reciever, $subject, $text, $headers);
  129.             mail("vovanabvgd@gmail.com", $subject, $text, $headers);
  130.  
  131.             $b24Username = "B24_USERNAME";
  132.             $b24Password = "B24_PASSWORD";
  133.             $b24Domain   = "B24_DOMAIN";
  134.  
  135.             $b24RequestParameters = Array
  136.             (
  137.                 "LOGIN"              => $b24Username,
  138.                 "PASSWORD"           => $b24Password,
  139.                 "TITLE"              => "Заказ №".$this->db->getLastId(),
  140.                 "NAME"               => $fullName,
  141.                 "LAST_NAME"          => "",
  142.                 "PHONE_OTHER"        => $phoneNum,
  143.                 "EMAIL_OTHER"        => $email,
  144.                 "OPPORTUNITY"        => $product["total"],
  145.                 "SOURCE_ID"          => "WEB",
  146.                 "SOURCE_DESCRIPTION" => $order_data["store_url"],
  147.                 "COMMENTS"           => $b24Text
  148.             );
  149.  
  150.             $b24RequestQuery = http_build_query($b24RequestParameters);
  151.             $b24RequestURL   = "https://".$b24Domain."/crm/configs/import/lead.php?".$b24RequestQuery;
  152.             $b24APIResponse  = file_get_contents($b24RequestURL);
  153.  
  154.             $b24Tokens = explode("&", file_get_contents("B24_TOKENS_FILENAME"));
  155.             $b24RefreshToken = $b24Tokens[1];
  156.  
  157.             $clientID = "CLIENT_ID";
  158.             $clientSecret = "CLIENT_SECRET";
  159.             $reqURL = "https://oauth.bitrix.info/oauth/token/?grant_type=refresh_token&client_id=$clientID&client_secret=$clientSecret&refresh_token=$b24RefreshToken";
  160.             $response = json_decode(file_get_contents($reqURL), true);
  161.  
  162.             $b24AccessToken = $response["access_token"];
  163.             $b24RefreshToken = $response["refresh_token"];
  164.            
  165.             $dbfc = $b24AccessToken."&".$b24RefreshToken;
  166.             file_put_contents("B24_TOKENS_FILENAME", $dbfc);
  167.  
  168.             foreach($products as $product)
  169.             {
  170.                 $b24RequestParameters = Array
  171.                 (
  172.                     "fields" => Array
  173.                     (
  174.                         "NAME"        => $product["name"],
  175.                         "CURRENCY_ID" => "RUB",
  176.                         "PRICE"       => $product["price"]
  177.                     ),
  178.  
  179.                     "auth"        => $b24AccessToken
  180.                 );
  181.  
  182.                 $b24RequestURL = "https://".$b24Domain."/rest/crm.product.add.json?".http_build_query($b24RequestParameters);
  183.                 $b24APIResponse  = file_get_contents($b24RequestURL);
  184.             }
  185.  
  186.         // extension code end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement