Compare commits
4 Commits
572604300a
...
v0.04
| Author | SHA1 | Date | |
|---|---|---|---|
| 04d625110d | |||
| 8031e2ffc4 | |||
| 1f141fac7d | |||
| 768f7467e3 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
/database
|
scripts/database/*
|
||||||
/html
|
scripts/html/*
|
||||||
*.zip
|
*.zip
|
||||||
@@ -112,4 +112,4 @@ Both tables are automatically removed when the plugin is uninstalled.
|
|||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
Nikola Petrov
|
Nikola Petrov nikola@petrovv.com
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fwrite($output, $mcmahonfirst);
|
|||||||
|
|
||||||
foreach ($entries as $i => $e) {
|
foreach ($entries as $i => $e) {
|
||||||
$rank = $ranks[$e->rank];
|
$rank = $ranks[$e->rank];
|
||||||
$id = $e->i + 1;
|
$id = $i + 1;
|
||||||
$egd = (strlen($e->egd_number) == 0) ? '0' : $e->egd_number;
|
$egd = (strlen($e->egd_number) == 0) ? '0' : $e->egd_number;
|
||||||
$out = " <IndividualParticipant typeversion=\"1\">
|
$out = " <IndividualParticipant typeversion=\"1\">
|
||||||
<Id>$id</Id>
|
<Id>$id</Id>
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Plugin Name: Go Form Plugin
|
|
||||||
* Description: Form plugin for Go players
|
|
||||||
* Version: 0.03
|
|
||||||
* Author: Nikola Petrov
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('ABSPATH'))
|
if (!defined('ABSPATH'))
|
||||||
exit;
|
exit;
|
||||||
@@ -37,18 +31,11 @@ function go_form_activate()
|
|||||||
email varchar(255) DEFAULT NULL,
|
email varchar(255) DEFAULT NULL,
|
||||||
egd_number varchar(20) DEFAULT NULL,
|
egd_number varchar(20) DEFAULT NULL,
|
||||||
comment text DEFAULT NULL,
|
comment text DEFAULT NULL,
|
||||||
created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
KEY form_id (form_id)
|
FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE
|
||||||
) $charset;");
|
) $charset;");
|
||||||
|
|
||||||
// Add default form if none exist
|
|
||||||
$existing_forms = $wpdb->get_var("SELECT COUNT(*) FROM $forms");
|
|
||||||
if ($existing_forms == 0) {
|
|
||||||
$wpdb->insert($forms, ['name' => 'Default Form']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
register_activation_hook(__FILE__, 'go_form_activate');
|
|
||||||
|
|
||||||
function go_form_uninstall()
|
function go_form_uninstall()
|
||||||
{
|
{
|
||||||
@@ -56,8 +43,6 @@ function go_form_uninstall()
|
|||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_entries");
|
||||||
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}go_form_forms");
|
||||||
}
|
}
|
||||||
register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
|
||||||
//register_deactivation_hook(__FILE__, 'go_form_uninstall');
|
|
||||||
// ========== Helpers ==========
|
// ========== Helpers ==========
|
||||||
$ranks = [
|
$ranks = [
|
||||||
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
|
0 => '30k', 1 => '29k', 2 => '28k', 3 => '27k', 4 => '26k',
|
||||||
@@ -107,20 +92,16 @@ function go_form_handle_submission()
|
|||||||
wp_die('Security check failed');
|
wp_die('Security check failed');
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 1;
|
if (isset($_POST['form_id'])) {
|
||||||
|
$form_id = intval($_POST['form_id']);
|
||||||
// Check if form exists
|
} else {
|
||||||
$form_exists = $wpdb->get_var($wpdb->prepare(
|
wp_redirect($_SERVER['HTTP_REFERER']);
|
||||||
"SELECT COUNT(*) FROM {$wpdb->prefix}go_form_forms WHERE id = %d",
|
exit;
|
||||||
$form_id
|
|
||||||
));
|
|
||||||
if (!$form_exists) {
|
|
||||||
$form_id = 1; // Fallback to default form
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rating = intval($_POST['rating']);
|
$rating = intval($_POST['rating']);
|
||||||
$rank = intval($_POST['rank']);
|
$rank = intval($_POST['rank']);
|
||||||
if($rating < -900) {
|
if ($rating < -900) {
|
||||||
$rating = ($rank * 100) - 900;
|
$rating = ($rank * 100) - 900;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,10 +199,7 @@ function go_form_delete_form()
|
|||||||
if (isset($_POST['value_one'])) {
|
if (isset($_POST['value_one'])) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$id = intval($_POST['value_one']);
|
$id = intval($_POST['value_one']);
|
||||||
if ($id > 1) {
|
$wpdb->delete("{$wpdb->prefix}go_form_forms", ['id' => $id]);
|
||||||
$wpdb->delete("{$wpdb->prefix}go_form_entries", ['form_id' => $id]);
|
|
||||||
$wpdb->delete("{$wpdb->prefix}go_form_forms", ['id' => $id]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'deleted' => 1), admin_url('admin.php'));
|
$redirect_url = add_query_arg(array('page' => 'go-form-settings', 'deleted' => 1), admin_url('admin.php'));
|
||||||
wp_redirect($redirect_url);
|
wp_redirect($redirect_url);
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
<th>Club</th>
|
<th>Club</th>
|
||||||
<th>Rank</th>
|
<th>Rank</th>
|
||||||
<th>EGD Number</th>
|
<th>EGD Number</th>
|
||||||
|
<th>Date Added</th>
|
||||||
<?php if ($show_admin): ?>
|
<?php if ($show_admin): ?>
|
||||||
<th>Rating</th>
|
<th>Rating</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Date Added</th>
|
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
<th>Comment</th>
|
<th>Comment</th>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -27,12 +27,12 @@
|
|||||||
<td> <?= esc_html($e->club) ?> </td>
|
<td> <?= esc_html($e->club) ?> </td>
|
||||||
<td> <?= esc_html($ranks[$e->rank]) ?> </td>
|
<td> <?= esc_html($ranks[$e->rank]) ?> </td>
|
||||||
<td> <?= esc_html($e->egd_number) ?> </td>
|
<td> <?= esc_html($e->egd_number) ?> </td>
|
||||||
|
<td> <?= esc_html($e->created_at) ?> </td>
|
||||||
|
|
||||||
<?php if ($show_admin): ?>
|
<?php if ($show_admin): ?>
|
||||||
|
|
||||||
<td> <?= esc_html($e->rating) ?> </td>
|
<td> <?= esc_html($e->rating) ?> </td>
|
||||||
<td> <?= esc_html($e->email) ?> </td>
|
<td> <?= esc_html($e->email) ?> </td>
|
||||||
<td> <?= esc_html($e->created_at) ?> </td>
|
|
||||||
<td>
|
<td>
|
||||||
<?php action_button('go_form_delete_entry', 'Delete', 'Delete this entry?', $e->id); ?>
|
<?php action_button('go_form_delete_entry', 'Delete', 'Delete this entry?', $e->id); ?>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
18
main.php
Normal file
18
main.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: Go Form Plugin
|
||||||
|
* Description: Form plugin for Go players
|
||||||
|
* Version: 0.04
|
||||||
|
* Author: Nikola Petrov
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('ABSPATH'))
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// Load plugin code
|
||||||
|
require_once plugin_dir_path(__FILE__) . 'go-form-plugin/go-form-plugin.php';
|
||||||
|
|
||||||
|
register_activation_hook(__FILE__, 'go_form_activate');
|
||||||
|
|
||||||
|
register_uninstall_hook(__FILE__, 'go_form_uninstall');
|
||||||
|
//register_deactivation_hook(__FILE__, 'go_form_uninstall');
|
||||||
@@ -7,10 +7,10 @@ CONTAINER_NAME_DB='wordpress_db'
|
|||||||
CONTAINER_NAME_WP='wordpress'
|
CONTAINER_NAME_WP='wordpress'
|
||||||
|
|
||||||
# Stop and remove containers
|
# Stop and remove containers
|
||||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||||
|
|
||||||
# Remove pod
|
# Remove pod
|
||||||
podman pod rm -f $POD_NAME 2>/dev/null || true
|
podman pod rm -f $POD_NAME || true
|
||||||
|
|
||||||
echo "removed pods"
|
echo "removed pods"
|
||||||
@@ -9,17 +9,18 @@ CONTAINER_NAME_DB='wordpress_db'
|
|||||||
CONTAINER_NAME_WP='wordpress'
|
CONTAINER_NAME_WP='wordpress'
|
||||||
|
|
||||||
# Stop and remove containers
|
# Stop and remove containers
|
||||||
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
podman stop $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||||
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP 2>/dev/null || true
|
podman rm $CONTAINER_NAME_DB $CONTAINER_NAME_WP || true
|
||||||
|
|
||||||
# Remove pod
|
# Remove pod
|
||||||
podman pod rm -f $POD_NAME 2>/dev/null || true
|
podman pod rm -f $POD_NAME || true
|
||||||
|
|
||||||
echo "removed pods"
|
echo "removed pods"
|
||||||
#exit 0
|
#exit 0
|
||||||
|
|
||||||
# Recreate pod
|
# Recreate pod
|
||||||
podman pod create -n $POD_NAME -p 8090:80
|
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
||||||
|
|
||||||
|
|
||||||
# Start MariaDB
|
# Start MariaDB
|
||||||
podman run --detach --pod $POD_NAME \
|
podman run --detach --pod $POD_NAME \
|
||||||
@@ -25,7 +25,7 @@ podman pull docker.io/wordpress
|
|||||||
|
|
||||||
# Create a pod instead of --link.
|
# Create a pod instead of --link.
|
||||||
# So both containers are able to reach each others.
|
# So both containers are able to reach each others.
|
||||||
podman pod create -n $POD_NAME -p 8090:80
|
podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306
|
||||||
|
|
||||||
podman run --detach --pod $POD_NAME \
|
podman run --detach --pod $POD_NAME \
|
||||||
-e MYSQL_ROOT_PASSWORD=$DB_PASS \
|
-e MYSQL_ROOT_PASSWORD=$DB_PASS \
|
||||||
3
scripts/zip.sh
Executable file
3
scripts/zip.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
cd ..
|
||||||
|
rm go-form-plugin.zip
|
||||||
|
zip -r go-form-plugin.zip go-form-plugin/* main.php
|
||||||
Reference in New Issue
Block a user