瀏覽代碼

Fixes in Blacklist Check for Extras

own3mall 9 年之前
父節點
當前提交
44e8d08795
共有 2 個文件被更改,包括 15 次插入5 次删除
  1. 9 0
      includes/helpers.php
  2. 6 5
      modules/extras/extras.php

+ 9 - 0
includes/helpers.php

@@ -358,4 +358,13 @@ function getOGPGitHubURL($gitHubURL){
 	return $gitHubURL;
 }
 
+function getGitHubOrganization($gitHubURL){
+	$gitHubOrg = "OpenGamePanel";
+	$githubCom = "github.com";
+	if(substr($gitHubURL, -1) == "/" && stripos($gitHubURL, $githubCom) !== false){
+		$gitHubOrg = substr($gitHubURL, stripos($gitHubURL, $githubCom) + strlen($githubCom) + 2);
+	}
+	return $gitHubOrg;
+}
+
 ?>

+ 6 - 5
modules/extras/extras.php

@@ -101,8 +101,8 @@ function installUpdate($info, $base_dir)
 			
 			if( file_exists( $web_file ) )
 			{
-				echo "/" . $web_file;
-				if(!in_array("/" . $web_file, $current_blacklist)){
+				echo $filename . "\n";
+				if(!in_array($filename, $current_blacklist)){
 					$temp = file_get_contents($temp_file);
 					$web = file_get_contents($web_file);
 					
@@ -241,11 +241,12 @@ function exec_ogp_module()
 			$current_blacklist[] = $blacklisted_file['file_path'];
 		}			
 	}
-	print_r($current_blacklist);
 	
 	// GitHub URL
 	$gitHubURL = $settings["custom_github_update_URL"];	
 	$gitHubURL = getOGPGitHubURL($gitHubURL);
+	$gitHubOrganization = getGitHubOrganization($gitHubURL);
+	echo "<p>GitHub Org is " . $gitHubOrganization . "</p>";
 	
 	set_time_limit(0);
 	$baseDir = str_replace( "modules" . DIRECTORY_SEPARATOR . $_GET['m'],"",dirname(__FILE__) );
@@ -296,7 +297,7 @@ function exec_ogp_module()
 	}
 	#return;
 	define('REPO_FILE', DATA_PATH . "repos");
-	define('URL', 'https://api.github.com/orgs/OpenGamePanel/repos'); // Returns detailed information of all repositories, and urls for more detailed informations about. Nice API GitHub! :)
+	define('URL', 'https://api.github.com/orgs/' . $gitHubOrganization . '/repos'); // Returns detailed information of all repositories, and urls for more detailed informations about. Nice API GitHub! :)
 	if(!file_exists(REPO_FILE) or isset($_GET['searchForUpdates']) or isset($_POST['update']))
 	{
 		# Without this $context the file_get_contents function was returning HTTP/1.0 403 Forbidden
@@ -406,7 +407,7 @@ function exec_ogp_module()
 			}
 		}
 		
-		if( ! $contents )
+		if( ! $contents && !isset($_GET["type"]) )
 		{
 			print_failure('Unable to get contents from : ' . $used_file);
 			continue;