diff --git a/database/migrations/2022_10_13_002653_add_ip_to_complains_table.php b/database/migrations/2022_10_13_002653_add_ip_to_complains_table.php new file mode 100644 index 00000000..84eca8be --- /dev/null +++ b/database/migrations/2022_10_13_002653_add_ip_to_complains_table.php @@ -0,0 +1,38 @@ +string('ip')->nullable(true); + }); + Schema::table('complain_replies', function (Blueprint $table) { + $table->string('ip')->nullable(true); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('complains', function (Blueprint $table) { + $table->dropColumn('ip'); + }); + Schema::table('complain_replies', function (Blueprint $table) { + $table->dropColumn('ip'); + }); + } +}; diff --git a/include/constants.php b/include/constants.php index 4f96d1f0..1825f479 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ where('email', $email)->first(); + if (!$user) { + stderr($lang_functions['std_error'], $lang_complains['text_new_failure']); + } + sql_query(sprintf('INSERT INTO complains (uuid, email, body, added, ip) VALUES (UUID(), %s, %s, NOW(), %s)', sqlesc($email), sqlesc($body), sqlesc(getip()))) or sqlerr(__FILE__, __LINE__); $Cache->delete_value('COMPLAINTS_COUNT_CACHE'); nexus_redirect(sprintf('complains.php?action=view&id=%s', get_single_value('complains', 'uuid', 'WHERE id = ' . mysql_insert_id()))); break; @@ -27,7 +31,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){ $body = filter_input(INPUT_POST, 'body', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $complain = \App\Models\Complain::query()->findOrFail($id); if(empty($id) || empty($body)) stderr($lang_functions['std_error'], $lang_complains['text_new_failure']); - sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, $uid, sqlesc($body))) or sqlerr(__FILE__, __LINE__); + sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body, ip) VALUES (%u, %u, NOW(), %s, %s)', $id, $uid, sqlesc($body), sqlesc(getip()))) or sqlerr(__FILE__, __LINE__); if ($uid > 0) { try { $toolRep = new \App\Repositories\ToolRepository(); @@ -111,6 +115,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){ printf(' [%s]', urlencode($user->username), $lang_complains['text_view_band_log']); } } + printf('
IP: ' . htmlspecialchars($complain['ip'])); echo '
', format_comment($complain['body']); end_frame(); // REPLIES @@ -118,7 +123,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){ $res = sql_query(sprintf('SELECT * FROM `complain_replies` WHERE complain = %u ORDER BY id DESC', $complain['id'])) or sqlerr(__FILE__, __LINE__); if(mysql_num_rows($res)){ while($row = mysql_fetch_assoc($res)){ - printf('%s @ %s: ', $row['userid'] ? get_plain_username($row['userid']) : $lang_complains['text_complainer'], gettime($row['added'])); + printf('%s @ %s (%s): ', $row['userid'] ? get_plain_username($row['userid']) : $lang_complains['text_complainer'], gettime($row['added']), htmlspecialchars($row['ip'])); echo format_comment($row['body']) . '
'; } }else{