Changeset 2778568
- Timestamp:
- 09/01/2022 05:33:37 AM (4 years ago)
- Location:
- crowdaa-sync
- Files:
-
- 7 edited
- 74 copied
-
tags/1.4.1 (copied) (copied from crowdaa-sync/trunk)
-
tags/1.4.1/CHANGELOG (copied) (copied from crowdaa-sync/trunk/CHANGELOG) (1 diff)
-
tags/1.4.1/LICENSE.txt (copied) (copied from crowdaa-sync/trunk/LICENSE.txt)
-
tags/1.4.1/README.txt (copied) (copied from crowdaa-sync/trunk/README.txt) (1 diff)
-
tags/1.4.1/admin (copied) (copied from crowdaa-sync/trunk/admin)
-
tags/1.4.1/admin/class-crowdaa-sync-add-info-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-api.php)
-
tags/1.4.1/admin/class-crowdaa-sync-add-info-wp.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-wp.php)
-
tags/1.4.1/admin/class-crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-admin-display.php) (1 diff)
-
tags/1.4.1/admin/class-crowdaa-sync-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-api.php)
-
tags/1.4.1/admin/class-crowdaa-sync-ext-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-ext-hooks.php)
-
tags/1.4.1/admin/class-crowdaa-sync-meta-box.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-meta-box.php)
-
tags/1.4.1/admin/class-crowdaa-sync-rest-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-rest-api.php)
-
tags/1.4.1/admin/class-crowdaa-sync-wp-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php)
-
tags/1.4.1/admin/css/crowdaa-sync-admin.css (copied) (copied from crowdaa-sync/trunk/admin/css/crowdaa-sync-admin.css)
-
tags/1.4.1/admin/js/crowdaa-sync-admin.js (copied) (copied from crowdaa-sync/trunk/admin/js/crowdaa-sync-admin.js) (1 diff)
-
tags/1.4.1/admin/partials/crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/partials/crowdaa-sync-admin-display.php) (3 diffs)
-
tags/1.4.1/cacert.pem (copied) (copied from crowdaa-sync/trunk/cacert.pem)
-
tags/1.4.1/composer.json (copied) (copied from crowdaa-sync/trunk/composer.json)
-
tags/1.4.1/crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/crowdaa-sync.php) (2 diffs)
-
tags/1.4.1/includes (copied) (copied from crowdaa-sync/trunk/includes)
-
tags/1.4.1/includes/class-crowdaa-sync-exception.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-exception.php)
-
tags/1.4.1/includes/class-crowdaa-sync-permissions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-permissions.php)
-
tags/1.4.1/includes/class-crowdaa-sync-syncdb.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-syncdb.php)
-
tags/1.4.1/includes/class-crowdaa-sync-timer.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-timer.php)
-
tags/1.4.1/includes/class-crowdaa-sync-utils.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-utils.php) (1 diff)
-
tags/1.4.1/includes/class-crowdaa-sync-versions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-versions.php)
-
tags/1.4.1/includes/class-crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync.php)
-
tags/1.4.1/index.php (copied) (copied from crowdaa-sync/trunk/index.php)
-
tags/1.4.1/languages (copied) (copied from crowdaa-sync/trunk/languages)
-
tags/1.4.1/public (copied) (copied from crowdaa-sync/trunk/public)
-
tags/1.4.1/uninstall.php (copied) (copied from crowdaa-sync/trunk/uninstall.php)
-
tags/1.4.1/vendor (copied) (copied from crowdaa-sync/trunk/vendor)
-
tags/1.4.1/vendor/bin (copied) (copied from crowdaa-sync/trunk/vendor/bin)
-
tags/1.4.1/vendor/composer/autoload_psr4.php (copied) (copied from crowdaa-sync/trunk/vendor/composer/autoload_psr4.php)
-
tags/1.4.1/vendor/composer/autoload_static.php (copied) (copied from crowdaa-sync/trunk/vendor/composer/autoload_static.php)
-
tags/1.4.1/vendor/composer/installed.json (copied) (copied from crowdaa-sync/trunk/vendor/composer/installed.json)
-
tags/1.4.1/vendor/firebase (copied) (copied from crowdaa-sync/trunk/vendor/firebase)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/CHANGELOG.md)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/README.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/README.md)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/composer.json)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/MessageFormatter.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/MessageFormatter.php)
-
tags/1.4.1/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php)
-
tags/1.4.1/vendor/guzzlehttp/promises/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/CHANGELOG.md)
-
tags/1.4.1/vendor/guzzlehttp/promises/src/EachPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/EachPromise.php)
-
tags/1.4.1/vendor/guzzlehttp/promises/src/FulfilledPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/FulfilledPromise.php)
-
tags/1.4.1/vendor/guzzlehttp/promises/src/RejectedPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/RejectedPromise.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/CHANGELOG.md)
-
tags/1.4.1/vendor/guzzlehttp/psr7/README.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/README.md)
-
tags/1.4.1/vendor/guzzlehttp/psr7/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/composer.json)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/CachingStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/CachingStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/DroppingStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/DroppingStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/FnStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/FnStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Header.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Header.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/InflateStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/InflateStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/LazyOpenStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/LazyOpenStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/LimitStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/LimitStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Message.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Message.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/MessageTrait.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MessageTrait.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/MimeType.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MimeType.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/MultipartStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MultipartStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/NoSeekStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/NoSeekStream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Query.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Query.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/ServerRequest.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/ServerRequest.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Stream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Stream.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Uri.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Uri.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/UriComparator.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/UriComparator.php)
-
tags/1.4.1/vendor/guzzlehttp/psr7/src/Utils.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Utils.php)
-
tags/1.4.1/vendor/symfony/deprecation-contracts/LICENSE (copied) (copied from crowdaa-sync/trunk/vendor/symfony/deprecation-contracts/LICENSE)
-
tags/1.4.1/vendor/symfony/deprecation-contracts/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/symfony/deprecation-contracts/composer.json)
-
trunk/CHANGELOG (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-crowdaa-sync-admin-display.php (modified) (1 diff)
-
trunk/admin/js/crowdaa-sync-admin.js (modified) (1 diff)
-
trunk/admin/partials/crowdaa-sync-admin-display.php (modified) (3 diffs)
-
trunk/crowdaa-sync.php (modified) (2 diffs)
-
trunk/includes/class-crowdaa-sync-utils.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
crowdaa-sync/tags/1.4.1/CHANGELOG
r2776976 r2778568 6 6 7 7 ## [Unreleased] 8 9 ## [1.4.1] - 2022-09-01 10 11 ### Added 12 13 - Plugin API key (not currently used, preparing it for 1.5.0) 8 14 9 15 ## [1.4.0] - 2022-08-29 -
crowdaa-sync/tags/1.4.1/README.txt
r2776976 r2778568 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1.4. 08 Stable tag: 1.4.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crowdaa-sync/tags/1.4.1/admin/class-crowdaa-sync-admin-display.php
r2776976 r2778568 200 200 update_option('crowdaa_user_id', $json->data->userId); 201 201 update_option('crowdaa_auth_token', $json->data->authToken); 202 Crowdaa_Sync_Utils::generate_plugin_api_key(); 202 203 203 204 add_action( -
crowdaa-sync/tags/1.4.1/admin/js/crowdaa-sync-admin.js
r2744975 r2778568 180 180 $('#crowdaa-sync-categories-mode-whitelist-checkbox').on('change', updateSyncCategoriesSelect); 181 181 updateSyncCategoriesSelect(); 182 183 let pluginApiKeyDisplayTimeout = null; 184 $('#plugin_api_key').focus(function(e) { 185 e.preventDefault(); 186 187 $(e.target).select(); 188 document.execCommand("copy"); 189 190 const $display = $('#plugin_api_key-copied'); 191 $display.text('Copied!'); 192 193 if (pluginApiKeyDisplayTimeout !== null) clearTimeout(pluginApiKeyDisplayTimeout); 194 pluginApiKeyDisplayTimeout = setTimeout(() => { 195 $display.text(''); 196 pluginApiKeyDisplayTimeout = null; 197 }, 3000); 198 }); 182 199 183 200 $('#crowdaa-reset-request').click(function(e) { -
crowdaa-sync/tags/1.4.1/admin/partials/crowdaa-sync-admin-display.php
r2776976 r2778568 23 23 24 24 <h2><?php esc_html_e('Connect to Crowdaa', CROWDAA_SYNC_PLUGIN_NAME); ?></h2> 25 <?php 25 <form method="post" action="<?php $admin_utils->login(); ?>"> 26 <?php 26 27 $api_url = get_option('crowdaa_api_url'); 27 28 $user_email = get_option('crowdaa_user_email'); … … 30 31 $user_api_key = get_option('crowdaa_user_api_key'); 31 32 $auth_token = get_option('crowdaa_auth_token'); 32 ?>33 <form method="post" action="<?php $admin_utils->login(); ?>">33 $plugin_api_key = Crowdaa_Sync_Utils::get_plugin_api_key(); 34 ?> 34 35 <div class="crowdaa-html-container"> 35 36 <p> … … 52 53 <label class="text-label" for="user_password"><?php esc_html_e('Password', CROWDAA_SYNC_PLUGIN_NAME); ?></label> 53 54 <input type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $auth_token) ? $user_password : ''); ?>"/> 55 </p> 56 <p> 57 <label class="text-label" for="plugin_api_key"><?php esc_html_e('Plugin API Key', CROWDAA_SYNC_PLUGIN_NAME); ?></label> 58 <input readonly type="text" required id="plugin_api_key" name="plugin_api_key" value="<?php echo esc_attr(($plugin_api_key && $auth_token) ? $plugin_api_key : ''); ?>"/> 59 <span id="plugin_api_key-copied"></span> 54 60 </p> 55 61 </div> -
crowdaa-sync/tags/1.4.1/crowdaa-sync.php
r2776976 r2778568 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1.4. 016 * Version: 1.4.1 17 17 * Requires at least: 5.5 18 18 * Requires PHP: 7.2 … … 34 34 * Uses SemVer - https://semver.org 35 35 */ 36 define('CROWDAA_SYNC_VERSION', '1.4. 0');36 define('CROWDAA_SYNC_VERSION', '1.4.1'); 37 37 define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__); 38 38 define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync'); -
crowdaa-sync/tags/1.4.1/includes/class-crowdaa-sync-utils.php
r2776976 r2778568 162 162 return ($ret); 163 163 } 164 165 /** 166 * Generates and returns a new token with the given length 167 */ 168 public static function random_token($length) { 169 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_'; 170 $pass = ''; 171 $alphaLength = strlen($alphabet) - 1; 172 while (strlen($pass) < $length) { 173 $c = rand(0, $alphaLength); 174 $pass .= $alphabet[$c]; 175 } 176 return $pass; 177 } 178 179 /** 180 * Generates and returns a new Crowdaa API token 181 */ 182 public static function generate_plugin_api_key() { 183 $internalApiToken = self::random_token(97); 184 update_option('crowdaa_plugin_api_key', $internalApiToken); 185 186 return ($internalApiToken); 187 } 188 189 /** 190 * Returns the current Crowdaa API token 191 */ 192 public static function get_plugin_api_key() { 193 $apiKey = get_option('crowdaa_plugin_api_key', null); 194 if (!$apiKey) { 195 $apiKey = self::generate_plugin_api_key(); 196 } 197 198 return ($apiKey); 199 } 200 201 /** 202 * Checks if the current execution was called from the Crowdaa API 203 */ 204 public static function is_crowdaa_api_request() { 205 if (!isset($_SERVER['HTTP_X_CROWDAA_API_KEY'])) { 206 return (false); 207 } 208 209 $clientApiKey = $_SERVER['HTTP_X_CROWDAA_API_KEY']; 210 $ourApiKey = self::get_plugin_api_key(); 211 212 return ($clientApiKey === $ourApiKey); 213 } 164 214 } -
crowdaa-sync/trunk/CHANGELOG
r2776976 r2778568 6 6 7 7 ## [Unreleased] 8 9 ## [1.4.1] - 2022-09-01 10 11 ### Added 12 13 - Plugin API key (not currently used, preparing it for 1.5.0) 8 14 9 15 ## [1.4.0] - 2022-08-29 -
crowdaa-sync/trunk/README.txt
r2776976 r2778568 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1.4. 08 Stable tag: 1.4.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crowdaa-sync/trunk/admin/class-crowdaa-sync-admin-display.php
r2776976 r2778568 200 200 update_option('crowdaa_user_id', $json->data->userId); 201 201 update_option('crowdaa_auth_token', $json->data->authToken); 202 Crowdaa_Sync_Utils::generate_plugin_api_key(); 202 203 203 204 add_action( -
crowdaa-sync/trunk/admin/js/crowdaa-sync-admin.js
r2744975 r2778568 180 180 $('#crowdaa-sync-categories-mode-whitelist-checkbox').on('change', updateSyncCategoriesSelect); 181 181 updateSyncCategoriesSelect(); 182 183 let pluginApiKeyDisplayTimeout = null; 184 $('#plugin_api_key').focus(function(e) { 185 e.preventDefault(); 186 187 $(e.target).select(); 188 document.execCommand("copy"); 189 190 const $display = $('#plugin_api_key-copied'); 191 $display.text('Copied!'); 192 193 if (pluginApiKeyDisplayTimeout !== null) clearTimeout(pluginApiKeyDisplayTimeout); 194 pluginApiKeyDisplayTimeout = setTimeout(() => { 195 $display.text(''); 196 pluginApiKeyDisplayTimeout = null; 197 }, 3000); 198 }); 182 199 183 200 $('#crowdaa-reset-request').click(function(e) { -
crowdaa-sync/trunk/admin/partials/crowdaa-sync-admin-display.php
r2776976 r2778568 23 23 24 24 <h2><?php esc_html_e('Connect to Crowdaa', CROWDAA_SYNC_PLUGIN_NAME); ?></h2> 25 <?php 25 <form method="post" action="<?php $admin_utils->login(); ?>"> 26 <?php 26 27 $api_url = get_option('crowdaa_api_url'); 27 28 $user_email = get_option('crowdaa_user_email'); … … 30 31 $user_api_key = get_option('crowdaa_user_api_key'); 31 32 $auth_token = get_option('crowdaa_auth_token'); 32 ?>33 <form method="post" action="<?php $admin_utils->login(); ?>">33 $plugin_api_key = Crowdaa_Sync_Utils::get_plugin_api_key(); 34 ?> 34 35 <div class="crowdaa-html-container"> 35 36 <p> … … 52 53 <label class="text-label" for="user_password"><?php esc_html_e('Password', CROWDAA_SYNC_PLUGIN_NAME); ?></label> 53 54 <input type="password" required id="user_password" name="user_password" value="<?php echo esc_attr(($user_password && $auth_token) ? $user_password : ''); ?>"/> 55 </p> 56 <p> 57 <label class="text-label" for="plugin_api_key"><?php esc_html_e('Plugin API Key', CROWDAA_SYNC_PLUGIN_NAME); ?></label> 58 <input readonly type="text" required id="plugin_api_key" name="plugin_api_key" value="<?php echo esc_attr(($plugin_api_key && $auth_token) ? $plugin_api_key : ''); ?>"/> 59 <span id="plugin_api_key-copied"></span> 54 60 </p> 55 61 </div> -
crowdaa-sync/trunk/crowdaa-sync.php
r2776976 r2778568 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1.4. 016 * Version: 1.4.1 17 17 * Requires at least: 5.5 18 18 * Requires PHP: 7.2 … … 34 34 * Uses SemVer - https://semver.org 35 35 */ 36 define('CROWDAA_SYNC_VERSION', '1.4. 0');36 define('CROWDAA_SYNC_VERSION', '1.4.1'); 37 37 define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__); 38 38 define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync'); -
crowdaa-sync/trunk/includes/class-crowdaa-sync-utils.php
r2776976 r2778568 162 162 return ($ret); 163 163 } 164 165 /** 166 * Generates and returns a new token with the given length 167 */ 168 public static function random_token($length) { 169 $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_'; 170 $pass = ''; 171 $alphaLength = strlen($alphabet) - 1; 172 while (strlen($pass) < $length) { 173 $c = rand(0, $alphaLength); 174 $pass .= $alphabet[$c]; 175 } 176 return $pass; 177 } 178 179 /** 180 * Generates and returns a new Crowdaa API token 181 */ 182 public static function generate_plugin_api_key() { 183 $internalApiToken = self::random_token(97); 184 update_option('crowdaa_plugin_api_key', $internalApiToken); 185 186 return ($internalApiToken); 187 } 188 189 /** 190 * Returns the current Crowdaa API token 191 */ 192 public static function get_plugin_api_key() { 193 $apiKey = get_option('crowdaa_plugin_api_key', null); 194 if (!$apiKey) { 195 $apiKey = self::generate_plugin_api_key(); 196 } 197 198 return ($apiKey); 199 } 200 201 /** 202 * Checks if the current execution was called from the Crowdaa API 203 */ 204 public static function is_crowdaa_api_request() { 205 if (!isset($_SERVER['HTTP_X_CROWDAA_API_KEY'])) { 206 return (false); 207 } 208 209 $clientApiKey = $_SERVER['HTTP_X_CROWDAA_API_KEY']; 210 $ourApiKey = self::get_plugin_api_key(); 211 212 return ($clientApiKey === $ourApiKey); 213 } 164 214 }
Note: See TracChangeset
for help on using the changeset viewer.