From e8b5a3a6dd548e471634886bb9022169c082cd35 Mon Sep 17 00:00:00 2001
From: Daichimarukana
Date: Mon, 19 Aug 2024 17:24:19 +0900
Subject: [PATCH] uwuzu v1.4.2 Funium
---
abi/addabi.php | 3 +-
api/migration-api.php | 40 +----
api/ueuse/delete.php | 126 +++----------
api/users/follow.php | 44 +----
delete/delete.php | 123 +------------
favorite/favorite.php | 7 +-
function/function.php | 309 +++++++++++++++++++++++++-------
home/index.php | 12 +-
others/account_migration.php | 92 +++++-----
passrecovery/startrecovery.php | 4 +-
server/uwuzuabout.txt | 4 +-
server/uwuzuinfo.txt | 4 +-
server/uwuzurelease.txt | 40 +++--
settings/index.php | 135 ++++++++++++--
settings_admin/update_admin.php | 9 +-
ueuse/index.php | 16 +-
update.json | 23 ++-
user/index.php | 2 +-
user/report.php | 107 +----------
uwuzu_database.sql | 6 +-
20 files changed, 560 insertions(+), 546 deletions(-)
diff --git a/abi/addabi.php b/abi/addabi.php
index 78f2a22..6905126 100644
--- a/abi/addabi.php
+++ b/abi/addabi.php
@@ -95,8 +95,9 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['abitext'])) && s
$title = safetext("" . $result2["username"] . "さんにメンションされました!");
$url = safetext("/!" . $postUniqid . "~" . $userid . "");
$userchk = 'none';
+ $category = 'mention';
- send_notification($touserid,$userid,$title,$msg,$url);
+ send_notification($touserid,$userid,$title,$msg,$url,$category);
}
if ($res) {
diff --git a/api/migration-api.php b/api/migration-api.php
index 058b8d2..2b07f6c 100644
--- a/api/migration-api.php
+++ b/api/migration-api.php
@@ -96,38 +96,14 @@ if(isset($_GET['migration_code'])) {
}
//メール送信はナシ
//------------
- $pdo->beginTransaction();
-
- try {
- $datetime = date("Y-m-d H:i:s");
- $msg = "アカウントの移行が完了したためこのアカウントの不正コピーを防ぐためアカウントを凍結しました!\n引き続きこのアカウントを利用するには管理者に凍結を解除してもらってください!";
- $title = "✨アカウントの移行が完了しました!🔄️";
- $url = "/rule/serverabout";
- $userchk = 'none';
- $from_userid = "uwuzu-fromsys";
-
- $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title)");
-
- $stmt->bindParam(':fromuserid', $from_userid, PDO::PARAM_STR);
- $stmt->bindParam(':touserid', $account, 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();
- }
+
+ $msg = "アカウントの移行が完了したためこのアカウントの不正コピーを防ぐためアカウントを凍結しました!\n引き続きこのアカウントを利用するには管理者に凍結を解除してもらってください!";
+ $title = "✨アカウントの移行が完了しました!🔄️";
+ $url = "/rule/serverabout";
+ $from_userid = "uwuzu-fromsys";
+ $category = "system";
+
+ send_notification($from_userid,$account,$title,$msg,$url,$category);
if ($res) {
$item = array(
diff --git a/api/ueuse/delete.php b/api/ueuse/delete.php
index 28c7a20..34b7bf0 100644
--- a/api/ueuse/delete.php
+++ b/api/ueuse/delete.php
@@ -72,7 +72,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
session_start();
if( !empty($pdo) ) {
- $userQuery = $pdo->prepare("SELECT username, userid, role FROM account WHERE token = :token");
+ $userQuery = $pdo->prepare("SELECT username, userid, role, loginid FROM account WHERE token = :token");
$userQuery->bindValue(':token', $token);
$userQuery->execute();
$userData = $userQuery->fetch();
@@ -93,111 +93,37 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
echo json_encode($response, JSON_UNESCAPED_UNICODE);
exit;
}else{
- $query = $pdo->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1');
-
- $query->execute(array(':uniqid' => $ueuseid));
-
- $result = $query->fetch();
-
- if(!(empty($result))){
- if($result["account"] === $userData["userid"]){
-
- $Userid = $userData["userid"];
- $photo_query = $pdo->prepare("SELECT * FROM ueuse WHERE account = :userid AND uniqid = :uniqid");
- $photo_query->bindValue(':userid', $Userid);
- $photo_query->bindValue(':uniqid', $ueuseid);
- $photo_query->execute();
- $photo_and_video = $photo_query->fetch();
-
- if(!($photo_and_video["photo1"] == "none")){
- $photoDelete1 = glob("../".$photo_and_video["photo1"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete1 as $photo1) {
- if (is_file($photo1)) {
- unlink($photo1);
- }
- }
- }
- if(!($photo_and_video["photo2"] == "none")){
- $photoDelete2 = glob("../".$photo_and_video["photo2"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete2 as $photo2) {
- if (is_file($photo2)) {
- unlink($photo2);
- }
- }
- }
- if(!($photo_and_video["photo3"] == "none")){
- $photoDelete3 = glob("../".$photo_and_video["photo3"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete3 as $photo3) {
- if (is_file($photo3)) {
- unlink($photo3);
- }
- }
- }
- if(!($photo_and_video["photo4"] == "none")){
- $photoDelete4 = glob("../".$photo_and_video["photo4"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete4 as $photo4) {
- if (is_file($photo4)) {
- unlink($photo4);
- }
- }
- }
- if(!($photo_and_video["video1"] == "none")){
- $videoDelete1 = glob("../".$photo_and_video["video1"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($videoDelete1 as $video1) {
- if (is_file($video1)) {
- unlink($video1);
- }
- }
- }
-
-
- try {
- $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE uniqid = :uniqid AND account = :userid");
- $deleteQuery->bindValue(':uniqid', $ueuseid, PDO::PARAM_STR);
- $deleteQuery->bindValue(':userid', $Userid, PDO::PARAM_STR);
- $res = $deleteQuery->execute();
-
- if ($res) {
- $response = array(
- 'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueuseid)),
- 'userid' => decode_yajirushi(htmlspecialchars_decode($userData["userid"])),
- 'success' => true
- );
-
- echo json_encode($response, JSON_UNESCAPED_UNICODE);
- exit;
- } else {
- $response = array(
- 'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueuseid)),
- 'userid' => decode_yajirushi(htmlspecialchars_decode($Userid)),
- 'success' => false
- );
-
- echo json_encode($response, JSON_UNESCAPED_UNICODE);
- exit;
- }
- } catch(PDOException $e) {
- $response = array(
- 'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueuseid)),
- 'userid' => decode_yajirushi(htmlspecialchars_decode($userData["userid"])),
- 'success' => false
- );
-
- echo json_encode($response, JSON_UNESCAPED_UNICODE);
- exit;
- }
+ if (safetext(isset($ueuseid)) && safetext(isset($userData["userid"])) && safetext(isset($userData["loginid"]))){
+ $postUserid = safetext($userData["userid"]);
+ $postUniqid = safetext($ueuseid);
+ $loginid = safetext($userData["loginid"]);
+
+ $result = delete_ueuse($postUniqid, $postUserid, $loginid);
+ if($result[0] === true){
+ $response = array(
+ 'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueuseid)),
+ 'userid' => decode_yajirushi(htmlspecialchars_decode($userData["userid"])),
+ 'success' => true
+ );
+ echo json_encode($response, JSON_UNESCAPED_UNICODE);
+ exit;
+ }else{
+ $response = array(
+ 'uniqid' => decode_yajirushi(htmlspecialchars_decode($ueuseid)),
+ 'userid' => decode_yajirushi(htmlspecialchars_decode($userData["userid"])),
+ 'success' => false
+ );
+ echo json_encode($response, JSON_UNESCAPED_UNICODE);
+ exit;
}
-
- } else {
- $err = "ueuse_not_found";
+ }else{
+ $err = "input_not_found";
$response = array(
'error_code' => $err,
);
-
+
echo json_encode($response, JSON_UNESCAPED_UNICODE);
- exit;
}
-
}
}
}else{
diff --git a/api/users/follow.php b/api/users/follow.php
index 8931672..b522917 100644
--- a/api/users/follow.php
+++ b/api/users/follow.php
@@ -118,53 +118,27 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR);
$updateQuery->bindValue(':userid', $Follow_userdata['userid'], PDO::PARAM_STR);
$res = $updateQuery->execute();
-
+
// 自分のfollowカラムを更新
- $updateQuery = $pdo->prepare("UPDATE account SET follow = CONCAT_WS(',', follow, :follow) WHERE userid = :userid");
- $updateQuery->bindValue(':follow', $Follow_userdata["userid"], PDO::PARAM_STR);
+ $myflwlist = explode(',', $userData['follow']);
+ $myflwlist[] = $userData['userid'];
+ $newFollowList = implode(',', array_unique($myflwlist));
+
+ $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid");
+ $updateQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR);
$updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR);
$res_follow = $updateQuery->execute();
$datetime = date("Y-m-d H:i:s");
$pdo->beginTransaction();
- try {
- $fromuserid = safetext($userid);
- $touserid = safetext($Follow_userdata["userid"]);
- $datetime = safetext(date("Y-m-d H:i:s"));
- $msg = safetext("".$userid."さんにフォローされました。");
- $title = safetext("🎉".$userid."さんにフォローされました!🎉");
- $url = safetext("/@" . $userid . "");
- $userchk = safetext('none');
-
- // 通知用SQL作成
- $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title)");
-
- $stmt->bindParam(':fromuserid', $fromuserid, 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);
-
- // SQLクエリの実行
- $res = $stmt->execute();
-
- // コミット
- $res = $pdo->commit();
-
- } catch(Exception $e) {
-
- // エラーが発生した時はロールバック
- $pdo->rollBack();
- }
+ send_notification($follow_userid, $userid, "🎉" . $userid . "さんにフォローされました!🎉", "" . $userid . "さんにフォローされました。", "/@" . $userid . "", "follow");
if ($res && $res_follow) {
//フォロー完了
$response = array(
'userid' => decode_yajirushi(htmlspecialchars_decode($Follow_userdata["userid"])),
+ 'success' => true
);
echo json_encode($response, JSON_UNESCAPED_UNICODE);
} else {
diff --git a/delete/delete.php b/delete/delete.php
index ff3699b..80aa6c8 100644
--- a/delete/delete.php
+++ b/delete/delete.php
@@ -2,132 +2,19 @@
require('../db.php');
require("../function/function.php");
-
if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && safetext(isset($_POST['account_id']))){
$postUserid = safetext($_POST['userid']);
$postUniqid = safetext($_POST['uniqid']);
$loginid = safetext($_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();
- }
-
- $query = $pdo->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1');
- $query->execute(array(':uniqid' => $postUniqid));
- $result = $query->fetch();
-
- if($result > 0){
- if($result["account"] === $postUserid){
- $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1');
- $query->execute(array(':userid' => $postUserid));
- $result2 = $query->fetch();
-
- if($result2["loginid"] === $loginid){
- $photo_query = $pdo->prepare("SELECT * FROM ueuse WHERE account = :userid AND uniqid = :uniqid");
- $photo_query->bindValue(':userid', $postUserid);
- $photo_query->bindValue(':uniqid', $postUniqid);
- $photo_query->execute();
- $photo_and_video = $photo_query->fetch();
-
- if(!($photo_and_video["photo1"] == "none")){
- $photoDelete1 = glob($photo_and_video["photo1"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete1 as $photo1) {
- if (is_file($photo1)) {
- unlink($photo1);
- }
- }
- }
- if(!($photo_and_video["photo2"] == "none")){
- $photoDelete2 = glob($photo_and_video["photo2"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete2 as $photo2) {
- if (is_file($photo2)) {
- unlink($photo2);
- }
- }
- }
- if(!($photo_and_video["photo3"] == "none")){
- $photoDelete3 = glob($photo_and_video["photo3"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete3 as $photo3) {
- if (is_file($photo3)) {
- unlink($photo3);
- }
- }
- }
- if(!($photo_and_video["photo4"] == "none")){
- $photoDelete4 = glob($photo_and_video["photo4"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($photoDelete4 as $photo4) {
- if (is_file($photo4)) {
- unlink($photo4);
- }
- }
- }
- if(!($photo_and_video["video1"] == "none")){
- $videoDelete1 = glob($photo_and_video["video1"]); // 「-ユーザーID.拡張子」というパターンを検索
- foreach ($videoDelete1 as $video1) {
- if (is_file($video1)) {
- unlink($video1);
- }
- }
- }
-
- $ruChkquery = $pdo->prepare('SELECT * FROM ueuse WHERE ruuniqid = :uniqid AND ueuse = "" limit 1');
- $ruChkquery->execute(array(':uniqid' => $postUniqid));
- $result3 = $ruChkquery->fetch();
-
- if($result3 > 0){
- try {
- // 削除クエリを実行
- $rudeleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE ruuniqid = :uniqid AND ueuse = ''");
- $rudeleteQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
- $res = $rudeleteQuery->execute();
-
- if (!($res)){
- $pdo->rollBack();
- $error_message[] = "リユーズの削除ができませんでした。";
- }
- } catch(PDOException $e) {
- $pdo->rollBack();
- $error_message[] = 'データベースエラー:' . $e->getMessage();
- }
- }
-
- try {
- // 削除クエリを実行
- $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE uniqid = :uniqid AND account = :userid");
- $deleteQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
- $deleteQuery->bindValue(':userid', $postUserid, PDO::PARAM_STR);
- $res = $deleteQuery->execute();
-
- if ($res) {
- echo json_encode(['success' => true]);
- exit;
- } else {
- $pdo->rollBack();
- echo json_encode(['success' => false, 'error' => '削除に失敗しました。']);
- exit;
- }
- } catch(PDOException $e) {
- $pdo->rollBack();
- echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]);
- exit;
- }
- }
- }else{
- echo json_encode(['success' => false, 'error' => '削除に失敗しました。(userid_err)']);
- exit;
- }
+ $result = delete_ueuse($postUniqid, $postUserid, $loginid);
+ if($result[0] === true){
+ echo json_encode(['success' => true]);
+ exit;
}else{
- echo json_encode(['success' => true, 'error' => 'すでに削除されています']);
+ echo json_encode(['success' => false, 'error' => '削除に失敗しました。']);
exit;
}
-
}else{
echo json_encode(['success' => false, 'error' => '削除に失敗しました。(sess_err)']);
exit;
diff --git a/favorite/favorite.php b/favorite/favorite.php
index 0fb52ea..e67cc2c 100644
--- a/favorite/favorite.php
+++ b/favorite/favorite.php
@@ -37,18 +37,21 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && sa
$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 = $pdo->prepare("SELECT account,ueuse,favorite FROM ueuse WHERE uniqid = :uniqid");
$stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR);
$stmt->execute();
$post = $stmt->fetch(PDO::FETCH_ASSOC);
- if ($post) {
+ if (!(empty($post))) {
$favoriteList = explode(',', $post['favorite']);
$index = array_search($userId, $favoriteList);
if ($index === false) {
// ユーザーIDを追加
$favoriteList[] = $userId;
+
+ send_notification(safetext($post['account']),$userId,"".$userId."さんがいいねしました!",safetext($post['ueuse']),"/!".$postUniqid."","favorite");
+
} else {
// ユーザーIDを削除
array_splice($favoriteList, $index, 1);
diff --git a/function/function.php b/function/function.php
index 423f918..3d10972 100644
--- a/function/function.php
+++ b/function/function.php
@@ -189,16 +189,20 @@ function resizeImage($filePath, $maxWidth, $maxHeight) {
}
//文字装飾・URL変換など
-function processMarkdownAndWrapEmptyLines($markdownText){
+function processMarkdownAndWrapEmptyLines($markdownText) {
+ $placeholders = [];
- //\___________________[注意]__________________\
- // \____ここの順番を変えるとうまく動かなくなります___\
- // \______Markdownうまく動くところを探すべし______\
+ // インラインコードをプレースホルダーに置き換える
+ $markdownText = preg_replace_callback('/`([^`\n]+)`/', function($matches) use (&$placeholders) {
+ $placeholder = 'PLACEHOLDER_' . count($placeholders);
+ $placeholders[$placeholder] = '' . $matches[1] . '';
+ return $placeholder;
+ }, $markdownText);
+
+ // ここから先の処理はインラインコードとコードブロックに影響しない
$markdownText = preg_replace('/\[\[buruburu (.+)\]\]/m', '$1', $markdownText);//ぶるぶる
- $markdownText = preg_replace('/(^|[^`])`([^`\n]+)`($|[^`])/m', '$1$2$3', $markdownText);//Inline Code
-
$markdownText = preg_replace_callback('/\[\[time (\d+)\]\]/m', function($matches) {
$timestamp = $matches[1];
return '' . date("Y/m/d H:i", htmlentities($timestamp, ENT_QUOTES, 'UTF-8', false)) . '';
@@ -238,12 +242,18 @@ function processMarkdownAndWrapEmptyLines($markdownText){
// 箇条書き(-)をHTMLのul/liタグに変換
$markdownText = preg_replace('/^- (.+)/m', '・ $1
', $markdownText);
-
+
// 空行の前に何もない行をHTMLのpタグに変換
$markdownText = preg_replace('/(^\s*)(?!\s)(.*)/m', '$1$2
', $markdownText);
+ // プレースホルダーを元のコードに戻す
+ foreach ($placeholders as $placeholder => $original) {
+ $markdownText = str_replace($placeholder, $original, $markdownText);
+ }
+
return $markdownText;
}
+
//Profile
function replaceProfileEmojiImages($postText) {
$postText = str_replace(''', '\'', $postText);
@@ -361,44 +371,76 @@ function YouTube_and_nicovideo_Links($postText) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
if(!(empty($parsedUrl['host']))){
- if($parsedUrl['host'] == "youtube.com" || $parsedUrl['host'] == "youtu.be" || $parsedUrl['host'] == "www.youtube.com" || $parsedUrl['host'] == "m.youtube.com"){
+ $video_time = "0";
+ $video_id = "";
+ if($parsedUrl['host'] == "youtube.com" || $parsedUrl['host'] == "youtu.be" || $parsedUrl['host'] == "www.youtube.com" || $parsedUrl['host'] == "m.youtube.com"){
if (isset($parsedUrl['query'])) {
- if(false !== strpos($parsedUrl['query'], 'v=')) {
- $video_id = str_replace('v=', '', htmlentities($parsedUrl['query'], ENT_QUOTES, 'UTF-8', false));
+ // クエリ部分を連想配列に変換する
+ parse_str($parsedUrl['query'], $queryParams);
+
+ // video_idの取得
+ if (isset($queryParams['v'])) {
+ $video_id = safetext($queryParams['v']);
$iframe = true;
- }else{
- $video_id = str_replace('/', '', htmlentities($parsedUrl['path'], ENT_QUOTES, 'UTF-8', false));
+ } else {
+ $video_id = str_replace('/', '', safetext($parsedUrl['path']));
$iframe = true;
}
+ // video_timeの取得
+ if (isset($queryParams['amp;t'])) {
+ $video_time = safetext($queryParams['amp;t']);
+ if(!(is_numeric($video_time))){
+ $video_time = "0";
+ }
+ } else {
+ $video_time = "0";
+ }
$video_id = str_replace('&', '?', $video_id);
- }elseif(isset($parsedUrl['path'])){
- $video_id = str_replace('/', '', htmlentities($parsedUrl['path'], ENT_QUOTES, 'UTF-8', false));
+ } elseif (isset($parsedUrl['path'])) {
+ $video_id = str_replace('/', '', safetext($parsedUrl['path']));
+ $video_time = "0";
$iframe = true;
- }else{
+ } else {
$video_id = "";
+ $video_time = "0";
$iframe = false;
}
+
// 不要な文字を削除してaタグを生成
- if($iframe == true){
- $link = '';
- }else{
+ if ($iframe) {
+ $link = '';
+ } else {
$link = "";
}
+
// URLをドメインのみを表示するaタグで置き換え
$postText = $link;
}elseif($parsedUrl['host'] == "nicovideo.jp" || $parsedUrl['host'] == "www.nicovideo.jp"){
-
if(isset($parsedUrl['path'])){
- $video_id = str_replace('/watch/', '', htmlentities($parsedUrl['path'], ENT_QUOTES, 'UTF-8', false));
+ $video_id = str_replace('/watch/', '', safetext($parsedUrl['path']));
$iframe = true;
}else{
$video_id = "";
$iframe = false;
}
+ if (isset($parsedUrl['query'])) {
+ // クエリ部分を連想配列に変換する
+ parse_str($parsedUrl['query'], $queryParams);
+
+ // video_timeの取得
+ if (isset($queryParams['from'])) {
+ $video_time = safetext($queryParams['from']);
+ if(!(is_numeric($video_time))){
+ $video_time = "0";
+ }
+ } else {
+ $video_time = "0";
+ }
+ }
// 不要な文字を削除してaタグを生成
if($iframe == true){
- $link = '