Merge pull request #48 from Claers/fix/check_pg_cmd_before_exec_them

Fix : Test pg_escape and pg_unescape exist before executing them
This commit is contained in:
jiaxin huang
2022-04-19 15:33:24 +08:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -132,7 +132,12 @@ class DbHelper
public function getExtra($data)
{
if ($this->getDBType() == "pgsql" && is_resource($data)) {
$extra = pg_unescape_bytea(stream_get_contents($data));
if (function_exists("pg_unescape_bytea")) {
$extra = pg_unescape_bytea(stream_get_contents($data));
}
else {
$extra = stream_get_contents($data);
}
return unserialize($extra);
}
return unserialize($data);

View File

@@ -65,7 +65,9 @@ class YoutubeHelper
if ($file) {
$extra = serialize($extra);
if($this->dbconn->getDBType() == "pgsql"){
$extra = pg_escape_bytea($extra);
if (function_exists("pg_escape_bytea")) {
$extra = pg_escape_bytea($extra);
}
}
$data = [
'uid' => $this->user,