From 49a89b55f621de3508f66dff9425e07534e5ef0b Mon Sep 17 00:00:00 2001 From: daichimarukana Date: Wed, 23 Aug 2023 20:15:05 +0900 Subject: [PATCH] uwuzu version 1.2.10 --- api/bot-api.php | 127 ++++++++++++++++++++++++++++++ api/ltl-api.php | 108 +++++++++++++++++++++++++ api/ueuse-api.php | 89 +++++++++++++++++++++ api/userdata-api.php | 1 + css/home.css | 55 ++++++++++--- emoji/addemoji.php | 2 + emoji/index.php | 3 +- notice/addnotice.php | 2 + others/index.php | 134 +++++++++++++++++++++++++++---- others/token.php | 170 ++++++++++++++++++++++++++++++++++++++++ server/uwuzuinfo.txt | 4 +- server/uwuzurelease.txt | 8 +- 12 files changed, 670 insertions(+), 33 deletions(-) create mode 100644 api/bot-api.php create mode 100644 api/ltl-api.php create mode 100644 api/ueuse-api.php create mode 100644 others/token.php diff --git a/api/bot-api.php b/api/bot-api.php new file mode 100644 index 0000000..0836002 --- /dev/null +++ b/api/bot-api.php @@ -0,0 +1,127 @@ + 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(); + } + + + 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 FROM account WHERE token = :token"); + $userQuery->bindValue(':token', $token); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if(empty($userData["userid"])){ + $err = "token_invalid"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + }else{ + // 書き込み日時を取得 + $username = $userData["username"]; + $userid = $userData["userid"]; + $datetime = date("Y-m-d H:i:s"); + $uniqid = createUniqId(); + $abi = "none"; + + // トランザクション開始 + $pdo->beginTransaction(); + + try { + + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, datetime, abi) VALUES (:username, :account, :uniqid, :ueuse, :datetime, :abi)"); + + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':account', $userid, PDO::PARAM_STR); + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); + + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + } catch(Exception $e) { + + // エラーが発生した時はロールバック + $pdo->rollBack(); + } + + if( $res ) { + $response = array( + 'uniqid' => $uniqid, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } else { + $err = "db_error_".$e->getMessage(); + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + + // プリペアドステートメントを削除 + $stmt = null; + } + } + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/ltl-api.php b/api/ltl-api.php new file mode 100644 index 0000000..4a1cb97 --- /dev/null +++ b/api/ltl-api.php @@ -0,0 +1,108 @@ + 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(); + } + + + if (!empty($pdo)) { + $sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT " . intval($offset) . ", " . intval($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']; + $message['role'] = $userData['role']; + } + } + + if (!empty($messages)) { + $response = array(); // ループ外で $response を初期化 + + foreach ($messages as $ueusedata) { + $favcnts = explode(',', $ueusedata["favorite"]); + $ueusedata["favorite_cnt"] = count($favcnts) - 1; + + $item = [ + 'account' => htmlentities($ueusedata["account"]), + 'username' => htmlentities($ueusedata["username"]), + 'uniqid' => htmlentities($ueusedata["uniqid"]), + 'ueuse' => htmlentities($ueusedata["ueuse"]), + 'photo1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"])), + 'photo2' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"])), + 'video1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"])), + 'favorite' => htmlentities($ueusedata["favorite"]), + 'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]), + 'datetime' => htmlentities($ueusedata["datetime"]), + 'abi' => htmlentities($ueusedata["abi"]), + 'abidatetime' => htmlentities($ueusedata["abidate"]), + ]; + + $response[$ueusedata["uniqid"]] = $item; // ループ内で $response にデータを追加 + } + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } else { + $err = "ueuse_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + + + $pdo = null; + } + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/ueuse-api.php b/api/ueuse-api.php new file mode 100644 index 0000000..afc9a6b --- /dev/null +++ b/api/ueuse-api.php @@ -0,0 +1,89 @@ + 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(); + } + + + 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, + )); + + $ueuseQuery = $pdo->prepare("SELECT account, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid"); + $ueuseQuery->bindValue(':ueuseid', $ueuseid); + $ueuseQuery->execute(); + $ueusedata = $ueuseQuery->fetch(); + } + +if (empty($ueusedata)){ + $response = array( + 'error_code' => "ueuseid_not_found", + ); +}else{ + $userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); + $userQuery->bindValue(':userid', $ueusedata["account"]); + $userQuery->execute(); + $userData = $userQuery->fetch(); + if ($userData) { + $ueusedata['username'] = $userData['username']; + $ueusedata['role'] = $userData['role']; + } + + + $favcnts = explode(',', $ueusedata["favorite"]); + $ueusedata["favorite_cnt"] = count($favcnts)-1; + + $response = array( + 'userid' => htmlentities($ueusedata["account"]), + 'user_name' => htmlentities($ueusedata["username"]), + 'uniqid' => htmlentities($ueusedata["uniqid"]), + 'ueuse' => htmlentities($ueusedata["ueuse"]), + 'photo1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo1"])), + 'photo2' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo2"])), + 'video1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["video1"])), + 'favorite' => htmlentities($ueusedata["favorite"]), + 'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]), + 'datetime' => htmlentities($ueusedata["datetime"]), + 'abi' => htmlentities($ueusedata["abi"]), + 'abidatetime' => htmlentities($ueusedata["abidate"]), + ); +} +echo json_encode($response, JSON_UNESCAPED_UNICODE);; + +}else{ + + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/userdata-api.php b/api/userdata-api.php index 6f028c7..d7253f4 100644 --- a/api/userdata-api.php +++ b/api/userdata-api.php @@ -1,4 +1,5 @@ + + 絵文字登録 - <?php echo file_get_contents($servernamefile);?> diff --git a/emoji/index.php b/emoji/index.php index 3442af4..8788fe3 100644 --- a/emoji/index.php +++ b/emoji/index.php @@ -137,7 +137,8 @@ $pdo = null; - + + 絵文字一覧 - <?php echo file_get_contents($servernamefile);?> diff --git a/notice/addnotice.php b/notice/addnotice.php index 9a0adcb..948e63a 100644 --- a/notice/addnotice.php +++ b/notice/addnotice.php @@ -231,6 +231,8 @@ $pdo = null; + + お知らせ配信 - <?php echo file_get_contents($servernamefile);?> diff --git a/others/index.php b/others/index.php index 505ccc2..fd1dcb5 100644 --- a/others/index.php +++ b/others/index.php @@ -1,5 +1,10 @@ true, )); - $userQuery = $dbh->prepare("SELECT userid FROM account WHERE userid = :userid"); + $userQuery = $dbh->prepare("SELECT userid,token FROM account WHERE userid = :userid"); $userQuery->bindValue(':userid', $userid); $userQuery->execute(); $userData = $userQuery->fetch(); @@ -283,7 +288,74 @@ if( !empty($_POST['session_submit']) ) { // すべての出力を終了 exit; } else { - $error_message[] = '登録に失敗しました。'; + $error_message[] = 'セッションの終了に失敗しました。'; + } + +} + + +if( !empty($_POST['token_submit']) ) { + $token = random_token(); + $pdo->beginTransaction(); + try { + + $stmt = $pdo->prepare("UPDATE account SET token = :token WHERE userid = :userid;"); + + $stmt->bindParam(':token', $token, 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['token'] = $token; + // リダイレクト先のURLへ転送する + $url = 'token.php'; + header('Location: ' . $url, true, 303); + exit; + } else { + $error_message[] = 'トークンの発行に失敗しました。'; + } + +} + +if( !empty($_POST['token_off_submit']) ) { + $token = ''; + $pdo->beginTransaction(); + try { + + $stmt = $pdo->prepare("UPDATE account SET token = :token WHERE userid = :userid;"); + + $stmt->bindParam(':token', $token, PDO::PARAM_STR); + + $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + } catch (Exception $e) { + + // エラーが発生した時はロールバック + $pdo->rollBack(); + } + + if ($res) { + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:".$url.""); + exit; + } else { + $error_message[] = 'トークンの削除に失敗しました。'; } } @@ -317,26 +389,54 @@ require('../logout/logout.php');
+

セッション終了

下のセッションを終了ボタンを押すと全てのログイン中のデバイスからログアウトされます。
再度uwuzu使用するにはログインが必須になります。

-
+ +

アカウント削除

-

アカウント誤削除を防ぐため下の入力ボックスにご自身のユーザーIDを入力する必要があります。

- - -

あなたはこのサーバーの管理者のようです。
管理者アカウントの移行は済んでいますか?
アカウントを削除しても大丈夫なのですか...?

- - -
-

確認用ユーザーID

- -
- - - - +

アカウント誤削除を防ぐため下の入力ボックスにご自身のユーザーIDを入力する必要があります。

+ +

あなたはこのサーバーの管理者のようです。
管理者アカウントの移行は済んでいますか?
アカウントを削除しても大丈夫なのですか...?

+ +
+

確認用ユーザーID

+ +
+ + +
+

API

+

APIの簡単な使用法です。

+
+
  • ユーザー情報取得API
  • +

    https://[ドメイン名(uwuzu.netなど)]/api/userdata-api?userid=[ユーザーID]

    +

    これによりユーザーのユーザーネーム(user_name)、プロフィール(profile)、登録日時(registered_date)、フォローしている人一覧(follow)、フォロワー一覧(follower)、フォロー・フォロワー数(follow_cnt,follower_cnt)が取得できます。

    +
    +
  • 単独投稿取得API
  • +

    https://[ドメイン名(uwuzu.netなど)]/api/ueuse-api?ueuseid=[投稿の詳細ページのリンクより投稿のID(!より後、~より手前の文字列)]

    +

    これにより投稿内容(ueuse)と、ユーザーネーム(user_name)、ユーザーID(userid)、投稿ID(uniqid)、写真・動画URL(photo1,photo2,video1)、いいねした人一覧(favorite)、いいね数(favorite_cnt)、投稿日時(datetime)、追記内容(abi)、追記日時(abidatetime)が取得できます。

    +
    +
  • ローカルタイムライン投稿取得API
  • +

    https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数]&page=[ページ切り替え]

    +

    これにより投稿内容(ueuse)と、ユーザーネーム(user_name)、ユーザーID(userid)、投稿ID(uniqid)、写真・動画URL(photo1,photo2,video1)、いいねした人一覧(favorite)、いいね数(favorite_cnt)、投稿日時(datetime)、追記内容(abi)、追記日時(abidatetime)が取得できます。
    page=は指定しなくても動作します。(https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数])

    +
    +
  • ローカルタイムライン投稿取得API
  • +

    https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数]&page=[ページ切り替え]

    +
    +
  • 投稿API
  • +

    https://[ドメイン名(uwuzu.netなど)]/api/bot-api?token=[アクセストークン]&ueuse=[投稿の内容]

    + +

    以下のボタンよりアクセストークンを取得すると使用できます。
    アクセストークンは一度発行すると作り直すまで再度確認はできません。また、絶対に他人に知られないように保護してください。

    + + +

    以下のボタンよりアクセストークンを削除できます。ボタンを押すとすぐに削除されますのでご注意ください。

    + +
    diff --git a/others/token.php b/others/token.php new file mode 100644 index 0000000..dfc92ee --- /dev/null +++ b/others/token.php @@ -0,0 +1,170 @@ + 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(); +} + +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; +} +$notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); +$notiQuery->bindValue(':userid', $userid); +$notiQuery->execute(); +$notiData = $notiQuery->fetch(PDO::FETCH_ASSOC); + +$notificationcount = $notiData['notification_count']; + +require('../logout/logout.php'); +?> + + + + + + + + + + +アクセストークン発行完了 - <?php echo file_get_contents($servernamefile);?> + + + + + +
    + + + + + +
    +

    アクセストークン発行完了

    + +
      + +

      + +
    + +
    +

    発行完了!以下のアクセストークンでこのアカウント()に投稿を行えます!

    +

    アクセストークンは以下のものです!
    +

      +

      以下のアクセストークンは絶対に他人に知られないように大切に保管してください!

      +
    +

    +

    + + 戻る +
    +
    + + + + + + \ No newline at end of file diff --git a/server/uwuzuinfo.txt b/server/uwuzuinfo.txt index 6579dae..8384445 100644 --- a/server/uwuzuinfo.txt +++ b/server/uwuzuinfo.txt @@ -1,4 +1,4 @@ uwuzu -1.2.9 -2023/08/22 +1.2.10 +2023/08/23 daichimarukana,putonfps \ No newline at end of file diff --git a/server/uwuzurelease.txt b/server/uwuzurelease.txt index 8a7dd4e..9ca1331 100644 --- a/server/uwuzurelease.txt +++ b/server/uwuzurelease.txt @@ -1,8 +1,14 @@ ## リリースノートだぜぇぇぇぇぇぇい!!!!!!! ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...) +## Version 1.2.10 +リリース日:2023/08/23 +モバイル向けUIを変更しました。 +使用できるAPIを増やしました。 +投稿API機能によりアクセストークンを使用し投稿できるようにしました。 + ## Version 1.2.9 -リリース日:2023/08/21 +リリース日:2023/08/22 メニュー画面に各機能のアイコンを表示するようにしました。 公式ロールがあるアカウントの投稿がタイムラインに流れると公式バッジがアカウントidの横に表示されるようにしました。 プロフィールにカスタム絵文字を使用できるようにしました。