Gossamer Forum
Home : Products : Links 2.0 : Discussions :

How Do you add Links in Batches or abundantly In Links 2.0?

Quote Reply
How Do you add Links in Batches or abundantly In Links 2.0?
Would anyone else around here happen to know how i can add links to Links 2.0 in batches? I doubt that single adding EACH link manually 1 at a time is the best it can get. Any help or tip on this?
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Please post product specific questions and comments in their designated forums.

As to your question, that depends on how the data you want to insert is comprised. The general concept is thus:

1) open linksid.txt for reading, retrieve last inserted ID, close file.
2) make backup of links.db
4) open links.db for writing, open old data file for reading
5) for each record read, increment ID number
6) format and/or insert values where needed (in Links format)
7) print new record to links.db
8) close old data file & links.db
9) open linksid.txt for writing, print new value, close.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
In Reply To:
Please post product specific questions and comments in their designated forums.

As to your question, that depends on how the data you want to insert is comprised. The general concept is thus:

1) open linksid.txt for reading, retrieve last inserted ID, close file.
2) make backup of links.db
4) open links.db for writing, open old data file for reading
5) for each record read, increment ID number
6) format and/or insert values where needed (in Links format)
7) print new record to links.db
8) close old data file & links.db
9) open linksid.txt for writing, print new value, close.
Thank you very much Phillip, i really appreciate it.
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
No problem. if you need further assistance with the actual coding, don't hesitate to ask. the more specific you can be on your requirements (including sample data to be imported) the easier and quicker we can help you.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Actually, i do need more help. See thing with me is that these things look like reading Japanese, because i am not any good with coding anything let alone trying to tweak them.

I want to import links like this into my "Teens" category..

Squeeze My Tits|http://www.littlethumbs.com/free/tresseme/Perfect-Nude-Teens/?coupon=1002835|Cutie plays with her boobies outside and squeezes them together wearing only a tshirt

Sweet Bikini Tresseme|http://www.littlethumbs.com/free/tresseme/Hot-Teen-Models/?coupon=1002835|Hottie in a bikini she has a killer tight body and and ass you can write home about

Perfect Nubile Ravon|http://www.littlethumbs.com/free/ravon/breasts/?coupon=1002835|These girls are blossoming into beautiful women

Hottie Ravon Tight Ass|http://www.littlethumbs.com/free/ravon/girls-naked/?coupon=1002835|Exclusive content of the freshent girls

Sexy Nubile Ravon|http://www.littlethumbs.com/free/ravon/girls-wild/?coupon=1002835|Naked teen girls and erotic women



They are broken down in this format.... Title|URL|Description

Usually if it was a TGP script, it could be imported like that, but these are freesites for linklists and Links is one of the best scripts for Linklist, i was told. So i am trying to see if there is a way i can import freesite title,url,description like that. I have thousands of them to add, and i cannot do them all one by one.

I hope i was a bit more specific, and if you think i am missing anything, please do not hesistate to tell me. Btw, the site i am using this for is http://freesitearchive.com if you would like to take a look. Thank you very much once again, and i really appreciate every feedback you give me.
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Looks like enough info. I'll see if I can write an import script for you this weekend. I just need to familiarize myself with the database formats again since I haven't run Links 2.0 in a few years.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
I will MORE than appreciate it if you do that for me Phillip, that would save me hundreds of hours. Thank you very much Phillip, i will be forever grateful. :)

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
How was your weekend Phillip? Hope it was good. I spent mine adding links manually to Links 2, and the sad part is that i was only able to add 450 total, pretty sad huh? Hehe. I really hope the import scripting came across your mind this weekend, and you thought about some non coding, non perl knowing webmaster out there that desperately needs help with adding links to Links 2. lol. Hope to hear from you soon, and thanks for even considering doing that for me, thats one of the nicest things someone has ever done for me on the internet or thought about doing for me. hehe

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
sorry, I got caught up working on a minor plugin for Links SQL for another user. I've got Monday and Tuesday off so I should be able to work that into my spare time.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
No problem bro, Monday and Tuesday is great for me. I am watching this thread, and it lets me know by email when you reply. So please post here when you do it or if you get time to do it. So i can come by and found out how i can get it from you. Thank you very much once again, and i really appreciate this.


-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Okay, here's permilimary version (untested).

Adjust $import_db, $date, $cat, $cname, $cmail as desired. Place the script in your admin directory and chmod to 755. Your original links.db will be backed up, but you should download a copy of links.db and your other database just in case.

Code:
#!/usr/bin/perl

require "links.cfg"; #change to full path if necessary

my $time = time();
my $bk_name = $db_script_path . '/data/links.db.' . $time;
my $import_db = $db_script_path . '/data/import.db';

my $id = 0;
my $date = '18-Jul-2005';
my $cat = 'Free';
my $cname = 'Contact Name';
my $cmail = 'Contact Email';

open (ID, $db_links_id_file_name) or die $!;
$id = <ID>;
chomp($id);
close ID;

rename($links_db_name, $bk_name);

open (OLD, $bk_name) or die $!;
open (NEW, ">$links_db_name") or die $!;
while (<OLD>) {
print NEW $_;
}
close NEW;
close OLD;

open (NEW, "+>$links_db_name") or die $!;
open (OLD, $import_db) or die $!;
while (my $line = <OLD>) {
chomp($line);
my ($title, $url, $desc) = split /\|/, $line;
my $line = join ("|", (++$id, $title, $url, $date, $cat, $desc, $cname, $cmail, 0, 'No', 'No', 0, 0, 'No');
print NEW $line . "\n";
}
close OLD;
close NEW;

open (ID, ">$db_links_id_file_name") or die $!;
print ID $id;
close ID;

print "Content-type: text/html\n\n";
print "import complete";

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
You rock bro, thank you very much. I will test it and let you know what the results are. Thank you very much once again. :)

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Hey Phillip, i cut and paste the script coding into a text file, and saved it as import.cgi, and i uploaded it to the admin directory, and set the chmod to 755. However, i get an error when i visit the page.

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@freesitearchive.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

That is the error message that i get when i visit the page. Maybe if i am doing something wrong with the saving process. I wouldn't know, but can you please let me know if the process that i described up top is the proper process to running the script? Thank you very much.

http://www.freesitearchive.com/admin/import.cgi

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
change
Code:
my $line = join ("|", (++$id, $title, $url, $date, $cat, $desc, $cname, $cmail, 0, 'No', 'No', 0, 0, 'No');

to
Code:
my $line = join ("|", (++$id, $title, $url, $date, $cat, $desc, $cname, $cmail, 0, 'No', 'No', 0, 0, 'No'));

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Still no luck i did everything you said to do. I am sorry for taking so much of your time with this Phillip, and i thank you for the time you put into it. I know you coded it right, so it is not a coding problem. I set the proper chmod, which is 755. Maybe it should be in a different directory? Right now it is in admin directory. I can send you my ftp access via private message if you would like to check it and see certain things for yourself. Maybe you will notice something that i am not seeing.
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
You don't need to do that. I'll install a copy of Links on my PC and see what's going on. I should have done that to start with. Blush

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Thanks a lot Phillip, please let me know how it went, and if i need to make more changes.

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Below is a simpler script. It will only import the data itself. You must MANUALLY set the starting ID number and update linksid.txt when you finished with the import. Please backup all data prior to running.

Code:
#!/perl/bin/perl

my $path = 'C:/links'; #path to data files
my $db = 'old.db'; #data file to import

my $id = 50;
my $date = '18-Jul-2005';
my $cat = 'Free';
my $cname = 'Contact Name';
my $cmail = 'Contact Email';

open (OUT, ">>$path" . "/links.db") or die $!;
open (IN, $path . "/$db") or die $!;
while (my $line = <IN>) {
chomp($line);
my ($title, $url, $desc) = split /\|/, $line;
print OUT join ("|", ($id++, $title, $url, $date, $cat, $desc, $cname, $cmail, 0, 'No', 'No', 0, 0, 'No')) . "\n";
}
close IN;
close OUT;

print "Content-type: text/html\n\n";
print "Import complete.";

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
Hey Phillip, i copied and pasted it. Then saved it as i.cgi, when i uploaded it to the admin directory, i changed the Chmod to 755, and i visit this link to activate or run the script..

http://www.freesitearchive.com/admin/i.cgi

i still come across with the same error, those are the process that i use to try to run it, if you see anything that i did wrong there, please let me know. Thank you very much.

-Greg
Quote Reply
Re: [edizzo] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
1)Is the path to perl set correctly?
2)Do you have the $path variable set to the directory containing links.db and the data file you want to import?
3)Did you set the $db variable to the name of file you want imported?

If you answered "yes" for all three questions, then there isn't much I can suggest. I'd need admin/telnet access to investigate the issue further.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How Do you add Links in Batches or abundantly In Links 2.0? In reply to
I will send you the admin access via ftp. I will send it via private message. I am sorry for bringing this problem up on you. Thank you for your patience and help.


-Greg