$1'; // Check for [quote] text $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism","$QuoteLayout", $Text); - + + // Check for [quote=Author] text + + $t_wrote = t('$1 wrote:'); + + $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism", + "
" . $t_wrote . " $2", + $Text); + // [img=widthxheight]image source[/img] $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); @@ -219,6 +267,13 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); } + // Unhide all [noparse] contained bbtags unspacefying them + // and triming the [noparse] tag. + + $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_unspacefy_and_trim',$Text); + $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim',$Text); + $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim',$Text); + // fix any escaped ampersands that may have been converted into links $Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text); if(strlen($saved_image)) diff --git a/include/conversation.php b/include/conversation.php index 20c7b2a511..3d13a11798 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -4,6 +4,28 @@ * Render actions localized */ function localize_item(&$item){ + + $Text = $item['body']; + $saved_image = ''; + $img_start = strpos($Text,'[img]data:'); + $img_end = strpos($Text,'[/img]'); + + if($img_start !== false && $img_end !== false && $img_end > $img_start) { + $start_fragment = substr($Text,0,$img_start); + $img_start += strlen('[img]'); + $saved_image = substr($Text,$img_start,$img_end - $img_start); + $end_fragment = substr($Text,$img_end + strlen('[/img]')); + $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment; + $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is'; + $replace = '[url=' . z_path() . '/redir/' . $item['contact-id'] + . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ; + + $Text = preg_replace($search,$replace,$Text); + + if(strlen($saved_image)) + $item['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text); + } + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){ @@ -262,15 +284,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']); - $location = (($item['location']) ? '' . $item['location'] . '' : ''); - $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); - if($coord) { - if($location) - $location .= '
Memory used: | $mem_used MB |
Peak memory used: | $peak_mem_used MB |
Time taken: | $time_taken sec |
\n";
+
+ echo "Checking database file name … ";
+
+ if($dbfile == "") {
+ echo "Please provide the name of the database file!
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "$dbfile
\n";
+
+ if(!$failed) {
+
+ echo "Touching/Creating " . htmlentities($dbfile) . " … ";
+
+ if(touch($dbfile) === FALSE) {
+ echo "Failed to touch the database file. Please check the given filename and/or fix the permissions of $dbfile_directory.
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "done
\n";
+
+ }
+
+ if(!$failed) {
+
+ echo "Setting file permissions to 0666 &hellip ";
+
+ if(chmod($dbfile, 0666) === FALSE) {
+ echo "Failed to change the permissions of $dbfile_directory/$dbfile. Please adjust them manually.
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "done
\n";
+
+ }
+
+ if(!$failed) {
+
+ echo "Checking if the given file is empty &hellip ";
+
+ if(filesize($dbfile) > 0) {
+ echo "$dbfile_directory/$dbfile is not empty. Can't create a new database. Please delete/empty this file or give another filename.
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "it is
\n";
+
+ }
+
+ if(!$failed) {
+
+ echo "Connecting to $dbfile … ";
+
+ $db = dba_open($dbfile, "c", $_POST['handler']);
+
+ if($db === FALSE) {
+ echo "Could not connect to the database!
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "done
\n";
+
+ }
+
+ if(!$failed) {
+
+ echo "Storing necessary internal variables &hellip ";
+
+ $internals = array(
+ "bayes*dbversion" => "2",
+ "bayes*texts.ham" => "0",
+ "bayes*texts.spam" => "0"
+ );
+
+ foreach($internals as $key => $value) {
+ if(dba_insert($key, $value, $db) === FALSE) {
+ echo "Failed to insert data!
\n";
+ $failed = TRUE;
+ break;
+ }
+ }
+
+ if(!$failed)
+ echo "done
\n";
+
+ }
+
+ if(!$failed) {
+
+ echo "Trying to read data from the database &hellip ";
+
+ $dbversion = dba_fetch("bayes*dbversion", $db);
+
+ if($dbversion != "2") {
+ echo "Failed to read data!
\n";
+ $failed = TRUE;
+ }
+ else
+ echo "success
\n";
+ }
+
+ if(!$failed) {
+
+ dba_close($db);
+
+ echo "
Successfully created a new b8 database!
\n\n"; + echo "Filename: | $dbfile_directory/$dbfile |
DBA handler: | {$_POST['handler']} |
Move this file to it's destination directory (default: the base directory of b8) to use it with b8. Be sure to use the right DBA handler in b8's configuration."; + + } + + echo "
\n\n"; + +} + +if($failed === TRUE or !isset($_POST['handler'])) { + +echo <<+The following table shows all available DBA handlers. Please choose the "Berkeley DB" one. +
+ +Handler | Description | |
$name | $version |