updated perl files to support sqlite related database configurations
This commit is contained in:
parent
64a0b15c54
commit
a39ea1339a
@ -8,7 +8,7 @@ dnf install -y \
|
|||||||
mariadb-server mariadb httpd \
|
mariadb-server mariadb httpd \
|
||||||
php php-mysqli php-gd \
|
php php-mysqli php-gd \
|
||||||
perl-Digest-SHA \
|
perl-Digest-SHA \
|
||||||
perl-DBD-MySQL perl-LDAP \
|
perl-DBD-MySQL perl-DBD-SQLite perl-LDAP \
|
||||||
mod_dav_svn mod_perl diffutils
|
mod_dav_svn mod_perl diffutils
|
||||||
|
|
||||||
dnf install -y \
|
dnf install -y \
|
||||||
|
@ -6,7 +6,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|||||||
php libapache2-mod-php php-mysql php-gd \
|
php libapache2-mod-php php-mysql php-gd \
|
||||||
libapache2-mod-perl2 libapache2-mod-svn \
|
libapache2-mod-perl2 libapache2-mod-svn \
|
||||||
libswitch-perl libconfig-simple-perl libdigest-sha-perl \
|
libswitch-perl libconfig-simple-perl libdigest-sha-perl \
|
||||||
libdbd-mysql-perl libnet-ldap-perl libsvn-perl libmail-sendmail-perl \
|
libdbd-mysql-perl libdbd-sqlite3-perl libnet-ldap-perl libsvn-perl libmail-sendmail-perl \
|
||||||
php-dev libsvn-dev make
|
php-dev libsvn-dev make
|
||||||
|
|
||||||
svn co http://code.miflux.com/svn/codepot/trunk/codepot && \
|
svn co http://code.miflux.com/svn/codepot/trunk/codepot && \
|
||||||
|
@ -236,6 +236,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -246,6 +247,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -75,6 +75,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -86,6 +87,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -58,6 +58,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -69,6 +70,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -73,6 +73,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -84,6 +85,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -56,6 +56,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -67,6 +68,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -46,6 +46,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -57,6 +58,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
|
@ -51,6 +51,7 @@ sub open_database
|
|||||||
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
if ($dbtype eq 'postgre') { $dbtype = 'Pg'; }
|
||||||
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
elsif ($dbtype eq 'oci8') { $dbtype = 'Oracle'; }
|
||||||
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
elsif ($dbtype eq 'mysqli') { $dbtype = 'mysql'; }
|
||||||
|
elsif ($dbtype eq 'sqlite') { $dbtype = 'SQLite'; }
|
||||||
|
|
||||||
my $dbstr;
|
my $dbstr;
|
||||||
my $dbuser;
|
my $dbuser;
|
||||||
@ -62,6 +63,12 @@ sub open_database
|
|||||||
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
$dbuser = $cfg->{database_username} . '/' . $cfg->{database_password} . '@' . $dbhost;
|
||||||
$dbpass = '';
|
$dbpass = '';
|
||||||
}
|
}
|
||||||
|
elsif ($dbtype eq 'SQLite')
|
||||||
|
{
|
||||||
|
$dbstr = "DBI:$dbtype:database=$dbhost;";
|
||||||
|
$dbuser = $cfg->{database_username};
|
||||||
|
$dbpass = $cfg->{database_password};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dbstr = "DBI:$dbtype:database=$dbname;";
|
$dbstr = "DBI:$dbtype:database=$dbname;";
|
||||||
@ -185,12 +192,12 @@ sub toggle_user
|
|||||||
|
|
||||||
$dbh->begin_work ();
|
$dbh->begin_work ();
|
||||||
|
|
||||||
my $query = $dbh->prepare ("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?");
|
my $query = $dbh->prepare("UPDATE ${QC}${prefix}user_account${QC} SET ${QC}enabled${QC}=? WHERE ${QC}userid${QC}=?");
|
||||||
if (!$query || !$query->execute ($enabled, $userid) || $query->rows() <= 0)
|
if (!$query || !(my $execok = $query->execute($enabled, $userid)) || $query->rows() <= 0)
|
||||||
{
|
{
|
||||||
my $errstr = $dbh->errstr();
|
my $errstr = $execok? "user not found": $dbh->errstr();
|
||||||
$dbh->rollback ();
|
$dbh->rollback ();
|
||||||
print (STDERR "Cannot enable/disable a user - $errstr\n");
|
print (STDERR "Cannot enable/disable the user '$userid' - $errstr\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +269,7 @@ if ($op <= 0)
|
|||||||
exit (2);
|
exit (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $cfg = get_config ();
|
my $cfg = get_config();
|
||||||
if (!defined($cfg))
|
if (!defined($cfg))
|
||||||
{
|
{
|
||||||
print (STDERR "Cannot load codepot configuration file\n");
|
print (STDERR "Cannot load codepot configuration file\n");
|
||||||
@ -294,7 +301,7 @@ if ($allowed_to_execute == 0)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $dbh = open_database ($cfg);
|
my $dbh = open_database($cfg);
|
||||||
if (!defined($dbh))
|
if (!defined($dbh))
|
||||||
{
|
{
|
||||||
printf (STDERR "Cannot open database - %s\n", $DBI::errstr);
|
printf (STDERR "Cannot open database - %s\n", $DBI::errstr);
|
||||||
@ -303,10 +310,10 @@ if (!defined($dbh))
|
|||||||
|
|
||||||
switch ($op)
|
switch ($op)
|
||||||
{
|
{
|
||||||
case 1 { $ret = add_user ($dbh, $cfg->{database_prefix}, $USERID, $PASSWD, $EMAIL); }
|
case 1 { $ret = add_user($dbh, $cfg->{database_prefix}, $USERID, $PASSWD, $EMAIL); }
|
||||||
case 2 { $ret = delete_user ($dbh, $cfg->{database_prefix}, $USERID); }
|
case 2 { $ret = delete_user($dbh, $cfg->{database_prefix}, $USERID); }
|
||||||
case 3 { $ret = toggle_user ($dbh, $cfg->{database_prefix}, $USERID, 'Y'); }
|
case 3 { $ret = toggle_user($dbh, $cfg->{database_prefix}, $USERID, 'Y'); }
|
||||||
case 4 { $ret = toggle_user ($dbh, $cfg->{database_prefix}, $USERID, 'N'); }
|
case 4 { $ret = toggle_user($dbh, $cfg->{database_prefix}, $USERID, 'N'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
close_database ($dbh);
|
close_database ($dbh);
|
||||||
|
Loading…
Reference in New Issue
Block a user