]> git.sur5r.net Git - bacula/docs/blobdiff - docs/home-page/en/pages/testimonial.php
Tweak bacula.org html meta data
[bacula/docs] / docs / home-page / en / pages / testimonial.php
index b5d1cc7a1bcdc3cff2c4fc1c0c64ccbe096bef5c..0e58d40dd0d30933fc732a41b1fdf3ff4602c552 100644 (file)
@@ -1,5 +1,6 @@
-<? require_once("inc/header.php"); ?>
-<?
+<? 
+require_once("inc/header.php"); 
+
 $dat_dir = '/var/www/testimonials';
 $upload_dir = '/var/www/bacula';
 $password='';
@@ -19,11 +20,14 @@ $org_type_lst = array(
 
 $version_lst = array(
        'empty'   => "SELECT ONE",
+       '208'   => "5.0.x",
+       '207'   => "3.0.x",
        '200'   => "1.36.x",
        '201'   => "1.38.x",
        '202'   => "2.0.x",
        '203'   => "2.2.x",
-       '204'   => "SVN version"
+       '206'   => "2.4.x",
+       '204'   => "GIT master version"
 );
 
 $catalog_lst = array(
@@ -206,11 +210,12 @@ if ($_REQUEST['action'] == 'Add' or $_REQUEST['action'] == 'Modify')
 
 <script type="text/javascript" language="JavaScript">
 
-function validate_testimonial (form) {
+function validate_testimonial () {
     var alertstr = '';
     var invalid  = 0;
     var invalid_fields = new Array();
     var ok;
+    var form = document.forms['form1'];
     // email: standard text, hidden, password, or textarea box
     var email = form.elements['email_address'].value;
     if (email == null || ! email.match(/^[\w\-\+\._]+\@[a-zA-Z0-9][-a-zA-Z0-9\.]*\.[a-zA-Z]+$/)) {
@@ -236,7 +241,7 @@ function validate_testimonial (form) {
     }
     var number = form.elements['orgtype_id'].value;
     if (number == null || ! number.match(/^[0-9]+$/)) {
-        alertstr += '-  Choose one of the "Organization type" options\n';
+        alertstr += '- Choose one of the "Organization type" options\n';
         invalid_fields.push('orgtype_id');
         invalid++;
     } 
@@ -261,46 +266,58 @@ function validate_testimonial (form) {
     }
     var ostype = form.elements['ostype_id'].value;
     if (ostype == null || ! ostype.match(/^[0-9]+$/)) {
-        alertstr += '-  Choose one of the "Director OS" field\n';
+        alertstr += '- Choose one of the "Director OS" field\n';
         invalid_fields.push('ostype_id');
         invalid++;
     }
     var catalog = form.elements['catalog_id'].value;
     if (catalog == null || ! catalog.match(/^[0-9]+$/)) {
-        alertstr += '-  Choose one of the "Catalog type" field\n';
+        alertstr += '- Choose one of the "Catalog type" field\n';
         invalid_fields.push('catalog_id');
         invalid++;
     }
+    var comments = form.elements['comments'].value;
+    if (comments != null && comments.match(/http:\/\//)) {
+        alertstr += '- Invalid entry for the "Comments" field, we disallow spam url\n';
+        invalid_fields.push('comments');
+        invalid++;
+    }
+    comments = form.elements['hardware_comments'].value;
+    if (comments != null && comments.match(/http:\/\//)) {
+        alertstr += '- Invalid entry for the "Hardware comments" field, we disallow spam url\n';
+        invalid_fields.push('hardware_comments');
+        invalid++;
+    }
     var number = form.elements['number_fd'].value;
     if (number == null || ! number.match(/^[0-9,\.]+$/)) {
-        alertstr += '-  Invalid entry for the "Number of Client" field\n';
+        alertstr += '- Invalid entry for the "Number of Client" field\n';
         invalid_fields.push('number_fd');
         invalid++;
     } 
     number = form.elements['number_sd'].value;
     if (number == null || ! number.match(/^[0-9,\.]+$/)) {
-        alertstr += '-  Invalid entry for the "Number of Storage" field\n';
+        alertstr += '- Invalid entry for the "Number of Storage" field\n';
         invalid_fields.push('number_sd');
         invalid++;
     } 
     number = form.elements['number_dir'].value;
-    if (number == null || ! number.match(/^[0-9,\.]+$/)) {
-        alertstr += '-  Invalid entry for the "Number of Director" field\n';
+    if (number == null || ! number.match(/^[0-9,\.]+$/) || number > 100) {
+        alertstr += '- Invalid entry for the "Number of Director" field\n';
         invalid_fields.push('number_dir');
         invalid++;
     } 
     number = form.elements['month_gb'].value;
     if (number == null || ! number.match(/^[0-9,\.]+$/)) {
-        alertstr += '-  Invalid entry for the "Number GB/month" field\n';
+        alertstr += '- Invalid entry for the "Number GB/month" field\n';
         invalid_fields.push('month_gb');
         invalid++;
     } 
     number = form.elements['number_files'].value;
     if (number == null || ! number.match(/^[0-9,\.]+$/)) {
-        alertstr += '-  Invalid entry for the "File number" field\n';
+        alertstr += '- Invalid entry for the "File number" field\n';
         invalid_fields.push('number_files');
         invalid++;
-    } 
+    }
     if (invalid > 0 || alertstr != '') {
         if (! invalid) invalid = 'The following';   // catch for programmer error
         alert(''+invalid+' error(s) were encountered with your submission:'+'\n\n'
@@ -336,7 +353,7 @@ information about how this data will be used.
 
 <tr>
         <td class="content">
-<form name='form1' enctype="multipart/form-data" method='post' onsubmit="return validate_testimonial(this)" action='?page=testimonial'>
+<form name='form1' enctype="multipart/form-data" method='post' action='?page=testimonial'>
 <input type='hidden' name='page' value='testimonial'>
 <table border='0' class='Content'>
 
@@ -559,12 +576,12 @@ Nics:
 <?
  if ($_REQUEST['action'] == 'Modify') {
   echo "<input type='hidden' title='testimonial id' id='id' name='id' class='ItemValue' value=''>";
-  echo "<input type='submit' name='action' class='ItemValue' value='Save'>";
+  echo "<input type='submit' name='action' class='ItemValue' onclick='return validate_testimonial();' value='Save'>";
   echo "<input type='submit' name='action' class='ItemValue' onclick='confirm(\"Are you sure ?\");' value='Delete'><br>";
   echo "<input type='hidden' name='page' class='ItemValue' value='testimonial'><br>";
 
 } else {  
-  echo "<input type='submit' name='action' class='ItemValue' value='Review Profile Submission'>";
+  echo "<input type='submit' name='action' class='ItemValue' onclick='return validate_testimonial(this);' value='Review Profile Submission'>";
 }
 ?>
 
@@ -654,7 +671,7 @@ if ($_REQUEST['action'] == 'Modify') {
                 $form['visible']=0;
                 save_formul($form);
 
-                send_email($form['id'], $form['email_address']);
+                send_email($form['id'], $form['contact_name'], $form['email_address']);
                 echo "You can modify your profile <a href='?page=testimonial&action=Modify&id=" . $form['id'] . "'>here</a> (keep this link as bookmark)<br><br>";
                 print_formul($form);
         }
@@ -678,10 +695,10 @@ if ($_REQUEST['action'] == 'Modify') {
         $form = load_formul($filename);
         
         if ($form['org_logo'] && file_exists($form['org_logo'])) {
-            unlink($upload_dir + $form['org_logo']);
+            rename($upload_dir + $form['org_logo'], 'removed.' + $upload_dir + $form['org_logo']);
         }
         if (file_exists($filename)) {
-            unlink($filename);
+            rename($filename, "$filename-removed");
             echo "Profile deleted";
         }
 
@@ -763,25 +780,26 @@ function view_all()
     $limit = $_REQUEST['limit'];
     $offset = $_REQUEST['offset'];
 
-    $limit = is_numeric($limit)?$limit:5;
+    $limit = is_numeric($limit)?$limit:50;
     $offset = is_numeric($offset)?$offset:0;
     $max = $offset + $limit;
 
     $admin = is_admin();
-    if ($limit > 20) { $limit = 20 ;}
+    if ($limit > 100) { $limit = 100 ;}
 
     if ($handle = opendir($dat_dir)) {
     /* Ceci est la facon correcte de traverser un dossier. */
         $i = 0 ;
         while (false !== ($file = readdir($handle))) {
-            if (preg_match("/profile.[a-z0-9\.]+/", $file)) {
+            if (preg_match("/^profile.[a-z0-9\.]+$/", $file)) {
                 if (($i >= $offset) && ($i < $max)) {
-                    print_formul_file("$dat_dir/$file",$admin);
+                    $i += print_formul_file("$dat_dir/$file",$admin);
+                } else {
+                    $i++;
                 }
                 if ($i > $max) {
                     break;
-                }
-           $i++;
+               }
             }
         } 
         closedir($handle);
@@ -801,7 +819,7 @@ function view_all()
 
 function export_form($formul)
 {
-        global $country_lst, $org_type_lst, $org_industry_lst, $os_lst, $catalog_lst;
+        global $country_lst, $org_type_lst, $org_industry_lst, $os_lst, $catalog_lst, $version_lst;
 
         $attribs = array('contact_name','email_address', 'org_name','title','website',
                          'hardware_comments','comments',
@@ -842,7 +860,7 @@ function get_file_from_id()
     return $filename;
 }
 
-function send_email($id, $email)
+function send_email($id, $name, $email)
 {
         // Your email address
 //        $from = 'kern@sibbald.com';
@@ -859,8 +877,15 @@ Best regards.
 ";
 
         mail($email, $subject, $message, "From: Bacula WebMaster <$from>");
-        mail($from, $subject, $message, "From: Bacula WebMaster <$from>");
-        mail('eric@eb.homelinux.org', $subject, $message, "From: Bacula WebMaster <$from>");
+
+        $message = "Hello, 
+You can review this testimonial at http://www.bacula.org/en/?page=testimonial&action=Modify&id=$id
+
+Best regards.
+";
+
+        
+        mail('testimonial@baculasystems.com', $subject, $message, "From: $name <$email>");
 
         echo "The email has been sent for approval.<br/>";
 }
@@ -890,7 +915,22 @@ function get_formul()
         foreach ($attribs as $arr) {
                 $formul[$arr] = preg_replace('/[^a-zA-Z0-9!\.?\:\/,;_()@\n -]/', " ", $_REQUEST[$arr]);
         }
-
+        /* Disallow http:// links into comments field */
+        $m = array();
+        preg_match('/http:\/\//', $_REQUEST['comments'], $m);
+        if (sizeof($m) > 2) {
+           return '';
+        }
+        $m = array();
+        preg_match('/http:\/\//', $_REQUEST['hardware_comments'], $m);
+        if (sizeof($m) > 2) {
+           return '';
+        }
+        /* Disallow when number of dir too big or > number of fd */
+        if (intval($_REQUEST['number_dir']) > 100 || 
+            intval($_REQUEST['number_dir']) > intval($_REQUEST['number_fd'])) {
+           return '';
+        }
         $attribs = array('publish_contact','publish_email', 'publish_orgname', 'orgtype_id', 
                          'orgindustry_id','org_size', 'publish_orgsize','publish_website', 'bacula_version',
                          'country_id','ostype_id', 'redundant_setup','number_fd','number_sd','support',
@@ -957,7 +997,7 @@ function form_set_text($formul,$val)
 function is_admin()
 {
    global $dat_dir;
-   $id = $_REQUEST['passwd'];
+   $id = $_REQUEST['p'];
 
    if (!$id) {
        return(false);
@@ -978,9 +1018,9 @@ function admin_link()
 {
    global $password;
    if (is_admin()) {
-      $pass = $_REQUEST['passwd'];
+      $pass = $_REQUEST['p'];
       $waiting = $_REQUEST['waiting'];    
-      $password = "&passwd=$pass";
+      $password = "&p=$pass";
       print "Admin: ";
       if ($waiting) {
          print "<a href='?page=testimonial&action=Admin$password'> View all</a><br>";
@@ -1124,7 +1164,7 @@ function dump_sql()
     if ($handle = opendir($dat_dir)) {
     /* Ceci est la facon correcte de traverser un dossier. */
         while (false !== ($file = readdir($handle))) {
-            if (preg_match("/profile.[a-z0-9\.]+/", $file)) {
+            if (preg_match("/^profile.[a-z0-9\.]+$/", $file)) {
                $tmpv = array();
                $tmpk = array();
                $form = load_formul("$dat_dir/$file");
@@ -1163,7 +1203,7 @@ function print_formul($formul)
    <? } ?>
 
    <? if ($formul['publish_website']) { ?>
-        <tr><td> Website: </td><td><? echo $formul['website'] ?> </td></tr>
+        <tr><td> Website: </td><td><a href="<? echo $formul['website'] ?>"><? echo $formul['website'] ?></a></td></tr>
    <? } ?>
 
    <? if ($formul['number_fd'] > 1) { ?>
@@ -1174,17 +1214,21 @@ function print_formul($formul)
         <tr><td> GB/Month: </td><td><? echo $formul['month_gb'] ?> </td></tr>
    <? } ?>
 
-   <tr><td> Comments: </td><td width='450'><i><? echo $formul['comments'] ?> </i></td></tr>
+   <tr><td> Comments: </td><td width='650'><i><? echo $formul['comments'] ?> </i></td></tr>
    <? if ($formul['publish_contact']) { ?>
         <tr align='right'><td></td><td><i><? echo $formul['contact_name'] ?> </i></td></tr>
    <? } ?>
+<!--
    </table>
    </td>
-   <td align='center' valign='center'>
+-->
+   <tr><td></td>
+   <td>
    <? if ($formul['org_logo']) { ?>
         <a href="<? echo $formul['org_logo'] ?>" ><img width='150' src="<? echo $formul['org_logo'] ?>"></a>
    <? } ?>
    </td>
+   </tr> <!-- added -->
    </table>
 <?
    return 1;