瀏覽代碼

Lowercase Constants Only, Cleanup of Old Files After Update, Minor Changes

own3mall 8 年之前
父節點
當前提交
4ec3a3ff66
共有 3 個文件被更改,包括 32 次插入10 次删除
  1. 27 7
      includes/helpers.php
  2. 4 3
      includes/view.php
  3. 1 0
      modules/update/updating.php

+ 27 - 7
includes/helpers.php

@@ -337,16 +337,20 @@ function removeOldGameConfigs(){ // Wrote this function in-case we rename config
 	);
 	
 	foreach($oldConfigsToRemove as $config){
-		if(file_exists($config)){
-			unlink($config);
-		}else{
-			if(file_exists(__DIR__ . "/../" . $config)){
-				unlink($config);
-			}
-		}
+		recursiveDelete($config);
 	}	 
 }
 
+function removeOldPanelFiles(){ // Should run post panel update to remove old files that are no longer users
+	$oldFiles = array(
+		'includes/database_mysql.php', 
+	);
+	
+	foreach($oldFiles as $file){
+		recursiveDelete($file);
+	}	
+}
+
 function getOGPGitHubURL($gitHubUsername, $repo){
 	$OGPGitHub = "https://github.com/OpenGamePanel/";
 	$gitHubURL = $OGPGitHub; 
@@ -393,4 +397,20 @@ function getGitHubOrganization($gitHubURL){
 	return $gitHubOrg;
 }
 
+function getOGPLangConstantsJSON(){
+	$finalConsts = array();
+	$consts = get_defined_constants(true);
+	foreach($consts["user"] as $key => $value){
+		if(strtolower($key) == $key){
+			$finalConsts[$key] = $value;
+		}
+	}
+	
+	if(count($finalConsts) > 0){
+		return json_encode(utf8ize($finalConsts));
+	}
+	
+	return false;
+}
+
 ?>

+ 4 - 3
includes/view.php

@@ -154,9 +154,10 @@ class OGPView {
 		$this->header_code .= '<script type="text/javascript" src="js/jquery/plugins/jquery.quicksearch.js"></script>' . "\n";
 		
 		// Dump defined constants to json (for language javascript)
-		$consts = get_defined_constants(true);
-		$jsonStrConsts = json_encode(utf8ize($consts["user"]));
-		$this->header_code .= '<script type="text/javascript">var langConsts = ' . $jsonStrConsts . ';</script>' . "\n";
+		$jsonStrConsts = getOGPLangConstantsJSON();
+		if($jsonStrConsts !== false){
+			$this->header_code .= '<script type="text/javascript">var langConsts = ' . $jsonStrConsts . ';</script>' . "\n";
+		}
 		
 		// Include our global JS
 		$this->header_code .= '<script type="text/javascript" src="js/global.js"></script>' . "\n";

+ 1 - 0
modules/update/updating.php

@@ -269,6 +269,7 @@ function exec_ogp_module()
 					update_module($db, $row['id'], $row['folder']);
 				}
 				print_success(update_complete); 
+				removeOldPanelFiles();
 			}
 			else
 			{