Skip to content

Commit

Permalink
fix php dl ; next is rm not empty dir ; udpate process needs test (ph…
Browse files Browse the repository at this point in the history
…p -> js -> py)
  • Loading branch information
froger-me committed Jan 10, 2024
1 parent fa6d030 commit 80a578a
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions integration/dummy-generic/wppus-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ private static function send_api_request( $action, $args = array() ) {
# build the request url
$full_url = self::$url . '/' . $action . '/?' . http_build_query( $args );

echo $full_url . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

# initialize cURL
$ch = curl_init(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_init

Expand All @@ -112,10 +110,10 @@ private static function check_for_updates() {
$endpoint = 'wppus-update-api';
$args = array(
'action' => 'get_metadata',
'package_id' => rawurlencode( self::$package_name ),
'installed_version' => rawurlencode( self::$version ),
'license_key' => rawurlencode( self::$license_key ),
'license_signature' => rawurlencode( self::$license_signature ),
'package_id' => self::$package_name,
'installed_version' => self::$version,
'license_key' => self::$license_key,
'license_signature' => self::$license_signature,
'update_type' => 'Generic',
);
# make the request
Expand All @@ -130,9 +128,9 @@ public static function activate() {
$endpoint = 'wppus-license-api';
$args = array(
'action' => 'activate',
'license_key' => rawurlencode( self::$license_key ),
'allowed_domains' => rawurlencode( self::$domain ),
'package_slug' => rawurlencode( self::$package_name ),
'license_key' => self::$license_key,
'allowed_domains' => self::$domain,
'package_slug' => self::$package_name,
);
# make the request
$response = self::send_api_request( $endpoint, $args );
Expand All @@ -151,9 +149,9 @@ public static function deactivate() {
$endpoint = 'wppus-license-api';
$args = array(
'action' => 'deactivate',
'license_key' => rawurlencode( self::$license_key ),
'allowed_domains' => rawurlencode( self::$domain ),
'package_slug' => rawurlencode( self::$package_name ),
'license_key' => self::$license_key,
'allowed_domains' => self::$domain,
'package_slug' => self::$package_name,
);
# make the request
self::send_api_request( $endpoint, $args );
Expand All @@ -168,7 +166,7 @@ public static function deactivate() {
private static function download_update( $response ) {
$response = json_decode( $response, true );
# get the download url from the response
$url = isset( $response['download_url'] ) ? rawurldecode( $response['download_url'] ) : '';
$url = isset( $response['download_url'] ) ? $response['download_url'] : '';
# set the path to the downloaded file
$output_file = '/tmp/' . self::$package_name . '.zip';

Expand Down Expand Up @@ -229,7 +227,7 @@ public static function update() {

# check if the file starts with the package name
if ( substr( basename( $file ), 0, strlen( self::$package_name ) + 1 ) === self::$package_name . '.' ) {
chmod( $octal_mode, $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_chmod
chmod( $file, $octal_mode ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_chmod
}
}

Expand Down

0 comments on commit 80a578a

Please sign in to comment.