From 4dd65bc9777d6fdb61f3241857a00cde9a53e488 Mon Sep 17 00:00:00 2001 From: Kio Date: Fri, 3 Apr 2020 13:58:04 -0400 Subject: [PATCH 01/68] Add Fabric Support for uploaded mods. There might not be much in terms of service, but I do know that Fabric offers a nice little .json file to probe. Perhaps if there is a good amount of support, we can find where that version number is hidden. (For now, however, it's hard coded as f1.15.2- What I use to distinguish between Forge 1.15.2, and Fabric 1.15.2.). Some mods do use the "Minecraft" depends feature, but not all, which makes it quite annoying. --- functions/send_mods.php | 319 ++++++++++++++++++++++------------------ 1 file changed, 172 insertions(+), 147 deletions(-) diff --git a/functions/send_mods.php b/functions/send_mods.php index 129ecc4..3a8bb0e 100644 --- a/functions/send_mods.php +++ b/functions/send_mods.php @@ -2,11 +2,11 @@ header('Content-Type: application/json'); session_start(); if(!$_SESSION['user']||$_SESSION['user']=="") { - die('{"status":"error","message":"Login session has expired"}'); + die('{"status":"error","message":"Login session has expired"}'); } if(substr($_SESSION['perms'],3,1)!=="1") { - echo '{"status":"error","message":"Insufficient permission!"}'; - exit(); + echo '{"status":"error","message":"Insufficient permission!"}'; + exit(); } $config = require("config.php"); require("dbconnect.php"); @@ -33,154 +33,179 @@ function slugify($text) { $fileName = implode("-",$fileName).".jar"; if(!file_exists("../mods/mods-".$fileName)) { - mkdir("../mods/mods-".$fileName); + mkdir("../mods/mods-".$fileName); } else { - echo '{"status":"error","message":"Folder mods-'.$fileName.' already exists!"}'; - exit(); + echo '{"status":"error","message":"Folder mods-'.$fileName.' already exists!"}'; + exit(); } if(move_uploaded_file($fileTmpLoc, "../mods/mods-".$fileName."/".$fileName)){ - $fileInfo = pathinfo("../mods/mods-".$fileName."/".$fileName); - if(file_exists("../mods/".$fileInfo['filename'].".zip")) { - $md5_1 = md5_file("../mods/mods-".$fileName."/".$fileName); - $exisingzip = new ZipArchive(); - $exisingzip->open("../mods/".$fileInfo['filename'].".zip"); - $exisingzip->extractTo("../mods/mods-".$fileName."/tmp/"); - $exisingzip->close(); - $md5_2 = md5_file("../mods/mods-".$fileName."/tmp/mods/".$fileName); - unlink("../mods/mods-".$fileName."/".$fileName); - unlink("../mods/mods-".$fileName."/tmp/mods/".$fileName); - rmdir("../mods/mods-".$fileName."/tmp/mods"); - rmdir("../mods/mods-".$fileName."/tmp"); - rmdir("../mods/mods-".$fileName); - if($md5_1 !== $md5_2) { - echo '{"status":"error","message":"File with name \''.$fileName.'\' already exists!","md51":"'.$md5_1.'","md52":"'.$md5_2.'","zip":"../mods/mods-'.$fileName.'/tmp/mods/'.$fileName.'"}'; - unlink("../mods/mods-".$fileName."/".$fileName); - rmdir("../mods/mods-".$fileName); - exit(); - } else { - $fq = mysqli_query($conn, "SELECT `id` FROM `mods` WHERE `filename` = '".$fileInfo['filename'].".zip'"); - if(mysqli_num_rows($fq)==1){ - echo '{"status":"info","message":"This mod is already in the database.","modid":'.mysqli_fetch_array($fq)['id'].'}'; - } else { - $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); - if($result) { - $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; - if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { - $warn['b'] = true; - $warn['level'] = "info"; - $warn['message'] = "There is some information missing in mcmod.info."; - } - } else { - $warn['b'] = true; - $warn['level'] = "warn"; - $warn['message'] = "File does not contain mod info. Manual configuration required."; - } - if(!$mcmod['name']) { - $pretty_name = mysqli_real_escape_string($conn, $fileName); - } else { - $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); - } - if(!$mcmod['modid']) { - $name = slugify($pretty_name); - } else { - if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { - $name = $mcmod['modid']; - } else { - $name = slugify($mcmod['modid']); - } - } - $link = $mcmod['url']; - $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); - $description = mysqli_real_escape_string($conn, $mcmod['description']); - $version = $mcmod['version']; - $mcversion = $mcmod['mcversion']; - $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); - //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; - $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); - if($res) { - if($warn['b']==true) { - if($warn['level']=="info") { - echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } else { - echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } - - } else { - echo '{"status":"succ","message":"Mod has been saved.","modid":'.mysqli_insert_id($conn).'}'; - } - } else { - echo '{"status":"error","message":"Mod could not be added to database"}'; - } - exit(); - } - - } - } else { - $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); - if($result) { - $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; - if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { - $warn['b'] = true; - $warn['level'] = "info"; - $warn['message'] = "There is some information missing in mcmod.info."; - } - } else { - $warn['b'] = true; - $warn['level'] = "warn"; - $warn['message'] = "File does not contain mod info. Manual configuration required."; - } - $zip = new ZipArchive(); - if ($zip->open("../mods/".$fileInfo['filename'].".zip", ZIPARCHIVE::CREATE) !== TRUE) { - echo '{"status":"error","message":"Could not open archive"}'; - exit(); - } - $path = "../mods/mods-".$fileName."/".$fileName; - $pathinfobn = $fileInfo['basename']; - $zip->addEmptyDir('mods'); - if(is_file($path)){ - $zip->addFile($path, "mods/".$pathinfobn) or die ('{"status":"error","message":"Could not add file $key"}'); - } - $zip->close(); - unlink("../mods/mods-".$fileName."/".$fileName); - rmdir("../mods/mods-".$fileName); - if(!$mcmod['name']) { - $pretty_name = mysqli_real_escape_string($conn, $fileName); - } else { - $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); - } - if(!$mcmod['modid']) { - $name = slugify($pretty_name); - } else { - if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { - $name = $mcmod['modid']; - } else { - $name = slugify($mcmod['modid']); - } - } - $link = $mcmod['url']; - $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); - $description = mysqli_real_escape_string($conn, $mcmod['description']); - $version = $mcmod['version']; - $mcversion = $mcmod['mcversion']; - $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); - //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; - $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); - if($res) { - if($warn['b']==true) { - if($warn['level']=="info") { - echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } else { - echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } - - } else { - echo '{"status":"succ","message":"Mod has been uploaded and saved.","modid":'.mysqli_insert_id($conn).'}'; - } - } else { - echo '{"status":"error","message":"Mod could not be added to database"}'; - } - } + $fileInfo = pathinfo("../mods/mods-".$fileName."/".$fileName); + if(file_exists("../mods/".$fileInfo['filename'].".zip")) { + $md5_1 = md5_file("../mods/mods-".$fileName."/".$fileName); + $exisingzip = new ZipArchive(); + $exisingzip->open("../mods/".$fileInfo['filename'].".zip"); + $exisingzip->extractTo("../mods/mods-".$fileName."/tmp/"); + $exisingzip->close(); + $md5_2 = md5_file("../mods/mods-".$fileName."/tmp/mods/".$fileName); + unlink("../mods/mods-".$fileName."/".$fileName); + unlink("../mods/mods-".$fileName."/tmp/mods/".$fileName); + rmdir("../mods/mods-".$fileName."/tmp/mods"); + rmdir("../mods/mods-".$fileName."/tmp"); + rmdir("../mods/mods-".$fileName); + if($md5_1 !== $md5_2) { + echo '{"status":"error","message":"File with name \''.$fileName.'\' already exists!","md51":"'.$md5_1.'","md52":"'.$md5_2.'","zip":"../mods/mods-'.$fileName.'/tmp/mods/'.$fileName.'"}'; + unlink("../mods/mods-".$fileName."/".$fileName); + rmdir("../mods/mods-".$fileName); + exit(); + } else { + $fq = mysqli_query($conn, "SELECT `id` FROM `mods` WHERE `filename` = '".$fileInfo['filename'].".zip'"); + if(mysqli_num_rows($fq)==1){ + echo '{"status":"info","message":"This mod is already in the database.","modid":'.mysqli_fetch_array($fq)['id'].'}'; + } else { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); + if($result) { + $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in mcmod.info."; + } + } elseif (file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json")) { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json"); + $q = json_decode(preg_replace('/\r|\n/','',trim($result)),true); + $mcmod = $q; + $mcmod["modid"] = $mcmod["id"]; + $mcmod["url"] = $mcmod["contact"]["sources"]; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in fabric.mod.json."; + } + + } else { + $warn['b'] = true; + $warn['level'] = "warn"; + $warn['message'] = "File does not contain mod info. Manual configuration required."; + } + if(!$mcmod['name']) { + $pretty_name = mysqli_real_escape_string($conn, $fileName); + } else { + $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); + } + if(!$mcmod['modid']) { + $name = slugify($pretty_name); + } else { + if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { + $name = $mcmod['modid']; + } else { + $name = slugify($mcmod['modid']); + } + } + $link = $mcmod['url']; + $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); + $description = mysqli_real_escape_string($conn, $mcmod['description']); + $version = $mcmod['version']; + $mcversion = $mcmod['mcversion']; + $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); + //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; + $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); + if($res) { + if($warn['b']==true) { + if($warn['level']=="info") { + echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } else { + echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } + + } else { + echo '{"status":"succ","message":"Mod has been saved.","modid":'.mysqli_insert_id($conn).'}'; + } + } else { + echo '{"status":"error","message":"Mod could not be added to database"}'; + } + exit(); + } + + } + } else { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); + if($result) { + $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in mcmod.info."; + } + } elseif (file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json")) { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json"); + $q = json_decode(preg_replace('/\r|\n/','',trim($result)),true); + $mcmod = $q; + $mcmod["modid"] = $mcmod["id"]; + $mcmod["authorList"] = $mcmod["authors"]; + $mcmod["url"] = $mcmod["contact"]["sources"]; + $mcmod["mcversion"] = "f1.15.2"; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in fabric.mod.json."; + } + } else { + $warn['b'] = true; + $warn['level'] = "warn"; + $warn['message'] = "File does not contain mod info. Manual configuration required."; + } + $zip = new ZipArchive(); + if ($zip->open("../mods/".$fileInfo['filename'].".zip", ZIPARCHIVE::CREATE) !== TRUE) { + echo '{"status":"error","message":"Could not open archive"}'; + exit(); + } + $path = "../mods/mods-".$fileName."/".$fileName; + $pathinfobn = $fileInfo['basename']; + $zip->addEmptyDir('mods'); + if(is_file($path)){ + $zip->addFile($path, "mods/".$pathinfobn) or die ('{"status":"error","message":"Could not add file $key"}'); + } + $zip->close(); + unlink("../mods/mods-".$fileName."/".$fileName); + rmdir("../mods/mods-".$fileName); + if(!$mcmod['name']) { + $pretty_name = mysqli_real_escape_string($conn, $fileName); + } else { + $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); + } + if(!$mcmod['modid']) { + $name = slugify($pretty_name); + } else { + if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { + $name = $mcmod['modid']; + } else { + $name = slugify($mcmod['modid']); + } + } + $link = $mcmod['url']; + $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); + $description = mysqli_real_escape_string($conn, $mcmod['description']); + $version = $mcmod['version']; + $mcversion = $mcmod['mcversion']; + $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); + //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; + $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); + if($res) { + if($warn['b']==true) { + if($warn['level']=="info") { + echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } else { + echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } + + } else { + echo '{"status":"succ","message":"Mod has been uploaded and saved.","modid":'.mysqli_insert_id($conn).'}'; + } + } else { + echo '{"status":"error","message":"Mod could not be added to database"}'; + } + } } else { echo '{"status":"error","message":"Permission denied! Open SSH and run chown -R www-data '.addslashes(dirname(dirname(get_included_files()[0]))).'"}'; } From 2e8a54989e11016da3f4df0a2cc4a49aec34e502 Mon Sep 17 00:00:00 2001 From: Kio Date: Fri, 3 Apr 2020 14:00:32 -0400 Subject: [PATCH 02/68] Update send_mods.php --- functions/send_mods.php | 314 ++++++++++++++++++++-------------------- 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/functions/send_mods.php b/functions/send_mods.php index 3a8bb0e..887fd13 100644 --- a/functions/send_mods.php +++ b/functions/send_mods.php @@ -2,11 +2,11 @@ header('Content-Type: application/json'); session_start(); if(!$_SESSION['user']||$_SESSION['user']=="") { - die('{"status":"error","message":"Login session has expired"}'); + die('{"status":"error","message":"Login session has expired"}'); } if(substr($_SESSION['perms'],3,1)!=="1") { - echo '{"status":"error","message":"Insufficient permission!"}'; - exit(); + echo '{"status":"error","message":"Insufficient permission!"}'; + exit(); } $config = require("config.php"); require("dbconnect.php"); @@ -33,179 +33,179 @@ function slugify($text) { $fileName = implode("-",$fileName).".jar"; if(!file_exists("../mods/mods-".$fileName)) { - mkdir("../mods/mods-".$fileName); + mkdir("../mods/mods-".$fileName); } else { - echo '{"status":"error","message":"Folder mods-'.$fileName.' already exists!"}'; - exit(); + echo '{"status":"error","message":"Folder mods-'.$fileName.' already exists!"}'; + exit(); } if(move_uploaded_file($fileTmpLoc, "../mods/mods-".$fileName."/".$fileName)){ - $fileInfo = pathinfo("../mods/mods-".$fileName."/".$fileName); - if(file_exists("../mods/".$fileInfo['filename'].".zip")) { - $md5_1 = md5_file("../mods/mods-".$fileName."/".$fileName); - $exisingzip = new ZipArchive(); - $exisingzip->open("../mods/".$fileInfo['filename'].".zip"); - $exisingzip->extractTo("../mods/mods-".$fileName."/tmp/"); - $exisingzip->close(); - $md5_2 = md5_file("../mods/mods-".$fileName."/tmp/mods/".$fileName); - unlink("../mods/mods-".$fileName."/".$fileName); - unlink("../mods/mods-".$fileName."/tmp/mods/".$fileName); - rmdir("../mods/mods-".$fileName."/tmp/mods"); - rmdir("../mods/mods-".$fileName."/tmp"); - rmdir("../mods/mods-".$fileName); - if($md5_1 !== $md5_2) { - echo '{"status":"error","message":"File with name \''.$fileName.'\' already exists!","md51":"'.$md5_1.'","md52":"'.$md5_2.'","zip":"../mods/mods-'.$fileName.'/tmp/mods/'.$fileName.'"}'; - unlink("../mods/mods-".$fileName."/".$fileName); - rmdir("../mods/mods-".$fileName); - exit(); - } else { - $fq = mysqli_query($conn, "SELECT `id` FROM `mods` WHERE `filename` = '".$fileInfo['filename'].".zip'"); - if(mysqli_num_rows($fq)==1){ - echo '{"status":"info","message":"This mod is already in the database.","modid":'.mysqli_fetch_array($fq)['id'].'}'; - } else { - $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); - if($result) { - $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; - if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { - $warn['b'] = true; - $warn['level'] = "info"; - $warn['message'] = "There is some information missing in mcmod.info."; - } - } elseif (file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json")) { - $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json"); - $q = json_decode(preg_replace('/\r|\n/','',trim($result)),true); - $mcmod = $q; - $mcmod["modid"] = $mcmod["id"]; - $mcmod["url"] = $mcmod["contact"]["sources"]; + $fileInfo = pathinfo("../mods/mods-".$fileName."/".$fileName); + if(file_exists("../mods/".$fileInfo['filename'].".zip")) { + $md5_1 = md5_file("../mods/mods-".$fileName."/".$fileName); + $exisingzip = new ZipArchive(); + $exisingzip->open("../mods/".$fileInfo['filename'].".zip"); + $exisingzip->extractTo("../mods/mods-".$fileName."/tmp/"); + $exisingzip->close(); + $md5_2 = md5_file("../mods/mods-".$fileName."/tmp/mods/".$fileName); + unlink("../mods/mods-".$fileName."/".$fileName); + unlink("../mods/mods-".$fileName."/tmp/mods/".$fileName); + rmdir("../mods/mods-".$fileName."/tmp/mods"); + rmdir("../mods/mods-".$fileName."/tmp"); + rmdir("../mods/mods-".$fileName); + if($md5_1 !== $md5_2) { + echo '{"status":"error","message":"File with name \''.$fileName.'\' already exists!","md51":"'.$md5_1.'","md52":"'.$md5_2.'","zip":"../mods/mods-'.$fileName.'/tmp/mods/'.$fileName.'"}'; + unlink("../mods/mods-".$fileName."/".$fileName); + rmdir("../mods/mods-".$fileName); + exit(); + } else { + $fq = mysqli_query($conn, "SELECT `id` FROM `mods` WHERE `filename` = '".$fileInfo['filename'].".zip'"); + if(mysqli_num_rows($fq)==1){ + echo '{"status":"info","message":"This mod is already in the database.","modid":'.mysqli_fetch_array($fq)['id'].'}'; + } else { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); + if($result) { + $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in mcmod.info."; + } + } elseif (file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json")) { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json"); + $q = json_decode(preg_replace('/\r|\n/','',trim($result)),true); + $mcmod = $q; + $mcmod["modid"] = $mcmod["id"]; + $mcmod["url"] = $mcmod["contact"]["sources"]; if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { $warn['b'] = true; $warn['level'] = "info"; $warn['message'] = "There is some information missing in fabric.mod.json."; } - } else { - $warn['b'] = true; - $warn['level'] = "warn"; - $warn['message'] = "File does not contain mod info. Manual configuration required."; - } - if(!$mcmod['name']) { - $pretty_name = mysqli_real_escape_string($conn, $fileName); - } else { - $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); - } - if(!$mcmod['modid']) { - $name = slugify($pretty_name); - } else { - if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { - $name = $mcmod['modid']; - } else { - $name = slugify($mcmod['modid']); - } - } - $link = $mcmod['url']; - $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); - $description = mysqli_real_escape_string($conn, $mcmod['description']); - $version = $mcmod['version']; - $mcversion = $mcmod['mcversion']; - $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); - //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; - $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); - if($res) { - if($warn['b']==true) { - if($warn['level']=="info") { - echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } else { - echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } - - } else { - echo '{"status":"succ","message":"Mod has been saved.","modid":'.mysqli_insert_id($conn).'}'; - } - } else { - echo '{"status":"error","message":"Mod could not be added to database"}'; - } - exit(); - } - - } - } else { - $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); - if($result) { - $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; - if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { - $warn['b'] = true; - $warn['level'] = "info"; - $warn['message'] = "There is some information missing in mcmod.info."; - } + } else { + $warn['b'] = true; + $warn['level'] = "warn"; + $warn['message'] = "File does not contain mod info. Manual configuration required."; + } + if(!$mcmod['name']) { + $pretty_name = mysqli_real_escape_string($conn, $fileName); + } else { + $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); + } + if(!$mcmod['modid']) { + $name = slugify($pretty_name); + } else { + if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { + $name = $mcmod['modid']; + } else { + $name = slugify($mcmod['modid']); + } + } + $link = $mcmod['url']; + $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); + $description = mysqli_real_escape_string($conn, $mcmod['description']); + $version = $mcmod['version']; + $mcversion = $mcmod['mcversion']; + $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); + //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; + $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); + if($res) { + if($warn['b']==true) { + if($warn['level']=="info") { + echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } else { + echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } + + } else { + echo '{"status":"succ","message":"Mod has been saved.","modid":'.mysqli_insert_id($conn).'}'; + } + } else { + echo '{"status":"error","message":"Mod could not be added to database"}'; + } + exit(); + } + + } + } else { + $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#mcmod.info"); + if($result) { + $mcmod = json_decode(preg_replace('/\r|\n/','',trim($result)),true)[0]; + if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { + $warn['b'] = true; + $warn['level'] = "info"; + $warn['message'] = "There is some information missing in mcmod.info."; + } } elseif (file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json")) { $result = file_get_contents("zip://".realpath("../mods/mods-".$fileName."/".$fileName)."#fabric.mod.json"); $q = json_decode(preg_replace('/\r|\n/','',trim($result)),true); $mcmod = $q; $mcmod["modid"] = $mcmod["id"]; - $mcmod["authorList"] = $mcmod["authors"]; + $mcmod["authorList"] = $mcmod["authors"]; $mcmod["url"] = $mcmod["contact"]["sources"]; - $mcmod["mcversion"] = "f1.15.2"; + $mcmod["mcversion"] = "f1.15.2"; if(!$mcmod['modid']||!$mcmod['name']||!$mcmod['description']||!$mcmod['version']||!$mcmod['mcversion']||!$mcmod['url']||!$mcmod['authorList']) { - $warn['b'] = true; - $warn['level'] = "info"; + $warn['b'] = true; + $warn['level'] = "info"; $warn['message'] = "There is some information missing in fabric.mod.json."; } - } else { - $warn['b'] = true; - $warn['level'] = "warn"; - $warn['message'] = "File does not contain mod info. Manual configuration required."; - } - $zip = new ZipArchive(); - if ($zip->open("../mods/".$fileInfo['filename'].".zip", ZIPARCHIVE::CREATE) !== TRUE) { - echo '{"status":"error","message":"Could not open archive"}'; - exit(); - } - $path = "../mods/mods-".$fileName."/".$fileName; - $pathinfobn = $fileInfo['basename']; - $zip->addEmptyDir('mods'); - if(is_file($path)){ - $zip->addFile($path, "mods/".$pathinfobn) or die ('{"status":"error","message":"Could not add file $key"}'); - } - $zip->close(); - unlink("../mods/mods-".$fileName."/".$fileName); - rmdir("../mods/mods-".$fileName); - if(!$mcmod['name']) { - $pretty_name = mysqli_real_escape_string($conn, $fileName); - } else { - $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); - } - if(!$mcmod['modid']) { - $name = slugify($pretty_name); - } else { - if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { - $name = $mcmod['modid']; - } else { - $name = slugify($mcmod['modid']); - } - } - $link = $mcmod['url']; - $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); - $description = mysqli_real_escape_string($conn, $mcmod['description']); - $version = $mcmod['version']; - $mcversion = $mcmod['mcversion']; - $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); - //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; - $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); - if($res) { - if($warn['b']==true) { - if($warn['level']=="info") { - echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } else { - echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; - } - - } else { - echo '{"status":"succ","message":"Mod has been uploaded and saved.","modid":'.mysqli_insert_id($conn).'}'; - } - } else { - echo '{"status":"error","message":"Mod could not be added to database"}'; - } - } + } else { + $warn['b'] = true; + $warn['level'] = "warn"; + $warn['message'] = "File does not contain mod info. Manual configuration required."; + } + $zip = new ZipArchive(); + if ($zip->open("../mods/".$fileInfo['filename'].".zip", ZIPARCHIVE::CREATE) !== TRUE) { + echo '{"status":"error","message":"Could not open archive"}'; + exit(); + } + $path = "../mods/mods-".$fileName."/".$fileName; + $pathinfobn = $fileInfo['basename']; + $zip->addEmptyDir('mods'); + if(is_file($path)){ + $zip->addFile($path, "mods/".$pathinfobn) or die ('{"status":"error","message":"Could not add file $key"}'); + } + $zip->close(); + unlink("../mods/mods-".$fileName."/".$fileName); + rmdir("../mods/mods-".$fileName); + if(!$mcmod['name']) { + $pretty_name = mysqli_real_escape_string($conn, $fileName); + } else { + $pretty_name = mysqli_real_escape_string($conn, $mcmod['name']); + } + if(!$mcmod['modid']) { + $name = slugify($pretty_name); + } else { + if(preg_match("^[a-z0-9]+(?:-[a-z0-9]+)*$", $mcmod['modid'])) { + $name = $mcmod['modid']; + } else { + $name = slugify($mcmod['modid']); + } + } + $link = $mcmod['url']; + $author = mysqli_real_escape_string($conn, implode(', ', $mcmod['authorList'])); + $description = mysqli_real_escape_string($conn, $mcmod['description']); + $version = $mcmod['version']; + $mcversion = $mcmod['mcversion']; + $md5 = md5_file("../mods/".$fileInfo['filename'].".zip"); + //$url = "http://".$config['host'].$config['dir']."mods/".$fileInfo['filename'].".zip"; + $res = mysqli_query($conn, "INSERT INTO `mods` (`name`,`pretty_name`,`md5`,`url`,`link`,`author`,`description`,`version`,`mcversion`,`filename`,`type`) VALUES ('".$name."','".$pretty_name."','".$md5."','','".$link."','".$author."','".$description."','".$version."','".$mcversion."','".$fileInfo['filename'].".zip','mod')"); + if($res) { + if($warn['b']==true) { + if($warn['level']=="info") { + echo '{"status":"info","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } else { + echo '{"status":"warn","message":"'.$warn['message'].'","modid":'.mysqli_insert_id($conn).'}'; + } + + } else { + echo '{"status":"succ","message":"Mod has been uploaded and saved.","modid":'.mysqli_insert_id($conn).'}'; + } + } else { + echo '{"status":"error","message":"Mod could not be added to database"}'; + } + } } else { echo '{"status":"error","message":"Permission denied! Open SSH and run chown -R www-data '.addslashes(dirname(dirname(get_included_files()[0]))).'"}'; } From 9c3472c4e1930fef40a9085a25750e2231e7c99b Mon Sep 17 00:00:00 2001 From: Kio Date: Fri, 3 Apr 2020 14:45:52 -0400 Subject: [PATCH 03/68] Remove Tawk.To You said it yourself on Discord - You're no longer interested in working on Solder. --- api/version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/version.json b/api/version.json index fc9ad84..95f2d35 100644 --- a/api/version.json +++ b/api/version.json @@ -1,7 +1,7 @@ { "version": "v1.3.0", "stream": "Release", - "warns": "

Warning! You shouldn't upload Optifine or Journey Map. If you want to use Journey Map, you should add it to the app as a remote mod. If you need more information, check http://journeymap.info/Technic or contact a human.

", + "warns": "

Warning! You shouldn't upload Optifine or Journey Map. If you want to use Journey Map, you should add it to the app as a remote mod. If you need more information, check http://journeymap.info/Technic

", "ltcl": "Improved security, Password encryption, Remote mods, Improved process of fetching Forge versions, Fixed bugs, Windows support, and more...", "changelog": "

v1.3.0

Description conming soon.

v1.2.1


You can now add not-compatible versions of mods to your builds
Menu Bars icon is shown instead of Technic Logo on narrower screens
Improved security
Fixed bug - Minecraft Version of a mod cannot be changed if it is the same string as it's Mod Version
Fixed Bug - The API sends latest build of your modpack to the user even if it's private

v1.2.0


Mods versions are now grouped by name - more versions of the same mod won't be displayed as separate mods
You can now migrate your modpacks from the original solder v0.8.0-beta using the automatic migration tool.
You can now download any mod you have uploaded to the application - .zip or .jar
You can now view content of any .zip file you have uploaded to the 'Other files' section

v1.1.2


Bootstrap is now stored locally

v1.1.1


Fixed checking for dev builds.

v1.1.0


Added Instant Modpack feature
Number of Downloads, Runs and likes are shown.
Modpack icons are shown
A warning message is shown when solder is unable to check for updates or connect to Technic.
Modpack Runs, Downloads, Likes and Icons are saved in a 30min cache.
Minor mod uploader changes.

v1.0.1


Fixed bug: Modpack is no longer set to private after using the 'Update Latest Version' button.

v1.0.0


resolder.php and platform.php scripts for solder verifier are now hosted by the user
Client IDs are now validated
Buttons for creating new build are now attached together
After over six months of work, Solder.cf is finished.
Happy new year!

v1.0.0.rc7


Side navigation is now hidden if the screen is narrower than 1000 pixels.
Dark theme is now stored in session, not the settings.php file

v1.0.0.rc6


Hidden notices and fixed php warnings.
Fixed Typo

v1.0.0.rc5


Fixed bug - Custom files are no longer marked as not compatible
Changed color of black check to green check when mod upload is successful.
Changed titles in Other Files section.

v1.0.0.rc4


Added script for database upgrading.

v1.0.0.rc3


Changed page titles.

v1.0.0.rc2


Additions:
  • Client management
  • Private modpacks and builds
  • Quick settings
  • Dark theme

Deletions:
  • Forge link verification - Fetching forge versions is now much faster
  • Sorting fetched forge versions

Changes and Fixes:" -} \ No newline at end of file +} From 43c49bcd905b18f5c1b4ba2fa1a4cf2cf356ebcd Mon Sep 17 00:00:00 2001 From: Kio Date: Fri, 3 Apr 2020 14:46:34 -0400 Subject: [PATCH 04/68] Update index.php --- index.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/index.php b/index.php index 4154be1..e4ba533 100644 --- a/index.php +++ b/index.php @@ -343,20 +343,6 @@ function uri($uri) { } else { $filecontents = file_get_contents('./api/version.json'); ?> - - - -