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

uwuzu version 1.2.11

This commit is contained in:
daichimarukana
2023-08-25 00:45:43 +09:00
parent 468536b4a8
commit 4ebbb1ca82
21 changed files with 586 additions and 466 deletions
+68 -1
View File
@@ -10,10 +10,37 @@ function createUniqId(){
return base_convert($hashCreateTime,10,36); return base_convert($hashCreateTime,10,36);
} }
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
$mentionedUsers = [];
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();
if (!empty($mention_userData)) {
$mentionedUsers[] = $mention_username;
}
}, $postText);
return $mentionedUsers;
}
if(isset($_GET['token'])&&isset($_GET['ueuse'])) { if(isset($_GET['token'])&&isset($_GET['ueuse'])) {
$token = htmlentities($_GET['token']); $token = htmlentities($_GET['token']);
$ueuse = htmlentities($_GET['ueuse']); $ueuse = nl2br(htmlentities($_GET['ueuse']));
require('../db.php'); require('../db.php');
@@ -89,6 +116,46 @@ if(isset($_GET['token'])&&isset($_GET['ueuse'])) {
// コミット // コミット
$res = $pdo->commit(); $res = $pdo->commit();
$mentionedUsers = get_mentions_userid($ueuse);
foreach ($mentionedUsers as $mentionedUser) {
$pdo->beginTransaction();
try {
$touserid = $mentionedUser;
$datetime = date("Y-m-d H:i:s");
$msg = "" . $ueuse . "";
$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(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
}
} catch(Exception $e) { } catch(Exception $e) {
// エラーが発生した時はロールバック // エラーが発生した時はロールバック
+2 -2
View File
@@ -67,7 +67,7 @@ try {
//-------------------------------------- //--------------------------------------
$userQuery = $dbh->prepare("SELECT username, userid, loginid, profile, role FROM account WHERE userid = :userid"); $userQuery = $dbh->prepare("SELECT username, userid, loginid, profile, role, iconname FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $userid); $userQuery->bindValue(':userid', $userid);
$userQuery->execute(); $userQuery->execute();
$userData = $userQuery->fetch(); $userData = $userQuery->fetch();
@@ -195,7 +195,7 @@ $pdo = null;
<?php endif; ?> <?php endif; ?>
<div class="myarea"> <div class="myarea">
<img src="image.php"> <img src="<?php echo htmlentities($userData['iconname']); ?>">
<p>名前</p> <p>名前</p>
<h2><?php if( !empty($row["username"]) ){ echo htmlentities( $row["username"], ENT_QUOTES, 'UTF-8'); } ?></h2> <h2><?php if( !empty($row["username"]) ){ echo htmlentities( $row["username"], ENT_QUOTES, 'UTF-8'); } ?></h2>
<div class="roleboxes"> <div class="roleboxes">
+93 -7
View File
@@ -389,14 +389,16 @@ body{
} }
.leftbutton .notipod{ .leftbutton .notipod{
width: 25px; width: auto;
height: 25px; height: 25px;
margin-left: auto; margin-left: auto;
margin-right: 20px; margin-right: 20px;
margin-top: auto; margin-top: auto;
margin-bottom: auto; margin-bottom: auto;
padding-left: 9px;
padding-right: 9px;
background-color: #FF4444; background-color: #FF4444;
border-radius: 50%; border-radius: 25px;
transition: all 250ms ease-out; transition: all 250ms ease-out;
} }
.leftbutton .notipod p{ .leftbutton .notipod p{
@@ -911,6 +913,29 @@ main h1{
font-weight: bold; font-weight: bold;
} }
.ueuse .mta{
line-height: 30px;
background-color: #FFFAE6;
padding: 6px;
border-radius: 25px;
margin-top: auto;
margin-bottom: auto;
margin-left: 3px;
margin-right: 3px;
font-size: 14px;
color:#FFC832;
text-decoration: none;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: bold;
transition: all 250ms ease-out;
}
.ueuse .mta:hover{
font-size: 14px;
background-color: #FFC832;
color:#FFFAE6;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
}
.ueuse a{ .ueuse a{
margin-top: auto; margin-top: auto;
margin-bottom: auto; margin-bottom: auto;
@@ -2680,13 +2705,15 @@ hr{
} }
.userheader .icon{ .userheader .icon{
margin-left: 24px; margin-left: 12px;
margin-right: 12px;
display: block; display: block;
width: auto; width: auto;
} }
.userheader .roleboxes{ .userheader .roleboxes{
margin-left: 24px; margin-left: 12px;
margin-right: 12px;
display: flex; display: flex;
padding: 0px; padding: 0px;
flex-wrap : wrap; flex-wrap : wrap;
@@ -2712,6 +2739,16 @@ hr{
flex-wrap : wrap; flex-wrap : wrap;
} }
.userheader .profile p{
margin-left: 12px;
margin-right: 12px;
}
.fzone{
margin-left: 12px;
margin-right: 12px;
}
main{ main{
height: 93.7dvh; height: 93.7dvh;
overflow: auto; overflow: auto;
@@ -2852,12 +2889,19 @@ hr{
border: none; border: none;
} }
.btmbutton:hover{ .btmbutton:hover{
background-color: #FFC832; background-color: #FFFFFF;
color: #FFFAE6; color: #FFC832;
box-shadow:none; box-shadow:none;
} }
.btmbutton:active{ .btmbutton:active svg{
box-shadow:none; box-shadow:none;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
fill: currentColor;
width: 4.7dvh;
height: 4.7dvh;
} }
svg { svg {
width: 5dvh; width: 5dvh;
@@ -2867,6 +2911,7 @@ hr{
margin-top: auto; margin-top: auto;
margin-bottom: auto; margin-bottom: auto;
fill: currentColor; fill: currentColor;
transition: all 250ms ease-out;
} }
@@ -3067,6 +3112,34 @@ hr{
border: 1px solid #EEE; border: 1px solid #EEE;
width: auto; width: auto;
} }
.ueuse .flebox{
display: flex;
flex-wrap: wrap;
}
.ueuse .flebox a {
flex-shrink: 0;
margin-top: auto;
margin-bottom: auto;
margin-left: 12px;
font-size: 18px;
color: #252525;
text-decoration: none;
font-family: 'BIZ UDPGothic', sans-serif;
font-weight: bold;
}
.ueuse .flebox .time{
margin-top: 6px;
margin-bottom: 6px;
margin-left: auto;
margin-right: 12px;
text-align: right;
font-size: 12px;
color:#999;
font-family: 'BIZ UDPGothic', sans-serif;
}
.leftbox{ .leftbox{
display: block; display: block;
@@ -3812,6 +3885,9 @@ hr{
.formarea p{ .formarea p{
color:#CCC; color:#CCC;
} }
.formarea li{
color:#CCC;
}
.modal-content { .modal-content {
@@ -3989,4 +4065,14 @@ hr{
.tokonone p{ .tokonone p{
color:#CCC; color:#CCC;
} }
.ueuse .mta{
background-color: #302c2c;
}
.ueuse .mta:hover{
font-size: 14px;
background-color: #FFC832;
color:#0c0c0c;
box-shadow:0 0px 48px 0 rgba(0, 0, 0, .2);
}
} }
+70
View File
@@ -116,6 +116,32 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
$notificationcount = $notiData['notification_count']; $notificationcount = $notiData['notification_count'];
//------------------------------------------- //-------------------------------------------
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
$mentionedUsers = [];
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();
if (!empty($mention_userData)) {
$mentionedUsers[] = $mention_username;
}
}, $postText);
return $mentionedUsers;
}
if( !empty($_POST['btn_submit']) ) { if( !empty($_POST['btn_submit']) ) {
@@ -279,6 +305,46 @@ if( !empty($_POST['btn_submit']) ) {
// コミット // コミット
$res = $pdo->commit(); $res = $pdo->commit();
$mentionedUsers = get_mentions_userid($ueuse);
foreach ($mentionedUsers as $mentionedUser) {
$pdo->beginTransaction();
try {
$touserid = $mentionedUser;
$datetime = date("Y-m-d H:i:s");
$msg = "" . $ueuse . "";
$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(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
}
} catch(Exception $e) { } catch(Exception $e) {
// エラーが発生した時はロールバック // エラーが発生した時はロールバック
@@ -619,6 +685,10 @@ $(document).ready(function() {
}); });
}); });
// 10秒後に実行
setTimeout(() => {
console.log("Execution 10sec"); // Execution 10sec
}, 10000);
}); });
-78
View File
@@ -1,78 +0,0 @@
<?php
require('../db.php');
// 変数の初期化
$current_date = null;
$message_array = array();
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
$row["userid"] = array();
$row["password"] = array();
$ruserid = array();
$rpassword = array();
$userid = null;
$_SESSION["userid"]="";
$password = null;
$_SESSION["password"]="";
session_start();
$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);
//$row['userid'] = "daichimarukn";
$userid = htmlentities($_GET['account']);
$options = array(
// SQL実行失敗時に例外をスルー
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
// デフォルトフェッチモードを連想配列形式に設定
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
// SELECTで得た結果に対してもrowCountメソッドを使えるようにする
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
);
if( empty($userid) ) {
$filePath = 'img/deficon/icon.png';
$data = file_get_contents($filePath);
header('Content-type: image/png');
//データを出力
echo $data;
exit();
}else{
$dbh = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
$result = $dbh->prepare("SELECT iconname, iconcontent, icontype, iconsize profile FROM account WHERE userid = :userid");
$result->bindValue(':userid', $userid);
// SQL実行
$result->execute();
$row = $result->fetch(); // ここでデータベースから取得した値を $row に代入する
header('Content-type: ' . $row['icontype']);
echo $row['iconcontent'];
exit();
}
-77
View File
@@ -1,77 +0,0 @@
<?php
require('db.php');
// 変数の初期化
$current_date = null;
$message_array = array();
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
$row["userid"] = array();
$row["password"] = array();
$ruserid = array();
$rpassword = array();
$userid = null;
$_SESSION["userid"]="";
$password = null;
$_SESSION["password"]="";
session_start();
$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);
//$row['userid'] = "daichimarukn";
$userid = $_SESSION['userid'];
$options = array(
// SQL実行失敗時に例外をスルー
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
// デフォルトフェッチモードを連想配列形式に設定
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
// SELECTで得た結果に対してもrowCountメソッドを使えるようにする
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
);
if( empty($userid) ) {
$filePath = 'img/deficon/icon.png';
$data = file_get_contents($filePath);
header('Content-type: image/png');
//データを出力
echo $data;
exit();
}else{
$dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
$result = $dbh->prepare("SELECT iconname, iconcontent, icontype, iconsize profile FROM account WHERE userid = :userid");
$result->bindValue(':userid', $userid);
// SQL実行
$result->execute();
$row = $result->fetch(); // ここでデータベースから取得した値を $row に代入する
header('Content-type: ' . $row['icontype']);
echo $row['iconcontent'];
exit();
}
-1
View File
@@ -19,7 +19,6 @@ if (isset($_SERVER['HTTP_COOKIE'])) {
setcookie($name, '', time()-1000, '/user'); setcookie($name, '', time()-1000, '/user');
} }
} }
session_destroy();
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
+94 -40
View File
@@ -124,27 +124,89 @@ if( !empty($_POST['btn_submit']) ) {
setcookie("profile",$profile,time()+60*60*24*14); setcookie("profile",$profile,time()+60*60*24*14);
if (!empty($_FILES['image']['name'])) { //----------------[icon image]-------------------------------
$img = $_FILES['image']; if (empty($_FILES['image']['name'])) {
}else{ $localFilePathhead = 'img/deficon/icon.png';
$localFilePath = 'img/deficon/icon.png';
$img = [ // 新しいファイル名を生成(uniqid + 拡張子)
'name' => 'deficon.png', $newFilename = uniqid() . '-'.$userid.'.png';
'type' => 'image/png', // 仮の Content-Type を指定(必要に応じて適切なものに変更してください)
'tmp_name' => $localFilePath, // 保存先のパスを生成
'error' => 0, $uploadedPath = 'usericons/' . $newFilename;
'size' => filesize($localFilePath)
]; // ファイルを移動
} $result = copy($localFilePathhead, $uploadedPath);
if ($result) {
$iconName = $uploadedPath; // 保存されたファイルのパスを使用
} else {
$errnum = $uploadedFile['error'];
if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";}
if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";}
if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";}
if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";}
if($errnum === 6){$errcode = "TMP_FOLDER_NAI";}
if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";}
if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";}
$error_message[] = 'アップロード失敗!(1)エラーコード:' .$uploadedFile['error'].'';
}
} else {
// アップロードされたファイル情報
$uploadedFile = $_FILES['image'];
// アップロードされたファイルの拡張子を取得
$extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION);
// 新しいファイル名を生成(uniqid + 拡張子)
$newFilename = uniqid() . '-'.$userid.'.' . $extension;
// 保存先のパスを生成
$uploadedPath = 'usericons/' . $newFilename;
// ファイルを移動
$result = move_uploaded_file($uploadedFile['tmp_name'], $uploadedPath);
if ($result) {
$iconName = $uploadedPath; // 保存されたファイルのパスを使用
} else {
$errnum = $uploadedFile['error'];
if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";}
if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";}
if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";}
if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";}
if($errnum === 6){$errcode = "TMP_FOLDER_NAI";}
if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";}
if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";}
$error_message[] = 'アップロード失敗!(1)エラーコード:' .$uploadedFile['error'].'';
}
}
//----------------[header image]-------------------------------
$localFilePathhead = 'img/defhead/head.png'; $localFilePathhead = 'img/defhead/head.png';
$headimg = [
'name' => 'defhead.png', // 新しいファイル名を生成(uniqid + 拡張子)
'type' => 'image/png', // 仮の Content-Type を指定(必要に応じて適切なものに変更してください) $newFilename = uniqid() . '-'.$userid.'.png';
'tmp_name' => $localFilePathhead,
'error' => 0, // 保存先のパスを生成
'size' => filesize($localFilePathhead) $uploadedPath = 'userheads/' . $newFilename;
];
// ファイルを移動
$result = copy($localFilePathhead, $uploadedPath);
if ($result) {
$headName = $uploadedPath; // 保存されたファイルのパスを使用
} else {
$errnum = $uploadedFile['error'];
if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";}
if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";}
if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";}
if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";}
if($errnum === 6){$errcode = "TMP_FOLDER_NAI";}
if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";}
if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";}
$error_message[] = 'アップロード失敗!(2)エラーコード:' .$uploadedFile['error'].'';
}
@@ -213,6 +275,15 @@ if( !empty($_POST['btn_submit']) ) {
if($userid === 'uwuzu_official'){ if($userid === 'uwuzu_official'){
$error_message[] = 'そのIDは登録禁止になっています。'; $error_message[] = 'そのIDは登録禁止になっています。';
} }
if($userid === 'uwuzu'){
$error_message[] = 'そのIDは登録禁止になっています。';
}
if($userid === 'admin'){
$error_message[] = 'そのIDは登録禁止になっています。';
}
if($userid === 'root'){
$error_message[] = 'そのIDは登録禁止になっています。';
}
if($result > 0){ if($result > 0){
$error_message[] = 'このID('.$userid.')は既に使用されています。他のIDを作成してください。'; //このE-mailは既に使用されています。 $error_message[] = 'このID('.$userid.')は既に使用されています。他のIDを作成してください。'; //このE-mailは既に使用されています。
@@ -329,30 +400,13 @@ if( !empty($_POST['btn_submit']) ) {
$loginid = sha1(uniqid(mt_rand(), true)); $loginid = sha1(uniqid(mt_rand(), true));
// SQL作成 // SQL作成
$stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, iconcontent, icontype, iconsize, headname, headcontent, headtype, headsize, role, datetime, admin) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :iconcontent, :icontype, :iconsize, :headname, :headcontent, :headtype, :headsize, :role, :datetime, :admin )"); $stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, headname, role, datetime, admin) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :headname, :role, :datetime, :admin )");
$iconName = $img['name']; // アイコン画像
$iconType = $img['type'];
$iconContent = file_get_contents($img['tmp_name']);
$iconSize = $img['size'];
// アイコン画像のバインド
$stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR); $stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR);
$stmt->bindValue(':icontype', $iconType, PDO::PARAM_STR);
$stmt->bindValue(':iconcontent', $iconContent, PDO::PARAM_STR);
$stmt->bindValue(':iconsize', $iconSize, PDO::PARAM_INT);
// ヘッダー画像関連の処理 // ヘッダー画像
$headName = $headimg['name'];
$headType = $headimg['type'];
$headContent = file_get_contents($headimg['tmp_name']);
$headSize = $headimg['size'];
// ヘッダー画像のバインド
$stmt->bindValue(':headname', $headName, PDO::PARAM_STR); $stmt->bindValue(':headname', $headName, PDO::PARAM_STR);
$stmt->bindValue(':headtype', $headType, PDO::PARAM_STR);
$stmt->bindValue(':headcontent', $headContent, PDO::PARAM_STR);
$stmt->bindValue(':headsize', $headSize, PDO::PARAM_INT);
// 他の値をセット // 他の値をセット
$stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':username', $username, PDO::PARAM_STR);
@@ -456,7 +510,7 @@ $pdo = null;
<div id="wrap"> <div id="wrap">
<div class="iconimg"> <div class="iconimg">
<img src="image.php"> <img src="img/deficon/icon.png">
</div> </div>
<label class="irobutton" for="file_upload">ファイル選択 <label class="irobutton" for="file_upload">ファイル選択
<input type="file" id="file_upload" name="image" accept="image/*"> <input type="file" id="file_upload" name="image" accept="image/*">
+3 -35
View File
@@ -34,40 +34,6 @@ $offset = ($pageNumber - 1) * $itemsPerPage;
$messages = array(); $messages = array();
if (!empty($pdo)) { if (!empty($pdo)) {
// ユーズ内の絵文字を画像に置き換える
function replaceEmojisWithImages($postText) {
// ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
$pattern = '/:(\w+):/';
$postTextWithImages = preg_replace_callback($pattern, function($matches) {
$emojiName = $matches[1];
return "<img src='../emoji/emojiimage.php?emoji=" . urlencode($emojiName) . "' alt='$emojiName'>";
}, $postText);
return $postTextWithImages;
}
function replaceURLsWithLinks($postText) {
// URLを正規表現を使って検出
$pattern = '/(https?:\/\/[^\s]+)/';
preg_match_all($pattern, $postText, $matches);
// 検出したURLごとに処理を行う
foreach ($matches[0] as $url) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
$domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
// ドメインのみを表示するaタグを生成
$link = "<a href='$url' target='_blank'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
$sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT $offset, $itemsPerPage"; $sql = "SELECT account, username, uniqid, rpuniqid, ueuse, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE rpuniqid = '' ORDER BY datetime DESC LIMIT $offset, $itemsPerPage";
$message_array = $pdo->query($sql); $message_array = $pdo->query($sql);
@@ -79,12 +45,14 @@ if (!empty($pdo)) {
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
foreach ($messages as &$message) { foreach ($messages as &$message) {
$userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $message["account"]); $userQuery->bindValue(':userid', $message["account"]);
$userQuery->execute(); $userQuery->execute();
$userData = $userQuery->fetch(); $userData = $userQuery->fetch();
if ($userData) { if ($userData) {
$message['iconname'] = $userData['iconname'];
$message['headname'] = $userData['headname'];
$message['username'] = $userData['username']; $message['username'] = $userData['username'];
$message['role'] = $userData['role']; $message['role'] = $userData['role'];
} }
+5 -38
View File
@@ -43,56 +43,23 @@ if (!empty($pdo)) {
$messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR); $messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR);
$messageQuery->execute(); $messageQuery->execute();
$message_array = $messageQuery->fetchAll(); $message_array = $messageQuery->fetchAll();
// ユーズ内の絵文字を画像に置き換える
function replaceEmojisWithImages($postText) {
// ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
$pattern = '/:(\w+):/';
$postTextWithImages = preg_replace_callback($pattern, function($matches) {
$emojiName = $matches[1];
return "<img src='../emoji/emojiimage.php?emoji=" . urlencode($emojiName) . "' alt='$emojiName'>";
}, $postText);
return $postTextWithImages;
}
function replaceURLsWithLinks($postText) {
// URLを正規表現を使って検出
$pattern = '/(https?:\/\/[^\s]+)/';
preg_match_all($pattern, $postText, $matches);
// 検出したURLごとに処理を行う
foreach ($matches[0] as $url) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
$domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
// ドメインのみを表示するaタグを生成
$link = "<a href='$url' target='_blank'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
$messages = array(); $messages = array();
foreach ($message_array as $row) { foreach ($message_array as $row) {
$messages[] = $row; $messages[] = $row;
} }
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
foreach ($messages as &$message) { foreach ($messages as &$message) {
$userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $message["account"]); $userQuery->bindValue(':userid', $message["account"]);
$userQuery->execute(); $userQuery->execute();
$userData = $userQuery->fetch(); $userData = $userQuery->fetch();
if ($userData) { if ($userData) {
$message['iconname'] = $userData['iconname'];
$message['headname'] = $userData['headname'];
$message['username'] = $userData['username']; $message['username'] = $userData['username'];
$message['role'] = $userData['role']; $message['role'] = $userData['role'];
} }
} }
+3 -33
View File
@@ -45,38 +45,6 @@ if (!empty($pdo)) {
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
)); ));
// 投稿内の絵文字を画像に置き換える
function replaceEmojisWithImages($postText) {
// 投稿内で絵文字名(:emoji:)を検出して画像に置き換える
$pattern = '/:(\w+):/';
$postTextWithImages = preg_replace_callback($pattern, function($matches) {
$emojiName = $matches[1];
return "<img src='../emoji/emojiimage.php?emoji=" . urlencode($emojiName) . "' alt='$emojiName'>";
}, $postText);
return $postTextWithImages;
}
function replaceURLsWithLinks($postText) {
// URLを正規表現を使って検出
$pattern = '/(https?:\/\/[^\s]+)/';
preg_match_all($pattern, $postText, $matches);
// 検出したURLごとに処理を行う
foreach ($matches[0] as $url) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
$domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
// ドメインのみを表示するaタグを生成
$link = "<a href='$url' target='_blank'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
// 投稿内容の取得(新しい順に取得) // 投稿内容の取得(新しい順に取得)
$messageQuery = $dbh->prepare("SELECT account, username, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT $offset, $itemsPerPage"); $messageQuery = $dbh->prepare("SELECT account, username, ueuse, uniqid, rpuniqid, datetime, photo1, photo2, video1, favorite, abi, abidate FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT $offset, $itemsPerPage");
$messageQuery->bindValue(':ueuseid', $ueuseid); $messageQuery->bindValue(':ueuseid', $ueuseid);
@@ -93,12 +61,14 @@ if (!empty($pdo)) {
} }
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
foreach ($messages as &$message) { foreach ($messages as &$message) {
$userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $message["account"]); $userQuery->bindValue(':userid', $message["account"]);
$userQuery->execute(); $userQuery->execute();
$userData = $userQuery->fetch(); $userData = $userQuery->fetch();
if ($userData) { if ($userData) {
$message['iconname'] = $userData['iconname'];
$message['headname'] = $userData['headname'];
$message['username'] = $userData['username']; $message['username'] = $userData['username'];
$message['role'] = $userData['role']; $message['role'] = $userData['role'];
} }
+3 -34
View File
@@ -53,51 +53,20 @@ if (!empty($pdo)) {
$messageQuery->execute(); $messageQuery->execute();
$message_array = $messageQuery->fetchAll(); $message_array = $messageQuery->fetchAll();
// ユーズ内の絵文字を画像に置き換える
function replaceEmojisWithImages($postText) {
// ユーズ内で絵文字名(:emoji:)を検出して画像に置き換える
$pattern = '/:(\w+):/';
$postTextWithImages = preg_replace_callback($pattern, function($matches) {
$emojiName = $matches[1];
return "<img src='../emoji/emojiimage.php?emoji=" . urlencode($emojiName) . "' alt='$emojiName'>";
}, $postText);
return $postTextWithImages;
}
function replaceURLsWithLinks($postText) {
// URLを正規表現を使って検出
$pattern = '/(https?:\/\/[^\s]+)/';
preg_match_all($pattern, $postText, $matches);
// 検出したURLごとに処理を行う
foreach ($matches[0] as $url) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
$domain = isset($parsedUrl['host']) ? $parsedUrl['host'] : '';
// ドメインのみを表示するaタグを生成
$link = "<a href='$url' target='_blank'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
$messages = array(); $messages = array();
foreach ($message_array as $row) { foreach ($message_array as $row) {
$messages[] = $row; $messages[] = $row;
} }
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
foreach ($messages as &$message) { foreach ($messages as &$message) {
$userQuery = $pdo->prepare("SELECT username, userid, profile, role FROM account WHERE userid = :userid"); $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $message["account"]); $userQuery->bindValue(':userid', $message["account"]);
$userQuery->execute(); $userQuery->execute();
$userData = $userQuery->fetch(); $userData = $userQuery->fetch();
if ($userData) { if ($userData) {
$message['iconname'] = $userData['iconname'];
$message['headname'] = $userData['headname'];
$message['username'] = $userData['username']; $message['username'] = $userData['username'];
$message['role'] = $userData['role']; $message['role'] = $userData['role'];
} }
+79 -2
View File
@@ -1,5 +1,81 @@
<?php <?php
function processMarkdownAndWrapEmptyLines($markdownText) {
// コード(#code)をHTMLのdiv class="code"タグに変換
$markdownText = preg_replace('/^#code (.+)/m', '<div class="code"><p>$1</p></div>', $markdownText);
// タイトル(#、##、###)をHTMLのhタグに変換
$markdownText = preg_replace('/^# (.+)/m', '<h1>$1</h1>', $markdownText);
$markdownText = preg_replace('/^## (.+)/m', '<h2>$1</h2>', $markdownText);
$markdownText = preg_replace('/^### (.+)/m', '<h3>$1</h3>', $markdownText);
// 箇条書き(-)をHTMLのul/liタグに変換
$markdownText = preg_replace('/^- (.+)/m', '<ul><li>$1</li></ul>', $markdownText);
// 空行の前に何もない行をHTMLのpタグに変換
$markdownText = preg_replace('/(^\s*)(?!\s)(.*)/m', '$1<p>$2</p>', $markdownText);
return $markdownText;
}
// ユーズ内の絵文字を画像に置き換える
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'>";
}, $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);
return $postTextWithImagesAndUsernames;
}
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' target='_blank'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = str_replace($url, $link, $postText);
}
return $postText;
}
class MessageDisplay { class MessageDisplay {
private $value; private $value;
private $userid; private $userid;
@@ -10,6 +86,7 @@ class MessageDisplay {
} }
public function display() { public function display() {
if (empty($this->value)) { if (empty($this->value)) {
echo '<div class="tokonone" id="noueuse"><p>ユーズがありません</p></div>'; echo '<div class="tokonone" id="noueuse"><p>ユーズがありません</p></div>';
} else { } else {
@@ -19,7 +96,7 @@ class MessageDisplay {
} }
echo ' <div class="flebox">'; echo ' <div class="flebox">';
echo ' <a href="/@' . htmlentities($this->value['account']) . '"><img src="../home/tlimage.php?account=' . urlencode($this->value['account']) . '"></a>'; echo ' <a href="/@' . htmlentities($this->value['account']) . '"><img src="'. htmlentities('../'.$this->value['iconname']) . '"></a>';
echo ' <a href="/@' . htmlentities($this->value['account']) . '">' . htmlentities($this->value['username']) . '</a>'; echo ' <a href="/@' . htmlentities($this->value['account']) . '">' . htmlentities($this->value['username']) . '</a>';
echo ' <div class="idbox">'; echo ' <div class="idbox">';
echo ' <a href="/@' . htmlentities($this->value['account']) . '">@' . htmlentities($this->value['account']) . '</a>'; echo ' <a href="/@' . htmlentities($this->value['account']) . '">@' . htmlentities($this->value['account']) . '</a>';
@@ -42,7 +119,7 @@ class MessageDisplay {
echo ' </div>'; echo ' </div>';
echo ' <p>' . replaceEmojisWithImages(replaceURLsWithLinks(nl2br($this->value['ueuse']))) . '</h1></h2></h3></font></center></p>'; echo ' <p>' . processMarkdownAndWrapEmptyLines(replaceEmojisWithImages(replaceURLsWithLinks(nl2br($this->value['ueuse'])))) . '</h1></h2></h3></font></center></p>';
if (!empty($this->value['photo2']) && $this->value['photo2'] !== 'none') { if (!empty($this->value['photo2']) && $this->value['photo2'] !== 'none') {
echo ' <div class="photo2">'; echo ' <div class="photo2">';
+24 -3
View File
@@ -177,6 +177,30 @@ if( !empty($_POST['btn_submit']) ) {
unlink($file2); // ファイルを削除 unlink($file2); // ファイルを削除
} }
} }
$folderPath3 = "../usericons/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete3 = glob($folderPath3 . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete3 as $file3) {
if (is_file($file3)) {
unlink($file3); // ファイルを削除
}
}
$folderPath4 = "../userheads/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete4 = glob($folderPath4 . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete4 as $file4) {
if (is_file($file4)) {
unlink($file4); // ファイルを削除
}
}
try { try {
@@ -422,9 +446,6 @@ require('../logout/logout.php');
<p>https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数]&page=[ページ切り替え]</p> <p>https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数]&page=[ページ切り替え]</p>
<p>これにより投稿内容(ueuse)と、ユーザーネーム(user_name)、ユーザーID(userid)、投稿ID(uniqid)、写真・動画URL(photo1,photo2,video1)、いいねした人一覧(favorite)、いいね数(favorite_cnt)、投稿日時(datetime)、追記内容(abi)、追記日時(abidatetime)が取得できます。<br>page=は指定しなくても動作します。(https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数])</p> <p>これにより投稿内容(ueuse)と、ユーザーネーム(user_name)、ユーザーID(userid)、投稿ID(uniqid)、写真・動画URL(photo1,photo2,video1)、いいねした人一覧(favorite)、いいね数(favorite_cnt)、投稿日時(datetime)、追記内容(abi)、追記日時(abidatetime)が取得できます。<br>page=は指定しなくても動作します。(https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数])</p>
<hr> <hr>
<li>ローカルタイムライン投稿取得API</li>
<p>https://[ドメイン名(uwuzu.netなど)]/api/ltl-api?limit=[取得件数]&page=[ページ切り替え]</p>
<hr>
<li>投稿API</li> <li>投稿API</li>
<p>https://[ドメイン名(uwuzu.netなど)]/api/bot-api?token=[アクセストークン]&ueuse=[投稿の内容]</p> <p>https://[ドメイン名(uwuzu.netなど)]/api/bot-api?token=[アクセストークン]&ueuse=[投稿の内容]</p>
+3 -9
View File
@@ -25,7 +25,7 @@ daichimarukana < 「うぃずゆー(With you)」「うぃじゅー(witzou)」「
## 4. 開発言語は? ## 4. 開発言語は?
uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作られています! uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作られています!
ライブラリはjQueryを導入しています! ライブラリはjQuery、Reactを導入しています!
## 5. サーバーの建て方 ## 5. サーバーの建て方
※MySQLの設定結構めんどいです。 ※MySQLの設定結構めんどいです。
@@ -42,14 +42,8 @@ uwuzuはPHPとJS、HTML(プログラミング言語じゃないか)、CSSで作
- loginid(varchar(256)) 自動ログイン時に本人アカウントか確認 - loginid(varchar(256)) 自動ログイン時に本人アカウントか確認
- mailadds(varchar(500)) メールアドレス保存用 - mailadds(varchar(500)) メールアドレス保存用
- profile(TEXT) プロフィールテキスト保存用 - profile(TEXT) プロフィールテキスト保存用
- iconname(varchar(256)) アイコン画像保存用 - iconname(varchar(256)) アイコン画像リンク保存用
- iconcontent(mediumblob) アイコン画像保存用 - headname(varchar(256)) ヘッダー画像リンク保存用
- icontype(varchar(256)) アイコン画像拡張子保存用
- iconsize(INT) アイコン画像サイズ保存用
- headname(varchar(256)) ヘッダー画像名保存用
- headcontent(mediumblob) ヘッダー画像保存用
- headtype(varchar(256)) ヘッダー画像拡張子保存用
- headsize(INT) ヘッダー画像サイズ保存用
- role(varchar(1024)) 「user」のようなロール保存用 - role(varchar(1024)) 「user」のようなロール保存用
- datetime(datetime) アカウント作成日時保存用 - datetime(datetime) アカウント作成日時保存用
- follow(text) アカウントがフォローしている人保存用 - follow(text) アカウントがフォローしている人保存用
+2 -2
View File
@@ -1,4 +1,4 @@
uwuzu uwuzu
1.2.10 1.2.11
2023/08/23 2023/08/25
daichimarukana,putonfps daichimarukana,putonfps
+8
View File
@@ -1,6 +1,14 @@
## リリースノートだぜぇぇぇぇぇぇい!!!!!!! ## リリースノートだぜぇぇぇぇぇぇい!!!!!!!
ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...) ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...)
## Version 1.2.11
リリース日:2023/08/25
モバイル向けUIを変更しました。
Markdown記法に一部対応しました。
メンション機能を追加しました。
アイコン・ヘッダーのファイルの保存形式を変更することにより動作を軽くしました!
※アイコン・ヘッダーはアカウント削除まで内部保存が次々されていきます。上書きはされません。
## Version 1.2.10 ## Version 1.2.10
リリース日:2023/08/23 リリース日:2023/08/23
モバイル向けUIを変更しました。 モバイル向けUIを変更しました。
+60 -23
View File
@@ -410,7 +410,34 @@ if( !empty($_POST['logout']) ) {
if( !empty($_POST['img1btn_submit']) ) { if( !empty($_POST['img1btn_submit']) ) {
if (!empty($_FILES['image2s']['name'])) { if (!empty($_FILES['image2s']['name'])) {
$headimg = $_FILES['image2s']; // アップロードされたファイル情報
$uploadedFile = $_FILES['image2s'];
// アップロードされたファイルの拡張子を取得
$extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION);
// 新しいファイル名を生成(uniqid + 拡張子)
$newFilename = uniqid() . '-'.$userid.'.' . $extension;
// 保存先のパスを生成
$uploadedPath = 'userheads/' . $newFilename;
// ファイルを移動
$result = move_uploaded_file($uploadedFile['tmp_name'], '../'.$uploadedPath);
if ($result) {
$headName = $uploadedPath; // 保存されたファイルのパスを使用
} else {
$errnum = $uploadedFile['error'];
if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";}
if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";}
if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";}
if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";}
if($errnum === 6){$errcode = "TMP_FOLDER_NAI";}
if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";}
if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";}
$error_message[] = 'アップロード失敗!(2)エラーコード:' .$errcode.'';
}
}else{ }else{
$error_message[] = 'ヘッダー画像を選択してください'; $error_message[] = 'ヘッダー画像を選択してください';
} }
@@ -444,19 +471,10 @@ if( !empty($_POST['img1btn_submit']) ) {
try { try {
// SQL作成 // SQL作成
$stmt = $pdo->prepare("UPDATE account SET headname = :headname, headtype = :headtype, headcontent = :headcontent, headsize = :headsize WHERE userid = :userid"); $stmt = $pdo->prepare("UPDATE account SET headname = :headname WHERE userid = :userid");
// ヘッダー画像関連の処理
$headName = $headimg['name'];
$headType = $headimg['type'];
$headContent = file_get_contents($headimg['tmp_name']);
$headSize = $headimg['size'];
// ヘッダー画像のバインド // ヘッダー画像のバインド
$stmt->bindValue(':headname', $headName, PDO::PARAM_STR); $stmt->bindValue(':headname', $headName, PDO::PARAM_STR);
$stmt->bindValue(':headtype', $headType, PDO::PARAM_STR);
$stmt->bindValue(':headcontent', $headContent, PDO::PARAM_STR);
$stmt->bindValue(':headsize', $headSize, PDO::PARAM_INT);
// ユーザーIDのバインド(WHERE句に必要) // ユーザーIDのバインド(WHERE句に必要)
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR); $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
@@ -491,7 +509,34 @@ if( !empty($_POST['img1btn_submit']) ) {
if( !empty($_POST['img2btn_submit']) ) { if( !empty($_POST['img2btn_submit']) ) {
if (!empty($_FILES['image']['name'])) { if (!empty($_FILES['image']['name'])) {
$img = $_FILES['image']; // アップロードされたファイル情報
$uploadedFile = $_FILES['image'];
// アップロードされたファイルの拡張子を取得
$extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION);
// 新しいファイル名を生成(uniqid + 拡張子)
$newFilename = uniqid() . '-'.$userid.'.' . $extension;
// 保存先のパスを生成
$uploadedPath = 'usericons/' . $newFilename;
// ファイルを移動
$result = move_uploaded_file($uploadedFile['tmp_name'], '../'.$uploadedPath);
if ($result) {
$iconName = $uploadedPath; // 保存されたファイルのパスを使用
} else {
$errnum = $uploadedFile['error'];
if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";}
if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";}
if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";}
if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";}
if($errnum === 6){$errcode = "TMP_FOLDER_NAI";}
if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";}
if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";}
$error_message[] = 'アップロード失敗!(2)エラーコード:' .$errcode.'';
}
}else{ }else{
$error_message[] = 'アイコン画像を選択してください'; $error_message[] = 'アイコン画像を選択してください';
} }
@@ -526,18 +571,10 @@ if( !empty($_POST['img2btn_submit']) ) {
try { try {
// SQL作成 // SQL作成
$stmt = $pdo->prepare("UPDATE account SET iconname = :iconname, icontype = :icontype, iconcontent = :iconcontent, iconsize = :iconsize WHERE userid = :userid"); $stmt = $pdo->prepare("UPDATE account SET iconname = :iconname WHERE userid = :userid");
$iconName = $img['name'];
$iconType = $img['type'];
$iconContent = file_get_contents($img['tmp_name']);
$iconSize = $img['size'];
// アイコン画像のバインド // アイコン画像のバインド
$stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR); $stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR);
$stmt->bindValue(':icontype', $iconType, PDO::PARAM_STR);
$stmt->bindValue(':iconcontent', $iconContent, PDO::PARAM_STR);
$stmt->bindValue(':iconsize', $iconSize, PDO::PARAM_INT);
// ユーザーIDのバインド(WHERE句に必要) // ユーザーIDのバインド(WHERE句に必要)
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR); $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
@@ -654,11 +691,11 @@ $pdo = null;
<form class="formarea" enctype="multipart/form-data" method="post"> <form class="formarea" enctype="multipart/form-data" method="post">
<div class="hed"> <div class="hed">
<img src="../user/headimage.php?account=<?php echo urlencode($userdata['userid']); ?>"> <img src="<?php echo htmlentities('../'.$userdata['headname']); ?>">
</div> </div>
<div class="iconimg"> <div class="iconimg">
<img src="../image.php"> <img src="<?php echo htmlentities('../'.$userdata['iconname']); ?>">
</div> </div>
<label class="imgbtn" for="file_upload">アイコン選択 <label class="imgbtn" for="file_upload">アイコン選択
<input type="file" id="file_upload" name="image" accept="image/*"> <input type="file" id="file_upload" name="image" accept="image/*">
+66
View File
@@ -123,6 +123,32 @@ $ueuseid = htmlentities(str_replace('!', '', $_GET['ueuseid']));
$touserid = htmlentities(str_replace('~', '', $_GET['touser'])); $touserid = htmlentities(str_replace('~', '', $_GET['touser']));
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
$mentionedUsers = [];
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();
if (!empty($mention_userData)) {
$mentionedUsers[] = $mention_username;
}
}, $postText);
return $mentionedUsers;
}
if( !empty($_POST['btn_submit']) ) { if( !empty($_POST['btn_submit']) ) {
@@ -311,6 +337,46 @@ if( !empty($_POST['btn_submit']) ) {
// コミット // コミット
$res = $pdo->commit(); $res = $pdo->commit();
$mentionedUsers = get_mentions_userid($ueuse);
foreach ($mentionedUsers as $mentionedUser) {
$pdo->beginTransaction();
try {
$touserid = $mentionedUser;
$datetime = date("Y-m-d H:i:s");
$msg = "" . $ueuse . "";
$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(':datetime', $datetime, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch(Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
}
} catch(Exception $e) { } catch(Exception $e) {
// エラーが発生した時はロールバック // エラーが発生した時はロールバック
-78
View File
@@ -1,78 +0,0 @@
<?php
require('../db.php');
// 変数の初期化
$current_date = null;
$message_array = array();
$error_message = array();
$pdo = null;
$stmt = null;
$res = null;
$option = null;
$row["userid"] = array();
$row["password"] = array();
$ruserid = array();
$rpassword = array();
$userid = null;
$_SESSION["userid"]="";
$password = null;
$_SESSION["password"]="";
session_start();
$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);
//$row['userid'] = "daichimarukn";
$userid = htmlentities($_GET['account']);
$options = array(
// SQL実行失敗時に例外をスルー
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
// デフォルトフェッチモードを連想配列形式に設定
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
// バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
// SELECTで得た結果に対してもrowCountメソッドを使えるようにする
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
);
if( empty($userid) ) {
$filePath = 'img/deficon/icon.png';
$data = file_get_contents($filePath);
header('Content-type: image/png');
//データを出力
echo $data;
exit();
}else{
$dbh = new PDO('mysql:charset=UTF8;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
$result = $dbh->prepare("SELECT headname, headcontent, headtype, headsize profile FROM account WHERE userid = :userid");
$result->bindValue(':userid', $userid);
// SQL実行
$result->execute();
$row = $result->fetch(); // ここでデータベースから取得した値を $row に代入する
header('Content-type: ' . $row['headtype']);
echo $row['headcontent'];
exit();
}
+3 -3
View File
@@ -179,7 +179,7 @@ if( !empty($pdo) ) {
$roles = explode(',', $userData["role"]); // カンマで区切られたロールを配列に分割 $roles = explode(',', $userData["role"]); // カンマで区切られたロールを配列に分割
$rerole = $dbh->prepare("SELECT follow, follower, username, userid, password, mailadds, profile, iconname, iconcontent, icontype, iconsize, headname, headcontent, headtype, headsize, role, datetime FROM account WHERE userid = :userid"); $rerole = $dbh->prepare("SELECT follow, follower, username, userid, password, mailadds, profile, iconname, headname, role, datetime FROM account WHERE userid = :userid");
$rerole->bindValue(':userid', $uwuzuid); $rerole->bindValue(':userid', $uwuzuid);
// SQL実行 // SQL実行
@@ -330,10 +330,10 @@ $pdo = null;
<div class="tokonone" id="noueuse"><p>このユーザーは存在しません</p></div> <div class="tokonone" id="noueuse"><p>このユーザーは存在しません</p></div>
<?php }else{?> <?php }else{?>
<div class="hed"> <div class="hed">
<img src="../user/headimage.php?account=<?php echo urlencode($userData['userid']); ?>"> <img src="<?php echo htmlentities('../'.$userdata['headname']); ?>">
</div> </div>
<div class="icon"> <div class="icon">
<img src="../home/tlimage.php?account=<?php echo urlencode($userData['userid']); ?>"> <img src="<?php echo htmlentities('../'.$userdata['iconname']); ?>">
<h2><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?></h2> <h2><?php echo htmlentities($userData['username'], ENT_QUOTES, 'UTF-8'); ?></h2>
<p>@<?php echo htmlentities($userData['userid'], ENT_QUOTES, 'UTF-8'); ?></p> <p>@<?php echo htmlentities($userData['userid'], ENT_QUOTES, 'UTF-8'); ?></p>
</div> </div>