diff --git a/app/Http/Controllers/Api/TG/HookController.php b/app/Http/Controllers/Api/TG/HookController.php index bfc12ad..b857d16 100755 --- a/app/Http/Controllers/Api/TG/HookController.php +++ b/app/Http/Controllers/Api/TG/HookController.php @@ -35,11 +35,11 @@ final class HookController $sText = $aUpdate["message"]["text"]; - if (isset($aUpdate["is_dove"])) { - $sSendType = "dove"; - } else { - $sSendType = false; - } +// if (isset($aUpdate["is_dove"])) { +// $sSendType = "dove"; +// } else { +// $sSendType = false; +// } // var_dump($sSendType); // exit; // test @@ -79,10 +79,10 @@ final class HookController // 返回可以是数组 if (is_array($r)) { foreach ($r as $row) { - $oTGHttp->sendToTG($row, $sSendType); + $oTGHttp->sendToTG($row, $aUpdate); } } else { - $oTGHttp->sendToTG($r, $sSendType); + $oTGHttp->sendToTG($r, $aUpdate); } Http::response(200); @@ -95,7 +95,7 @@ final class HookController } catch (\Throwable $e) { $sMessage = "错误(文件: " . $e->getFile() . ",行: " . $e->getLine() . "): " . $e->getMessage(); - $oTGHttp->sendToTG($sMessage, $sSendType); + $oTGHttp->sendToTG($sMessage, $aUpdate); Http::response(200, 'error'); } diff --git a/app/Http/Controllers/CronController.php b/app/Http/Controllers/CronController.php index 0e2c85c..a835b3a 100755 --- a/app/Http/Controllers/CronController.php +++ b/app/Http/Controllers/CronController.php @@ -6,7 +6,9 @@ use Illuminate\Http\Request; use App\Models\Article; use App\Models\Option; use App\Services\TG\Http as TGHttp; +use App\Services\TomTool\Http as Http; use App\Services\Github\Github as ServiceGithub; +use App\Services\Github\Blade as ServiceBlade; class CronController { @@ -21,6 +23,8 @@ class CronController private $aArticle; + private $isTest = 0; + public function index() { try { @@ -29,20 +33,24 @@ class CronController $i = date("i"); $s = date("s"); $iRand = rand(1, 1440); + $aUpdate = []; +// $isTest = 0; //test $aGet = $_GET; if (isset($aGet['is_test']) && $aGet['is_test'] == 1) { $isTest = 1; + $this->isTest = 1; + $aUpdate["shell"] = "cmd"; if ($aGet["time_type"] == 'i') { $i = (string) $aGet['v']; } else if ($aGet["time_type"] == 'h') { $h = (string) $aGet['v']; } else if ($aGet["time_type"] == "rand") { $iRand = $aGet["v"]; + } else if ($aGet["time_type"] == "id") { + $iTestId = $aGet["v"]; } - } else { - $isTest = 0; } // 暂停 @@ -52,6 +60,17 @@ class CronController exit("暂停"); } + // id测试 + if (isset($iTestId)) { + $aArticle = Article::where("id", $iTestId)->get()->toArray(); + if (!empty($aArticle)) { + $this->run($aArticle); + } else { + exit("这个id没找到"); + } + exit; + } + // i_in10规则 $iIin10 = $i[1]; $aArticle = Article::where("i_in10", $iIin10)->where("status", 1)->get()->toArray(); @@ -93,7 +112,7 @@ class CronController $sMessage = "错误(文件: " . $e->getFile() . ",行: " . $e->getLine() . "): " . $e->getMessage(); $oTGHttp = new TGHttp(); - $oTGHttp->sendToTG($sMessage); + $oTGHttp->sendToTG($sMessage, $aUpdate); } @@ -109,8 +128,26 @@ class CronController $this->sProjectPath = env("BASE_DIR")."github/".$this->sUserName."-".$this->sProjectName; $this->sProjectUrl = "git@".$this->sMailName.".com:".$this->sUserName."/".$this->sProjectName.".git"; $this->aArticle = $row; + $aArticleRow = $row; + $sModType = $row["mod_type"] ?? "v1"; + $sMod = $row["mod"]; - $sReadMe = ServiceGithub::GetReadMe($row); + // 获取文章的方式 + if ($sModType == "v1") { + + $sReadMe = ServiceGithub::GetReadMe($row); + + // 新版 + } else { + + $oHttp = new Http(); + $oHttp->sMethod = "post"; + $sMasterUrl = "https://".env("www_master")."/api/github/get"; +// $oHttp->bIsJson = true; + $oHttp->aData = $row; + $sReadMe = $oHttp->send($sMasterUrl); + + } // 没有文件夹,创建一个 if (!is_dir($this->sProjectPath)) { @@ -134,9 +171,15 @@ class CronController } file_put_contents($this->sProjectPath."/version.text", time()); - + // 提交 - $this->gitPush(); + if ($this->isTest == 1) { + $content = file_get_contents($this->sProjectPath."/README.md"); + echo $content; + exit; + } else { + $this->gitPush(); + } } } @@ -176,7 +219,7 @@ class CronController private function formatstr($str) { - $str = substr($str, 1, -1); +// $str = substr($str, 1, -1); return $str; } diff --git a/app/Http/Controllers/TestsController.php b/app/Http/Controllers/TestsController.php index 3cc58c5..8549e25 100755 --- a/app/Http/Controllers/TestsController.php +++ b/app/Http/Controllers/TestsController.php @@ -17,44 +17,6 @@ class TestsController public function hook($sHostName = 'ssssss') { - -// // 定义要添加的配置 -// $host = $sHostName; -// $hostname = "github.com"; -// $user = "git"; -// $identityFile = env("path_ssh")."/id_rsa_".$sHostName; -// -// // 构建配置字符串 -// $config = "\nHost ".$host.".com\n"; -// $config .= "\tHostName $hostname\n"; -// $config .= "\tUser $user\n"; -// $config .= "\tIdentityFile $identityFile\n"; -// -// // 指定 SSH 配置文件路径 -// $sshConfigFile = env("path_ssh")."/config"; -// -// // 检查文件是否存在,如果不存在则创建 -// if (!file_exists($sshConfigFile)) { -// touch($sshConfigFile); -// } -// -// // 追加配置到文件 -// file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX); -// -// // 设置文件权限 -// chmod($sshConfigFile, 0600); -// -// echo "SSH config updated successfully."; - - - - -// exit; -// $t = []; -// $a = $t['zz']["cc"] += 10; -// $a = $t['zz']["cc"] += 10; -// tomd($a); -// exit; @$k = $_GET["k"]; @$s = $_GET["s"]; @@ -62,17 +24,14 @@ class TestsController // exit("?"); // } - $s = '/'.$s; - - //test -// $s = "\/AticleSet__1115zz__sale_rate 1118.118"; -// $s = "\/git#LastTime 1"; $s= "/test#cron__i 07"; $s = "/dog#list"; $s = "/dog#github 1002"; + $s = "/test#cron__rand 1"; + $oHttp = new Http(); $oHttp->sMethod = "post"; $oHttp->sToUrl = env("APP_URL")."/api/tg/hook"; diff --git a/app/Models/Blade.php b/app/Models/Blade.php new file mode 100755 index 0000000..862ec09 --- /dev/null +++ b/app/Models/Blade.php @@ -0,0 +1,21 @@ +toArray(); + + foreach ($aSelf as &$aSelfRow) { + unset($aSelfRow["content"]); + } + + return $aSelf; + } +} diff --git a/app/Services/Github/Blade.php b/app/Services/Github/Blade.php new file mode 100644 index 0000000..33013f6 --- /dev/null +++ b/app/Services/Github/Blade.php @@ -0,0 +1,146 @@ +sMethod = "get"; + $oHttp->bIsJson = true; + $sDateNow = date("Y-m-d"); + $sMasterUrl = "https://".env("www_master")."/api/ship/get/".$aArticle["ship_code"]."/github/".$aArticle["user_name"]."-".$aArticle["project_name"]; + $sShip = $oHttp->send($sMasterUrl); + $aShip = json_decode($sShip, true); + + $ship_name = $aShip["name"]; + $ship_www = $aShip["www"]; + $ship_good = $this->goodToStr($aShip["good"]); + $ship_have_huodong = $aShip["have_huodong"]; + $ship_huodong_str = $aShip["huodong"]["str"] ?? false; + //// ship系列end + + //// rand 系列 + //// good pool系列 + // 随机good,预留 + $oHttp = new Http(); + $oHttp->sMethod = "get"; + $sMasterUrl = "https://".env("www_master")."/api/good/rand/".$dog_ship_code; + $oHttp->bIsJson = true; + $sGood = $oHttp->send($sMasterUrl); + $aGood = json_decode($sGood, true); + + $rand_good = $this->goodToStr($aGood["good"]); + + + + tomd($rand_good, 1); + + + +// $ship_www = + +// $aArticle["ex_ship"] = $aShip; +// $aArticle["ex_ship_name"] = $aShip["name"]; +// $aArticle["ex_ship_www"] = $aShip["www"]; +// +// +// +// +// +// +// +// $aArticle["ex_feed_v2ray_url"] = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt"; +// $aArticle["ex_feed_clash_url"] = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml"; +// +// $aArticle["ex_ship"] = $aShip; +// $aArticle["ex_ship_name"] = $aShip["name"]; +// $aArticle["ex_ship_www"] = $aShip["www"]; + + + +// tomd($aArticle); + +// $oBlade = ModelBlade::all(); + +// tomd($oBlade, 1); + + + + +// echo eval(""); +// echo 123; +// exit; + $zz = "???"; + + $s = "zabc{$this->date('Y-m-d')}defg"; + + return $s; + + + + + +// $r = $this->GetShip($aArticle); + + tomd($r, 1); + echo "balzzzzde"; + exit; + } + +} diff --git a/app/Services/Github/Github.php b/app/Services/Github/Github.php index 86b7552..2389e7d 100644 --- a/app/Services/Github/Github.php +++ b/app/Services/Github/Github.php @@ -13,22 +13,43 @@ class Github { $sClass = "App\\Services\\Github\\Mod\\".$sClassDir."\\".$sClass; $sFunc = "Get"; - + if (method_exists($sClass, $sFunc)) { // tomd($sClass, 1); $oInstans = new $sClass(); // $oInstans->aHuodong = self::GetHuodong($aArticle); - $oInstans->aShip = self::GetShip($aArticle); + + $aShip = self::GetShip($aArticle); + + $oInstans->aShip = $aShip; // 之前脑残了,这个思路傻逼,直接补充$aArticle就行了 + + $aArticle = self::ArticleEx($aArticle, $aShip); // 难看就难看吧,兼容一下 + $sReadMe = $oInstans->$sFunc($aArticle); + return $sReadMe; + } else { // 模版里可以返回false,但不能没有模版 throw new \Exception("没找到这个模版:".$sClass."\\".$sFunc); -// return false; } } + + // 扩展都往里这里来 + public static function ArticleEx($aArticle, $aShip) + { + $aArticle["ex_feed_v2ray_url"] = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt"; + $aArticle["ex_feed_clash_url"] = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml"; + + $aArticle["ex_ship"] = $aShip; + $aArticle["ex_ship_name"] = $aShip["name"]; + $aArticle["ex_ship_www"] = $aShip["www"]; + + return $aArticle; + } + public static function GetShip($aArticle) { $oHttp = new Http(); @@ -40,6 +61,22 @@ class Github { $sShip = $oHttp->send($sMasterUrl); $aShip = json_decode($sShip, true); + $aGood = json_decode($aShip["good"], true); +// tomd($aShip, 1); + $sGoodStr = ""; + $i = 0; + foreach ($aGood as $row) { + if ($i !== 0) { + $sGoodStr .= " + +"; + } + $sGoodStr .= $row; + $i++; + } + + $aShip["good_str"] = $sGoodStr; + $aShip["youhui_str"] = "购买套餐时输入【".$aArticle['sale_code']."】优惠码,可享".$aArticle['sale_rate']."折优惠,折后低至8元/月。"; if (isset($aShip["huodong"]["str"]) && !empty($aShip["huodong"]["str"])) { @@ -48,12 +85,14 @@ class Github { ".$aShip["huodong"]["str"]; } -// tomd(empty($aShip["huodong"]["str"]), 1); -// tomd($aShip, 1); - return $aShip; } +// public static GetFeedV2ray($aArticle) +// { +// +// } + // public static function GetHuodong($aArticle) // { diff --git a/app/Services/Github/Mod/FreeNode/C.php b/app/Services/Github/Mod/FreeNode/C.php index dff2a4f..d7212d4 100755 --- a/app/Services/Github/Mod/FreeNode/C.php +++ b/app/Services/Github/Mod/FreeNode/C.php @@ -10,15 +10,9 @@ class C extends Base { public function Get($aArticle) { - -// if (!$this->todayUpd()) { -// return false; -// } - + $aFreenodeCountry = $this->getFreenodeCountryFromMaster(); -// tomd($aFreenodeCountry, 1); - $sContent = " # 公益免费v2ray/clash节点订阅,每小时更新,最后更新时间:".date('Y-m-d H:i:s')." diff --git a/app/Services/Github/Mod/FreeNode/D.php b/app/Services/Github/Mod/FreeNode/D.php new file mode 100755 index 0000000..32583f9 --- /dev/null +++ b/app/Services/Github/Mod/FreeNode/D.php @@ -0,0 +1,71 @@ +todayUpd()) { +// return false; +// } + +// tomd($aArticle, 1); + + $sContent = "# 免费v2ray/clash节点订阅 每日自动更新 +翻墙、免费翻墙、免费科学上网、免费节点、免费梯子、免费ss/v2ray/trojan节点、蓝灯、谷歌商店、翻墙梯子 + +免费节点来自:".$aArticle["fn_www"]." + +## 客户端下载 + +| 名称 | 操作系统 | 地址 | +|------|----------|------| +| SingBox | Mac/Linux/Android/Ios | [https://sing-box.sagernet.org/clients/](https://sing-box.sagernet.org/clients/) | +| FlClash | Mac/Linux/Windows/Android | [https://github.com/chen08209/FlClash](https://github.com/chen08209/FlClash) | +| Clash Verge | Mac/Linux/Windows | [https://github.com/clash-verge-rev/clash-verge-rev](https://github.com/clash-verge-rev/clash-verge-rev) | +| Clash Meta Android | Android | [https://github.com/MetaCubeX/ClashMetaForAndroid](https://github.com/MetaCubeX/ClashMetaForAndroid) | +| ClashX Meta | Mac | [https://github.com/MetaCubeX/ClashX.Meta](https://github.com/MetaCubeX/ClashX.Meta) | +| V2RayN | Windows | [https://github.com/2dust/v2rayN](https://github.com/2dust/v2rayN) | +| V2RayNG | Android | [https://github.com/2dust/v2rayNG](https://github.com/2dust/v2rayNG) | +| V2RayU | Mac | [https://github.com/yanue/V2rayU](https://github.com/yanue/V2rayU) | + +## 订阅链接: + +### Clash订阅链接 + +- ".$aArticle["ex_feed_clash_url"]." + +### V2ray订阅链接 + +- ".$aArticle["ex_feed_v2ray_url"]." + +## 更多clash节点订阅 : + +### 性价比机场推荐:[".$aArticle["ex_ship_name"]."](https://".$aArticle["ex_ship_www"].") + +".$aArticle["ex_ship"]["good_str"]." + +".$aArticle["ex_ship"]["youhui_str"]." + +点击进入[".$aArticle["ex_ship_www"]."机场官网](https://".$aArticle["ex_ship_www"].")。 + +#### 更新于:".date("Y-m-d H:i:s"); + +// $t = ["test1","test2"]; +// $t = json_encode($t); +// +// tomd($t, 1); + + tomd($sContent, 1); + + return $sContent; + + } + +} diff --git a/app/Services/TG/Hook/Mod/Blade.php b/app/Services/TG/Hook/Mod/Blade.php new file mode 100644 index 0000000..04791e8 --- /dev/null +++ b/app/Services/TG/Hook/Mod/Blade.php @@ -0,0 +1,69 @@ +content); + unset($oBladeRow->id); + } + + return $oBlade; + } + + public function List() + { + $oBlade = ModelBlade::all(); + $oBlade = $this->filter($oBlade); + + return $this->toJson($oBlade); + } + + public function Find($aParam) + { + $sField = $aParam["aOption"][1] ?? "id"; + $sValue = $aParam["aArg"][1] ?? false; + + if ($sValue == "?") { + return "/blade#find__{field?} {value}"; + } + + $oBlade = ModelBlade::where($sField, $sValue)->first(); + + return $oBlade->content; + } + + public function Like($aParam) + { + $sField = $aParam["aOption"][1] ?? false; + $sValue = $aParam["aArg"][1] ?? false; + + if ($sValue == "?") { + return "/blade#like__{field} {value}"; + } + + if (!$sField) { + return "需要field"; + } + + if (!$sValue) { + return "需要value"; + } + + $oBlade = ModelBlade::where($sField, "like", "%".$sValue."%")->get(); + + $oBlade = $this->filter($oBlade); + + return $this->toJson($oBlade); + } + + public function Del($aParam) + { + $sCode = $aParam["aArg"][] + } + +} diff --git a/app/Services/TG/Hook/Mod/Db.php b/app/Services/TG/Hook/Mod/Db.php new file mode 100644 index 0000000..bf56e89 --- /dev/null +++ b/app/Services/TG/Hook/Mod/Db.php @@ -0,0 +1,35 @@ +oHttp->sMethod = "get"; $this->oHttp->sToUrl = env("APP_URL")."/cron"; $this->oHttp->bIsJson = true; $this->oHttp->aData = [ - "is_test" => true, + "is_test" => $is_test, "time_type" => $sTimeType, "v" => $sValue ]; diff --git a/app/Services/TG/Http.php b/app/Services/TG/Http.php index 1f463d4..589ab54 100644 --- a/app/Services/TG/Http.php +++ b/app/Services/TG/Http.php @@ -13,29 +13,33 @@ class Http { $this->sApiChatId = env('telegram_chatid'); } - public function sendToTG($sMsg, $mType = false) + public function sendToTG($sMsg, $aUpdate = []) { -// var_dump($mType); -// exit; - - if ($mType == "dove") { + if (isset($aUpdate["shell"]) && $aUpdate["shell"] == "cmd") { + + echo $sMsg; - if (env("is_loc") == true) { - echo "
";
- }
+ } else if (isset($aUpdate["is_dove"]) && $aUpdate["is_dove"] == true) {
echo $sMsg;
} else {
if (env("is_loc") == true) {
- echo "";
- echo($sMsg);
+ echo $sMsg;
} else {
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
file_get_contents($url);
}
+
+// if (env("is_loc") == true) {
+// echo "";
+// echo $sMsg;
+// } else {
+// $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
+// file_get_contents($url);
+// }
}