]> git.sur5r.net Git - bacula/docs/blobdiff - docs/home-page/pages/testimonial.php
Update
[bacula/docs] / docs / home-page / pages / testimonial.php
index 7042ab1a470542dd60ebedc9ab6f114a76c9c23f..d9458c307e1219bf24fecda938bd29ee0bf49479 100644 (file)
@@ -316,10 +316,10 @@ size='4' maxlength='6' value=''></td>
 </tr>
 
 <tr>
-<td class='ItemName'>Organization Logo:</td>
+<td class='ItemName'>Organization Logo :</td>
 <td class='ItemValue'>
 <input type="file" name="org_logo" title="png, gif or jpeg file only please"/>
-</td>
+</td><td><i>max width 150px. png, gif or jpeg only</i></td>
 </tr>
 
 <tr><td class='ItemName'><font color='red'>*</font>Country:</td>
@@ -405,6 +405,15 @@ while(list ($key, $val) = each ($catalog_lst))
 <td class='ItemValue'><input type='text' class='ItemValue' name='number_files'
  id='number_files' title='select count(1) from File;' size='10' maxlength='15' value=''></td>
 </tr>
+<tr>
+
+<td class='ItemName'>Need professional support:</td>
+<td class='ItemValue'>
+<select name='support' class='ItemValue'>
+<option id='support_0' value='0' SELECTED>No
+<option id='support_1' value='1'>Yes
+</select></td>
+</tr>
 
 <tr><td colspan=4><br></td></tr>
 
@@ -434,9 +443,6 @@ Nics:
   echo "<input type='submit' name='btnSubmit' class='ItemValue' onclick='confirm(\"Are you sure ?\");' value='Delete'><br>";
   echo "<input type='hidden' name='page' class='ItemValue' value='testimonial'><br>";
 
-  echo "<input type='text' title='Password' name='passwd' class='ItemValue' value=''>";
-  echo "<input type='submit' name='btnSubmit' class='ItemValue' value='Accept'>";
-
 } else {  
   echo "<input type='submit' name='btnSubmit' class='ItemValue' value='Review Profile Submission'>";
 }
@@ -467,13 +473,12 @@ we find the need.
 }
 
 if ($_REQUEST['btnSubmit'] == 'Modify') {
-   $id = $_REQUEST['id'];
+   $filename = get_file_from_id();
 
-   if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
-         return(0) ;
+   if (!$filename) {
+       return (0);
    }
 
-   $filename="$dat_dir/profile.$id";
    $formul = load_formul($filename);
 
    echo "<script type='text/javascript' language='JavaScript'>\n";
@@ -486,7 +491,7 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
 
    $attribs = array('publish_contact','publish_email', 'publish_orgname', 'orgtype_id', 
                     'orgindustry_id', 'publish_orgsize','publish_website', 'bacula_version',
-                    'country_id','ostype_id', 'redundant_setup', 'catalog_id');
+                    'country_id','ostype_id', 'redundant_setup', 'catalog_id', 'support');
    foreach ($attribs as $arr) {
         form_set_selection($formul, $arr);
    }
@@ -497,7 +502,7 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
 
         $form = get_formul();
         if (!$form) {
-                echo "Sorry, you miss something, i can't accept your submission";
+                echo "Sorry, something is missing, I cannot accept your submission";
         } else {
                 $token = uniqid(md5(rand()), true);
                 $filename = "$dat_dir/profile.$token";
@@ -506,31 +511,26 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
                 $form['id'] = $token;
                 save_formul($form);
 
-                send_email($form['id']);
-                echo "Your submission id is " . $form['id'] . "<br>";
+                send_email($form['id'], $form['email_address']);
                 echo "You can modify your profile <a href='?page=testimonial&btnSubmit=Modify&id=" . $form['id'] . "'>here</a> (keep this link as bookmark)<br><br>";
-                print_formul($form['filename'], true);
+                print_formul($form);
         }
 
 } elseif ($_REQUEST['btnSubmit'] == 'View') {
+       
+       $file = get_file_from_id();
 
-        $id = $_REQUEST['id'];
-
-        if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
-            return(0) ;
-        }
-        $filename="$dat_dir/profile.$id";
-        
-        print_formul($filename,true);
+       if ($file) {
+            print_formul_file($filename,true);
+       }
 
 } elseif ($_REQUEST['btnSubmit'] == 'Delete') {
 
-        $id = $_REQUEST['id'];
+       $filename = get_file_from_id();
 
-        if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
-            return(0) ;
-        }
-        $filename="$dat_dir/profile.$id";
+       if (!$filename) {
+           return (0);
+       }
 
         $form = load_formul($filename);
         
@@ -542,42 +542,39 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
             echo "Profile deleted";
         }
 
-} elseif ($_REQUEST['btnSubmit'] == 'Accept') {
+} elseif ($_REQUEST['btnSubmit'] == 'Accept' && is_admin()) {
 
-        $id = $_REQUEST['id'];
-
-        if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
-            return(0) ;
-        }
-        $filename="$dat_dir/profile.$id";
+       $filename = get_file_from_id();
         
-        $form = load_formul($filename);
-        if (is_admin()) {
-                $form['visible']=1;
-        }
-        save_formul($form);
-        echo "$id is now visible";
-        print_formul($form,1);
+       if (!$filename) {
+           return (0);
+       }
 
-} elseif ($_REQUEST['btnSubmit'] == 'Save') {
+        $form = load_formul($filename);
 
-        $id = $_REQUEST['id'];
+       $hide = $_REQUEST['hide'];
 
-        if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
-            return(0) ;
-        }
+        if ($hide) {
+                $form['visible']=0;
+        } else {
+               $form['visible']=1;
+       }
+        save_formul($form);
+        echo $form['id'] . " is now " . ($hide?"un":"") . "visible";
+        print_formul($form);
 
-        $filename="$dat_dir/profile.$id";
+} elseif ($_REQUEST['btnSubmit'] == 'Save') {
+       
+       $filename = get_file_from_id();
 
-        if (!file_exists($filename)) {
-                echo "Can't verify your id";
-                return (0);
-        }       
+       if (!$filename) {
+           return (0);
+       }
 
         $form = get_formul();
 
         $form['filename'] = $filename;  
-        $form['id'] = $id;
+        $form['id'] = $_REQUEST['id'];  // id is clean
 //      $form['visible'] = false;
 
         if (!$form['org_logo']) {
@@ -587,9 +584,44 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
 
         save_formul($form);
 
-        echo "Your profile have been modified.<br>";
-        print_formul($filename,true);
+        echo "Your profile has been modified.<br>";
+        print_formul($form);
+
+} elseif ($_REQUEST['btnSubmit'] == 'Admin' && is_admin()) {
+
+
+    $pass = $_REQUEST['passwd']; // passwd is clean
+    $waiting = $_REQUEST['waiting'];
+    
+    if ($waiting) {
+       print '<a href="?page=testimonial&btnSubmit=Admin&passwd=' . $pass . '"> View all</a><br>';
+       print "<h1>View all waiting testimonials</h1>";
+    } else {
+       print '<a href="?page=testimonial&btnSubmit=Admin&waiting=1&passwd=' . $pass . '"> View Waiting</a><br>';
+       print "<h1>View all testimonials</h1>";
+    }
 
+    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)) {
+                     $form = load_formul("$dat_dir/$file") ;
+                       // on affiche ceux qui sont en attente ou bien tous
+                    if (!$waiting || !$form['visible']) {
+                       print_formul($form);
+                       if ($form['visible']) {
+                          print "<a href=\"?page=testimonial&btnSubmit=Accept&hide=1&passwd=" . $pass . "&id=" . $form['id'] . "\"> Hide </a> | \n";
+                       } else {
+                          print "<a href=\"?page=testimonial&btnSubmit=Accept&passwd=" . $pass . "&id=" . $form['id'] . "\"> Accept </a> | \n";
+                       }
+                       print "<a href=\"?page=testimonial&btnSubmit=Modify&id=" . $form['id'] . "\"> Modify </a> | \n";
+                       print "<a href=\"?page=testimonial&btnSubmit=AdminExport&passwd=" . $pass . "&id=" . $form['id'] . "\"> Export </a><br><br>\n";
+
+                    }
+                }
+            } 
+            closedir($handle);
+    } 
 
 } elseif (!$_REQUEST['btnSubmit'] || $_REQUEST['btnSubmit'] == 'ViewAll') {
 
@@ -611,7 +643,7 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
             while (false !== ($file = readdir($handle))) {
                 if (preg_match("/profile.[a-z0-9\.]+/", $file)) {
                     if ($i >= $offset && $i < ($offset + $limit)) {
-                        $i += print_formul("$dat_dir/$file",$admin);
+                        $i += print_formul_file("$dat_dir/$file",$admin);
                     }
 
                     if ($i > ($offset + $limit)) {
@@ -621,24 +653,83 @@ if ($_REQUEST['btnSubmit'] == 'Modify') {
             } 
             closedir($handle);
     }
+
+} elseif ($_REQUEST['btnSubmit'] == 'AdminExport' && is_admin()) {
+
+   $file = get_file_from_id();
+   if (!$file) {
+       return 0;
+   }
+   $form = load_formul($file);
+   if ($form) {
+       export_form($form);
+   }
+} else {
+       print "Invalid btnSubmit<br>";
+}
+
+function export_form($formul)
+{
+        global $country_lst, $org_type_lst, $org_industry_lst, $os_lst, $catalog_lst;
+
+        $attribs = array('contact_name','email_address', 'org_name','title','website',
+                        'hardware_comments','comments',
+                        'publish_contact','publish_email', 'publish_orgname','org_size','redundant_setup',
+                        'date','visible', 'support',
+                        'number_fd','number_sd','month_gb','number_files','publish_orgsize','publish_website');
+       print "<pre>\n";
+        foreach ($attribs as $arr) {
+               print "$arr = " . $formul[$arr] . "\n";
+        }
+
+       print "orgtype = " . $org_type_lst[$formul['orgtype_id']] . "\n";
+       print "orgindustry = " . $org_industry_lst[$formul['orgindustry_id']] . "\n";
+       print "bacula_version = " . $version_lst[$formul['bacula_version']] . "\n";
+       print "country = " . $country_lst[$formul['country_id']] . "\n";
+       print "ostype = " . $os_lst[$formul['ostype_id']] . "\n";
+       print "catalog = " . $catalog_lst[$formul['catalog_id']] . "\n";
+
+       print "<pre>\n";
 }
 
-function send_email($id)
+function get_file_from_id()
+{
+    global $dat_dir;
+    $id = $_REQUEST['id'];
+
+    if (!ereg('^[a-zA-Z0-9\.]+$',$id)) {
+         return(0) ;
+    }
+
+    $filename="$dat_dir/profile.$id";
+
+    if (!file_exists($filename)) {
+         echo "Can't verify your id";
+         return (0);
+    }       
+
+    return $filename;
+}
+
+function send_email($id, $email)
 {
         // Your email address
-        $email = 'kern@sibbald.com';
+        $from = 'kern@sibbald.com';
+//        $from = 'eric@eb.homelinux.org';
 
         // The subject
         $subject = "[BACULA] New testimonial";
 
         // The message
-        $message = "Hi
-there is a new testimonial at http://www.bacula.org/?page=testimonial&btnSubmit=Modify&id=$id
+        $message = "Hello
+You can modify your new testimonial at http://www.bacula.org/?page=testimonial&btnSubmit=Modify&id=$id
 
-Bye
+Best regards.
 ";
 
-        mail($email, $subject, $message, "From: eric@eb.homelinux.org");
+        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>");
 
         echo "The email has been sent for approval.<br/>";
 }
@@ -670,7 +761,7 @@ function get_formul()
 
         $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',
+                         'country_id','ostype_id', 'redundant_setup','number_fd','number_sd','support',
                          'month_gb','number_files','catalog_id');
         foreach ($attribs as $arr) {
                 if (preg_match("/^[0-9]+$/", $_REQUEST[$arr])) {
@@ -708,10 +799,6 @@ function get_formul()
         $formul['date'] = time();
         $formul['visible'] = false;
 
-//      foreach ($formul as $key => $val) {
-//              print "$key = $val<br/>";
-//      }
-
         return $formul;
 }
 
@@ -737,7 +824,6 @@ function is_admin()
         
         if (file_exists("$dat_dir/$id")) {
             return true;
-            $formul['visible'] = $val;
         } else {
             return false;
         }
@@ -764,21 +850,30 @@ function load_formul($filename)
         return $formul;
 }
 
-function print_formul($filename, $visible) {
-        global $country_lst, $org_type_lst, $org_industry_lst, $os_lst;
+function print_formul_file($filename, $admin) {
 
         $formul = load_formul($filename);
         if (!$formul) {
                 return 0;
         }
         
-        if (!$visible) {
+        if (!$admin) {
                 if (!$formul['visible']) {
                         return 0;
                 }
-        }
+        } else {
+               print "<a href=\"?page=testimonial&btnSubmit=Modify&id=" . $formul['id'] . "\">Modify</a><br>\n";
+       }
+
+       return print_formul($formul);
+}
+
+function print_formul($formul)
+{
+   global $country_lst, $org_type_lst, $org_industry_lst, $os_lst,$catalog_lst;
+
    ?>
-   <table>
+   <table width="80%">
    <td>
    <b><? echo ($formul['publish_orgname'])?$formul['org_name']:'N/A' ?></b><br>
    <table>
@@ -794,28 +889,27 @@ function print_formul($filename, $visible) {
         <tr><td> Website: </td><td><? echo $formul['website'] ?> </td></tr>
    <? } ?>
 
-   <? if ($formul['number_fd']) { ?>
+   <? if ($formul['number_fd'] > 1) { ?>
         <tr><td> Number of fd: </td><td><? echo $formul['number_fd'] ?> </td></tr>
    <? } ?>
 
-   <? if ($formul['month_gb']) { ?>
+   <? if ($formul['month_gb'] > 1) { ?>
         <tr><td> GB/Month: </td><td><? echo $formul['month_gb'] ?> </td></tr>
    <? } ?>
 
-   <tr><td> Comments: </td><td><i><? echo $formul['comments'] ?> </i></td></tr>
+   <tr><td> Comments: </td><td width='450'><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>
    <? if ($formul['org_logo']) { ?>
-        <img width='250' src="<? echo $formul['org_logo'] ?>">
-   <? } ?>
-   <? if ($formul['publish_contact']) { ?>
-        <tr align='right'><td></td><td><i><? echo $formul['contact_name'] ?> </i></td></tr>
+        <a href="<? echo $formul['org_logo'] ?>" ><img width='150' src="<? echo $formul['org_logo'] ?>"></a>
    <? } ?>
    </td>
    </table>
 <?
-
    return 1;
 }