diff --git a/abi/addabi.php b/abi/addabi.php
index 6766577..021a307 100644
--- a/abi/addabi.php
+++ b/abi/addabi.php
@@ -1,40 +1,40 @@
-beginTransaction();
-
- $stmt = $pdo->prepare("UPDATE ueuse SET abi = :abi, abidate = :abidate WHERE uniqid = :uniqid");
- $stmt->bindValue(':abi', $abitext, PDO::PARAM_STR);
- $stmt->bindValue(':abidate', $abidate, PDO::PARAM_STR);
- $stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
-
- // SQLクエリの実行
- $res = $stmt->execute();
-
- // コミット
- $pdo->commit();
-
- if ($res) {
- header('Content-Type: application/json');
- echo json_encode(['success' => true]);
- exit;
- } else {
- header('Content-Type: application/json');
- echo json_encode(['success' => false, 'error' => '追加に失敗しました。']);
- exit;
- }
- } catch(PDOException $e) {
- header('Content-Type: application/json');
- echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
- exit;
- }
-}
-?>
+beginTransaction();
+
+ $stmt = $pdo->prepare("UPDATE ueuse SET abi = :abi, abidate = :abidate WHERE uniqid = :uniqid");
+ $stmt->bindValue(':abi', $abitext, PDO::PARAM_STR);
+ $stmt->bindValue(':abidate', $abidate, PDO::PARAM_STR);
+ $stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
+
+ // SQLクエリの実行
+ $res = $stmt->execute();
+
+ // コミット
+ $pdo->commit();
+
+ if ($res) {
+ header('Content-Type: application/json');
+ echo json_encode(['success' => true]);
+ exit;
+ } else {
+ header('Content-Type: application/json');
+ echo json_encode(['success' => false, 'error' => '追加に失敗しました。']);
+ exit;
+ }
+ } catch(PDOException $e) {
+ header('Content-Type: application/json');
+ echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
+ exit;
+ }
+}
+?>
diff --git a/addauthcode.php b/addauthcode.php
new file mode 100644
index 0000000..5fc9c8d
--- /dev/null
+++ b/addauthcode.php
@@ -0,0 +1,224 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
+
+} catch(PDOException $e) {
+
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+require_once 'authcode/GoogleAuthenticator.php';
+
+if(empty($_SESSION['secretcode'])){
+ $authcode = new PHPGangsta_GoogleAuthenticator();
+ $secret = $authcode->createSecret();
+ $_SESSION['secretcode'] = $secret;
+}else{
+ $authcode = new PHPGangsta_GoogleAuthenticator();
+ $secret = $_SESSION['secretcode'];
+}
+
+if( !empty($_POST['btn_submit']) ) {
+ $chkauthcode = new PHPGangsta_GoogleAuthenticator();
+ //二段階認証の確認
+ $userauthcode = $_POST['usercode'];
+
+ $discrepancy = 2;
+
+ $checkResult = $chkauthcode->verifyCode($secret, $userauthcode, $discrepancy);
+ if ($checkResult) {
+ if( empty($error_message) ) {
+ $secret = $_SESSION['secretcode'];
+ // トランザクション開始
+ $pdo->beginTransaction();
+
+ try {
+
+ // SQL作成
+ $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode WHERE userid = :userid");
+
+ $stmt->bindValue(':authcode', $secret, PDO::PARAM_STR);
+
+ // ユーザーIDのバインド(WHERE句に必要)
+ $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
+
+ // SQLクエリの実行
+ $res = $stmt->execute();
+
+ // コミット
+ $res = $pdo->commit();
+
+
+ } catch (Exception $e) {
+
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
+ }
+
+ if ($res) {
+ 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, '/');
+ }
+ }
+ $userid = "";
+ // リダイレクト先のURLへ転送する
+ $url = 'success.php';
+ header('Location: ' . $url, true, 303);
+ exit;
+ } else {
+ $error_message[] = '更新に失敗しました。';
+ }
+
+ // プリペアドステートメントを削除
+ $stmt = null;
+ }
+ } else {
+ $error_message[] = "二段階認証が出来ませんでした。再度お試しください。";
+ }
+}
+
+
+
+// データベースの接続を閉じる
+$pdo = null;
+
+?>
+
+
+
+
diff --git a/nextpage/nextpage.php b/nextpage/nextpage.php
index 9270139..f4c856f 100644
--- a/nextpage/nextpage.php
+++ b/nextpage/nextpage.php
@@ -1,124 +1,112 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
-} catch (PDOException $e) {
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-$userid = $_GET['userid'];
-
-$itemsPerPage = 30; // 1ページあたりのユーズ数
-$pageNumber = isset($_GET['page']) ? intval($_GET['page']) : 1;
-$offset = ($pageNumber - 1) * $itemsPerPage;
-
-$messages = array();
-
-if (!empty($pdo)) {
-
- function customStripTags($html, $allowedTags) {
- $allowedTagString = implode('|', $allowedTags);
- $pattern = "/<(?!$allowedTagString)[^>]+>/";
- return preg_replace($pattern, '', $html);
- }
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font');
-
- // ユーズ内の絵文字を画像に置き換える
- function replaceEmojisWithImages($postText) {
- // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
- $pattern = '/:(\w+):/';
- $postTextWithImages = preg_replace_callback($pattern, function($matches) {
- $emojiName = $matches[1];
- return "
";
- }, $postText);
- return $postTextWithImages;
- }
-
- function replaceURLsWithLinks($postText) {
- // URLを正規表現を使って検出
- $pattern = '/(https?:\/\/[^\s]+)/';
- preg_match_all($pattern, $postText, $matches);
-
- // 検出したURLごとに処理を行う
- foreach ($matches[0] as $url) {
- // ドメイン部分を抽出
- $parsedUrl = parse_url($url);
- $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
-
- // ドメインのみを表示するaタグを生成
- $link = "
$domain ";
-
- // URLをドメインのみを表示するaタグで置き換え
- $postText = str_replace($url, $link, $postText);
- }
-
- return $postText;
- }
-
-
- $sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT $offset, $itemsPerPage";
- $message_array = $pdo->query($sql);
-
- while ($row = $message_array->fetch(PDO::FETCH_ASSOC)) {
-
- $messages[] = $row;
- }
-
- // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
- foreach ($messages as &$message) {
- $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $message["account"]);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-
- if ($userData) {
- $message['username'] = $userData['username'];
- }
- }
-
- // ユーズ内のHTMLコードに指定のタグを有効化する関数
- function replaceUnescapedHTMLTags($html) {
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font'); // 有効化するタグ
- return customStripTags($html, $allowedTags);
- }
-
- if(!empty($messages)){
- foreach ($messages as $value) {
-
- $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
-
- // コンマで区切って配列に分割し、要素数を数える
- $favIds = explode(',', $fav);
- $value["favcnt"] = count($favIds)-1;
-
- $messageDisplay = new MessageDisplay($value, $userid); // $userid をコンストラクタに渡す
- $messageDisplay->display();
- }
- }else{
- echo '
';
- }
-
- $pdo = null;
-
-}
-
-?>
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
+} catch (PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+$userid = htmlentities($_GET['userid']);
+
+$itemsPerPage = 30; // 1ページあたりのユーズ数
+$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
+$offset = ($pageNumber - 1) * $itemsPerPage;
+
+$messages = array();
+
+if (!empty($pdo)) {
+
+
+ // ユーズ内の絵文字を画像に置き換える
+ function replaceEmojisWithImages($postText) {
+ // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
+ $pattern = '/:(\w+):/';
+ $postTextWithImages = preg_replace_callback($pattern, function($matches) {
+ $emojiName = $matches[1];
+ return "
";
+ }, $postText);
+ return $postTextWithImages;
+ }
+
+ function replaceURLsWithLinks($postText) {
+ // URLを正規表現を使って検出
+ $pattern = '/(https?:\/\/[^\s]+)/';
+ preg_match_all($pattern, $postText, $matches);
+
+ // 検出したURLごとに処理を行う
+ foreach ($matches[0] as $url) {
+ // ドメイン部分を抽出
+ $parsedUrl = parse_url($url);
+ $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
+
+ // ドメインのみを表示するaタグを生成
+ $link = "
$domain ";
+
+ // URLをドメインのみを表示するaタグで置き換え
+ $postText = str_replace($url, $link, $postText);
+ }
+
+ return $postText;
+ }
+
+
+ $sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT $offset, $itemsPerPage";
+ $message_array = $pdo->query($sql);
+
+ while ($row = $message_array->fetch(PDO::FETCH_ASSOC)) {
+
+ $messages[] = $row;
+ }
+
+ // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
+ foreach ($messages as &$message) {
+ $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $message["account"]);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+
+ if ($userData) {
+ $message['username'] = $userData['username'];
+ }
+ }
+
+ if(!empty($messages)){
+ foreach ($messages as $value) {
+
+ $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
+
+ // コンマで区切って配列に分割し、要素数を数える
+ $favIds = explode(',', $fav);
+ $value["favcnt"] = count($favIds)-1;
+
+ $messageDisplay = new MessageDisplay($value, $userid); // $userid をコンストラクタに渡す
+ $messageDisplay->display();
+ }
+ }else{
+ echo '
';
+ }
+
+ $pdo = null;
+
+}
+
+?>
diff --git a/nextpage/notification.php b/nextpage/notification.php
index c5b710e..7b36cfb 100644
--- a/nextpage/notification.php
+++ b/nextpage/notification.php
@@ -1,63 +1,63 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
-} catch (PDOException $e) {
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-$userid = $_GET['userid'];
-
-$itemsPerPage = 30; // 1ページあたりの投稿数
-$pageNumber = isset($_GET['page']) ? intval($_GET['page']) : 1;
-$offset = ($pageNumber - 1) * $itemsPerPage;
-
-$messages = array();
-
-if (!empty($pdo)) {
-
- $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- 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();
-
- if (!empty($message_array)) {
- foreach ($message_array as $value) {
- $messageDisplay = new MessageDisplay($value); // userid を渡さない
- $messageDisplay->display();
- }
- } else {
- echo '
';
- }
-
-
- $pdo = null;
-
-}
-
-?>
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
+} catch (PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+$userid = htmlentities($_GET['userid']);
+
+$itemsPerPage = 30; // 1ページあたりの投稿数
+$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
+$offset = ($pageNumber - 1) * $itemsPerPage;
+
+$messages = array();
+
+if (!empty($pdo)) {
+
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ 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();
+
+ if (!empty($message_array)) {
+ foreach ($message_array as $value) {
+ $messageDisplay = new MessageDisplay($value); // userid を渡さない
+ $messageDisplay->display();
+ }
+ } else {
+ echo '
';
+ }
+
+
+ $pdo = null;
+
+}
+
+?>
diff --git a/nextpage/notificationview.php b/nextpage/notificationview.php
index 8a94294..4727d44 100644
--- a/nextpage/notificationview.php
+++ b/nextpage/notificationview.php
@@ -1,32 +1,32 @@
-value = $value;
- }
-
- public function display() {
- echo '
';
- echo '
';
-
- echo '
';
- $day = date("Ymd", strtotime(htmlspecialchars($this->value['datetime'])));
- if ($day == date("Ymd")) {
- echo date("今日 H:i", strtotime(htmlspecialchars($this->value['datetime'])));
- } else {
- echo date("Y年m月d日 H:i", strtotime(htmlspecialchars($this->value['datetime'])));
- }
- echo '
';
-
- echo '
';
-
- // 投稿内のHTMLコードを表示する部分
- echo '
' . htmlspecialchars($this->value['title']) . ' ';
- echo '
' . htmlspecialchars($this->value['msg']) . '
';
- echo '
続きをみる ';
-
- echo '
';
- }
-}
-?>
+value = $value;
+ }
+
+ public function display() {
+ echo '
';
+ echo '
';
+
+ echo '
';
+ $day = date("Ymd", strtotime(htmlentities($this->value['datetime'])));
+ if ($day == date("Ymd")) {
+ echo date("今日 H:i", strtotime(htmlentities($this->value['datetime'])));
+ } else {
+ echo date("Y年m月d日 H:i", strtotime(htmlentities($this->value['datetime'])));
+ }
+ echo '
';
+
+ echo '
';
+
+ // 投稿内のHTMLコードを表示する部分
+ echo '
' . htmlentities($this->value['title']) . ' ';
+ echo '
' . htmlentities($this->value['msg']) . '
';
+ echo '
続きをみる ';
+
+ echo '
';
+ }
+}
+?>
diff --git a/nextpage/searchpage.php b/nextpage/searchpage.php
index c14d434..e30193f 100644
--- a/nextpage/searchpage.php
+++ b/nextpage/searchpage.php
@@ -1,131 +1,118 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
-} catch (PDOException $e) {
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-
-$keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
-$userid = $_GET['userid'];
-
-$messages = array();
-
-if (!empty($pdo)) {
-
- $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
- ));
-
- $messageQuery = $dbh->prepare("SELECT account,username,ueuse,uniqid,rpuniqid,datetime,photo1,photo2,video1,favorite, abi, abidate FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC");
- $messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR);
- $messageQuery->execute();
- $message_array = $messageQuery->fetchAll();
-
- function customStripTags($html, $allowedTags) {
- $allowedTagString = implode('|', $allowedTags);
- $pattern = "/<(?!$allowedTagString)[^>]+>/";
- return preg_replace($pattern, '', $html);
- }
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font');
-
- // ユーズ内の絵文字を画像に置き換える
- function replaceEmojisWithImages($postText) {
- // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
- $pattern = '/:(\w+):/';
- $postTextWithImages = preg_replace_callback($pattern, function($matches) {
- $emojiName = $matches[1];
- return "
";
- }, $postText);
- return $postTextWithImages;
- }
-
- function replaceURLsWithLinks($postText) {
- // URLを正規表現を使って検出
- $pattern = '/(https?:\/\/[^\s]+)/';
- preg_match_all($pattern, $postText, $matches);
-
- // 検出したURLごとに処理を行う
- foreach ($matches[0] as $url) {
- // ドメイン部分を抽出
- $parsedUrl = parse_url($url);
- $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
-
- // ドメインのみを表示するaタグを生成
- $link = "
$domain ";
-
- // URLをドメインのみを表示するaタグで置き換え
- $postText = str_replace($url, $link, $postText);
- }
-
- return $postText;
- }
-
-
-
-
- $messages = array();
- foreach ($message_array as $row) {
- $messages[] = $row;
- }
- // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
- foreach ($messages as &$message) {
- $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $message["account"]);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-
- if ($userData) {
- $message['username'] = $userData['username'];
- }
- }
-
- // ユーズ内のHTMLコードに指定のタグを有効化する関数
- function replaceUnescapedHTMLTags($html) {
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font'); // 有効化するタグ
- return customStripTags($html, $allowedTags);
- }
-
- if(!empty($messages)){
- foreach ($messages as $value) {
-
- $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
-
- // コンマで区切って配列に分割し、要素数を数える
- $favIds = explode(',', $fav);
- $value["favcnt"] = count($favIds)-1;
-
- $messageDisplay = new MessageDisplay($value, $userid);
- $messageDisplay->display();
- }
- }else{
- echo '
';
- }
-
- $pdo = null;
-
-}
-
-?>
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
+} catch (PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+
+$keyword = htmlentities(isset($_GET['keyword'])) ? htmlentities($_GET['keyword']) : '';
+$userid = htmlentities($_GET['userid']);
+
+$messages = array();
+
+if (!empty($pdo)) {
+
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
+ ));
+
+ $messageQuery = $dbh->prepare("SELECT account,username,ueuse,uniqid,rpuniqid,datetime,photo1,photo2,video1,favorite, abi, abidate FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC");
+ $messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR);
+ $messageQuery->execute();
+ $message_array = $messageQuery->fetchAll();
+
+ // ユーズ内の絵文字を画像に置き換える
+ function replaceEmojisWithImages($postText) {
+ // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
+ $pattern = '/:(\w+):/';
+ $postTextWithImages = preg_replace_callback($pattern, function($matches) {
+ $emojiName = $matches[1];
+ return "
";
+ }, $postText);
+ return $postTextWithImages;
+ }
+
+ function replaceURLsWithLinks($postText) {
+ // URLを正規表現を使って検出
+ $pattern = '/(https?:\/\/[^\s]+)/';
+ preg_match_all($pattern, $postText, $matches);
+
+ // 検出したURLごとに処理を行う
+ foreach ($matches[0] as $url) {
+ // ドメイン部分を抽出
+ $parsedUrl = parse_url($url);
+ $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
+
+ // ドメインのみを表示するaタグを生成
+ $link = "
$domain ";
+
+ // URLをドメインのみを表示するaタグで置き換え
+ $postText = str_replace($url, $link, $postText);
+ }
+
+ return $postText;
+ }
+
+
+
+
+ $messages = array();
+ foreach ($message_array as $row) {
+ $messages[] = $row;
+ }
+ // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
+ foreach ($messages as &$message) {
+ $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $message["account"]);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+
+ if ($userData) {
+ $message['username'] = $userData['username'];
+ }
+ }
+
+ if(!empty($messages)){
+ foreach ($messages as $value) {
+
+ $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
+
+ // コンマで区切って配列に分割し、要素数を数える
+ $favIds = explode(',', $fav);
+ $value["favcnt"] = count($favIds)-1;
+
+ $messageDisplay = new MessageDisplay($value, $userid);
+ $messageDisplay->display();
+ }
+ }else{
+ echo '
';
+ }
+
+ $pdo = null;
+
+}
+
+?>
diff --git a/nextpage/ueusepage.php b/nextpage/ueusepage.php
index 7de81e8..087304c 100644
--- a/nextpage/ueusepage.php
+++ b/nextpage/ueusepage.php
@@ -1,139 +1,125 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
-} catch (PDOException $e) {
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-$userid = $_GET['userid'];
-
-$ueuseid = isset($_GET['id']) ? $_GET['id'] : '';
-
-$itemsPerPage = 30; // 1ページあたりの投稿数
-$pageNumber = isset($_GET['page']) ? intval($_GET['page']) : 1;
-$offset = ($pageNumber - 1) * $itemsPerPage;
-
-$messages = array();
-
-if (!empty($pdo)) {
-
-
- // データベース接続の設定
- $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
- ));
-
-
-
- function customStripTags($html, $allowedTags) {
- $allowedTagString = implode('|', $allowedTags);
- $pattern = "/<(?!$allowedTagString)[^>]+>/";
- return preg_replace($pattern, '', $html);
- }
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font');
- // 投稿内の絵文字を画像に置き換える
- function replaceEmojisWithImages($postText) {
- // 投稿内で絵文字名(:emoji:)を検出して画像に置き換える
- $pattern = '/:(\w+):/';
- $postTextWithImages = preg_replace_callback($pattern, function($matches) {
- $emojiName = $matches[1];
- return "
";
- }, $postText);
- return $postTextWithImages;
- }
-
- function replaceURLsWithLinks($postText) {
- // URLを正規表現を使って検出
- $pattern = '/(https?:\/\/[^\s]+)/';
- preg_match_all($pattern, $postText, $matches);
-
- // 検出したURLごとに処理を行う
- foreach ($matches[0] as $url) {
- // ドメイン部分を抽出
- $parsedUrl = parse_url($url);
- $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
-
- // ドメインのみを表示するaタグを生成
- $link = "
$domain ";
-
- // URLをドメインのみを表示するaタグで置き換え
- $postText = str_replace($url, $link, $postText);
- }
-
- return $postText;
- }
-
- // 投稿内容の取得(新しい順に取得)
- $messageQuery = $dbh->prepare("SELECT account, username, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT $offset, $itemsPerPage");
- $messageQuery->bindValue(':ueuseid', $ueuseid);
- $messageQuery->bindValue(':rpueuseid', $ueuseid);
- $messageQuery->execute();
- $message_array = $messageQuery->fetchAll();
-
- $messages = array();
-
-
-
- foreach ($message_array as $row) {
- $messages[] = $row;
- }
- // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
- foreach ($messages as &$message) {
- $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $message["account"]);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-
- if ($userData) {
- $message['username'] = $userData['username'];
- }
- }
-
- // 投稿内のHTMLコードに指定のタグを有効化する関数
- function replaceUnescapedHTMLTags($html) {
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font'); // 有効化するタグ
- return customStripTags($html, $allowedTags);
- }
-
- if(!empty($messages)){
- foreach ($messages as $value) {
- $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
-
- // コンマで区切って配列に分割し、要素数を数える
- $favIds = explode(',', $fav);
- $value["favcnt"] = count($favIds)-1;
-
- $messageDisplay = new MessageDisplay($value, $userid);
- $messageDisplay->display();
- }
- }else{
- echo '
';
- }
-
- $pdo = null;
-
-}
-
-?>
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
+} catch (PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+$userid = htmlentities($_GET['userid']);
+
+$ueuseid = htmlentities(isset($_GET['id'])) ? htmlentities($_GET['id']) : '';
+
+$itemsPerPage = 30; // 1ページあたりの投稿数
+$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
+$offset = ($pageNumber - 1) * $itemsPerPage;
+
+$messages = array();
+
+if (!empty($pdo)) {
+
+
+ // データベース接続の設定
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
+ ));
+
+ // 投稿内の絵文字を画像に置き換える
+ function replaceEmojisWithImages($postText) {
+ // 投稿内で絵文字名(:emoji:)を検出して画像に置き換える
+ $pattern = '/:(\w+):/';
+ $postTextWithImages = preg_replace_callback($pattern, function($matches) {
+ $emojiName = $matches[1];
+ return "
";
+ }, $postText);
+ return $postTextWithImages;
+ }
+
+ function replaceURLsWithLinks($postText) {
+ // URLを正規表現を使って検出
+ $pattern = '/(https?:\/\/[^\s]+)/';
+ preg_match_all($pattern, $postText, $matches);
+
+ // 検出したURLごとに処理を行う
+ foreach ($matches[0] as $url) {
+ // ドメイン部分を抽出
+ $parsedUrl = parse_url($url);
+ $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
+
+ // ドメインのみを表示するaタグを生成
+ $link = "
$domain ";
+
+ // URLをドメインのみを表示するaタグで置き換え
+ $postText = str_replace($url, $link, $postText);
+ }
+
+ return $postText;
+ }
+
+ // 投稿内容の取得(新しい順に取得)
+ $messageQuery = $dbh->prepare("SELECT account, username, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT $offset, $itemsPerPage");
+ $messageQuery->bindValue(':ueuseid', $ueuseid);
+ $messageQuery->bindValue(':rpueuseid', $ueuseid);
+ $messageQuery->execute();
+ $message_array = $messageQuery->fetchAll();
+
+ $messages = array();
+
+
+
+ foreach ($message_array as $row) {
+ $messages[] = $row;
+ }
+ // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
+ foreach ($messages as &$message) {
+ $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $message["account"]);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+
+ if ($userData) {
+ $message['username'] = $userData['username'];
+ }
+ }
+
+ if(!empty($messages)){
+ foreach ($messages as $value) {
+ $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
+
+ // コンマで区切って配列に分割し、要素数を数える
+ $favIds = explode(',', $fav);
+ $value["favcnt"] = count($favIds)-1;
+
+ $messageDisplay = new MessageDisplay($value, $userid);
+ $messageDisplay->display();
+ }
+ }else{
+ echo '
';
+ }
+
+ $pdo = null;
+
+}
+
+?>
diff --git a/nextpage/userpage.php b/nextpage/userpage.php
index 7e5699d..320b6a1 100644
--- a/nextpage/userpage.php
+++ b/nextpage/userpage.php
@@ -1,140 +1,125 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
-} catch (PDOException $e) {
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-
-$uwuzuid = isset($_GET['id']) ? $_GET['id'] : '';
-$userid = $_GET['userid'];
-
-$itemsPerPage = 30; // 1ページあたりのユーズ数
-$pageNumber = isset($_GET['page']) ? intval($_GET['page']) : 1;
-$offset = ($pageNumber - 1) * $itemsPerPage;
-
-$messages = array();
-
-if (!empty($pdo)) {
-
- $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
- ));
-
- $userQuery = $dbh->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $uwuzuid);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-
- $messageQuery = $dbh->prepare("SELECT account,username,ueuse,uniqid,rpuniqid,datetime,photo1,photo2,video1,favorite, abi, abidate FROM ueuse WHERE account = :userid AND rpuniqid = ''ORDER BY datetime DESC LIMIT $offset, $itemsPerPage");
- $messageQuery->bindValue(':userid', $uwuzuid);
- $messageQuery->execute();
- $message_array = $messageQuery->fetchAll();
-
- function customStripTags($html, $allowedTags) {
- $allowedTagString = implode('|', $allowedTags);
- $pattern = "/<(?!$allowedTagString)[^>]+>/";
- return preg_replace($pattern, '', $html);
- }
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font');
-
- // ユーズ内の絵文字を画像に置き換える
- function replaceEmojisWithImages($postText) {
- // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
- $pattern = '/:(\w+):/';
- $postTextWithImages = preg_replace_callback($pattern, function($matches) {
- $emojiName = $matches[1];
- return "
";
- }, $postText);
- return $postTextWithImages;
- }
-
- function replaceURLsWithLinks($postText) {
- // URLを正規表現を使って検出
- $pattern = '/(https?:\/\/[^\s]+)/';
- preg_match_all($pattern, $postText, $matches);
-
- // 検出したURLごとに処理を行う
- foreach ($matches[0] as $url) {
- // ドメイン部分を抽出
- $parsedUrl = parse_url($url);
- $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
-
- // ドメインのみを表示するaタグを生成
- $link = "
$domain ";
-
- // URLをドメインのみを表示するaタグで置き換え
- $postText = str_replace($url, $link, $postText);
- }
-
- return $postText;
- }
-
-
-
-
- $messages = array();
- foreach ($message_array as $row) {
- $messages[] = $row;
- }
- // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
- foreach ($messages as &$message) {
- $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $message["account"]);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-
- if ($userData) {
- $message['username'] = $userData['username'];
- }
- }
-
- // ユーズ内のHTMLコードに指定のタグを有効化する関数
- function replaceUnescapedHTMLTags($html) {
- $allowedTags = array('h1', 'h2', 'h3', 'center', 'font'); // 有効化するタグ
- return customStripTags($html, $allowedTags);
- }
-
- if(!empty($messages)){
- foreach ($messages as $value) {
-
- $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
-
- // コンマで区切って配列に分割し、要素数を数える
- $favIds = explode(',', $fav);
- $value["favcnt"] = count($favIds)-1;
-
- $messageDisplay = new MessageDisplay($value, $userid);
- $messageDisplay->display();
- }
- }else{
- echo '
';
- }
-
- $pdo = null;
-
-}
-
-?>
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
+} catch (PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+
+$uwuzuid = htmlentities(isset($_GET['id'])) ? htmlentities($_GET['id']) : '';
+$userid = htmlentities($_GET['userid']);
+
+$itemsPerPage = 30; // 1ページあたりのユーズ数
+$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
+$offset = ($pageNumber - 1) * $itemsPerPage;
+
+$messages = array();
+
+if (!empty($pdo)) {
+
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
+ ));
+
+ $userQuery = $dbh->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $uwuzuid);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+
+ $messageQuery = $dbh->prepare("SELECT account,username,ueuse,uniqid,rpuniqid,datetime,photo1,photo2,video1,favorite, abi, abidate FROM ueuse WHERE account = :userid AND rpuniqid = ''ORDER BY datetime DESC LIMIT $offset, $itemsPerPage");
+ $messageQuery->bindValue(':userid', $uwuzuid);
+ $messageQuery->execute();
+ $message_array = $messageQuery->fetchAll();
+
+ // ユーズ内の絵文字を画像に置き換える
+ function replaceEmojisWithImages($postText) {
+ // ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
+ $pattern = '/:(\w+):/';
+ $postTextWithImages = preg_replace_callback($pattern, function($matches) {
+ $emojiName = $matches[1];
+ return "
";
+ }, $postText);
+ return $postTextWithImages;
+ }
+
+ function replaceURLsWithLinks($postText) {
+ // URLを正規表現を使って検出
+ $pattern = '/(https?:\/\/[^\s]+)/';
+ preg_match_all($pattern, $postText, $matches);
+
+ // 検出したURLごとに処理を行う
+ foreach ($matches[0] as $url) {
+ // ドメイン部分を抽出
+ $parsedUrl = parse_url($url);
+ $domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
+
+ // ドメインのみを表示するaタグを生成
+ $link = "
$domain ";
+
+ // URLをドメインのみを表示するaタグで置き換え
+ $postText = str_replace($url, $link, $postText);
+ }
+
+ return $postText;
+ }
+
+
+ $messages = array();
+ foreach ($message_array as $row) {
+ $messages[] = $row;
+ }
+ // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
+ foreach ($messages as &$message) {
+ $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $message["account"]);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+
+ if ($userData) {
+ $message['username'] = $userData['username'];
+ }
+ }
+
+ if(!empty($messages)){
+ foreach ($messages as $value) {
+
+ $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
+
+ // コンマで区切って配列に分割し、要素数を数える
+ $favIds = explode(',', $fav);
+ $value["favcnt"] = count($favIds)-1;
+
+ $messageDisplay = new MessageDisplay($value, $userid);
+ $messageDisplay->display();
+ }
+ }else{
+ echo '
';
+ }
+
+ $pdo = null;
+
+}
+
+?>
diff --git a/nextpage/view.php b/nextpage/view.php
index 7bef23d..cfbb58c 100644
--- a/nextpage/view.php
+++ b/nextpage/view.php
@@ -1,85 +1,85 @@
-
-value = $value;
- $this->userid = $userid;
- }
-
- public function display() {
- if (empty($this->value)) {
- echo '
';
- } else {
- echo '
';
- if(!empty($this->value['rpuniqid'])){
- echo '
';
- }
- echo '
';
-
- echo '
';
- echo '
' . htmlspecialchars($this->value['username']) . ' ';
- echo '
';
- echo '
';
- $day = date("Ymd", strtotime(htmlspecialchars($this->value['datetime'])));
- if ($day == date("Ymd")) {
- echo date("今日 H:i", strtotime(htmlspecialchars($this->value['datetime'])));
- } else {
- echo date("Y年m月d日 H:i", strtotime(htmlspecialchars($this->value['datetime'])));
- }
- echo '
';
-
- echo '
';
-
- echo '
' . replaceEmojisWithImages(replaceURLsWithLinks(nl2br(replaceUnescapedHTMLTags($this->value['ueuse'])))) . '
';
-
- if (!empty($this->value['photo2']) && $this->value['photo2'] !== 'none') {
- echo '
';
- echo '
';
- echo '
';
- echo '
';
- } elseif (!empty($this->value['photo1']) && $this->value['photo1'] !== 'none') {
- echo '
';
- echo '
';
- echo '
';
- }
- if (!empty($this->value['video1']) && $this->value['video1'] !== 'none') {
- echo '
';
- echo ' ';
- echo '
';
- }
-
- if(!($this->value['abi'] == "none")){
- echo '
';
- echo '
';
- echo '
' . htmlspecialchars($this->value['username']) . 'さんが追記しました ';
- echo ' ';
- echo '
'. htmlspecialchars($this->value['abi']) . '
';
- echo '
追記日時 : '. date("Y年m月d日 H:i", strtotime(htmlspecialchars($this->value['abidate']))) . ' ';
- echo '
';
- }
-
- echo '
';
- echo '
';
- if (false !== strstr($this->value['favorite'], $this->userid)) {
- echo '
' . htmlspecialchars($this->value['favcnt']) . ' ';
- }else{
- echo '
' . htmlspecialchars($this->value['favcnt']) . ' ';
- }
- echo '
返信をみる&する ';
- if($this->value['account'] === $this->userid){
- if($this->value['abi'] === "none"){
- echo '
';
- }
- echo '
';
- }
- echo '
';
- echo '
';
- }
- }
-}
+
+value = $value;
+ $this->userid = $userid;
+ }
+
+ public function display() {
+ if (empty($this->value)) {
+ echo '
';
+ } else {
+ echo '
';
+ if(!empty($this->value['rpuniqid'])){
+ echo '
';
+ }
+ echo '
';
+
+ echo '
';
+ echo '
' . htmlentities($this->value['username']) . ' ';
+ echo '
';
+ echo '
';
+ $day = date("Ymd", strtotime(htmlentities($this->value['datetime'])));
+ if ($day == date("Ymd")) {
+ echo date("今日 H:i", strtotime(htmlentities($this->value['datetime'])));
+ } else {
+ echo date("Y年m月d日 H:i", strtotime(htmlentities($this->value['datetime'])));
+ }
+ echo '
';
+
+ echo '
';
+
+ echo '
' . replaceEmojisWithImages(replaceURLsWithLinks(nl2br($this->value['ueuse']))) . '
';
+
+ if (!empty($this->value['photo2']) && $this->value['photo2'] !== 'none') {
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ } elseif (!empty($this->value['photo1']) && $this->value['photo1'] !== 'none') {
+ echo '
';
+ echo '
';
+ echo '
';
+ }
+ if (!empty($this->value['video1']) && $this->value['video1'] !== 'none') {
+ echo '
';
+ echo ' ';
+ echo '
';
+ }
+
+ if(!($this->value['abi'] == "none")){
+ echo '
';
+ echo '
';
+ echo '
' . htmlentities($this->value['username']) . 'さんが追記しました ';
+ echo ' ';
+ echo '
'.replaceEmojisWithImages(replaceURLsWithLinks(nl2br($this->value['abi']))) . '
';
+ echo '
追記日時 : '. date("Y年m月d日 H:i", strtotime(htmlentities($this->value['abidate']))) . ' ';
+ echo '
';
+ }
+
+ echo '
';
+ echo '
';
+ if (false !== strstr($this->value['favorite'], $this->userid)) {
+ echo '
' . htmlentities($this->value['favcnt']) . ' ';
+ }else{
+ echo '
' . htmlentities($this->value['favcnt']) . ' ';
+ }
+ echo '
返信をみる&する ';
+ if($this->value['account'] === $this->userid){
+ if($this->value['abi'] === "none"){
+ echo '
';
+ }
+ echo '
';
+ }
+ echo '
';
+ echo '
';
+ }
+ }
+}
?>
\ No newline at end of file
diff --git a/notice/addnotice.php b/notice/addnotice.php
index d1c2018..8bff8b1 100644
--- a/notice/addnotice.php
+++ b/notice/addnotice.php
@@ -25,8 +25,8 @@ $option = null;
session_start();
-$userid = $_SESSION['userid'];
-$username = $_SESSION['username'];
+$userid = htmlentities($_SESSION['userid']);
+$username = htmlentities($_SESSION['username']);
try {
diff --git a/notice/notice.php b/notice/notice.php
index c2e8e41..f3b6dca 100644
--- a/notice/notice.php
+++ b/notice/notice.php
@@ -1,40 +1,40 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
-
-} catch(PDOException $e) {
-
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-$sql = "SELECT title, note, account, datetime FROM notice ORDER BY datetime DESC";
-$notice_array = $pdo->query($sql);
-
-while ($row = $notice_array->fetch(PDO::FETCH_ASSOC)) {
-
- $notices[] = $row;
-}
-
-if(!empty($notices)){
- foreach ($notices as $value) {
- $uneinoticenote = $value['note'];
- $uneinoticetitle = $value['title'];
- $uneinoticeaccount = $value['account'];
- $uneinoticedatetime = $value['datetime'];
- }
-}else{
- $uneinoticenote = "";
- $uneinoticetitle = "おしらせはありません";
- $uneinoticeaccount = "uwuzu";
- $uneinoticedatetime = "";
-}
-
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
+
+} catch(PDOException $e) {
+
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+$sql = "SELECT title, note, account, datetime FROM notice ORDER BY datetime DESC";
+$notice_array = $pdo->query($sql);
+
+while ($row = $notice_array->fetch(PDO::FETCH_ASSOC)) {
+
+ $notices[] = $row;
+}
+
+if(!empty($notices)){
+ foreach ($notices as $value) {
+ $uneinoticenote = htmlentities($value['note']);
+ $uneinoticetitle = htmlentities($value['title']);
+ $uneinoticeaccount = htmlentities($value['account']);
+ $uneinoticedatetime = htmlentities($value['datetime']);
+ }
+}else{
+ $uneinoticenote = "";
+ $uneinoticetitle = "おしらせはありません";
+ $uneinoticeaccount = "uwuzu";
+ $uneinoticedatetime = "";
+}
+
diff --git a/notification/index.php b/notification/index.php
index 75972ce..91195bd 100644
--- a/notification/index.php
+++ b/notification/index.php
@@ -1,229 +1,229 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
- );
- $pdo = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
-
-} catch(PDOException $e) {
-
- // 接続エラーのときエラー内容を取得する
- $error_message[] = $e->getMessage();
-}
-
-if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
-
- $passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
- $passQuery->bindValue(':userid', $_SESSION['userid']);
- $passQuery->execute();
- $res = $passQuery->fetch();
- if(empty($res["userid"])){
- header("Location: ../login.php");
- exit;
- }elseif($_SESSION['loginid'] === $res["loginid"]){
- // セッションに値をセット
- $userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
- $username = $_SESSION['username']; // セッションに格納されている値をそのままセット
- $_SESSION['admin_login'] = true;
- $_SESSION['userid'] = $userid;
- $_SESSION['username'] = $username;
- $_SESSION['loginid'] = $res["loginid"];
- setcookie('userid', $userid, time() + 60 * 60 * 24 * 14);
- setcookie('username', $username, time() + 60 * 60 * 24 * 14);
- setcookie('loginid', $res["loginid"], time() + 60 * 60 * 24 * 14);
- setcookie('admin_login', true, time() + 60 * 60 * 24 * 14);
- }else{
- header("Location: ../login.php");
- exit;
- }
-
-
-} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
-
- $passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
- $passQuery->bindValue(':userid', $_COOKIE['userid']);
- $passQuery->execute();
- $res = $passQuery->fetch();
- if(empty($res["userid"])){
- header("Location: ../login.php");
- exit;
- }elseif($_COOKIE['loginid'] === $res["loginid"]){
- // セッションに値をセット
- $userid = $_COOKIE['userid']; // クッキーから取得した値をセット
- $username = $_COOKIE['username']; // クッキーから取得した値をセット
- $_SESSION['admin_login'] = true;
- $_SESSION['userid'] = $userid;
- $_SESSION['username'] = $username;
- $_SESSION['loginid'] = $res["loginid"];
- setcookie('userid', $userid, time() + 60 * 60 * 24 * 14);
- setcookie('username', $username, time() + 60 * 60 * 24 * 14);
- setcookie('loginid', $res["loginid"], time() + 60 * 60 * 24 * 14);
- setcookie('admin_login', true, time() + 60 * 60 * 24 * 14);
- }else{
- header("Location: ../login.php");
- exit;
- }
-
-
-} else {
- // ログインが許可されていない場合、ログインページにリダイレクト
- header("Location: ../login.php");
- exit;
-}
-if(empty($userid)){
- header("Location: ../login.php");
- exit;
-}
-if(empty($username)){
- header("Location: ../login.php");
- exit;
-}
-
-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;
-}
-
-
-
-// データベースの接続を閉じる
-$pdo = null;
-
-?>
-
-
-
-
-
-
-
-
-
通知 -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 🤔
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
+
+} catch(PDOException $e) {
+
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = $e->getMessage();
+}
+
+if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
+
+ $passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
+ $passQuery->bindValue(':userid', $_SESSION['userid']);
+ $passQuery->execute();
+ $res = $passQuery->fetch();
+ if(empty($res["userid"])){
+ header("Location: ../login.php");
+ exit;
+ }elseif($_SESSION['loginid'] === $res["loginid"]){
+ // セッションに値をセット
+ $userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
+ $username = $_SESSION['username']; // セッションに格納されている値をそのままセット
+ $_SESSION['admin_login'] = true;
+ $_SESSION['userid'] = $userid;
+ $_SESSION['username'] = $username;
+ $_SESSION['loginid'] = $res["loginid"];
+ setcookie('userid', $userid, time() + 60 * 60 * 24 * 14);
+ setcookie('username', $username, time() + 60 * 60 * 24 * 14);
+ setcookie('loginid', $res["loginid"], time() + 60 * 60 * 24 * 14);
+ setcookie('admin_login', true, time() + 60 * 60 * 24 * 14);
+ }else{
+ header("Location: ../login.php");
+ exit;
+ }
+
+
+} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
+
+ $passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
+ $passQuery->bindValue(':userid', $_COOKIE['userid']);
+ $passQuery->execute();
+ $res = $passQuery->fetch();
+ if(empty($res["userid"])){
+ header("Location: ../login.php");
+ exit;
+ }elseif($_COOKIE['loginid'] === $res["loginid"]){
+ // セッションに値をセット
+ $userid = $_COOKIE['userid']; // クッキーから取得した値をセット
+ $username = $_COOKIE['username']; // クッキーから取得した値をセット
+ $_SESSION['admin_login'] = true;
+ $_SESSION['userid'] = $userid;
+ $_SESSION['username'] = $username;
+ $_SESSION['loginid'] = $res["loginid"];
+ setcookie('userid', $userid, time() + 60 * 60 * 24 * 14);
+ setcookie('username', $username, time() + 60 * 60 * 24 * 14);
+ setcookie('loginid', $res["loginid"], time() + 60 * 60 * 24 * 14);
+ setcookie('admin_login', true, time() + 60 * 60 * 24 * 14);
+ }else{
+ header("Location: ../login.php");
+ exit;
+ }
+
+
+} else {
+ // ログインが許可されていない場合、ログインページにリダイレクト
+ header("Location: ../login.php");
+ exit;
+}
+if(empty($userid)){
+ header("Location: ../login.php");
+ exit;
+}
+if(empty($username)){
+ header("Location: ../login.php");
+ exit;
+}
+
+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;
+}
+
+
+
+// データベースの接続を閉じる
+$pdo = null;
+
+?>
+
+
+
+
+
+
+
+
+
通知 -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 🤔
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/others/index.php b/others/index.php
index 9bfd40e..61f3ad4 100644
--- a/others/index.php
+++ b/others/index.php
@@ -25,8 +25,8 @@ $option = null;
session_start();
-$userid = $_SESSION['userid'];
-$username = $_SESSION['username'];
+$userid = htmlentities($_SESSION['userid']);
+$username = htmlentities($_SESSION['username']);
// 管理者としてログインしているか確認
if( empty($_SESSION['admin_login']) || $_SESSION['admin_login'] !== true ) {
@@ -136,7 +136,7 @@ if( !empty($pdo) ) {
if( !empty($_POST['btn_submit']) ) {
- $chkuserid = $_POST['chkuserid'];
+ $chkuserid = htmlentities($_POST['chkuserid']);
if( empty($chkuserid) ) {
$error_message[] = '確認用ユーザーIDを入力してください。';
@@ -233,6 +233,51 @@ if( !empty($_POST['btn_submit']) ) {
}
+if( !empty($_POST['session_submit']) ) {
+ $loginid = sha1(uniqid(mt_rand(), true));
+ $pdo->beginTransaction();
+ try {
+
+ $stmt = $pdo->prepare("UPDATE account SET loginid = :loginid WHERE userid = :userid;");
+
+ $stmt->bindParam(':loginid', $loginid, PDO::PARAM_STR);
+
+ $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
+
+ // SQLクエリの実行
+ $res = $stmt->execute();
+
+ // コミット
+ $res = $pdo->commit();
+ } catch (Exception $e) {
+
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
+ }
+
+ if ($res) {
+ 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;
+ } else {
+ $error_message[] = '登録に失敗しました。';
+ }
+
+}
+
+
if( !empty($_POST['logout']) ) {
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
@@ -259,7 +304,9 @@ if( !empty($_POST['logout']) ) {
-
アカウント削除ページ -
+
+
+
その他の項目 -
@@ -275,7 +322,11 @@ if( !empty($_POST['logout']) ) {
+
+
+
+
+
+
\ No newline at end of file
diff --git a/passrecovery/startrecovery.php b/passrecovery/startrecovery.php
new file mode 100644
index 0000000..0be93ee
--- /dev/null
+++ b/passrecovery/startrecovery.php
@@ -0,0 +1,298 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
+ );
+ $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $options);
+} catch(PDOException $e) {
+ // 接続エラーのときエラー内容を取得する
+ $error_message[] = 'データベース接続エラー: ' . $e->getMessage();
+}
+
+
+if( !empty($_POST['btn_submit']) ) {
+
+ $options = array(
+ // SQL実行失敗時に例外をスルー
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ // デフォルトフェッチモードを連想配列形式に設定
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ // バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
+ // SELECTで得た結果に対してもrowCountメソッドを使えるようにする
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
+ );
+
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $options);
+
+ require_once '../authcode/GoogleAuthenticator.php';
+
+ $result = $dbh->prepare("SELECT authcode,loginid,username FROM account WHERE userid = :userid");
+
+ $result->bindValue(':userid', $userid);
+ // SQL実行
+ $result->execute();
+ if($result->rowCount() > 0) {
+ $row = $result->fetch();
+
+ $tousercode = $row["authcode"];
+
+ $chkauthcode = new PHPGangsta_GoogleAuthenticator();
+
+ $userauthcode = $_POST['usercode'];
+ $password = $_POST['password'];
+
+ if(empty($userauthcode)){
+ $error_message[] = "コードを入力してください。";
+ }else{
+
+ $discrepancy = 2;
+
+ $checkResult = $chkauthcode->verifyCode($tousercode, $userauthcode, $discrepancy);
+ if ($checkResult) {
+
+ // パスワードの入力チェック
+ if( empty($password) ) {
+ $error_message[] = 'パスワードを入力してください。';
+ } else {
+
+ $weakPasswords = array(
+ "password",
+ "123456",
+ "123456789",
+ "12345",
+ "12345678",
+ "123123",
+ "1234567890",
+ "1234567",
+ "1q2w3e",
+ "qwerty123",
+ "aa12345678",
+ "password1",
+ "1234",
+ "qwertyuiop",
+ "123321",
+ "12321",
+ "qwertyui",
+ "abcd1234",
+ "zaq12wsx",
+ "1q2w3e4r",
+ "qwer1234",
+ "sakura",
+ "asdf1234",
+ "asdfghjkl",
+ "asdfghjk",
+ "member",
+ "1qaz2wsx",
+ "doraemon",
+ "makoto",
+ "takeshi",
+ "machi1",
+ "machida",
+ "machida1",
+ "tokyo",
+ "arashi",
+ "dropbox",
+ "twitter",
+ "elonmusk",
+ "xcorp",
+ "1234qwer",
+ "japan",
+ "nippon",
+ "tukareta",
+ "tweet",
+ "discord",
+ "misskey",
+ "qwerty",
+ "123456789",
+ "abc123",
+ "password123",
+ "admin",
+ "letmein",
+ "iloveyou",
+ "111111",
+ "12345678910",
+ "user",
+ "root",
+ "system",
+ // 他にも弱いパスワードを追加できます
+ );
+
+ function isWeakPassword($passwords) {
+ global $weakPasswords;
+ return in_array($passwords, $weakPasswords);
+ }
+
+ // テスト用のパスワード(実際にはユーザー入力などから取得することになります。
+
+ if (isWeakPassword($password)) {
+ $error_message[] = "パスワードが弱いです。セキュリティ上変更してください。";
+ } else {
+
+ }
+
+ if( 4 > mb_strlen($password, 'UTF-8') ) {
+ $error_message[] = 'パスワードは4文字以上である必要があります。';
+ }
+
+ // 文字数を確認
+ if( 100 < mb_strlen($password, 'UTF-8') ) {
+ $error_message[] = 'パスワードは100文字以内で入力してください。';
+ }
+ }
+
+ if( empty($error_message) ) {
+ // トランザクション開始
+ $pdo->beginTransaction();
+ $hashpassword = password_hash($password, PASSWORD_DEFAULT);
+
+ try {
+ // SQL作成
+ $stmt = $pdo->prepare("UPDATE account SET password = :password WHERE userid = :userid;");
+
+ // 他の値をセット
+ $stmt->bindParam(':password', $hashpassword, PDO::PARAM_STR);
+
+ // 条件を指定
+ // 以下の部分を適切な条件に置き換えてください
+ $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
+
+ // SQLクエリの実行
+ $res = $stmt->execute();
+
+ // コミット
+ $res = $pdo->commit();
+
+ } catch (Exception $e) {
+
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
+ }
+
+ if ($res) {
+ $_SESSION['userid'] = "";
+ $url = 'donerecovery.php';
+ header('Location: ' . $url, true, 303);
+
+ // すべての出力を終了
+ exit;
+ } else {
+ $error_message[] = 'パスワードの更新に失敗しました。';
+ }
+ }
+
+ }else {
+ $error_message[] = '二段階認証が出来ませんでした。再度お試しください。';
+ }
+
+ // プリペアドステートメントを削除
+ $stmt = null;
+ }
+ }
+}
+
+// データベースの接続を閉じる
+$pdo = null;
+
+?>
+
+
+
+