updated plugin Gitium version 1.0.7

This commit is contained in:
KawaiiPunk 2024-10-09 12:44:21 +00:00 committed by Gitium
parent c54fa007bd
commit 627ec103fe
9 changed files with 70 additions and 35 deletions

View File

@ -193,7 +193,7 @@ function gitium_group_commit_modified_plugins_and_themes( $msg_append = '' ) {
}
foreach ( $commit_groups as $base_path => $change ) {
$commit_message = _gitium_format_message( $change['name'], $change['version'], "${change['action']} ${change['type']}" );
$commit_message = _gitium_format_message( $change['name'], $change['version'], "{$change['action']} {$change['type']}" );
$commit = _gitium_commit_changes( "$commit_message $msg_append", $base_path, false );
if ( $commit ) {
$commits[] = $commit;

View File

@ -18,14 +18,14 @@
header( 'Content-Type: text/html' );
define( 'SHORTINIT', true );
//$wordpress_loader = $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
$wordpress_loader = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_STRING) . '/wp-load.php';
$wordpress_loader = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '/wp-load.php';
require_once $wordpress_loader;
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/inc/class-git-wrapper.php';
$webhook_key = get_option( 'gitium_webhook_key', '' );
$get_key = filter_input(INPUT_GET, 'key', FILTER_SANITIZE_STRING);
$get_key = filter_input(INPUT_GET, 'key', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! empty ( $webhook_key ) && isset( $get_key ) && $webhook_key == $get_key ) :
( '1.7' <= substr( $git->get_version(), 0, 3 ) ) or wp_die( 'Gitium plugin require minimum `git version 1.7`!' );

View File

@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Gitium
* Version: 1.0.6
* Version: 1.0.7
* Author: Presslabs
* Author URI: https://www.presslabs.com
* License: GPL2
@ -9,7 +9,7 @@
* Text Domain: gitium
* Domain Path: /languages/
*/
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
/* Copyright 2014-2024 Presslabs <ping@presslabs.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as

View File

@ -15,7 +15,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('GITIGNORE', <<<EOF
if (!defined('GITIGNORE'))
define('GITIGNORE', <<<EOF
*.log
*.swp
*.back
@ -134,7 +135,9 @@ class Git_Wrapper {
}
private function get_env() {
$env = array();
$env = array(
'HOME' => getenv( 'HOME' ),
);
$key_file = null;
if ( defined( 'GIT_SSH' ) && GIT_SSH ) {
@ -162,7 +165,7 @@ class Git_Wrapper {
$env = $this->get_env();
$git_bin_path = apply_filters( 'gitium_git_bin_path', '' );
$cmd = "${git_bin_path}git $args 2>&1";
$cmd = "{$git_bin_path}git $args 2>&1";
$proc = proc_open(
$cmd,

View File

@ -59,7 +59,7 @@ class Gitium_Menu {
}
public function disconnect_repository() {
$gitium_disconnect_repo = filter_input(INPUT_POST, 'GitiumSubmitDisconnectRepository', FILTER_SANITIZE_STRING);
$gitium_disconnect_repo = filter_input(INPUT_POST, 'GitiumSubmitDisconnectRepository', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_disconnect_repo ) ) {
return;
@ -73,8 +73,8 @@ class Gitium_Menu {
}
public function show_message() {
$get_message = filter_input(INPUT_GET, 'message', FILTER_SANITIZE_STRING);
$get_success = filter_input(INPUT_GET, 'success', FILTER_SANITIZE_STRING);
$get_message = filter_input(INPUT_GET, 'message', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$get_success = filter_input(INPUT_GET, 'success', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( isset( $get_message ) && $get_message ) {
$type = ( isset( $get_success ) && $get_success == 1 ) ? 'updated' : 'error';
$message = get_transient( 'message_'. $get_message );

View File

@ -52,7 +52,7 @@ class Gitium_Submenu_Configure extends Gitium_Menu {
}
public function regenerate_keypair() {
$submit_keypair = filter_input(INPUT_POST, 'GitiumSubmitRegenerateKeypair', FILTER_SANITIZE_STRING);
$submit_keypair = filter_input(INPUT_POST, 'GitiumSubmitRegenerateKeypair', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $submit_keypair ) ) {
return;
}
@ -62,7 +62,7 @@ class Gitium_Submenu_Configure extends Gitium_Menu {
}
public function gitium_warning() {
$submit_warning = filter_input(INPUT_POST, 'GitiumSubmitWarning', FILTER_SANITIZE_STRING);
$submit_warning = filter_input(INPUT_POST, 'GitiumSubmitWarning', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $submit_warning ) ) {
return;
}
@ -88,8 +88,8 @@ class Gitium_Submenu_Configure extends Gitium_Menu {
}
public function init_repo() {
$remote_url = filter_input(INPUT_POST, 'remote_url', FILTER_SANITIZE_STRING);
$gitium_submit_fetch = filter_input(INPUT_POST, 'GitiumSubmitFetch', FILTER_SANITIZE_STRING);
$remote_url = filter_input(INPUT_POST, 'remote_url', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$gitium_submit_fetch = filter_input(INPUT_POST, 'GitiumSubmitFetch', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_submit_fetch ) || ! isset( $remote_url ) ) {
return;
}
@ -107,8 +107,8 @@ class Gitium_Submenu_Configure extends Gitium_Menu {
}
public function choose_branch() {
$gitium_submit_merge_push = filter_input(INPUT_POST, 'GitiumSubmitMergeAndPush', FILTER_SANITIZE_STRING);
$tracking_branch = filter_input(INPUT_POST, 'tracking_branch', FILTER_SANITIZE_STRING);
$gitium_submit_merge_push = filter_input(INPUT_POST, 'GitiumSubmitMergeAndPush', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$tracking_branch = filter_input(INPUT_POST, 'tracking_branch', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_submit_merge_push ) || ! isset( $tracking_branch ) ) {
return;
}

View File

@ -38,7 +38,7 @@ class Gitium_Submenu_Settings extends Gitium_Menu {
}
public function regenerate_webhook() {
$gitium_regen_webhook = filter_input(INPUT_POST, 'GitiumSubmitRegenerateWebhook', FILTER_SANITIZE_STRING);
$gitium_regen_webhook = filter_input(INPUT_POST, 'GitiumSubmitRegenerateWebhook', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_regen_webhook ) ) {
return;
}
@ -48,7 +48,7 @@ class Gitium_Submenu_Settings extends Gitium_Menu {
}
public function regenerate_public_key() {
$submit_regenerate_pub_key = filter_input(INPUT_POST, 'GitiumSubmitRegeneratePublicKey', FILTER_SANITIZE_STRING);
$submit_regenerate_pub_key = filter_input(INPUT_POST, 'GitiumSubmitRegeneratePublicKey', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $submit_regenerate_pub_key ) ) {
return;
}
@ -99,8 +99,8 @@ class Gitium_Submenu_Settings extends Gitium_Menu {
}
public function save() {
$submit_save = filter_input(INPUT_POST, 'GitiumSubmitSave', FILTER_SANITIZE_STRING);
$gitignore_content = filter_input(INPUT_POST, 'gitignore_content', FILTER_SANITIZE_STRING);
$submit_save = filter_input(INPUT_POST, 'GitiumSubmitSave', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$gitignore_content = filter_input(INPUT_POST, 'gitignore_content', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $submit_save ) || ! isset( $gitignore_content ) ) {
return;
}

View File

@ -77,7 +77,7 @@ class Gitium_Submenu_Status extends Gitium_Menu {
}
public function save_ignorelist() {
$gitium_ignore_path = filter_input(INPUT_POST, 'GitiumIgnorePath', FILTER_SANITIZE_STRING);
$gitium_ignore_path = filter_input(INPUT_POST, 'GitiumIgnorePath', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_ignore_path ) ) {
return;
} else {
@ -94,8 +94,8 @@ class Gitium_Submenu_Status extends Gitium_Menu {
}
public function save_changes() {
$gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_STRING);
$gitium_commit_msg = filter_input(INPUT_POST, 'commitmsg', FILTER_SANITIZE_STRING);
$gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$gitium_commit_msg = filter_input(INPUT_POST, 'commitmsg', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_save_changes ) ) {
return;
}

View File

@ -4,10 +4,10 @@ Contributors: PressLabs
Donate link: https://www.presslabs.com/gitium/
Tags: git, version, versioning, deployment, version-control, github, bitbucket, travis, code, revision, testing, development, branch, production, staging, debug, plugin, gitium, presslabs, simple
Requires at least: 4.7
Tested up to: 6.2.2
Tested up to: 6.6
Requires PHP: 5.6
License: GPLv2
Stable tag: 1.0.6
Stable tag: 1.0.7
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Automatic git version control and deployment for your plugins and themes integrated into wp-admin.
@ -54,18 +54,40 @@ This WordPress plugin can be found at https://wordpress.org/plugins/gitium/
== Installation ==
= Manual Installation =
1. Upload `gitium.zip` to the `/wp-content/plugins/` directory;
2. Extract the `gitium.zip` archive into the `/wp-content/plugins/` directory;
3. Activate the plugin through the 'Plugins' menu in WordPress.
Alternatively, go into your WordPress dashboard and click on Plugins -> Add Plugin and search for `Gitium`. Then, click on Install and, after that, on Activate Now.
1. Go to your WordPress admin dashboard.
2. Navigate to 'Plugins' → 'Add New'.
3. Search for "Gitium".
4. Install and activate the Gitium plugin.
= Usage =
Activate the plugin and follow the on-screen instructions under the `Gitium` menu.
- Connect Your Repository
After activation, go to the Gitium settings in your WordPress admin area.
Copy the Public Key that Gitium has generated for you from the Key Pair field.
In your repository manager of choice (GitHub, GitLab, or Bitbucket), go to the settings page and find the “Deploy keys” (or similar) section. There you will need to add the Public Key youve copied from Gitium. This will grant Gitium access to your repository. Make sure to allow write access as well. Also make sure that you copy the entire key from gitium.
Now go back to your main repository page and copy the SSH URL to your repo. Paste this URL in Gitium and press the “Fetch” button.
A “Repository initialized successfully” message will show up. This means that your repository has been populated with the current code of your website and it is ready to start working with Gitium.
_IMPORTANT_: Gitium does its best not to version your WordPress core, neither your `/wp-content/uploads` folder.
- Initial Commit
Once connected, Gitium will automatically commit your existing WordPress theme and plugins to the connected repository.
This initial commit serves as the baseline for your sites code.
- Making Changes
Make changes to your WordPress sites code (themes, plugins) as needed.
Gitium will automatically commit these changes to your Git repository.
Using the webhook provided by Gitium, it will also automatically deploy the changes from the repository to your WordPress site.
- Webook Configuration
Gitium uses the webhook to automatically deploy remote changes to your server. To configure it follow these steps:
1. Go to your WordPress website and go to your Gitium Settings page;
2. Copy the full Webhook URL that Gitium provides;
3. In your Git Manager settings, go to Webhook section, add a new webhook and paste the webhook URL you have copied from Gitium.
4. Press Add, no settings changes needed. The webook simply needs a ping, nothing more. The security key is already embedded in the final URL Gitium has generated for you.
Now when you push to your repo, this webhook will automatically pull the changes to your remote server and deploy them.
You can see more details about the plugin also in our documentation here: https://www.presslabs.com/docs/code/gitium/install-gitium/
== Frequently Asked Questions ==
@ -95,12 +117,22 @@ Gitium does not support multisite setups at the moment.
Submodules are currently not supported.
= Where do I report security bugs found in this plugin? =
Please report security bugs found in the source code of the Gitium plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/gitium). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
== Upgrade Notice ==
= 1.0.5 =
Fixed wrong redirection for multisite installations during initial setup
= 1.0.7 =
PHP8.1 compatibility, check if gitignore is already defined and add HOME env
== Changelog ==
= 1.0.7 =
* Fix: HOME env definition;
* Fix: deprecation warnings in PHP 8.1;
* Compat: added composer.json package;
* Compat: add the possibility to use a custom `.gitignore` by defining the `GITIGNORE` constant.
= 1.0.6 =
* Fixed deprecation warnings for dynamic property in git-wrapper