<commit_before>#!/usr/bin/perl

package saliweb::server;

use strict;


use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Pretty;
use Digest::MD5;
use File::Copy;

use saliweb::frontend;
use DBI;

use vars '@ISA', '@EXPORT', '$NAME', '$VERSION', '$DATE', '$AUTHOR';
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(help_link remote_user header validate_user get_datetime upload_file get_seq_id CleanSeq make_seq_id format_sequence check_file end_server add_user validate_access navigation validate_email get_dir_list );

$NAME = "saliweb::server";
$DATE = "9-09-2009";
$AUTHOR = "<NAME>";

#
# -------------------------------------------------------------------------


sub help_link {

    my $server=shift @_;
    my $keyword=shift @_;
    my $help_link;
    my $q=new CGI;
    my ($url);
    if (grep/^http/,$keyword) {
        $url=$keyword;
    } else {
        $url="display?server=$server&style=helplink&type=help#$keyword";
    }

    $help_link=$q->a({-href=>"$url",-border=>"0", -onClick=>"launchHelp(\'$url\'); return false;"},
            $q->img({-src=>"/img/help.jpg", -border=>0,-valign=>"bottom"} ));

    return $help_link;
}

sub remote_user {

        my $q= new CGI;
        my ($current_user,$remote_host);
        $current_user=$ENV{'REMOTE_USER'};
        $remote_host=$ENV{"REMOTE_HOST"}||$ENV{'REMOTE_ADDR'};
        return ($remote_host);
}

sub header {
    my $root=shift @_;
    my $title=shift @_;
    my $menutitle=shift@_;
    my $menuentries_ref=shift@_;
    my $current_project=shift@_;
    my $navigation=shift@_;
    my %menuentries;
    if ($menuentries_ref) {
        %menuentries=%$menuentries_ref;
    } 
        
    my $q=new CGI;
    my ($headertable,$field,$linkline);
    my ($remote_host)=&remote_user;
        my ($menuentries,$entry);
        foreach $entry (sort keys %menuentries) {
            
            if ($menuentries{$entry} eq "not available") {
                $menuentries.="<li>$entry</li>\n";
            } else {
                $menuentries.="<li><a href=\"".$menuentries{$entry}."\">$entry</a></li>\n";
            }
    }
              
    $headertable="<div id=\"container\">\n    <div id=\"header1\"> 
        <h3><img src=\"http://salilab.org/img/logo_small.gif\" height=\"40\" alt=\"\" /> $title</h3>\n    </div>";
    $headertable.="\n    <div id=\"navigation_lab\">\n
            &bull;&nbsp;<a href=\"http://salilab.org\">Sali Lab Home</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modweb\"> ModWeb</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modbase/\">ModBase</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modeval/\">ModEval</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/pcss/\">PCSS</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/foxs/\">FoXS</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/imp/\">IMP</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modpipe/\">ModPipe</a>&nbsp;&bull;&nbsp;
    \n</div>\n    $navigation
        <div style=\"clear:both;\"></div><div id=\"bodypart\">";
    $headertable.=" \n<div id=\"left\">
          $current_project";
    if ($menutitle ne "none") {
        $headertable.=
            "\n<div id=\"navigation_saliresources\">"
            ." <h3>$menutitle</h3> 
              <ul> $menuentries</ul>
            \n</div>";
    }
    $headertable.="\n</div>";

    return $headertable;
    
}

sub validate_user {

    my $dbh=shift @_;
    my $database=shift @_;
    my $type=shift @_;
    my $user_name=shift @_;
    my $password=shift @_;
    my $server=shift @_;
    my ($query,$sth,@row,$hash);
    my %userinfo;
    my ($first,$last,$email);
<commit_msg>Link to MultiFit web server<commit_after>#!/usr/bin/perl

package saliweb::server;

use strict;


use CGI;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Pretty;
use Digest::MD5;
use File::Copy;

use saliweb::frontend;
use DBI;

use vars '@ISA', '@EXPORT', '$NAME', '$VERSION', '$DATE', '$AUTHOR';
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(help_link remote_user header validate_user get_datetime upload_file get_seq_id CleanSeq make_seq_id format_sequence check_file end_server add_user validate_access navigation validate_email get_dir_list );

$NAME = "saliweb::server";
$DATE = "9-09-2009";
$AUTHOR = "<NAME>";

#
# -------------------------------------------------------------------------


sub help_link {

    my $server=shift @_;
    my $keyword=shift @_;
    my $help_link;
    my $q=new CGI;
    my ($url);
    if (grep/^http/,$keyword) {
        $url=$keyword;
    } else {
        $url="display?server=$server&style=helplink&type=help#$keyword";
    }

    $help_link=$q->a({-href=>"$url",-border=>"0", -onClick=>"launchHelp(\'$url\'); return false;"},
            $q->img({-src=>"/img/help.jpg", -border=>0,-valign=>"bottom"} ));

    return $help_link;
}

sub remote_user {

        my $q= new CGI;
        my ($current_user,$remote_host);
        $current_user=$ENV{'REMOTE_USER'};
        $remote_host=$ENV{"REMOTE_HOST"}||$ENV{'REMOTE_ADDR'};
        return ($remote_host);
}

sub header {
    my $root=shift @_;
    my $title=shift @_;
    my $menutitle=shift@_;
    my $menuentries_ref=shift@_;
    my $current_project=shift@_;
    my $navigation=shift@_;
    my %menuentries;
    if ($menuentries_ref) {
        %menuentries=%$menuentries_ref;
    } 
        
    my $q=new CGI;
    my ($headertable,$field,$linkline);
    my ($remote_host)=&remote_user;
        my ($menuentries,$entry);
        foreach $entry (sort keys %menuentries) {
            
            if ($menuentries{$entry} eq "not available") {
                $menuentries.="<li>$entry</li>\n";
            } else {
                $menuentries.="<li><a href=\"".$menuentries{$entry}."\">$entry</a></li>\n";
            }
    }
              
    $headertable="<div id=\"container\">\n    <div id=\"header1\"> 
        <h3><img src=\"http://salilab.org/img/logo_small.gif\" height=\"40\" alt=\"\" /> $title</h3>\n    </div>";
    $headertable.="\n    <div id=\"navigation_lab\">\n
            &bull;&nbsp;<a href=\"http://salilab.org\">Sali Lab Home</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modweb\"> ModWeb</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modbase/\">ModBase</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modeval/\">ModEval</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/pcss/\">PCSS</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/foxs/\">FoXS</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/imp/\">IMP</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/multifit/\">MultiFit</a>&nbsp;&bull;&nbsp;
        <a href=\"http://salilab.org/modpipe/\">ModPipe</a>&nbsp;&bull;&nbsp;
    \n</div>\n    $navigation
        <div style=\"clear:both;\"></div><div id=\"bodypart\">";
    $headertable.=" \n<div id=\"left\">
          $current_project";
    if ($menutitle ne "none") {
        $headertable.=
            "\n<div id=\"navigation_saliresources\">"
            ." <h3>$menutitle</h3> 
              <ul> $menuentries</ul>
            \n</div>";
    }
    $headertable.="\n</div>";

    return $headertable;
    
}

sub validate_user {

    my $dbh=shift @_;
    my $database=shift @_;
    my $type=shift @_;
    my $user_name=shift @_;
    my $password=shift @_;
    my $server=shift @_;
    my ($query,$sth,@row,$hash);
    my %userinfo;
    my ($first,$last,$email);

{'fraction_non_alphanumeric': 0.2236877523553163, 'fraction_numerical': 0.004576043068640646, 'mean_word_length': 2.6125425376762275, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1167232', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2607, 'n_words': 428}