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

uwuzu v1.3.0 new_planet

This commit is contained in:
Daichimarukana
2024-02-24 19:17:08 +09:00
parent 29c46fcc4e
commit 1597041471
115 changed files with 5655 additions and 2252 deletions
+49 -37
View File
@@ -11,7 +11,9 @@ $banurl = preg_split("/\r\n|\n|\r/", $banurl_info);
//投稿及び返信レート制限↓(分):デフォで60件/分まで
$max_ueuse_rate_limit = 60;
header("Content-Type: application/json; charset=utf-8; Access-Control-Allow-Origin: *;");
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
function createUniqId(){
list($msec, $sec) = explode(" ", microtime());
@@ -21,7 +23,13 @@ function createUniqId(){
return base_convert($hashCreateTime,10,36);
}
function decode_yajirushi($postText){
$postText = str_replace('←', '←', $postText);
$postText = str_replace('↓', '↓', $postText);
$postText = str_replace('↑', '↑', $postText);
$postText = str_replace('→', '→', $postText);
return $postText;
}
function get_mentions_userid($postText) {
// @useridを検出する
$usernamePattern = '/@(\w+)/';
@@ -77,14 +85,16 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
}
// 禁止url確認
for($i = 0; $i < count($banurl); $i++) {
if (false !== strpos($ueuse, 'https://'.$banurl[$i])) {
$err = "contains_prohibited_url";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
exit;
if(!($banurl[$i] == "")){
if (false !== strpos($ueuse, 'https://'.$banurl[$i])) {
$err = "contains_prohibited_url";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
exit;
}
}
}
}
@@ -201,7 +211,7 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
// コミット
$res = $pdo->commit();
$mentionedUsers = get_mentions_userid($ueuse);
$mentionedUsers = array_unique(get_mentions_userid($ueuse));
foreach ($mentionedUsers as $mentionedUser) {
@@ -266,7 +276,7 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
// プリペアドステートメントを削除
$stmt = null;
}else{
$err = "over_rate_limit ";
$err = "over_rate_limit";
$response = array(
'error_code' => $err,
);
@@ -309,14 +319,16 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
}
// 禁止url確認
for($i = 0; $i < count($banurl); $i++) {
if (false !== strpos($ueuse, 'https://'.$banurl[$i])) {
$err = "contains_prohibited_url";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
exit;
if(!($banurl[$i] == "")){
if (false !== strpos($ueuse, 'https://'.$banurl[$i])) {
$err = "contains_prohibited_url";
$response = array(
'error_code' => $err,
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
exit;
}
}
}
}
@@ -472,7 +484,7 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
// コミット
$res = $pdo->commit();
$mentionedUsers = get_mentions_userid($ueuse);
$mentionedUsers = array_unique(get_mentions_userid($ueuse));
foreach ($mentionedUsers as $mentionedUser) {
@@ -490,13 +502,13 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
$stmt->bindParam(':touserid', htmlentities($touserid), PDO::PARAM_STR);
$stmt->bindParam(':msg', htmlentities($msg), PDO::PARAM_STR);
$stmt->bindParam(':url', htmlentities($url), PDO::PARAM_STR);
$stmt->bindParam(':userchk', htmlentities($userchk), PDO::PARAM_STR);
$stmt->bindParam(':title', htmlentities($title), PDO::PARAM_STR);
$stmt->bindParam(':touserid', decode_yajirushi(htmlspecialchars_decode($touserid), PDO::PARAM_STR));
$stmt->bindParam(':msg', decode_yajirushi(htmlspecialchars_decode($msg), PDO::PARAM_STR));
$stmt->bindParam(':url', decode_yajirushi(htmlspecialchars_decode($url), PDO::PARAM_STR));
$stmt->bindParam(':userchk', decode_yajirushi(htmlspecialchars_decode($userchk), PDO::PARAM_STR));
$stmt->bindParam(':title', decode_yajirushi(htmlspecialchars_decode($title), PDO::PARAM_STR));
$stmt->bindParam(':datetime', htmlentities($datetime), PDO::PARAM_STR);
$stmt->bindParam(':datetime', decode_yajirushi(htmlspecialchars_decode($datetime), PDO::PARAM_STR));
// SQLクエリの実行
$res = $stmt->execute();
@@ -647,16 +659,16 @@ if(isset($_GET['token'])&&isset($_GET['type'])) {
$userdata["follower_cnt"] = count($followercnts)-1;
$response = array(
'user_name' => htmlentities($userdata["username"]),
'user_id' => htmlentities($userdata["userid"]),
'profile' => htmlentities($userdata["profile"]),
'user_icon' => htmlentities("https://".$domain."/".$userdata["iconname"]),
'user_header' => htmlentities("https://".$domain."/".$userdata["headname"]),
'registered_date' => htmlentities($userdata["datetime"]),
'follow' => htmlentities($userdata["follow"]),
'follow_cnt' => htmlentities($userdata["follow_cnt"]),
'follower' => htmlentities($userdata["follower"]),
'follower_cnt' => htmlentities($userdata["follower_cnt"]),
'user_name' => decode_yajirushi(htmlspecialchars_decode($userdata["username"])),
'user_id' => decode_yajirushi(htmlspecialchars_decode($userdata["userid"])),
'profile' => decode_yajirushi(htmlspecialchars_decode($userdata["profile"])),
'user_icon' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["iconname"])),
'user_header' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["headname"])),
'registered_date' => decode_yajirushi(htmlspecialchars_decode($userdata["datetime"])),
'follow' => decode_yajirushi(htmlspecialchars_decode($userdata["follow"])),
'follow_cnt' => decode_yajirushi(htmlspecialchars_decode($userdata["follow_cnt"])),
'follower' => decode_yajirushi(htmlspecialchars_decode($userdata["follower"])),
'follower_cnt' => decode_yajirushi(htmlspecialchars_decode($userdata["follower_cnt"])),
);
}
echo json_encode($response, JSON_UNESCAPED_UNICODE);;
+25 -17
View File
@@ -1,11 +1,19 @@
<?php
header("Content-Type: application/json; charset=utf-8; Access-Control-Allow-Origin: *;");
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
function decode_yajirushi($postText){
$postText = str_replace('&larr;', '←', $postText);
$postText = str_replace('&darr;', '↓', $postText);
$postText = str_replace('&uarr;', '↑', $postText);
$postText = str_replace('&rarr;', '→', $postText);
return $postText;
}
if(isset($_GET['limit'])) {
$itemsPerPage = (int)$_GET['limit']; // 1ページあたりの投稿数
$itemsPerPage = htmlentities((int)$_GET['limit']); // 1ページあたりの投稿数
if(isset($_GET['page'])) {
$pageNumber = (int)$_GET['page'];
$pageNumber = htmlentities((int)$_GET['page']);
}else{
$pageNumber = 1;
}
@@ -65,19 +73,19 @@ if(isset($_GET['limit'])) {
$ueusedata["favorite_cnt"] = count($favcnts) - 1;
$item = [
'account' => htmlentities($ueusedata["account"]),
'username' => htmlentities($ueusedata["username"]),
'uniqid' => htmlentities($ueusedata["uniqid"]),
'ueuse' => htmlentities($ueusedata["ueuse"]),
'photo1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"])),
'photo2' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"])),
'video1' => htmlentities(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"])),
'favorite' => htmlentities($ueusedata["favorite"]),
'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]),
'datetime' => htmlentities($ueusedata["datetime"]),
'abi' => htmlentities($ueusedata["abi"]),
'abidatetime' => htmlentities($ueusedata["abidate"]),
'nsfw' => htmlentities($ueusedata["nsfw"]),
'account' => decode_yajirushi(htmlspecialchars_decode($ueusedata["account"])),
'username' => decode_yajirushi(htmlspecialchars_decode($ueusedata["username"])),
'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["uniqid"])),
'ueuse' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])),
'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))),
'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))),
'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', '' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))),
'favorite' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite"])),
'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])),
'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])),
'abi' => decode_yajirushi(htmlspecialchars_decode($ueusedata["abi"])),
'abidatetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["abidate"])),
'nsfw' => decode_yajirushi(htmlspecialchars_decode($ueusedata["nsfw"])),
];
$response[$ueusedata["uniqid"]] = $item; // ループ内で $response にデータを追加
+15 -14
View File
@@ -1,5 +1,7 @@
<?php
header("Content-Type: application/json; charset=utf-8; Access-Control-Allow-Origin: *;");
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
$mojisizefile = "../server/textsize.txt";
@@ -20,6 +22,13 @@ for( $i=0;$i<$cnt;$i++ ){
$uwuzuinfo[$i] = ($softwaredata[$i]);
}
function decode_yajirushi($postText){
$postText = str_replace('&larr;', '←', $postText);
$postText = str_replace('&darr;', '↓', $postText);
$postText = str_replace('&uarr;', '↑', $postText);
$postText = str_replace('&rarr;', '→', $postText);
return $postText;
}
require('../db.php');
$datetime = array();
@@ -61,15 +70,7 @@ for( $i=0;$i<$cnt;$i++ ){
$notices[] = $row;
}
if(htmlspecialchars($serversettings["serverinfo"]["server_icon"], ENT_QUOTES, 'UTF-8') === "true"){
$openregit = false;
}elseif(htmlspecialchars($serversettings["serverinfo"]["server_icon"], ENT_QUOTES, 'UTF-8') === "false"){
$openregit = true;
}else{
$openregit = false;
}
if(htmlspecialchars($serversettings["serverinfo"]["server_icon"], ENT_QUOTES, 'UTF-8') === "true"){
if(htmlspecialchars($serversettings["serverinfo"]["server_invitation"], ENT_QUOTES, 'UTF-8') === "true"){
$invitation_code = true;
}else{
$invitation_code = false;
@@ -77,10 +78,10 @@ for( $i=0;$i<$cnt;$i++ ){
foreach ($notices as $value) {
$notices = array(
"title" => htmlentities($value['title']),
"note" => htmlentities($value['note']),
"editor" => htmlentities($value['account']),
"datetime" => htmlentities($value['datetime']),
"title" => decode_yajirushi(htmlspecialchars_decode($value['title'])),
"note" => decode_yajirushi(htmlspecialchars_decode($value['note'])),
"editor" => decode_yajirushi(htmlspecialchars_decode($value['account'])),
"datetime" => decode_yajirushi(htmlspecialchars_decode($value['datetime'])),
);
$notice[] = $notices;
+22 -14
View File
@@ -1,6 +1,14 @@
<?php
header("Content-Type: application/json; charset=utf-8; Access-Control-Allow-Origin: *;");
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
function decode_yajirushi($postText){
$postText = str_replace('&larr;', '←', $postText);
$postText = str_replace('&darr;', '↓', $postText);
$postText = str_replace('&uarr;', '↑', $postText);
$postText = str_replace('&rarr;', '→', $postText);
return $postText;
}
if(isset($_GET['ueuseid'])) {
$ueuseid = htmlentities($_GET['ueuseid']);
@@ -61,18 +69,18 @@ if (empty($ueusedata)){
$ueusedata["favorite_cnt"] = count($favcnts)-1;
$response = array(
'userid' => htmlentities($ueusedata["account"]),
'user_name' => htmlentities($ueusedata["username"]),
'uniqid' => htmlentities($ueusedata["uniqid"]),
'ueuse' => htmlentities($ueusedata["ueuse"]),
'photo1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo1"])),
'photo2' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo2"])),
'video1' => htmlentities(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["video1"])),
'favorite' => htmlentities($ueusedata["favorite"]),
'favorite_cnt' => htmlentities($ueusedata["favorite_cnt"]),
'datetime' => htmlentities($ueusedata["datetime"]),
'abi' => htmlentities($ueusedata["abi"]),
'abidatetime' => htmlentities($ueusedata["abidate"]),
'userid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["account"])),
'user_name' => decode_yajirushi(htmlspecialchars_decode($ueusedata["username"])),
'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["uniqid"])),
'ueuse' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])),
'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo1"]))),
'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["photo2"]))),
'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', ''.$_SERVER['HTTP_HOST'].'/', $ueusedata["video1"]))),
'favorite' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite"])),
'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])),
'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])),
'abi' => decode_yajirushi(htmlspecialchars_decode($ueusedata["abi"])),
'abidatetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["abidate"])),
);
}
echo json_encode($response, JSON_UNESCAPED_UNICODE);;
+20 -12
View File
@@ -1,6 +1,14 @@
<?php
header("Content-Type: application/json; charset=utf-8; Access-Control-Allow-Origin: *;");
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
function decode_yajirushi($postText){
$postText = str_replace('&larr;', '←', $postText);
$postText = str_replace('&darr;', '↓', $postText);
$postText = str_replace('&uarr;', '↑', $postText);
$postText = str_replace('&rarr;', '→', $postText);
return $postText;
}
if(isset($_GET['userid'])) {
$search = htmlentities($_GET['userid']);
@@ -54,16 +62,16 @@ if (empty($userdata)){
$userdata["follower_cnt"] = count($followercnts)-1;
$response = array(
'user_name' => htmlentities($userdata["username"]),
'user_id' => htmlentities($userdata["userid"]),
'profile' => htmlentities($userdata["profile"]),
'user_icon' => htmlentities("https://".$domain."/".$userdata["iconname"]),
'user_header' => htmlentities("https://".$domain."/".$userdata["headname"]),
'registered_date' => htmlentities($userdata["datetime"]),
'follow' => htmlentities($userdata["follow"]),
'follow_cnt' => htmlentities($userdata["follow_cnt"]),
'follower' => htmlentities($userdata["follower"]),
'follower_cnt' => htmlentities($userdata["follower_cnt"]),
'user_name' => decode_yajirushi(htmlspecialchars_decode($userdata["username"])),
'user_id' => decode_yajirushi(htmlspecialchars_decode($userdata["userid"])),
'profile' => decode_yajirushi(htmlspecialchars_decode($userdata["profile"])),
'user_icon' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["iconname"])),
'user_header' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["headname"])),
'registered_date' => decode_yajirushi(htmlspecialchars_decode($userdata["datetime"])),
'follow' => decode_yajirushi(htmlspecialchars_decode($userdata["follow"])),
'follow_cnt' => decode_yajirushi(htmlspecialchars_decode($userdata["follow_cnt"])),
'follower' => decode_yajirushi(htmlspecialchars_decode($userdata["follower"])),
'follower_cnt' => decode_yajirushi(htmlspecialchars_decode($userdata["follower_cnt"])),
);
}
echo json_encode($response, JSON_UNESCAPED_UNICODE);
+5
View File
@@ -0,0 +1,5 @@
<?php
$url = "instance";
header("Location:".$url."");
exit;
?>
+63
View File
@@ -0,0 +1,63 @@
<?php
$serversettings_file = "../../server/serversettings.ini";
$serversettings = parse_ini_file($serversettings_file, true);
function decode_yajirushi($postText){
$postText = str_replace('&larr;', '←', $postText);
$postText = str_replace('&darr;', '↓', $postText);
$postText = str_replace('&uarr;', '↑', $postText);
$postText = str_replace('&rarr;', '→', $postText);
return $postText;
}
if(htmlspecialchars($serversettings["serverinfo"]["server_activitypub"], ENT_QUOTES, 'UTF-8') === "true"){
header("Content-Type: application/json");
header("charset=utf-8");
header("Access-Control-Allow-Origin: *");
$mojisizefile = "../../server/textsize.txt";
$adminfile = htmlentities($serversettings["serverinfo"]["server_admin"]);
$servernamefile = htmlentities($serversettings["serverinfo"]["server_name"]);
$serverinfofile = '../../server/info.txt';
$serverinfo = htmlentities(file_get_contents($serverinfofile));
$contactfile = htmlentities($serversettings["serverinfo"]["server_admin_mailadds"]);
$domain = $_SERVER['HTTP_HOST'];
$softwarefile = "../../server/uwuzuinfo.txt";
$softwaredata = htmlentities(file_get_contents($softwarefile));
$onlyuser = htmlentities($serversettings["serverinfo"]["server_invitation"]);
$server_head = htmlentities($serversettings["serverinfo"]["server_head"]);
$softwaredata = explode( "\n", $softwaredata );
$cnt = count( $softwaredata );
for( $i=0;$i<$cnt;$i++ ){
$uwuzuinfo[$i] = ($softwaredata[$i]);
}
if($onlyuser === "true"){
$openregit = false;
}elseif($onlyuser === "false"){
$openregit = true;
}else{
$openregit = false;
}
$item = array(
"uri" => $domain,
"email" => $contactfile,
"title" => "uwuzu",
"version" =>str_replace("\r", '', $uwuzuinfo[1]),
"thumbnail" => $server_head,
"description" => $serverinfo,
);
echo json_encode($item, JSON_UNESCAPED_UNICODE);
}else{
header("HTTP/1.1 410 Gone");
}
?>