diff --git a/serendipity_event_oembed/ChangeLog b/serendipity_event_oembed/ChangeLog
new file mode 100644
index 00000000..e6f161c3
--- /dev/null
+++ b/serendipity_event_oembed/ChangeLog
@@ -0,0 +1,3 @@
+Version 1.00 (brockhaus)
+-----------------------
+* Initial Release, have fun! :)
\ No newline at end of file
diff --git a/serendipity_event_oembed/CurlFetcher.php b/serendipity_event_oembed/CurlFetcher.php
new file mode 100644
index 00000000..9792cf5c
--- /dev/null
+++ b/serendipity_event_oembed/CurlFetcher.php
@@ -0,0 +1,79 @@
+ array ( 'method' => 'GET', 'max_redirects' => $max_redirects, ),);
+ $file_content = file_get_contents($fileurl, null, stream_context_create($context));
+ }
+ return $file_content;
+ }
+
+ /**
+ * Handling redirections with curl if safe_mode or open_basedir is enabled. The function working transparent, no problem with header and returntransfer options. You can handle the max redirection with the optional second argument (the function is set the variable to zero if max redirection exceeded).
+ * Second parameter values:
+ * - maxredirect is null or not set: redirect maximum five time, after raise PHP warning
+ * - maxredirect is greather then zero: no raiser error, but parameter variable set to zero
+ * - maxredirect is less or equal zero: no follow redirections
+ * (see: http://php.net/manual/en/function.curl-setopt.php)
+ */
+ private function curl_exec_follow(/*resource*/ $ch, /*int*/ &$maxredirect = null) {
+ $mr = $maxredirect === null ? 5 : intval($maxredirect);
+ if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $mr > 0);
+ curl_setopt($ch, CURLOPT_MAXREDIRS, $mr);
+ } else {
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ if ($mr > 0) {
+ $newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+
+ $rch = curl_copy_handle($ch);
+ curl_setopt($rch, CURLOPT_HEADER, true);
+ curl_setopt($rch, CURLOPT_NOBODY, true);
+ curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
+ curl_setopt($rch, CURLOPT_RETURNTRANSFER, true);
+ do {
+ curl_setopt($rch, CURLOPT_URL, $newurl);
+ $header = curl_exec($rch);
+ if (curl_errno($rch)) {
+ $code = 0;
+ } else {
+ $code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
+ if ($code == 301 || $code == 302) {
+ preg_match('/Location:(.*?)\n/', $header, $matches);
+ $newurl = trim(array_pop($matches));
+ } else {
+ $code = 0;
+ }
+ }
+ } while ($code && --$mr);
+ curl_close($rch);
+ if (!$mr) {
+ if ($maxredirect === null) {
+ trigger_error('Too many redirects. When following redirects, libcurl hit the maximum amount.', E_USER_WARNING);
+ } else {
+ $maxredirect = 0;
+ }
+ return false;
+ }
+ curl_setopt($ch, CURLOPT_URL, $newurl);
+ }
+ }
+ return curl_exec($ch);
+ }
+}
\ No newline at end of file
diff --git a/serendipity_event_oembed/OEmbedDatabase.php b/serendipity_event_oembed/OEmbedDatabase.php
new file mode 100644
index 00000000..e994584c
--- /dev/null
+++ b/serendipity_event_oembed/OEmbedDatabase.php
@@ -0,0 +1,99 @@
+html)) {
+ $oembed->html = OEmbedDatabase::cleanup_html($oembed->html);
+ }
+ $save = array();
+ $save['urlmd5'] = md5($url);
+ $save['url'] = $url;
+ $save['oetype'] = $oembed->type;
+ $save['oeobj'] = serialize($oembed);
+ serendipity_db_insert( PLUGIN_OEMBED_DATABASEVNAME, $save );
+ return $oembed;
+ }
+
+ function load_oembed($url) {
+ global $serendipity;
+ if (empty($url)) return null;
+
+ $urlmd5 = md5($url);
+ $query = "select oeobj from {$serendipity['dbPrefix']}" . PLUGIN_OEMBED_DATABASEVNAME . " where urlmd5='$urlmd5'";
+
+ $rows = serendipity_db_query($query);
+ if (!is_array($rows)) { // fresh search
+ return null;
+ }
+ else {
+ $oeobj = null;
+ foreach ($rows as $row) {
+ $oeobj = $row['oeobj'];
+ if (!empty($oeobj)) break;
+ }
+ if (!empty($oeobj)) {
+ return unserialize($oeobj);
+ }
+
+ }
+ return null;
+ }
+ function clear_cache() {
+ global $serendipity;
+ $q = "delete from {$serendipity['dbPrefix']}" . PLUGIN_OEMBED_DATABASEVNAME;
+ serendipity_db_schema_import($q);
+ }
+
+ function install(&$obj) {
+ global $serendipity;
+
+ if (!OEmbedDatabase::table_created(PLUGIN_OEMBED_DATABASEVNAME)) {
+ $md5test = md5("test");
+ $md5len = strlen($md5test);
+ $q = "create table {$serendipity['dbPrefix']}" . PLUGIN_OEMBED_DATABASEVNAME. " (" .
+ "urlmd5 char($md5len) not null, " .
+ "url varchar(3000) not null, " .
+ "oetype varchar(20) not null, " .
+ "oeobj text not null, " .
+ "primary key (urlmd5)" .
+ ")";
+
+ $result = serendipity_db_schema_import($q);
+
+ if ($result !== true) {
+ return;
+ }
+ }
+ }
+
+
+ function table_created($table = PLUGIN_OEMBED_DATABASEVNAME) {
+ global $serendipity;
+
+ $q = "select count(*) from {$serendipity['dbPrefix']}" . $table;
+ $row = serendipity_db_query($q, true, 'num');
+
+ if (!is_numeric($row[0])) { // if the response we got back was an SQL error.. :P
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ function cleanup_html( $str ) {
+ $str = trim($str);
+ // Clear unicode stuff
+ $str=str_ireplace("\u003C","<",$str);
+ $str=str_ireplace("\u003E",">",$str);
+ // Clear CDATA Trash.
+ $str = preg_replace("@^$@", '$1', $str);
+ $str = preg_replace("@^$@", '$1', $str);
+ return $str;
+ }
+
+}
\ No newline at end of file
diff --git a/serendipity_event_oembed/OEmbedTemplater.php b/serendipity_event_oembed/OEmbedTemplater.php
new file mode 100644
index 00000000..2e35757c
--- /dev/null
+++ b/serendipity_event_oembed/OEmbedTemplater.php
@@ -0,0 +1,35 @@
+assign('oembedurl',$url);
+ $serendipity['smarty']->assign('oembed',(array)$oembed);
+ $tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
+ if (!$tfile || $filename == $tfile) {
+ $tfile = dirname(__FILE__) . '/' . $filename;
+ }
+
+ $inclusion = $serendipity['smarty']->security_settings[@INCLUDE_ANY];
+ $serendipity['smarty']->security_settings[@INCLUDE_ANY] = true;
+
+ if (version_compare($serendipity['version'], '1.7-alpha1','>=')) {
+ $serendipity['smarty']->disableSecurity();
+ }
+ else {
+ $serendipity['smarty']->security = false;
+ }
+
+ // be smarty 3 compat including the serendipity_smarty class wrappers ->fetch and ->display methods and remove changed parameter number 4
+ $content = @$serendipity['smarty']->fetch('file:'. $tfile);//, false
+
+ $serendipity['smarty']->security_settings[@INCLUDE_ANY] = $inclusion;
+
+ return $content;
+ }
+}
\ No newline at end of file
diff --git a/serendipity_event_oembed/lang_de.inc.php b/serendipity_event_oembed/lang_de.inc.php
new file mode 100755
index 00000000..3896913c
--- /dev/null
+++ b/serendipity_event_oembed/lang_de.inc.php
@@ -0,0 +1,9 @@
+
+ * EN-Revision: Revision of lang_en.inc.php
+ */
+
+@define('PLUGIN_EVENT_OEMBED_NAME', 'oEmbed Plugin');
diff --git a/serendipity_event_oembed/lang_en.inc.php b/serendipity_event_oembed/lang_en.inc.php
new file mode 100755
index 00000000..4452f636
--- /dev/null
+++ b/serendipity_event_oembed/lang_en.inc.php
@@ -0,0 +1,26 @@
+
+ * EN-Revision: Revision of lang_en.inc.php
+ */
+
+@define('PLUGIN_EVENT_OEMBED_NAME', 'oEmbed Plugin');
+@define('PLUGIN_EVENT_OEMBED_DESC', 'oEmbed is a format for allowing an embedded representation of a URL on your blog. It allows blog articles to display embedded content (such as tweets, photos or videos) when a user posts a link to that resource, without having to parse the resource directly.');
+
+@define('PLUGIN_EVENT_OEMBED_MAXWIDTH', 'Max width of replacements');
+@define('PLUGIN_EVENT_OEMBED_MAXWIDTH_DESC', 'This is the max width the service should produce when providing a replacement. Not all services supports this but most.');
+@define('PLUGIN_EVENT_OEMBED_MAXHEIGHT', 'Max height of replacements');
+@define('PLUGIN_EVENT_OEMBED_MAXHEIGHT_DESC','This is the max height the service should produce when providing a replacement. Not all services supports this but most.');
+
+@define('PLUGIN_EVENT_OEMBED_INFO', '
oEmbed Plugin
' .
+'
'.
+'This plugin expands URLs to pages of known services to a representation of that URL. It shows i.e. the video for a youtube URL or the image instead of a flickr URL. ' .
+'The syntax of this plugin is [embed link] (or [e link] if you like it shorter). '.
+'If the link is not supported by the plugin at the moment, it will replace the URL by a link pointing to that URL. '.
+'
'.
+'Please put this plugin at the top of your plugins list, so no other plugin can change this syntax (by adding a href i.e.)'.
+'
'.
+'The plugin supports representations of the following link types:%s'.
+'