12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- // iniettori metadati - cesco@ventuordici.org - arav2010
- //punto di iniezione
- function store_md_array($data, $obj_rel_path){
- $obj_abs_path = $GLOBALS["conf"]["data_basedir"].$obj_rel_path;
- if(is_file($obj_abs_path)){
- // incapsulamenti matchati a seconda delle estensioni...
- if(preg_match("/\.oga$|\.ogv$|\.ogg$/i",$obj_abs_path)){
- store_ogg_md($data,$obj_abs_path);
- }
- elseif(preg_match("/\.webm$|\.mkv$/i",$obj_abs_path)){
- // quando webm di merda supportera' i metadati
- }
- else{
- report(2,"$obj_abs_path file has illegal extension.");
- }
- }
- elseif(is_dir($obj_abs_path)){
- // metadati dir
- store_dir_md($data,$obj_abs_path);
- }
- else{
- report(2,"what is $obj_abs_path ?");
- // oppss
- }
- }
- // scrivi metadata sugli ogg
- function store_ogg_md($data,$obj_abs_path) {
- if(file_exists($obj_abs_path) AND is_file($obj_abs_path)){
- $wristri = "";
- foreach ($data as $key => $value) {
- if ($value == "") continue;
- $wristri .= " -t ".escapeshellarg($key."=".$value);
- }
- $writcom = escapeshellcmd($GLOBALS["conf"]["executables"]["vorbiscomment"])." -wR ".escapeshellarg($obj_abs_path)." $wristri";
- report(1, "AAAA ".$writcom);
- shell_exec($writcom);
- }
- }
- // scrivi metadata delle directory
- function store_dir_md($data,$obj_abs_path){
- if(file_exists($obj_abs_path) AND is_dir($obj_abs_path)){
- $dirmdfile = $obj_abs_path."/".$GLOBALS["conf"]["dirmetadatafile"];
- $fp = fopen($dirmdfile, 'w');
- foreach ($data as $key => $value) {
- $value = stripslashes($value);
- if (trim($key) == "" or trim($value) == "") continue;
- $argo = trim($key)."=".trim($value);
- fwrite($fp, $argo);
- }
- fclose($fp);
- } else {
- report(2,"$obj_abs_path is not a folder!");
- }
-
- }
- ?>
|