</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 250px. png, gif or jpeg only</i></td>
</tr>
<tr><td class='ItemName'><font color='red'>*</font>Country:</td>
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'>";
}
}
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";
$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);
echo "Profile deleted";
}
-} elseif ($_REQUEST['btnSubmit'] == 'Accept') {
-
- $id = $_REQUEST['id'];
+} elseif ($_REQUEST['btnSubmit'] == 'Accept' && is_admin()) {
- 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']) {
save_formul($form);
echo "Your profile has been modified.<br>";
- print_formul($filename,true);
+ 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') {
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)) {
}
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',
+ '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 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)
+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>");
echo "The email has been sent for approval.<br/>";
}
$formul['date'] = time();
$formul['visible'] = false;
-// foreach ($formul as $key => $val) {
-// print "$key = $val<br/>";
-// }
-
return $formul;
}
if (file_exists("$dat_dir/$id")) {
return true;
- $formul['visible'] = $val;
} else {
return false;
}
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>
</td>
</table>
<?
-
return 1;
}