web/event_process.php
changeset 988 954019f62866
child 1000 c294569b0725
equal deleted inserted replaced
987:18cb05f027a0 988:954019f62866
       
     1 <?php
       
     2 include_once 'common.php';
       
     3 
       
     4 $user_data = authenticate($C_event_users, $translate);
       
     5 
       
     6 if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
       
     7 	header("Location: ./event_form.php");
       
     8 	exit;
       
     9 }
       
    10 
       
    11 function create_zip($zip_path,$zip_folder, $config_values, $files) {
       
    12     $zip = new ZipArchive;
       
    13     if($zip->open($zip_path, ZipArchive::CREATE) === FALSE) {
       
    14     	return FALSE;
       
    15     }
       
    16     $config_content = "<?php\n\$config = array(\n";
       
    17     foreach ($config_values as $key => $value) {
       
    18         $config_content .= "    '$key' => '$value',\n";
       
    19     }
       
    20     $config_content .= ");\n";
       
    21     
       
    22     $zip->addEmptyDir($event_title);
       
    23     $zip->addFromString("$zip_folder/config.php", $config_content);
       
    24     
       
    25     $zip->addEmptyDir("$event_title/images");
       
    26     foreach ($files as $key => $file_desc) {
       
    27     	if($file_desc['size']>0) {
       
    28             $zip->addFile($file_desc['tmp_name'], "$event_title/images/".$file_desc['name']);
       
    29     	}
       
    30     }
       
    31     
       
    32     return $zip->close();
       
    33 }
       
    34 
       
    35 /**
       
    36  * Modifies a string to remove all non ASCII characters and spaces.
       
    37  */
       
    38 function slugify($text)
       
    39 {
       
    40 	// replace non letter or digits by -
       
    41 	$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
       
    42 
       
    43 	// trim
       
    44 	$text = trim($text, '-');
       
    45 
       
    46 	// transliterate
       
    47 	if (function_exists('iconv'))
       
    48 	{
       
    49 		$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
       
    50 	}
       
    51 
       
    52 	// lowercase
       
    53 	$text = strtolower($text);
       
    54 
       
    55 	// remove unwanted characters
       
    56 	$text = preg_replace('~[^-\w]+~', '', $text);
       
    57 
       
    58 	if (empty($text))
       
    59 	{
       
    60 		return 'n-a';
       
    61 	}
       
    62 
       
    63 	return $text;
       
    64 }
       
    65 
       
    66 ?>
       
    67 
       
    68 <!DOCTYPE html>
       
    69 <html lang="<?php echo($actual); ?>">
       
    70 <head>
       
    71     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
       
    72     <title>Polemic Tweet &mdash; event form</title>
       
    73     <meta http-equiv="X-UA-Compatible" content="IE=9" />
       
    74 
       
    75     <!-- FONT -->
       
    76     <link href='<?php echo(registry_url('PT-Sans_Narrow','font'))?>' rel='stylesheet' type='text/css'>
       
    77     <link href='<?php echo(registry_url('PT-Sans','font'))?>' rel='stylesheet' type='text/css'>
       
    78     
       
    79     <!-- CSS -->
       
    80     <link rel="stylesheet" href="<?php echo(registry_url('blueprint-screen','css'));?>" type="text/css" media="screen, projection"/>
       
    81     <link rel="stylesheet" href="<?php echo(registry_url('blueprint-print','css'));?>" type="text/css" media="print"/>
       
    82     <!--[if lt IE 8]><link rel="stylesheet" href="<?php echo(registry_url('blueprint-ie','css'));?>" type="text/css" media="screen, projection"><![endif]-->
       
    83 	<link rel="stylesheet" href="<?php echo(registry_url('blueprint-plugins-fancy-type','css'));?>" type="text/css" media="screen, projection"/>
       
    84 	<link rel="stylesheet" href="<?php echo(registry_url('custom','css'));?>" type="text/css" media="screen, projection"/>
       
    85     
       
    86     <!-- JAVASCRIPT -->
       
    87     <script type="text/javascript" src="<?php echo(registry_url('jquery','js'))?>"></script>
       
    88     <script type="text/javascript" src="<?php echo(registry_url('underscore','js'))?>"></script>
       
    89     
       
    90     
       
    91 </head>
       
    92 <body>
       
    93 	<div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
       
    94     <div class="container">
       
    95       <img src="images/ENMI_2010_logo.gif" class="logo">
       
    96 	  <ul class="menu">
       
    97 		  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>" class="menuLink">
       
    98 		  	<?php print $translate->_("Accueil"); ?></a></li>
       
    99 		  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>about.php" class="menuLink">
       
   100 		  	<?php print $translate->_("A propos"); ?></a></li>
       
   101 		  <li ><a href="mailto:contact@iri.centrepompidou.fr" class="menuLink" >
       
   102 		  	<?php print $translate->_("Contact"); ?></a></li>
       
   103 	  </ul>
       
   104 	  <ul class="menu">
       
   105 		  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>archives.php" class="menuLink">
       
   106 		  	<?php print $translate->_("Archives"); ?></a></li>
       
   107 		<?php
       
   108 		if($_SESSION['auth']) { ?>
       
   109 		  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>logout.php" class="menuLink">
       
   110 		  	<?php print $translate->_("Logout"); ?></a></li>
       
   111 		<?php
       
   112 		}
       
   113 		?>
       
   114 	  </ul>
       
   115 	  
       
   116 	  
       
   117 	  <ul class="menu lang" >
       
   118 	  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>index.php?lang=ja_JP" class="menuLink" >
       
   119 	       <img src='images/flag_jp.gif'<?php if($actual!="ja_JP"){echo("style='opacity: .5;'"); } ?> />
       
   120 	        <?php print $translate->_("Japonais"); ?></a></li>
       
   121 	  <li class="menuUnderline"><a href="<?php echo(URL_ROOT); ?>index.php?lang=fr" class="menuLink">
       
   122 	       <img src='images/flag_fr.gif' <?php if($actual!="fr"){echo("style='opacity: .5;'"); } ?> />
       
   123 	       <?php print $translate->_("Français"); ?></a></li>
       
   124 	  <li ><a href="<?php echo(URL_ROOT); ?>index.php?lang=en" class="menuLink">
       
   125 	       <img src='images/flag_en.gif' <?php if($actual!="en"){echo("style='opacity: .5;'"); } ?> />
       
   126 	       <?php print $translate->_("Anglais"); ?></a></li>
       
   127 	  </ul>
       
   128 	</div>
       
   129 	<div class="container">
       
   130 	<?php
       
   131 	if(!isset($user_data) || isset($user_data['error'])) {
       
   132 		print "<div class=\"error-message\"><h2>".$user_data['error']."</h2></div>";
       
   133 	}
       
   134 	else {
       
   135 		
       
   136 		
       
   137 		$config_values = array_merge($_POST);
       
   138 		
       
   139 		foreach ($_FILES as $key => $value) {
       
   140 			$config_values[$key] = "images/".basename($value['name']);
       
   141 		}
       
   142 		
       
   143 		$event_title = slugify($config_values['title']);
       
   144 		
       
   145 		$zip_filename = "$C_event_props/$event_title.zip";
       
   146 		
       
   147 		create_zip($zip_filename, $event_title, $config_values, $_FILES);
       
   148 		
       
   149 		print("<div class=\"process-message\">");
       
   150 		print $translate->_("Event_recorded_message");
       
   151 		print("</div>");
       
   152 	}
       
   153 	?>
       
   154 	</div>
       
   155 </body>