From 76cf76475c0bbe6223dbf7ebbba2656eadcc2817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=A0=E3=81=84=E3=81=A1=E3=81=BE=E3=82=8B?= <98202777+Daichimarukana@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:57:56 +0900 Subject: [PATCH] Add files via upload --- authcode/GoogleAuthenticator.php | 4 +- authcode/license.txt | 11 ++ css/home.css | 294 +++++++++++++++++++++++++++++++ emoji/addemoji.php | 18 +- emoji/index.php | 20 +-- home/index.php | 19 +- logout/index.php | 60 +++++++ logout/logout.php | 10 ++ nextpage/notification.php | 11 +- nextpage/notificationview.php | 8 +- notice/addnotice.php | 19 +- notification/index.php | 20 +-- others/index.php | 23 +-- search/index.php | 18 +- server/uwuzuabout.txt | 8 +- server/uwuzuinfo.txt | 4 +- server/uwuzurelease.txt | 20 +++ settings/addauthcode.php | 17 +- settings/index.php | 23 +-- settings/success.php | 9 +- user/index.php | 18 +- 21 files changed, 453 insertions(+), 181 deletions(-) create mode 100644 authcode/license.txt create mode 100644 logout/index.php create mode 100644 logout/logout.php diff --git a/authcode/GoogleAuthenticator.php b/authcode/GoogleAuthenticator.php index bf7d116..6bac520 100644 --- a/authcode/GoogleAuthenticator.php +++ b/authcode/GoogleAuthenticator.php @@ -98,7 +98,7 @@ class PHPGangsta_GoogleAuthenticator * * @return string */ - public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = array()) + public function getQRCodeUrl($name, $secret, $title = null, $params = array()) { $width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 200; $height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 200; @@ -109,7 +109,7 @@ class PHPGangsta_GoogleAuthenticator $urlencoded .= urlencode('&issuer='.urlencode($title)); } - return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level"; + return "$urlencoded"; } /** diff --git a/authcode/license.txt b/authcode/license.txt new file mode 100644 index 0000000..0106de3 --- /dev/null +++ b/authcode/license.txt @@ -0,0 +1,11 @@ +Copyright (c) 2012, Michael Kliewe All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +なお、このフォルダにあるコードは改変させていただいでおります。 \ No newline at end of file diff --git a/css/home.css b/css/home.css index b80c592..23fb476 100644 --- a/css/home.css +++ b/css/home.css @@ -2312,6 +2312,103 @@ label>input { } +.notification2{ + animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards; + margin: 12px; + border-radius: 10px; + padding-left: 24px; + padding-right: 24px; + padding-top: 16px; + padding-bottom: 16px; + background-color: #FFFAE6; + border: 1px solid #EEE; + width: auto; +} + +.notification2 .flebox{ + display: flex; +} + +.notification2 .flebox a{ + margin-top: auto; + margin-bottom: auto; + margin-left: 12px; + font-size: 18px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; +} + +.notification2 .flebox .idbox{ + margin-top: auto; + margin-bottom: auto; + margin-left: 6px; + border-radius: 10px; + background-color: #FFF; + border: 1px solid #EEE; +} +.notification2 .flebox .idbox a{ + margin-top: 6px; + margin-bottom: 6px; + margin-left: 8px; + margin-right: 8px; + text-align: center; + font-size: 12px; + color:#999; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; +} + +.notification2 p{ + line-height: 20px; + overflow-wrap: break-word; + margin-top: auto; + margin-bottom: auto; + margin-left: 12px; + font-size: 16px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; +} + +.notification2 h3{ + overflow-wrap: break-word; + margin-top: auto; + margin-bottom: 6px; + margin-left: 12px; + font-size: 24px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; +} + + +.notification2 .flebox .time{ + margin-top: auto; + margin-bottom: auto; + margin-left: auto; + margin-right: 12px; + text-align: right; + font-size: 12px; + color:#999; + font-family: 'BIZ UDPGothic', sans-serif; +} + +.notification2 a{ + overflow-wrap: break-word; + margin-top: 24px; + margin-bottom: auto; + margin-left: 12px; + font-size: 16px; + color:#4e4428; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; +} + .notification{ animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards; @@ -2373,6 +2470,7 @@ label>input { } .notification p{ + line-height: 20px; overflow-wrap: break-word; margin-top: auto; margin-bottom: auto; @@ -3141,6 +3239,168 @@ hr{ border: 1px solid #EEE; } + + + .notification .flebox a{ + margin-top: auto; + margin-bottom: auto; + margin-left: 12px; + font-size: 18px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + .notification .flebox .idbox{ + margin-top: auto; + margin-bottom: auto; + margin-left: 6px; + border-radius: 10px; + background-color: #FFF; + border: 1px solid #EEE; + } + .notification .flebox .idbox a{ + margin-top: 6px; + margin-bottom: 6px; + margin-left: 8px; + margin-right: 8px; + text-align: center; + font-size: 12px; + color:#999; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + } + + .notification p{ + line-height: 20px; + overflow-wrap: break-word; + margin-top: auto; + margin-bottom: auto; + margin-left: -6px; + font-size: 16px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + .notification h3{ + overflow-wrap: break-word; + margin-top: 12px; + margin-bottom: 6px; + margin-left: -6px; + font-size: 18px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + + .notification .flebox .time{ + margin-top: auto; + margin-bottom: auto; + margin-left: auto; + margin-right: -6px; + text-align: right; + font-size: 12px; + color:#999; + font-family: 'BIZ UDPGothic', sans-serif; + } + + .notification a{ + overflow-wrap: break-word; + margin-top: 32px; + margin-bottom: auto; + margin-left: -6px; + font-size: 16px; + color:#4e4428; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + .notification2 .flebox a{ + margin-top: auto; + margin-bottom: auto; + margin-left: 12px; + font-size: 18px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + .notification2 .flebox .idbox{ + margin-top: auto; + margin-bottom: auto; + margin-left: 6px; + border-radius: 10px; + background-color: #FFF; + border: 1px solid #EEE; + } + .notification2 .flebox .idbox a{ + margin-top: 6px; + margin-bottom: 6px; + margin-left: 8px; + margin-right: 8px; + text-align: center; + font-size: 12px; + color:#999; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + } + + .notification2 p{ + line-height: 20px; + overflow-wrap: break-word; + margin-top: auto; + margin-bottom: auto; + margin-left: -6px; + font-size: 16px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + .notification2 h3{ + overflow-wrap: break-word; + margin-top: 12px; + margin-bottom: 6px; + margin-left: -6px; + font-size: 18px; + color:#252525; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + + + .notification2 .flebox .time{ + margin-top: auto; + margin-bottom: auto; + margin-left: auto; + margin-right: -6px; + text-align: right; + font-size: 12px; + color:#999; + font-family: 'BIZ UDPGothic', sans-serif; + } + + .notification2 a{ + overflow-wrap: break-word; + margin-top: 32px; + margin-bottom: auto; + margin-left: -6px; + font-size: 16px; + color:#4e4428; + text-decoration: none; + font-family: 'BIZ UDPGothic', sans-serif; + font-weight: bold; + } + } /*------------------------------------------------------------------------------------------------------------*/ @@ -3506,6 +3766,12 @@ hr{ color: #FFFAE6; } + + .btmbutton_on{ + background-color: #FFC832; + color:#FF4444; + } + .terms{ background-color: #0c0c0c; @@ -3559,6 +3825,34 @@ hr{ color: #FFF; } + .notification2{ + background-color: #3a3333; + border: none; + } + + .notification2 .flebox a{ + color:#CCC5; + } + + .notification2 p{ + color:#FFF; + } + + .notification2 h3{ + color:#CCC; + } + + + .notification2 .flebox .time{ + color:#CCC; + } + + .notification2 a{ + color:#FFC832; + } + + + .notification{ background-color: #181616; border: none; diff --git a/emoji/addemoji.php b/emoji/addemoji.php index a7f0213..316042a 100644 --- a/emoji/addemoji.php +++ b/emoji/addemoji.php @@ -259,23 +259,7 @@ if( !empty($_POST['btn_submit']) ) { } -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} +require('../logout/logout.php'); diff --git a/emoji/index.php b/emoji/index.php index 7974507..3442af4 100644 --- a/emoji/index.php +++ b/emoji/index.php @@ -125,25 +125,7 @@ if (!empty($pdo)) { } } -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} - - +require('../logout/logout.php'); // データベースの接続を閉じる diff --git a/home/index.php b/home/index.php index 81ff420..4faa00e 100644 --- a/home/index.php +++ b/home/index.php @@ -300,24 +300,7 @@ if( !empty($_POST['btn_submit']) ) { -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} - +require('../logout/logout.php'); diff --git a/logout/index.php b/logout/index.php new file mode 100644 index 0000000..5fe4129 --- /dev/null +++ b/logout/index.php @@ -0,0 +1,60 @@ + + + + + + + + + + + +ログアウト完了 - <?php echo file_get_contents($servernamefile);?> + + + + + + + +
+ + +
+

ログアウト完了

+


ログアウトが完了しました!

+

ボタンを押すとログインページにリダイレクトします。

+ + +
+
+ + + + \ No newline at end of file diff --git a/logout/logout.php b/logout/logout.php new file mode 100644 index 0000000..da38f1c --- /dev/null +++ b/logout/logout.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/nextpage/notification.php b/nextpage/notification.php index 3bea3d4..b7ea5af 100644 --- a/nextpage/notification.php +++ b/nextpage/notification.php @@ -41,6 +41,11 @@ if (!empty($pdo)) { PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, )); + $messageQuery = $dbh->prepare("SELECT title,msg,url,datetime,userchk FROM notification WHERE touserid = :userid ORDER BY datetime DESC LIMIT $offset, $itemsPerPage"); + $messageQuery->bindValue(':userid', $userid); + $messageQuery->execute(); + $message_array = $messageQuery->fetchAll(); + // トランザクション開始 $pdo->beginTransaction(); @@ -52,12 +57,6 @@ if (!empty($pdo)) { $res = $stmt->execute(); $res = $pdo->commit(); - - $messageQuery = $dbh->prepare("SELECT title,msg,url,datetime,userchk FROM notification WHERE touserid = :userid ORDER BY datetime DESC LIMIT $offset, $itemsPerPage"); - $messageQuery->bindValue(':userid', $userid); - $messageQuery->execute(); - $message_array = $messageQuery->fetchAll(); - if (!empty($message_array)) { foreach ($message_array as $value) { $messageDisplay = new MessageDisplay($value); // userid を渡さない diff --git a/nextpage/notificationview.php b/nextpage/notificationview.php index 4727d44..0925e64 100644 --- a/nextpage/notificationview.php +++ b/nextpage/notificationview.php @@ -7,7 +7,11 @@ class MessageDisplay { } public function display() { - echo '
'; + if($this->value['userchk'] === "none"){ + echo '
'; + }else{ + echo '
'; + } echo '
'; echo '
'; @@ -24,7 +28,7 @@ class MessageDisplay { // 投稿内のHTMLコードを表示する部分 echo '

' . htmlentities($this->value['title']) . '

'; echo '

' . htmlentities($this->value['msg']) . '

'; - echo ' 続きをみる'; + echo ' 詳細をみる'; echo '
'; } diff --git a/notice/addnotice.php b/notice/addnotice.php index 585f132..9a0adcb 100644 --- a/notice/addnotice.php +++ b/notice/addnotice.php @@ -219,24 +219,7 @@ if( !empty($_POST['btn_submit']) ) { } -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} - +require('../logout/logout.php'); // データベースの接続を閉じる diff --git a/notification/index.php b/notification/index.php index 5374e41..f971606 100644 --- a/notification/index.php +++ b/notification/index.php @@ -118,25 +118,7 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC); $notificationcount = $notiData['notification_count']; -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} - - +require('../logout/logout.php'); // データベースの接続を閉じる $pdo = null; diff --git a/others/index.php b/others/index.php index d14c128..505ccc2 100644 --- a/others/index.php +++ b/others/index.php @@ -187,6 +187,11 @@ if( !empty($_POST['btn_submit']) ) { $deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR); $res = $deleteQuery->execute(); + // 通知削除クエリを実行 + $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid"); + $deleteQuery->bindValue(':touserid', $userid, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + // フォローの更新 $updateFollowQuery = $pdo->prepare("UPDATE account SET follow = REPLACE(follow, :userid, '') WHERE follow LIKE :pattern"); $updateFollowQuery->bindValue(':userid', ",$userid", PDO::PARAM_STR); @@ -284,23 +289,7 @@ if( !empty($_POST['session_submit']) ) { } -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} +require('../logout/logout.php'); ?> diff --git a/search/index.php b/search/index.php index d3fd5ac..5f2cb30 100644 --- a/search/index.php +++ b/search/index.php @@ -116,23 +116,7 @@ $notificationcount = $notiData['notification_count']; //------------------------------------------- -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} +require('../logout/logout.php'); diff --git a/server/uwuzuabout.txt b/server/uwuzuabout.txt index a0ebfcf..d23be35 100644 --- a/server/uwuzuabout.txt +++ b/server/uwuzuabout.txt @@ -10,6 +10,8 @@ uwuzuの読みはゆずです。 ## 2. 誰でもサーバーを建てれるってことは、分散型? 残念っ! uwuzuにはActivityPubやその他の連合用機能がないため基本的に導入されたサーバー中心の中央集権型SNSです! +いやでも中央集権型でも誰でもサーバーを立てれるから分散型...? +分散中央型SNSな気がしてきました!(?) 今後いつかはActivityPubも導入しようかと思っています... ## 3. 名前の由来って何? @@ -26,7 +28,7 @@ uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作 ライブラリはjQueryを導入しています! ## 5. サーバーの建て方 -※MySQLの設定結構めんどいです。脆弱です。 +※MySQLの設定結構めんどいです。 まず、Apache2とPHP 8とmysql Ver 15が導入されているサーバーを準備します! 次にSQLを設定します。(InnoDB) まず、お好きな名前でDBを作成し、その中に、account,emoji,notice,role,ueuse,notificationとテーブルを作成します。 @@ -53,6 +55,8 @@ uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作 - follow(text) アカウントがフォローしている人保存用 - follower(text) アカウントがフォローされている人保存用 - admin(varchar(25)) 管理者アカウントなら「yes」、それ以外なら「none」と入力。 +- authcode(varchar(256)) 二段階認証用キー保存用 +- backupcode(varchar(256)) 二段階認証のバックアップコード保存用 ### emoji - sysid(INT)(AUTO_INCREMENT) アカウントが追加されるとカウントされるシステム用ID @@ -122,7 +126,7 @@ uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作 - onlyuser.txt : 招待コード機能をオンにするかどうか、「true」でオン、「false」でオフ。招待コードはDBに直接追加。 ### これでサーバーは完成!!! -結構脆弱だから気をつけてね... +もう一度サーバーを起動してみんなに公開しよう!!! ## 6. Android、iOS、その他OS向けのアプリについて 残念ですが今現在は公式アプリ等はなく、Webブラウザからお楽しみいただけます。 diff --git a/server/uwuzuinfo.txt b/server/uwuzuinfo.txt index 8ef5948..05b25ef 100644 --- a/server/uwuzuinfo.txt +++ b/server/uwuzuinfo.txt @@ -1,4 +1,4 @@ uwuzu -1.2.6 -2023/08/19 +1.2.8 +2023/08/21 daichimarukana,putonfps \ No newline at end of file diff --git a/server/uwuzurelease.txt b/server/uwuzurelease.txt index 0fb9edd..d723b5a 100644 --- a/server/uwuzurelease.txt +++ b/server/uwuzurelease.txt @@ -1,6 +1,26 @@ ## リリースノートだぜぇぇぇぇぇぇい!!!!!!! ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...) +## Version 1.2.8 +リリース日:2023/08/21 +ログイン時にリダイレクトを繰り返してしまうバグを修正しました。 +ログアウトできないバグを修正しました。 + +## Version 1.2.7 +リリース日:2023/08/21 +通知画面のスマホ向けUIを改善しました。 +Y.Swetake様よりファイルをお借りすることによりQRコードをサーバー上で生成できるようにしました。 +それにより高速なQRコードの生成が可能となりました。 +また、Michael Kliewe様の二段階認証実装用ライブラリのコードを一部改変させていただきました。 +二段階認証のバックアップコードを生成する機能を作成しました。 +ログイン通知を送信するようにしました。 +未読の通知をわかりやすくしました。 +アカウント削除時に通知が削除されるようにしました。 + +## Version 1.2.6.1 +リリース日:2023/08/19 +CSSの変更忘れです。 + ## Version 1.2.6 リリース日:2023/08/19 ログイン時の二段階認証入力画面を数字のみに限定しました。 diff --git a/settings/addauthcode.php b/settings/addauthcode.php index 7848501..45b5568 100644 --- a/settings/addauthcode.php +++ b/settings/addauthcode.php @@ -8,6 +8,11 @@ function createUniqId(){ return base_convert($hashCreateTime,10,36); } +function random($length = 32) +{ + return substr(str_shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length); +} + require('../db.php'); @@ -142,6 +147,7 @@ if( !empty($_POST['btn_submit']) ) { $checkResult = $chkauthcode->verifyCode($secret, $userauthcode, $discrepancy); if ($checkResult) { if( empty($error_message) ) { + $backupcode = random(); $secret = $_SESSION['secretcode']; // トランザクション開始 $pdo->beginTransaction(); @@ -149,10 +155,10 @@ if( !empty($_POST['btn_submit']) ) { try { // SQL作成 - $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode WHERE userid = :userid"); + $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode,backupcode = :backupcode WHERE userid = :userid"); $stmt->bindValue(':authcode', $secret, PDO::PARAM_STR); - + $stmt->bindValue(':backupcode', $backupcode, PDO::PARAM_STR); // ユーザーIDのバインド(WHERE句に必要) $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); @@ -171,6 +177,7 @@ if( !empty($_POST['btn_submit']) ) { if ($res) { // リダイレクト先のURLへ転送する + $_SESSION['backupcode'] = $backupcode; $url = 'success.php'; header('Location: ' . $url, true, 303); exit; @@ -186,7 +193,7 @@ if( !empty($_POST['btn_submit']) ) { } } - +require('../logout/logout.php'); // データベースの接続を閉じる $pdo = null; @@ -232,14 +239,14 @@ $pdo = null; $name = $userid; - $qrCodeUrl = $authcode->getQRCodeGoogleUrl($name, $secret, $title); + $qrCodeUrl = $authcode->getQRCodeUrl($name, $secret, $title); ?>

以下の二次元コードより二段階認証をセットアップしてください。

セットアップが完了したら入力ボックスにコードを入力して「次へ」ボタンを押してください!
注意:まだ二段階認証の設定は終わっていません。次へを押すと設定が完了します。

- +

二段階認証コード

diff --git a/settings/index.php b/settings/index.php index 51074d2..3867007 100644 --- a/settings/index.php +++ b/settings/index.php @@ -568,23 +568,7 @@ if( !empty($_POST['img2btn_submit']) ) { } } -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} +require('../logout/logout.php'); if( !empty($_POST['auth_on_submit']) ) { $_SESSION['userid'] = $userid; @@ -599,15 +583,17 @@ if( !empty($_POST['auth_on_submit']) ) { if( !empty($_POST['auth_off_submit']) ) { if( empty($error_message) ) { $secret = ""; + $backupcode = ""; // トランザクション開始 $pdo->beginTransaction(); try { // SQL作成 - $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode WHERE userid = :userid"); + $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode,backupcode = :backupcode WHERE userid = :userid"); $stmt->bindValue(':authcode', $secret, PDO::PARAM_STR); + $stmt->bindValue(':backupcode', $backupcode, PDO::PARAM_STR); // ユーザーIDのバインド(WHERE句に必要) $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); @@ -716,6 +702,7 @@ $pdo = null; +

一時的に有効なキーを生成する二段階認証を設定することにより本人以外がログインしにくくなります。

下のボタンを押すとすぐに解除されます。確認などはありません。気をつけてください。

diff --git a/settings/success.php b/settings/success.php index 0ad5b91..f17f72e 100644 --- a/settings/success.php +++ b/settings/success.php @@ -22,7 +22,7 @@ $option = null; $userid = $_SESSION['userid']; - +$backupcode = $_SESSION['backupcode']; try { @@ -112,6 +112,8 @@ $notiQuery->execute(); $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC); $notificationcount = $notiData['notification_count']; + +require('../logout/logout.php'); ?> @@ -148,8 +150,11 @@ $notificationcount = $notiData['notification_count']; - +

登録完了!セキュリティの強化にご協力いただきありがとうございます!
(≧∇≦)

+

バックアップコードは以下のものです!
以下のコードでスマートフォンをなくしてしまったなどのもしものときにログインいただけます。
絶対に大切に保管してください!
また、そのバックアップコードは絶対に公開しないでください。

+

+

戻る
diff --git a/user/index.php b/user/index.php index ef43ea5..075e9ab 100644 --- a/user/index.php +++ b/user/index.php @@ -291,23 +291,7 @@ if (!empty($_POST['follow'])) { -if( !empty($_POST['logout']) ) { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - // リダイレクト先のURLへ転送する - $url = '../index.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; -} +require('../logout/logout.php');