Skip to content

Commit

Permalink
Move QuickPick constants to root.php and update references
Browse files Browse the repository at this point in the history
  • Loading branch information
N6REJ committed Dec 23, 2024
1 parent 2ff42f4 commit 6aadffc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
16 changes: 3 additions & 13 deletions core/classes/actions/class.action.quickPick.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
*/
class QuickPick
{
// Membership Pro api key & url
const API_KEY = '4abe15e5-95f2-4663-ad12-eadb245b28b4';
const API_URL = 'https://bearsampp.com/index.php?option=com_osmembership&task=api.get_active_plan_ids&api_key=';

// URL where quickpick-releases.json lives.
const JSON_URL = 'https://raw.githubusercontent.com/Bearsampp/Bearsampp/main/core/resources/quickpick-releases.json';

/**
* @var array $modules
*
Expand Down Expand Up @@ -136,7 +129,7 @@ public function checkQuickpickJson()
}

// Get the creation time of the remote file
$headers = get_headers( self::JSON_URL, 1 );
$headers = get_headers( QUICKPICK_JSON_URL, 1 );
if ( $headers === false || !isset( $headers['Last-Modified'] ) ) {
// If we cannot get the headers or Last-Modified is not set, assume no update is needed
return false;
Expand Down Expand Up @@ -186,11 +179,8 @@ public function rebuildQuickpickJson(): array
{
Util::logDebug( 'Fetching JSON file: ' . $this->jsonFilePath );

// Define the URL of the remote JSON file
$url = self::JSON_URL;

// Fetch the JSON content from the URL
$jsonContent = file_get_contents( $url );
$jsonContent = file_get_contents( QUICKPICK_JSON_URL );

if ( $jsonContent === false ) {
// Handle error if the file could not be fetched
Expand Down Expand Up @@ -317,7 +307,7 @@ public function checkDownloadId(): bool
return false;
}

$url = self::API_URL . self::API_KEY . '&download_id=' . $DownloadId;
$url = QUICKPICK_API_URL . QUICKPICK_API_KEY . '&download_id=' . $DownloadId;
Util::logDebug( 'API URL: ' . $url );

$response = @file_get_contents( $url );
Expand Down
26 changes: 17 additions & 9 deletions core/root.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@
* Website: https://bearsampp.com
* Github: https://github.com/Bearsampp
*/

/**
* Defines constants used throughout the Bearsampp application.
*/
define('APP_AUTHOR_NAME', 'N6REJ');
define('APP_TITLE', 'Bearsampp');
define('APP_WEBSITE', 'https://bearsampp.com');
define('APP_LICENSE', 'GPL3 License');
define('APP_GITHUB_USER', 'Bearsampp');
define('APP_GITHUB_REPO', 'Bearsampp');
define('APP_GITHUB_USERAGENT', 'Bearsampp');
define('APP_GITHUB_LATEST_URL', 'https://api.github.com/repos/' . APP_GITHUB_USER . '/' . APP_GITHUB_REPO . '/releases/latest');
define('RETURN_TAB', ' ');
const APP_AUTHOR_NAME = 'N6REJ';
const APP_TITLE = 'Bearsampp';
const APP_WEBSITE = 'https://bearsampp.com';
const APP_LICENSE = 'GPL3 License';
const APP_GITHUB_USER = 'Bearsampp';
const APP_GITHUB_REPO = 'Bearsampp';
const APP_GITHUB_USERAGENT = 'Bearsampp';
const APP_GITHUB_LATEST_URL = 'https://api.github.com/repos/' . APP_GITHUB_USER . '/' . APP_GITHUB_REPO . '/releases/latest';
const RETURN_TAB = ' ';

// Membership Pro API key & URL
const QUICKPICK_API_KEY = '4abe15e5-95f2-4663-ad12-eadb245b28b4';
const QUICKPICK_API_URL = 'https://bearsampp.com/index.php?option=com_osmembership&task=api.get_active_plan_ids&api_key=';

// URL where quickpick-releases.json lives
const QUICKPICK_JSON_URL = 'https://raw.githubusercontent.com/Bearsampp/Bearsampp/main/core/resources/quickpick-releases.json';

/**
* Includes the Root class file and creates an instance of Root.
Expand Down

0 comments on commit 6aadffc

Please sign in to comment.