%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/fusion-builder/inc/
Upload File :
Create Path :
Current File : /dom645759/wp-content/plugins/fusion-builder/inc/class-fusion-form-db-items.php

<?php
/**
 * Abstraction for submissions & forms.
 *
 * @package fusion-builder
 * @since 3.1
 */

/**
 * Form Submissions & Forms abstraction.
 *
 * @since 3.1
 */
abstract class Fusion_Form_DB_Items {

	/**
	 * The table name.
	 *
	 * @access protected
	 * @since 3.1
	 * @var string
	 */
	protected $table_name;

	/**
	 * Get form submissions.
	 *
	 * @param array $args An array of arguments for the query.
	 * @return array      An array of submissions.
	 */
	public function get( $args = [] ) {
		global $wpdb;
		$db = new Fusion_Form_DB();

		// The table name.
		$table_name = $wpdb->prefix . $this->table_name;

		if ( ! isset( $args['what'] ) ) {
			$args['what'] = '*';
		}

		// The query basics.
		$query = 'SELECT ' . $args['what'] . " FROM `$table_name`";

		// Build the WHERE fragment of the query.
		if ( isset( $args['where'] ) ) {
			$where = [];
			foreach ( $args['where'] as $where_fragment_key => $where_fragment_val ) {
				$where[] = $this->get_where_fragment( $where_fragment_key, $where_fragment_val );
			}

			$query .= ' WHERE ' . implode( ' AND ', $where );
		}

		// Build the ORDER BY fragment of the query.
		if ( isset( $args['order by'] ) ) {
			$order_by = sanitize_sql_orderby( $args['order by'] );
			if ( $order_by ) {
				$query .= ' ORDER BY ' . $order_by;
			}
		}

		// Build the LIMIT fragment of the query.
		if ( isset( $args['limit'] ) ) {
			$query .= ' LIMIT ' . absint( $args['limit'] );
		}

		// Build the OFFSET fragment of the query.
		if ( isset( $args['offset'] ) ) {
			$query .= ' OFFSET ' . absint( $args['offset'] );
		}

		return $db->get_results( $query );
	}

	/**
	 * Builds one "column = value" WHERE fragment. Values used to be spliced in raw, with callers
	 * quoting strings themselves, so one complete, escaped quoted literal is still used as it is.
	 * Integers are used as they are and anything else is prepared as a string. A column that is not
	 * a plain identifier matches nothing.
	 *
	 * @since 3.16.3
	 * @access protected
	 * @param string     $column The column name.
	 * @param int|string $value  The value.
	 * @return string The fragment.
	 */
	protected function get_where_fragment( $column, $value ) {
		global $wpdb;

		if ( ! $this->is_column_name( $column ) ) {
			return '1 = 0';
		}

		if ( is_int( $value ) ) {
			return "`$column` = $value";
		}

		$value = (string) $value;
		if ( preg_match( '/^(?:\'(?:[^\'\\\\]|\\\\.)*\'|"(?:[^"\\\\]|\\\\.)*")$/s', $value ) ) {
			return "`$column` = $value";
		}

		return $wpdb->prepare( "`$column` = %s", $value ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
	}

	/**
	 * Whether a string is a plain column name, safe to put in a query.
	 *
	 * @since 3.16.3
	 * @access protected
	 * @param mixed $column The column name.
	 * @return bool
	 */
	protected function is_column_name( $column ) {
		return is_string( $column ) && 1 === preg_match( '/^[A-Za-z0-9_]+$/', $column );
	}

	/**
	 * Insert form submission meta to database.
	 *
	 * @since 3.1
	 * @access public
	 * @param array $args The arguments.
	 * @return integer|boolean The last insert id or false if query failed.
	 */
	public function insert( $args ) {
		global $wpdb;

		// Insert form into database.
		$result = $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
			$wpdb->prefix . $this->table_name,
			apply_filters( $this->table_name . '_insert_query_args', $args )
		);

		Fusion_Form_DB::invalidate_cache();

		// Check if insert failed.
		if ( false === $result ) {
			return new WP_Error(
				'db_insert_error',
				__( 'AWB Form database insert failed.', 'fusion-builder' ) . ' ' . $wpdb->last_error,
				[ 'db_error' => $wpdb->last_error ],
			);
		}

		// Get last inserted forms row id.
		return $wpdb->insert_id;
	}

	/**
	 * Update item.
	 *
	 * @since 3.1
	 * @access public
	 * @param array        $data         Data to update (in column => value pairs).
	 *                                   Both $data columns and $data values should be "raw"
	 *                                   (neither should be SQL escaped).
	 *                                   Sending a null value will cause the column to be set to NULL -
	 *                                   the corresponding format is ignored in this case.
	 * @param array        $where        A named array of WHERE clauses (in column => value pairs).
	 *                                   Multiple clauses will be joined with ANDs.
	 *                                   Both $where columns and $where values should be "raw".
	 *                                   Sending a null value will create an IS NULL comparison -
	 *                                   the corresponding format will be ignored in this case.
	 * @param array|string $format       An array of formats to be mapped to each of the values in $data.
	 *                                   If string, that format will be used for all of the values in $data.
	 *                                   A format is one of '%d', '%f', '%s' (integer, float, string).
	 *                                   If omitted, all values in $data will be treated as strings
	 *                                   unless otherwise specified in wpdb::$field_types.
	 * @param array|string $where_format An array of formats to be mapped to each of the values in $where.
	 *                                   If string, that format will be used for all of the items in $where.
	 *                                   A format is one of '%d', '%f', '%s' (integer, float, string).
	 *                                   If omitted, all values in $where will be treated as strings.
	 * @return void
	 */
	public function update( $data, $where, $format = null, $where_format = null ) {
		global $wpdb;

		// Update item.
		$wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery
			$wpdb->prefix . $this->table_name,
			$data,
			$where,
			$format,
			$where_format
		);

		Fusion_Form_DB::invalidate_cache();
	}

	/**
	 * Delete a submission.
	 *
	 * @access public
	 * @since 3.1
	 * @param int|array $ids       The submission ID(s).
	 * @param string    $id_column The column to use in our WHERE query fragment.
	 * @return void
	 */
	public function delete( $ids, $id_column = 'id' ) {
		global $wpdb;
		$db = new Fusion_Form_DB();

		// The column goes into the query as it is.
		if ( ! $this->is_column_name( $id_column ) ) {
			return;
		}

		$ids = (array) $ids;

		foreach ( $ids as $id ) {

			// Make sure $id is an integer.
			$id = (int) $id;

			// Delete submission.
			$db->query( $wpdb->prepare( "DELETE FROM `{$wpdb->prefix}{$this->table_name}` WHERE `{$wpdb->prefix}{$this->table_name}`.`$id_column` = %d", $id ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		}
	}
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap299.xml 2026-12-01 https://louisvillegop.com/sitemap778.xml 2026-12-01 https://louisvillegop.com/sitemap107.xml 2026-12-01 https://louisvillegop.com/sitemap907.xml 2026-12-01 https://louisvillegop.com/sitemap345.xml 2026-12-01 https://louisvillegop.com/sitemap303.xml 2026-12-01 https://louisvillegop.com/sitemap444.xml 2026-12-01 https://louisvillegop.com/sitemap380.xml 2026-12-01 https://louisvillegop.com/sitemap35.xml 2026-12-01 https://louisvillegop.com/sitemap780.xml 2026-12-01 https://louisvillegop.com/sitemap753.xml 2026-12-01 https://louisvillegop.com/sitemap771.xml 2026-12-01 https://louisvillegop.com/sitemap659.xml 2026-12-01 https://louisvillegop.com/sitemap372.xml 2026-12-01 https://louisvillegop.com/sitemap436.xml 2026-12-01 https://louisvillegop.com/sitemap808.xml 2026-12-01 https://louisvillegop.com/sitemap261.xml 2026-12-01 https://louisvillegop.com/sitemap885.xml 2026-12-01 https://louisvillegop.com/sitemap288.xml 2026-12-01 https://louisvillegop.com/sitemap730.xml 2026-12-01 https://louisvillegop.com/sitemap458.xml 2026-12-01 https://louisvillegop.com/sitemap651.xml 2026-12-01 https://louisvillegop.com/sitemap52.xml 2026-12-01 https://louisvillegop.com/sitemap776.xml 2026-12-01 https://louisvillegop.com/sitemap604.xml 2026-12-01 https://louisvillegop.com/sitemap1000.xml 2026-12-01 https://louisvillegop.com/sitemap442.xml 2026-12-01 https://louisvillegop.com/sitemap330.xml 2026-12-01 https://louisvillegop.com/sitemap841.xml 2026-12-01 https://louisvillegop.com/sitemap516.xml 2026-12-01 https://louisvillegop.com/sitemap862.xml 2026-12-01 https://louisvillegop.com/sitemap552.xml 2026-12-01 https://louisvillegop.com/sitemap96.xml 2026-12-01 https://louisvillegop.com/sitemap773.xml 2026-12-01 https://louisvillegop.com/sitemap823.xml 2026-12-01 https://louisvillegop.com/sitemap744.xml 2026-12-01 https://louisvillegop.com/sitemap643.xml 2026-12-01 https://louisvillegop.com/sitemap253.xml 2026-12-01 https://louisvillegop.com/sitemap422.xml 2026-12-01 https://louisvillegop.com/sitemap240.xml 2026-12-01 https://louisvillegop.com/sitemap12.xml 2026-12-01 https://louisvillegop.com/sitemap939.xml 2026-12-01 https://louisvillegop.com/sitemap6.xml 2026-12-01 https://louisvillegop.com/sitemap109.xml 2026-12-01 https://louisvillegop.com/sitemap915.xml 2026-12-01 https://louisvillegop.com/sitemap597.xml 2026-12-01 https://louisvillegop.com/sitemap989.xml 2026-12-01 https://louisvillegop.com/sitemap535.xml 2026-12-01 https://louisvillegop.com/sitemap950.xml 2026-12-01 https://louisvillegop.com/sitemap956.xml 2026-12-01 https://louisvillegop.com/sitemap964.xml 2026-12-01 https://louisvillegop.com/sitemap221.xml 2026-12-01 https://louisvillegop.com/sitemap561.xml 2026-12-01 https://louisvillegop.com/sitemap252.xml 2026-12-01 https://louisvillegop.com/sitemap243.xml 2026-12-01 https://louisvillegop.com/sitemap184.xml 2026-12-01 https://louisvillegop.com/sitemap953.xml 2026-12-01 https://louisvillegop.com/sitemap858.xml 2026-12-01 https://louisvillegop.com/sitemap131.xml 2026-12-01 https://louisvillegop.com/sitemap802.xml 2026-12-01 https://louisvillegop.com/sitemap811.xml 2026-12-01 https://louisvillegop.com/sitemap317.xml 2026-12-01 https://louisvillegop.com/sitemap603.xml 2026-12-01 https://louisvillegop.com/sitemap671.xml 2026-12-01 https://louisvillegop.com/sitemap637.xml 2026-12-01 https://louisvillegop.com/sitemap876.xml 2026-12-01 https://louisvillegop.com/sitemap389.xml 2026-12-01 https://louisvillegop.com/sitemap629.xml 2026-12-01 https://louisvillegop.com/sitemap216.xml 2026-12-01 https://louisvillegop.com/sitemap944.xml 2026-12-01