Converter

More
18 years 3 months ago #129 by Norman
Converter was created by Norman
Hi Guys, I installed 1.7 two days ago because of all the spam. I have modified it to my taste and it's all systems go.

Converter.exe does a pretty god job but as we know it removes the emoticons in the original lish.txt file. It also removes all the BR tags so I have lost all the formatting. By formatting I mean the breaks in the text as can be seen in this message.

What I am left with is a small box symbol when viewed in Notepad. There
should be a BR tag after each of these symbols except for the last one in each message.

The symbol I am referring to is (I believe) the newline character. Unfortunately, Notepad cannot search for this character. I have manually edited a few messages to put the formatting back and it works. Now, if only I could knock up a quick PHP hack to do this :)

Norman

Please Log in or Create an account to join the conversation.

More
18 years 3 months ago #130 by Pete
Replied by Pete on topic Converter

Norman wrote: Converter.exe does a pretty god job but as we know it removes the emoticons in the original lish.txt file.


We are actually working on a way to fix this problem to allow the script to upgrade the smilies.

Norman wrote: It also removes all the BR tags so I have lost all the formatting. By formatting I mean the breaks in the text as can be seen in this message. What I am left with is a small box symbol when viewed in Notepad. There should be a BR tag after each of these symbols except for the last one in each message.


That small box that you see is actually a carriage return aka "New Line" in the text. Its how notepad represents it (as a small box).

Norman wrote: Unfortunately, Notepad cannot search for this character. I have manually edited a few messages to put the formatting back and it works. Now, if only I could knock up a quick PHP hack to do this :)


Notepad is not the way to do this. It would be a lot easier to do this in PHP or using a small VB Macro in word or excel. Hold off on doing this for a few days. I will see if I can make a few quick corrections to the coverter.

Pete

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
18 years 3 months ago #132 by Norman
Replied by Norman on topic Converter
Peter, OK and thanks. I could not agree with you more regarding Notepad.

I will hold off partly because you have suugested to do so and partly because I do not have the time right now :( I am sure that you knowledge of PHP is far, far greater than mine :)

Norman

Please Log in or Create an account to join the conversation.

More
18 years 3 months ago #133 by Pete
Replied by Pete on topic Converter
Ok, its done. Here is the NEW and improve converter script (which will be included in the next release of the guestbook as well). It fixes the smiley conversion issue, styling issue, the line break issue and a few other miscellanous issues like email hyperlink format:
Code:
<?php ////////////////////////////////////////////////////////// /// The purpose of this script is to convert the list.txt /// data from the old format (which was used for DigiOz /// Guestbook 1.0 through 1.6 to the new Object Oriented /// Serialized format used in Guestbook Version 1.7. ////////////////////////////////////////////////////////// ////////////////////////////////////// /// Function to reverse smiley face /// and style formatting in messages ////////////////////////////////////// function smiley_face_undo($yourmessage) { $i = 0; $ubb1 = array( "[b]", "[B]", "[/b]", "[/B]", "[u]", "[U]", "[/u]", "[/U]", "[i]", "[I]", "[/i]", "[/I]", "[center]", "[CENTER]", "[/center]", "[/CENTER]" ); $ubb2 = array( "<b>", "<B>", "</b>", "</B>", "<u>", "<U>", "</u>", "</U>", "<i>", "<I>", "</i>", "</I>", "<center>", "<CENTER>", "</center>", "</CENTER>" ); $sm1 = array( ":?:", ":D", ":?", ":cool:", ":cry:", ":shock:", ":evil:", ":!:", ":frown:", ":idea:", ":arrow:", ":lol:", ":x", ":mrgreen:", ":|", ":P", ":oops:", ":roll:", ":(", ":)", ":o", ":twisted:", ":wink:" ); $sm2 = array( "question", "biggrin", "confused", "cool", "cry", "eek", "evil", "exclaim", "frown", "idea", "arrow", "lol", "mad", "mrgreen", "neutral", "razz", "redface", "rolleyes", "sad", "smile", "surprised", "twisted", "wink" ); $sm3 = array( ": ?:", ":D", ":?", ":cool:", ":cry:", ":shock:", ":evil:", ":!:", ":frown:", ":idea:", ":arrow:", ":lol:", ":x", ":mrgreen:", ":|", ":P", ": oops :", ":roll:", ":(", ":)", ":o", ":twisted:", ":wink:" ); // UBB Code Removal and Replacing HTML tags with the appropriate UBB tag for ($i=0; $i<=15; $i++) { $yourmessage = str_replace($ubb2[$i], $ubb1[$i], $yourmessage); } // Removing smiley faces for guestbook entries for ($i=0; $i<=22; $i++) { $yourmessage = str_replace("<img src=\"images/icon_$sm2[$i].gif\" ALT=\"$sm3[$i]\">", $sm1[$i], $yourmessage); } return $yourmessage; } ////////////////////////////////////// /// Main Body of the Converter Script ////////////////////////////////////// include("../gbclass.php"); $fd = fopen ("list.txt", "r"); while (!feof ($fd)) { $buffer = fgets($fd, 4096); $lines[] = $buffer; } fclose ($fd); $countLines = count($lines); //echo $countLines; foreach ($lines as $value) { // Find each part of the entry $value = str_replace("<b>Date:</b>", "|", $value); $value = str_replace("<br><b>From:</b>", "|", $value); $value = str_replace("<br><b>Email: </b>", "|", $value); $value = str_replace("<br><br><b>Message:</b>", "|", $value); $value = smiley_face_undo($value); //$value = str_replace("\n","<br>", $value); //$value = str_replace("\r","<br>", $value); $msgArray = explode("|", $value); $tmpDate = $msgArray[1]; $tmpFrom = $msgArray[2]; $tmpEmail = $msgArray[3]; $tmpMessage = $msgArray[4]; $tmpEmail = str_replace('"','"', $tmpEmail); $tmpEmail = str_replace("'","'", $tmpEmail); $tmpEmail = strip_tags($tmpEmail); $tmpFrom = strip_tags($tmpFrom); $tmpFrom = str_replace('"','"', $tmpFrom); $tmpFrom = str_replace("'","'", $tmpFrom); $tmpMessage = strip_tags($tmpMessage, "<br>"); $tmpMessage = str_replace('"','"', $tmpMessage); $tmpMessage = str_replace("'","'", $tmpMessage); if($tmpDate != "" && $tmpFrom != "" && $tmpEmail != "" && $tmpMessage != "") { /* echo "DATE: ".$tmpDate."<br>"; echo "FROM: ".$tmpFrom."<br>"; echo "EMAIL: ".$tmpEmail."<br>"; echo "MESSAGE: ".$tmpMessage."<br>"; echo "<hr>"; */ $a = new gbClass(); $a->setGBVars($tmpDate,$tmpFrom,$tmpEmail,$tmpMessage); @ $fp = fopen("list_converted.txt","a"); flock($fp, 2); $data = serialize($a)."<!-- E -->"; fwrite($fp, $data); flock($fp, 3); fclose($fp); } } echo "<b>Guestbook Entry Conversion Completed!</b>"; ?>

This should take care of all the conversion issues. Enjoy!

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
18 years 3 months ago #134 by Norman
Replied by Norman on topic Converter
Hi Pete, My word, that was quick.

I took my preserved list.txt as before together with the new converter.php and a list_converted.txt. Run the new converter.php via the web browser and it did it in a flash. Unfortunately, the list_converted.txt is considerably smaller and only contains about 30% of the original entries. I had between 14 and 15 pages at ten per page, now I have between 4 and 5 pages :?

If I get time tonight, I will see if I can established what messages are missing, i.e. random or a large chunk.

Thanks, Norman

Please Log in or Create an account to join the conversation.

More
18 years 3 months ago #135 by Pete
Replied by Pete on topic Converter
Hmm.... it is probably getting stuck on a special character or something. I will look into this more tomorrow (feel free to let me know what entry the converter is getting stuck on in your list.txt file).

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.125 seconds
Powered by Kunena Forum