I
I
Ivan Budakov2019-11-04 18:47:14
PHP
Ivan Budakov, 2019-11-04 18:47:14

The problem of moving to a VPS, how to fix the form submission?

Good evening!
This situation arose with the site speedsporter.ru , this is transferred from another hosting best-sporter.ru .
The problem is the following, when trying to go to the catalog: speedsporter.ru/catalog/adidas-yeezy-boost-350, the products are not displayed, although they are on the main page, the database is connected. The files were not edited during the transfer, only the base.
At the same time, the filter and pagination work out clearly. Only the catalog and sending forms
Also, when trying to send an order form or feedback, we are immediately dropped due to "id error", paste the code for sending the order:

<?php
/**
 * Order
 *
 * @author dandelion <web.dandelion@gmail.com>
 * @package App_Order
 */
class App_Order extends Controller
{
    function indexAction(array $params)
    {
        $product_id = @$params[0];
        if (!$product_id)
            echo $product_id;
            die('id error');
        $product = $this->model->product->getById($product_id);
        if ($product->isEmpty())
            die('product doesnt exist');
       
        $form = $this->load->form('order');
        if ($form->isSubmit() && $form->isValid())
        {
            $data = new Entity(array_map('strip_tags',$form->getData()));
 
            $ip = $this->model->user->getIp();
            if ($this->model->order->countByIp($ip) >= 5) {
                die('fail');
            }
 
            /**
             * Сохранение данных
             */
            $id = $this->model->order->add(array(
                'product_id' => $product_id,
                'name'  => $data->name,
                'phone' => $data->phone,
                // 'email' => $data->email,
                // 'address' => $data->address,
                // 'message' => $data->message,
                //'step' => 1,
                'timestamp'  => time(),
                'ref' => (string)@$_COOKIE['ref'],
                'utm_source' => (string)@$_COOKIE['utm_source'],
                'utm_medium' => (string)@$_COOKIE['utm_medium'],
                'utm_term' => (string)@$_COOKIE['utm_term'],
                'utm_content' => (string)@$_COOKIE['utm_content'],
                'utm_campaign' => (string)@$_COOKIE['utm_campaign'],
                'referer' => (string)@$_COOKIE['referer'],
                'phrase' => (string)@$_COOKIE['phrase'],
                'ip' => $ip,                
            ));
            /**
             * Отправка на мыло
             */
            $sent = false;
            if ($this->var->email)
            {
                require_once DIR_LIB.'/phpmailer/class.phpmailer.php';
 
                $mail = new PHPMailer();
                $mail->From     = '[email protected]'.$_SERVER['HTTP_HOST'];
                $mail->FromName = $data->name ? $data->name : $_SERVER['HTTP_HOST'];    $mail->AddReplyTo($data->email, $data->name);
                $mail->Host     = $_SERVER['HTTP_HOST'];
                if (YANDEX_SMTP_LOGIN && YANDEX_SMTP_PASS)
                {
                    $mail->From     = YANDEX_SMTP_LOGIN;//$data->email;
                    $mail->IsSMTP(); // enable SMTP
                    $mail->SMTPAuth = true;  // authentication enabled
                    $mail->Host = 'smtp.yandex.ru';
                    $mail->Port = 25;
                    $mail->Username = YANDEX_SMTP_LOGIN;  
                    $mail->Password = YANDEX_SMTP_PASS;      
                }
                else
                {
                    $mail->Mailer   = "mail";
                }
                $mail->Body    = nl2br(
"Товар: <a href='http://{$_SERVER['HTTP_HOST']}/item/{$product->key}'>$product->name</a>".($product->code ? " ($product->code)":'')."
Телефон: $data->phone
".(!empty($_COOKIE['ref']) ? "Реферал: {$_COOKIE['ref']}" : '')."
 
".(!empty($_COOKIE['referer']) ? "Источник: {$_COOKIE['referer']}" : '')."
".(!empty($_COOKIE['phrase']) ? "Фраза: {$_COOKIE['phrase']}" : '')."
 
".(!empty($_COOKIE['utm_source']) ? '[utm]'.join('-',array(@$_COOKIE['utm_source'],@$_COOKIE['utm_medium'],@$_COOKIE['utm_term'],@$_COOKIE['utm_content'],@$_COOKIE['utm_campaign'])).'[/utm]' : '')."
[ip]{$_SERVER['REMOTE_ADDR']}[/ip]
 
");
                $mail->AltBody = strip_tags(str_replace("<br/>", "\n", $mail->Body));
                $mail->Subject = 'Заказ #'.$id;//$data->subject;
                $emails = array_map('trim',explode(',',$this->var->email));
                foreach ($emails as $email)
                    $mail->AddAddress($email);
 
                $sent = $mail->Send();
            }
            /**
             * SMS
             */
            $stuff = $this->model->stuff->get();
            if ($stuff->sms_order_enable)
            {
                $phone1 = preg_replace('@[^0-9][email protected]','',$data->phone);
                $phone2 = preg_replace('@[^0-9][email protected]','',$stuff->sms_order_phone);
                $placeholders = array(
                    '{ID}' => $id,
                    '{NAME}' => $data->name,
                    '{PHONE}' => $data->phone,
                    '{TOTAL}' => ((int)$product->price).' '.$stuff->currency,
                );
                $text1 = str_replace(array_keys($placeholders),array_values($placeholders),$stuff->sms_order_client);
                $text2 = str_replace(array_keys($placeholders),array_values($placeholders),$stuff->sms_order_admin);
               
                if ($phone1 && $text1)
                    $this->model->sms->send($phone1,$text1);
                if ($phone2 && $text2)
                    $this->model->sms->send($phone2,$text2);
            }
            /**
             * Результат
             */
            if ($id || $sent)
            {
                $this->Url_redirectTo('order/success/'.$id);
                die('ok');
                //$this->tpl->assignBlockVars('success');
                //unset($_POST);
                //$this->Url_redirectTo('order/shipping/'.$id);
            }
            else
            {
                //$this->tpl->assignBlockVars('fail');
            }
            /*
            if (isset($params[1]) && $params[1]=='pay')
            {
                $this->model->order->edit(array(
                    'step' => 3,
                    'paymethod'  => 'robokassa'
                ),$id);
 
                $stuff = $this->model->stuff->get();
               
                $mrh_login = ROBOKASSA_LOGIN;
                $mrh_pass1 = ROBOKASSA_PASS1;
                $out_summ = $product->price;
                $inv_id = $id;
                $inv_desc = "Оплата заказа в магазине \"{$stuff->site_name}\"";
                $shp_item = 1;
                $in_curr = "PCR";
                $culture = "ru";
                $crc  = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1");
                $test_url = "http://test.robokassa.ru/Index.aspx";
                $production_url = "https://merchant.roboxchange.com/Index.aspx";
                $final_url = "{$production_url}?".http_build_query(array(
                    'MrchLogin' => $mrh_login,
                    'OutSum' => $out_summ,
                    'InvId' => $inv_id,
                    'Desc' => $inv_desc,
                    'SignatureValue' => $crc,
                    //'IncCurrLabel' => $in_curr,
                    'Culture' => $culture,
                ));
                die("<meta http-equiv=\"refresh\" content=\"0; url={$final_url}\"/>
                <p>Пожалуйста, подождите, идет перенаправление на сервис RoboKassa...</p>
                <p>Если ваш браузер не поддерживает автоматической переадресации, нажмите <a href=\"{$final_url}\">сюда</a></p>");
            }
            else
            {
                $this->model->order->edit(array(
                    'step' => 5,
                ),$id);
                $this->Url_redirectTo('order/success/'.$id);
                die('ok');
            }
             */
        }
        else $form->renderErrors($this->tpl);
       
        $this->tpl->assignVars(array(
            'ID'=>$product_id,
            'PRODUCT_NAME'=>$product->name
        ));
    }
   
    function successAction(array $params)
    {
        $id = (int)@$params[0];
        if (!$id)
            die('id error');
           
            $order = $this->model->order->getById($id);
            $product = $this->model->product->getById($order->product_id);
            $goods = array(
                    'id' => $product->id,
                    'name' => $product->name,
                    'price' => $product->price,
                    'quantity' => 1
            );
           
        $this->tpl->assignVars(array(
            'ID' => $id,
            'TOTAL' => $product->price,
            'GOODS' => json_encode($goods),
        ));
    }
}

Version PHP 5.6 in both cases, maybe something needs to be installed on the server? I thought PHPMailer, no, after installing it, the situation is the same. Thanks for any help and tips on where to look!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2019-11-04
@FanatPHP

I would suggest freelansim.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question