rename p1

This commit is contained in:
Joey Kimsey
2025-02-03 12:29:16 -05:00
parent 394e752094
commit 20f09e6789
29 changed files with 0 additions and 0 deletions

111
renamed/functions/input.php Normal file
View File

@ -0,0 +1,111 @@
<?php
/**
* functions/input.php
*
* This class manages and returns GET, FILE, and POST variables.
*
* @version 1.1.2
* @author Joey Kimsey <Joey@thetempusproject.com>
* @link https://TheTempusProject.com/libraries/Bedrock
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject\Bedrock\Functions;
use TheTempusProject\Canary\Bin\Canary as Debug;
class Input {
/**
* Checks to see if input exists in the order of POST, GET, FILE.
* A default name value of "submit" is used if none is specified.
*
* @param {string} [$data] - Name of the desired input (default: 'submit')
* @return {bool}
*/
public static function exists( $data = 'submit' ) {
if ( self::post( $data ) ) {
return true;
} elseif ( self::get( $data ) ) {
return true;
} elseif ( self::file( $data ) ) {
return true;
} else {
Debug::log( 'Input::exists: No input Found: '. $data );
return false;
}
}
/**
* Checks for a files existence and that it is not null
* then returns its value or bool false if none is found
*
* @param {string} [$data] - Name of desired $_FILES value.
* @return {bool|string} - Returns false if not found and a string if found.
*/
public static function file( $data ) {
if ( !isset( $_FILES[$data] ) ) {
Debug::log( "Input - file : $data not found." );
return false;
}
if ( $_FILES[$data]['tmp_name'] == '' ) {
Debug::log( "Input - file : $data empty." );
return false;
}
return $_FILES[$data];
}
/**
* Checks for a post variable named $data and returns
* its value if true or bool false if none is found.
*
* @param {string} [$data] - Name of desired $_POST value.
* @return {bool|string} - Returns false if not found and a string if found.
*/
public static function post( $data ) {
if ( !isset( $_POST[$data] ) ) {
Debug::debug( "Input - post : $data not found." );
return false;
}
if ( empty( $_POST[$data] ) ) {
Debug::debug( "Input - post : $data empty." );
return false;
}
return $_POST[$data];
}
/**
* Checks for a post variable named $data and returns
* its value if found or null if not found.
*
* @param {string} [$data] - Name of desired $_POST value.
* @return {string}
*/
public static function postNull( $data ) {
if ( !isset( $_POST[$data] ) ) {
Debug::debug( "Input - post : $data not found." );
return;
}
if ( empty( $_POST[$data] ) ) {
Debug::debug( "Input - post : $data empty." );
return;
}
return $_POST[$data];
}
/**
* Checks for a get variable named $data.
*
* @param {string} [$data] - Name of desired $_GET value.
* @return {bool|string} - Returns false if not found and a string if found.
*/
public static function get( $data ) {
if ( !isset( $_GET[$data] ) ) {
Debug::debug( "Input - get : $data not found." );
return false;
}
if ( empty( $_GET[$data] ) ) {
Debug::debug( "Input - get : $data empty." );
return false;
}
return $_GET[$data];
}
}