Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit f958ce8

Browse files
committed
Initial upload files
0 parents  commit f958ce8

File tree

12 files changed

+653
-0
lines changed

12 files changed

+653
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
phpunit.xml
2+
composer.phar
3+
composer.lock
4+
composer-test.lock
5+
vendor/
6+
build/artifacts/
7+
artifacts/
8+
docs/_build
9+
docs/*.pyc
10+
.git*/
11+
.idea
12+
.DS_STORE

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# CHANGELOG
2+
3+
## 1.0.0 - 2017-01-17
4+
* Added `Josantonius\Ip\Ip` class.
5+
* Added `Josantonius\Ip\Ip::get()` method.
6+
7+
## 1.0.0 - 2017-01-17
8+
* Added `Josantonius\Ip\Exception\IpException` class.
9+
* Added `Josantonius\Ip\Exception\Exceptions` abstract class.
10+
* Added `Josantonius\Ip\Exception\IpException->__construct()` method.
11+
12+
## 1.0.0 - 2017-01-17
13+
* Added `Josantonius\Ip\Tests\IpTest` class.
14+
* Added `Josantonius\Ip\Tests\IpTest::testGetIp()` method.

CONDUCT.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4+
5+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
6+
7+
Examples of unacceptable behavior by participants include:
8+
9+
* The use of sexualized language or imagery
10+
* Personal attacks
11+
* Trolling or insulting/derogatory comments
12+
* Public or private harassment
13+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
14+
* Other unethical or unprofessional conduct.
15+
16+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17+
18+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations.
19+
20+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
21+
22+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

LICENSE

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

README-ES.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# PHP Ip library
2+
3+
[![Latest Stable Version](https://poser.pugx.org/josantonius/ip/v/stable)](https://packagist.org/packages/josantonius/ip) [![Total Downloads](https://poser.pugx.org/josantonius/ip/downloads)](https://packagist.org/packages/josantonius/ip) [![Latest Unstable Version](https://poser.pugx.org/josantonius/ip/v/unstable)](https://packagist.org/packages/josantonius/ip) [![License](https://poser.pugx.org/josantonius/ip/license)](https://packagist.org/packages/josantonius/ip)
4+
5+
[Spanish version](README-ES.md)
6+
7+
Clase PHP para obtener la IP del usuario.
8+
9+
---
10+
11+
- [Instalación](#instalación)
12+
- [Requisitos](#requisitos)
13+
- [Cómo empezar y ejemplos](#cómo-empezar-y-ejemplos)
14+
- [Métodos disponibles](#métodos-disponibles)
15+
- [Uso](#uso)
16+
- [Tests](#tests)
17+
- [Manejador de excepciones](#manejador-de-excepciones)
18+
- [Contribuir](#contribuir)
19+
- [Repositorio](#repositorio)
20+
- [Autor](#autor)
21+
- [Licencia](#licencia)
22+
23+
---
24+
25+
### Instalación
26+
27+
La mejor forma de instalar esta extensión es a través de [composer](http://getcomposer.org/download/).
28+
29+
Para instalar PHP Ip library, simplemente escribe:
30+
31+
$ composer require Josantonius/Ip
32+
33+
### Requisitos
34+
35+
Esta ĺibrería es soportada por versiones de PHP 7.0 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
36+
37+
Para utilizar esta librería en HHVM (HipHop Virtual Machine) tendrás que activar los tipos escalares. Añade la siguiente ĺínea "hhvm.php7.scalar_types = true" en tu "/etc/hhvm/php.ini".
38+
39+
### Cómo empezar y ejemplos
40+
41+
Para utilizar esta librería, simplemente:
42+
43+
```php
44+
require __DIR__ . '/vendor/autoload.php';
45+
46+
use Josantonius\Ip\Ip;
47+
```
48+
### Métodos disponibles
49+
50+
Métodos disponibles en esta librería:
51+
52+
```php
53+
Ip::get();
54+
```
55+
### Uso
56+
57+
Ejemplo de uso para esta librería:
58+
59+
```php
60+
<?php
61+
require __DIR__ . '/vendor/autoload.php';
62+
63+
use Josantonius\Ip\Ip;
64+
65+
print_r(Ip::get()); # 66.249.76.29
66+
```
67+
68+
### Tests
69+
70+
Para utilizar la clase de [pruebas](tests), simplemente:
71+
72+
```php
73+
<?php
74+
$loader = require __DIR__ . '/vendor/autoload.php';
75+
76+
$loader->addPsr4('Josantonius\\Ip\\Tests\\', __DIR__ . '/vendor/josantonius/ip/tests');
77+
78+
use Josantonius\Ip\Tests\IpTest;
79+
```
80+
Métodos de prueba disponibles en esta librería:
81+
82+
```php
83+
IpTest::testGetIp();
84+
```
85+
86+
### Manejador de excepciones
87+
88+
Esta librería utiliza [control de excepciones](src/Exception) que puedes personalizar a tu gusto.
89+
### Contribuir
90+
1. Comprobar si hay incidencias abiertas o abrir una nueva para iniciar una discusión en torno a un fallo o función.
91+
1. Bifurca la rama del repositorio en GitHub para iniciar la operación de ajuste.
92+
1. Escribe una o más pruebas para la nueva característica o expón el error.
93+
1. Haz cambios en el código para implementar la característica o reparar el fallo.
94+
1. Envía pull request para fusionar los cambios y que sean publicados.
95+
96+
Esto está pensado para proyectos grandes y de larga duración.
97+
98+
### Repositorio
99+
100+
Los archivos de este repositorio se crearon y subieron automáticamente con [Reposgit Creator](https://github.com/Josantonius/BASH-Reposgit).
101+
102+
### Autor
103+
104+
Mantenido por [Josantonius](https://github.com/Josantonius/).
105+
106+
### Licencia
107+
108+
Este proyecto está licenciado bajo la **licencia MIT**. Consulta el archivo [LICENSE](LICENSE) para más información.

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# PHP Ip library
2+
3+
[![Latest Stable Version](https://poser.pugx.org/josantonius/ip/v/stable)](https://packagist.org/packages/josantonius/ip) [![Total Downloads](https://poser.pugx.org/josantonius/ip/downloads)](https://packagist.org/packages/josantonius/ip) [![Latest Unstable Version](https://poser.pugx.org/josantonius/ip/v/unstable)](https://packagist.org/packages/josantonius/ip) [![License](https://poser.pugx.org/josantonius/ip/license)](https://packagist.org/packages/josantonius/ip)
4+
5+
[Spanish version](README-ES.md)
6+
7+
PHP class to get user IP.
8+
9+
---
10+
11+
- [Installation](#installation)
12+
- [Requirements](#requirements)
13+
- [Quick Start and Examples](#quick-start-and-examples)
14+
- [Available Methods](#available-methods)
15+
- [Usage](#usage)
16+
- [Tests](#tests)
17+
- [Exception Handler](#exception-handler)
18+
- [Contribute](#contribute)
19+
- [Repository](#repository)
20+
- [Author](#author)
21+
- [Licensing](#licensing)
22+
23+
---
24+
25+
### Installation
26+
27+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
28+
29+
To install PHP Ip library, simply:
30+
31+
$ composer require Josantonius/Ip
32+
33+
### Requirements
34+
35+
This library is supported by PHP versions 7.0 or higher and is compatible with HHVM versions 3.0 or higher.
36+
37+
To use this library in HHVM (HipHop Virtual Machine) you will have to activate the scalar types. Add the following line "hhvm.php7.scalar_types = true" in your "/etc/hhvm/php.ini".
38+
39+
### Quick Start and Examples
40+
41+
To use this class, simply:
42+
43+
```php
44+
require __DIR__ . '/vendor/autoload.php';
45+
46+
use Josantonius\Ip\Ip;
47+
```
48+
### Available Methods
49+
50+
Available methods in this library:
51+
52+
```php
53+
Ip::get();
54+
```
55+
### Usage
56+
57+
Example of use for this library:
58+
59+
```php
60+
<?php
61+
require __DIR__ . '/vendor/autoload.php';
62+
63+
use Josantonius\Ip\Ip;
64+
65+
print_r(Ip::get()); # 66.249.76.29
66+
```
67+
68+
### Tests
69+
70+
To use the [test](tests) class, simply:
71+
72+
```php
73+
<?php
74+
$loader = require __DIR__ . '/vendor/autoload.php';
75+
76+
$loader->addPsr4('Josantonius\\Ip\\Tests\\', __DIR__ . '/vendor/josantonius/ip/tests');
77+
78+
use Josantonius\Ip\Tests\IpTest;
79+
80+
```
81+
Available test methods in this library:
82+
83+
```php
84+
IpTest::testGetIp();
85+
```
86+
87+
### Exception Handler
88+
89+
This library uses [exception handler](src/Exception) that you can customize.
90+
### Contribute
91+
1. Check for open issues or open a new issue to start a discussion around a bug or feature.
92+
1. Fork the repository on GitHub to start making your changes.
93+
1. Write one or more tests for the new feature or that expose the bug.
94+
1. Make code changes to implement the feature or fix the bug.
95+
1. Send a pull request to get your changes merged and published.
96+
97+
This is intended for large and long-lived objects.
98+
99+
### Repository
100+
101+
All files in this repository were created and uploaded automatically with [Reposgit Creator](https://github.com/Josantonius/BASH-Reposgit).
102+
103+
### Author
104+
105+
Maintained by [Josantonius](https://github.com/Josantonius/).
106+
107+
### Licensing
108+
109+
This project is licensed under **MIT license**. See the [LICENSE](LICENSE) file for more info.

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "josantonius/ip",
3+
"version": "1.0.0",
4+
"type": "library",
5+
"description": "PHP class to get user IP.",
6+
"keywords": [
7+
"IP",
8+
"Get user IP",
9+
"REMOTE_ADDR",
10+
"HHVM",
11+
"PHP"
12+
],
13+
"license": "MIT",
14+
"authors": [
15+
{
16+
"name": "Josantonius",
17+
"email": "info@josantonius.com",
18+
"homepage": "https://github.com/josantonius",
19+
"role": "Developer"
20+
}
21+
],
22+
"minimum-stability": "dev",
23+
"prefer-stable" : true,
24+
"require": {
25+
"php" : ">=7.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"Josantonius\\Ip\\": "src/"
30+
}
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"Josantonius\\Ip\\Tests\\": "tests/"
35+
}
36+
},
37+
"extra": {
38+
"branch-alias": {
39+
"dev-master": "1.0-dev"
40+
}
41+
}
42+
}

contributors.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Josantonius

src/Exception/IpException.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* PHP class to get user IP.
4+
*
5+
* @category JST
6+
* @package Ip
7+
* @subpackage IpException
8+
* @author Josantonius - info@josantonius.com
9+
* @copyright Copyright (c) 2017 JST PHP Framework
10+
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+
* @version 1.0.0
12+
* @link https://github.com/Josantonius/PHP-Ip
13+
* @since File available since 1.0.0 - Update: 2017-01-17
14+
*/
15+
16+
namespace Josantonius\Ip\Exception;
17+
18+
/**
19+
* Exception class for Ip library.
20+
*
21+
* You can use an exception and error handler with this library.
22+
*
23+
* @since 1.0.0
24+
*
25+
* @link https://github.com/Josantonius/PHP-ErrorHandler
26+
*/
27+
class IpException extends \Exception {
28+
29+
/**
30+
* Exception handler.
31+
*
32+
* @since 1.0.0
33+
*
34+
* @param string $msg → message error (Optional)
35+
* @param int $error → error code (Optional)
36+
* @param int $status → HTTP response status code (Optional)
37+
*/
38+
public function __construct(string $msg = '', int $error = 0, int $status = 0) {
39+
40+
$this->message = $msg;
41+
$this->code = $error;
42+
$this->statusCode = $status;
43+
}
44+
}

0 commit comments

Comments
 (0)