* fix the error of pcre.backtrack_limit for preg_match.

This commit is contained in:
wyd621
2013-07-29 14:56:38 +08:00
parent fb1b8520a3
commit fa8937eff4
2 changed files with 11 additions and 10 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ $(document).ready(function()
var contentType = arr[0].split(";")[0].split(":")[1];
html = '<img src="' + result + '" alt="" />';
$.post(createLink('file', 'ajaxEditorImage'), {editor: html}, function(data){cmd.inserthtml(data);});
$.post(createLink('file', 'ajaxPasteImage'), {editor: html}, function(data){cmd.inserthtml(data);});
};
reader.readAsDataURL(file);
@@ -94,7 +94,7 @@ $(document).ready(function()
var html = K(doc.body).html();
if(html.search(/<img src="data:.+;base64,/) > -1)
{
$.post(createLink('file', 'ajaxEditorImage'), {editor: html}, function(data){K(doc.body).html(data);});
$.post(createLink('file', 'ajaxPasteImage'), {editor: html}, function(data){K(doc.body).html(data);});
}
}, 80);
});
+9 -8
View File
@@ -237,30 +237,31 @@ class fileModel extends model
}
/**
* Replace editor image
* Paste image in kindeditor at firefox and chrome.
*
* @param string $data
* @access public
* @return string
*/
public function replaceEditorImage($data)
public function pasteImage($data)
{
preg_match_all('/<img src=\\\"(data:image\/(\w+);base64,(.+))\\\" .+ \/>/U', $data, $out);
foreach($out[3] as $id => $base64Image)
ini_set('pcre.backtrack_limit', strlen($data));
preg_match_all('/<img src=\\\"(data:image\/(\S+);base64,(\S+))\\\" .+ \/>/U', $data, $out);
foreach($out[3] as $key => $base64Image)
{
$imageData = base64_decode($base64Image);
$file['extension'] = $out[2][$id];
$file['pathname'] = $this->setPathName($id, $file['extension']);
$file['extension'] = $out[2][$key];
$file['pathname'] = $this->setPathName($key, $file['extension']);
$file['size'] = strlen($imageData);
$file['addedBy'] = $this->app->user->account;
$file['addedDate'] = helper::today();
$file['title'] = 'Paste in editor';
$file['title'] = basename($file['pathname']);
file_put_contents($this->savePath . $file['pathname'], $imageData);
$this->dao->insert(TABLE_FILE)->data($file)->exec();
$data = str_replace($out[1][$id], $this->webPath . $file['pathname'], $data);
$data = str_replace($out[1][$key], $this->webPath . $file['pathname'], $data);
}
return $data;