Changes for use .env file and not a php with sensible data (#37)

* * Changes for use .env file and not a php with sensible data

* * Changes for use .env file and not a php with sensible data
This commit is contained in:
Vitor Mattos 2017-01-15 14:38:04 -02:00 committed by Daniil Gentili
parent 92e8e4a00d
commit e7f642ea4c
5 changed files with 74 additions and 9 deletions

1
.env.example Normal file
View File

@ -0,0 +1 @@
NUMBER=+5521999596772

11
.gitignore vendored
View File

@ -4,6 +4,14 @@ _site
.idea/ .idea/
*.iml *.iml
# Eclipse
.buildpath
.project
.settings
# VI
*.swp
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
@ -76,3 +84,6 @@ web_API.log
db_connect.php db_connect.php
sessions sessions
docs_md docs_md
# .evn
.env

View File

@ -10,7 +10,8 @@
"phpseclib/phpseclib": "^2.0", "phpseclib/phpseclib": "^2.0",
"paragonie/constant_time_encoding": "^1|^2", "paragonie/constant_time_encoding": "^1|^2",
"paragonie/random_compat": "^2.0", "paragonie/random_compat": "^2.0",
"php": ">=5.6.0" "php": ">=5.6.0",
"vlucas/phpdotenv": "^2.4"
}, },
"authors": [ "authors": [
{ {

61
composer.lock generated
View File

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3a10bc147a48cd4573bcc9654d3be153", "hash": "b1210d4490e9d7e46ea39393f02b77d6",
"content-hash": "e220f48be9907b7881feacec0528a3e8",
"packages": [ "packages": [
{ {
"name": "danog/phpstruct", "name": "danog/phpstruct",
@ -57,7 +58,7 @@
"struct", "struct",
"unpack" "unpack"
], ],
"time": "2016-11-14T15:09:50+00:00" "time": "2016-11-14 15:09:50"
}, },
{ {
"name": "paragonie/constant_time_encoding", "name": "paragonie/constant_time_encoding",
@ -118,7 +119,7 @@
"hex2bin", "hex2bin",
"rfc4648" "rfc4648"
], ],
"time": "2016-07-11T20:32:06+00:00" "time": "2016-07-11 20:32:06"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
@ -166,7 +167,7 @@
"pseudorandom", "pseudorandom",
"random" "random"
], ],
"time": "2016-11-07T23:38:38+00:00" "time": "2016-11-07 23:38:38"
}, },
{ {
"name": "phpseclib/phpseclib", "name": "phpseclib/phpseclib",
@ -258,7 +259,57 @@
"x.509", "x.509",
"x509" "x509"
], ],
"time": "2016-10-04T00:57:04+00:00" "time": "2016-10-04 00:57:04"
},
{
"name": "vlucas/phpdotenv",
"version": "v2.4.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c",
"reference": "3cc116adbe4b11be5ec557bf1d24dc5e3a21d18c",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"Dotenv\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause-Attribution"
],
"authors": [
{
"name": "Vance Lucas",
"email": "vance@vancelucas.com",
"homepage": "http://www.vancelucas.com"
}
],
"description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.",
"keywords": [
"dotenv",
"env",
"environment"
],
"time": "2016-09-01 10:05:43"
} }
], ],
"packages-dev": [], "packages-dev": [],

View File

@ -20,16 +20,17 @@ if (file_exists('web_data.php')) {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline'); $MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
if (file_exists('number.php') && $MadelineProto === false) { if (file_exists('number.php') && $MadelineProto === false) {
include_once 'number.php'; $dotenv = new Dotenv\Dotenv(__DIR__);
$dotenv->load();
$MadelineProto = new \danog\MadelineProto\API($settings); $MadelineProto = new \danog\MadelineProto\API($settings);
$checkedPhone = $MadelineProto->auth->checkPhone(// auth.checkPhone becomes auth->checkPhone $checkedPhone = $MadelineProto->auth->checkPhone(// auth.checkPhone becomes auth->checkPhone
[ [
'phone_number' => $number, 'phone_number' => getenv('NUMBER'),
] ]
); );
\danog\MadelineProto\Logger::log($checkedPhone); \danog\MadelineProto\Logger::log($checkedPhone);
$sentCode = $MadelineProto->phone_login($number); $sentCode = $MadelineProto->phone_login(getenv('NUMBER'));
\danog\MadelineProto\Logger::log($sentCode); \danog\MadelineProto\Logger::log($sentCode);
echo 'Enter the code you received: '; echo 'Enter the code you received: ';
$code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1); $code = fgets(STDIN, (isset($sentCode['type']['length']) ? $sentCode['type']['length'] : 5) + 1);