Chevereto使用QQAPI登陆教程

998597568.png

简要介绍(Introduction)

此文介绍如何为您的Chevereto添加QQ登陆方式,试验性教程,造成的损失由您自己负责!!!


支持环境(Requirement)

PHP >= 7.0

Chevereto >= 3.13.0

在执行所有操作前,请先做好数据备份工作,以免造成不必要的损失!!!


食用指南(Usage)

1. 安装社会化登陆库(Install support Library)

站点根目录执行,安装社会化登陆库(需环境支持Composer)

https://github.com/overtrue/socialite

composer require "overtrue/socialite" -vvv

2. 添加QQ登陆方式(Add QQ login method)

修改class.login.php文件

// app\lib\classes\class.login.php:30

     public static $social_services = [
        'facebook' => 'Facebook',
        'twitter' => 'Twitter',
        'google' => 'Google',
        'vk' => 'VK',
    ];
// 修改为以下内容
     public static $social_services = [
        'facebook' => 'Facebook',
        'twitter' => 'Twitter',
        'google' => 'Google',
        'vk' => 'VK',
        'qq' => 'QQ',
    ];

3. 载入社会化登陆库(Load support library)

引入社会化登陆库,增加QQ登陆方式


// app\routes\overrides\route.connect.php:18/19

use Overtrue\Socialite\SocialiteManager;


// app\routes\overrides\route.connect.php:24/25

        if (!in_array($doing, ['google', 'facebook', 'twitter', 'vk'])) {
            return $handler->issue404();
        }
//修改为以下内容
        if (!in_array($doing, ['google', 'facebook', 'twitter', 'vk', 'qq'])) {
            return $handler->issue404();
        }

// 添加以下内容

// app\routes\overrides\route.connect.php:277~279

            case 'qq':
                $config = [
                    'qq' => [
                        'client_id' => CHV\getSetting('qq_client_id'),
                        'client_secret' => CHV\getSetting('qq_client_secret'),
                        'redirect' => G\get_base_url('connect/qq'),
                    ],
                ];

                $client = new SocialiteManager($config);
    
                if (isset($_GET['code'])) {
                    $get_user = $client->driver('qq')->user();
                    $_SESSION['qq']['token'] = $get_user->getAccessToken();
                }else{
                    $response =$client->driver('qq')->redirect();
                    $response->send();
                    $get_user = $client->driver('qq')->user();
                }
    
                if ($_SESSION['qq']['token']) {
                    $get_user->setToken($_SESSION['qq']['token']);
                }
    
                if ($get_user->getAccessToken()) {
                    if ($get_user) {
                        $social_pictures = [
                            'avatar'        => $get_user->getAvatar(),
                            'background'    => null
                        ];
                        $connect_user = [
                            'id'        => $get_user->getId(),
                            'username'  => G\sanitize_string(G\unaccent_string($get_user->getName()), true, true),
                            'name'      => $get_user->getName(),
                            'avatar'    => $get_user->getAvatar(),
                            'url'       => null
                        ];
                        $connect_tokens = [
                            'secret'    => $get_user->getAccessToken(),
                            'token_hash'=> null
                        ];
                        $do_connect = true;
                    }
                } else {
                    G\redirect(G\get_base_url('connect/qq'));
                }
            break;


4. 添加QQ登陆验证方式(Validate social networks)

添加QQ登陆方式,以便过社交登陆验证

// app\routes\overrides\route.dashboard.php:1049~1054 

                    $social_validate = [
                        'facebook'    => ['facebook_app_id', 'facebook_app_secret'],
                        'twitter'    => ['twitter_api_key', 'twitter_api_secret'],
                        'google'    => ['google_client_id', 'google_client_secret'],
                    ];
//修改为以下内容
                    $social_validate = [
                        'facebook'    => ['facebook_app_id', 'facebook_app_secret'],
                        'twitter'    => ['twitter_api_key', 'twitter_api_secret'],
                        'google'    => ['google_client_id', 'google_client_secret'],
                        'qq'        => ['qq_client_id', 'qq_client_secret'],
                    ];


5. 仪表盘添加社交网络(Add Social Network)

添加QQ互联设置界面

//app\themes\Peafowl\overrides\views\dashboard.php:2818 

            <div class="input-label">
                <label for="qq">QQ</label>
                <div class="c5 phablet-c1"><select type="text" name="qq" id="qq" class="text-input" data-combo="qq-combo">
                    <?php
                        echo CHV\Render\get_select_options_html([1 => _s('Enabled'), 0 => _s('Disabled')], get_safe_post() ? get_safe_post()['qq'] : CHV\Settings::get('qq')); ?>
                </select></div>
                <div class="input-below"><?php _se('You need a <a href="https://connect.qq.com/manage.html" target="_blank">QQ app</a> for this.'); ?></div>
            </div>
            <div id="qq-combo">
                <div data-combo-value="1" class="switch-combo c9 phablet-c1<?php if (!(get_safe_post() ? get_safe_post()['qq'] : CHV\Settings::get('qq'))) {
                            echo ' soft-hidden';
                        } ?>">
                    <div class="input-label">
                        <label for="qq_client_id"><?php _se('QQ client id'); ?></label>
                        <input type="text" name="qq_client_id" id="qq_client_id" class="text-input" value="<?php echo get_safe_post() ? get_safe_post()['qq_client_id'] : CHV\Settings::get('qq_client_id', true); ?>">
                        <div class="input-warning red-warning"><?php echo get_input_errors()['qq_client_id']; ?></div>
                    </div>
                    <div class="input-label">
                        <label for="qq_client_secret"><?php _se('QQ client secret'); ?></label>
                        <input type="text" name="qq_client_secret" id="qq_client_secret" class="text-input" value="<?php echo get_safe_post() ? get_safe_post()['qq_client_secret'] : CHV\Settings::get('qq_client_secret', true); ?>">
                        <div class="input-warning red-warning"><?php echo get_input_errors()['qq_client_secret']; ?></div>
                    </div>
                </div>
            </div>


6. 添加CSS样式文件(Adding style.css)

// appthemesPeafowlcustom_hooks\

添加 style.css


7. 【重要】升级数据库(Upgrade database)

执行http://yourwebsite.com/install-qq 升级数据库,更新QQ登陆方式!

升级数据库


文件下载(Download)

此处为隐藏内容,请评论后刷新查看内容(免注册),谢谢!

## Hash校验

MD5: FE7BD8CC6B6A3E4F7455A70C205FC568

SHA1: 354F49D7469BBCEF6AC1FAB0F6144D97CE7E8CC5

CRC32: D72A42DD

致谢(Thanks)

Chevereto

Yandex Social Login for chevereto

Socialite



Chevereto 漂亮邮件模板

效果演示:

2030806560.png

简介

Chevereto 官方的邮件模板是非常简洁且单调的,某天有个突如其来的想法从脑海冒出来,想给邮件来点不一样的色彩,正好 Chevereto 程序支持自定义,说干就干!


食用指南

上传邮件模板文件至 Chevereto 主题 Peafowl/overrides/mails/ 文件目录下即可,或者直接替换掉mails 目录亦可。


目前已支持以下模板

  • 账号更换邮箱

  • 新账户注册验证

  • 账户重置密码

  • 新用户注册欢迎

更改邮件模板头图

打开邮件模板文件,找到以下代码,替换为你自己的图片链接。


$body_arr   = [ // Mail body array (easier to edit)
    'Backimg'    => 'https://resbeta.com/images/2019/02/22/365027cf0b5e911c3212750373c9f684.md.jpg',//修改此处图片链接即可
.........
};

文件下载

此处为隐藏内容,请评论后刷新查看内容(免注册),谢谢!

## Hash校验

MD5: F762E9B899F43C42B6D704EF92205344

SHA1: B7E566923829BE64A11BCE8FEE9871E5D1E2EBDE

CRC32: 995CA64F


以上内容转载自: 松鼠の博客-https://doge.uk

この記事はhttp://www.chieng.cn から来て、再現してください!

打赏 支付宝 微信