web/common.php
changeset 988 954019f62866
parent 985 374aacd1eb0d
child 989 e4e219f7b12c
equal deleted inserted replaced
987:18cb05f027a0 988:954019f62866
    11 );
    11 );
    12 
    12 
    13 /**
    13 /**
    14 * Base configuration
    14 * Base configuration
    15 */
    15 */
       
    16 date_default_timezone_set('UTC');
    16 
    17 
    17 $ldt_platform = 'http://ldt.iri.centrepompidou.fr/';
    18 $ldt_platform = 'http://ldt.iri.centrepompidou.fr/';
    18 $project_url_base = 'ldtplatform/ldt/cljson/id/';
    19 $project_url_base = 'ldtplatform/ldt/cljson/id/';
    19 
    20 
    20 $C_default_rep = 'attention-1314-01-notion-attention';
    21 $C_default_rep = 'attention-1314-01-notion-attention';
    21 $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0';
    22 $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0';
       
    23 $C_event_props = __DIR__ . "/event_props";
       
    24 $C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d'));
    22 
    25 
    23 $archives_list = array(
    26 $archives_list = array(
    24     "rsln", "rsln-opendata", "rsln-mercedes-bunz",
    27     "rsln", "rsln-opendata", "rsln-mercedes-bunz",
    25 	"enmi2011-technologie-confiance", "CPV", array("fens_FabLab_Design_Metadata","fablab"),
    28 	"enmi2011-technologie-confiance", "CPV", array("fens_FabLab_Design_Metadata","fablab"),
    26 array("fens_FabLab_Design_Metadata","designmd"), array("mashup","conference"), array("mashup","tableronde"),
    29 array("fens_FabLab_Design_Metadata","designmd"), array("mashup","conference"), array("mashup","tableronde"),
    55 $req_rep = $C_default_rep;
    58 $req_rep = $C_default_rep;
    56 if(isset($config) && isset($config['rep'])) {
    59 if(isset($config) && isset($config['rep'])) {
    57 	$req_rep = $config['rep'];
    60 	$req_rep = $config['rep'];
    58 }
    61 }
    59 
    62 
    60 include_once dirname(__FILE__).'/traduction.php';
    63 foreach (glob(dirname(__FILE__).'/traductions/*.php') as $trad_filename)
       
    64 {
       
    65 	include_once $trad_filename;
       
    66 }
    61 if(file_exists(dirname(__FILE__)."/$req_rep/traduction.php")) {
    67 if(file_exists(dirname(__FILE__)."/$req_rep/traduction.php")) {
    62 	include_once dirname(__FILE__)."/$req_rep/traduction.php";
    68 	include_once dirname(__FILE__)."/$req_rep/traduction.php";
    63 }
    69 }
    64 
    70 
    65 
    71 
   151 
   157 
   152 $client = new Zend_Http_Client();
   158 $client = new Zend_Http_Client();
   153 $translate = new Zend_Translate('array', $init, 'fr');
   159 $translate = new Zend_Translate('array', $init, 'fr');
   154 
   160 
   155 
   161 
   156 $translate->addTranslation($english, 'en');
   162 $translate->addTranslation($traduction_en, 'en');
   157 $translate->addTranslation($japan, 'ja_JP');
   163 $translate->addTranslation($traduction_ja, 'ja_JP');
   158 $translate->addTranslation($french, 'fr');
   164 $translate->addTranslation($traduction_fr, 'fr');
   159 
   165 
   160 if(isset($config)) {
   166 if(isset($config)) {
   161     
   167     
   162     set_config_translations($config, $translate);
   168     set_config_translations($config, $translate);
   163 //     $config_translations = get_config_translations($config);
   169 //     $config_translations = get_config_translations($config);
   192 }
   198 }
   193 
   199 
   194 $js_registry = array(
   200 $js_registry = array(
   195 	'local' => array(
   201 	'local' => array(
   196 	    'libdir'        => URL_ROOT.'res/js/',
   202 	    'libdir'        => URL_ROOT.'res/js/',
   197 	    'jquery' 		=> URL_ROOT.'res/js/jquery-1.4.3.min.js',
   203 	    'jquery' 		=> URL_ROOT.'res/js/jquery-1.10.2.min.js',
   198 	    'raphael' 		=> URL_ROOT.'res/js/raphael-min.js',
   204 	    'raphael' 		=> URL_ROOT.'res/js/raphael-min.js',
   199 	    'jquery-ui' 	=> URL_ROOT.'res/js/jquery-ui-1.8.13.min.js',
   205 	    'jquery-ui' 	=> URL_ROOT.'res/js/jquery-ui.min.js',
   200 	    'niceforms' 	=> URL_ROOT.'res/js/niceforms.js',
   206 	    'niceforms' 	=> URL_ROOT.'res/js/niceforms.js',
   201 	    'jquery-url' 	=> URL_ROOT.'res/js/jquery.url.js',
   207 	    'jquery-url' 	=> URL_ROOT.'res/js/jquery.url.js',
   202 	    'ldtplayer' 	=> URL_ROOT.'res/metadataplayer/src/js/LdtPlayer.js',
   208 	    'ldtplayer' 	=> URL_ROOT.'res/metadataplayer/src/js/LdtPlayer.js',
   203 		'fancybox' 		=> URL_ROOT.'res/js/fancybox/jquery.fancybox-1.3.4.pack.js',
   209 		'fancybox' 		=> URL_ROOT.'res/js/fancybox/jquery.fancybox.pack.js',
   204 		'jquery-tools' 	=> URL_ROOT.'res/js/jquery.tools.min.js',
   210 		'jquery-tools' 	=> URL_ROOT.'res/js/jquery.tools.min.js',
   205 		'tw-widget' 	=> URL_ROOT.'res/js/tw_widget.js',
   211 		'tw-widget' 	=> URL_ROOT.'res/js/tw_widget.js',
   206 		'jquery-mousewheel' => URL_ROOT.'res/js/jquery.mousewheel-3.0.4.pack.js',
   212 		'jquery-mousewheel' => URL_ROOT.'res/js/jquery.mousewheel.js',
   207 		'swfobject' 	=> URL_ROOT.'res/js/swfobject.js',
   213 		'swfobject' 	=> URL_ROOT.'res/js/swfobject.js',
   208 		'json-js' 		=> URL_ROOT.'res/js/json2.js',
   214 		'json-js' 		=> URL_ROOT.'res/js/json2.js',
   209 		'underscore'    => URL_ROOT.'res/js/underscore-min.js' ,
   215 		'underscore'    => URL_ROOT.'res/js/underscore-min.js' ,
   210         'jquery-scrollto'=>URL_ROOT.'res/js/jquery.scrollTo-1.4.2-min.js' ,
   216         'jquery-scrollto'=>URL_ROOT.'res/js/jquery.scrollTo-1.4.2-min.js' ,
   211         'twcx-main'     => URL_ROOT.'res/js/live-polemic.js' ,
   217         'twcx-main'     => URL_ROOT.'res/js/live-polemic.js' ,
   212         'semanticboard' => URL_ROOT.'res/js/semanticboard.js' ,
   218         'semanticboard' => URL_ROOT.'res/js/semanticboard.js' ,
   213         'metadataplayer'=> URL_ROOT.'res/metadataplayer/LdtPlayer-core.js' ,
   219         'metadataplayer'=> URL_ROOT.'res/metadataplayer/LdtPlayer-core.js' ,
   214         'ldtwidgets'    => URL_ROOT.'res/metadataplayer/' ,
   220         'ldtwidgets'    => URL_ROOT.'res/metadataplayer/' ,
   215         'tracemanager'  => URL_ROOT.'res/js/tracemanager.js' ,
   221         'tracemanager'  => URL_ROOT.'res/js/tracemanager.js' ,
   216         'jwplayer-js'   => URL_ROOT.'res/js/jwplayer.js'
   222         'jwplayer-js'   => URL_ROOT.'res/js/jwplayer.js',
       
   223 		'jquery-te'     => URL_ROOT.'res/js/jquery-te-1.4.0.min.js',
   217 	),
   224 	),
   218 	'cdn' => array(
   225 	'cdn' => array(
   219         'libdir'        => URL_ROOT.'res/js/',
   226         'libdir'        => URL_ROOT.'res/js/',
   220 	    'jquery' 		=> 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js',
   227 	    'jquery' 		=> 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',
   221 		'raphael' 		=> URL_ROOT.'res/js/raphael-min.js',
   228 		'raphael' 		=> URL_ROOT.'res/js/raphael-min.js',
   222 		'jquery-ui' 	=> 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js',
   229 		'jquery-ui' 	=> 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js',
   223 		'niceforms' 	=> URL_ROOT.'res/js/niceforms.js',
   230 		'niceforms' 	=> URL_ROOT.'res/js/niceforms.js',
   224 		'jquery-url' 	=> URL_ROOT.'res/js/jquery.url.js',
   231 		'jquery-url' 	=> URL_ROOT.'res/js/jquery.url.js',
   225 		'ldtplayer' 	=> URL_ROOT.'res/metadataplayer/src/js/LdtPlayer.js',
   232 		'ldtplayer' 	=> URL_ROOT.'res/metadataplayer/src/js/LdtPlayer.js',
   226 		'fancybox' 		=> URL_ROOT.'res/js/fancybox/jquery.fancybox-1.3.4.pack.js',
   233 		'fancybox' 		=> URL_ROOT.'res/js/fancybox/jquery.fancybox.pack.js',
   227 		'jquery-tools' 	=> 'http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js',
   234 		'jquery-tools' 	=> 'http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js',
   228 		'tw-widget' 	=> 'http://widgets.twimg.com/j/2/widget.js',
   235 		'tw-widget' 	=> 'http://widgets.twimg.com/j/2/widget.js',
   229         'jquery-mousewheel' => URL_ROOT.'res/js/jquery.mousewheel-3.0.4.pack.js',
   236         'jquery-mousewheel' => URL_ROOT.'res/js/jquery.mousewheel.js',
   230 		'swfobject' 	=> 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
   237 		'swfobject' 	=> 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
   231         'json-js'       => URL_ROOT.'res/js/json2.js',
   238         'json-js'       => URL_ROOT.'res/js/json2.js',
   232         'underscore'    => URL_ROOT.'res/js/underscore-min.js' ,
   239         'underscore'    => URL_ROOT.'res/js/underscore-min.js' ,
   233         'jquery-scrollto'=>URL_ROOT.'res/js/jquery.scrollTo-1.4.2-min.js' ,
   240         'jquery-scrollto'=>URL_ROOT.'res/js/jquery.scrollTo-1.4.2-min.js' ,
   234         'twcx-main'     => URL_ROOT.'res/js/live-polemic.js' ,
   241         'twcx-main'     => URL_ROOT.'res/js/live-polemic.js' ,
   235         'semanticboard' => URL_ROOT.'res/js/semanticboard.js' ,
   242         'semanticboard' => URL_ROOT.'res/js/semanticboard.js' ,
   236         'metadataplayer'=> URL_ROOT.'res/metadataplayer/LdtPlayer-core.js' ,
   243         'metadataplayer'=> URL_ROOT.'res/metadataplayer/LdtPlayer-core.js' ,
   237         'ldtwidgets'    => URL_ROOT.'res/metadataplayer/' ,
   244         'ldtwidgets'    => URL_ROOT.'res/metadataplayer/' ,
   238         'tracemanager'  => URL_ROOT.'res/js/tracemanager.js' ,
   245         'tracemanager'  => URL_ROOT.'res/js/tracemanager.js' ,
   239         'jwplayer-js'   => URL_ROOT.'res/js/jwplayer.js'
   246         'jwplayer-js'   => URL_ROOT.'res/js/jwplayer.js',
       
   247 		'jquery-te'     => URL_ROOT.'res/js/jquery-te-1.4.0.min.js',
   240 	)
   248 	)
   241 );
   249 );
   242 
   250 
   243 $font_registry = array(
   251 $font_registry = array(
   244 	'local' => array(
   252 	'local' => array(
   257 	   	'blueprint-screen' => URL_ROOT.'res/css/blueprint-screen.css',
   265 	   	'blueprint-screen' => URL_ROOT.'res/css/blueprint-screen.css',
   258 		'blueprint-print' => URL_ROOT.'res/css/blueprint-print.css',
   266 		'blueprint-print' => URL_ROOT.'res/css/blueprint-print.css',
   259 		'blueprint-ie' => URL_ROOT.'res/css/blueprint-ie.css',
   267 		'blueprint-ie' => URL_ROOT.'res/css/blueprint-ie.css',
   260 		'blueprint-plugins-fancy-type' => URL_ROOT.'res/css/blueprint-plugins/fancy-type/screen.css',
   268 		'blueprint-plugins-fancy-type' => URL_ROOT.'res/css/blueprint-plugins/fancy-type/screen.css',
   261 		'custom' => URL_ROOT.'res/css/custom.css',
   269 		'custom' => URL_ROOT.'res/css/custom.css',
   262 		'fancybox' => URL_ROOT.'res/js/fancybox/jquery.fancybox-1.3.4.css',
   270 		'fancybox' => URL_ROOT.'res/js/fancybox/jquery.fancybox.css',
   263 		'jquery-ui' => URL_ROOT.'res/metadataplayer/res/css/jq-css/themes/base/jquery-ui.css',
   271 		'jquery-ui' => URL_ROOT.'res/metadataplayer/res/css/jq-css/themes/base/jquery-ui.css',
   264 		'tabs-slideshow' => URL_ROOT.'res/css/tabs-slideshow.css',
   272 		'tabs-slideshow' => URL_ROOT.'res/css/tabs-slideshow.css',
   265 		'tweetcast' => URL_ROOT.'res/css/tweetcast.css',
   273 		'tweetcast' => URL_ROOT.'res/css/tweetcast.css',
   266 		'semanticboard' =>  URL_ROOT.'res/css/semanticboard.css',
   274 		'semanticboard' =>  URL_ROOT.'res/css/semanticboard.css',
   267         'archives-iframe' => URL_ROOT.'res/css/archives-iframe.css',
   275         'archives-iframe' => URL_ROOT.'res/css/archives-iframe.css',
   268         'metadataplayer' => URL_ROOT.'res/metadataplayer/LdtPlayer-core.css',
   276         'metadataplayer' => URL_ROOT.'res/metadataplayer/LdtPlayer-core.css',
       
   277 		'jquery-te' => URL_ROOT.'res/css/jquery-te.css',
   269 	),
   278 	),
   270 	'cdn' => array(
   279 	'cdn' => array(
   271 		'blueprint-screen' => URL_ROOT.'res/css/blueprint-screen.css',
   280 		'blueprint-screen' => URL_ROOT.'res/css/blueprint-screen.css',
   272 		'blueprint-print' => URL_ROOT.'res/css/blueprint-print.css',
   281 		'blueprint-print' => URL_ROOT.'res/css/blueprint-print.css',
   273 		'blueprint-ie' => URL_ROOT.'res/css/blueprint-ie.css',
   282 		'blueprint-ie' => URL_ROOT.'res/css/blueprint-ie.css',
   274 		'blueprint-plugins-fancy-type' => URL_ROOT.'res/css/blueprint-plugins/fancy-type/screen.css',
   283 		'blueprint-plugins-fancy-type' => URL_ROOT.'res/css/blueprint-plugins/fancy-type/screen.css',
   275 		'custom' => URL_ROOT.'res/css/custom.css',
   284 		'custom' => URL_ROOT.'res/css/custom.css',
   276 		'fancybox' => URL_ROOT.'res/js/fancybox/jquery.fancybox-1.3.4.css',
   285 		'fancybox' => URL_ROOT.'res/js/fancybox/jquery.fancybox.css',
   277 		'jquery-ui' => "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/base/jquery-ui.css",
   286 		'jquery-ui' => "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/base/jquery-ui.css",
   278 		'tabs-slideshow' => URL_ROOT.'res/css/tabs-slideshow.css',
   287 		'tabs-slideshow' => URL_ROOT.'res/css/tabs-slideshow.css',
   279         'tweetcast' => URL_ROOT.'res/css/tweetcast.css',
   288         'tweetcast' => URL_ROOT.'res/css/tweetcast.css',
   280         'semanticboard' =>  URL_ROOT.'res/css/semanticboard.css',
   289         'semanticboard' =>  URL_ROOT.'res/css/semanticboard.css',
   281         'archives-iframe' => URL_ROOT.'res/css/archives-iframe.css',
   290         'archives-iframe' => URL_ROOT.'res/css/archives-iframe.css',
   282         'metadataplayer' => URL_ROOT.'res/metadataplayer/LdtPlayer-core.css',
   291         'metadataplayer' => URL_ROOT.'res/metadataplayer/LdtPlayer-core.css',
       
   292 		'jquery-te' => URL_ROOT.'res/css/jquery-te.css',
   283 	)
   293 	)
   284 );
   294 );
   285 
   295 
   286 
   296 
   287 function registry_url($key, $type, $registry_def=null) {
   297 function registry_url($key, $type, $registry_def=null) {
   387         return $metadata;
   397         return $metadata;
   388     } else {
   398     } else {
   389         return get_metadata_url($metadata);
   399         return get_metadata_url($metadata);
   390     }
   400     }
   391 }
   401 }
       
   402 
       
   403 
       
   404 $realm = 'Polemictweet restricted area';
       
   405 
       
   406 function authenticate($users, $translate) {
       
   407 
       
   408 	global $realm;
       
   409 	
       
   410 	if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
       
   411 		$_SESSION['http_digest_nonce'] = uniqid();
       
   412 		header('HTTP/1.1 401 Unauthorized');
       
   413 		header('WWW-Authenticate: Digest realm="'.$realm.
       
   414 		'",qop="auth",nonce="'.$_SESSION['http_digest_nonce'].'",opaque="'.md5($realm).'"');
       
   415 
       
   416 		return array('error' => $translate->_('This area is restricted, please authenticate'));
       
   417 	}
       
   418 
       
   419 
       
   420 	//analyze the PHP_AUTH_DIGEST variable
       
   421 	if (!($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) ||
       
   422 		!isset($users[$data['username']])) {
       
   423 		$_SERVER['PHP_AUTH_DIGEST'] = '';
       
   424 		return array('error' => $translate->_('Wrong Credentials!'));
       
   425 	}
       
   426 
       
   427 
       
   428 	//generate the valid response
       
   429 	$A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
       
   430 	$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']);
       
   431 	$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
       
   432 
       
   433 	if ($data['response'] != $valid_response) {
       
   434 		$_SERVER['PHP_AUTH_DIGEST'] = '';
       
   435 		return array('error' => $translate->_('Wrong Credentials!'));
       
   436 	}
       
   437 
       
   438 	// ok, valid username & password
       
   439 	$_SESSION['auth'] = $data;
       
   440 	return $data;
       
   441 }
       
   442 
       
   443 function logout() {
       
   444 	global $realm;
       
   445 	
       
   446 	$_SESSION['auth'] = null;
       
   447 	header('HTTP/1.1 401 Unauthorized');
       
   448 	header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$_SESSION['http_digest_nonce'].'",opaque="'.md5($realm).'"');
       
   449 }
       
   450 
       
   451 
       
   452 //function to parse the http auth header
       
   453 function http_digest_parse($txt)
       
   454 {
       
   455 	// protect against missing data
       
   456 	$needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
       
   457 	$data = array();
       
   458 	$keys = implode('|', array_keys($needed_parts));
       
   459 
       
   460 	preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
       
   461 
       
   462 	foreach ($matches as $m) {
       
   463 		$data[$m[1]] = $m[3] ? $m[3] : $m[4];
       
   464 		unset($needed_parts[$m[1]]);
       
   465 	}
       
   466 
       
   467 	return $needed_parts ? false : $data;
       
   468 }