]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - config/cfgroot/general-functions.pl
BUG12070: Its not possible to use the underscore in email addresses
[ipfire-2.x.git] / config / cfgroot / general-functions.pl
index f448c34befc7cf8af483f674f02665c0203d6a54..aefcfb6878442555edc1b73cdaf5ceb8793c88ef 100644 (file)
@@ -149,6 +149,10 @@ sub readhash
        while (<FILE>)
        {
                chop;
+
+               # Skip comments.
+               next if ($_ =~ /^#/);
+
                ($var, $val) = split /=/, $_, 2;
                if ($var)
                {
@@ -235,7 +239,13 @@ sub writehashpart
 sub age {
        my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
                $atime, $mtime, $ctime, $blksize, $blocks) = stat $_[0];
-       my $totalsecs = time() - $mtime;
+       my $t = time() - $mtime;
+
+       return &format_time($t);
+}
+
+sub format_time($) {
+       my $totalsecs = shift;
        my @s = ();
 
        my $secs = $totalsecs % 60;
@@ -774,7 +784,7 @@ sub validemail {
     return 0 if ( substr($parts[1],-1,1) eq '.' );
 
     #check first addresspart (before '@' sign)
-    return 0 if  ( $parts[0] !~ m/^[a-zA-Z0-9\.!\-\+#]+$/ );
+    return 0 if  ( $parts[0] !~ m/^[a-zA-Z0-9\.!\-\_\+#]+$/ );
 
     #check second addresspart (after '@' sign)
     return 0 if  ( $parts[1] !~ m/^[a-zA-Z0-9\.\-]+$/ );
@@ -1159,5 +1169,12 @@ sub dnssec_status() {
 
        return $status;
 }
+sub number_cpu_cores() {
+       open my $cpuinfo, "/proc/cpuinfo" or die "Can't open cpuinfo: $!\n";
+       my $cores = scalar (map /^processor/, <$cpuinfo>);
+       close $cpuinfo;
+
+       return $cores;
+}
 
 1;