исправлено Работа сайте через https

zxc

Пользователь
Справедливости ради у нас есть репозиторий на GitHub, где можно предлагать свои реквесты. Это я про замену класса. Потребительское отношение к движку до добра не доведет.
Я настолько это варварски сделал, что стыдно предлагать на GitHub :) Да и на гитхабе я пионер, все что я там освоил - это поиск по репозиторию
Могу кинуть сюда
Сам класс

Please Login or Register to view hidden text.



Код:
<?php

if ( !defined('IN_PHPBB') )
{
    die('Hacking attempt');
    exit;
}

if ($bb_cfg['emailer_disabled']) bb_die($lang['EMAILER_DISABLED']);

$need_captcha = ($_GET['mode'] == 'sendpassword' && !IS_ADMIN);

$need_captcha=false;

if ( isset($_POST['submit']) )
{
    if ($need_captcha && !CAPTCHA()->verify_code())    bb_die($lang['CONFIRM_CODE_WRONG']);
    $email = ( !empty($_POST['email']) ) ? trim(strip_tags(htmlspecialchars($_POST['email']))) : '';
    $sql = "SELECT *
        FROM " . BB_USERS . "
        WHERE user_email = '" . DB()->escape($email)."'";
    if ( $result = DB()->sql_query($sql) )
    {
        if ( $row = DB()->sql_fetchrow($result) )
        {
            if (!$row['user_active'])
            {
                bb_die($lang['NO_SEND_ACCOUNT_INACTIVE']);
            }
            if (in_array($row['user_level'], array(MOD, ADMIN)))
            {
                bb_die($lang['NO_SEND_ACCOUNT']);
            }

            $username = $row['username'];
            $user_id = $row['user_id'];

            $user_actkey = make_rand_str(12);
            $user_password = make_rand_str(8);

            $sql = "UPDATE " . BB_USERS . "
                SET user_newpasswd = '" . md5(md5($user_password)) . "', user_actkey = '$user_actkey'
                WHERE user_id = " . $row['user_id'];
            if ( !DB()->sql_query($sql) )
            {
                message_die(GENERAL_ERROR, 'Could not update new password information', '', __LINE__, __FILE__, $sql);
            }

            include(INC_DIR . 'phpmailer/class.phpmailer.php');
            include(INC_DIR . 'phpmailer/class.smtp.php');
            //Create a new PHPMailer instance
            $mail = new PHPMailer;
            // Set PHPMailer to use the sendmail transport
           
            if($bb_cfg['smtp_delivery']==1){
                $mail->isSMTP();
                //Enable SMTP debugging
                // 0 = off (for production use)
                // 1 = client messages
                // 2 = client and server messages
               
                $mail->SMTPDebug = 4;
                $mail->Debugoutput = 'html';
                $mail->Host = (!empty($bb_cfg['smtp_host'])) ? $bb_cfg['smtp_host'] : "smtp.google.com";
                //Set the SMTP port number - likely to be 25, 465 or 587
                //$mail->Port = (!empty($bb_cfg['smtp_port'])) ? (int)$bb_cfg['smtp_port'] : 587;
                $mail->Port = (!empty($bb_cfg['smtp_port'])) ? 587 : 587;

                $mail->SMTPSecure = ($mail->Port==465) ? 'ssl' : 'tls';;
                //echo !extension_loaded('openssl')?"Not Available":"Available";
                 $mail->SMTPAutoTLS = false;
                //Whether to use SMTP authentication
                $mail->SMTPAuth = true;
                //Username to use for SMTP authentication
                $mail->Username = (!empty($bb_cfg['smtp_username'])) ? $bb_cfg['smtp_username'] : false;
                //Password to use for SMTP authentication
                $mail->Password = (!empty($bb_cfg['smtp_password'])) ? $bb_cfg['smtp_password'] : false;
            }
            else{
                $mail->isSendmail();  
            }
           
           
            //
           
           
            //Set who the message is to be sent from
            $mail->CharSet = 'UTF-8';
            $mail->setFrom($bb_cfg['board_email'], 'MYTRACKER');
            //Set an alternative reply-to address
            $mail->addReplyTo($bb_cfg['board_email'], 'MYTRACKER');
            //Set who the message is to be sent to
            $mail->addAddress($row['user_email'], $row['username']);
            //Set the subject line
            $mail->Subject = $lang['NEW_PASSWORD_ACTIVATION'];
           
            $mail->use_template('user_activate_passwd', $row['user_lang']);
           
            $mail_vars = (array(
                'SITENAME' => $lang['SITENAME'],
                'USERNAME' => $username,
                'PASSWORD' => $user_password,
                'EMAIL_SIG' => (!empty($bb_cfg['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $bb_cfg['board_email_sig']) : '',

                'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
            ));
           
           
            $mail_html = ($mail->use_template('user_activate_passwd', $row['user_lang'], $mail_vars));
            $mail_html = str_replace("\r\n","<br />\r\n",$mail_html);

           
            //var_dump($mail_tpl);
            //die();
           
            //Read an HTML message body from an external file, convert referenced images to embedded,
            //convert HTML into a basic plain-text alternative body
            $mail->msgHTML($mail_html, dirname(__FILE__));
            //Replace the plain text body with one created manually
            $mail->AltBody = strip_tags($mail_html);
            //Attach an image file
            //$mail->addAttachment('images/phpmailer_mini.png');

            //send the message, check for errors
            if (!$mail->send()) {
                $message = "Mailer Error: " . $mail->ErrorInfo;
            } else {
                $message = $lang['PASSWORD_UPDATED'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_INDEX'],  '<a href="index.php">', '</a>');
            }
           


            message_die(GENERAL_MESSAGE, $message);
        }
        else
        {
            message_die(GENERAL_MESSAGE, $lang['NO_EMAIL_MATCH']);
        }
    }
    else
    {
        message_die(GENERAL_ERROR, 'Could not obtain user information for sendpassword', '', __LINE__, __FILE__, $sql);
    }
}
else
{
    $email = $username = '';
}

$template->assign_vars(array(
    'USERNAME' => $username,
    'EMAIL' => $email,
    'CAPTCHA_HTML'       => ($need_captcha) ? CAPTCHA()->get_html() : '',
    'S_HIDDEN_FIELDS' => '',
    'S_PROFILE_ACTION' => "profile.php?mode=sendpassword")
);

print_page('usercp_sendpasswd.tpl');
В class.php.mailer.php
Добавил одну функцию
Код:
    public function use_template($template_file, $template_lang = '', $mail_vars=array())
    {
        global $bb_cfg;

        if (trim($template_file) == '')
        {
            message_die(GENERAL_ERROR, 'No template file set', '', __LINE__, __FILE__);
        }

        if (trim($template_lang) == '')
        {
            $template_lang = $bb_cfg['default_lang'];
        }

        if (empty($this->tpl_msg[$template_lang . $template_file]))
        {
            $tpl_file = LANG_ROOT_DIR ."lang_$template_lang/email/$template_file.tpl";

            if (!@file_exists(@phpbb_realpath($tpl_file)))
            {
                $tpl_file = LANG_ROOT_DIR ."lang_{$bb_cfg['default_lang']}/email/$template_file.tpl";

                if (!@file_exists(@phpbb_realpath($tpl_file)))
                {
                    message_die(GENERAL_ERROR, 'Could not find email template file :: ' . $template_file, '', __LINE__, __FILE__);
                }
            }

            if (!($fd = @fopen($tpl_file, 'r')))
            {
                message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
            }

            $this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
            fclose($fd);
        }
       
        $this->msg = $this->tpl_msg[$template_lang . $template_file];
       
        foreach($mail_vars as $k => $v){
                $this->msg = str_replace('{'.$k.'}',$v,$this->msg);
               
        }
       
        $this->msg = str_replace("\n","\r\n",$this->msg);
        $this->msg = str_replace("\r\r\n","\r\n",$this->msg);

        return $this->msg;
    }
 
Последнее редактирование:

Ragnar

Пользователь
Странно, но при обновлении сайтмап через крон прописываются ссылки через http, а при ручном обновлении нормально - через https. В роботс прописал через https.
 

zxc

Пользователь
Обновил я сегодня Хром до версии 56 и все мои сертификаты StartSSL перестали ему нравится
Кто ж знал

Please Login or Register to view hidden text.

 
Сверху