Gossamer Forum
Home : Products : Links 2.0 : Customization :

Upgrading DB

Quote Reply
Upgrading DB
Hi,
I am having lots of trouble using upgrade.db. All this script does is add 0|0|Yes to the end of each link. I need it to replace a feild with a default value such as 0 or NO. I also need this to add to a certain feild like $RecOut[9]
I think you could add something like:
$RecOut[10] = 0;
in there but dont you need something else as there are no feilds in [10]?
Thanks,
Paul


Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting
Quote Reply
Re: Upgrading DB In reply to
upgrade.db???? Are you using the upgrade.pl script? If so, you need to UPDATE/UPGRADE your links.db ONE field at a time that you add in the %db_def hash in the links.db file...

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: Upgrading DB In reply to
Oops I meant upgrade.pl just got a little confused. Anyway the thing is that my fields are all messed up and some of the new feilds are in the middle of %db_def and not the end. This would save me lots of time and frustration if there was a way to upgrade it like what I meant before.
Thank You,
Paul

Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting
Quote Reply
Re: Upgrading DB In reply to
Could you not just add the fields at the end - it would make it a lot easier?

Mods:http://wiredon.net/gt/download.shtml
Installs:http://wiredon.net/gt/


Quote Reply
Re: Upgrading DB In reply to
Yeah I did that and it works. I need to have a random number or text consisting of 6 or more characters for the password feild. This will ensure the highest security. Then I could e-mail out the password and the user can change it.
Thanks,
Paul

Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting
Quote Reply
Re: Upgrading DB In reply to
Can anyone please help. I really need this. I could figure everything out but all I need is peice of code to generate random characters.
Thank You,
Paul

Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting
Quote Reply
Re: Upgrading DB In reply to
Search the internet, search the perl forum....it has been mentioned many times.

For the easy way out use the code below.....

Random numbers/letters....
Code:
my @dig = ('0..9', 'a..z', 'A..Z');
srand(time ^ $$);
for (my $i = 0; $i++ < 8;) {
$rand .= $dig[rand(@dig)];
}
For just numbers....

Code:
$rand = int(rand(1000000));
There are better ways but that is a start.




Mods:http://wiredon.net/gt/download.shtml
Installs:http://wiredon.net/gt/


Quote Reply
Re: Upgrading DB In reply to
Hi Paul,

This looks like very useful code.

I tried to generate the code via a global but got this error:

Error: Unable to compile function: random_num. Reason: Global symbol "$RAND" requires explicit package name at (eval 4) line 6.

What could be wrong here? And is the time funcion based on the second?


This is the code is used:

sub {
# Displays random number/letter.
my @dig = ('0..9', 'a..z', 'A..Z');
srand(time ^ $$);
for (my $i = 0; $i++ < 8;) {
$RAND .= $dig[rand(@dig)];
}
}

Quote Reply
Re: Upgrading DB In reply to
Try

my $RAND

You realise you have an anonymous sub-routine there...or are you using Links SQL?.....either way, use my.

Mods:http://wiredon.net/gt/download.shtml
Installs:http://wiredon.net/gt/


Quote Reply
Re: Upgrading DB In reply to
Getting a little more complexed.....

Code:
my @ar = ('A'..'Z','a'..'z','0'..'9');
return join('', map($ar[int(rand @ar)], (1 .. 10)));
Mods:http://wiredon.net/gt/download.shtml
Installs:http://wiredon.net/gt/


Quote Reply
Re: Upgrading DB In reply to
Ok I have went to many perl tutorials and can't find out how to do this. This code works great but resets to the same random number for each link. Here is the code:

#!/usr/bin/perl

require "links.cfg";
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";

$rand = int(rand(1000000));

$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "$db_links_name")
or print "Unable to open links database 'links.db'. Reason: $!" and exit;
open (DBOUT, ">$db_links_name.bak")
or print "Unable to open output database. Reason: $!" and exit;
LINE: while (<DB> )
{
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@RecOut = &split_decode($_);
$RecOut[18] = $rand;
print DBOUT &join_encode(&array_to_hash(0, @RecOut));
}
close DB;
close DBOUT;
print "\nLinks database now has password field changed.\n\n";

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB>) { print DBTMP; }
close DB;
close DBTMP;
}
}
else {
&cgierr ("Error building! Links database is 0 bytes!");
}

Can you please help.
Thank You,
Paul

Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting
Quote Reply
Re: Upgrading DB In reply to
Can someone please help, Im about to release my new directory and I need to have this set up. Im not good with foreach tags and I thing that's part of what you need to do.
Thank You,
Paul

Hot Web Hosting
Low cost web hosting:
http://www.thehotweb.net/webhosting