Skip to content

Commit 8f51658

Browse files
author
Lablnet
committed
update
1 parent 8ad0f55 commit 8f51658

File tree

8 files changed

+264
-179
lines changed

8 files changed

+264
-179
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Malik Umer Farooq
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Readme.md

+72-20
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,83 @@
11
# PHP input class
22
## This package can process the current HTTP request values.
33

4+
## Requirement
5+
1. PHP
6+
2. Composer
7+
8+
## Installation
9+
Installing this package is very simple, first ensure you have the right PHP version and composer installed then in your terminal/(command prompt) run: `composer require lablnet/input`
10+
11+
## Dependencies
12+
This class use `[lablnet/http-client](https://packagist.org/packages/lablnet/http-client)` library.
13+
414
## Feature
515

6-
1. Supported method get,post,put
7-
2. Clean input method
8-
3. check whether request is ajax or not
9-
4. Wordwrap
10-
5. check whether form submit or not
11-
6. Restore line breaks method
16+
1. Supported method get,post,put,patch,delete,files,others.
17+
2. Clean input method(clean XSS attack/sanitize input).
18+
3. Determine whether request is ajax or not.
19+
4. Restore line breaks method.
1220

1321
# Description
14-
It can access the HTTP request values and return them in a more convinient way to the application.
15-
Currently it can check the input values when using the GET, POST, PUT parameters, filter the parameter values, check whether request is sent by a browser using AJAX, word wrap parameter values, check whether
22+
It can access the HTTP request values and return them in a more convenient way to the application.
23+
Currently it can check the input values when using the GET, POST, PUT, PATCH, DELETE, FILES etc parameters, filter the parameter values, check whether request is sent by a browser using AJAX, word wrap parameter values, check whether
1624
the request is a form submission, fix parameter value line breaks.
1725

18-
## TODO
19-
Add method for emojies convertor
26+
> This class provide helpers functions for easily use of class.
27+
28+
## Input
29+
You can get input by calling `input` helpers or `Input::input` method
30+
```php
31+
require_once "../vendor/autoload.php";
32+
$username = input('username');
33+
```
34+
```php
35+
//in OOP style
36+
use Lablnet\Input;
37+
require_once "../vendor/autoload.php";
38+
$username = Input::input('username');
39+
```
40+
41+
## Escape
42+
You can escape input by calling `escape` helpers or `Input::escape` method
43+
```php
44+
require_once "../vendor/autoload.php";
45+
$username = escape(input('username'));
46+
```
47+
```php
48+
//in OOP style
49+
use Lablnet\Input;
50+
require_once "../vendor/autoload.php";
51+
$username = Input::clean(Input::input('username'));
52+
```
53+
54+
## Determine whether request is ajax/xhr?
55+
You can determine current request by calling `is_ajax` helpers or `Input::isAjax` method
56+
```php
57+
require_once "../vendor/autoload.php";
58+
if (is_ajax('name')) {
59+
//ajax
60+
}
61+
```
62+
```php
63+
//in OOP style
64+
use Lablnet\Input;
65+
require_once "../vendor/autoload.php";
66+
if (Input::isAjax('name')) {
67+
//ajax
68+
}
69+
```
2070

21-
# Simple Example
22-
## for more detail see index.php
23-
<?php
24-
require_once 'init.php';
25-
echo InPut::Input('q');
26-
?>
27-
<form action='' method='post'>
28-
<input type='text' name='q' ?>
29-
</form>
71+
## Restore line breaks
72+
You can restore line breaks by calling `restore_line_break` helpers or `Input::restoreLineBreaks` method
73+
```php
74+
require_once "../vendor/autoload.php";
75+
$comment = restore_line_break(escape(input('username')));
76+
```
77+
```php
78+
//in OOP style
79+
use Lablnet\Input;
80+
require_once "../vendor/autoload.php";
81+
$comment = Input::restoreLineBreaks(Input::clean(Input::input('username')));
82+
```
3083

31-

classes/InPut.php

-152
This file was deleted.

composer.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "lablnet/input",
3+
"description": "PHP input package.",
4+
"keywords": ["php", "input","request","free","package","Lablnet"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Malik Umer Farooq",
9+
"email":"[email protected]",
10+
"homepage": "https://softhub99.com"
11+
}
12+
],
13+
"autoload": {
14+
"psr-4": {
15+
"Lablnet\\": "src/"
16+
},
17+
"files":["src/functions/helpers.php"]
18+
},
19+
"require":{
20+
"lablnet/http-client": "^1.0"
21+
}
22+
}

index.php example/index.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<?php
2-
require_once 'init.php';
3-
if (InPut::IsFromSubmit('submit')) {
4-
if (InPut::Input('q')) {
5-
echo '<div class="container">'.InPut::Input('q').'</div>';
2+
require_once "../vendor/autoload.php";
3+
if (input('submit')) {
4+
5+
//Check whether the request ajax/xhr?
6+
//var_dump(is_ajax());
7+
//echo "<br>";
8+
if (input('q')) {
9+
echo '<div class="container">'.input('q').'</div>';
610
}
711
}
812
?>

init.php

-3
This file was deleted.

0 commit comments

Comments
 (0)