1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-04 19:14:41 +00:00

uwuzu version 1.2.19

This commit is contained in:
daichimarukana
2023-09-10 18:19:44 +09:00
parent 66a93d34ec
commit c4a67e75ec
43 changed files with 4546 additions and 698 deletions
+26 -33
View File
@@ -9,15 +9,15 @@ AGPLライセンスです!!!
## 5. サーバーの建て方
※MySQLの設定結構めんどいです。
まず、Apache2とPHP 8とmysql Ver 15が導入されているサーバーを準備します!
PHP 8では事前にGDを有効化しておいてください!(QRコードの生成に必要です。)
次にSQLを設定します。(InnoDB)
まず、お好きな名前でDBを作成し、その中に、account,emoji,notice,role,ueuse,notificationとテーブルを作成します。
まず、お好きな名前でDBを作成し、その中に、account,emoji,notice,role,ueuse,notification,ads,reportとテーブルを作成します。
テーブルの中身は以下のとおりです。
照合順序は全て標準でutf8mb4_general_ciです。
【お知らせ!!!】
バージョン1.2.15よりSQLの構造ファイルを公開したので今までと比べて大幅に簡単にuwuzuサーバーの構築ができるようになりました!!
なお、ロールは自動で追加されませんのでuser、officialロールはご自身で追加してください!
## 簡単に構築できるようSQLの構造ファイルがリリースに添付されています!そちらをインポートしていただけますと大幅に簡単に導入できます
(userロールとofficialロールとiceロールの設定は別途必要です。お手数ですがそこの設定だけよろしくお願いいたします。)
### account
- sysid(INT)(AUTO_INCREMENT ) アカウントが追加されるとカウントされるシステム用ID
@@ -88,37 +88,30 @@ AGPLライセンスです!!!
- used(varchar(25)) 使用済みかそうでないか
- datetime(datetime) 招待コード仕様日時更新用
すべて作成完了したらGithubよりuwuzuのファイルをDLし、解凍し、それをサーバーの動作ディレクトリに置き、Apacheのhttpd.confからその動作ディレクトリを指定し、あとはApacheとphpとMy SQLを起動するだけ!
起動したらまずDBのroleにphpmyadminから「user」ロールと「official」ロールを追加、権限は「user」と「official」でOK。ロール名はとりあえず「一般ユーザー」ロールの色はHEXコード(#を除く)で000000のように指定。(この2つのロールがないとエラーが発生します。)
そしたら普通にuwuzuにアクセスして自分のアカウントを登録。
それが終わったら一度サーバーを止め、uwuzuの動作ディレクトリ内のserverフォルダ内のファイルを各自設定
ファイルの機能は以下の通り!
- admininfo.txt : 管理者名(てすとまる/@sampledayo)
- contact.txt : 管理者への連絡用メアド(sample@test.com)
- info.txt : サーバー登録時に表示されるメッセージ(好きな内容)
- privacypolicy.txt : プライバシーポリシー(サーバーのプライバシーポリシーを記載)
- servername.txt : サーバー名(てすとさば)
- terms.txt : 利用規約(サーバーの利用規約を記載)
- uwuzuabout.txt : このファイル(uwuzuを改造した場合は書き換え)
- uwuzuinfo.txt : uwuzuのバージョン等記載(uwuzuを改造した場合は書き換え)
- uwuzurelease.txt : uwuzuのバージョン等記載(uwuzuを改造した場合は書き換え)
- onlyuser.txt : 招待コード機能をオンにするかどうか、「true」でオン、「false」でオフ。招待コードはDBに直接追加。
### report
- sysid(INT)(AUTO_INCREMENT) 追加されるとカウントされるシステム用ID
- uniqid(varchar(256)) 通報ID保存用
- userid(varchar(500)) 通報先ユーザーID保存用
- report_userid(varchar(500)) 通報元ユーザーID保存用
- msg(text) サービス管理者宛メッセージ保存用
- datetime(datetime) 通報日時保存用
- admin_chk(varchar(25)) 解決済みかどうか確認用
### ads
- sysid(INT)(AUTO_INCREMENT) 追加されるとカウントされるシステム用ID
- uniqid(varchar(512)) 広告ID保存用
- url(varchar(512)) 広告のクリック先URL保存用
- image_url(varchar(512)) 広告に表示する画像URL保存用
- memo(text) 広告にマウスオーバーしたときに表示されるメッセージ保存用
- start_date(datetime) 広告配信開始日時保存用
- limit_date(datetime) 広告配信終了日時保存用
- datetime(datetime) 広告追加日時保存用
すべて作成完了したらGithubよりuwuzuのファイルをDLし、解凍し、それをサーバーの動作ディレクトリに置き、Apacheのhttpd.confからその動作ディレクトリを指定し、あとはApacheとphpとMy SQLを起動するだけ!
起動したらまずDBのroleにphpmyadminから「user」ロールを追加権限は「user」でOK。ロール名はとりあえず「一般ユーザー」ロールの色はHEXコード(#を除く)で000000のように指定。
すべて作成完了したらGithubよりuwuzuのファイルをDLし、解凍し、それをサーバーの動作ディレクトリに置き、Apacheのhttpd.confからその動作ディレクトリを指定し、動作ディレクトリ内のdb.phpにDBのログイン情報を書き込んであとはApacheとphpとMy SQLを起動するだけ!
起動したらまずDBのroleにphpmyadminから「user」ロールと「official」ロールと「ice」ロールを追加権限は「user」と「official」と「ice」でOK。ロール名はとりあえず「一般ユーザー」とか適当でOK、ロールの色はHEXコード(#を除く)で000000のように指定。(この3つのロールがないとエラーが発生します。)
そしたら普通にuwuzuにアクセスして自分のアカウントを登録。
それが終わったら一度サーバーを止め、uwuzuの動作ディレクトリ内のserverフォルダ内のファイルを各自設定
ファイルの機能は以下の通り!
- admininfo.txt : 管理者名(てすとまる/@sampledayo)
- contact.txt : 管理者への連絡用メアド(sample @test.com)
- info.txt : サーバー登録時に表示されるメッセージ(好きな内容)
- privacypolicy.txt : プライバシーポリシー(サーバーのプライバシーポリシーを記載)
- servername.txt : サーバー名(てすとさば)
- terms.txt : 利用規約(サーバーの利用規約を記載)
- uwuzuabout.txt : このファイル(uwuzuを改造した場合は書き換え)
- uwuzuinfo.txt : uwuzuのバージョン等記載(uwuzuを改造した場合は書き換え)
- uwuzurelease.txt : uwuzuのバージョン等記載(uwuzuを改造した場合は書き換え)
## 管理者アカウント登録機能が追加されました。【[domain]/admin/】より設定できるのでそちらをご利用ください。
なお、管理者アカウントを導入後に登録した場合サーバーを止めてuwuzu動作ディレクトリ内のserverフォルダ内のファイルを設定する必要はございません。
### これでサーバーは完成!!!
脆弱だから自己責任で楽しんでね~()
+113 -87
View File
@@ -1,105 +1,142 @@
<?php
require('../db.php');
if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['abitext'])) && htmlentities(isset($_POST['userid']))) {
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
$ses_userid = $_SESSION['userid'];
if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['abitext'])) && htmlentities(isset($_POST['userid'])) && htmlentities(isset($_POST['account_id']))) {
$userid = htmlentities($_POST['userid']);
if($userid === $ses_userid){
$postUniqid = htmlentities($_POST['uniqid']);
$abitext = htmlentities($_POST['abitext']);
$username = htmlentities($_POST['username']);
$abidate = date("Y-m-d H:i:s");
$postUniqid = htmlentities($_POST['uniqid']);
$abitext = htmlentities($_POST['abitext']);
$username = htmlentities($_POST['username']);
$loginid = htmlentities($_POST['account_id']);
//-------------------------------------------
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
$mentionedUsers = [];
$abidate = date("Y-m-d H:i:s");
preg_replace_callback($usernamePattern, function($matches) use (&$mentionedUsers) {
$mention_username = $matches[1];
//-------------------------------------------
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
$mentionedUsers = [];
$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,
));
preg_replace_callback($usernamePattern, function($matches) use (&$mentionedUsers) {
$mention_username = $matches[1];
$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,
));
$mention_userQuery = $dbh->prepare("SELECT username, userid FROM account WHERE userid = :userid");
$mention_userQuery->bindValue(':userid', $mention_username);
$mention_userQuery->execute();
$mention_userData = $mention_userQuery->fetch();
$mention_userQuery = $dbh->prepare("SELECT username, userid FROM account WHERE userid = :userid");
$mention_userQuery->bindValue(':userid', $mention_username);
$mention_userQuery->execute();
$mention_userData = $mention_userQuery->fetch();
if (!empty($mention_userData)) {
$mentionedUsers[] = $mention_username;
}
}, $postText);
if (!empty($mention_userData)) {
$mentionedUsers[] = $mention_username;
}
}, $postText);
return $mentionedUsers;
}
return $mentionedUsers;
}
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
// データベース接続の設定
$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,
));
$pdo->beginTransaction();
$query = $dbh->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1');
$stmt = $pdo->prepare("UPDATE ueuse SET abi = :abi, abidate = :abidate WHERE uniqid = :uniqid AND account = :userid");
$stmt->bindValue(':abi', $abitext, PDO::PARAM_STR);
$stmt->bindValue(':abidate', $abidate, PDO::PARAM_STR);
$stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$stmt->bindValue(':userid', $ses_userid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
$query->execute(array(':uniqid' => $postUniqid));
// コミット
$pdo->commit();
$result = $query->fetch();
$mentionedUsers = get_mentions_userid($abitext);
if($result["account"] === $userid){
// データベース接続の設定
$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,
));
$query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1');
$query->execute(array(':userid' => $userid));
$result2 = $query->fetch();
if($result2["loginid"] === $loginid){
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
foreach ($mentionedUsers as $mentionedUser) {
$pdo->beginTransaction();
try {
$touserid = $mentionedUser;
$datetime = date("Y-m-d H:i:s");
$msg = "" . $abitext . "";
$title = "" . $username . "さんにメンションされました!";
$url = "/!" . $uniqid . "~" . $userid . "";
$userchk = 'none';
$stmt = $pdo->prepare("UPDATE ueuse SET abi = :abi, abidate = :abidate WHERE uniqid = :uniqid AND account = :userid");
$stmt->bindValue(':abi', $abitext, PDO::PARAM_STR);
$stmt->bindValue(':abidate', $abidate, PDO::PARAM_STR);
$stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
// 通知用SQL作成
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$pdo->commit();
$mentionedUsers = get_mentions_userid($abitext);
foreach ($mentionedUsers as $mentionedUser) {
$pdo->beginTransaction();
try {
$touserid = $mentionedUser;
$datetime = date("Y-m-d H:i:s");
$msg = "" . $abitext . "";
$title = "" . $username . "さんにメンションされました!";
$url = "/!" . $uniqid . "~" . $userid . "";
$userchk = 'none';
// 通知用SQL作成
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
$stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR);
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
$stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR);
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
$stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res2 = $stmt->execute();
// SQLクエリの実行
$res2 = $stmt->execute();
// コミット
$res2 = $pdo->commit();
// コミット
$res2 = $pdo->commit();
} catch(Exception $e) {
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res2) {
header('Content-Type: application/json');
echo json_encode(['success' => true]);
exit;
} else {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => '追加に失敗しました。']);
exit;
}
}
if ($res2) {
if ($res) {
header('Content-Type: application/json');
echo json_encode(['success' => true]);
exit;
@@ -108,22 +145,11 @@ if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['abitext'
echo json_encode(['success' => false, 'error' => '追加に失敗しました。']);
exit;
}
}
if ($res) {
} catch(PDOException $e) {
header('Content-Type: application/json');
echo json_encode(['success' => true]);
exit;
} else {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => '追加に失敗しました。']);
echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
exit;
}
} catch(PDOException $e) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
exit;
}
}
}
+16
View File
@@ -42,6 +42,22 @@ if(isset($_GET['token'])&&isset($_GET['ueuse'])) {
$token = htmlentities($_GET['token']);
$ueuse = nl2br(htmlentities($_GET['ueuse']));
if($token === 'ice'){
$err = "input_error";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
}elseif($token === ''){
$err = "input_error";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
}
require('../db.php');
$datetime = array();
+575 -9
View File
@@ -677,6 +677,7 @@ main h1{
border: none;
display: block;
width:120px;
height: 24px;
padding: 8px auto;
margin-left: auto;
@@ -754,6 +755,56 @@ main h1{
width:115px;
}
.fzone .follow .report{
cursor: pointer;
border: none;
display: block;
padding: 6px;
width:24px;
height: 24px;
margin-left: auto;
margin-right: 12px;
margin-top: 12px;
margin-bottom: 12px;
background-color: #FFFAE6;
border-radius: 50px;
color:#FFC832;
border: 1px solid #FFC832;
font-size: 16px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: center;
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.fzone .follow .report:hover{
background-color: #ffebeb;
color: #ff4848;
border: 1px solid #ff4848;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:32px;
}
.fzone .follow .report:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:22px;
}
.fzone .follow .report svg{
width: 24px;
height: 24px;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: 6px;
fill: currentColor;
}
.fzone .time{
margin-top: auto;
margin-bottom: 0px;
@@ -763,6 +814,7 @@ main h1{
.fzone .time p{
margin-top: 0px;
margin-bottom: 0px;
margin-right: 32px;
text-align: left;
font-size: 12px;
color:#999;
@@ -828,7 +880,41 @@ main h1{
border-bottom: 1px solid #FFC832;
}
.ads{
display: block;
position: relative;
animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards;
margin: 12px;
border-radius: 10px;
padding: 0px;
overflow:hidden;
background-color: #F5F5F5;
border: 1px solid #EEE;
width: auto;
}
@keyframes slideInY {
0% {
transform: translateY(24px);
opacity: 0;
}
100% {
transform: translateY(0px);
}
40%,100% {
opacity: 1;
}
}
.ads a{
margin: 0px;
padding: 0px;
}
.ads a img{
object-fit: cover;
margin: 0px;
width: 100%;
height: 10dvh;
vertical-align:top;
}
.ueuse{
animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards;
margin: 12px;
@@ -1413,7 +1499,14 @@ main h1{
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.ueuse .favbox .addabi svg {
margin-top: -12px;
margin-right: 0px;
width: 24px;
height: 24px;
fill: currentColor;
transition: all 250ms ease-out;
}
.ueuse .favbox img{
margin-left: 0px;
@@ -1945,6 +2038,7 @@ label>input {
font-size: 18px;
}
.modal-content p{
line-height: 20px;
font-size: 16px;
color:#252525;
text-decoration: none;
@@ -2260,6 +2354,7 @@ label>input {
margin-left: 12px;
margin-right: 12px;
width: 24%;
height: 92.5dvh;
background-color: #fff;
padding: 12px;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
@@ -2279,7 +2374,7 @@ label>input {
.rightbox .noticearea{
width: auto;
height: 52dvh;
height: 50dvh;
overflow: scroll;
border-radius: 10px;
}
@@ -2370,7 +2465,7 @@ label>input {
.rightbox .btmbox{
position: absolute;
bottom: 12px; /*下に固定*/
height: 31dvh;
height: 35dvh;
width: 90%;
}
@@ -3026,6 +3121,13 @@ hr{
margin-left: 0px;
}
summary {
font-weight: bold;
margin: -0.5em -0.5em 0;
padding: 0.5em;
}
.server_code{
animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards;
margin-top: 12px;
@@ -3034,14 +3136,15 @@ hr{
padding-left: 12px;
padding-right: 12px;
padding-top: 8px;
padding-bottom: 8px;
padding-bottom: 4px;
background-color: #F5F5F5;
border: 1px solid #EEE;
width: auto;
}
.server_code h1{
margin-top: 4px;
margin-bottom: 4px;
.server_code details {
padding: 0px;
margin-top: 0px;
margin-bottom: 0px;
text-align: left;
color:#252525;
font-family: 'BIZ UDGothic', sans-serif;
@@ -3050,6 +3153,28 @@ hr{
line-height: 22px;
font-weight: bold;
}
.server_code summary {
display: block;
list-style: none;
}
.server_code summary::-webkit-details-marker {
display: none;
}
.server_code details[open] p{
animation: slideInYopen 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}
@keyframes slideInYopen {
0% {
transform: translateY(-16px);
opacity: 0;
}
100% {
transform: translateY(0px);
}
40%,100% {
opacity: 1;
}
}
.server_code p{
margin-top: 4px;
margin-bottom: 4px;
@@ -3061,7 +3186,328 @@ hr{
line-height: 22px;
font-weight: bold;
}
.delbox {
margin: 0px;
padding: 0px;
display: flex;
}
.delbox p{
margin-top: auto;
margin-bottom: auto;
text-align: left;
color:#252525;
font-family: 'BIZ UDGothic', sans-serif;
word-wrap: break-word;
font-size: 14px;
line-height: 22px;
font-weight: bold;
}
.delbox .delbtn{
cursor: pointer;
border: none;
display: block;
width:60px;
padding: 8px auto;
margin-left: auto;
margin-right: 0px;
margin-top: 2px;
margin-bottom: 6px;
padding-top: 2px;
padding-bottom: 2px;
background-color: #F5F5F5;
border-radius: 50px;
color:#FF4848;
font-size: 16px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: center;
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.delbox .delbtn:hover{
background-color: #FF4848;
color: #f5f5f5;;
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.admin_settings{
display: flex;
}
.admin_settings .admin_right{
margin-right: 0px;
width: 70%;
}
.admin_settings .admin_left{
position: sticky;
top: 0;
margin-left: 0px;
padding: 12px;
width: 30%;
height: 92.5dvh;
border-right: 1px solid #EEE;
}
.admin_leftbtn{
cursor: pointer;
border: none;
display: flex;
width:80%;
margin: 8px;
padding: 8px auto;
margin-left: auto;
margin-right: auto;
padding-left: 12px;
padding-top: 4px;
padding-bottom: 4px;
background-color: #FFFFFF;
border-radius: 50px;
color:#FFC832;
font-size: 18px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: left;
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.admin_leftbtn:hover{
background-color: #FFC832;
color: #FFFAE6;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:85%;
}
.admin_leftbtn:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:75%;
}
.admin_userinfo{
padding: 12px;
}
.admin_userinfo .icon{
display: flex;
vertical-align: middle;
}
.admin_userinfo .icon img{
object-fit: cover;
margin-top: 12px;
text-align: left;
width: 128px;
height:128px;
border-radius: 50%;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
}
.admin_userinfo .icon .tatext{
display: block;
margin-top: auto;
margin-bottom: auto;
}
.admin_userinfo .icon .tatext h2{
word-wrap: break-word;
margin-left: 12px;
margin-top: 12px;
margin-bottom: auto;
color:#252525;
font-size: 32px;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: 900;
}
.admin_userinfo .icon .tatext p{
word-wrap: break-word;
margin-left: 12px;
margin-right: auto;
margin-top: auto;
margin-bottom: 14px;
color: #999;
font-size: 18px;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: 900;
}
.admin_userinfo .profile p{
text-align: left;
margin-top: 12px;
margin-bottom: auto;
margin-left: 0px;
margin-right: 0px;
word-wrap: break-word;
font-size: 18px;
color:#252525;
text-decoration: none;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: bold;
}
.admin_userinfo .roleboxes{
margin-top: 12px;
margin-left: 0px;
display: flex;
padding: 0px;
flex-wrap : wrap;
}
.admin_userinfo .rolebox{
margin-top: 0px;
margin-bottom: 12px;
margin-left: 0px;
margin-right: 12px;
width: auto;
padding-left: auto;
padding-right: auto;
background-color: #fff;
border: 1px solid #FFC832;
border-radius: 25px;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .15);
}
.admin_userinfo .rolebox p{
color:#FFC832;
margin-top: 2px;
margin-bottom: 2px;
margin-left: 10px;
margin-right: 10px;
font-size: 16px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
}
.admin_userinfo .about{
display: block;
}
.admin_userinfo .p2{
margin-top: 0px;
margin-bottom: 10px;
word-wrap: break-word;
line-height: 20px;
color: #868686;
font-size: 12px;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: normal;
}
.admin_userinfo .about p{
word-wrap: break-word;
margin-left: 0px;
margin-right: auto;
margin-top: auto;
margin-bottom: 14px;
color: #252525;
font-size: 18px;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: 900;
}
.admin_userinfo .banzone{
display: flex;
}
.admin_userinfo .banzone .banbtn{
cursor: pointer;
border: none;
display: block;
width:25%;
margin: 12px;
padding: 8px 5%;
margin-left: auto;
margin-right: auto;
padding-top: 8px;
padding-bottom: 8px;
background-color: #ff4848;
text-align: center;
border-radius: 50px;
color:#fff;
font-size: 22px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: center;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .15);
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
}
.admin_userinfo .banzone .banbtn:hover{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:30%;
}
.admin_userinfo .banzone .banbtn:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:20%;
}
.admin_userinfo .banzone .waterbtn{
cursor: pointer;
border: none;
display: block;
width:25%;
margin: 12px;
padding: 8px 5%;
margin-left: auto;
margin-right: auto;
padding-top: 8px;
padding-bottom: 8px;
background-color: #FFFAE6;
text-align: center;
border-radius: 50px;
color:#FFC832;
font-size: 22px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: center;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .15);
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
}
.admin_userinfo .banzone .waterbtn:hover{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:30%;
}
.admin_userinfo .banzone .waterbtn:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:20%;
}
.admin_userinfo .banzone .icebtn{
cursor: pointer;
border: none;
display: block;
width:25%;
margin: 12px;
padding: 8px 5%;
margin-left: auto;
margin-right: auto;
padding-top: 8px;
padding-bottom: 8px;
background-color: #ffbc0d;
text-align: center;
border-radius: 50px;
color:#fff;
font-size: 22px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: center;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .15);
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
}
.admin_userinfo .banzone .icebtn:hover{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:30%;
}
.admin_userinfo .banzone .icebtn:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:20%;
}
/*------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------スマホ向け--------------------------------------------------*/
/*--------------------------------------------------ここから--------------------------------------------------*/
@@ -3486,6 +3932,16 @@ hr{
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.ueuse .favbox .addabi svg {
margin-top: -8px;
margin-right: 0px;
margin-bottom: 2px;
width: 24px;
height: 24px;
fill: currentColor;
transition: all 250ms ease-out;
}
.ueuse{
animation: slideInY 0.5s cubic-bezier(0.25, 1, 0.5, 1) 1 forwards;
@@ -4191,6 +4647,59 @@ hr{
text-align: left;
}
.admin_settings{
display: block;
}
.admin_settings .admin_right{
width: 100%;
}
.admin_settings .admin_left{
background-color: #fff;
position:relative;
width: 100%;
height: auto;
padding: 0px;
border-right: 1px solid #EEE;
}
.admin_leftbtn{
cursor: pointer;
border: none;
display: block;
width:80%;
margin: 8px;
padding: 8px auto;
margin-left: auto;
margin-right: auto;
padding-left: 12px;
padding-top: 4px;
padding-bottom: 4px;
background-color: #FFFFFF;
border-radius: 50px;
color:#FFC832;
font-size: 18px;
font-family: 'Zen Maru Gothic', sans-serif;
font-weight: normal;
text-decoration:none;
text-align: left;
transition: box-shadow 250ms ease-in-out;
transition: width 250ms ease-out;
transition: all 250ms ease-out;
}
.admin_leftbtn:hover{
background-color: #FFC832;
color: #FFFAE6;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
width:85%;
}
.admin_leftbtn:active{
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .05);
width:75%;
}
}
/*------------------------------------------------------------------------------------------------------------*/
@@ -4408,6 +4917,18 @@ hr{
color:#FFFAE6;
}
.fzone .follow .report{
background-color: #0c0c0c;
color:#FFC832;
border: 1px solid #FFC832;
}
.fzone .follow .report:hover{
background-color: #302c2c;
color: #ff4848;
border: 1px solid #ff4848;
}
.rightbox{
background-color: #0c0c0c;
@@ -4580,7 +5101,7 @@ hr{
border: none;
width: auto;
}
.server_code h1{
.server_code details{
color: #CCC;
}
.server_code p{
@@ -4732,4 +5253,49 @@ hr{
color: #FFC832;
border-bottom: 1px solid #FFC832;
}
.admin_settings .admin_left{
background-color: #0c0c0c;
border-right: none;
}
.admin_leftbtn{
background-color: #0c0c0c;
color:#FFC832;
}
.admin_leftbtn:hover{
background-color: #FFC832;
color: #0c0c0c;
}
.admin_userinfo .icon .tatext h2{
color:#FFF;
}
.admin_userinfo .icon .tatext p{
color: #CCC;
}
.admin_userinfo .profile p{
color:#CCC;
}
.admin_userinfo .rolebox{
background-color: #0c0c0c;
border: 1px solid #FFC832;
}
.admin_userinfo .rolebox p{
color:#FFC832;
}
.admin_userinfo .p2{
color: #CCC;
}
.admin_userinfo .about p{
color: #FFF;
}
.delbox .delbtn{
background-color: #302c2c;
color:#FF4848;
}
.delbox .delbtn:hover{
background-color: #FF4848;
color: #F5F5F5;
}
}
+38 -24
View File
@@ -1,27 +1,35 @@
<?php
require('../db.php');
if (isset($_POST['uniqid']) && isset($_POST['userid'])){
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
$userid = $_SESSION['userid'];
if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['userid'])) && htmlentities(isset($_POST['account_id']))){
$postUserid = htmlentities($_POST['userid']);
$postUniqid = htmlentities($_POST['uniqid']);
$loginid = htmlentities($_POST['account_id']);
if($userid === $postUserid){
try {
$option = array(
PDO::ATTR_ERRMODE => 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();
}
try {
$option = array(
PDO::ATTR_ERRMODE => 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();
}
// データベース接続の設定
$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,
));
$query = $dbh->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1');
$query->execute(array(':uniqid' => $postUniqid));
$result = $query->fetch();
if($result["account"] === $postUserid){
// データベース接続の設定
$dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
@@ -29,20 +37,20 @@ if (isset($_POST['uniqid']) && isset($_POST['userid'])){
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
));
$query = $dbh->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1');
$query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1');
$query->execute(array(':uniqid' => $postUniqid));
$result = $query->fetch();
$query->execute(array(':userid' => $postUserid));
if($result["account"] === $postUserid){
$result2 = $query->fetch();
if($result2["loginid"] === $loginid){
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
// 削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE uniqid = :uniqid AND account = :userid");
$deleteQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR);
$deleteQuery->bindValue(':userid', $postUserid, PDO::PARAM_STR);
$res = $deleteQuery->execute();
if ($res) {
@@ -57,6 +65,12 @@ if (isset($_POST['uniqid']) && isset($_POST['userid'])){
exit;
}
}
}else{
echo json_encode(['success' => false, 'error' => '削除に失敗しました。(userid_err)']);
exit;
}
}else{
echo json_encode(['success' => false, 'error' => '削除に失敗しました。(sess_err)']);
exit;
}
?>
+2
View File
@@ -57,6 +57,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -100,6 +101,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+2
View File
@@ -55,6 +55,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -98,6 +99,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+68 -48
View File
@@ -1,65 +1,85 @@
<?php
require('../db.php');
if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['userid']))) {
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
$ses_userid = $_SESSION['userid'];
if (htmlentities(isset($_POST['uniqid'])) && htmlentities(isset($_POST['userid'])) && htmlentities(isset($_POST['account_id']))) {
$postUniqid = htmlentities($_POST['uniqid']);
$userId = htmlentities($_POST['userid']);
$loginid = htmlentities($_POST['account_id']);
if($userId === $ses_userid){
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
try {
$option = array(
PDO::ATTR_ERRMODE => 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();
}
// 投稿のいいね情報を取得
$stmt = $pdo->prepare("SELECT favorite FROM ueuse WHERE uniqid = :uniqid");
$stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$stmt->execute();
$post = $stmt->fetch(PDO::FETCH_ASSOC);
// データベース接続の設定
$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,
));
$query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1');
$query->execute(array(':userid' => $userId));
$result2 = $query->fetch();
if($result2["loginid"] === $loginid){
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
// 投稿のいいね情報を取得
$stmt = $pdo->prepare("SELECT favorite FROM ueuse WHERE uniqid = :uniqid");
$stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$stmt->execute();
$post = $stmt->fetch(PDO::FETCH_ASSOC);
if ($post) {
$favoriteList = explode(',', $post['favorite']);
$index = array_search($userId, $favoriteList);
if ($index === false) {
// ユーザーIDを追加
$favoriteList[] = $userId;
} else {
// ユーザーIDを削除
array_splice($favoriteList, $index, 1);
}
// 新しいいいね情報を更新
$newFavorite = implode(',', $favoriteList);
$updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid");
$updateQuery->bindValue(':favorite', $newFavorite, PDO::PARAM_STR);
$updateQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$res = $updateQuery->execute();
if ($res) {
echo json_encode(['success' => true, 'newFavorite' => $newFavorite]);
exit;
} else {
echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']);
exit;
}
if ($post) {
$favoriteList = explode(',', $post['favorite']);
$index = array_search($userId, $favoriteList);
if ($index === false) {
// ユーザーIDを追加
$favoriteList[] = $userId;
} else {
// ユーザーIDを削除
array_splice($favoriteList, $index, 1);
}
// 新しいいいね情報を更新
$newFavorite = implode(',', $favoriteList);
$updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid");
$updateQuery->bindValue(':favorite', $newFavorite, PDO::PARAM_STR);
$updateQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$res = $updateQuery->execute();
if ($res) {
echo json_encode(['success' => true, 'newFavorite' => $newFavorite]);
exit;
} else {
echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']);
echo json_encode(['success' => false, 'error' => '投稿が見つかりません。']);
exit;
}
} else {
echo json_encode(['success' => false, 'error' => '投稿が見つかりません。']);
} catch(PDOException $e) {
echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
exit;
}
} catch(PDOException $e) {
echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
exit;
}
} else {
echo json_encode(['success' => false, 'error' => '必要なパラメータが提供されていません。']);
exit;
}
} else {
echo json_encode(['success' => false, 'error' => '必要なパラメータが提供されていません。']);
exit;
}
?>
+166 -164
View File
@@ -42,9 +42,10 @@ try {
$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 = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_SESSION['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -55,6 +56,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -87,7 +90,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_COOKIE['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -98,6 +101,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -448,28 +453,30 @@ if ("serviceWorker" in navigator) {
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="いまどうしてる?" name="ueuse"><?php if( !empty($_SESSION['ueuse']) ){ echo htmlspecialchars( $_SESSION['ueuse'], ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<?php if(!($role ==="ice")){?>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="いまどうしてる?" name="ueuse"><?php if( !empty($ueuse) ){ echo htmlspecialchars($ueuse, ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<input type="submit" class="ueusebtn" name="btn_submit" value="ユーズする">
<input type="submit" class="ueusebtn" name="btn_submit" value="ユーズする">
</div>
</div>
</div>
</form>
</form>
<?php }?>
<script>
document.getElementById("upload_videos1").addEventListener('change', function(e){
var file_reader = new FileReader();
@@ -551,167 +558,151 @@ if ("serviceWorker" in navigator) {
</body>
<script>
$(document).ready(function() {
loadPosts();
loadPosts();
var pageNumber = 1;
var isLoading = false;
var pageNumber = 1;
var isLoading = false;
function loadPosts() {
if (isLoading) return;
isLoading = true;
$("#loading").show();
var userid = '<?php echo $userid; ?>';
$.ajax({
url: '../nextpage/ftlpage.php', // PHPファイルへのパス
method: 'GET',
data: { page: pageNumber, userid: userid },
dataType: 'html',
success: function(response) {
$('#postContainer').append(response);
pageNumber++;
isLoading = false;
$("#loading").hide();
}
});
}
$('.outer').on('scroll', function() {
var innerHeight = $('.inner').innerHeight(), //内側の要素の高さ
outerHeight = $('.outer').innerHeight(), //外側の要素の高さ
outerBottom = innerHeight - outerHeight; //内側の要素の高さ - 外側の要素の高さ
if (outerBottom <= $('.outer').scrollTop()) {
var elem = document.getElementById("noueuse");
if (elem === null){
// 存在しない場合の処理
loadPosts();
} else {
// 存在する場合の処理
return;
}
function loadPosts() {
if (isLoading) return;
isLoading = true;
$("#loading").show();
var userid = '<?php echo $userid; ?>';
$.ajax({
url: '../nextpage/nextpage.php', // PHPファイルへのパス
method: 'GET',
data: { page: pageNumber, userid: userid },
dataType: 'html',
success: function(response) {
$('#postContainer').append(response);
pageNumber++;
isLoading = false;
$("#loading").hide();
}
});
}
$(document).on('click', '.favbtn, .favbtn_after', function(event) {
$('.outer').on('scroll', function() {
var innerHeight = $('.inner').innerHeight(), //内側の要素の高さ
outerHeight = $('.outer').innerHeight(), //外側の要素の高さ
outerBottom = innerHeight - outerHeight; //内側の要素の高さ - 外側の要素の高さ
if (outerBottom <= $('.outer').scrollTop()) {
var elem = document.getElementById("noueuse");
event.preventDefault();
if (elem === null){
// 存在しない場合の処理
loadPosts();
} else {
// 存在する場合の処理
return;
}
}
});
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
$(document).on('click', '.favbtn, .favbtn_after', function(event) {
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
event.preventDefault();
var $this = $(this); // ボタン要素を変数に格納
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
var $this = $(this); // ボタン要素を変数に格納
$.ajax({
url: '../favorite/favorite.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid, account_id: account_id }, // ここに自分のユーザーIDを指定
dataType: 'json',
success: function(response) {
if (response.success) {
// いいね成功時の処理
if (isLiked) {
$this.removeClass('favbtn_after'); // クラスを削除していいねを取り消す
$this.find('img').attr('src', '../img/sysimage/favorite_1.svg'); // 画像を元の画像に戻す
} else {
$this.addClass('favbtn_after'); // クラスを追加していいねを追加する
$this.find('img').attr('src', '../img/sysimage/favorite_2.svg'); // 画像を新しい画像に置き換える
}
var newFavoriteList = response.newFavorite.split(',');
var likeCount = newFavoriteList.length - 1;
likeCountElement.text(likeCount); // いいね数を更新
} else {
// いいね失敗時の処理
}
}.bind(this), // コールバック内でthisが適切な要素を指すようにbindする
error: function() {
// エラー時の処理
}
});
});
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../favorite/favorite.php',
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid }, // ここに自分のユーザーIDを指定
data: { uniqid: uniqid2, userid: userid, account_id: account_id },
dataType: 'json',
success: function(response) {
success: function (response) {
if (response.success) {
// いいね成功時の処理
if (isLiked) {
$this.removeClass('favbtn_after'); // クラスを削除していいねを取り消す
$this.find('img').attr('src', '../img/sysimage/favorite_1.svg'); // 画像を元の画像に戻す
} else {
$this.addClass('favbtn_after'); // クラスを追加していいねを追加する
$this.find('img').attr('src', '../img/sysimage/favorite_2.svg'); // 画像を新しい画像に置き換える
}
var newFavoriteList = response.newFavorite.split(',');
var likeCount = newFavoriteList.length - 1;
likeCountElement.text(likeCount); // いいね数を更新
postElement.remove();
} else {
// いいね失敗時の処理
// 削除失敗時の処理
}
}.bind(this), // コールバック内でthisが適切な要素を指すようにbindする
error: function() {
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2 },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
var more_modal = document.getElementById('myMoreModal');
var m_cancelButton = document.getElementById('m_c_button'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.more_btn', function (event) {
more_modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
m_cancelButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
more_modal.style.display = 'none';
}, 150);
});
});
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
$(document).on('click', '.addabi', function (event) {
$(document).on('click', '.addabi', function (event) {
abimodal.style.display = 'block';
modalMain.addClass("slideUp");
@@ -733,7 +724,9 @@ $(document).ready(function() {
event.preventDefault();
var abitext = document.getElementById("abitexts").value;
var username = "<?php echo $username?>";
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
@@ -745,25 +738,34 @@ $(document).ready(function() {
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: username},
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
if (response.success) {
abimodal.style.display = 'none';
postAbiElement.remove();
console.log(response);
} else {
abimodal.style.display = 'none';
postAbiElement.remove();
}
},
error: function (xhr, status, error) {
console.log(error);
abimodal.style.display = 'none';
postAbiElement.remove();
}
});
}
});
});
});
var osho_gats = document.getElementById('osho_gats');
$(document).on('click', '.os_exit_btn', function (event) {
document.cookie = "event=done; max-age=86400";
osho_gats.style.display = 'none';
});
});
+34 -25
View File
@@ -44,7 +44,7 @@ try {
if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_SESSION['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -55,6 +55,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -87,7 +89,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_COOKIE['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -98,6 +100,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -480,28 +484,30 @@ if ("serviceWorker" in navigator) {
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="いまどうしてる?" name="ueuse"><?php if( !empty($ueuse) ){ echo htmlspecialchars($ueuse, ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<?php if(!($role ==="ice")){?>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="いまどうしてる?" name="ueuse"><?php if( !empty($ueuse) ){ echo htmlspecialchars($ueuse, ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<input type="submit" class="ueusebtn" name="btn_submit" value="ユーズする">
<input type="submit" class="ueusebtn" name="btn_submit" value="ユーズする">
</div>
</div>
</div>
</form>
</form>
<?php }?>
<script>
document.getElementById("upload_videos1").addEventListener('change', function(e){
var file_reader = new FileReader();
@@ -632,6 +638,7 @@ $(document).ready(function() {
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
@@ -641,7 +648,7 @@ $(document).ready(function() {
$.ajax({
url: '../favorite/favorite.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid }, // ここに自分のユーザーIDを指定
data: { uniqid: postUniqid, userid: userid, account_id: account_id }, // ここに自分のユーザーIDを指定
dataType: 'json',
success: function(response) {
if (response.success) {
@@ -683,6 +690,7 @@ $(document).ready(function() {
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
@@ -695,7 +703,7 @@ $(document).ready(function() {
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2, userid: userid },
data: { uniqid: uniqid2, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
if (response.success) {
@@ -748,6 +756,7 @@ $(document).ready(function() {
var abitext = document.getElementById("abitexts").value;
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
@@ -759,7 +768,7 @@ $(document).ready(function() {
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid },
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
+1
View File
@@ -0,0 +1 @@
<svg version="1.1" id="addabi_1" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 760" width="24"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h360v80H200v560h560v-360h80v360q0 33-23.5 56.5T760-120H200Zm120-160v-80h320v80H320Zm0-120v-80h320v80H320Zm0-120v-80h320v80H320Zm360-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>

After

Width:  |  Height:  |  Size: 371 B

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.9 KiB

+1
View File
@@ -0,0 +1 @@
<svg id="report" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240ZM330-120 120-330v-300l210-210h300l210 210v300L630-120H330Zm34-80h232l164-164v-232L596-760H364L200-596v232l164 164Zm116-280Z"/></svg>

After

Width:  |  Height:  |  Size: 368 B

+21 -1
View File
@@ -27,7 +27,7 @@ try {
$userid = htmlentities($_GET['userid']);
$itemsPerPage = 30; // 1ページあたりのユーズ数
$itemsPerPage = 15; // 1ページあたりのユーズ数
$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
$offset = ($pageNumber - 1) * $itemsPerPage;
@@ -89,6 +89,23 @@ if (!empty($pdo)) {
$message['reply_count'] = $rpData['reply_count'];
}
}
//adsystem------------------
$message['ads'] = "false";
$today = date("Y-m-d H:i:s");
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
$adsQuery->bindValue(':today', $today);
$adsQuery->execute();
$adsresult = $adsQuery->fetch();
if(!(empty($adsresult))){
$message['ads'] = "true";
$message['ads_url'] = $adsresult["url"];
$message['ads_img_url'] = $adsresult["image_url"];
$message['ads_memo'] = $adsresult["memo"];
}
//--------------------------
if(!empty($messages)){
foreach ($messages as $value) {
@@ -102,6 +119,9 @@ if (!empty($pdo)) {
$messageDisplay = new MessageDisplay($value, $userid); // $userid をコンストラクタに渡す
$messageDisplay->display();
}
if($message['ads'] === "true"){
echo '<div class="ads"><a href = "' . htmlentities($message['ads_url']) . '"><img src="' . htmlentities($message['ads_img_url']) . '" title="' . htmlentities($message['ads_memo']) . '"></a></div>';
}
}else{
echo '<div class="tokonone" id="noueuse"><p>ユーズがありません</p></div>';
}
+21 -1
View File
@@ -27,7 +27,7 @@ try {
$userid = htmlentities($_GET['userid']);
$itemsPerPage = 30; // 1ページあたりのユーズ数
$itemsPerPage = 15; // 1ページあたりのユーズ数
$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
$offset = ($pageNumber - 1) * $itemsPerPage;
@@ -66,6 +66,23 @@ if (!empty($pdo)) {
$message['reply_count'] = $rpData['reply_count'];
}
}
//adsystem------------------
$message['ads'] = "false";
$today = date("Y-m-d H:i:s");
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
$adsQuery->bindValue(':today', $today);
$adsQuery->execute();
$adsresult = $adsQuery->fetch();
if(!(empty($adsresult))){
$message['ads'] = "true";
$message['ads_url'] = $adsresult["url"];
$message['ads_img_url'] = $adsresult["image_url"];
$message['ads_memo'] = $adsresult["memo"];
}
//--------------------------
if(!empty($messages)){
foreach ($messages as $value) {
@@ -79,6 +96,9 @@ if (!empty($pdo)) {
$messageDisplay = new MessageDisplay($value, $userid); // $userid をコンストラクタに渡す
$messageDisplay->display();
}
if($message['ads'] === "true"){
echo '<div class="ads"><a href = "' . htmlentities($message['ads_url']) . '"><img src="' . htmlentities($message['ads_img_url']) . '" title="' . htmlentities($message['ads_memo']) . '"></a></div>';
}
}else{
echo '<div class="tokonone" id="noueuse"><p>ユーズがありません</p></div>';
}
+1 -1
View File
@@ -27,7 +27,7 @@ class MessageDisplay {
// 投稿内のHTMLコードを表示する部分
echo ' <h3>' . htmlentities($this->value['title']) . '</h3>';
echo ' <p>' . htmlentities($this->value['msg']) . '</p>';
echo ' <p>' . nl2br(htmlentities($this->value['msg'])) . '</p>';
echo ' <a href="' . htmlentities($this->value['url']) . '">詳細をみる</a>';
echo '</div>';
+22 -1
View File
@@ -29,7 +29,7 @@ $userid = htmlentities($_GET['userid']);
$ueuseid = htmlentities(isset($_GET['id'])) ? htmlentities($_GET['id']) : '';
$itemsPerPage = 30; // 1ページあたりの投稿数
$itemsPerPage = 15; // 1ページあたりの投稿数
$pageNumber = htmlentities(isset($_GET['page'])) ? htmlentities(intval($_GET['page'])) : 1;
$offset = ($pageNumber - 1) * $itemsPerPage;
@@ -83,6 +83,24 @@ if (!empty($pdo)) {
}
}
//adsystem------------------
$message['ads'] = "false";
$today = date("Y-m-d H:i:s");
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
$adsQuery->bindValue(':today', $today);
$adsQuery->execute();
$adsresult = $adsQuery->fetch();
if(!(empty($adsresult))){
$message['ads'] = "true";
$message['ads_url'] = $adsresult["url"];
$message['ads_img_url'] = $adsresult["image_url"];
$message['ads_memo'] = $adsresult["memo"];
}
//--------------------------
if(!empty($messages)){
foreach ($messages as $value) {
$fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数
@@ -94,6 +112,9 @@ if (!empty($pdo)) {
$messageDisplay = new MessageDisplay($value, $userid);
$messageDisplay->display();
}
if($message['ads'] === "true"){
echo '<div class="ads"><a href = "' . htmlentities($message['ads_url']) . '"><img src="' . htmlentities($message['ads_img_url']) . '" title="' . htmlentities($message['ads_memo']) . '"></a></div>';
}
}else{
echo '<div class="tokonone" id="noueuse"><p>投稿がありません</p></div>';
}
+7 -2
View File
@@ -127,6 +127,8 @@ class MessageDisplay {
}
} elseif ($datetime >= $today) {
echo "今日 " . date("H:i", $datetime);
} elseif (date("Y", $datetime) == date("Y")) {
echo date("m月d日 H:i", $datetime);
} else {
echo date("Y年m月d日 H:i", $datetime);
}
@@ -171,13 +173,16 @@ class MessageDisplay {
}
echo '<a href="/!'.htmlentities($this->value['uniqid']). '~' . htmlentities($this->value['account']) . '" class="tuduki"><svg><use xlink:href="../img/sysimage/reply_1.svg#reply_1"></use></svg>'.htmlentities($this->value['reply_count']).'</a>';
if($this->value['account'] === $this->userid){
if($this->value['abi'] === "none"){
echo '<input type="submit" name="addabi" id="addabi" data-uniqid2="' . htmlentities($this->value['uniqid']) . '" class="addabi" value="追記する">';
if(!($this->value['role'] === "ice")){
if($this->value['abi'] === "none"){
echo '<button name="addabi" id="addabi" data-uniqid2="' . htmlentities($this->value['uniqid']) . '" class="addabi"><svg><use xlink:href="../img/sysimage/addabi_1.svg#addabi_1"></use></svg></button>';
}
}
echo '<input type="submit" name="delueuse" id="uniqid2" data-uniqid2="' . htmlentities($this->value['uniqid']) . '" class="delbtn" value="削除">';
}
echo '</div>';
echo '</div>';
}
}
}
+2
View File
@@ -57,6 +57,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -100,6 +101,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+2
View File
@@ -59,6 +59,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -102,6 +103,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+3 -1
View File
@@ -488,10 +488,12 @@ require('../logout/logout.php');
?>
<p>以下のボタンよりアクセストークンを取得すると使用できます。<br>アクセストークンは一度発行すると作り直すまで再度確認はできません。また、絶対に他人に知られないように保護してください。<p>
<input type="submit" class = "irobutton" name="token_submit" value="アクセストークン発行">
<?php }elseif($userData['token']==='ice'){ ?>
<p>アカウントが凍結されているため発行できません。</p>
<?php }else{ ?>
<p>以下のボタンよりアクセストークンを削除できます。ボタンを押すとすぐに削除されますのでご注意ください。</p>
<input type="submit" class = "irobutton" name="token_off_submit" value="アクセストークン削除">
<?php } ?>
<?php }?>
</form>
</main>
+2
View File
@@ -54,6 +54,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -97,6 +98,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+3
View File
@@ -9,6 +9,9 @@
<?php }?>
<a href="/search" class="btmbutton"><svg><use xlink:href="../img/sysimage/menuicon/search.svg#search"></use></svg></a>
<a href="/settings" class="btmbutton"><svg><use xlink:href="../img/sysimage/menuicon/settings.svg#settings"></use></svg></a>
<?php if($res["admin"] === "yes"){?>
<a href="/settings_admin/serveradmin" class="btmbutton"><svg><use xlink:href="../img/sysimage/menuicon/server.svg#server"></use></svg></a>
<?php }?>
</div>
</div>
<?php ?>
+1 -1
View File
@@ -20,7 +20,7 @@
<hr>
<a href="/emoji/addemoji" class="leftbutton"><svg><use xlink:href="../img/sysimage/menuicon/addemoji.svg#addemoji"></use></svg>絵文字登録</a>
<a href="/notice/addnotice" class="leftbutton"><svg><use xlink:href="../img/sysimage/menuicon/addnotice.svg#addnotice"></use></svg>お知らせ配信</a>
<a href="/settings/serveradmin" class="leftbutton"><svg><use xlink:href="../img/sysimage/menuicon/server.svg#server"></use></svg>サーバー設定</a>
<a href="/settings_admin/serveradmin" class="leftbutton"><svg><use xlink:href="../img/sysimage/menuicon/server.svg#server"></use></svg>サーバー設定</a>
<?php }?>
<hr>
<form method="post">
+2 -2
View File
@@ -19,8 +19,8 @@
$uwuzuinfo[$i] = ($softwaredata[$i]);
}
?>
<h1>お知らせ</h1>
<div class="noticearea">
<h1>お知らせ</h1>
<?php if(empty($notices)){?>
<div class="noticebox">
<h4>なし</h4>
@@ -38,8 +38,8 @@
</div>
<?php }}?>
</div>
<h1>サーバー情報</h1>
<div class="btmbox">
<h1>サーバー情報</h1>
<h2>Server</h2>
<h3><?php echo file_get_contents($servernamefile);?></h3>
<p><?php echo $domain;?></p>
+54 -71
View File
@@ -55,6 +55,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -98,6 +99,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -288,13 +290,13 @@ $(document).ready(function() {
}
$(document).on('click', '.favbtn, .favbtn_after', function(event) {
event.preventDefault();
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
@@ -304,7 +306,7 @@ $(document).ready(function() {
$.ajax({
url: '../favorite/favorite.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid }, // ここに自分のユーザーIDを指定
data: { uniqid: postUniqid, userid: userid, account_id: account_id }, // ここに自分のユーザーIDを指定
dataType: 'json',
success: function(response) {
if (response.success) {
@@ -328,86 +330,67 @@ $(document).ready(function() {
// エラー時の処理
}
});
});
});
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2 },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
var more_modal = document.getElementById('myMoreModal');
var m_cancelButton = document.getElementById('m_c_button'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.more_btn', function (event) {
more_modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
m_cancelButton.addEventListener('click', () => {
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
modalMain.addClass("slideDown");
window.setTimeout(function(){
more_modal.style.display = 'none';
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
});
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
$(document).on('click', '.addabi', function (event) {
$(document).on('click', '.addabi', function (event) {
abimodal.style.display = 'block';
modalMain.addClass("slideUp");
@@ -430,6 +413,8 @@ $(document).ready(function() {
var abitext = document.getElementById("abitexts").value;
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
@@ -441,7 +426,7 @@ $(document).ready(function() {
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: usernames },
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
@@ -462,9 +447,7 @@ $(document).ready(function() {
});
}
});
});
});
});
</script>
+25 -4
View File
@@ -31,12 +31,12 @@ uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作
まず、Apache2とPHP 8とmysql Ver 15が導入されているサーバーを準備します!
PHP 8では事前にGDを有効化しておいてください!(QRコードの生成に必要です。)
次にSQLを設定します。(InnoDB)
まず、お好きな名前でDBを作成し、その中に、account,emoji,notice,role,ueuse,notificationとテーブルを作成します。
まず、お好きな名前でDBを作成し、その中に、account,emoji,notice,role,ueuse,notification,ads,reportとテーブルを作成します。
テーブルの中身は以下のとおりです。
照合順序は全て標準でutf8mb4_general_ciです。
## 簡単に構築できるようSQLの構造ファイルがリリースに添付されています!そちらをインポートしていただけますと大幅に簡単に導入できます!
(userロールとofficialロールの設定は別途必要です。お手数ですがそこの設定だけよろしくお願いいたします。)
(userロールとofficialロールとiceロールの設定は別途必要です。お手数ですがそこの設定だけよろしくお願いいたします。)
### account
- sysid(INT)(AUTO_INCREMENT ) アカウントが追加されるとカウントされるシステム用ID
@@ -107,8 +107,27 @@ PHP 8では事前にGDを有効化しておいてください!(QRコードの
- used(varchar(25)) 使用済みかそうでないか
- datetime(datetime) 招待コード仕様日時更新用
### report
- sysid(INT)(AUTO_INCREMENT) 追加されるとカウントされるシステム用ID
- uniqid(varchar(256)) 通報ID保存用
- userid(varchar(500)) 通報先ユーザーID保存用
- report_userid(varchar(500)) 通報元ユーザーID保存用
- msg(text) サービス管理者宛メッセージ保存用
- datetime(datetime) 通報日時保存用
- admin_chk(varchar(25)) 解決済みかどうか確認用
### ads
- sysid(INT)(AUTO_INCREMENT) 追加されるとカウントされるシステム用ID
- uniqid(varchar(512)) 広告ID保存用
- url(varchar(512)) 広告のクリック先URL保存用
- image_url(varchar(512)) 広告に表示する画像URL保存用
- memo(text) 広告にマウスオーバーしたときに表示されるメッセージ保存用
- start_date(datetime) 広告配信開始日時保存用
- limit_date(datetime) 広告配信終了日時保存用
- datetime(datetime) 広告追加日時保存用
すべて作成完了したらGithubよりuwuzuのファイルをDLし、解凍し、それをサーバーの動作ディレクトリに置き、Apacheのhttpd.confからその動作ディレクトリを指定し、動作ディレクトリ内のdb.phpにDBのログイン情報を書き込んであとはApacheとphpとMy SQLを起動するだけ!
起動したらまずDBのroleにphpmyadminから「user」ロールと「official」ロールを追加、権限は「user」と「official」でOK。ロール名はとりあえず「一般ユーザー」ロールの色はHEXコード(#を除く)で000000のように指定。(このつのロールがないとエラーが発生します。)
起動したらまずDBのroleにphpmyadminから「user」ロールと「official」ロールと「ice」ロールを追加、権限は「user」と「official」と「ice」でOK。ロール名はとりあえず「一般ユーザー」とか適当でOK、ロールの色はHEXコード(#を除く)で000000のように指定。(この3つのロールがないとエラーが発生します。)
そしたら普通にuwuzuにアクセスして自分のアカウントを登録。
## 管理者アカウント登録機能が追加されました。【[domain]/admin/】より設定できるのでそちらをご利用ください。
なお、管理者アカウントを導入後に登録した場合サーバーを止めてuwuzu動作ディレクトリ内のserverフォルダ内のファイルを設定する必要はございません。
@@ -118,6 +137,8 @@ PHP 8では事前にGDを有効化しておいてください!(QRコードの
## 管理者アカウント作成後にログインし、サーバー設定より以下の項目が簡単に設定できます。
- 404imagepath.txt : 404ページに表示する画像パス保存用
- 503imagepath.txt : 503ページに表示する画像パス保存用
- admininfo.txt : 管理者名(てすとまる/@sampledayo)
- contact.txt : 管理者への連絡用メアド(sample@test.com)
- info.txt : サーバー登録時に表示されるメッセージ(好きな内容)
@@ -152,4 +173,4 @@ daichimarukanaと一緒に開発したいよ~って人は私のHPからメー
編集者 : daichimarukana
最終更新日 : 2023/09/05 0:36
最終更新日 : 2023/09/10 18:15
+2 -2
View File
@@ -1,4 +1,4 @@
uwuzu
1.2.18
2023/09/06
1.2.19
2023/09/10
daichimarukana,putonfps
+23
View File
@@ -1,6 +1,29 @@
## リリースノートだぜぇぇぇぇぇぇい!!!!!!!
ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...)
## Version 1.2.19
リリース日:2023/09/10
脆弱性修正時に新たなバグが追加されてしまったためそれの修正をしました。
修正箇所にはまだ脆弱性があるため使用時はご注意ください。
日時表示で投稿日時が同じ年内の場合は月/日表示にするようにしました。
追記ボタンをアイコン表示にしました。
招待コードの表示UIを変更しました。
招待コードを量産できる機能を実装しました。
招待コードを簡単に削除できるようにしました。
通知内で改行できるようにしました。
アカウントの凍結・BAN機能を実装しました。
凍結機能実装にあたり「凍結/ice」ロールが必須になりました。
サーバー構築時は「ユーザー/user・公式/official・凍結/ice」を追加するようにしてください。
設定画面のUIを変更しました。
アカウント通報機能を実装しました。
広告を設置できるようにしました!
広告は各サーバーごとに募集して載せる方式となります。
また、広告によって収入を得る場合電気通信事業者に該当するため電気通信事業の届出をしてください。
詳細は電気通信事業参入マニュアル[追補版]をご覧ください。[https://www.soumu.go.jp/main_content/000477428.pdf]
広告はLTL・FTL・返信画面に投稿10件につき1件表示されます。
広告の優先順位等は設定できません。
広告はTLの横幅いっぱいに、縦は10dvhで表示されます。
## Version 1.2.18
リリース日:2023/09/06
脆弱性を修正しました。
+2
View File
@@ -67,6 +67,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -110,6 +111,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+2
View File
@@ -54,6 +54,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -97,6 +98,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
+400
View File
@@ -0,0 +1,400 @@
<?php
$servernamefile = "../server/servername.txt";
$serverinfofile = '../server/info.txt';
$serverinfo = file_get_contents($serverinfofile);
$servertermsfile = '../server/terms.txt';
$serverterms = file_get_contents($servertermsfile);
$serverprvfile = '../server/privacypolicy.txt';
$serverprv = file_get_contents($serverprvfile);
$contactfile = "../server/contact.txt";
$adminfile = "../server/admininfo.txt";
$serverstopfile = "../server/serverstop.txt";
$onlyuserfile = "../server/onlyuser.txt";
$err404imagefile = "../server/404imagepath.txt";
$robots = "../robots.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
function random_code($length = 8){
return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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(!($res["admin"] === "yes")){
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'];
if( !empty($_POST['ads_btn_submit']) ) {
$ads_url = htmlentities($_POST['ads_url']);
$ads_img_url = htmlentities($_POST['ads_img_url']);
$ads_start_date = htmlentities(date($_POST['ads_start_date']));
$ads_limit_date = htmlentities(date($_POST['ads_limit_date']));
$ads_memo = htmlentities($_POST['ads_memo']);
if(empty($ads_url)){
$error_message[] = "URLが入力されていません。";
}
if(empty($ads_img_url)){
$error_message[] = "画像のURLが入力されていません。";
}
if(empty($ads_start_url)){
$error_message[] = "設置開始日時が入力されていません。";
}
if(empty($ads_limit_url)){
$error_message[] = "設置終了日時が入力されていません。";
}
if(empty($ads_memo_url)){
$error_message[] = "メモが入力されていません。";
}
if (!empty($pdo)) {
// 書き込み日時を取得
$datetime = date("Y-m-d H:i:s");
$uniqid = createUniqId();
// トランザクション開始
$pdo->beginTransaction();
try {
// SQL作成
$stmt = $pdo->prepare("INSERT INTO ads (uniqid, url, image_url, memo, start_date, limit_date, datetime) VALUES (:uniqid, :url, :image_url, :memo, :start_date, :limit_date, :datetime)");
$stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR);
$stmt->bindParam(':url', $ads_url, PDO::PARAM_STR);
$stmt->bindParam(':image_url', $ads_img_url, PDO::PARAM_STR);
$stmt->bindParam(':memo', $ads_memo, PDO::PARAM_STR);
$stmt->bindParam(':start_date', $ads_start_date, PDO::PARAM_STR);
$stmt->bindParam(':limit_date', $ads_limit_date, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, 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[] = $e->getMessage();
}
// プリペアドステートメントを削除
$stmt = null;
}
}
if( !empty($_POST['ads_del']) ) {
$ads_uniqid = htmlentities($_POST['ads_id']);
try{
// 通知削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM ads WHERE uniqid = :uniqid");
$deleteQuery->bindValue(':uniqid', $ads_uniqid, PDO::PARAM_STR);
$res = $deleteQuery->execute();
} 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[] = $e->getMessage();
}
// プリペアドステートメントを削除
$stmt = null;
}
require('../logout/logout.php');
if(isset($_GET['q'])){
$keyword = htmlentities($_GET['q']);
}else{
$keyword = "";
}
if (!empty($pdo)) {
$sql = "SELECT * FROM ads ORDER BY datetime DESC";
$allads = $pdo->query($sql);
while ($row = $allads->fetch(PDO::FETCH_ASSOC)) {
$adss[] = $row;
}
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>広告 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="admin_settings">
<?php require('settings_left_menu.php');?>
<div class="admin_right">
<form class="formarea" enctype="multipart/form-data" method="post">
<h1>広告追加</h1>
<p>広告はLTL・FTL・返信画面に表示されます。<br>また、投稿10件につき一件の広告がランダムに選ばれ表示されます。<br>表示の優先順位は設定できません。</p>
<div>
<p>クリックした時のリダイレクト先URL</p>
<div class="p2">広告をクリックするとこのURLに飛びます。</div>
<input id="ads_url" placeholder="https://uwuzu.net/" class="inbox" type="text" name="ads_url" value="">
</div>
<div>
<p>画像URL</p>
<div class="p2">以下のURL先の画像が表示されます。</div>
<input id="ads_img_url" placeholder="https://uwuzu.net/img/uwuzulogo.png" class="inbox" type="text" name="ads_img_url" value="">
</div>
<div>
<p>掲載開始日時</p>
<div class="p2">広告の掲載開始日時です。</div>
<input type="date" name="ads_start_date" class="inbox" value="2023-08-16">
</div>
<div>
<p>掲載終了日時</p>
<div class="p2">広告の掲載終了日時です。</div>
<input type="date" name="ads_limit_date" class="inbox" value="2023-08-17">
</div>
<div>
<p>広告のメモ</p>
<div class="p2">ユーザーが広告について確認するときに表示されるメモです。</div>
<textarea type="text" name="ads_memo" placeholder="このメモはユーザーに公開されます" class="inbox"></textarea>
</div>
<input type="submit" class = "irobutton" name="ads_btn_submit" value="追加">
</form>
<div class="formarea">
<hr>
<h1>広告一覧</h1>
<?php if(!(empty($adss))){?>
<?php foreach ($adss as $value) {?>
<div class="server_code">
<details>
<summary><?php echo htmlentities($value["url"]);?></summary>
<hr>
<p>設置状況:<?php if( !empty($value["url"]) ){
if($value["start_date"] < date("Y-m-d H:i:s") && $value["limit_date"] > date("Y-m-d H:i:s")){
echo "設置中  ✅";
}else{
echo "設置解除済⛔";
}}?></p>
<p>設置期間:<?php echo date("Y年m月d日",strtotime($value["start_date"])).' から '.date("Y年m月d日",strtotime($value["limit_date"])).' まで';?>
<hr>
<p>URL:<?php echo htmlentities($value["url"]);?></p>
<p>画像URL:<?php echo htmlentities($value["image_url"]);?></p>
<hr>
<p>メモ:<?php echo htmlentities($value["memo"]);?></p>
<hr>
<p>追加日時:<?php echo htmlentities($value["datetime"]);?></p>
<hr>
<form enctype="multipart/form-data" method="post">
<div class="delbox">
<p>削除ボタンを押すとこの広告は削除されます。</p>
<input type="text" name="ads_id" id="ads_id" value="<?php echo htmlentities($value["uniqid"]);?>" style="display:none;" >
<input type="submit" name="ads_del" class="delbtn" value="削除">
</div>
</form>
</details>
</div>
<?php }?>
<?php }?>
</div>
</div>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
</body>
</html>
+60
View File
@@ -0,0 +1,60 @@
<?php
require('../db.php');
if (htmlentities(isset($_POST['code'])) && htmlentities(isset($_POST['userid'])) && htmlentities(isset($_POST['account_id']))){
$postUserid = htmlentities($_POST['userid']);
$postCode= htmlentities($_POST['code']);
$loginid = htmlentities($_POST['account_id']);
try {
$option = array(
PDO::ATTR_ERRMODE => 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();
}
// データベース接続の設定
$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,
));
$query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1');
$query->execute(array(':userid' => $postUserid));
$result2 = $query->fetch();
if($result2["loginid"] === $loginid){
if($result2["admin"] === "yes"){
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
// 削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM invitation WHERE code = :code");
$deleteQuery->bindValue(':code', $postCode, PDO::PARAM_STR);
$res = $deleteQuery->execute();
if ($res) {
echo json_encode(['success' => true]);
exit;
} else {
echo json_encode(['success' => false, 'error' => '削除に失敗しました。']);
exit;
}
} catch(PDOException $e) {
echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
exit;
}
}
}
}else{
echo json_encode(['success' => false, 'error' => '削除に失敗しました。(sess_err)']);
exit;
}
?>
+364
View File
@@ -0,0 +1,364 @@
<?php
$servernamefile = "../server/servername.txt";
$serverinfofile = '../server/info.txt';
$serverinfo = file_get_contents($serverinfofile);
$servertermsfile = '../server/terms.txt';
$serverterms = file_get_contents($servertermsfile);
$serverprvfile = '../server/privacypolicy.txt';
$serverprv = file_get_contents($serverprvfile);
$contactfile = "../server/contact.txt";
$adminfile = "../server/admininfo.txt";
$serverstopfile = "../server/serverstop.txt";
$onlyuserfile = "../server/onlyuser.txt";
$err404imagefile = "../server/404imagepath.txt";
$robots = "../robots.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
function random_code($length = 8){
return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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(!($res["admin"] === "yes")){
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'];
if( !empty($pdo) ) {
// データベース接続の設定
$dbh = new PDO('mysql:charset=UTF8;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 FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $userid);
$userQuery->execute();
$userData = $userQuery->fetch();
$role = $userData["role"];
$dbh = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
$rerole = $dbh->prepare("SELECT username, userid, password, mailadds, profile, iconname, headname, role, datetime FROM account WHERE userid = :userid");
$rerole->bindValue(':userid', $userid);
// SQL実行
$rerole->execute();
$userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する
}
if (!empty($pdo)) {
$sql = "SELECT code,used,datetime FROM invitation ORDER BY datetime DESC";
$invcode = $pdo->query($sql);
while ($row = $invcode->fetch(PDO::FETCH_ASSOC)) {
$codes[] = $row;
}
}
if( !empty($_POST['code_btn_submit']) ) {
$make_code = $_POST['make_code'];
$code_num = 0;
while ($code_num < (int)$make_code) {
$code_num++;
$pdo->beginTransaction();
$datetime = date("Y-m-d H:i:s");
try {
$new_invcode = random_code();
$used = "none";
// SQL作成
$stmt = $pdo->prepare("INSERT INTO invitation (code, used, datetime) VALUES (:code, :used, :datetime)");
$stmt->bindParam(':code', $new_invcode, PDO::PARAM_STR);
$stmt->bindParam(':used', $used, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, 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[] = '発行に失敗しました。';
}
// プリペアドステートメントを削除
$stmt = null;
}
require('../logout/logout.php');
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>招待コード発行所 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="admin_settings">
<?php require('settings_left_menu.php');?>
<div class="admin_right">
<form class="formarea" enctype="multipart/form-data" method="post">
<h1>招待コード発行所</h1>
<?php if(file_get_contents($onlyuserfile) === "true"){?>
<p>下の発行ボタンで新しくコードを発行できます!<br>なお、コードは一回限り有効です。</p>
<div>
<p>発行数</p>
<input id="make_code" placeholder="1" class="inbox" type="number" name="make_code" value="1" min="1" max="10000">
</div>
<input type="submit" class = "irobutton" name="code_btn_submit" value="発行!">
<?php foreach ($codes as $value) {?>
<div class="server_code">
<details>
<summary>コード:<?php if( !empty($value["code"]) ){ echo htmlentities($value["code"]); }?><?php if( !empty($value["used"]) ){if($value["used"] === "true"){echo " ✅";}}?> </summary>
<p>使用状況:<?php if( !empty($value["used"]) ){
if($value["used"] === "none"){
echo "未使用<br>発行日時:".$value["datetime"]."";
}elseif($value["used"] === "true"){
echo "使用済み<br>使用日時:".$value["datetime"]."";
}?></p>
<div class="delbox">
<p>削除ボタンを押すとこのコードは使用できなくなります。</p>
<button type="button" id="code_delete" class="delbtn" del-code="<?php echo htmlentities($value["code"]);?>">削除</button>
</div>
</details>
</div>
<?php }?>
<?php }?>
<?php }else{?>
<p>サーバーは招待制にされていないため招待コードは利用できません。</p>
<?php }?>
</form>
</div>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
<script>
$(document).ready(function() {
$(document).on('click', '.delbtn', function (event) {
var code = $(this).attr('del-code');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var codeElement = $(this).closest('.server_code');
$.ajax({
url: 'code_delete.php',
method: 'POST',
data: { code: code, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
if (response.success) {
codeElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
});
</script>
</body>
</html>
+447
View File
@@ -0,0 +1,447 @@
<?php
$servernamefile = "../server/servername.txt";
$serverinfofile = '../server/info.txt';
$serverinfo = file_get_contents($serverinfofile);
$servertermsfile = '../server/terms.txt';
$serverterms = file_get_contents($servertermsfile);
$serverprvfile = '../server/privacypolicy.txt';
$serverprv = file_get_contents($serverprvfile);
$contactfile = "../server/contact.txt";
$adminfile = "../server/admininfo.txt";
$serverstopfile = "../server/serverstop.txt";
$onlyuserfile = "../server/onlyuser.txt";
$err404imagefile = "../server/404imagepath.txt";
$robots = "../robots.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
function random_code($length = 8){
return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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(!($res["admin"] === "yes")){
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'];
if( !empty($pdo) ) {
// データベース接続の設定
$dbh = new PDO('mysql:charset=UTF8;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 FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $userid);
$userQuery->execute();
$userData = $userQuery->fetch();
$role = $userData["role"];
$dbh = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
$rerole = $dbh->prepare("SELECT username, userid, password, mailadds, profile, iconname, headname, role, datetime FROM account WHERE userid = :userid");
$rerole->bindValue(':userid', $userid);
// SQL実行
$rerole->execute();
$userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する
}
if (!empty($pdo)) {
$sql = "SELECT code,used,datetime FROM invitation ORDER BY datetime DESC";
$invcode = $pdo->query($sql);
while ($row = $invcode->fetch(PDO::FETCH_ASSOC)) {
$codes[] = $row;
}
}
if( !empty($_POST['btn_submit']) ) {
// 空白除去
$servername = $_POST['servername'];
$serverinfo = $_POST['serverinfo'];
$serveradminname = $_POST['serveradminname'];
$servermailadds = $_POST['servermailadds'];
$onlyuser = $_POST['onlyuser'];
if($onlyuser === "true"){
$saveonlyuser = "true";
}else{
$saveonlyuser = "false";
}
$postrobots = $_POST['robots'];
if($postrobots === "true"){
//GPTBotによるクロールを拒否
$file = fopen($robots, 'w');
$data = "User-agent: GPTBot\nDisallow: /";
fputs($file, $data);
fclose($file);
}else{
//GPTBotによるクロールを許可
$file = fopen($robots, 'w');
$data = "";
fputs($file, $data);
fclose($file);
}
$serverterms = $_POST['serverterms'];
$serverprv = $_POST['serverprv'];
$serverstop = $_POST['serverstop'];
//鯖名
$file = fopen($servernamefile, 'w');
$data = $servername;
fputs($file, $data);
fclose($file);
//鯖紹介
$file = fopen($serverinfofile, 'w');
$data = $serverinfo;
fputs($file, $data);
fclose($file);
//鯖管理者名
$file = fopen($adminfile, 'w');
$data = $serveradminname;
fputs($file, $data);
fclose($file);
//鯖管理者メアド
$file = fopen($contactfile, 'w');
$data = $servermailadds;
fputs($file, $data);
fclose($file);
//招待制にするか
$file = fopen($onlyuserfile, 'w');
$data = $saveonlyuser;
fputs($file, $data);
fclose($file);
//利用規約
$file = fopen($servertermsfile, 'w');
$data = $serverterms;
fputs($file, $data);
fclose($file);
//プライバシーポリシー
$file = fopen($serverprvfile, 'w');
$data = $serverprv;
fputs($file, $data);
fclose($file);
//鯖停止
$file = fopen($serverstopfile, 'w');
$data = $serverstop;
fputs($file, $data);
fclose($file);
$url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("Location:".$url."");
exit;
}
require('../logout/logout.php');
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>サーバー設定 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="admin_settings">
<?php require('settings_left_menu.php');?>
<div class="admin_right">
<form class="formarea" enctype="multipart/form-data" method="post">
<h1>サーバー設定</h1>
<div>
<p>サーバー名</p>
<input id="servername" placeholder="uwuzuさ~ば~" class="inbox" type="text" name="servername" value="<?php if( !empty(file_get_contents($servernamefile)) ){ echo htmlspecialchars(file_get_contents($servernamefile), ENT_QUOTES, 'UTF-8'); } ?>">
</div>
<div>
<p>サーバー紹介メッセージ</p>
<textarea id="serverinfo" placeholder="たのしいさーばーです" class="inbox" type="text" name="serverinfo"><?php $sinfo = explode("\n", $serverinfo); foreach ($sinfo as $info) { echo $info; }?></textarea>
</div>
<div>
<p>サーバー管理者の名前</p>
<input id="serveradminname" placeholder="わたし" class="inbox" type="text" name="serveradminname" value="<?php if( !empty(file_get_contents($adminfile)) ){ echo htmlspecialchars(file_get_contents($adminfile), ENT_QUOTES, 'UTF-8'); } ?>">
</div>
<div>
<p>サーバーへのお問い合わせ用メールアドレス</p>
<input id="servermailadds" placeholder="" class="inbox" type="text" name="servermailadds" value="<?php if( !empty(file_get_contents($contactfile)) ){ echo htmlspecialchars(file_get_contents($contactfile), ENT_QUOTES, 'UTF-8'); } ?>">
</div>
<div>
<p>招待制にするかどうか</p>
<div class="switch_button">
<?php if(file_get_contents($onlyuserfile) === "true"){?>
<input id="onlyuser" class="switch_input" type='checkbox' name="onlyuser" value="true" checked/>
<label for="onlyuser" class="switch_label"></label>
<?php }else{?>
<input id="onlyuser" class="switch_input" type='checkbox' name="onlyuser" value="true" />
<label for="onlyuser" class="switch_label"></label>
<?php }?>
</div>
</div>
<div>
<p>OpenAIによるクロールを拒否するかどうか<br>※robots.txtによりOpenAIからのクロールを拒否するものであり、他のAI企業によるクロールを完全拒否するものではございません。</p>
<div class="switch_button">
<?php if(file_get_contents($robots) === "User-agent: GPTBot\nDisallow: /"){?>
<input id="robots" class="switch_input" type='checkbox' name="robots" value="true" checked/>
<label for="robots" class="switch_label"></label>
<?php }else{?>
<input id="robots" class="switch_input" type='checkbox' name="robots" value="true" />
<label for="robots" class="switch_label"></label>
<?php }?>
</div>
</div>
<div>
<p>利用規約</p>
<textarea id="serverterms" placeholder="しっかり書きましょう" class="inbox" type="text" name="serverterms"><?php $sinfo = explode("\n", $serverterms); foreach ($sinfo as $info) { echo $info; }?></textarea>
</div>
<div>
<p>プライバシーポリシー</p>
<textarea id="serverprv" placeholder="しっかり書きましょう" class="inbox" type="text" name="serverprv"><?php $sinfo = explode("\n", $serverprv); foreach ($sinfo as $info) { echo $info; }?></textarea>
</div>
<div>
<p>サーバー停止時表示メッセージ</p>
<input id="serverstop" placeholder="現在サーバーは止まっておりません。" class="inbox" type="text" name="serverstop" value="<?php if( !empty(file_get_contents($serverstopfile)) ){ echo htmlspecialchars(file_get_contents($serverstopfile), ENT_QUOTES, 'UTF-8'); } ?>">
</div>
<input type="submit" class = "irobutton" name="btn_submit" value="保存&更新">
</form>
</div>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
<script>
$(document).ready(function() {
$(document).on('click', '.delbtn', function (event) {
var code = $(this).attr('del-code');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var codeElement = $(this).closest('.server_code');
$.ajax({
url: 'code_delete.php',
method: 'POST',
data: { code: code, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
if (response.success) {
codeElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
});
</script>
</body>
</html>
+8
View File
@@ -0,0 +1,8 @@
<?php ?>
<div class="admin_left">
<a href="serveradmin" class="admin_leftbtn">サーバー設定</a>
<a href="useradmin" class="admin_leftbtn">ユーザー管理</a>
<a href="codeadmin" class="admin_leftbtn">招待コード発行所</a>
<a href="ad_admin" class="admin_leftbtn">広告</a>
</div>
<?php ?>
+374
View File
@@ -0,0 +1,374 @@
<?php
$servernamefile = "../server/servername.txt";
$serverinfofile = '../server/info.txt';
$serverinfo = file_get_contents($serverinfofile);
$servertermsfile = '../server/terms.txt';
$serverterms = file_get_contents($servertermsfile);
$serverprvfile = '../server/privacypolicy.txt';
$serverprv = file_get_contents($serverprvfile);
$contactfile = "../server/contact.txt";
$adminfile = "../server/admininfo.txt";
$serverstopfile = "../server/serverstop.txt";
$onlyuserfile = "../server/onlyuser.txt";
$err404imagefile = "../server/404imagepath.txt";
$robots = "../robots.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
function random_code($length = 8){
return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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(!($res["admin"] === "yes")){
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'];
if( !empty($_POST['btn_submit']) ) {
// 空白除去
$target_userid = $_POST['target_userid'];
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,
));
$rerole = $dbh->prepare("SELECT * FROM account WHERE userid = :userid");
$rerole->bindValue(':userid', $target_userid);
// SQL実行
$rerole->execute();
$userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する
if(empty($userdata)){
$error_message[] = "ユーザーがいません";
}else{
$_SESSION['userdata'] = $userdata;
// リダイレクト先のURLへ転送する
$url = 'userinfo';
header('Location: ' . $url, true, 303);
// すべての出力を終了
exit;
}
}
}
if( !empty($_POST['report_done']) ) {
$report_id = $_POST['report_id'];
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,
));
$newchk = "done";
// トランザクション開始
$pdo->beginTransaction();
try {
$stmt = $pdo->prepare("UPDATE report SET admin_chk = :adchk WHERE uniqid = :uniqid");
$stmt->bindValue(':adchk', $newchk, PDO::PARAM_STR);
$stmt->bindValue(':uniqid', $report_id , PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
if ($res) {
$url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("Location:".$url."");
exit;
} else {
$error_message[] = '発行に失敗しました。';
}
} catch (Exception $e) {
$error_message[] = "えらー";
// エラーが発生した時はロールバック
$pdo->rollBack();
}
}
}
require('../logout/logout.php');
if(isset($_GET['q'])){
$keyword = htmlentities($_GET['q']);
}else{
$keyword = "";
}
if (!empty($pdo)) {
$sql = "SELECT * FROM report WHERE admin_chk = 'none' ORDER BY datetime DESC";
$allreport = $pdo->query($sql);
while ($row = $allreport->fetch(PDO::FETCH_ASSOC)) {
$reports[] = $row;
}
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>ユーザー管理 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="admin_settings">
<?php require('settings_left_menu.php');?>
<div class="admin_right">
<form class="formarea" enctype="multipart/form-data" method="post">
<h1>ユーザー管理</h1>
<div>
<p>ユーザーID</p>
<div class="p2">「@」は外してください。</div>
<input id="target_userid" placeholder="admin" class="inbox" type="text" name="target_userid" value="<?php if( !empty($keyword) ){ echo htmlspecialchars($keyword, ENT_QUOTES, 'UTF-8'); } ?>">
</div>
<input type="submit" class = "irobutton" name="btn_submit" value="検索">
<section class="inner">
<div id="postContainer">
</div>
</section>
<div id="loading" class="loading" style="display: none;">
🤔
</div>
<hr>
</form>
<div class="formarea">
<h1>通報</h1>
<?php if(!(empty($reports))){?>
<?php foreach ($reports as $value) {?>
<div class="server_code">
<details>
<summary>@<?php if( !empty($value["userid"]) ){ echo htmlentities($value["userid"]); }?></summary>
<hr>
<p>通報先アカウント名:@<?php echo htmlentities($value["userid"]);?></p>
<p>通報元アカウント名:@<?php echo htmlentities($value["report_userid"]);?></p>
<hr>
<p>通報元アカウントよりメッセージ</p>
<p><?php echo nl2br(htmlentities($value["msg"]));?></p>
<hr>
<p>通報日時:<?php echo htmlentities($value["datetime"]);?></p>
<hr>
<p>アカウント操作を行う場合は上の「ユーザーID」にアカウントをしたいユーザーIDを入れて対応してください。</p>
<form enctype="multipart/form-data" method="post">
<div class="delbox">
<p>解決ボタンを押すとこの件は解決済みとなります。</p>
<input type="text" name="report_id" value="<?php echo htmlentities($value["uniqid"]);?>" style="display:none;" >
<input type="submit" name="report_done" class="delbtn" value="解決">
</div>
</form>
</details>
</div>
<?php }?>
<?php }else{?>
<p>通報されたアカウントはありません。</p>
<?php }?>
</div>
</div>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
</body>
</html>
+696
View File
@@ -0,0 +1,696 @@
<?php
$servernamefile = "../server/servername.txt";
$serverinfofile = '../server/info.txt';
$serverinfo = file_get_contents($serverinfofile);
$servertermsfile = '../server/terms.txt';
$serverterms = file_get_contents($servertermsfile);
$serverprvfile = '../server/privacypolicy.txt';
$serverprv = file_get_contents($serverprvfile);
$contactfile = "../server/contact.txt";
$adminfile = "../server/admininfo.txt";
$serverstopfile = "../server/serverstop.txt";
$onlyuserfile = "../server/onlyuser.txt";
$err404imagefile = "../server/404imagepath.txt";
$robots = "../robots.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
function random_code($length = 8){
return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
$userdata = $_SESSION['userdata'];
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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(!($res["admin"] === "yes")){
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'];
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,
));
$roles = explode(',', $userdata["role"]);
$roleDataArray = array();
foreach ($roles as $roleId) {
$rerole = $dbh->prepare("SELECT rolename, roleauth, rolecolor FROM role WHERE roleidname = :role");
$rerole->bindValue(':role', $roleId);
$rerole->execute();
$roleDataArray[$roleId] = $rerole->fetch();
}
$followIds = explode(',', $userdata['follow']);
$followCount = count($followIds)-1;
$followerIds = explode(',', $userdata['follower']);
$followerCount = count($followerIds)-1;
$result = $dbh->prepare("SELECT ueuse FROM ueuse WHERE account = :userid ORDER BY datetime");
$result->bindValue(':userid', $userdata["userid"]);
$result->execute();
$upload_cnt1 = $result->rowCount();
}
if( !empty($_POST['send_ice_submit']) ) {
$notice_msg = $_POST['notice_msg'];
$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,
));
$newrole = "ice";
$newtoken = "ice";
$newadmin = "user";
// トランザクション開始
$pdo->beginTransaction();
try {
$touserid = htmlentities($userdata['userid'], ENT_QUOTES, 'UTF-8');
// SQL作成
$stmt = $pdo->prepare("UPDATE account SET role = :role,token = :newtoken,admin = :newadmin WHERE userid = :userid");
$stmt->bindValue(':role', $newrole, PDO::PARAM_STR);
$stmt->bindValue(':newtoken', $newtoken, PDO::PARAM_STR);
$stmt->bindValue(':newadmin', $newadmin, PDO::PARAM_STR);
$stmt->bindValue(':userid', $touserid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
$pdo->beginTransaction();
try {
$touserid = htmlentities($userdata['userid'], ENT_QUOTES, 'UTF-8');
$datetime = date("Y-m-d H:i:s");
$msg = "サービス管理者からのメッセージは以下のものです。\n" . $notice_msg . "\n異議申し立てする場合は連絡用メールに異議申し立てをする旨を記載し送信をしてください。";
$title = "🧊お使いのアカウントは凍結されました。🧊";
$url = "/rule/serverabout";
$userchk = 'none';
// 通知用SQL作成
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
$stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR);
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
$stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res2 = $stmt->execute();
// コミット
$res2 = $pdo->commit();
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
header("Location:useradmin");
exit;
} else {
$error_message[] = '凍結に失敗しました。';
}
}
if( !empty($_POST['send_water_submit']) ) {
$newrole = "user";
$newtoken = "";
$newadmin = "user";
// トランザクション開始
$pdo->beginTransaction();
try {
$touserid = htmlentities($userdata['userid'], ENT_QUOTES, 'UTF-8');
// SQL作成
$stmt = $pdo->prepare("UPDATE account SET role = :role,token = :newtoken,admin = :newadmin WHERE userid = :userid");
$stmt->bindValue(':role', $newrole, PDO::PARAM_STR);
$stmt->bindValue(':newtoken', $newtoken, PDO::PARAM_STR);
$stmt->bindValue(':newadmin', $newadmin, PDO::PARAM_STR);
$stmt->bindValue(':userid', $touserid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch (Exception $e) {
$error_message[] = "えらー";
// エラーが発生した時はロールバック
$pdo->rollBack();
}
$pdo->beginTransaction();
try {
$touserid = htmlentities($userdata['userid'], ENT_QUOTES, 'UTF-8');
$datetime = date("Y-m-d H:i:s");
$msg = "サービス管理者によりお使いのアカウントは解凍されました!\n今まで通りご利用いただけます。\nまた、APIを使用している方はAPIのトークンがリセットされているため再度トークンを発行してご利用ください。";
$title = "🫗お使いのアカウントが解凍されました!🫗";
$url = "/home";
$userchk = 'none';
// 通知用SQL作成
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
$stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR);
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
$stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR);
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res2 = $stmt->execute();
// コミット
$res2 = $pdo->commit();
} catch(Exception $e) {
$error_message[] = "えらー";
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
header("Location:useradmin");
exit;
} else {
$error_message[] = '解凍に失敗しました。';
}
}
if( !empty($_POST['send_ban_submit']) ) {
$userId2 = $userdata['userid']; // 削除対象のユーザーID
$folderPath = "../ueuseimages/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete = glob($folderPath . "*-$userId2.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete as $file) {
if (is_file($file)) {
unlink($file); // ファイルを削除
}
}
$folderPath2 = "../ueusevideos/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete2 = glob($folderPath2 . "*-$userId2.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete2 as $file2) {
if (is_file($file2)) {
unlink($file2); // ファイルを削除
}
}
$folderPath3 = "../usericons/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete3 = glob($folderPath3 . "*-$userId2.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete3 as $file3) {
if (is_file($file3)) {
unlink($file3); // ファイルを削除
}
}
$folderPath4 = "../userheads/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete4 = glob($folderPath4 . "*-$userId2.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete4 as $file4) {
if (is_file($file4)) {
unlink($file4); // ファイルを削除
}
}
try {
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS);
// 投稿削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE account = :userid");
$deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR);
$res = $deleteQuery->execute();
// アカウント削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM account WHERE userid = :userid");
$deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR);
$res = $deleteQuery->execute();
// 通知削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid");
$deleteQuery->bindValue(':touserid', $userId2, PDO::PARAM_STR);
$res = $deleteQuery->execute();
// フォローの更新
$updateFollowQuery = $pdo->prepare("UPDATE account SET follow = REPLACE(follow, :userid, '') WHERE follow LIKE :pattern");
$updateFollowQuery->bindValue(':userid', ",$userId2", PDO::PARAM_STR);
$updateFollowQuery->bindValue(':pattern', "%,$userId2%", PDO::PARAM_STR);
$updateFollowQuery->execute();
// フォロワーの更新
$updateFollowerQuery = $pdo->prepare("UPDATE account SET follower = REPLACE(follower, :userid, '') WHERE follower LIKE :pattern");
$updateFollowerQuery->bindValue(':userid', ",$userId2", PDO::PARAM_STR);
$updateFollowerQuery->bindValue(':pattern', "%,$userId2%", PDO::PARAM_STR);
$updateFollowerQuery->execute();
// いいねの更新
$updateFavoriteQuery = $pdo->prepare("UPDATE ueuse SET favorite = REPLACE(favorite, :favorite, '') WHERE favorite LIKE :pattern");
$updateFavoriteQuery->bindValue(':favorite', ",$userId2", PDO::PARAM_STR);
$updateFavoriteQuery->bindValue(':pattern', "%,$userId2%", PDO::PARAM_STR);
$updateFavoriteQuery->execute();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
header("Location:useradmin");
exit;
} else {
$error_message[] = 'アカウント削除に失敗しました。';
}
// プリペアドステートメントを削除
$stmt = null;
}
require('../logout/logout.php');
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>ユーザー管理 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="admin_settings">
<?php require('settings_left_menu.php');?>
<div class="admin_right">
<div class="admin_userinfo">
<div class="icon">
<img src="<?php echo htmlentities('../'.$userdata['iconname']); ?>">
<div class="tatext">
<h2><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?></h2>
<p>@<?php echo htmlentities($userdata['userid'], ENT_QUOTES, 'UTF-8'); ?></p>
</div>
</div>
<div class="roleboxes">
<?php foreach ($roles as $roleId): ?>
<?php $roleData = $roleDataArray[$roleId]; ?>
<div class="rolebox" style="border: 1px solid <?php echo '#' . $roleData["rolecolor"]; ?>;">
<p style="color: <?php echo '#' . $roleData["rolecolor"]; ?>;">
<?php if (!empty($roleData["rolename"])) { echo htmlentities($roleData["rolename"], ENT_QUOTES, 'UTF-8'); } ?>
</p>
</div>
<?php endforeach; ?>
</div>
<div class="profile">
<div class="p2">プロフィール</div>
<p><?php echo nl2br(htmlspecialchars($userdata["profile"], ENT_QUOTES, 'UTF-8')); ?></p>
</div>
<hr>
<div class="about">
<div class="p2">メールアドレス</div>
<p><?php if( !empty($userdata["mailadds"]) ){ echo htmlspecialchars($userdata["mailadds"], ENT_QUOTES, 'UTF-8'); }else{echo "未設定";} ?></p>
<hr>
<div class="p2">二段階認証</div>
<p><?php if( !empty($userdata["authcode"]) ){ echo "設定済み";}else{echo "未設定";} ?></p>
<hr>
<div class="p2">管理者権限</div>
<p><?php if( !empty($userdata["admin"] === "yes") ){ echo "あり";}else{echo "なし";} ?></p>
<hr>
<div class="p2">フォロー数</div>
<p><?php if( $followCount > 0 ){ echo htmlspecialchars($followCount, ENT_QUOTES, 'UTF-8');}else{echo "なし";} ?></p>
<div class="p2">フォロワー数</div>
<p><?php if( $followerCount > 0 ){ echo htmlspecialchars($followerCount, ENT_QUOTES, 'UTF-8');}else{echo "なし";} ?></p>
<hr>
<div class="p2">投稿数</div>
<p><?php if( $upload_cnt1 > 0 ){ echo $upload_cnt1;}else{echo "なし";} ?></p>
<hr>
<div class="p2">アカウント登録日時</div>
<p><?php echo htmlspecialchars($userdata["datetime"], ENT_QUOTES, 'UTF-8'); ?></p>
<hr>
<div class="p2">アカウント操作</div>
<div class="banzone">
<?php if($roleId === "ice"){?>
<button id="water" class="waterbtn">解凍</button>
<?php }else{?>
<button id="ice" class="icebtn">凍結</button>
<?php }?>
<button id="ban" class="banbtn">BAN</button>
</div>
</div>
</div>
</div>
</div>
<div id="account_IceModal" class="modal">
<div class="modal-content">
<h1>このアカウントを凍結しますか?</h1>
<p><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントを凍結しますか?<br>凍結すると<?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんは以下のことができなくなります。<br>・投稿<br>・追記<br>・フォロー<br>・返信<br>・管理者権限の利用(管理者権限を持っていた場合)<br>・APIの使用(トークンがリセットされます)<br>また、以下の欄に入力した内容が個別メッセージとして通知欄に表示されます。<br><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんは異議申し立てが可能です。</p>
<form method="post" id="deleteForm">
<textarea id="notice_msg" placeholder="<?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんへのメッセージ" name="notice_msg"></textarea>
<div class="btn_area">
<input type="submit" id="deleteButton" class="fbtn_no" name="send_ice_submit" value="凍結">
<input type="button" id="cancelButton" class="fbtn" value="キャンセル">
</div>
</form>
</div>
</div>
<div id="account_BanModal" class="modal">
<div class="modal-content">
<h1>このアカウントをBANしますか?</h1>
<p><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントをBANしますか?<br>BANすると<?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントとは削除されます。<br>また、以下のデータも削除されます。<br>・アカウントに紐づいている画像や写真データ<br>・投稿<br>・フォロー情報やいいね情報<br>・APIトークン<br>・アカウントのメールアドレス<br>・その他アカウントに関連している情報<br>また、すぐに削除されるため本人に削除通知を送ることは出来ません。<br><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントを削除する場合は「BAN」を押してください。<br>アカウントの復旧は出来ません。</p>
<form class="btn_area" method="post" id="deleteForm">
<input type="submit" id="deleteButton2" class="fbtn_no" name="send_ban_submit" value="BAN">
<input type="button" id="cancelButton2" class="fbtn" value="キャンセル">
</form>
</div>
</div>
<div id="account_WaterModal" class="modal">
<div class="modal-content">
<h1>このアカウントを解凍しますか?</h1>
<p><?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントを解凍しますか?<br>凍結すると<?php echo htmlentities($userdata['username'], ENT_QUOTES, 'UTF-8'); ?>さんは今まで通りアカウントを使用できます。</p>
<form method="post" id="deleteForm">
<div class="btn_area">
<input type="submit" id="deleteButton3" class="fbtn_no" name="send_water_submit" value="解凍">
<input type="button" id="cancelButton3" class="fbtn" value="キャンセル">
</div>
</form>
</div>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
</body>
<script>
$(document).ready(function() {
var modal3 = document.getElementById('account_WaterModal');
var deleteButton3 = document.getElementById('deleteButton3');
var cancelButton3 = document.getElementById('cancelButton3'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.waterbtn', function (event) {
modal3.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
deleteButton3.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal3.style.display = 'none';
}, 150);
});
cancelButton3.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal3.style.display = 'none';
}, 150);
});
});
var modal = document.getElementById('account_IceModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.icebtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
var modal2 = document.getElementById('account_BanModal');
var deleteButton2 = document.getElementById('deleteButton2');
var cancelButton2 = document.getElementById('cancelButton2'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.banbtn', function (event) {
modal2.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
deleteButton2.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal2.style.display = 'none';
}, 150);
});
cancelButton2.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal2.style.display = 'none';
}, 150);
});
});
});
</script>
</html>
+150 -139
View File
@@ -49,7 +49,7 @@ try {
if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_SESSION['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -60,6 +60,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -92,7 +94,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_COOKIE['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -103,6 +105,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -482,29 +486,30 @@ $pdo = null;
<div class="emojibox">
<h1>返信</h1>
</div>
<?php if(!($role ==="ice")){?>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="へんし~ん!!!" name="ueuse"><?php if( !empty($_SESSION['ueuse']) ){ echo htmlentities( $_SESSION['ueuse'], ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<form method="post" enctype="multipart/form-data">
<div class="sendbox">
<textarea id="ueuse" placeholder="へんし~ん!!!" name="ueuse"><?php if( !empty($_SESSION['ueuse']) ){ echo htmlentities( $_SESSION['ueuse'], ENT_QUOTES, 'UTF-8'); } ?></textarea>
<p>画像のEXIF情報(位置情報など)は削除されません。<br>情報漏洩に気をつけてくださいね…</p>
<div class="fxbox">
<label for="upload_images" id="images">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images" id ="upload_images" accept="image/*">
</label>
<label for="upload_images2" id="images2">
<img src="../img/sysimage/image_1.svg">
<input type="file" name="upload_images2" id ="upload_images2" accept="image/*">
</label>
<label for="upload_videos1" id="videos1">
<img src="../img/sysimage/video_1.svg">
<input type="file" name="upload_videos1" id ="upload_videos1" accept="video/*">
</label>
<input type="submit" class="ueusebtn" name="btn_submit" value="返信する">
<input type="submit" class="ueusebtn" name="btn_submit" value="返信する">
</div>
</div>
</div>
</form>
</form>
<?php }?>
<script>
document.getElementById("upload_videos1").addEventListener('change', function(e){
var file_reader = new FileReader();
@@ -618,95 +623,100 @@ $(document).ready(function() {
}
}
});
$(document).on('click', '.favbtn, .favbtn_after', function(event) {
event.preventDefault();
event.preventDefault();
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
var $this = $(this); // ボタン要素を変数に格納
var $this = $(this); // ボタン要素を変数に格納
$.ajax({
url: '../favorite/favorite.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid, account_id: account_id }, // ここに自分のユーザーIDを指定
dataType: 'json',
success: function(response) {
if (response.success) {
// いいね成功時の処理
if (isLiked) {
$this.removeClass('favbtn_after'); // クラスを削除していいねを取り消す
$this.find('img').attr('src', '../img/sysimage/favorite_1.svg'); // 画像を元の画像に戻す
} else {
$this.addClass('favbtn_after'); // クラスを追加していいねを追加する
$this.find('img').attr('src', '../img/sysimage/favorite_2.svg'); // 画像を新しい画像に置き換える
}
var newFavoriteList = response.newFavorite.split(',');
var likeCount = newFavoriteList.length - 1;
likeCountElement.text(likeCount); // いいね数を更新
} else {
// いいね失敗時の処理
}
}.bind(this), // コールバック内でthisが適切な要素を指すようにbindする
error: function() {
// エラー時の処理
}
});
});
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../favorite/favorite.php',
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid }, // ここに自分のユーザーIDを指定
data: { uniqid: uniqid2, userid: userid, account_id: account_id },
dataType: 'json',
success: function(response) {
success: function (response) {
if (response.success) {
// いいね成功時の処理
if (isLiked) {
$this.removeClass('favbtn_after'); // クラスを削除していいねを取り消す
$this.find('img').attr('src', '../img/sysimage/favorite_1.svg'); // 画像を元の画像に戻す
} else {
$this.addClass('favbtn_after'); // クラスを追加していいねを追加する
$this.find('img').attr('src', '../img/sysimage/favorite_2.svg'); // 画像を新しい画像に置き換える
}
var newFavoriteList = response.newFavorite.split(',');
var likeCount = newFavoriteList.length - 1;
likeCountElement.text(likeCount); // いいね数を更新
postElement.remove();
} else {
// いいね失敗時の処理
// 削除失敗時の処理
}
}.bind(this), // コールバック内でthisが適切な要素を指すようにbindする
error: function() {
},
error: function () {
// エラー時の処理
}
});
});
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2, userid: userid },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
@@ -715,60 +725,61 @@ $(document).ready(function() {
$(document).on('click', '.addabi', function (event) {
abimodal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
abimodal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var postAbiElement = $(this).closest('.addabi');
var uniqid2 = $(this).attr('data-uniqid2');
var postAbiElement = $(this).closest('.addabi');
AbiCancelButton.addEventListener('click', () => {
AbiCancelButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
abimodal.style.display = 'none';
}, 150);
});
$('#AbiForm').off('submit').on('submit', function (event) {
event.preventDefault();
var abitext = document.getElementById("abitexts").value;
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
abimodal.style.display = 'none';
}, 150);
});
$('#AbiForm').off('submit').on('submit', function (event) {
event.preventDefault();
var abitext = document.getElementById("abitexts").value;
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
abimodal.style.display = 'none';
}, 150);
}else{
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
if (response.success) {
abimodal.style.display = 'none';
postAbiElement.remove();
console.log(response);
} else {
abimodal.style.display = 'none';
postAbiElement.remove();
}
},
error: function (xhr, status, error) {
console.log(error);
}else{
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
if (response.success) {
abimodal.style.display = 'none';
postAbiElement.remove();
console.log(response);
} else {
abimodal.style.display = 'none';
postAbiElement.remove();
}
});
}
});
},
error: function (xhr, status, error) {
console.log(error);
abimodal.style.display = 'none';
postAbiElement.remove();
}
});
}
});
});
});
+96 -79
View File
@@ -47,7 +47,7 @@ try {
if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_SESSION['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -58,6 +58,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -90,7 +92,7 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin FROM account WHERE userid = :userid");
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', $_COOKIE['userid']);
$passQuery->execute();
$res = $passQuery->fetch();
@@ -101,6 +103,8 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true) {
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
@@ -487,21 +491,27 @@ $pdo = null;
<p><?php echo $follow_yes;?></p>
</div>
<?php }?>
<div class="follow">
<a href="/user/report?q=<?php echo htmlentities($userData['userid'], ENT_QUOTES, 'UTF-8'); ?>" class="report" title="通報"><svg><use xlink:href="../img/sysimage/report_1.svg#report"></use></svg></a>
</div>
<?php if ($userData['userid'] == $userid) { ?>
<div class="follow">
<a href="../settings/" class="fbtn_no">設定</a>
<a href="../settings/" class="fbtn_no" title="設定" >設定</a>
</div>
<?php } else { ?>
<form method="post">
<div class="follow">
<?php
$followerList = explode(',', $userdata['follower']);
if (in_array($userid, $followerList)) {
// フォロー済みの場合はフォロー解除ボタンを表示
echo '<input type="button" id="openModalButton" class="fbtn_un" name="unfollow" value="フォロー解除">';
} else {
// 未フォローの場合はフォローボタンを表示
echo '<input type="submit" class="fbtn" name="follow" value="フォロー">';
if(!($role === "ice")){
$followerList = explode(',', $userdata['follower']);
if (in_array($userid, $followerList)) {
// フォロー済みの場合はフォロー解除ボタンを表示
echo '<input type="button" id="openModalButton" class="fbtn_un" name="unfollow" value="フォロー解除">';
} else {
// 未フォローの場合はフォローボタンを表示
echo '<input type="submit" class="fbtn" name="follow" value="フォロー">';
}
}
?>
</div>
@@ -510,15 +520,17 @@ $pdo = null;
<?php } ?>
</div>
<div id="myModal" class="modal">
<div class="modal-content">
<p><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?>さんをフォロー解除しますか?</p>
<form class="btn_area" method="post">
<input type="submit" id="openModalButton" class="fbtn_no" name="unfollow" value="フォロー解除">
<input type="button" id="closeModal" class="fbtn" value="キャンセル">
</form>
<?php if(!($role === "ice")){?>
<div id="myModal" class="modal">
<div class="modal-content">
<p><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?>さんをフォロー解除しますか?</p>
<form class="btn_area" method="post">
<input type="submit" id="openModalButton" class="fbtn_no" name="unfollow" value="フォロー解除">
<input type="button" id="closeModal" class="fbtn" value="キャンセル">
</form>
</div>
</div>
</div>
<?php }?>
<hr>
<div class="select_utl">
<button class="btn" id="all_ueuse_btn">ユーズ</button>
@@ -697,6 +709,26 @@ $(document).ready(function() {
}
});
// JavaScriptでウィンドウを制御
const modal1 = document.getElementById('myModal');
const openModalButton = document.getElementById('openModalButton');
const closeButton = document.getElementById('closeModal');
var modalMain = $('.modal-content');
openModalButton.addEventListener('click', () => {
modal1.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
});
closeButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal1.style.display = 'none';
}, 150);
});
$(document).on('click', '.favbtn, .favbtn_after', function(event) {
@@ -704,6 +736,7 @@ $(document).ready(function() {
var postUniqid = $(this).data('uniqid');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var likeCountElement = $(this).find('.like-count'); // いいね数を表示する要素
var isLiked = $(this).hasClass('favbtn_after'); // 現在のいいねの状態を判定
@@ -713,7 +746,7 @@ $(document).ready(function() {
$.ajax({
url: '../favorite/favorite.php',
method: 'POST',
data: { uniqid: postUniqid, userid: userid }, // ここに自分のユーザーIDを指定
data: { uniqid: postUniqid, userid: userid, account_id: account_id }, // ここに自分のユーザーIDを指定
dataType: 'json',
success: function(response) {
if (response.success) {
@@ -737,85 +770,67 @@ $(document).ready(function() {
// エラー時の処理
}
});
});
});
});
// JavaScriptでウィンドウを制御
const modal1 = document.getElementById('myModal');
const openModalButton = document.getElementById('openModalButton');
const closeButton = document.getElementById('closeModal');
var modalMain = $('.modal-content');
openModalButton.addEventListener('click', () => {
modal1.style.display = 'block';
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
});
modalMain.removeClass("slideDown");
closeButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal1.style.display = 'none';
}, 150);
});
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
var uniqid2 = $(this).attr('data-uniqid2');
var uniqid2 = $(this).attr('data-uniqid2');
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
var postElement = $(this).closest('.ueuse');
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2, userid: userid },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
$.ajax({
url: '../delete/delete.php',
method: 'POST',
data: { uniqid: uniqid2, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
if (response.success) {
postElement.remove();
} else {
// 削除失敗時の処理
}
},
error: function () {
// エラー時の処理
}
});
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
});
});
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
var abimodal = document.getElementById('myAbiModal');
var AbiAddButton = document.getElementById('AbiAddButton');
var AbiCancelButton = document.getElementById('AbiCancelButton');
var modalMain = $('.modal-content');
$(document).on('click', '.addabi', function (event) {
$(document).on('click', '.addabi', function (event) {
abimodal.style.display = 'block';
modalMain.addClass("slideUp");
@@ -839,6 +854,7 @@ $(document).ready(function() {
var abitext = document.getElementById("abitexts").value;
var usernames = '<?php echo $username; ?>';
var userid = '<?php echo $userid; ?>';
var account_id = '<?php echo $loginid; ?>';
if(abitext == ""){
modalMain.removeClass("slideUp");
@@ -850,7 +866,7 @@ $(document).ready(function() {
$.ajax({
url: '../abi/addabi.php',
method: 'POST',
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid },
data: { uniqid: uniqid2, abitext: abitext, username: usernames, userid: userid, account_id: account_id },
dataType: 'json',
success: function (response) {
console.log(response); // レスポンス内容をコンソールに表示
@@ -872,6 +888,7 @@ $(document).ready(function() {
}
});
});
});
</script>
</html>
+456
View File
@@ -0,0 +1,456 @@
<?php
$servernamefile = "../server/servername.txt";
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
$hashCreateTime = $sec.floor($msec*1000000);
$hashCreateTime = strrev($hashCreateTime);
return base_convert($hashCreateTime,10,36);
}
require('../db.php');
// 変数の初期化
$datetime = array();
$user_name = null;
$message = array();
$message_data = null;
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
$userid = htmlentities($_SESSION['userid']);
$username = htmlentities($_SESSION['username']);
try {
$option = array(
PDO::ATTR_ERRMODE => 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,role 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}else{
header("Location: ../login.php");
exit;
}
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role 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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$role = $res["role"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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'];
function customStripTags($html, $allowedTags) {
$allowedTagsString = '<' . implode('><', $allowedTags) . '>';
return strip_tags($html, $allowedTagsString);
}
$allowedTags = array('h1', 'h2', 'h3', 'center', 'font');
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,
));
if(isset($_GET['q'])){
$uwuzuid = htmlentities($_GET['q']);
}else{
$uwuzuid = "";
}
// ユーズ内の絵文字を画像に置き換える
function replaceEmojisWithImages($postText) {
// ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
$emojiPattern = '/:(\w+):/';
$postTextWithImages = preg_replace_callback($emojiPattern, function($matches) {
$emojiName = $matches[1];
return "<img src='../emoji/emojiimage.php?emoji=" . urlencode($emojiName) . "' alt=':$emojiName:' title=':$emojiName:'>";
}, $postText);
// @username を検出してリンクに置き換える
$usernamePattern = '/@(\w+)/';
$postTextWithImagesAndUsernames = preg_replace_callback($usernamePattern, function($matches) {
$username = $matches[1];
$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,
));
$mentionsuserQuery = $dbh->prepare("SELECT username, userid FROM account WHERE userid = :userid");
$mentionsuserQuery->bindValue(':userid', $username);
$mentionsuserQuery->execute();
$mentionsuserData = $mentionsuserQuery->fetch();
if(empty($mentionsuserData)){
return "@$username";
}else{
return "<a class = 'mta' href='/@".$mentionsuserData["userid"]."'>@".$mentionsuserData["username"]."</a>";
}
}, $postTextWithImages);
$hashtagsPattern = '/#([\p{Han}\p{Hiragana}\p{Katakana}A-Za-z0-9_]+)/u';
$postTextWithHashtags = preg_replace_callback($hashtagsPattern, function($matches) {
$hashtags = $matches[1];
return "<a class = 'hashtags' href='/search?q=".urlencode('#').$hashtags."'>".'#'.$hashtags."</a>";
}, $postTextWithImagesAndUsernames);
return $postTextWithHashtags;
}
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 = "<a href='$url'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
$userQuery = $dbh->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $uwuzuid);
$userQuery->execute();
$userData = $userQuery->fetch();
if(!empty($userData["userid"])){
$roles = explode(',', $userData["role"]); // カンマで区切られたロールを配列に分割
$rerole = $dbh->prepare("SELECT follow, follower, username, userid, password, mailadds, profile, iconname, headname, role, datetime FROM account WHERE userid = :userid");
$rerole->bindValue(':userid', $uwuzuid);
// SQL実行
$rerole->execute();
$userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する
$roleDataArray = array();
foreach ($roles as $roleId) {
$rerole = $dbh->prepare("SELECT rolename, roleauth, rolecolor FROM role WHERE roleidname = :role");
$rerole->bindValue(':role', $roleId);
$rerole->execute();
$roleDataArray[$roleId] = $rerole->fetch();
}
//-------フォロー数---------
$follow = $userdata['follow']; // コンマで区切られたユーザーIDを含む変数
// コンマで区切って配列に分割し、要素数を数える
$followIds = explode(',', $follow);
$followCount = count($followIds)-1;
$follow_on_me = strpos($follow, $userid);
if ($follow_on_me !== false) {
$follow_yes = "フォローされています"; // worldを含む:6
}else{
$follow_yes = ""; // worldを含む:6
}
//-------フォロワー数---------
$follower = $userdata['follower']; // コンマで区切られたユーザーIDを含む変数
// コンマで区切って配列に分割し、要素数を数える
$followerIds = explode(',', $follower);
$followerCount = count($followerIds)-1;
$profileText = htmlentities($userData['profile'], ENT_QUOTES, 'UTF-8');
}else{
$userData["userid"] = "none";
$userData['username'] = "ゆーざーなし";
}
}
if (!empty($_POST['report'])) {
$msg = htmlentities($_POST['send_text']);
// 書き込み日時を取得
$datetime = date("Y-m-d H:i:s");
$uniqid = createUniqId();
$admin_chk = "none";
$touserid = $userData['userid'];
// トランザクション開始
$pdo->beginTransaction();
try {
// SQL作成
$stmt = $pdo->prepare("INSERT INTO report (uniqid, userid, report_userid, msg, datetime, admin_chk) VALUES (:uniqid, :userid, :report_userid, :msg, :datetime, :admin_chk)");
$stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR);
$stmt->bindParam(':userid', $touserid, PDO::PARAM_STR);
$stmt->bindParam(':report_userid', $userid, PDO::PARAM_STR);
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
$stmt->bindParam(':admin_chk', $admin_chk, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if( $res ) {
header("Location:success");
exit;
} else {
$error_message[] = $e->getMessage();
}
// プリペアドステートメントを削除
$stmt = null;
}
require('../logout/logout.php');
// データベースの接続を閉じる
$pdo = null;
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="../css/home.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?> さんを通報 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main class="outer">
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<form class="formarea" enctype="multipart/form-data" method="post">
<h1>通報</h1>
<div class="p2">通報先アカウント名</div>
<p><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?></p>
<div class="p2">通報先id</div>
<p><?php echo htmlentities($userData['userid'], ENT_QUOTES, 'UTF-8'); ?></p>
<div class="p2">プロフィール</div>
<p><?php echo nl2br(htmlentities($userData['profile'], ENT_QUOTES, 'UTF-8')); ?></p>
<hr>
<p><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?>さんを通報しますか?<br>通報すると管理者宛に通知が届き、管理者の判断により<?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?>さんのアカウントに対処が行われます。<br>なお、虚偽の通報や理にかなわない通報などによっては管理者の判断によりあなたのアカウントが凍結やBAN(削除)される可能性があります。</p>
<p>管理者は通報者のid(@<?php echo htmlentities($userid, ENT_QUOTES, 'UTF-8'); ?>)を確認できます。</p>
<p>もし通報理由などありましたら下の入力欄に記載してください。</p>
<?php if($userid === $userData['userid']){; ?>
<ul class="errmsg">
<p>通報しようとしているアカウントはご自身のアカウントのようですが本当に通報してもよろしいのですか?<br>もしアカウントの削除をしたいのであれば左側メニューよりその他からアカウント削除が可能です。</p>
</ul>
<?php }?>
<textarea id="send_text" placeholder="通報理由" name="send_text" class="inbox"></textarea>
<div class="p2">※誤通報防止の為通報ボタンを小さくしております。</div>
<div class="delbox">
<button type="button" id="delbtn" class="delbtn">通報</button>
</div>
<div id="myDelModal" class="modal">
<div class="modal-content">
<h1>最終確認</h1>
<p>本当に通報しますか?<br>通報は取り消しできません。</p>
<div class="btn_area">
<input type="submit" id="deleteButton" class="fbtn_no" name="report" value="通報">
<input type="button" id="cancelButton" class="fbtn" value="キャンセル">
</div>
</div>
</div>
</form>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
</body>
<script>
$(document).ready(function() {
var modal = document.getElementById('myDelModal');
var deleteButton = document.getElementById('deleteButton');
var cancelButton = document.getElementById('cancelButton'); // 追加
var modalMain = $('.modal-content');
$(document).on('click', '.delbtn', function (event) {
modal.style.display = 'block';
modalMain.addClass("slideUp");
modalMain.removeClass("slideDown");
deleteButton.addEventListener('click', () => {
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
cancelButton.addEventListener('click', () => { // 追加
modalMain.removeClass("slideUp");
modalMain.addClass("slideDown");
window.setTimeout(function(){
modal.style.display = 'none';
}, 150);
});
});
});
</script>
</html>
+193
View File
@@ -0,0 +1,193 @@
<?php
$servernamefile = "../server/servername.txt";
require('../db.php');
$onlyuserfile = "../server/onlyuser.txt";
$onlyuser = file_get_contents($onlyuserfile);
session_name('uwuzu_s_id');
session_start();
session_regenerate_id(true);
// 変数の初期化
$current_date = null;
$message_array = array();
$error_message = array();
$authcode = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
try {
$option = array(
PDO::ATTR_ERRMODE => 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"] && $_SESSION['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_SESSION['userid']; // セッションに格納されている値をそのままセット
$username = $_SESSION['username']; // セッションに格納されている値をそのままセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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"] && $_COOKIE['userid'] === $res["userid"]){
// セッションに値をセット
$userid = $_COOKIE['userid']; // クッキーから取得した値をセット
$username = $_COOKIE['username']; // クッキーから取得した値をセット
$loginid = $res["loginid"];
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 14,
'path' => '/',
'samesite' => 'lax',
]);
}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');
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/home.css">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="apple-touch-icon" type="image/png" href="../favicon/apple-touch-icon-180x180.png">
<link rel="icon" type="image/png" href="../favicon/icon-192x192.png">
<title>設定 - <?php echo file_get_contents($servernamefile);?></title>
</head>
<body>
<?php require('../require/leftbox.php');?>
<main>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="formarea">
<h1>通報完了</h1>
<?php if( !empty($error_message) ): ?>
<ul class="errmsg">
<?php foreach( $error_message as $value ): ?>
<p>・ <?php echo $value; ?></p>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<p>通報しました!</p>
<a href="/home/" class="irobutton">戻る</a>
</div>
</main>
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
</body>
</html>
+60 -3
View File
@@ -2,8 +2,8 @@
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- ホスト: ひみつ♡()
-- 生成日時: 2023-09-02 18:20:50
-- ホスト: ひみつ
-- 生成日時: 2023-09-10 11:16:42
-- サーバのバージョン: 10.4.28-MariaDB
-- PHP のバージョン: 8.2.4
@@ -18,7 +18,7 @@ SET time_zone = "+00:00";
/*!40101 SET NAMES utf8mb4 */;
--
-- データベース: `nandemo`
-- データベース: `account`
--
-- --------------------------------------------------------
@@ -49,6 +49,23 @@ CREATE TABLE `account` (
-- --------------------------------------------------------
--
-- テーブルの構造 `ads`
--
CREATE TABLE `ads` (
`sysid` int(11) NOT NULL,
`uniqid` varchar(512) NOT NULL,
`url` varchar(512) NOT NULL,
`image_url` varchar(512) NOT NULL,
`memo` text NOT NULL,
`start_date` datetime NOT NULL,
`limit_date` datetime NOT NULL,
`datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- テーブルの構造 `emoji`
--
@@ -109,6 +126,22 @@ CREATE TABLE `notification` (
-- --------------------------------------------------------
--
-- テーブルの構造 `report`
--
CREATE TABLE `report` (
`sysid` int(11) NOT NULL,
`uniqid` varchar(256) NOT NULL,
`userid` varchar(500) NOT NULL,
`report_userid` varchar(500) NOT NULL,
`msg` text NOT NULL,
`datetime` datetime NOT NULL,
`admin_chk` varchar(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
--
-- テーブルの構造 `role`
--
@@ -153,6 +186,12 @@ CREATE TABLE `ueuse` (
ALTER TABLE `account`
ADD PRIMARY KEY (`sysid`);
--
-- テーブルのインデックス `ads`
--
ALTER TABLE `ads`
ADD PRIMARY KEY (`sysid`);
--
-- テーブルのインデックス `emoji`
--
@@ -177,6 +216,12 @@ ALTER TABLE `notice`
ALTER TABLE `notification`
ADD PRIMARY KEY (`sysid`);
--
-- テーブルのインデックス `report`
--
ALTER TABLE `report`
ADD PRIMARY KEY (`sysid`);
--
-- テーブルのインデックス `role`
--
@@ -199,6 +244,12 @@ ALTER TABLE `ueuse`
ALTER TABLE `account`
MODIFY `sysid` int(11) NOT NULL AUTO_INCREMENT;
--
-- テーブルの AUTO_INCREMENT `ads`
--
ALTER TABLE `ads`
MODIFY `sysid` int(11) NOT NULL AUTO_INCREMENT;
--
-- テーブルの AUTO_INCREMENT `emoji`
--
@@ -223,6 +274,12 @@ ALTER TABLE `notice`
ALTER TABLE `notification`
MODIFY `sysid` int(11) NOT NULL AUTO_INCREMENT;
--
-- テーブルの AUTO_INCREMENT `report`
--
ALTER TABLE `report`
MODIFY `sysid` int(11) NOT NULL AUTO_INCREMENT;
--
-- テーブルの AUTO_INCREMENT `role`
--