[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/calendar/egroupware.org/ -> accept_holiday.php (source)

   1  <?php
   2    /**************************************************************************\
   3    * eGroupWare                                                               *
   4    * http://www.egroupware.org                                                *
   5    * Written by Mark Peters <skeeter@phpgroupware.org>                        *
   6    * --------------------------------------------                             *
   7    *  This program is free software; you can redistribute it and/or modify it *
   8    *  under the terms of the GNU General Public License as published by the   *
   9    *  Free Software Foundation; either version 2 of the License, or (at your  *
  10    *  option) any later version.                                              *
  11    \**************************************************************************/
  12      /* $Id: accept_holiday.php 20295 2006-02-15 12:31:25Z  $ */
  13  
  14      $send_back_to = str_replace('submit','admin',$_SERVER['HTTP_REFERER']);
  15      if(!$_POST['locale'])
  16      {
  17          Header('Location: '.$send_back_to);
  18      }
  19  
  20  	function _holiday_cmp($a,$b)
  21      {
  22          if (($year_diff = ($a['occurence'] <= 0 ? 0 : $a['occurence']) - ($b['occurence'] <= 0 ? 0 : $b['occurence'])))
  23          {
  24              return $year_diff;
  25          }
  26          return $a['month'] - $b['month'] ? $a['month'] - $b['month'] : $a['day'] - $b['day'];
  27      }
  28  
  29      $send_back_to = str_replace('&locale='.$_POST['locale'],'',$send_back_to);
  30      $file = './holidays.'.$_POST['locale'].'.csv';
  31      if(!file_exists($file) || filesize($file) < 300)    // treat very small files as not existent
  32      {
  33          if (count($_POST['name']))
  34          {
  35              $fp = fopen($file,'w');
  36              if ($_POST['charset']) fwrite($fp,"charset\t".$_POST['charset']."\n");
  37  
  38              $holidays = array();
  39              foreach($_POST['name'] as $i => $name)
  40              {
  41                  $holidays[] = array(
  42                      'locale' => $_POST['locale'],
  43                      'name'   => str_replace('\\','',$name),
  44                      'day'    => $_POST['day'][$i],
  45                      'month'  => $_POST['month'][$i],
  46                      'occurence' => $_POST['occurence'][$i],
  47                      'dow'    => $_POST['dow'][$i],
  48                      'observance_rule' => $_POST['observance'][$i],
  49                  );
  50              }
  51              // sort holidays by year / occurence:
  52              usort($holidays,'_holiday_cmp');
  53              
  54              $last_year = -1;
  55              foreach($holidays as $holiday)
  56              {
  57                  $year = $holiday['occurence'] <= 0 ? 0 : $holiday['occurence'];
  58                  if ($year != $last_year)
  59                  {
  60                      fwrite($fp,"\n".($year ? $year : 'regular (year=0)').":\n");
  61                      $last_year = $year;
  62                  }
  63                  fwrite($fp,"$holiday[locale]\t$holiday[name]\t$holiday[day]\t$holiday[month]\t$holiday[occurence]\t$holiday[dow]\t$holiday[observance_rule]\n");
  64              }
  65              fclose($fp);
  66          }
  67          Header('Location: '.$send_back_to);
  68      }
  69      else
  70      {
  71  ?>
  72  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  73  <html>
  74  <head>
  75      <title>eGroupWare.org: There is already a holiday-file for '<?php echo $_POST['locale']; ?>' !!!</title>
  76  </head>
  77  <body>
  78      <h1>There is already a holiday-file for '<?php echo $_POST['locale']; ?>' !!!</h1>
  79  
  80      <p>If you think your version of the holidays for '<?php echo $_POST['locale']; ?>' should replace
  81      the existing one, please <a href="<?php echo $_SERVER['HTTP_REFERER']; ?>&download=1">download</a> the file
  82      and <a href="mailto:egroupware-developers@lists.sourceforge.net">mail it</a> to us.</p>
  83  
  84      <p>To get back to your own eGroupWare-install <a href="<?php echo $send_back_to; ?>">click here</a>.</p>
  85  </body>
  86  </html>
  87  <?php
  88      }
  89  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7