DigiOz Programming Forum


Feel free to post any Programming related questions you may have here

Importing from other guestbooks

Please Post Questions for All Other DigiOz Scripts Here.

Moderator: Pete

Importing from other guestbooks

Postby Hawk » 08/08/2012 09:35

I have been using a guestbook that has no ip blocking, now I am getting flooded with spam and cannot block the ip's. I would love to use your guestbook, but of course everyone's flat file is different and yours looks like it uses multiple files. Is there an easy way to import from another flat file?? Thanks!!!
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Pete » 08/08/2012 14:05

Hello Hawk,

Do you have a sample data file from your old guestbook? If so email it to us at support@digioz.com and we'll take a look at it for you.

Pete
DigiOz Webmaster
http://www.digioz.com
User avatar
Pete
Site Admin
 
Posts: 518
Joined: 09/29/2005 14:48
Location: Chicago, IL

Re: Importing from other guestbooks

Postby Hawk » 08/14/2012 08:36

Sorry for the late reply, been out of town. Thanks for looking at this. Sending it in now. Thanks!!!!
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Pete » 08/14/2012 13:36

Hey Mike,

I looked at your data file. Here is what a typical record looks like:

Code: Select all
|~|20110922061446|~|1/24/2005|~|Some Guy|~|email@mail.com|~|Entry Message Goes Here|~||~|1.2.3.4|~|


Based on the above layout, I wrote the following converter code to convert your .dat file data to DigiOz Guestbook 1.7.2 format. Here is the code for "converter_mike.php":

Code: Select all
<?php
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)
{
    $entry_array = explode('|~|',$value);
   
    /*
    echo "Time:".$entry_array[1]."<br>";
    echo "Date:".$entry_array[2]."<br>"; 
    echo "Name:".$entry_array[3]."<br>";
    echo "Email:".$entry_array[4]."<br>";
    echo "Message:".$entry_array[5]."<br>";
    echo "???:".$entry_array[6]."<br>";
    echo "IP:".$entry_array[7]."<br>";
    echo "<hr>";
    */
   
    $tmpDate = $entry_array[2]; 
    $tmpFrom = $entry_array[3];
    $tmpEmail = $entry_array[4];
    $tmpMessage = $entry_array[5];   
 
    $tmpEmail = str_replace('"','"', $tmpEmail);
    $tmpEmail = str_replace("'","'", $tmpEmail);

    $tmpFrom = strip_tags($tmpFrom);
    $tmpFrom = str_replace('"','"', $tmpFrom);
    $tmpFrom = str_replace("'","'", $tmpFrom);

    $tmpMessage = strip_tags($tmpMessage);
    $tmpMessage = str_replace('"','"', $tmpMessage);
    $tmpMessage = str_replace("'","'", $tmpMessage);

    if($tmpDate != "" && $tmpFrom != "" && $tmpEmail != "" && $tmpMessage != "")
    {
        $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>";

?>


The converter assumes the following:

  • Each guestbook entry resides on a separate line in the data file.
  • Email address seems to be optional, so you will have to set email to optional in the new guestbook file.
  • The following mapping was assumed based on sequence of entry blocks (basically these are only the fields that we need for the new guestbook):
    • 2 - Date
    • 3 - Name
    • 4 - Email
    • 5 - Message

You can edit the data in the .dat file with Notepad and re-run the script to make corrections to the data before finalizing the converted file. All you have to do is to create a file called "converter_mike.php" and place it in the "/converter/" folder of your guestbook, along with a file called "list.txt" then run the php file. It will convert and create a new file called "list_converted.txt" when it is done, which you can then copy into "/data/" folder and rename to "list.txt" to use for your guestbook.

Let me know if you have any questions.

Pete
DigiOz Webmaster
http://www.digioz.com
User avatar
Pete
Site Admin
 
Posts: 518
Joined: 09/29/2005 14:48
Location: Chicago, IL

Re: Importing from other guestbooks

Postby Hawk » 08/14/2012 13:45

Wow!!! Thanks so much!!!!! The guestbook I was using was Ardguest in case anyone else is coming over from it. Again, Pete, I cannot thank you enough!!! Now to get it all converted and set up!!!

Edit:
Here is the website to the old guestbook:

http://www.promosi-web.com/script/guestbook/
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Hawk » 09/20/2012 14:34

I am just now getting around to getting this implemented. Is there a way to sort the guestbook by date? I uploaded the file you sent me and the 2004 posts start on the first page. I can manually go in and adjust it I guess.
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Hawk » 09/20/2012 14:47

http://www.alexisbatastini.com/TestGues ... &order=asc

In case you want to see what I am talking about.
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Pete » 09/20/2012 14:47

The guestbook shows entries in descending order (based on the order they were added in). If you think about this, if users keep adding new entries as time goes by, the date they were added will always increase, so this would mean that the entries would show in descending date order automatically, unless you have manually added entries to the data file or imported entries from a different guestbook that did not store entries in this manner.

Does this make sense?

Pete
DigiOz Webmaster
http://www.digioz.com
User avatar
Pete
Site Admin
 
Posts: 518
Joined: 09/29/2005 14:48
Location: Chicago, IL

Re: Importing from other guestbooks

Postby Hawk » 09/20/2012 14:52

Totally makes sense. I am referring to the old data from the old flat file. I would like to sort it so the oldest is last as well. It is the opposite, except for 5 or so entries. Every entry is from the converted flat file except the one I did today with Test in the body.
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Pete » 09/20/2012 15:00

In your case you may have to do some manual editing. Take your data file for example:

http://www.alexisbatastini.com/TestGues ... a/list.txt

Open this file in Notepad, you will see something like this:

Code: Select all
O:7:"gbClass":4:{s:6:"gbDate";s:23:"May 31, 2012 - 12:44 PM";s:6:"gbFrom";s:6:"Morgan";s:7:"gbEmail";s:20:"mbatastini@aflac.com";s:9:"gbMessage";s:721:"Hey Sissy...  To say that I miss you would be the understatement of the century.  Words cannot express just how badly I wish you were still here with me, but I know that you are watching over me and are with me every step of the way, in everything that I do.  Today you would have turned 22 and I can just imagine the wonderful and beautiful woman you would have become.  God is so lucky to have you amongst his angels and I am even more lucky to have you as my sister and Guardian Angel. I hope you are throwing one heck of a party in Heaven and know that we are all thinking of you, missing you, and loving you from down here, not just today but everyday.  Sending butterfly kisses and the biggest hug - Your Big Sister";}<!-- E -->O:7:"gbClass":4:{s:6:"gbDate";s:20:"Thu 09/20/12 12:29PM";s:6:"gbFrom";s:4:"Mike";s:7:"gbEmail";s:13:"blah@blah.com";s:9:"gbMessage";s:9:"Test
<br>";}<!-- E --> ...


Each post is separated from the next using the "<!-- E -->" separator, which means you can copy and paste an entry like the following:

Code: Select all
O:7:"gbClass":4:{s:6:"gbDate";s:20:"Thu 09/20/12 12:29PM";s:6:"gbFrom";s:4:"Mike";s:7:"gbEmail";s:13:"blah@blah.com";s:9:"gbMessage";s:9:"Test
<br>";}<!-- E -->


And then paste it after another entry "<!-- E -->" separator.

Pete
DigiOz Webmaster
http://www.digioz.com
User avatar
Pete
Site Admin
 
Posts: 518
Joined: 09/29/2005 14:48
Location: Chicago, IL

Re: Importing from other guestbooks

Postby Hawk » 09/20/2012 15:23

So dont change the data itself, just rearrange the order in the list.txt?
Hawk
 
Posts: 7
Joined: 08/08/2012 09:28

Re: Importing from other guestbooks

Postby Pete » 09/20/2012 15:25

Correct. I don't recommend changing the data, because if you do you will have to also change the length of the string that each serialized attribute contains, and that tends to get very tedious. Just rearrange the order of the whole entry.

Pete
DigiOz Webmaster
http://www.digioz.com
User avatar
Pete
Site Admin
 
Posts: 518
Joined: 09/29/2005 14:48
Location: Chicago, IL


Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest

cron