<?php
/************************************************************
* *
* Pindorama Core Configuration v. 0.11 *
* Guilherme Capilé <hide@address.com> *
* *
************************************************************/
global $c, $arg, $param, $l;
function publish_files ($file_arr, $data_arr, $mask = "0664")
{
global $xmlrpc_r, $base_export, $c, $l, $xmlrpc_t;
$hostname = $c["host"];
$base_export = $c["xmlrpc_s"]["document_root"];
//touch($base_export."/tmp");
$files = "";
if (is_array($file_arr) && count($file_arr) == count($data_arr)) {
$i = 0;
foreach ($file_arr as $file) {
if ($file != "" && $data_arr[$i] != "") {
if (substr($file, 0, 1) != "/") {
$file = "/".$file;
}
if (check_dir($file)) {
$fp = @fopen ($base_export.$file, "wb") or die(xmlrpc_error(3, $hostname.": ".$l["xmlrpc"]["publish_error"].$file));
fwrite($fp, $data_arr[$i]);
fclose($fp);
if ($mask != "") {
@chmod ($base_export.$file, $mask);
}
$files .= ", $file";
}
}
$i++;
}
} else {
echo xmlrpc_error (3, $l["xmlrpc"]["publish_nofiles"]);
}
if ($files != "") {
$xmlrpc_r = array("result" => TRUE, "msg"=>substr($files, 2));
return true;
} else {
return false;
}
}
function check_dir($path) {
global $base_export;
$pre_dir = "";
$filename = basename($path);
$temp = split ("/", $path);
foreach ($temp as $dir) {
$pre_dir = $pre_dir.$dir;
if ($dir == $filename) {
return true;
exit;
} elseif (!is_dir($base_export.$pre_dir)) {
$old_umask = umask(0);
if (!@mkdir($base_export.$pre_dir, 0775)){
xmlrpc_error(3, $l["xmlrpc"]["publish_folder"].$base_export.$pre_dir.$l["xmlrpc"]["publish_notcreated"]);
return false;
exit;
}
$pre_dir = $pre_dir."/";
} else {
$pre_dir = $pre_dir."/";
}
}
}
?>