function convertdatauris($in) { global $CFG, $userid; $okext = array('jpeg' => '.jpg', 'gif' => '.gif', 'png' => '.png'); if (strpos($in, 'data:image') === false) { return $in; } $in = preg_replace('/<img[^>]*src="data:image[^>]*$/', '', $in); if (!isset($CFG['GEN']['noFileBrowser'])) { preg_match_all('/<img[^>]*src="(data:image\\/(\\w+);base64,([^"]*))"/', $in, $matches); foreach ($matches[3] as $k => $code) { $img = base64_decode($code); $ext = $matches[2][$k]; if (!isset($okext[$ext])) { continue; } $key = "ufiles/{$userid}/pastedimage" . tzdate("ymd-His", time()) . '-' . $k . $okext[$ext]; storecontenttofile($img, $key, "public"); $in = str_replace($matches[1][$k], getuserfileurl($key), $in); } return $in; } else { $in = preg_replace('/<img[^>]*src="data:image[^>]*>/', '', $in); } return $in; }
function extractToS3($keybase, $sec = "public") { $n = 0; if ($this->numFiles > 0) { foreach ($this->files as $key => $information) { if (storecontenttofile($information["file"], $keybase . '/' . $information["name"], $sec)) { $n++; } } } return $n; }