HEX
Server: LiteSpeed
System: Linux srv158.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: u1694298 (3732)
PHP: 7.4.33
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: /home/u1694298/www/wp-content/plugins/yop-poll/includes/Models/class-model-poll.php
<?php
namespace YopPoll\Models;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Model_Poll extends Model_Base {

	protected $table = 'polls';

	public function get_with_elements( $id ) {
		$poll = $this->find( $id );
		if ( ! $poll ) {
			return null;
		}

		$element_model    = new Model_Element();
		$subelement_model = new Model_Subelement();

		$elements = $element_model->get_by_poll( $id );

		foreach ( $elements as &$element ) {
			$element['subelements'] = $subelement_model->get_by_element( $element['id'] );
		}

		$poll['elements'] = $elements;
		return $poll;
	}

	public function increment_submits( $id ) {
		global $wpdb;
		$table = $this->get_table();
		$wpdb->query( $wpdb->prepare( "UPDATE {$table} SET total_submits = total_submits + 1 WHERE id = %d", $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter -- $table built from $wpdb->prefix . YOP_POLL_TABLE_PREFIX; counter write, no cache layer applicable.
	}

	public function decrement_submits( int $id ): void {
		global $wpdb;
		$table = $this->get_table();
		$wpdb->query( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter -- $table built from $wpdb->prefix . YOP_POLL_TABLE_PREFIX; counter write, no cache layer applicable.
			"UPDATE {$table} SET total_submits = GREATEST(0, total_submits - 1) WHERE id = %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			$id
		) );
	}

	public function increment_submited_answers( int $id, int $delta ) {
		if ( 0 === $delta ) {
			return;
		}
		global $wpdb;
		$table = $this->get_table();
		$wpdb->query( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery, PluginCheck.Security.DirectDB.UnescapedDBParameter -- $table built from $wpdb->prefix . YOP_POLL_TABLE_PREFIX; counter write, no cache layer applicable.
			"UPDATE {$table} SET total_submited_answers = total_submited_answers + %d WHERE id = %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			$delta, $id
		) );
	}
}