own3mall 5 лет назад
Родитель
Сommit
4fd9eebe26

+ 2 - 2
includes/helpers.php

@@ -429,14 +429,14 @@ function runPostUpdateOperations(){
 	}
 }
 
-function getOGPGitHubURL($gitHubUsername, $repo){
+function getOGPGitHubURL($gitHubUsername, $branch = "master", $repo){
 	$OGPGitHub = "https://github.com/OpenGamePanel/";
 	$gitHubURL = $OGPGitHub; 
 	if(isset($gitHubUsername) && !empty($gitHubUsername)){
 		$gitHubURL = "https://github.com/" . $gitHubUsername . "/"; 
 	}
 	
-	$paths[] = $gitHubURL . $repo . "/commits/master.atom";
+	$paths[] = $gitHubURL . $repo . "/commits/" . $branch . '.atom';
 	$exists = get_first_existing_file($paths);
 	if($exists !== false){
 		return $gitHubURL;

+ 3 - 0
lang/English/modules/settings.php

@@ -91,6 +91,9 @@ define('OGP_LANG_login_attempts_before_banned', "Number of failed login attempts
 define('OGP_LANG_login_attempts_before_banned_info', "If a user tries to login with invalid credentials more than this many times, the user will be banned temporarily by the panel.");
 define('OGP_LANG_custom_github_update_username', "GitHub update username");
 define('OGP_LANG_custom_github_update_username_info', "Enter your GitHub username ONLY to use your own forked repositories to update OGP. This should only be changed by developers who wish to use their own repos for development rather than checking in possibly buggy code into the main branch.");
+define('OGP_LANG_custom_github_update_branch_name', "GitHub branch name");
+define('OGP_LANG_custom_github_update_branch_name_info', "Enter the branch name you want to use for updating OGP. This should only be changed by developers who wish to use their own repos for development rather than checking in possibly buggy code into the main branch.  Leave this field blank to default to \"master\"");
+
 define('OGP_LANG_remote_query', "Remote query");
 define('OGP_LANG_remote_query_info', "Use the remote server (agent) to make queries to the game servers (Only GameQ and LGSL).");
 define('OGP_LANG_check_expiry_by', "Check expiration using");

+ 3 - 1
modules/extras/extras.php

@@ -417,7 +417,9 @@ function exec_ogp_module()
 			$isTheme = true;
 		}
 		
-		$REMOTE_REPO_FILE = $gitHubURL . $repository['name'] . '/commits/master.atom';
+		$gitHubBranchName = (!empty($settings['custom_github_update_branch_name']) ? $settings['custom_github_update_branch_name'] : 'master');
+		
+		$REMOTE_REPO_FILE = $gitHubURL . $repository['name'] . '/commits/' . $gitHubBranchName . '.atom';
 		$LOCAL_REPO_FILE = DATA_PATH . $repository['name'] . '.atom';
 		if(!file_exists($LOCAL_REPO_FILE) 
 			OR (isset($_GET['searchForUpdates']) and $_GET['searchForUpdates'] == $repository['name']) 

+ 2 - 0
modules/settings/settings.php

@@ -66,6 +66,7 @@ function exec_ogp_module()
 			"recaptcha_use_login" => $_REQUEST['recaptcha_use_login'],
 			"login_attempts_before_banned" => $_REQUEST['login_attempts_before_banned'],
 			"custom_github_update_username" => $_REQUEST['custom_github_update_username'],
+			"custom_github_update_branch_name" => $_REQUEST['custom_github_update_branch_name'],
 			"show_server_id_game_monitor" => $_REQUEST['show_server_id_game_monitor'],
 			"default_game_server_home_path_prefix" => $_REQUEST['default_game_server_home_path_prefix'],
 			"use_authorized_hosts" => $_REQUEST['use_authorized_hosts'],
@@ -176,6 +177,7 @@ function exec_ogp_module()
 	$ft->add_field('string','login_ban_time', array_key_exists("login_ban_time", $row) && !empty($row["login_ban_time"]) && is_numeric($row["login_ban_time"]) ? $row["login_ban_time"] : '');
 	
 	$ft->add_field('string','custom_github_update_username',@$row['custom_github_update_username']);
+	$ft->add_field('string','custom_github_update_branch_name',@$row['custom_github_update_branch_name']);
 	
 	$ft->add_field('on_off','show_server_id_game_monitor',@$row['show_server_id_game_monitor']);
 	

+ 7 - 4
modules/update/update.php

@@ -66,16 +66,18 @@ function exec_ogp_module()
 	// GitHub URL
 	if(function_exists("getOGPGitHubURL") && function_exists("getOGPGitHubURLUnstrict") && function_exists("getGitHubOrganization")){
 		$gitHubUsername = $settings["custom_github_update_username"];	
-		$gitHubURL = getOGPGitHubURL($gitHubUsername, REPONAME);
+		$gitHubBranch = $settings["custom_github_update_branch_name"];	
+		$gitHubURL = getOGPGitHubURL($gitHubUsername, $gitHubBranch, REPONAME);
 		$gitHubOrganization = getGitHubOrganization($gitHubURL);
 	}else{
 		$gitHubURL = "https://github.com/OpenGamePanel/";
 	}
 	
+	$gitHubBranchName = (!empty($settings['custom_github_update_branch_name']) ? $settings['custom_github_update_branch_name'] : 'master');
 	
-	define('RSS_REMOTE_PATH', $gitHubURL . REPONAME . '/commits/master.atom');
+	define('RSS_REMOTE_PATH', $gitHubURL . REPONAME . '/commits/' . $gitHubBranchName . '.atom');
 	define('MODULE_PATH', 'modules/'.$_GET['m'].'/');
-	define('RSS_LOCAL_PATH', MODULE_PATH.'master.atom');
+	define('RSS_LOCAL_PATH', MODULE_PATH . $gitHubBranchName . '.atom');
 		
 	if( is_writable(MODULE_PATH) )
 	{
@@ -155,6 +157,7 @@ function exec_ogp_module()
 					$commitsToShow = 5;
 					
 					$gitHubUpdateName = (!empty($settings['custom_github_update_username']) ? $settings['custom_github_update_username'] : 'OpenGamePanel');
+					
 					$ch = curl_init();
 					curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/'.$gitHubUpdateName.'/'.REPONAME.'/commits');
 					curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0');
@@ -175,7 +178,7 @@ function exec_ogp_module()
 								echo '<b>'.str_replace("*", "<br><br>", $v['commit']['message']) .'</b></li><br>';
 								++$commitsStart;
 							}
-							echo '</ul><a href="https://github.com/'.$gitHubUpdateName.'/'.REPONAME.'/commits/master" target="_blank">View more commits...</a>';
+							echo '</ul><a href="https://github.com/'.$gitHubUpdateName.'/'.REPONAME.'/commits/' . $gitHubBranchName . '" target="_blank">View more commits...</a>';
 						}
 					}
 				}

+ 2 - 1
modules/update/updating.php

@@ -50,7 +50,8 @@ function exec_ogp_module()
 	// GitHub URL
 	if(function_exists("getOGPGitHubURL") && function_exists("getOGPGitHubURLUnstrict")){
 		$gitHubUsername = $settings["custom_github_update_username"];	
-		$gitHubURL = getOGPGitHubURL($gitHubUsername, REPONAME);
+		$gitHubBranch = $settings["custom_github_update_branch_name"];	
+		$gitHubURL = getOGPGitHubURL($gitHubUsername, $gitHubBranch, REPONAME);
 	}else{
 		$gitHubURL = "https://github.com/OpenGamePanel/";
 	}