#!/usr/bin/perl -w use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use LWP::Simple; use DBI; require("cookie.lib"); my $cgi = new CGI; my $DBNAME = "jejeno"; my $DBHOST = "sql24.webhuset.no"; my $DBUSERNAME = "jejeno"; my $DBPASSWORD = "lBEvGCx9t"; my $PATH = "/cgi-bin"; my $FILENAME = "jeje.cgi"; my $error = ""; my $error2 = ""; &GetCookies('jeje_id', 'jeje_al'); if ($cgi->param('submit_login')) { my $email_tmp = $cgi->param('email'); my $password_tmp = $cgi->param('password'); if ($password_tmp =~ s/[^a-z0-9\_]//g) { $error .= "* Ugyldig tegn i passordet.
\n"; } if ($error eq "") { my $query = "SELECT id, email, password, access_level FROM users;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$email, \$password, \$access_level); while($sth->fetch()) { if ($email_tmp eq $email && $password_tmp eq $password) { $found = 1; $v1 = $id; $v2 = $access_level; } } $sth->finish(); $dbh->disconnect; } if($found ne 1) { $error .= "* E-post eller passord er feil.\n"; } if($error eq "") { &SetCookies('jeje_id', $v1); &SetCookies('jeje_al', $v2); print "Location: jeje.cgi\n\n"; exit; } else { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); setPageHits(1); getHtml(-1); getBottom(); } } elsif ($cgi->param('submit_signup')) { my $name_tmp = $cgi->param('name'); my $email_tmp = $cgi->param('email'); my $password_tmp = $cgi->param('password'); if ($password_tmp =~ s/[^a-z0-9\_]//g) { $error .= "* Ikke gyldig tegn, bruk a-z, 0-9 og _.
\n"; } $len = length($password_tmp); if ($len <= 4) { $error .= "* Passordet må være minst fem tegn.
\n"; } if ($name_tmp eq "") { $error .= "* Navn må fylles ut.
\n"; } if ($email_tmp =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $email_tmp !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { $error .= "* Vennligst skriv inn en gyldig epost.
\n"; } if ($error eq "") { my $query = "SELECT email, password FROM users;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$email, \$password); while($sth->fetch()) { if ($email_tmp eq $email) { $found = 1; } } $sth->finish(); $dbh->disconnect; } if ($found eq 1){ $error .= "* Beklager, men denne e-post adressen finnes allerede.
\n"; } if($error eq "") { my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $month = $month + 1; my $date = "$year-$month-$dayOfMonth"; my $query = "INSERT INTO users VALUES (default, '$name_tmp', '$email_tmp', '$password_tmp', '', '', '', 'nor', '$date', 0, 2);"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; my $query = "SELECT id, access_level FROM users where email = '$email_tmp';"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$access_level); $sth->fetch(); &SetCookies('jeje_id', $id); &SetCookies('jeje_al', $access_level); $sth->finish(); $dbh->disconnect; print "Location: jeje.cgi\n\n"; exit; } else { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); setPageHits(1); getHtml(-1); getBottom(); } } elsif ($cgi->param('submit_user')) { my $name_tmp = $cgi->param('name'); my $email_tmp = $cgi->param('email'); my $gender = $cgi->param('gender'); my $birthday_day = $cgi->param('birthday_day'); my $birthday_month = $cgi->param('birthday_month'); my $birthday_year = $cgi->param('birthday_year'); my $postal_code = $cgi->param('postal_code'); my $birthday = "$birthday_year-$birthday_month-$birthday_day"; if ($name_tmp eq "") { $error .= "* Navn må fylles ut.
\n"; } if ($email_tmp =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $email_tmp !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { $error .= "* Vennligst skriv inn en gyldig epost.
\n"; } if ($error eq "") { my $query = "SELECT email, password FROM users WHERE id <> $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$email, \$password); while($sth->fetch()) { if ($email_tmp eq $email) { $found = 1; } } $sth->finish(); $dbh->disconnect; } if ($found eq 1){ $error .= "* Beklager, men denne e-post adressen finnes allerede.
\n"; } print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger bruker / bytt passord
\n"); print("
\n"); if($error eq "") { print("På grunn av streng sikkerhet, skriv inn e-post og passord:
\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); if($postal_code eq "") { print("\n"); } else { print("\n"); } print("\n"); print("
\n"); print("\n"); print("
E-post:
Passord:
\n"); } else { print("Rediger eller legg til nye detaljer:\n"); print("\n"); print("\n"); print("
\n"); print("\n"); ($tmp_year,$tmp_month,$tmp_day) = split('-',$birthday); print("\n"); if($postal_code eq 0) { print("
\n"); } else { print("
\n"); } print("\n"); print("
Navn:
E-post:
Kjønn:
Fødselsdato:\n"); print("\n"); print("
Postnummer:
Postnummer:
\n"); print("
$error\n"); } print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif ($cgi->param('submit_security')) { my $name_hidden = $cgi->param('name_tmp'); my $email_hidden = $cgi->param('email_tmp'); my $gender = $cgi->param('gender'); my $birthday = $cgi->param('birthday'); my $postal_code = $cgi->param('postal_code'); my $email_tmp = $cgi->param('email'); my $password_tmp = $cgi->param('password'); if ($password_tmp =~ s/[^a-z0-9\_]//g) { $error .= "* Ugyldig tegn i passordet.
\n"; } if ($error eq "") { my $query = "SELECT id, email, password, access_level FROM users WHERE id = $Cookies{'jeje_id'};;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$email, \$password, \$access_level); while($sth->fetch()) { if ($email_tmp eq $email && $password_tmp eq $password) { $found = 1; $v1 = $id; $v2 = $access_level; } } $sth->finish(); $dbh->disconnect; } if($found ne 1) { $error .= "* E-post eller passord er feil.\n"; } print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger bruker / bytt passord
\n"); print("
\n"); if($error eq "") { my $query = "UPDATE users SET name = '$name_hidden', email = '$email_hidden', gender = $gender, birthday = '$birthday', postal_code = $postal_code WHERE id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; print("Brukeren er endret!
\n"); print "\n"; } else { print("På grunn av streng sikkerhet, skriv inn e-post og passord:
\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
\n"); print("\n"); print("
E-post:
Passord:
\n"); print("
$error\n"); } print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif ($cgi->param('submit_pass')) { my $old_password = $cgi->param('old_password'); my $new_password1 = $cgi->param('new_password1'); my $new_password2 = $cgi->param('new_password2'); my $query = "SELECT password FROM users WHERE id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$password); $sth->fetch(); if ($old_password eq $password) { $found = 1; } $sth->finish(); $dbh->disconnect; if ($found ne 1){ $error .= "* Gammelt passord stemmer ikke.
\n"; } if ($new_password1 =~ s/[^a-z0-9\_]//g) { $error .= "* Ikke gyldig tegn i nytt passord, bruk a-z, 0-9 og _.
\n"; } if ($new_password1 ne $new_password2) { $error .= "* Nytt passord og gjenta nytt passord er forskjellig.
\n"; } $len = length($new_password1); if ($len <= 4) { $error .= "* Nye passordet må være minst fem tegn.
\n"; } print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger bruker / bytt passord
\n"); print("
\n"); if($error eq "") { my $query = "UPDATE users SET password = '$new_password1' WHERE id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; print("Passordet er endret!
\n"); print "\n"; } else { print("Bytt passord:\n"); print("\n"); print("\n"); print("
\n"); print("\n"); print("\n"); print("
Gammelt passord:
Nytt passord:
Gjenta nytt passord:
\n"); print("
$error\n"); } print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif ($cgi->param('submit_sendpass')) { my $email_tmp = $cgi->param('password_email'); if ($email_tmp =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $email_tmp !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) { $error2 .= "* Vennligst skriv inn en gyldig epost.
\n"; } if ($error2 eq "") { my $query = "SELECT email FROM users;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$email); while($sth->fetch()) { if ($email_tmp eq $email) { $found = 1; } } $sth->finish(); $dbh->disconnect; } if ($found ne 1){ $error2 .= "* Beklager, men denne e-post adressen finnes ikke / er ikke registrert.
\n"; } print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Glemt passordet ditt?
\n"); print("
\n"); if($error2 eq "") { sendPassword($email_tmp); print("Passordet er sendt til e-post adresse: $email_tmp.
\n"); print "\n"; } else { print("Skriv inn e-post adressen som passordet skal sendes til.
\n"); print("Denne e-postadressen må være identisk med din registrerte e-postadresse.
\n"); print("\n"); print("
\n"); print("\n"); print("
E-post:
\n"); print("
$error2\n"); } print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($cgi->param('submit_link')) { print("Content-type: text/html\r\n\r\n"); getTop(); my $title = $cgi->param('title'); my $description = $cgi->param('description'); my $url = $cgi->param('url'); my $search_words = $cgi->param('search_words'); my $cat_id = $cgi->param('cat_id'); print("\n"); print("
"); print("\n"); print("
\n"); print("
Legg til nettsted
\n"); print("
\n"); if($title eq "" || $url eq "" || $url eq "http://www.") { getAddLinkHtmlError($title, $description, $url, $search_words, $cat_id); } else { addLink($title, $description, $url, $search_words, $cat_id); print("
Nettsiden $title er sendt til godkjenning..
\n"); print("Hvis dette er en seriøs nettside, vil den være tilgjengelig for alle innen 24 timer.
\n"); print("Tusen takk for bidraget!

..JEJE.no!





\n"); print "\n"; } print("
\n"); print("\n"); getCatBar(); print("
\n"); getBottom(); } elsif($cgi->param('submit_cat')) { print("Content-type: text/html\r\n\r\n"); getTop(); my $title = $cgi->param('title'); my $search_words = $cgi->param('search_words'); my $parent_id = $cgi->param('parent_id'); print("\n"); print("
"); print("\n"); print("
\n"); print("
Legg til kategori
\n"); print("
\n"); if($title eq "") { getAddCatHtmlError($title, $search_words, $parent_id); } else { print("
Kategorien $title er sendt til godkjenning..
\n"); print("Hvis dette er en seriøs kategori, vil den være tilgjengelig for alle innen 24 timer.
\n"); print("Tusen takk for bidraget!

..JEJE.no!





\n"); print("\n"); addCat($title, $search_words, $parent_id); } print("
\n"); print("\n"); getCatBar(); print("
\n"); getBottom(); } elsif($cgi->param('cat_id')) { print("Content-type: text/html\r\n\r\n"); getTop(); my $cat_id = $cgi->param('cat_id'); getHtml($cat_id); setCatHits($cat_id); getBottom(); } elsif($cgi->param('submit_mail')) { print("Content-type: text/html\r\n\r\n"); getTop(); my $from = $cgi->param('from'); my $subject = $cgi->param('subject'); my $message = $cgi->param('message'); sendMail($from, $subject, $message); print("\n"); print("
"); print("\n"); print("
E-post sendt!
\n"); print("
\n"); print("
E-post er sendt til support\@jeje.no..
\n"); print("Hvis det er en svaradresse, så vil det komme svar tilbake innen 24 timer..
\n"); print("..JEJE.no!





\n"); print("
\n"); print("\n"); print("
\n"); print "\n"; getBottom(); } elsif($cgi->param('action')) { my $action = $cgi->param('action'); my $id = $cgi->param('id'); if($action eq "1") { print("Content-type: text/html\r\n\r\n"); getTop(); setPageHits(3); print("\n"); print("
\n"); print(""); print("
Ukens bilde
\n"); print("
\n"); getPic(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "2") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
TOPP 100!
\n"); print("
\n"); print("Nedenfor vil du finne de 100 mest besøkte sidene på JEJE.no!\n"); print("
\n"); setPageHits(8); getTopp100(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "3") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Siste 10
\n"); print("
\n"); print("Nedenfor vil du finne de 10 siste / nyeste sidene på JEJE.no!\n"); print("
\n"); setPageHits(9); getLast10(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "4") { print("Content-type: text/html\r\n\r\n"); getTop(); setPageHits(4); print("\n"); print("
\n"); print(""); print("
Legg til kategori
\n"); print("
\n"); getAddCatHtml(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "5") { print("Content-type: text/html\r\n\r\n"); getTop(); setPageHits(5); print("\n"); print("
\n"); print(""); print("
Legg til nettsted
\n"); print("
\n"); getAddLinkHtml(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "6") { print("Content-type: text/html\r\n\r\n"); getTop(); setPageHits(6); print("\n"); print("
\n"); print(""); print("
Informasjon
\n"); print("
\n"); getInfo(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "7") { print("Content-type: text/html\r\n\r\n"); getTop(); setPageHits(7); print("\n"); print("
\n"); print(""); print("
Kontakt oss
\n"); print("
\n"); getSendMail(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "8") { if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Legg til favoritter
\n"); print("
\n"); addFavorite($Cookies{'jeje_id'}, $id); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } else { print "Location: jeje.cgi\n\n"; exit; } } elsif($action eq "9") { if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $query = "SELECT link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$link_id); my $count = 0; while($sth->fetch()) { $count = $count + 1; } $sth->finish(); $dbh->disconnect; if($count == 0) { print "Location: jeje.cgi\n\n"; exit; } else { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger favoritter
\n"); print("
\n"); editFavorites(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } } else { print "Location: jeje.cgi\n\n"; exit; } } elsif($action eq "10") { if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger favoritter
\n"); print("
\n"); delFavorite($id); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } else { print "Location: jeje.cgi\n\n"; exit; } } elsif ($action eq "11") { &SetCookies('jeje_id', ""); &SetCookies('jeje_al', ""); print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Logget ut!
\n"); print("
\n"); print("Du er nå logget ut!

\n"); #print("TIPS: Hvis du har en datamaskin som du eier eller bruker mye, ikke logg deg ut!
Neste gang du bruker JEJE.no og du ikke har logget deg ut, er favoritter og de andre personlige elementene tilgjengelig med en gang! Altså du slipper å logge deg inn for hver gang.
Brukerinformasjonen og passordet ditt er beskyttet med at du må gjenta e-post og passord når endringer gjøres.\n"); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); print "\n"; } elsif ($action eq "12") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); setPageHits(1); getHtml(-1); getBottom(); } elsif($action eq "13") { if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Rediger bruker / bytt passord
\n"); print("
\n"); getEditUser(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } else { print "Location: jeje.cgi\n\n"; exit; } } elsif($action eq "14") { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); print("
\n"); print(""); print("
\n"); print("
Glemt passordet ditt?
\n"); print("
\n"); getSendPassword(); print("
\n"); print("\n"); getCatBar(); print("
\n"); print("\n"); getBottom(); } elsif($action eq "15") { my $color_id = $cgi->param('color_id'); my $query = "UPDATE users SET top_color = $color_id WHERE id=$Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; print "Location: jeje.cgi\n\n"; exit; } } else { print("Content-type: text/html\r\n\r\n"); getTop(); print("\n"); setPageHits(1); getHtml(-1); getBottom(); } sub getHtml { my ($cat_id) = @_; print("\n"); print("
\n"); if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "" && $cat_id eq -1) { getBirthday($Cookies{'jeje_id'}); } if($cat_id eq -1) { #print(""); #print("
\n"); #print("
Nyheter
\n"); #print("
\n"); #print("\n"); #print("
"); #getVG(); #print(""); #getDB(); #print("
"); #print("
\n"); #print("\n"); #print("
\n"); } print("\n"); print("
\n"); print("
Arkiv
\n"); print("
\n"); getPosition($cat_id); getCat($cat_id); print("
\n"); print("\n"); if($cat_id != -1) { print("
\n"); print("\n"); print("
\n"); print("
Nettsider
\n"); print("
\n"); getLink($cat_id); print("
\n"); print("\n"); } print("
\n"); print("\n"); } sub getCatBar { my $cat_id = -1; print("
\n"); print("\n"); print("
\n"); print("
Arkiv
\n"); print("
\n"); getPosition($cat_id); getCat($cat_id); print("
\n"); print("\n"); } sub getAddLinkHtml { print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); my $query = "SELECT id, title FROM cat order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title); print "\n"; $sth->finish(); $dbh->disconnect; print("\n"); print("
Tittel:*
Beskrivelse:
Url:*
Søkeord:
Kategori:
\n"); print("
* er felter som må fylles ut!\n"); } sub getAddLinkHtmlError { my ($title, $description, $url, $search_words, $cat_id) = @_; print("\n"); if($title eq "") { print("\n"); } else { print("\n"); } print("\n"); if($url eq "" || $url eq "http://www.") { print("\n"); } else { print("\n"); } print("\n"); my $query = "SELECT id, title FROM cat order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title); print "\n"); print("
Tittel:*
Tittel:
Beskrivelse:
Url:*
Url:
Søkeord:
Kategori:\n"; $sth->finish(); $dbh->disconnect; print("
\n"); print("
* er felter som må fylles ut!\n"); } sub getAddCatHtml { print("\n"); print("\n"); print("\n"); my $query = "SELECT id, title FROM cat order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title); print "\n"; $sth->finish(); $dbh->disconnect; print("\n"); print("
Tittel:*
Søkeord:
Underkategori:
\n"); print("
* er felter som må fylles ut!\n"); } sub getAddCatHtmlError { my ($title, $search_words, $parent_id) = @_; print("\n"); print("\n"); print("\n"); my $query = "SELECT id, title FROM cat order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title); print "\n"); print("
Tittel:*
Search_words:
Underkategori:\n"; $sth->finish(); $dbh->disconnect; print("
\n"); print("
* er felter som må fylles ut!\n"); } sub getPosition { my ($cat_id) = @_; if($cat_id == -1) { print("\n"); } else { my $query = "SELECT title, parent_id FROM cat WHERE id=$cat_id"; my $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); my $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$title, \$parent_id); $sth->fetch(); my $this_title = $title; my $query2 = "SELECT id, title FROM cat WHERE id=$parent_id"; my $sth2 = $dbh->prepare($query2); $sth2->execute(); $sth2->bind_columns(\$id, \$title); $sth2->fetch(); print("
\n"); print("
\n"); print("
Tilbake
\n"); print("
\n"); print("
" . fixNorChar($this_title) . "

\n"); $sth->finish(); $sth2->finish(); $dbh->disconnect; } } sub getCat { my ($cat_id) = @_; my $query = "SELECT id, title FROM cat WHERE parent_id=" . $cat_id . " order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title); my $query2 = "SELECT count(id) as total_cat FROM cat WHERE parent_id=" . $cat_id . ";"; $sth2 = $dbh->prepare($query2); $sth2->execute(); $sth2->bind_columns(\$total_cat); $sth2->fetch(); my $height = 124; my $count = 0; if($total_cat < 8) { $height = ($total_cat * 18); } while($sth->fetch()) { $count = $count + 1; if($count == 1) { print "
\n"; } if($count == 9) { print "
\n"; print "
\n"; } if($count == 17) { print "
\n"; print "
\n"; } print "
\n"; print "
\n"; print "
" . fixNorChar($title) . "
\n"; } if($count >= 1) { print "
\n"; } if($count == 0 and $cat_id != -1) { print "
Ingen underkategorier...

\n"; } $sth->finish(); $sth2->finish(); $dbh->disconnect; } # Function addData insert into sql a pending_link.. sub addLink { my ($title, $description, $url, $search_words, $cat_id) = @_; my $query = "INSERT INTO pending_link VALUES (default, '$title', '$description', '$url', '$search_words', $cat_id, 0);"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; } # Function addData insert into sql a pending_cat.. sub addCat { my ($title, $search_words, $parent_id) = @_; my $query = "INSERT INTO pending_cat VALUES (default, '$title', '$search_words', $parent_id, 0);"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; } sub getLink { my ($cat_id) = @_; my $query = "SELECT id, title, description, hits FROM link WHERE cat_id=$cat_id order by title;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title, \$description, \$hits); my $count = 0; while($sth->fetch()) { $count = $count + 1; if($count ne 1 and $count ne 2) { print("
\n"); } if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $found = 0; my $query = "SELECT user_id, link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $sth2 = $dbh->prepare($query); $sth2->execute(); $sth2->bind_columns(\$user_id, \$link_id); while($sth2->fetch()) { if($user_id eq $Cookies{'jeje_id'} && $link_id eq $id) { $found = 1; } } $sth2->finish(); if($found ne 1) { print("
\n"); } } print("
\n"); if($description ne "") { print "
" . fixNorChar($description) . "
\n"; } print("
\n"); if($count eq 1) { print("
\n"); } } if($count eq 0) { print "
Ingen nettsider i denne katalogen...

\n"; } $sth->finish(); $dbh->disconnect; } # Function setCatHits updates the sql with count of hits.. sub setCatHits { my ($cat_id) = @_; my $query = "UPDATE cat SET hits = hits + 1 WHERE id=" . $cat_id . ";"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; } sub setPageHits { my ($id) = @_; my $query = "UPDATE page_hits SET hits = hits + 1 WHERE id=$id;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; } sub getInfo { #open (FILE,"info.txt"); #$mainpage = ""; #while () { # $mainpage .= $_; #} #close (FILE); print("Hvorfor bruke JEJE.no?
\n"); print("JEJE.no - Lett å nett!, en enkel vei ut på det store Internett.
\n"); print("Denne startsiden har i motsetning til andre startsider en ren og fin meny som gjør det enkelt for brukerne å finne hva de måtte lete etter.
\n"); print("Utseende har også et preg av enkelhet for at det skal bli oversiktlig og klar til bruk for enhver person som måtte ønske det.
\n"); print("Så kom å bruk snareveier til søkemotorer og legg til dine favorittsider slik at du raskt og enkelt kan finne de igjen når du skal på internett!
\n"); print("Har du en nettside som du liker godt er det bare å legge den til slik at JEJE.no blir større, og at andre brukere kan få glede av den også!

\n"); print("Hvorfor registrere seg på JEJE.no?
\n"); print("Det tar deg nesten like lang tid å registrere deg som å logge deg inn på JEJE.no..
Med kun; navn, e-post og passord så er du registrert!
\n"); print("Fordelen ved å være registrert er at du får tilgang til å legge til favoritter og bruke disse som snarvei. Du får også muligheten til å gjøre JEJE.no til en mer personlig startside.\n"); } sub getPic { my $query = "SELECT id, day, month, year, url FROM picture;"; my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $month = $month + 1; my $theTime = "$dayOfMonth.$month.$year"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$day, \$month, \$year, \$url); while($sth->fetch()) { my $theTime2 = ""; for($i=0;$i<=6;$i++) { my $theTime2 = "" . ($day+$i) . ".$month.$year"; if($theTime eq $theTime2) { print("\n"); setPicHits($id); last; } } } $sth->finish(); $dbh->disconnect; } # Function setHits updates the sql with count of hits.. sub setPicHits { my ($id) = @_; my $query = "UPDATE picture SET hits = hits + 1 WHERE id=$id;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; } sub getSendMail { print("Spørsmål? Send oss en e-post!

"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
Til:support\@jeje.no
Fra:
Subjekt:
Melding:\n"); print("
\n"); } sub sendMail { my ($from, $subject, $message) = @_; if($from eq "") { $from = "anonym\@jeje.no"; } open (MAIL, "|/usr/sbin/sendmail -t"); print MAIL "From: $from\n"; print MAIL "To: support\@jeje.no\n"; print MAIL "Subject: SUPPORT: $subject\n\n"; print MAIL "$message"; close(MAIL); } sub getTop { print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print(" \n"); print(" \n"); print(" \n"); print(" \n"); print(" \n"); print("\n"); print(" JEJE.no - Lett på nett!\n"); print(" \n"); print(" \n"); print("
\"\"
\n"); print("
\n"); print("
\n"); print("
\n"); print("
\n"); if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $query = "SELECT top_color FROM users where id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$top_color); $sth->fetch(); my $color_id = $top_color; $sth->finish(); $dbh->disconnect; if($color_id ne 0) { my $query2 = "SELECT top_url, header_url FROM top_color where id = $color_id;"; $dbh2 = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth2 = $dbh2->prepare($query2); $sth2->execute(); $sth2->bind_columns(\$top_url, \$header_url); $sth2->fetch(); print(" \"JEJE.no\n"); print("\n"); $sth2->finish(); $dbh2->disconnect; } else { my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $color_id = 1; if($dayOfWeek eq 0) { $color_id = 1; } elsif($dayOfWeek eq 1) { $color_id = 1; } elsif($dayOfWeek eq 2) { $color_id = 2; } elsif($dayOfWeek eq 3) { $color_id = 3; } elsif($dayOfWeek eq 4) { $color_id = 4; } elsif($dayOfWeek eq 5) { $color_id = 5; } elsif($dayOfWeek eq 6) { $color_id = 1; } my $query = "SELECT top_url, header_url FROM top_color where id = $color_id;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$top_url, \$header_url); $sth->fetch(); print(" \"JEJE.no\n"); print("\n"); $sth->finish(); $dbh->disconnect; } } else { my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $color_id = 1; if($dayOfWeek eq 0) { $color_id = 1; } elsif($dayOfWeek eq 1) { $color_id = 1; } elsif($dayOfWeek eq 2) { $color_id = 2; } elsif($dayOfWeek eq 3) { $color_id = 3; } elsif($dayOfWeek eq 4) { $color_id = 4; } elsif($dayOfWeek eq 5) { $color_id = 5; } elsif($dayOfWeek eq 6) { $color_id = 1; } my $query = "SELECT top_url, header_url FROM top_color where id = $color_id;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$top_url, \$header_url); $sth->fetch(); print(" \"JEJE.no\n"); print("\n"); $sth->finish(); $dbh->disconnect; } print("
\n"); print(" "); getCountDown(); print("\n"); print("
\n"); print(" \n"); my $query = "SELECT title, search_word FROM top_search ORDER BY search_index;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$title, \$search_word); print("
\n"); print(" \n"); print(" \n"); print(" \n"); print("
\n"); print(" \n"); print("
\n"); print("
\n"); print("
\n"); print("
\n"); print(" \n"); print("
\n"); print("
Meny\n"); if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "" && $cgi->param('action') ne "11") { print("
\n"); } else { print("
\n"); } print(" \n"); if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "" && $cgi->param('action') ne "11") { print("
Favoritter\n"); my $query = "SELECT link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$link_id); my $count = 0; while($sth->fetch()) { $count = $count + 1; } $sth->finish(); $dbh->disconnect; if($count == 0) { print("
\n"); } else { print("rediger
\n"); } print("\n"); } else { if($cgi->param('action') eq "") { print("
Velkommen!\n"); print("
\n"); print("\n"); } } print("
\n"); print("\n"); print("
\n"); print("
\n"); } sub getBottom { print("\n"); print("
\n"); if ($cgi->param('action') eq "12" || $cgi->param('submit_signup')) { if ($Cookies{'jeje_id'} eq "" && $Cookies{'jeje_al'} eq "") { print("\n"); print("
\n"); print("
Registrer deg!
\n"); print("
\n"); $name = $cgi->param('name'); $email = $cgi->param('email'); $email = $cgi->param('password'); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
Navn:
E-post:
Passord:
\n"); if($error) { print("$error
\n"); } } else { print("\n"); print("
\n"); print("
Bruker
\n"); print("
\n"); my $query = "SELECT name FROM users where id=$Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$name); $sth->fetch(); print("Logget inn som:
\n"); print("$name

\n"); $sth->finish(); $dbh->disconnect; print("Logg ut
\n"); } } else { if ($Cookies{'jeje_id'} eq "" && $Cookies{'jeje_al'} eq "") { print("\n"); print("
\n"); print("
Login
\n"); print("
\n"); $email = $cgi->param('email'); $password = $cgi->param('password'); print("\n"); print("\n"); print("\n"); print("\n"); print("
E-post:
Passord:
Registrer deg!
\n"); if($error) { print("
$error\n"); } } else { if($cgi->param('action') eq "11") { print("\n"); print("
\n"); print("
Login
\n"); print("
\n"); $email = $cgi->param('email'); $password = $cgi->param('password'); print("\n"); print("\n"); print("\n"); print("\n"); print("
E-post:
Passord:
Registrer deg!
\n"); if($error) { print("
$error\n"); } } else { print("\n"); print("
\n"); print("
Bruker
\n"); print("
\n"); my $query = "SELECT name FROM users where id=$Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$name); $sth->fetch(); print("Logget inn som:
\n"); print("$name

\n"); $sth->finish(); $dbh->disconnect; print("Logg ut
\n"); } } } print("
\n"); print("\n"); print("\n"); print("
TOPP 10!
\n"); print("
\n"); getTopp10(); print("
\n"); print("\n"); print("
\n"); print("\n"); print("
\n"); print("
\n"); my $year = getYear(); my $datetime = getDateTime(); print("
Copyright $year JEJE.no.. Lett på nett! - support\@jeje.no$datetime\n"); print("
\n"); print("
\n"); print("
\n"); print("\n"); print("\n"); print("\n"); print("\n"); } sub getTopp10 { my $query = "SELECT id, title, description, hits FROM link order by hits desc;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title, \$description, \$hits); my $count = 1; while($sth->fetch()) { if($count ne 1) { print("
\n"); } if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $found = 0; my $query = "SELECT user_id, link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $sth2 = $dbh->prepare($query); $sth2->execute(); $sth2->bind_columns(\$user_id, \$link_id); while($sth2->fetch()) { if($user_id eq $Cookies{'jeje_id'} && $link_id eq $id) { $found = 1; } } $sth2->finish(); if($found ne 1) { print("
\n"); } } print "
$count. $title
\n"; $count = $count + 1; if($count == 11) { last; $count = 1; } if($count eq 1) { print("
\n"); } } $sth->finish(); $dbh->disconnect; } sub getDateTime { my ($tmp_second, $tmp_minute, $tmp_hour, $tmp_day, $tmp_month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $tmp_month = $tmp_month + 1; if($tmp_month < 10) { $month = "0$tmp_month"; } else { $month = "$tmp_month"; } if($tmp_day < 10) { $day = "0$tmp_day"; } else { $day = "$tmp_day"; } if($tmp_hour < 10) { $hour = "0$tmp_hour"; } else { $hour = "$tmp_hour"; } if($tmp_minute < 10) { $minute = "0$tmp_minute"; } else { $minute = "$tmp_minute"; } if($tmp_second < 10) { $second = "0$tmp_second"; } else { $second = "$tmp_second"; } return "$day.$month.$year $hour:$minute:$second"; } sub getYear { my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; return $year; } sub getTopp100 { my $query = "SELECT id, title, description, hits FROM link group by title order by hits desc;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title, \$description, \$hits); my $count = 1; while($sth->fetch()) { if($count ne 1) { print("
\n"); } if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $found = 0; my $query = "SELECT user_id, link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $sth2 = $dbh->prepare($query); $sth2->execute(); $sth2->bind_columns(\$user_id, \$link_id); while($sth2->fetch()) { if($user_id eq $Cookies{'jeje_id'} && $link_id eq $id) { $found = 1; } } $sth2->finish(); if($found ne 1) { print("
\n"); } } print "
$count. " . fixNorChar($title) . "
\n"; if($description ne "") { print("
" . fixNorChar($description) . "
\n"); } $count = $count + 1; if($count == 101) { last; $count = 1; } if($count eq 1) { print("
\n"); } } $sth->finish(); $dbh->disconnect; } sub getFavorites { my $query = "SELECT link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$link_id); my $count = 0; while($sth->fetch()) { $count = $count + 1; if($link_id) { my $query2 = "SELECT title FROM link where id = $link_id;"; $sth2 = $dbh->prepare($query2); $sth2->execute(); $sth2->bind_columns(\$title); $sth2->fetch(); print("

  • \n"); $sth2->finish(); } } $sth->finish(); $dbh->disconnect; if($count == 0) { print("Ingen favoritter!

    \n"); print("For å legge til en favoritt: Gå til arkivet, søk eller topp 100.
    Der finnes det mange nettsider. Til høyre for en av nettsidene, er det en stjerne.
    Klikk på denne!
    \n"); } } sub addFavorite { my ($id1, $id2) = @_; my $query = "SELECT user_id, link_id FROM users;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$user_id, \$link_id); while($sth->fetch()) { if ($id1 eq $user_id && $id2 eq $link_id) { $found = 1; } } $sth->finish(); $dbh->disconnect; if($found ne 1) { print("
    Nettsiden er lagt til i favoritter..

    \n"); my $query2 = "INSERT INTO favorite VALUES (default, $id1, $id2, 1);"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth2 = $dbh->prepare($query2); $sth2->execute(); $dbh->disconnect; } else { print("
    Nettsiden finnes allerede i favoritter..

    \n"); } print "\n"; } sub editFavorites { if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $query = "SELECT link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$link_id); my $count = 0; while($sth->fetch()) { if($link_id) { $count = $count + 1; if($count ne 1 and $count ne 2) { print("
    \n"); } my $query2 = "SELECT title FROM link where id = $link_id;"; $sth2 = $dbh->prepare($query2); $sth2->execute(); $sth2->bind_columns(\$title); $sth2->fetch(); print("
    \n"); print "
    \n"; $sth2->finish(); } print("
    \n"); if($count eq 1) { print("
    \n"); } } $sth->finish(); $dbh->disconnect; } } sub delFavorite { my ($id) = @_; my $query = "DELETE FROM favorite where link_id = $id and user_id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $dbh->disconnect; print("
    Nettsiden er fjernet fra favoritter..

    \n"); print "\n"; } sub getEditUser { my $query = "SELECT name, email, gender, birthday, postal_code FROM users where id = $Cookies{'jeje_id'};"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$name, \$email, \$gender, \$birthday, \$postal_code); $sth->fetch(); print("Rediger eller legg til nye detaljer:\n"); print("\n"); print("\n"); print("
    \n"); print("\n"); ($tmp_year,$tmp_month,$tmp_day) = split('-',$birthday); print("\n"); if($postal_code eq 0) { print("
    \n"); } else { print("
    \n"); } print("\n"); print("
    Navn:
    E-post:
    Kjønn:
    Fødselsdato:\n"); print("\n"); print("
    Postnummer:
    Postnummer:
    \n"); $sth->finish(); $dbh->disconnect; print("
    Bytt passord:\n"); print("\n"); print("\n"); print("
    \n"); print("\n"); print("\n"); print("
    Gammelt passord:
    Nytt passord:
    Gjenta nytt passord:
    \n"); } sub getSendPassword { print("Skriv inn e-post adressen som passordet skal sendes til.
    \n"); print("Denne e-postadressen må være identisk med din registrerte e-postadresse.
    \n"); print("\n"); print("
    \n"); print("\n"); print("
    E-post:
    \n"); } sub sendPassword { my ($email) = @_; my $query = "SELECT password FROM users WHERE email = '$email';"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$password); $sth->fetch(); open (MAIL, "|/usr/sbin/sendmail -t"); print MAIL <<__END_OF_MESSAGE__; To: $email From: support\@jeje.no Subject: Passord til JEJE.no __END_OF_MESSAGE__ print MAIL ("Hei! Her er passordet til brukeren din: e-post:\t\t\t $email passord:\t\t\t$password NB! Pga. sikkerhet, anbefales passord-bytte med en gang du logger inn. Med vennlig hilsen JEJE.no Support Team support\@jeje.no\n"); close (MAIL); $sth->finish(); $dbh->disconnect; } sub getLast10 { my $query = "SELECT id, title, description, hits FROM link order by id desc;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$id, \$title, \$description, \$hits); my $count = 1; while($sth->fetch()) { if($count ne 1) { print("
    \n"); } if ($Cookies{'jeje_id'} ne "" && $Cookies{'jeje_al'} ne "") { my $found = 0; my $query = "SELECT user_id, link_id FROM favorite where user_id = $Cookies{'jeje_id'};"; $sth2 = $dbh->prepare($query); $sth2->execute(); $sth2->bind_columns(\$user_id, \$link_id); while($sth2->fetch()) { if($user_id eq $Cookies{'jeje_id'} && $link_id eq $id) { $found = 1; } } $sth2->finish(); if($found ne 1) { print("
    \n"); } } print "
    \n"; if($description ne "") { print("
    " . fixNorChar($description) . "
    \n"); } $count = $count + 1; if($count == 11) { last; $count = 1; } if($count eq 1) { print("
    \n"); } } $sth->finish(); $dbh->disconnect; } sub getBirthday { my ($id) = @_; my ($second, $minute, $hour, $tmp_day, $tmp_month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $month_tmp = $tmp_month + 1; if($month_tmp < 10) { $month = "0$month_tmp"; } else { $month = "$month_tmp"; } if($tmp_day < 10) { $day = "0$tmp_day"; } else { $day = "$tmp_day"; } my $today = "$month-$day"; my $query = "SELECT name, birthday FROM users WHERE id = $id;"; $dbh = DBI->connect("dbi:mysql:$DBNAME;$DBHOST",$DBUSERNAME,$DBPASSWORD); $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(\$name, \$birthday); $sth->fetch(); my @time = split('-', $birthday); my $age = ($year - $time[0]); my $birth = $time[1] . "-" . $time[2]; if($birth eq $today) { print("\n"); print("
    \n"); print("
    Bursdag!
    \n"); print("
    \n"); print("Gratulerer med $age års dagen i dag, $name!\n"); #print("birth = $birth, today = $today\n"); print("
    \n"); print("\n"); print("
    \n"); } $sth->finish(); $dbh->disconnect; } sub getCountDown { my $start_day = 335; my $final_day = 359; my ($second, $minute, $hour, $day, $tmp_month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); my $today = $dayOfYear; my $day_count = $final_day - $today - 1; #print("JEJE.no ønsker alle en riktig GOD JUL og GODT NYTT ÅR!"); #if($today >= $start_day and $today <= $final_day) { # if($day_count eq 0) { # print("JEJE.no ønsker alle en riktig GOD JUL og GODT NYTT ÅR!"); # } elsif ($day_count eq 1) { # print("I dag er det $day_count dag igjen til julaften.. GOD JUL!"); # } else { # print("I dag er det $day_count dager igjen til julaften.. GOD JUL!"); # } #} else { # print("JEJE.no ønsker alle en riktig GOD JUL og GODT NYTT ÅR!"); #} } sub getDate { my ($date) = @_; my ($year, $month, $day) = split(/-/, $date); return "$day.$month.$year"; } sub getVG { print("VG Nett:
    \n"); my $content = get("http://www.vg.no/rss/create.php"); my(@lines) = split(/\n/, $content); my($line, @titles, @links, @descs, @times, $desc_count, $time_count); foreach $line (@lines) { if($line =~ //) { $time_count++; my ($tmp_time1, $tmp_time2) = split(//, $line); my ($tmp_time3) = split(/<\/dc:date>/, $tmp_time2); my ($tmp_time4) = split(/\+/, $tmp_time3); my ($tmp_time5, $tmp_time6) = split(/T/, $tmp_time4); my ($tmp_time7, $tmp_time8) = split(/:/, $tmp_time6); if($time_count ne 1) { push(@times, getDate($tmp_time5) . " $tmp_time7:$tmp_time8"); } } if($line =~ // and $line !~ /<title>VG RSS<\/title>/ and $line !~ /<title>VG RSS<\/title>/) { $line = fixNorChar($line); my ($tmp_title1, $tmp_title2) = split(/<title>/, $line); my ($tmp_title3) = split(/<\/title>/, $tmp_title2); my ($tmp_title4, $tmp_title5) = split(/<\!\[CDATA\[/, $tmp_title3); my ($tmp_title6) = split(/\]\]>/, $tmp_title5); push(@titles, $tmp_title6); } if($line =~ /<description>/) { $desc_count++; $line = fixNorChar($line); my ($tmp_desc1, $tmp_desc2) = split(/<description>/, $line); my ($tmp_desc3) = split(/<\/description>/, $tmp_desc2); my ($tmp_desc4, $tmp_desc5) = split(/<\!\[CDATA\[/, $tmp_desc3); my ($tmp_desc6) = split(/\]\]>/, $tmp_desc5); if($desc_count ne 1) { push(@descs, $tmp_desc6); } } if($line =~ /<link>/ and $line !~ /<link>http:\/\/www.vg.no\/<\/link>/) { my ($tmp_link1, $tmp_link2) = split(/<link>/, $line); my ($tmp_link3) = split(/<\/link>/, $tmp_link2); my ($tmp_link4, $tmp_link5) = split(/http:\/\/go.vg.no\/cgi-bin\/go.cgi\/rssart\//, $tmp_link3); push(@links, $tmp_link5); } } my ($i); for ($i = 0; $i < 10; $i++) { print("<a href=\"$links[$i]\" title=\"$descs[$i]\">$titles[$i]</a><br>\n$times[$i]<br>\n"); } } sub getDB { print("<a href=\"http://www.dagbladet.no/\">Dagbladet.no</a>:<br>\n"); my $content = get("http://www.dagbladet.no/rss/oppdatert.xml"); my(@lines) = split(/\n/, $content); # read file into list my($line, @titles, @links, @descs, @times, $desc_count); foreach $line (@lines) # loop thru list { if($line =~ /<title>/ and $line !~ /<title>Dagbladet.no - oppdatert<\/title>/ and $line !~ /<title>Dagbladet.no<\/title>/) { $line = fixNorChar($line); my ($tmp_title1, $tmp_title2) = split(/<title>/, $line); my ($tmp_title3) = split(/<\/title>/, $tmp_title2); push(@titles, $tmp_title3); } if($line =~ /<link>/ and $line !~ /<link>http:\/\/www.dagbladet.no<\/link>/ and $line !~ /<link>http:\/\/www.dagbladet.no\/<\/link>/) { my ($tmp_link1, $tmp_link2) = split(/<link>/, $line); my ($tmp_link3) = split(/<\/link>/, $tmp_link2); push(@links, $tmp_link3); } if($line =~ /<description>/) { $desc_count++; $line = fixNorChar($line); my ($tmp_desc1, $tmp_desc2) = split(/<description>/, $line); my ($tmp_desc3) = split(/<\/description>/, $tmp_desc2); if($desc_count ne 1) { push(@descs, $tmp_desc3); } } if($line =~ /<dc:date>/) { $time_count++; my ($tmp_time1, $tmp_time2) = split(/<dc:date>/, $line); my ($tmp_time3) = split(/<\/dc:date>/, $tmp_time2); my ($tmp_time4) = split(/\+/, $tmp_time3); my ($tmp_time5, $tmp_time6) = split(/T/, $tmp_time4); my ($tmp_time7, $tmp_time8) = split(/:/, $tmp_time6); if($time_count ne 1) { push(@times, getDate($tmp_time5) . " $tmp_time7:$tmp_time8"); } } } my ($i); for ($i = 0; $i < 10; $i++) { print("<a href=\"$links[$i]\" title=\"$descs[$i]\">$titles[$i]</a><br>\n$times[$i]<br>\n"); } } sub fixNorChar { my ($string) = @_; for(my $i=0; $i<20; $i++) { $string =~ s/æ/æ/i; $string =~ s/ø/ø/i; $string =~ s/å/å/i; $string =~ s/Æ/Æ/i; $string =~ s/Ø/Ø/i; $string =~ s/Å/Å/i; $string =~ s/æ/æ/i; $string =~ s/ø/ø/i; $string =~ s/Ã¥/å/i; $string =~ s/Ø/Ø/i; $string =~ s/Ã…/Å/i; $string =~ s/«/«/i; $string =~ s/»/»/i; $string =~ s/é/é/i; } return $string; }