-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add wraper to databases; reorganize structure and add composer support
- Loading branch information
Felipe Braz
committed
Nov 28, 2018
1 parent
f4fc108
commit a8843c7
Showing
6 changed files
with
661 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "fbraz3/php5-compatibility-layer", | ||
"description": "Implementa de forma transparente funções que foram descontinuadas no PHP7", | ||
"type": "library", | ||
"license": "GPL-3.0", | ||
"require": { | ||
"php": "^7.0", | ||
"ext-openssl": "*" | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"src/wrapper-legacy.php", | ||
"src/wrapper-mssql.php", | ||
"src/wrapper-mysql.php" | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
if (!function_exists('mysql_connect')) { | ||
echo "Function mysql_connect not exists!\n"; | ||
} | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
if (function_exists('mysql_connect')) { | ||
echo "Function mysql_connect now exists!\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: felipebraz | ||
* Date: 09/07/18 | ||
* Time: 13:33 | ||
*/ | ||
|
||
if (!function_exists('ereg')) { | ||
function ereg($pattern, $subject, &$matches = array()) | ||
{ | ||
return preg_match('/' . $pattern . '/', $subject, $matches); | ||
} | ||
} | ||
if (!function_exists('eregi')) { | ||
function eregi($pattern, $subject, &$matches = array()) | ||
{ | ||
return preg_match('/' . $pattern . '/i', $subject, $matches); | ||
} | ||
} | ||
if (!function_exists('ereg_replace')) { | ||
function ereg_replace($pattern, $replacement, $string) | ||
{ | ||
return preg_replace('/' . $pattern . '/', $replacement, $string); | ||
} | ||
} | ||
if (!function_exists('eregi_replace')) { | ||
function eregi_replace($pattern, $replacement, $string) | ||
{ | ||
return preg_replace('/' . $pattern . '/i', $replacement, $string); | ||
} | ||
} | ||
if (!function_exists('split')) { | ||
function split($pattern, $subject, $limit = -1) | ||
{ | ||
return preg_split('/' . $pattern . '/', $subject, $limit); | ||
} | ||
} | ||
if (!function_exists('spliti')) { | ||
function spliti($pattern, $subject, $limit = -1) | ||
{ | ||
return preg_split('/' . $pattern . '/i', $subject, $limit); | ||
} | ||
} | ||
if (!function_exists('session_unregister')) { | ||
function session_unregister($value) | ||
{ | ||
unset($_SESSION[$value]); | ||
return true; | ||
} | ||
} | ||
if (!function_exists('session_register')) { | ||
function session_register($variavel) | ||
{ | ||
global $$variavel; | ||
$_SESSION[$variavel] = $$variavel; | ||
return true; | ||
} | ||
} | ||
|
||
/** | ||
* Escapa as mesmas strings do mysql_real_escape_string, mas sem precisar de ponteiro de conexao | ||
* "Characters encoded are \, ', ", NUL (ASCII 0), \n, \r, and Control+Z" | ||
* @see https://dev.mysql.com/doc/refman/5.7/en/mysql-real-escape-string.html | ||
* @see https://stackoverflow.com/questions/1162491/alternative-to-mysql-real-escape-string-without-connecting-to-db | ||
* @param string $value | ||
* @return string | ||
*/ | ||
function mres($value) | ||
{ | ||
$search = array("\\", "\x00", "\n", "\r", "'", '"', "\x1a"); | ||
$replace = array("\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"); | ||
|
||
return str_replace($search, $replace, $value); | ||
} | ||
|
||
if (!function_exists('mysql_real_escape_string')) { | ||
/** | ||
* Escapes special characters in a string for use in an SQL statement | ||
* @link http://php.net/manual/en/function.mysql-real-escape-string.php | ||
* The string that is to be escaped. | ||
* </p> | ||
* @return string the escaped string, or false on error. | ||
* @since 4.3.0 | ||
* @since 5.0 | ||
*/ | ||
function mysql_real_escape_string($value) | ||
{ | ||
return mres($value); | ||
} | ||
} | ||
if (!function_exists('mysql_escape_string')) { | ||
/** | ||
* Escapes a string for use in a mysql_query | ||
* @link http://php.net/manual/en/function.mysql-escape-string.php | ||
* @deprecated 5.3.0 Use mysql_real_escape_string() instead | ||
* The string that is to be escaped. | ||
* </p> | ||
* @return string the escaped string. | ||
* @since 4.0.3 | ||
* @since 5.0 | ||
*/ | ||
function mysql_escape_string($value) | ||
{ | ||
return mres($value); | ||
} | ||
} |
Oops, something went wrong.